@navikt/ds-react 8.10.5 → 8.11.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/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +0 -1
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.d.ts +6 -6
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +6 -29
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/cjs/data/stories/Data.test-data.d.ts +3 -6
- package/cjs/data/stories/Data.test-data.js +46 -59
- package/cjs/data/stories/Data.test-data.js.map +1 -1
- package/cjs/data/table/base-cell/DataTableBaseCell.d.ts +18 -18
- package/cjs/data/table/base-cell/DataTableBaseCell.js +4 -8
- package/cjs/data/table/base-cell/DataTableBaseCell.js.map +1 -1
- package/cjs/data/table/column-header/DataTableColumnHeader.d.ts +19 -13
- package/cjs/data/table/column-header/DataTableColumnHeader.js +26 -28
- package/cjs/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/cjs/data/table/column-header/useTableColumnResize.d.ts +19 -29
- package/cjs/data/table/column-header/useTableColumnResize.js +30 -28
- package/cjs/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +1 -1
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js +2 -2
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -1
- package/cjs/data/table/helpers/collectTableRowEntries.d.ts +2 -2
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.d.ts +14 -11
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js +45 -51
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/getSingleSelectProps.d.ts +9 -8
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js +23 -10
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/selection.types.d.ts +24 -32
- package/cjs/data/table/helpers/selection/selection.utils.d.ts +21 -0
- package/cjs/data/table/helpers/selection/selection.utils.js +46 -0
- package/cjs/data/table/helpers/selection/selection.utils.js.map +1 -0
- package/cjs/data/table/hooks/useColumnOptions.d.ts +17 -6
- package/cjs/data/table/hooks/useColumnOptions.js +26 -8
- package/cjs/data/table/hooks/useColumnOptions.js.map +1 -1
- package/cjs/data/table/hooks/useTableDetailsPanel.d.ts +10 -14
- package/cjs/data/table/hooks/useTableDetailsPanel.js +6 -5
- package/cjs/data/table/hooks/useTableDetailsPanel.js.map +1 -1
- package/cjs/data/table/hooks/useTableItems.d.ts +32 -19
- package/cjs/data/table/hooks/useTableItems.js +13 -15
- package/cjs/data/table/hooks/useTableItems.js.map +1 -1
- package/cjs/data/table/hooks/useTableKeyboardNav.d.ts +1 -6
- package/cjs/data/table/hooks/useTableKeyboardNav.js +1 -4
- package/cjs/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/table/hooks/useTableSelection.d.ts +7 -6
- package/cjs/data/table/hooks/useTableSelection.js +52 -35
- package/cjs/data/table/hooks/useTableSelection.js.map +1 -1
- package/cjs/data/table/hooks/useTableSort.d.ts +15 -9
- package/cjs/data/table/hooks/useTableSort.js +9 -11
- package/cjs/data/table/hooks/useTableSort.js.map +1 -1
- package/cjs/data/table/index.d.ts +1 -1
- package/cjs/data/table/index.js +3 -23
- package/cjs/data/table/index.js.map +1 -1
- package/cjs/data/table/root/DataGridTable.types.d.ts +65 -0
- package/cjs/data/table/root/DataGridTable.types.js +3 -0
- package/cjs/data/table/root/DataGridTable.types.js.map +1 -0
- package/cjs/data/table/root/DataGridTableRoot.d.ts +104 -0
- package/cjs/data/table/root/DataGridTableRoot.js +237 -0
- package/cjs/data/table/root/DataGridTableRoot.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.context.d.ts +17 -7
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js +4 -4
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -1
- package/cjs/data/table/tbody/DataTableTbody.js +4 -2
- package/cjs/data/table/tbody/DataTableTbody.js.map +1 -1
- package/cjs/data/table/tr/DataTableTr.d.ts +7 -5
- package/cjs/data/table/tr/DataTableTr.js +69 -32
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/data/token-filter/TokenFilter.d.ts +0 -6
- package/cjs/data/token-filter/TokenFilter.js +1 -1
- package/cjs/data-grid/index.d.ts +2 -0
- package/cjs/data-grid/index.js +9 -0
- package/cjs/data-grid/index.js.map +1 -0
- package/cjs/data-grid/root/DataGrid.types.d.ts +35 -0
- package/cjs/{data/table/root/DataTable.types.js → data-grid/root/DataGrid.types.js} +1 -1
- package/cjs/data-grid/root/DataGrid.types.js.map +1 -0
- package/cjs/data-grid/root/DataGridRoot.context.d.ts +16 -0
- package/cjs/data-grid/root/DataGridRoot.context.js +11 -0
- package/cjs/data-grid/root/DataGridRoot.context.js.map +1 -0
- package/cjs/data-grid/root/DataGridRoot.d.ts +89 -0
- package/cjs/data-grid/root/DataGridRoot.js +93 -0
- package/cjs/data-grid/root/DataGridRoot.js.map +1 -0
- package/cjs/preview.d.ts +1 -0
- package/cjs/preview.js +7 -0
- package/cjs/preview.js.map +1 -0
- package/cjs/table/ColumnHeader.js +2 -1
- package/cjs/table/ColumnHeader.js.map +1 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +0 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/esm/data/drag-and-drop/root/DragAndDropRoot.d.ts +6 -6
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js +6 -29
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/esm/data/stories/Data.test-data.d.ts +3 -6
- package/esm/data/stories/Data.test-data.js +46 -59
- package/esm/data/stories/Data.test-data.js.map +1 -1
- package/esm/data/table/base-cell/DataTableBaseCell.d.ts +18 -18
- package/esm/data/table/base-cell/DataTableBaseCell.js +4 -8
- package/esm/data/table/base-cell/DataTableBaseCell.js.map +1 -1
- package/esm/data/table/column-header/DataTableColumnHeader.d.ts +19 -13
- package/esm/data/table/column-header/DataTableColumnHeader.js +27 -29
- package/esm/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/esm/data/table/column-header/useTableColumnResize.d.ts +19 -29
- package/esm/data/table/column-header/useTableColumnResize.js +30 -28
- package/esm/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +1 -1
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js +2 -2
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -1
- package/esm/data/table/helpers/collectTableRowEntries.d.ts +2 -2
- package/esm/data/table/helpers/selection/getMultipleSelectProps.d.ts +14 -11
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js +45 -51
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/getSingleSelectProps.d.ts +9 -8
- package/esm/data/table/helpers/selection/getSingleSelectProps.js +23 -10
- package/esm/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/selection.types.d.ts +24 -32
- package/esm/data/table/helpers/selection/selection.utils.d.ts +21 -0
- package/esm/data/table/helpers/selection/selection.utils.js +43 -0
- package/esm/data/table/helpers/selection/selection.utils.js.map +1 -0
- package/esm/data/table/hooks/useColumnOptions.d.ts +17 -6
- package/esm/data/table/hooks/useColumnOptions.js +26 -8
- package/esm/data/table/hooks/useColumnOptions.js.map +1 -1
- package/esm/data/table/hooks/useTableDetailsPanel.d.ts +10 -14
- package/esm/data/table/hooks/useTableDetailsPanel.js +6 -5
- package/esm/data/table/hooks/useTableDetailsPanel.js.map +1 -1
- package/esm/data/table/hooks/useTableItems.d.ts +32 -19
- package/esm/data/table/hooks/useTableItems.js +14 -13
- package/esm/data/table/hooks/useTableItems.js.map +1 -1
- package/esm/data/table/hooks/useTableKeyboardNav.d.ts +1 -6
- package/esm/data/table/hooks/useTableKeyboardNav.js +1 -4
- package/esm/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/esm/data/table/hooks/useTableSelection.d.ts +7 -6
- package/esm/data/table/hooks/useTableSelection.js +52 -35
- package/esm/data/table/hooks/useTableSelection.js.map +1 -1
- package/esm/data/table/hooks/useTableSort.d.ts +15 -9
- package/esm/data/table/hooks/useTableSort.js +10 -12
- package/esm/data/table/hooks/useTableSort.js.map +1 -1
- package/esm/data/table/index.d.ts +1 -1
- package/esm/data/table/index.js +1 -21
- package/esm/data/table/index.js.map +1 -1
- package/esm/data/table/root/DataGridTable.types.d.ts +65 -0
- package/esm/data/table/root/DataGridTable.types.js +2 -0
- package/esm/data/table/root/DataGridTable.types.js.map +1 -0
- package/esm/data/table/root/DataGridTableRoot.d.ts +104 -0
- package/esm/data/table/root/DataGridTableRoot.js +202 -0
- package/esm/data/table/root/DataGridTableRoot.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.context.d.ts +17 -7
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js +4 -4
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -1
- package/esm/data/table/tbody/DataTableTbody.js +4 -2
- package/esm/data/table/tbody/DataTableTbody.js.map +1 -1
- package/esm/data/table/tr/DataTableTr.d.ts +7 -5
- package/esm/data/table/tr/DataTableTr.js +68 -32
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/data/token-filter/TokenFilter.d.ts +0 -6
- package/esm/data/token-filter/TokenFilter.js +1 -1
- package/esm/data-grid/index.d.ts +2 -0
- package/esm/data-grid/index.js +4 -0
- package/esm/data-grid/index.js.map +1 -0
- package/esm/data-grid/root/DataGrid.types.d.ts +35 -0
- package/esm/data-grid/root/DataGrid.types.js +2 -0
- package/esm/data-grid/root/DataGrid.types.js.map +1 -0
- package/esm/data-grid/root/DataGridRoot.context.d.ts +16 -0
- package/esm/data-grid/root/DataGridRoot.context.js +7 -0
- package/esm/data-grid/root/DataGridRoot.context.js.map +1 -0
- package/esm/data-grid/root/DataGridRoot.d.ts +89 -0
- package/esm/data-grid/root/DataGridRoot.js +57 -0
- package/esm/data-grid/root/DataGridRoot.js.map +1 -0
- package/esm/preview.d.ts +1 -0
- package/esm/preview.js +3 -0
- package/esm/preview.js.map +1 -0
- package/esm/table/ColumnHeader.js +2 -1
- package/esm/table/ColumnHeader.js.map +1 -1
- package/package.json +23 -3
- package/src/data/drag-and-drop/drag-handler/DragAndDropDragHandler.tsx +0 -1
- package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +18 -52
- package/src/data/stories/Data.test-data.tsx +76 -65
- package/src/data/table/base-cell/DataTableBaseCell.tsx +36 -26
- package/src/data/table/column-header/DataTableColumnHeader.tsx +62 -62
- package/src/data/table/column-header/useTableColumnResize.ts +63 -79
- package/src/data/table/details-panel-row/DataTableDetailsPanelRow.tsx +3 -3
- package/src/data/table/helpers/collectTableRowEntries.ts +1 -2
- package/src/data/table/helpers/selection/getMultipleSelectProps.ts +69 -83
- package/src/data/table/helpers/selection/getSingleSelectProps.ts +35 -17
- package/src/data/table/helpers/selection/selection.types.ts +23 -33
- package/src/data/table/helpers/selection/selection.utils.test.ts +161 -0
- package/src/data/table/helpers/selection/selection.utils.ts +73 -0
- package/src/data/table/hooks/__tests__/useTableItems.test.ts +2 -1
- package/src/data/table/hooks/useColumnOptions.ts +49 -15
- package/src/data/table/hooks/useTableDetailsPanel.tsx +21 -28
- package/src/data/table/hooks/useTableItems.ts +60 -38
- package/src/data/table/hooks/useTableKeyboardNav.ts +1 -13
- package/src/data/table/hooks/useTableSelection.ts +80 -68
- package/src/data/table/hooks/useTableSort.ts +36 -23
- package/src/data/table/index.tsx +4 -21
- package/src/data/table/root/DataGridTable.types.ts +82 -0
- package/src/data/table/root/DataGridTableRoot.tsx +566 -0
- package/src/data/table/root/DataTableRoot.context.ts +24 -10
- package/src/data/table/sub-row-toggle/DataTableSubRowToggle.tsx +6 -5
- package/src/data/table/tbody/DataTableTbody.tsx +6 -2
- package/src/data/table/tr/DataTableTr.tsx +145 -47
- package/src/data/token-filter/TokenFilter.tsx +1 -1
- package/src/data-grid/index.ts +3 -0
- package/src/data-grid/root/DataGrid.types.ts +36 -0
- package/src/data-grid/root/DataGridRoot.context.ts +21 -0
- package/src/data-grid/root/DataGridRoot.tsx +152 -0
- package/src/preview.ts +2 -0
- package/src/table/ColumnHeader.tsx +3 -1
- package/cjs/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.d.ts +0 -22
- package/cjs/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js +0 -35
- package/cjs/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js.map +0 -1
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.d.ts +0 -27
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js +0 -86
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js.map +0 -1
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.d.ts +0 -5
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js +0 -6
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js.map +0 -1
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.d.ts +0 -24
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js +0 -108
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js.map +0 -1
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +0 -46
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js +0 -112
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js.map +0 -1
- package/cjs/data/table/root/DataTable.types.d.ts +0 -63
- package/cjs/data/table/root/DataTable.types.js.map +0 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +0 -141
- package/cjs/data/table/root/DataTableRoot.js +0 -229
- package/cjs/data/table/root/DataTableRoot.js.map +0 -1
- package/cjs/data/table/root/DataTableRoot.legacy.d.ts +0 -177
- package/cjs/data/table/root/DataTableRoot.legacy.js +0 -104
- package/cjs/data/table/root/DataTableRoot.legacy.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.d.ts +0 -22
- package/esm/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js +0 -29
- package/esm/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.d.ts +0 -27
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js +0 -50
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.d.ts +0 -5
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js +0 -3
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js.map +0 -1
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.d.ts +0 -24
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js +0 -68
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js.map +0 -1
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +0 -46
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js +0 -109
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js.map +0 -1
- package/esm/data/table/root/DataTable.types.d.ts +0 -63
- package/esm/data/table/root/DataTable.types.js +0 -2
- package/esm/data/table/root/DataTable.types.js.map +0 -1
- package/esm/data/table/root/DataTableRoot.d.ts +0 -141
- package/esm/data/table/root/DataTableRoot.js +0 -193
- package/esm/data/table/root/DataTableRoot.js.map +0 -1
- package/esm/data/table/root/DataTableRoot.legacy.d.ts +0 -177
- package/esm/data/table/root/DataTableRoot.legacy.js +0 -59
- package/esm/data/table/root/DataTableRoot.legacy.js.map +0 -1
- package/src/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.tsx +0 -104
- package/src/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.tsx +0 -74
- package/src/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.tsx +0 -11
- package/src/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.tsx +0 -94
- package/src/data/table/Readme.md +0 -11
- package/src/data/table/helpers/selection/SelectionSubtreeHelper.test.ts +0 -66
- package/src/data/table/helpers/selection/SelectionSubtreeHelper.ts +0 -162
- package/src/data/table/hooks/__tests__/useTableSelection.test.ts +0 -488
- package/src/data/table/root/DataTable.types.ts +0 -87
- package/src/data/table/root/DataTableRoot.legacy.tsx +0 -297
- package/src/data/table/root/DataTableRoot.tsx +0 -562
- package/src/data/table/root/agent-feature-gap.md +0 -96
|
@@ -2,39 +2,58 @@ import { useMemo } from "react";
|
|
|
2
2
|
import type {
|
|
3
3
|
ColumnDefinition,
|
|
4
4
|
ColumnDefinitions,
|
|
5
|
-
} from "../root/
|
|
6
|
-
import
|
|
5
|
+
} from "../root/DataGridTable.types";
|
|
6
|
+
import { ACTION_CELL_WIDTH } from "../tr/DataTableTr";
|
|
7
7
|
|
|
8
8
|
type UseColumnOptions = {
|
|
9
9
|
stickyColumns?: {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
start?: 1;
|
|
11
|
+
end?: 1;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
hasSelection: boolean;
|
|
14
|
+
hasDetailsPanel: boolean;
|
|
15
|
+
layout: "fixed" | "auto";
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type StickyStartState = {
|
|
19
|
+
selection: boolean;
|
|
20
|
+
expansion: boolean;
|
|
21
|
+
selectionOffset: number;
|
|
22
|
+
firstColumnOffset: number;
|
|
14
23
|
};
|
|
15
24
|
|
|
16
25
|
type UseColumnOptionsResult<T> = {
|
|
17
26
|
columns: {
|
|
18
27
|
isSticky: "start" | "end" | false;
|
|
28
|
+
isStickyLast?: boolean;
|
|
29
|
+
stickyLeftOffset?: number;
|
|
19
30
|
colDef: ColumnDefinition<T>;
|
|
20
31
|
}[];
|
|
21
|
-
|
|
32
|
+
stickyStart: StickyStartState;
|
|
33
|
+
totalColSpan: number;
|
|
22
34
|
};
|
|
23
35
|
|
|
24
36
|
function useColumnOptions<T>(
|
|
25
37
|
columnDefinitions: ColumnDefinitions<T>,
|
|
26
38
|
options: UseColumnOptions,
|
|
27
39
|
): UseColumnOptionsResult<T> {
|
|
28
|
-
const { stickyColumns,
|
|
40
|
+
const { stickyColumns, hasSelection, hasDetailsPanel, layout } = options;
|
|
41
|
+
|
|
42
|
+
const hasStickyStart = stickyColumns?.start === 1;
|
|
29
43
|
|
|
30
|
-
const
|
|
44
|
+
const stickyExpansion = hasStickyStart && hasDetailsPanel;
|
|
45
|
+
const stickySelection = hasStickyStart && hasSelection;
|
|
46
|
+
|
|
47
|
+
const stickySelectionOffset = stickyExpansion ? ACTION_CELL_WIDTH : 0;
|
|
48
|
+
const stickyFirstColumnOffset =
|
|
49
|
+
(stickyExpansion ? ACTION_CELL_WIDTH : 0) +
|
|
50
|
+
(stickySelection ? ACTION_CELL_WIDTH : 0);
|
|
31
51
|
|
|
32
52
|
const columns = useMemo(() => {
|
|
33
53
|
return columnDefinitions.map((colDef, index) => {
|
|
34
|
-
const isFirstSticky =
|
|
35
|
-
stickyColumns?.first === "1" && index === 0 && !hasSelection;
|
|
54
|
+
const isFirstSticky = hasStickyStart && index === 0;
|
|
36
55
|
const isLastSticky =
|
|
37
|
-
stickyColumns?.
|
|
56
|
+
stickyColumns?.end === 1 && index === columnDefinitions.length - 1;
|
|
38
57
|
|
|
39
58
|
return {
|
|
40
59
|
isSticky: isFirstSticky
|
|
@@ -42,21 +61,36 @@ function useColumnOptions<T>(
|
|
|
42
61
|
: isLastSticky
|
|
43
62
|
? ("end" as const)
|
|
44
63
|
: (false as const),
|
|
64
|
+
isStickyLast: isFirstSticky && !isLastSticky,
|
|
65
|
+
stickyLeftOffset: isFirstSticky ? stickyFirstColumnOffset : undefined,
|
|
45
66
|
colDef,
|
|
46
67
|
};
|
|
47
68
|
});
|
|
48
69
|
}, [
|
|
49
70
|
columnDefinitions,
|
|
50
|
-
|
|
51
|
-
stickyColumns
|
|
52
|
-
|
|
71
|
+
hasStickyStart,
|
|
72
|
+
stickyColumns,
|
|
73
|
+
stickyFirstColumnOffset,
|
|
53
74
|
]);
|
|
54
75
|
|
|
76
|
+
const totalColSpan =
|
|
77
|
+
columns.length +
|
|
78
|
+
(layout === "fixed" ? 1 : 0) +
|
|
79
|
+
(hasSelection ? 1 : 0) +
|
|
80
|
+
(hasDetailsPanel ? 1 : 0);
|
|
81
|
+
|
|
55
82
|
return {
|
|
56
|
-
|
|
83
|
+
stickyStart: {
|
|
84
|
+
selection: stickySelection,
|
|
85
|
+
expansion: stickyExpansion,
|
|
86
|
+
selectionOffset: stickySelectionOffset,
|
|
87
|
+
firstColumnOffset: stickyFirstColumnOffset,
|
|
88
|
+
},
|
|
57
89
|
columns,
|
|
90
|
+
totalColSpan,
|
|
58
91
|
};
|
|
59
92
|
}
|
|
60
93
|
|
|
61
94
|
export { useColumnOptions };
|
|
95
|
+
export type { StickyStartState };
|
|
62
96
|
export type { UseColumnOptionsResult };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import { createStrictContext } from "../../../utils/helpers";
|
|
3
3
|
import { useControllableState } from "../../../utils/hooks";
|
|
4
|
-
import {
|
|
4
|
+
import { useDataTableContext } from "../root/DataTableRoot.context";
|
|
5
5
|
|
|
6
6
|
type DetailsPanelProps<T> = {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Function to get the content to show in the details panel for a given row.
|
|
9
9
|
* When provided, an expand toggle column is added automatically.
|
|
10
10
|
*/
|
|
11
|
-
getContent
|
|
11
|
+
getContent: (rowData: T) => React.ReactNode;
|
|
12
12
|
/**
|
|
13
13
|
* Determines whether a row can be expanded to show details panel content.
|
|
14
14
|
* @default () => true
|
|
@@ -16,22 +16,18 @@ type DetailsPanelProps<T> = {
|
|
|
16
16
|
isRowExpandable?: (rowData: T) => boolean;
|
|
17
17
|
/**
|
|
18
18
|
* Controlled list of expanded row IDs.
|
|
19
|
-
* Use with `
|
|
19
|
+
* Use with `onExpandedRowIdsChange` for controlled usage, or `defaultExpandedRowIds` for uncontrolled.
|
|
20
20
|
*/
|
|
21
|
-
expandedRowIds?:
|
|
21
|
+
expandedRowIds?: string[];
|
|
22
22
|
/**
|
|
23
23
|
* Initial list of expanded row IDs for uncontrolled usage.
|
|
24
24
|
* @default []
|
|
25
25
|
*/
|
|
26
|
-
defaultExpandedRowIds?:
|
|
26
|
+
defaultExpandedRowIds?: string[];
|
|
27
27
|
/**
|
|
28
28
|
* Called when the list of expanded row IDs changes.
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* TODO:
|
|
32
|
-
* - Docs: This pattern is called "Master / Detail" in general terms
|
|
33
29
|
*/
|
|
34
|
-
onExpandedRowIdsChange?: (ids:
|
|
30
|
+
onExpandedRowIdsChange?: (ids: string[]) => void; // TODO: Docs: This pattern is called "Master / Detail" in general terms
|
|
35
31
|
/**
|
|
36
32
|
* Returns the height (in px) or `"auto"` for a row's details panel.
|
|
37
33
|
* When a number is returned, the panel scrolls within that fixed height.
|
|
@@ -46,9 +42,9 @@ type DetailsPanelProps<T> = {
|
|
|
46
42
|
};
|
|
47
43
|
|
|
48
44
|
type DataTableDetailsPanelContextT = {
|
|
49
|
-
isExpanded: (id: string
|
|
50
|
-
isDetailsPanelExpandable: (id: string
|
|
51
|
-
toggleExpansion: (id: string
|
|
45
|
+
isExpanded: (id: string) => boolean;
|
|
46
|
+
isDetailsPanelExpandable: (id: string) => boolean;
|
|
47
|
+
toggleExpansion: (id: string) => void;
|
|
52
48
|
toggleAll: () => void;
|
|
53
49
|
isAllExpanded: boolean;
|
|
54
50
|
getDetailsPanelContent?: (row: unknown) => React.ReactNode;
|
|
@@ -68,7 +64,7 @@ const {
|
|
|
68
64
|
|
|
69
65
|
function DataTableDetailsPanelProvider<T>({
|
|
70
66
|
children,
|
|
71
|
-
detailsPanel
|
|
67
|
+
detailsPanel,
|
|
72
68
|
}: { detailsPanel?: DetailsPanelProps<T> } & { children: React.ReactNode }) {
|
|
73
69
|
const {
|
|
74
70
|
expandedRowIds,
|
|
@@ -78,7 +74,7 @@ function DataTableDetailsPanelProvider<T>({
|
|
|
78
74
|
isRowExpandable,
|
|
79
75
|
getHeight,
|
|
80
76
|
showExpandAll = false,
|
|
81
|
-
} = detailsPanel;
|
|
77
|
+
} = detailsPanel || {};
|
|
82
78
|
|
|
83
79
|
const [expandedIds, setExpandedIds] = useControllableState({
|
|
84
80
|
value: expandedRowIds,
|
|
@@ -87,21 +83,18 @@ function DataTableDetailsPanelProvider<T>({
|
|
|
87
83
|
});
|
|
88
84
|
|
|
89
85
|
/* TODO: False is just fallback until auto and root is merged */
|
|
90
|
-
const
|
|
86
|
+
const tableContext = useDataTableContext(false);
|
|
91
87
|
|
|
92
|
-
const { itemDetails } =
|
|
93
|
-
itemDetails: new Map<
|
|
94
|
-
string | number,
|
|
95
|
-
{ rowData: T; id: string | number; level: number }
|
|
96
|
-
>(),
|
|
88
|
+
const { itemDetails } = tableContext?.tableItems ?? {
|
|
89
|
+
itemDetails: new Map<string, { rowData: T; id: string; level: number }>(),
|
|
97
90
|
};
|
|
98
91
|
|
|
99
92
|
const expandableIds = React.useMemo(() => {
|
|
100
93
|
if (!getContent) {
|
|
101
|
-
return new Set<string
|
|
94
|
+
return new Set<string>();
|
|
102
95
|
}
|
|
103
96
|
|
|
104
|
-
const ids = new Set<string
|
|
97
|
+
const ids = new Set<string>();
|
|
105
98
|
|
|
106
99
|
for (const { rowData, id, level } of itemDetails.values()) {
|
|
107
100
|
/* We only allow Master - Details pattern on top level rows */
|
|
@@ -118,18 +111,18 @@ function DataTableDetailsPanelProvider<T>({
|
|
|
118
111
|
}, [getContent, isRowExpandable, itemDetails]);
|
|
119
112
|
|
|
120
113
|
const isDetailsPanelExpandableById = useCallback(
|
|
121
|
-
(id: string
|
|
114
|
+
(id: string) => expandableIds.has(id),
|
|
122
115
|
[expandableIds],
|
|
123
116
|
);
|
|
124
117
|
|
|
125
118
|
const isExpanded = useCallback(
|
|
126
|
-
(id: string
|
|
119
|
+
(id: string) =>
|
|
127
120
|
isDetailsPanelExpandableById(id) && expandedIds.includes(id),
|
|
128
121
|
[expandedIds, isDetailsPanelExpandableById],
|
|
129
122
|
);
|
|
130
123
|
|
|
131
124
|
const toggleExpansion = useCallback(
|
|
132
|
-
(id: string
|
|
125
|
+
(id: string) => {
|
|
133
126
|
if (!isDetailsPanelExpandableById(id)) {
|
|
134
127
|
return;
|
|
135
128
|
}
|
|
@@ -172,7 +165,7 @@ function DataTableDetailsPanelProvider<T>({
|
|
|
172
165
|
);
|
|
173
166
|
}
|
|
174
167
|
|
|
175
|
-
function getDataTableDetailsPanelId(tableId: string, rowId: string
|
|
168
|
+
function getDataTableDetailsPanelId(tableId: string, rowId: string) {
|
|
176
169
|
return `${tableId}-expansion-${rowId}`;
|
|
177
170
|
}
|
|
178
171
|
|
|
@@ -1,39 +1,54 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { createStrictContext } from "../../../utils/helpers";
|
|
3
2
|
import { useControllableState } from "../../../utils/hooks";
|
|
4
3
|
import {
|
|
5
4
|
type ItemDetail,
|
|
6
|
-
type TableRowEntryId,
|
|
7
5
|
collectTableRowEntries,
|
|
8
6
|
} from "../helpers/collectTableRowEntries";
|
|
9
7
|
|
|
10
8
|
type SubRowsProps<T> = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Function to get sub-rows for a given row.
|
|
11
|
+
*/
|
|
12
|
+
getRows: (rowData: T) => T[];
|
|
13
|
+
/**
|
|
14
|
+
* Controlled list of IDs of rows that should be expanded.
|
|
15
|
+
*/
|
|
16
|
+
expandedRowIds?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* IDs of rows that should be initially expanded.
|
|
19
|
+
* Only used when `expandedRowIds` is not provided, i.e. when the expanded state is uncontrolled.
|
|
20
|
+
*/
|
|
21
|
+
defaultExpandedRowIds?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Called when the list of expanded row IDs changes.
|
|
24
|
+
*/
|
|
25
|
+
onExpandedRowIdsChange?: (ids: string[]) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Determines whether a row should be expandable.
|
|
28
|
+
* By default, all rows are expandable when `getRows` is provided.
|
|
29
|
+
*/
|
|
14
30
|
isRowExpandable?: (rowData: T) => boolean;
|
|
15
|
-
onExpandedRowIdsChange?: (ids: (string | number)[]) => void;
|
|
16
31
|
};
|
|
17
32
|
|
|
18
33
|
type UseTableItemsArgs<T> = {
|
|
19
34
|
items: T[];
|
|
20
|
-
getRowId?: (rowData: T) =>
|
|
35
|
+
getRowId?: (rowData: T) => string;
|
|
21
36
|
subRows?: SubRowsProps<T>;
|
|
22
37
|
};
|
|
23
38
|
|
|
24
|
-
type
|
|
39
|
+
type UseTableItemsReturn<T> = {
|
|
25
40
|
items: T[];
|
|
26
|
-
itemDetails: Map<
|
|
41
|
+
itemDetails: Map<string, ItemDetail<T>>;
|
|
27
42
|
/** Row ids for the rows currently rendered in the table body. */
|
|
28
|
-
visibleRowIds:
|
|
43
|
+
visibleRowIds: string[];
|
|
29
44
|
/** Direct child ids for each row, used to traverse selection groups lazily. */
|
|
30
|
-
childRowIdsById: Map<
|
|
31
|
-
onExpandedRowIdsChange: (id: string
|
|
32
|
-
isSubRowExpanded: (id: string
|
|
45
|
+
childRowIdsById: Map<string, string[]>;
|
|
46
|
+
onExpandedRowIdsChange: (id: string) => void;
|
|
47
|
+
isSubRowExpanded: (id: string) => boolean;
|
|
33
48
|
};
|
|
34
49
|
|
|
35
|
-
function useTableItems<T>(args: UseTableItemsArgs<T>):
|
|
36
|
-
const { items, subRows
|
|
50
|
+
function useTableItems<T>(args: UseTableItemsArgs<T>): UseTableItemsReturn<T> {
|
|
51
|
+
const { items, subRows, getRowId } = args;
|
|
37
52
|
|
|
38
53
|
const {
|
|
39
54
|
expandedRowIds,
|
|
@@ -41,7 +56,7 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
41
56
|
getRows,
|
|
42
57
|
onExpandedRowIdsChange,
|
|
43
58
|
isRowExpandable,
|
|
44
|
-
} = subRows;
|
|
59
|
+
} = subRows || {};
|
|
45
60
|
|
|
46
61
|
const [nestedSubRowsExpandedIds, setNestedSubRowsExpandedIds] =
|
|
47
62
|
useControllableState({
|
|
@@ -69,9 +84,9 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
69
84
|
});
|
|
70
85
|
|
|
71
86
|
const localVisibleItems: T[] = [];
|
|
72
|
-
const localVisibleRowIds:
|
|
87
|
+
const localVisibleRowIds: string[] = [];
|
|
73
88
|
|
|
74
|
-
const addVisibleRows = (rowId:
|
|
89
|
+
const addVisibleRows = (rowId: string): string[] => {
|
|
75
90
|
const details = rowEntriesMap.get(rowId);
|
|
76
91
|
|
|
77
92
|
if (!details) {
|
|
@@ -81,7 +96,7 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
81
96
|
localVisibleItems.push(details.rowData);
|
|
82
97
|
localVisibleRowIds.push(details.id);
|
|
83
98
|
|
|
84
|
-
const visibleDescendantRowIds:
|
|
99
|
+
const visibleDescendantRowIds: string[] = [];
|
|
85
100
|
|
|
86
101
|
if (expandedIdsSet.has(details.id)) {
|
|
87
102
|
for (const childRowId of details.children) {
|
|
@@ -106,7 +121,7 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
106
121
|
}, [getRows, items, getRowId, isRowExpandable, expandedIdsSet]);
|
|
107
122
|
|
|
108
123
|
const handleExpandedSubRowIdChange = useCallback(
|
|
109
|
-
(id: string
|
|
124
|
+
(id: string) => {
|
|
110
125
|
setNestedSubRowsExpandedIds((prev) =>
|
|
111
126
|
prev.includes(id)
|
|
112
127
|
? prev.filter((expandedId) => expandedId !== id)
|
|
@@ -116,23 +131,30 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
116
131
|
[setNestedSubRowsExpandedIds],
|
|
117
132
|
);
|
|
118
133
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
childRowIdsById,
|
|
124
|
-
onExpandedRowIdsChange: handleExpandedSubRowIdChange,
|
|
125
|
-
isSubRowExpanded: (id: string | number) => expandedIdsSet.has(id),
|
|
126
|
-
};
|
|
127
|
-
}
|
|
134
|
+
const isSubRowExpanded = useCallback(
|
|
135
|
+
(id: string) => expandedIdsSet.has(id),
|
|
136
|
+
[expandedIdsSet],
|
|
137
|
+
);
|
|
128
138
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
139
|
+
return useMemo(
|
|
140
|
+
() => ({
|
|
141
|
+
items: visibleItems,
|
|
142
|
+
itemDetails,
|
|
143
|
+
visibleRowIds,
|
|
144
|
+
childRowIdsById,
|
|
145
|
+
onExpandedRowIdsChange: handleExpandedSubRowIdChange,
|
|
146
|
+
isSubRowExpanded,
|
|
147
|
+
}),
|
|
148
|
+
[
|
|
149
|
+
visibleItems,
|
|
150
|
+
itemDetails,
|
|
151
|
+
visibleRowIds,
|
|
152
|
+
childRowIdsById,
|
|
153
|
+
handleExpandedSubRowIdChange,
|
|
154
|
+
isSubRowExpanded,
|
|
155
|
+
],
|
|
156
|
+
);
|
|
157
|
+
}
|
|
136
158
|
|
|
137
|
-
export { useTableItems
|
|
138
|
-
export type { ItemDetail, SubRowsProps };
|
|
159
|
+
export { useTableItems };
|
|
160
|
+
export type { ItemDetail, SubRowsProps, UseTableItemsReturn };
|
|
@@ -18,17 +18,9 @@ import { useGridCache } from "./useGridCache";
|
|
|
18
18
|
|
|
19
19
|
type UseTableKeyboardNavOptions = {
|
|
20
20
|
enabled: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Custom callback to determine if navigation should be blocked.
|
|
23
|
-
* Called before default blocking logic.
|
|
24
|
-
*/
|
|
25
|
-
shouldBlockNavigation?: (event: KeyboardEvent) => boolean;
|
|
26
21
|
};
|
|
27
22
|
|
|
28
|
-
function useTableKeyboardNav({
|
|
29
|
-
enabled,
|
|
30
|
-
shouldBlockNavigation: customBlockFn,
|
|
31
|
-
}: UseTableKeyboardNavOptions) {
|
|
23
|
+
function useTableKeyboardNav({ enabled }: UseTableKeyboardNavOptions) {
|
|
32
24
|
const [tableRef, setTableRef] = useState<HTMLTableElement | null>(null);
|
|
33
25
|
const { getTableGrid, activeCell, setActiveCell } = useGridCache(
|
|
34
26
|
tableRef,
|
|
@@ -110,10 +102,6 @@ function useTableKeyboardNav({
|
|
|
110
102
|
* Checks if navigation should be blocked based on current focus context.
|
|
111
103
|
*/
|
|
112
104
|
const handleTableKeyDown = useEventCallback((event: KeyboardEvent): void => {
|
|
113
|
-
if (customBlockFn?.(event)) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
105
|
const action = getNavigationAction(event);
|
|
118
106
|
if (!action) {
|
|
119
107
|
return;
|
|
@@ -1,109 +1,122 @@
|
|
|
1
1
|
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { useDataGridContext } from "../../../data-grid/root/DataGridRoot.context";
|
|
2
3
|
import { useId } from "../../../utils-external";
|
|
3
4
|
import { useControllableState } from "../../../utils/hooks";
|
|
4
5
|
import { getMultipleSelectProps } from "../helpers/selection/getMultipleSelectProps";
|
|
5
6
|
import { getSingleSelectProps } from "../helpers/selection/getSingleSelectProps";
|
|
6
7
|
import type {
|
|
7
|
-
SelectedKeysT,
|
|
8
8
|
SelectionProps,
|
|
9
9
|
TableSelection,
|
|
10
10
|
} from "../helpers/selection/selection.types";
|
|
11
|
+
import type { TableRowEntryId } from "../root/DataGridTable.types";
|
|
12
|
+
import type { UseTableItemsReturn } from "./useTableItems";
|
|
11
13
|
|
|
12
|
-
type UseTableSelectionArgs = {
|
|
13
|
-
selection?: SelectionProps
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/* Direct child ids let selection walk nested rows lazily. */
|
|
17
|
-
childRowIdsById?: Map<string | number, (string | number)[]>;
|
|
14
|
+
type UseTableSelectionArgs<T> = {
|
|
15
|
+
selection?: SelectionProps<T>;
|
|
16
|
+
selectionTrigger: "row" | "control";
|
|
17
|
+
tableItems: UseTableItemsReturn<T>;
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
type UseTableSelectionReturn = {
|
|
21
21
|
selection: TableSelection;
|
|
22
22
|
renderSelection: boolean;
|
|
23
|
-
|
|
23
|
+
selectionTrigger: "row" | "control";
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
function useTableSelection({
|
|
27
|
-
selection = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
function useTableSelection<T>({
|
|
27
|
+
selection = {
|
|
28
|
+
mode: "none",
|
|
29
|
+
},
|
|
30
|
+
selectionTrigger = "row",
|
|
31
|
+
tableItems,
|
|
32
|
+
}: UseTableSelectionArgs<T>): UseTableSelectionReturn {
|
|
33
|
+
const { isLoading } = useDataGridContext();
|
|
31
34
|
const {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
disableRowSelectionOnClick = false,
|
|
35
|
+
mode,
|
|
36
|
+
defaultSelectedRowIds,
|
|
37
|
+
selectedRowIds: selectedRowIdsProp,
|
|
38
|
+
onSelectedRowIdsChange,
|
|
39
|
+
enableRowSelection,
|
|
38
40
|
} = selection;
|
|
39
41
|
|
|
42
|
+
const { visibleRowIds = [] } = tableItems;
|
|
43
|
+
|
|
40
44
|
const radioGroupName = useId();
|
|
41
45
|
|
|
42
|
-
const [selectedKeys, setSelectedKeys] = useControllableState<
|
|
43
|
-
value:
|
|
44
|
-
defaultValue:
|
|
45
|
-
onChange:
|
|
46
|
+
const [selectedKeys, setSelectedKeys] = useControllableState<string[]>({
|
|
47
|
+
value: mode !== "none" ? selectedRowIdsProp : undefined,
|
|
48
|
+
defaultValue: defaultSelectedRowIds ?? [],
|
|
49
|
+
onChange: onSelectedRowIdsChange,
|
|
46
50
|
});
|
|
47
51
|
|
|
48
52
|
const selectedKeysSet = useMemo(() => new Set(selectedKeys), [selectedKeys]);
|
|
49
53
|
|
|
50
|
-
const disabledKeysSet = useMemo(
|
|
51
|
-
() => new Set(disabledSelectionKeys),
|
|
52
|
-
[disabledSelectionKeys],
|
|
53
|
-
);
|
|
54
|
-
|
|
55
54
|
const isRowSelected = useCallback(
|
|
56
|
-
(rowId:
|
|
55
|
+
(rowId: TableRowEntryId) => selectedKeysSet.has(rowId),
|
|
57
56
|
[selectedKeysSet],
|
|
58
57
|
);
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
return useMemo(() => {
|
|
60
|
+
const baseSelection = { selectedKeys, isRowSelected };
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
if (mode === "none") {
|
|
63
|
+
return {
|
|
64
|
+
selection: {
|
|
65
|
+
mode,
|
|
66
|
+
...baseSelection,
|
|
67
|
+
selectedKeys: [],
|
|
68
|
+
},
|
|
69
|
+
selectionTrigger,
|
|
70
|
+
renderSelection: false,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (mode === "single") {
|
|
75
|
+
return {
|
|
76
|
+
selection: {
|
|
77
|
+
mode,
|
|
78
|
+
...baseSelection,
|
|
79
|
+
...getSingleSelectProps({
|
|
80
|
+
selectedKeysSet,
|
|
81
|
+
setSelectedKeys,
|
|
82
|
+
name: radioGroupName,
|
|
83
|
+
enableRowSelection,
|
|
84
|
+
}),
|
|
85
|
+
},
|
|
86
|
+
selectionTrigger,
|
|
87
|
+
renderSelection: visibleRowIds.length !== 0,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
73
90
|
|
|
74
|
-
if (selectionMode === "single") {
|
|
75
91
|
return {
|
|
76
92
|
selection: {
|
|
77
|
-
|
|
93
|
+
mode,
|
|
78
94
|
...baseSelection,
|
|
79
|
-
...
|
|
95
|
+
...getMultipleSelectProps({
|
|
80
96
|
selectedKeysSet,
|
|
97
|
+
selectedKeys,
|
|
81
98
|
setSelectedKeys,
|
|
82
|
-
|
|
83
|
-
|
|
99
|
+
enableRowSelection,
|
|
100
|
+
tableItems,
|
|
101
|
+
isLoading,
|
|
84
102
|
}),
|
|
85
103
|
},
|
|
86
|
-
|
|
104
|
+
selectionTrigger,
|
|
87
105
|
renderSelection: visibleRowIds.length !== 0,
|
|
88
106
|
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}),
|
|
103
|
-
},
|
|
104
|
-
disableRowSelectionOnClick,
|
|
105
|
-
renderSelection: visibleRowIds.length !== 0,
|
|
106
|
-
};
|
|
107
|
+
}, [
|
|
108
|
+
mode,
|
|
109
|
+
selectedKeys,
|
|
110
|
+
selectedKeysSet,
|
|
111
|
+
isRowSelected,
|
|
112
|
+
selectionTrigger,
|
|
113
|
+
visibleRowIds,
|
|
114
|
+
setSelectedKeys,
|
|
115
|
+
radioGroupName,
|
|
116
|
+
enableRowSelection,
|
|
117
|
+
tableItems,
|
|
118
|
+
isLoading,
|
|
119
|
+
]);
|
|
107
120
|
}
|
|
108
121
|
|
|
109
122
|
/**
|
|
@@ -111,12 +124,11 @@ function useTableSelection({
|
|
|
111
124
|
*/
|
|
112
125
|
const noSelectionState: UseTableSelectionReturn = {
|
|
113
126
|
selection: {
|
|
114
|
-
|
|
127
|
+
mode: "none",
|
|
115
128
|
selectedKeys: [],
|
|
116
|
-
disabledSelectionKeys: [],
|
|
117
129
|
isRowSelected: () => false,
|
|
118
130
|
},
|
|
119
|
-
|
|
131
|
+
selectionTrigger: "row",
|
|
120
132
|
renderSelection: false,
|
|
121
133
|
};
|
|
122
134
|
|