-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Integrate col mgmt modal feature with table hooks
Signed-off-by: Ian Bolton <[email protected]>
- Loading branch information
1 parent
4f54b05
commit e2a0503
Showing
33 changed files
with
388 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
client/src/app/hooks/table-controls/column/useColumnState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useLocalStorage } from "@migtools/lib-ui"; | ||
|
||
export interface ColumnState<TColumnKey extends string> { | ||
id: TColumnKey; | ||
label: string; | ||
isVisible: boolean; | ||
} | ||
|
||
export interface IColumnState<TColumnKey extends string> { | ||
columns: ColumnState<TColumnKey>[]; | ||
setColumns: (newColumns: ColumnState<TColumnKey>[]) => void; | ||
} | ||
|
||
interface IColumnStateArgs<TColumnKey extends string> { | ||
initialColumns: ColumnState<TColumnKey>[]; | ||
columnsKey: string; | ||
} | ||
|
||
export const useColumnState = <TColumnKey extends string>( | ||
args: IColumnStateArgs<TColumnKey> | ||
): IColumnState<TColumnKey> => { | ||
const [columns, setColumns] = useLocalStorage<ColumnState<TColumnKey>[]>({ | ||
key: args.columnsKey, | ||
defaultValue: args.initialColumns, | ||
}); | ||
|
||
return { columns, setColumns }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.