@wallarm-org/design-system 1.17.0 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Table/TableContext/TableProvider.js +6 -2
- package/dist/components/Table/TableContext/types.d.ts +2 -0
- package/dist/components/Table/lib/createSelectionColumn.js +7 -2
- package/dist/components/Table/types.d.ts +22 -0
- package/dist/metadata/components.json +18 -2
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ const toTanStackPinning = (p, pinnedLeft)=>({
|
|
|
15
15
|
end: p?.right ?? []
|
|
16
16
|
});
|
|
17
17
|
const TableProvider = (props)=>{
|
|
18
|
-
const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, columnGroups, virtualized, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onRowReorder, onMasterCellClick, activeRowId: activeRowIdProp, onSettingsOpenChange } = props;
|
|
18
|
+
const { data, columns, isLoading = false, isLoadingPrevious = false, skeletonCount = TABLE_SKELETON_ROWS, children, getRowId, sorting: sortingProp, onSortingChange, manualSorting = false, rowSelection: rowSelectionProp, onRowSelectionChange, enableSelectAllRows = true, onSelectAllRows, columnSizing: columnSizingProp, onColumnSizingChange, columnPinning: columnPinningProp, onColumnPinningChange, columnOrder: columnOrderProp, onColumnOrderChange, grouping: groupingProp, onGroupingChange, expanded: expandedProp, onExpandedChange, renderGroupRow, getSubRows, renderExpandedRow, columnVisibility: columnVisibilityProp, onColumnVisibilityChange, defaultColumnVisibility, defaultColumnOrder, columnGroups, virtualized, estimateRowHeight, overscan = TABLE_VIRTUALIZATION_OVERSCAN, onEndReached, onEndReachedThreshold, onStartReached, onStartReachedThreshold, initialScrollToRowId, onRowReorder, onMasterCellClick, activeRowId: activeRowIdProp, onSettingsOpenChange } = props;
|
|
19
19
|
const masterCellActiveRowId = activeRowIdProp ?? null;
|
|
20
20
|
const sortingEnabled = !!onSortingChange;
|
|
21
21
|
const selectionEnabled = !!onRowSelectionChange;
|
|
@@ -213,6 +213,8 @@ const TableProvider = (props)=>{
|
|
|
213
213
|
alwaysPinnedLeft,
|
|
214
214
|
masterColumnId,
|
|
215
215
|
lastSelectedRowIndexRef,
|
|
216
|
+
selectAllRowsEnabled: enableSelectAllRows,
|
|
217
|
+
onSelectAllRows,
|
|
216
218
|
containerRef,
|
|
217
219
|
tbodyRef,
|
|
218
220
|
virtualizerRef,
|
|
@@ -259,7 +261,9 @@ const TableProvider = (props)=>{
|
|
|
259
261
|
onRowReorder,
|
|
260
262
|
masterCellActiveRowId,
|
|
261
263
|
onMasterCellClick,
|
|
262
|
-
onSettingsOpenChange
|
|
264
|
+
onSettingsOpenChange,
|
|
265
|
+
enableSelectAllRows,
|
|
266
|
+
onSelectAllRows
|
|
263
267
|
]);
|
|
264
268
|
useEffect(()=>{
|
|
265
269
|
if (!selectionEnabled) return;
|
|
@@ -34,6 +34,8 @@ export interface TableContextValue<T extends RowData> {
|
|
|
34
34
|
columnGroups?: TableColumnGroup[];
|
|
35
35
|
setColumnOrder: (order: string[]) => void;
|
|
36
36
|
lastSelectedRowIndexRef: RefObject<number | null>;
|
|
37
|
+
selectAllRowsEnabled: boolean;
|
|
38
|
+
onSelectAllRows?: (selected: boolean) => void;
|
|
37
39
|
alwaysPinnedLeft: string[];
|
|
38
40
|
masterColumnId: string | null;
|
|
39
41
|
containerRef: RefObject<HTMLDivElement | null>;
|
|
@@ -42,7 +42,7 @@ const SelectionCell = ({ row, table })=>{
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
const SelectAllHeaderCell = (_props)=>{
|
|
45
|
-
const { table } = useTableContext();
|
|
45
|
+
const { table, selectAllRowsEnabled, onSelectAllRows } = useTableContext();
|
|
46
46
|
const checked = table.getIsAllRowsSelected();
|
|
47
47
|
const { selectableCount, selectedCount } = table.getFilteredRowModel().flatRows.reduce((acc, row)=>{
|
|
48
48
|
if (!row.getCanSelect()) return acc;
|
|
@@ -54,9 +54,14 @@ const SelectAllHeaderCell = (_props)=>{
|
|
|
54
54
|
selectedCount: 0
|
|
55
55
|
});
|
|
56
56
|
const indeterminate = !checked && selectedCount > 0;
|
|
57
|
+
if (!selectAllRowsEnabled) return null;
|
|
58
|
+
const handleCheckedChange = ()=>{
|
|
59
|
+
table.toggleAllRowsSelected(!checked);
|
|
60
|
+
onSelectAllRows?.(!checked);
|
|
61
|
+
};
|
|
57
62
|
return /*#__PURE__*/ jsx(Checkbox, {
|
|
58
63
|
checked: indeterminate ? 'indeterminate' : checked,
|
|
59
|
-
onCheckedChange:
|
|
64
|
+
onCheckedChange: handleCheckedChange,
|
|
60
65
|
disabled: 0 === selectableCount,
|
|
61
66
|
children: /*#__PURE__*/ jsx(CheckboxIndicator, {})
|
|
62
67
|
});
|
|
@@ -190,6 +190,28 @@ export interface TableProps<T> extends TestableProps {
|
|
|
190
190
|
manualSorting?: boolean;
|
|
191
191
|
rowSelection?: TableRowSelectionState;
|
|
192
192
|
onRowSelectionChange?: TableOnChangeFn<TableRowSelectionState>;
|
|
193
|
+
/**
|
|
194
|
+
* Renders the master checkbox in the selection column header.
|
|
195
|
+
*
|
|
196
|
+
* Set `false` when "all rows" is not a selection the consumer can act on —
|
|
197
|
+
* a listing whose scope the consumer cannot express, for instance — leaving
|
|
198
|
+
* per-row checkboxes (shift-click range selection included) as the only way
|
|
199
|
+
* to select. The column itself stays, so the layout does not shift.
|
|
200
|
+
*
|
|
201
|
+
* Default: `true`.
|
|
202
|
+
*/
|
|
203
|
+
enableSelectAllRows?: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* Called when the master checkbox is toggled, with its new state, in
|
|
206
|
+
* addition to the `onRowSelectionChange` the toggle produces.
|
|
207
|
+
*
|
|
208
|
+
* The state change alone cannot identify the gesture: "every loaded row is
|
|
209
|
+
* selected" is also what checking the last row by hand produces. A consumer
|
|
210
|
+
* that treats the master checkbox as meaning more than the loaded rows —
|
|
211
|
+
* everything matching a server-side filter, say — needs to know the
|
|
212
|
+
* difference, which is what this reports.
|
|
213
|
+
*/
|
|
214
|
+
onSelectAllRows?: (selected: boolean) => void;
|
|
193
215
|
columnSizing?: TableColumnSizingState;
|
|
194
216
|
onColumnSizingChange?: TableOnChangeFn<TableColumnSizingState>;
|
|
195
217
|
columnPinning?: TableColumnPinningState;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
3
|
-
"generatedAt": "2026-09-
|
|
2
|
+
"version": "1.17.0",
|
|
3
|
+
"generatedAt": "2026-09-08T11:38:56.199Z",
|
|
4
4
|
"components": [
|
|
5
5
|
{
|
|
6
6
|
"name": "Accordion",
|
|
@@ -79002,6 +79002,12 @@
|
|
|
79002
79002
|
"type": "TableRowSelectionState | undefined",
|
|
79003
79003
|
"required": false
|
|
79004
79004
|
},
|
|
79005
|
+
{
|
|
79006
|
+
"name": "enableSelectAllRows",
|
|
79007
|
+
"type": "boolean | undefined",
|
|
79008
|
+
"required": false,
|
|
79009
|
+
"description": "Renders the master checkbox in the selection column header.\n\nSet `false` when \"all rows\" is not a selection the consumer can act on —\na listing whose scope the consumer cannot express, for instance — leaving\nper-row checkboxes (shift-click range selection included) as the only way\nto select. The column itself stays, so the layout does not shift.\n\nDefault: `true`."
|
|
79010
|
+
},
|
|
79005
79011
|
{
|
|
79006
79012
|
"name": "columnSizing",
|
|
79007
79013
|
"type": "TableColumnSizingState | undefined",
|
|
@@ -85141,6 +85147,16 @@
|
|
|
85141
85147
|
"code": "() => {\n const [rowSelection, setRowSelection] = useState<TableRowSelectionState>({});\n\n return (\n <Table\n data={securityEvents}\n columns={securityColumns}\n getRowId={row => row.id}\n rowSelection={rowSelection}\n onRowSelectionChange={setRowSelection}\n >\n <TableActionBar>\n <Button variant='ghost' color='neutral-alt' onClick={onDuplicate}>\n <Copy /> Duplicate\n </Button>\n <Button color='brand' onClick={onDelete}>\n <Trash2 /> Delete\n </Button>\n </TableActionBar>\n </Table>\n );\n}",
|
|
85142
85148
|
"description": "Checkboxes plus `TableActionBar`, which rises from the bottom once a row is ticked and\ncarries the verbs that apply to the whole selection."
|
|
85143
85149
|
},
|
|
85150
|
+
{
|
|
85151
|
+
"name": "SelectAllRowsGesture",
|
|
85152
|
+
"code": "() => {\n const [rowSelection, setRowSelection] = useState<TableRowSelectionState>({});\n const [filterWide, setFilterWide] = useState(false);\n const MATCHING_THE_FILTER = 1474;\n\n const selectedCount = filterWide ? MATCHING_THE_FILTER : Object.keys(rowSelection).length;\n\n return (\n <Table\n data={securityEvents}\n columns={securityColumns}\n getRowId={row => row.id}\n rowSelection={rowSelection}\n onRowSelectionChange={updater => {\n setRowSelection(updater);\n // \"Everything matching the filter, minus this one row\" is not a filter,\n // so any hand-made change falls back to the explicit list.\n setFilterWide(false);\n }}\n onSelectAllRows={setFilterWide}\n >\n <TableActionBar>\n <TableActionBarSelection>\n <BulkBarSummaryCount>\n {selectedCount} {selectedCount === 1 ? 'event' : 'events'} selected\n </BulkBarSummaryCount>\n <BulkBarSummaryClear />\n </TableActionBarSelection>\n <Button color='brand' onClick={onDelete}>\n <Trash2 /> Delete\n </Button>\n </TableActionBar>\n </Table>\n );\n}",
|
|
85153
|
+
"description": "`onSelectAllRows` separates the master checkbox from a hand-made full selection, which the\nrow state alone cannot tell apart. Here the gesture means \"every row matching the filter\",\nincluding the ones the server has not sent — so the bar jumps to the filter's total, and any\nmanual change drops back to the rows actually loaded."
|
|
85154
|
+
},
|
|
85155
|
+
{
|
|
85156
|
+
"name": "SelectAllRowsDisabled",
|
|
85157
|
+
"code": "() => {\n const [rowSelection, setRowSelection] = useState<TableRowSelectionState>({});\n\n return (\n <Table\n data={securityEvents}\n columns={securityColumns}\n getRowId={row => row.id}\n rowSelection={rowSelection}\n onRowSelectionChange={setRowSelection}\n enableSelectAllRows={false}\n />\n );\n}",
|
|
85158
|
+
"description": "`enableSelectAllRows={false}` drops the master checkbox while keeping the column, for a\nlisting where \"all rows\" is not a scope the consumer can act on. Per-row checkboxes stay,\nshift-click range selection included."
|
|
85159
|
+
},
|
|
85144
85160
|
{
|
|
85145
85161
|
"name": "RowSelectionWindowScroll",
|
|
85146
85162
|
"code": "() => {\n const largeData = useMemo(() => createLargeSecurityEvents(100), []);\n const [rowSelection, setRowSelection] = useState<TableRowSelectionState>({});\n\n return (\n <>\n <Table\n data-testid='row-selection-window-scroll-table'\n data={largeData}\n columns={securityColumns}\n getRowId={row => row.id}\n virtualized='window'\n rowSelection={rowSelection}\n onRowSelectionChange={setRowSelection}\n >\n <TableActionBar>\n <Button variant='ghost' color='neutral-alt' onClick={onDuplicate}>\n <Copy /> Duplicate\n </Button>\n <Button color='brand' onClick={onDelete}>\n <Trash2 /> Delete\n </Button>\n </TableActionBar>\n </Table>\n {/* Filler so the e2e suite can scroll the table fully out of view while a\n selection stays active — this story's only content otherwise fills\n exactly to the table's own height, so max scroll would always leave\n the table's tail in view. Generous margin over the viewport height\n (800px in the e2e config) so the anchor is unambiguously out of view\n at max scroll, not just mostly. */}\n <div style={{ height: 3000 }} />\n </>\n );\n}",
|