-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable checkbox column roe selection in Table (#1329)
* enable checkbox column roe selection in Table * fix type issue
- Loading branch information
Showing
13 changed files
with
154 additions
and
21 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
2 changes: 1 addition & 1 deletion
2
vuu-ui/packages/vuu-table/src/cell-renderers/checkbox-cell/CheckboxCell.tsx
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
5 changes: 5 additions & 0 deletions
5
...i/packages/vuu-table/src/cell-renderers/checkbox-row-selector/CheckboxRowSelectorCell.css
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,5 @@ | ||
.vuuTableCell { | ||
.vuuCheckboxRowSelectorIcon { | ||
margin-top: calc(var(--row-height) / 2 - 6px ); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...i/packages/vuu-table/src/cell-renderers/checkbox-row-selector/CheckboxRowSelectorCell.tsx
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,32 @@ | ||
import { TableCellRendererProps } from "@finos/vuu-table-types"; | ||
import { isRowSelected, registerComponent } from "@finos/vuu-utils"; | ||
import { Checkbox } from "@salt-ds/core"; | ||
import { useComponentCssInjection } from "@salt-ds/styles"; | ||
import { useWindow } from "@salt-ds/window"; | ||
|
||
import checkboxRowSelectorCss from "./CheckboxRowSelectorCell.css"; | ||
|
||
export const CheckboxRowSelectorCell: React.FC<TableCellRendererProps> = ({ | ||
row, | ||
}) => { | ||
const targetWindow = useWindow(); | ||
useComponentCssInjection({ | ||
testId: "vuu-checkbox-row-selector-cell", | ||
css: checkboxRowSelectorCss, | ||
window: targetWindow, | ||
}); | ||
|
||
const isChecked = isRowSelected(row); | ||
|
||
return <Checkbox checked={isChecked} className="vuuCheckboxRowSelector" />; | ||
}; | ||
CheckboxRowSelectorCell.displayName = "CheckboxCell"; | ||
|
||
registerComponent( | ||
"checkbox-row-selector-cell", | ||
CheckboxRowSelectorCell, | ||
"cell-renderer", | ||
{ | ||
serverDataType: "boolean", | ||
} | ||
); |
1 change: 1 addition & 0 deletions
1
vuu-ui/packages/vuu-table/src/cell-renderers/checkbox-row-selector/index.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 @@ | ||
export * from "./CheckboxRowSelectorCell"; |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./checkbox-cell"; | ||
export * from "./checkbox-row-selector"; | ||
export * from "./input-cell"; | ||
export * from "./toggle-cell"; |
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
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
45 changes: 45 additions & 0 deletions
45
vuu-ui/showcase/src/examples/Table/TableSelection.examples.tsx
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,45 @@ | ||
import { getSchema, SimulTableName, vuuModule } from "@finos/vuu-data-test"; | ||
import { Table, TableProps } from "@finos/vuu-table"; | ||
import { useCallback, useMemo } from "react"; | ||
|
||
import "./Table.examples.css"; | ||
|
||
let displaySequence = 1; | ||
|
||
export const CheckboxSelection = () => { | ||
const tableProps = useMemo< | ||
Pick<TableProps, "config" | "dataSource" | "selectionModel"> | ||
>(() => { | ||
const tableName: SimulTableName = "instruments"; | ||
return { | ||
config: { | ||
columns: getSchema(tableName).columns, | ||
rowSeparators: true, | ||
zebraStripes: true, | ||
}, | ||
dataSource: | ||
vuuModule<SimulTableName>("SIMUL").createDataSource(tableName), | ||
selectionModel: "checkbox", | ||
}; | ||
}, []); | ||
|
||
const onSelect = useCallback((row) => { | ||
console.log("onSelect", { row }); | ||
}, []); | ||
const onSelectionChange = useCallback((selected) => { | ||
console.log("onSelectionChange", { selected }); | ||
}, []); | ||
|
||
return ( | ||
<Table | ||
{...tableProps} | ||
height={645} | ||
navigationStyle="row" | ||
renderBufferSize={5} | ||
onSelect={onSelect} | ||
onSelectionChange={onSelectionChange} | ||
width={723} | ||
/> | ||
); | ||
}; | ||
CheckboxSelection.displaySequence = displaySequence++; |
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