@navikt/ds-react 8.10.3 → 8.10.5
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/action-menu/ActionMenu.js +1 -1
- package/cjs/action-menu/ActionMenu.js.map +1 -1
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +11 -12
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDrop.context.d.ts +4 -2
- package/cjs/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.d.ts +5 -5
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +49 -28
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/cjs/data/drag-and-drop/types.d.ts +0 -4
- package/cjs/data/{drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts → drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.d.ts} +3 -3
- package/cjs/data/{drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js → drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js} +5 -5
- package/cjs/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js.map +1 -0
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.d.ts +27 -0
- package/cjs/data/{drag-and-drop-old/item/DataDragAndDropItem.js → drag-and-drop-legacy/item/DragAndDropItemLegacy.js} +12 -12
- package/cjs/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js.map +1 -0
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.d.ts +5 -0
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js +6 -0
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js.map +1 -0
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.d.ts +24 -0
- package/cjs/data/{drag-and-drop-old/root/DataDragAndDropRoot.js → drag-and-drop-legacy/root/DragAndDropLegacyRoot.js} +10 -10
- package/cjs/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js.map +1 -0
- package/cjs/data/stories/Data.test-data.d.ts +24 -0
- package/cjs/data/stories/Data.test-data.js +1615 -0
- package/cjs/data/stories/Data.test-data.js.map +1 -0
- package/cjs/data/table/column-header/DataTableColumnHeader.d.ts +4 -1
- package/cjs/data/table/column-header/DataTableColumnHeader.js +4 -4
- package/cjs/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/cjs/data/table/column-header/useTableColumnResize.d.ts +21 -18
- package/cjs/data/table/column-header/useTableColumnResize.js +7 -25
- package/cjs/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +6 -0
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js +32 -0
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -0
- package/cjs/data/table/helpers/collectTableRowEntries.d.ts +9 -7
- package/cjs/data/table/helpers/collectTableRowEntries.js +21 -14
- package/cjs/data/table/helpers/collectTableRowEntries.js.map +1 -1
- package/cjs/data/table/helpers/table-focus.d.ts +0 -3
- package/cjs/data/table/helpers/table-focus.js +38 -8
- package/cjs/data/table/helpers/table-focus.js.map +1 -1
- package/cjs/data/table/hooks/useColumnOptions.js +18 -5
- package/cjs/data/table/hooks/useColumnOptions.js.map +1 -1
- package/cjs/data/table/hooks/useGridCache.js +2 -2
- package/cjs/data/table/hooks/useGridCache.js.map +1 -1
- package/cjs/data/table/hooks/useTableDetailsPanel.d.ts +62 -0
- package/cjs/data/table/hooks/{useTableExpansion.js → useTableDetailsPanel.js} +21 -20
- package/cjs/data/table/hooks/useTableDetailsPanel.js.map +1 -0
- package/cjs/data/table/hooks/useTableItems.d.ts +14 -17
- package/cjs/data/table/hooks/useTableItems.js +17 -16
- package/cjs/data/table/hooks/useTableItems.js.map +1 -1
- package/cjs/data/table/hooks/useTableKeyboardNav.js +5 -1
- package/cjs/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/cjs/data/table/hooks/useTableSelection.d.ts +4 -2
- package/cjs/data/table/hooks/useTableSelection.js +6 -1
- package/cjs/data/table/hooks/useTableSelection.js.map +1 -1
- package/cjs/data/table/index.d.ts +1 -2
- package/cjs/data/table/index.js +22 -12
- package/cjs/data/table/index.js.map +1 -1
- package/cjs/data/table/root/DataTable.types.d.ts +7 -9
- package/cjs/data/table/root/DataTableRoot.context.d.ts +5 -1
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +79 -115
- package/cjs/data/table/root/DataTableRoot.js +163 -38
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.legacy.d.ts +177 -0
- package/cjs/data/table/root/DataTableRoot.legacy.js +104 -0
- package/cjs/data/table/root/DataTableRoot.legacy.js.map +1 -0
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.d.ts +6 -0
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js +21 -0
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -0
- package/cjs/data/table/tr/DataTableTr.js +11 -11
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js +1 -1
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/cjs/utils/components/floating/Floating.d.ts +16 -1
- package/cjs/utils/components/floating/Floating.js +50 -13
- package/cjs/utils/components/floating/Floating.js.map +1 -1
- package/cjs/utils/components/floating-menu/Menu.js +1 -1
- package/cjs/utils/components/floating-menu/Menu.js.map +1 -1
- package/cjs/utils/helpers/create-strict-context.js +1 -1
- package/cjs/utils/helpers/create-strict-context.js.map +1 -1
- package/cjs/utils/hooks/useControllableState.d.ts +5 -5
- package/cjs/utils/hooks/useControllableState.js.map +1 -1
- package/cjs/utils/hooks/useValueAsRef.js +1 -1
- package/cjs/utils/hooks/useValueAsRef.js.map +1 -1
- package/cjs/utils-external/hooks/useId.js +1 -1
- package/cjs/utils-external/hooks/useId.js.map +1 -1
- package/esm/action-menu/ActionMenu.js +1 -1
- package/esm/action-menu/ActionMenu.js.map +1 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +11 -12
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/esm/data/drag-and-drop/root/DragAndDrop.context.d.ts +4 -2
- package/esm/data/drag-and-drop/root/DragAndDrop.context.js.map +1 -1
- package/esm/data/drag-and-drop/root/DragAndDropRoot.d.ts +5 -5
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js +49 -28
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/esm/data/drag-and-drop/types.d.ts +0 -4
- package/esm/data/{drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.d.ts → drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.d.ts} +3 -3
- package/esm/data/{drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js → drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js} +4 -4
- package/esm/data/drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.js.map +1 -0
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.d.ts +27 -0
- package/esm/data/{drag-and-drop-old/item/DataDragAndDropItem.js → drag-and-drop-legacy/item/DragAndDropItemLegacy.js} +11 -11
- package/esm/data/drag-and-drop-legacy/item/DragAndDropItemLegacy.js.map +1 -0
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.d.ts +5 -0
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js +3 -0
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacy.context.js.map +1 -0
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.d.ts +24 -0
- package/esm/data/{drag-and-drop-old/root/DataDragAndDropRoot.js → drag-and-drop-legacy/root/DragAndDropLegacyRoot.js} +8 -8
- package/esm/data/drag-and-drop-legacy/root/DragAndDropLegacyRoot.js.map +1 -0
- package/esm/data/stories/Data.test-data.d.ts +24 -0
- package/esm/data/stories/Data.test-data.js +1606 -0
- package/esm/data/stories/Data.test-data.js.map +1 -0
- package/esm/data/table/column-header/DataTableColumnHeader.d.ts +4 -1
- package/esm/data/table/column-header/DataTableColumnHeader.js +4 -4
- package/esm/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/esm/data/table/column-header/useTableColumnResize.d.ts +21 -18
- package/esm/data/table/column-header/useTableColumnResize.js +7 -25
- package/esm/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +6 -0
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js +27 -0
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -0
- package/esm/data/table/helpers/collectTableRowEntries.d.ts +9 -7
- package/esm/data/table/helpers/collectTableRowEntries.js +21 -14
- package/esm/data/table/helpers/collectTableRowEntries.js.map +1 -1
- package/esm/data/table/helpers/table-focus.d.ts +0 -3
- package/esm/data/table/helpers/table-focus.js +38 -8
- package/esm/data/table/helpers/table-focus.js.map +1 -1
- package/esm/data/table/hooks/useColumnOptions.js +18 -5
- package/esm/data/table/hooks/useColumnOptions.js.map +1 -1
- package/esm/data/table/hooks/useGridCache.js +2 -2
- package/esm/data/table/hooks/useGridCache.js.map +1 -1
- package/esm/data/table/hooks/useTableDetailsPanel.d.ts +62 -0
- package/esm/data/table/hooks/{useTableExpansion.js → useTableDetailsPanel.js} +18 -17
- package/esm/data/table/hooks/useTableDetailsPanel.js.map +1 -0
- package/esm/data/table/hooks/useTableItems.d.ts +14 -17
- package/esm/data/table/hooks/useTableItems.js +17 -16
- package/esm/data/table/hooks/useTableItems.js.map +1 -1
- package/esm/data/table/hooks/useTableKeyboardNav.js +6 -2
- package/esm/data/table/hooks/useTableKeyboardNav.js.map +1 -1
- package/esm/data/table/hooks/useTableSelection.d.ts +4 -2
- package/esm/data/table/hooks/useTableSelection.js +6 -1
- package/esm/data/table/hooks/useTableSelection.js.map +1 -1
- package/esm/data/table/index.d.ts +1 -2
- package/esm/data/table/index.js +21 -1
- package/esm/data/table/index.js.map +1 -1
- package/esm/data/table/root/DataTable.types.d.ts +7 -9
- package/esm/data/table/root/DataTableRoot.context.d.ts +5 -1
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +79 -115
- package/esm/data/table/root/DataTableRoot.js +170 -36
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.legacy.d.ts +177 -0
- package/esm/data/table/root/DataTableRoot.legacy.js +59 -0
- package/esm/data/table/root/DataTableRoot.legacy.js.map +1 -0
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.d.ts +6 -0
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js +16 -0
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -0
- package/esm/data/table/tr/DataTableTr.js +11 -11
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/utils/components/dismissablelayer/DismissableLayer.js +1 -1
- package/esm/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/esm/utils/components/floating/Floating.d.ts +16 -1
- package/esm/utils/components/floating/Floating.js +48 -13
- package/esm/utils/components/floating/Floating.js.map +1 -1
- package/esm/utils/components/floating-menu/Menu.js +2 -2
- package/esm/utils/components/floating-menu/Menu.js.map +1 -1
- package/esm/utils/helpers/create-strict-context.js +1 -1
- package/esm/utils/helpers/create-strict-context.js.map +1 -1
- package/esm/utils/hooks/useControllableState.d.ts +5 -5
- package/esm/utils/hooks/useControllableState.js.map +1 -1
- package/esm/utils/hooks/useValueAsRef.js +1 -1
- package/esm/utils/hooks/useValueAsRef.js.map +1 -1
- package/esm/utils-external/hooks/useId.js +1 -1
- package/esm/utils-external/hooks/useId.js.map +1 -1
- package/package.json +8 -7
- package/src/action-menu/ActionMenu.tsx +1 -1
- package/src/data/drag-and-drop/drag-handler/DragAndDropDragHandler.tsx +11 -16
- package/src/data/drag-and-drop/root/DragAndDrop.context.tsx +4 -2
- package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +85 -40
- package/src/data/drag-and-drop/types.ts +0 -5
- package/src/data/{drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.tsx → drag-and-drop-legacy/drag-handler/DragAndDropDragHandlerLegacy.tsx} +5 -5
- package/src/data/{drag-and-drop-old/item/DataDragAndDropItem.tsx → drag-and-drop-legacy/item/DragAndDropItemLegacy.tsx} +13 -13
- package/src/data/{drag-and-drop-old/root/DataDragAndDrop.context.tsx → drag-and-drop-legacy/root/DragAndDropLegacy.context.tsx} +3 -3
- package/src/data/{drag-and-drop-old/root/DataDragAndDropRoot.tsx → drag-and-drop-legacy/root/DragAndDropLegacyRoot.tsx} +19 -21
- package/src/data/stories/Data.test-data.tsx +1702 -0
- package/src/data/table/column-header/DataTableColumnHeader.tsx +8 -6
- package/src/data/table/column-header/useTableColumnResize.ts +29 -44
- package/src/data/table/details-panel-row/DataTableDetailsPanelRow.tsx +57 -0
- package/src/data/table/helpers/collectTableRowEntries.ts +36 -30
- package/src/data/table/helpers/table-focus.ts +63 -9
- package/src/data/table/hooks/__tests__/useTableItems.test.ts +58 -12
- package/src/data/table/hooks/__tests__/useTableSelection.test.ts +57 -44
- package/src/data/table/hooks/useColumnOptions.ts +19 -5
- package/src/data/table/hooks/useGridCache.ts +3 -2
- package/src/data/table/hooks/useTableDetailsPanel.tsx +185 -0
- package/src/data/table/hooks/useTableItems.ts +44 -52
- package/src/data/table/hooks/useTableKeyboardNav.ts +6 -2
- package/src/data/table/hooks/useTableSelection.ts +17 -6
- package/src/data/table/index.tsx +5 -3
- package/src/data/table/root/DataTable.types.ts +20 -9
- package/src/data/table/root/DataTableRoot.context.ts +5 -1
- package/src/data/table/root/DataTableRoot.legacy.tsx +297 -0
- package/src/data/table/root/DataTableRoot.tsx +484 -219
- package/src/data/table/root/agent-feature-gap.md +96 -0
- package/src/data/table/sub-row-toggle/DataTableSubRowToggle.tsx +39 -0
- package/src/data/table/tr/DataTableTr.tsx +14 -13
- package/src/utils/components/dismissablelayer/DismissableLayer.tsx +1 -1
- package/src/utils/components/floating/Floating.tsx +56 -13
- package/src/utils/components/floating-menu/Menu.tsx +4 -1
- package/src/utils/helpers/create-strict-context.tsx +1 -1
- package/src/utils/hooks/useControllableState.ts +11 -8
- package/src/utils/hooks/useValueAsRef.ts +1 -1
- package/src/utils-external/hooks/useId.ts +1 -1
- package/cjs/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +0 -1
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +0 -27
- package/cjs/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +0 -1
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +0 -5
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js +0 -6
- package/cjs/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +0 -1
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +0 -24
- package/cjs/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +0 -1
- package/cjs/data/table/hooks/useTableExpansion.d.ts +0 -27
- package/cjs/data/table/hooks/useTableExpansion.js.map +0 -1
- package/cjs/data/table/root/DataTableAuto.d.ts +0 -182
- package/cjs/data/table/root/DataTableAuto.js +0 -206
- package/cjs/data/table/root/DataTableAuto.js.map +0 -1
- package/esm/data/drag-and-drop-old/drag-handler/DataDragAndDropDragHandler.js.map +0 -1
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.d.ts +0 -27
- package/esm/data/drag-and-drop-old/item/DataDragAndDropItem.js.map +0 -1
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.d.ts +0 -5
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js +0 -3
- package/esm/data/drag-and-drop-old/root/DataDragAndDrop.context.js.map +0 -1
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.d.ts +0 -24
- package/esm/data/drag-and-drop-old/root/DataDragAndDropRoot.js.map +0 -1
- package/esm/data/table/hooks/useTableExpansion.d.ts +0 -27
- package/esm/data/table/hooks/useTableExpansion.js.map +0 -1
- package/esm/data/table/root/DataTableAuto.d.ts +0 -182
- package/esm/data/table/root/DataTableAuto.js +0 -170
- package/esm/data/table/root/DataTableAuto.js.map +0 -1
- package/src/data/table/hooks/useTableExpansion.tsx +0 -146
- package/src/data/table/root/DataTableAuto.test.tsx +0 -244
- package/src/data/table/root/DataTableAuto.tsx +0 -612
|
@@ -7,56 +7,47 @@ import {
|
|
|
7
7
|
collectTableRowEntries,
|
|
8
8
|
} from "../helpers/collectTableRowEntries";
|
|
9
9
|
|
|
10
|
+
type SubRowsProps<T> = {
|
|
11
|
+
getRows?: (rowData: T) => T[];
|
|
12
|
+
expandedRowIds?: (string | number)[];
|
|
13
|
+
defaultExpandedRowIds?: (string | number)[];
|
|
14
|
+
isRowExpandable?: (rowData: T) => boolean;
|
|
15
|
+
onExpandedRowIdsChange?: (ids: (string | number)[]) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
10
18
|
type UseTableItemsArgs<T> = {
|
|
11
19
|
items: T[];
|
|
12
|
-
getRowId?: (rowData: T
|
|
13
|
-
|
|
14
|
-
* Master - Detail pattern props
|
|
15
|
-
*/
|
|
16
|
-
/* expandedDetailsPanelIds?: (string | number)[];
|
|
17
|
-
defaultExpandedDetailsPanelIds?: (string | number)[];
|
|
18
|
-
isDetailsPanelExpandable?: (rowData: T) => boolean;
|
|
19
|
-
onDetailsPanelChange?: (ids: (string | number)[]) => void;
|
|
20
|
-
|
|
21
|
-
getDetailsPanelHeight?: (row: T) => number | "auto";
|
|
22
|
-
getDetailsPanelContent?: (row: T) => React.ReactNode; */
|
|
23
|
-
/**
|
|
24
|
-
* Expanded/Nested rows pattern props
|
|
25
|
-
*/
|
|
26
|
-
getSubRows?: (rowData: T) => T[];
|
|
27
|
-
expandedSubRowIds?: (string | number)[];
|
|
28
|
-
defaultExpandedSubRowIds?: (string | number)[];
|
|
29
|
-
isSubRowExpandable?: (rowData: T) => boolean;
|
|
30
|
-
onExpandedSubRowIdsChange?: (ids: (string | number)[]) => void;
|
|
20
|
+
getRowId?: (rowData: T) => TableRowEntryId;
|
|
21
|
+
subRows?: SubRowsProps<T>;
|
|
31
22
|
};
|
|
32
23
|
|
|
33
24
|
type useTableItemsReturn<T> = {
|
|
34
25
|
items: T[];
|
|
35
|
-
itemDetails: Map<
|
|
26
|
+
itemDetails: Map<TableRowEntryId, ItemDetail<T>>;
|
|
36
27
|
/** Row ids for the rows currently rendered in the table body. */
|
|
37
28
|
visibleRowIds: TableRowEntryId[];
|
|
38
29
|
/** Direct child ids for each row, used to traverse selection groups lazily. */
|
|
39
30
|
childRowIdsById: Map<TableRowEntryId, TableRowEntryId[]>;
|
|
40
|
-
|
|
31
|
+
onExpandedRowIdsChange: (id: string | number) => void;
|
|
41
32
|
isSubRowExpanded: (id: string | number) => boolean;
|
|
42
33
|
};
|
|
43
34
|
|
|
44
35
|
function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
36
|
+
const { items, subRows = {}, getRowId } = args;
|
|
37
|
+
|
|
45
38
|
const {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
isSubRowExpandable,
|
|
53
|
-
} = args;
|
|
39
|
+
expandedRowIds,
|
|
40
|
+
defaultExpandedRowIds,
|
|
41
|
+
getRows,
|
|
42
|
+
onExpandedRowIdsChange,
|
|
43
|
+
isRowExpandable,
|
|
44
|
+
} = subRows;
|
|
54
45
|
|
|
55
46
|
const [nestedSubRowsExpandedIds, setNestedSubRowsExpandedIds] =
|
|
56
47
|
useControllableState({
|
|
57
|
-
value:
|
|
58
|
-
defaultValue:
|
|
59
|
-
onChange:
|
|
48
|
+
value: expandedRowIds,
|
|
49
|
+
defaultValue: defaultExpandedRowIds ?? [],
|
|
50
|
+
onChange: onExpandedRowIdsChange,
|
|
60
51
|
});
|
|
61
52
|
|
|
62
53
|
const expandedIdsSet = useMemo(
|
|
@@ -66,32 +57,35 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
66
57
|
|
|
67
58
|
const { itemDetails, visibleItems, visibleRowIds, childRowIdsById } =
|
|
68
59
|
useMemo(() => {
|
|
69
|
-
const {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
60
|
+
const {
|
|
61
|
+
itemDetails: rowEntriesMap,
|
|
62
|
+
rootRowIds,
|
|
63
|
+
childRowIdsById: _childRowIdsById,
|
|
64
|
+
} = collectTableRowEntries({
|
|
65
|
+
items,
|
|
66
|
+
getRowId,
|
|
67
|
+
getRows,
|
|
68
|
+
isRowExpandable,
|
|
69
|
+
});
|
|
76
70
|
|
|
77
71
|
const localVisibleItems: T[] = [];
|
|
78
72
|
const localVisibleRowIds: TableRowEntryId[] = [];
|
|
79
73
|
|
|
80
|
-
const addVisibleRows = (
|
|
81
|
-
const details = rowEntriesMap.get(
|
|
74
|
+
const addVisibleRows = (rowId: TableRowEntryId): TableRowEntryId[] => {
|
|
75
|
+
const details = rowEntriesMap.get(rowId);
|
|
82
76
|
|
|
83
77
|
if (!details) {
|
|
84
78
|
return [];
|
|
85
79
|
}
|
|
86
80
|
|
|
87
|
-
localVisibleItems.push(rowData);
|
|
81
|
+
localVisibleItems.push(details.rowData);
|
|
88
82
|
localVisibleRowIds.push(details.id);
|
|
89
83
|
|
|
90
84
|
const visibleDescendantRowIds: TableRowEntryId[] = [];
|
|
91
85
|
|
|
92
86
|
if (expandedIdsSet.has(details.id)) {
|
|
93
|
-
for (const
|
|
94
|
-
const childVisibleRowIds = addVisibleRows(
|
|
87
|
+
for (const childRowId of details.children) {
|
|
88
|
+
const childVisibleRowIds = addVisibleRows(childRowId);
|
|
95
89
|
visibleDescendantRowIds.push(...childVisibleRowIds);
|
|
96
90
|
}
|
|
97
91
|
}
|
|
@@ -99,8 +93,8 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
99
93
|
return [details.id, ...visibleDescendantRowIds];
|
|
100
94
|
};
|
|
101
95
|
|
|
102
|
-
for (const
|
|
103
|
-
addVisibleRows(
|
|
96
|
+
for (const rowId of rootRowIds) {
|
|
97
|
+
addVisibleRows(rowId);
|
|
104
98
|
}
|
|
105
99
|
|
|
106
100
|
return {
|
|
@@ -109,7 +103,7 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
109
103
|
childRowIdsById: _childRowIdsById,
|
|
110
104
|
itemDetails: rowEntriesMap,
|
|
111
105
|
};
|
|
112
|
-
}, [
|
|
106
|
+
}, [getRows, items, getRowId, isRowExpandable, expandedIdsSet]);
|
|
113
107
|
|
|
114
108
|
const handleExpandedSubRowIdChange = useCallback(
|
|
115
109
|
(id: string | number) => {
|
|
@@ -127,20 +121,18 @@ function useTableItems<T>(args: UseTableItemsArgs<T>): useTableItemsReturn<T> {
|
|
|
127
121
|
itemDetails,
|
|
128
122
|
visibleRowIds,
|
|
129
123
|
childRowIdsById,
|
|
130
|
-
|
|
124
|
+
onExpandedRowIdsChange: handleExpandedSubRowIdChange,
|
|
131
125
|
isSubRowExpanded: (id: string | number) => expandedIdsSet.has(id),
|
|
132
126
|
};
|
|
133
127
|
}
|
|
134
128
|
|
|
135
129
|
const { Provider: TableItemsProvider, useContext: useTableItemsContext } =
|
|
136
130
|
/* TODO: Can we type this better? */
|
|
137
|
-
createStrictContext<
|
|
138
|
-
Omit<useTableItemsReturn<any>, "visibleRowIds" | "childRowIdsById">
|
|
139
|
-
>({
|
|
131
|
+
createStrictContext<Omit<useTableItemsReturn<any>, "childRowIdsById">>({
|
|
140
132
|
name: "TableItemsContext",
|
|
141
133
|
errorMessage:
|
|
142
134
|
"useTableItemsContext must be used within a TableItemsProvider",
|
|
143
135
|
});
|
|
144
136
|
|
|
145
137
|
export { useTableItems, TableItemsProvider, useTableItemsContext };
|
|
146
|
-
export type { ItemDetail };
|
|
138
|
+
export type { ItemDetail, SubRowsProps };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
2
|
import { useEventCallback } from "../../../utils/hooks";
|
|
3
3
|
import { focusInitialTableTarget } from "../helpers/table-cell";
|
|
4
|
-
import { focusCellAndUpdateTabIndex } from "../helpers/table-focus";
|
|
4
|
+
import { focusCell, focusCellAndUpdateTabIndex } from "../helpers/table-focus";
|
|
5
5
|
import {
|
|
6
6
|
findFirstCell,
|
|
7
7
|
findFirstCellInRow,
|
|
@@ -137,6 +137,10 @@ function useTableKeyboardNav({
|
|
|
137
137
|
const target = event.target as Element | null;
|
|
138
138
|
|
|
139
139
|
if (tableRef && target === tableRef) {
|
|
140
|
+
if (activeCell) {
|
|
141
|
+
focusCell(activeCell);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
140
144
|
focusInitialTableTarget(tableRef);
|
|
141
145
|
return;
|
|
142
146
|
}
|
|
@@ -173,7 +177,7 @@ function useTableKeyboardNav({
|
|
|
173
177
|
|
|
174
178
|
return {
|
|
175
179
|
/* Table should only have tabIndex until the focus is moved inside and is enabled */
|
|
176
|
-
tabIndex: enabled ?
|
|
180
|
+
tabIndex: enabled ? 0 : undefined,
|
|
177
181
|
setTableRef,
|
|
178
182
|
};
|
|
179
183
|
}
|
|
@@ -9,7 +9,8 @@ import type {
|
|
|
9
9
|
TableSelection,
|
|
10
10
|
} from "../helpers/selection/selection.types";
|
|
11
11
|
|
|
12
|
-
type UseTableSelectionArgs =
|
|
12
|
+
type UseTableSelectionArgs = {
|
|
13
|
+
selection?: SelectionProps;
|
|
13
14
|
/* Visible rows manage the header checkbox state and render selection cells. */
|
|
14
15
|
visibleRowIds: (string | number)[];
|
|
15
16
|
/* Direct child ids let selection walk nested rows lazily. */
|
|
@@ -19,17 +20,23 @@ type UseTableSelectionArgs = SelectionProps & {
|
|
|
19
20
|
type UseTableSelectionReturn = {
|
|
20
21
|
selection: TableSelection;
|
|
21
22
|
renderSelection: boolean;
|
|
23
|
+
disableRowSelectionOnClick: boolean;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
function useTableSelection({
|
|
25
|
-
|
|
26
|
-
defaultSelectedKeys,
|
|
27
|
-
selectedKeys: selectedKeysProp,
|
|
28
|
-
onSelectionChange,
|
|
29
|
-
disabledSelectionKeys = [],
|
|
27
|
+
selection = {},
|
|
30
28
|
visibleRowIds = [],
|
|
31
29
|
childRowIdsById,
|
|
32
30
|
}: UseTableSelectionArgs): UseTableSelectionReturn {
|
|
31
|
+
const {
|
|
32
|
+
selectionMode = "none",
|
|
33
|
+
defaultSelectedKeys,
|
|
34
|
+
selectedKeys: selectedKeysProp,
|
|
35
|
+
onSelectionChange,
|
|
36
|
+
disabledSelectionKeys = [],
|
|
37
|
+
disableRowSelectionOnClick = false,
|
|
38
|
+
} = selection;
|
|
39
|
+
|
|
33
40
|
const radioGroupName = useId();
|
|
34
41
|
|
|
35
42
|
const [selectedKeys, setSelectedKeys] = useControllableState<SelectedKeysT>({
|
|
@@ -59,6 +66,7 @@ function useTableSelection({
|
|
|
59
66
|
...baseSelection,
|
|
60
67
|
selectedKeys: [],
|
|
61
68
|
},
|
|
69
|
+
disableRowSelectionOnClick,
|
|
62
70
|
renderSelection: false,
|
|
63
71
|
};
|
|
64
72
|
}
|
|
@@ -75,6 +83,7 @@ function useTableSelection({
|
|
|
75
83
|
name: radioGroupName,
|
|
76
84
|
}),
|
|
77
85
|
},
|
|
86
|
+
disableRowSelectionOnClick,
|
|
78
87
|
renderSelection: visibleRowIds.length !== 0,
|
|
79
88
|
};
|
|
80
89
|
}
|
|
@@ -92,6 +101,7 @@ function useTableSelection({
|
|
|
92
101
|
childRowIdsById,
|
|
93
102
|
}),
|
|
94
103
|
},
|
|
104
|
+
disableRowSelectionOnClick,
|
|
95
105
|
renderSelection: visibleRowIds.length !== 0,
|
|
96
106
|
};
|
|
97
107
|
}
|
|
@@ -106,6 +116,7 @@ const noSelectionState: UseTableSelectionReturn = {
|
|
|
106
116
|
disabledSelectionKeys: [],
|
|
107
117
|
isRowSelected: () => false,
|
|
108
118
|
},
|
|
119
|
+
disableRowSelectionOnClick: false,
|
|
109
120
|
renderSelection: false,
|
|
110
121
|
};
|
|
111
122
|
|
package/src/data/table/index.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export {
|
|
2
|
+
/* export {
|
|
3
3
|
default as DataTable,
|
|
4
4
|
DataTableCaption,
|
|
5
5
|
DataTableThead,
|
|
@@ -8,7 +8,7 @@ export {
|
|
|
8
8
|
DataTableTh,
|
|
9
9
|
DataTableTd,
|
|
10
10
|
DataTableTfoot,
|
|
11
|
-
} from "./root/DataTableRoot";
|
|
11
|
+
} from "./root/DataTableRoot.legacy";
|
|
12
12
|
export type {
|
|
13
13
|
DataTableProps,
|
|
14
14
|
DataTableCaptionProps,
|
|
@@ -18,4 +18,6 @@ export type {
|
|
|
18
18
|
DataTableThProps,
|
|
19
19
|
DataTableTdProps,
|
|
20
20
|
DataTableTfootProps,
|
|
21
|
-
} from "./root/DataTableRoot";
|
|
21
|
+
} from "./root/DataTableRoot.legacy"; */
|
|
22
|
+
|
|
23
|
+
export { DataTable, type DataTableProps } from "./root/DataTableRoot";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ResizeProps } from "../column-header/useTableColumnResize";
|
|
2
|
+
|
|
1
3
|
type SortDirection = "asc" | "desc" | "none";
|
|
2
4
|
|
|
3
5
|
/**
|
|
@@ -5,12 +7,17 @@ type SortDirection = "asc" | "desc" | "none";
|
|
|
5
7
|
* - Consider "accessorKey" or similar to allow simple column definitions without a cell function.
|
|
6
8
|
* - Add "align" property for better control over text alignment in cells.
|
|
7
9
|
*/
|
|
8
|
-
type ColumnDefinition<T
|
|
10
|
+
type ColumnDefinition<T, DetailsT = Record<string, any>> = Pick<
|
|
11
|
+
ResizeProps,
|
|
12
|
+
| "resizable"
|
|
13
|
+
| "width"
|
|
14
|
+
| "defaultWidth"
|
|
15
|
+
| "autoWidth"
|
|
16
|
+
| "minWidth"
|
|
17
|
+
| "maxWidth"
|
|
18
|
+
| "onWidthChange"
|
|
19
|
+
> & {
|
|
9
20
|
id: string;
|
|
10
|
-
width?: number | string;
|
|
11
|
-
defaultWidth?: number | string;
|
|
12
|
-
minWidth?: number | string;
|
|
13
|
-
maxWidth?: number | string;
|
|
14
21
|
/**
|
|
15
22
|
* Text alignment for cells in this column.
|
|
16
23
|
*
|
|
@@ -22,9 +29,6 @@ type ColumnDefinition<T> = {
|
|
|
22
29
|
* Assigned to the cell's `th` element instead of `td` if true.
|
|
23
30
|
*
|
|
24
31
|
* Should be used for cells that act as row headers. Each row should have one rowheader, and only have one cell with `isRowHeader: true`,
|
|
25
|
-
*
|
|
26
|
-
* TODO: Not implemented
|
|
27
|
-
* - Add a generic tablecell component that can render either a td or th based on context or this prop.
|
|
28
32
|
*/
|
|
29
33
|
isRowHeader?: boolean;
|
|
30
34
|
/**
|
|
@@ -44,9 +48,16 @@ type ColumnDefinition<T> = {
|
|
|
44
48
|
* Use `sort` and `onSortChange` on the root component to control sort state.
|
|
45
49
|
*/
|
|
46
50
|
sortable?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Additional metadata that can be used for filtering or other purposes. Not used by the table itself.
|
|
53
|
+
*/
|
|
54
|
+
details?: DetailsT;
|
|
47
55
|
};
|
|
48
56
|
|
|
49
|
-
type ColumnDefinitions<T
|
|
57
|
+
type ColumnDefinitions<T, DetailsT = Record<string, any>> = ColumnDefinition<
|
|
58
|
+
T,
|
|
59
|
+
DetailsT
|
|
60
|
+
>[];
|
|
50
61
|
|
|
51
62
|
/**
|
|
52
63
|
* A single sort entry representing a column's current sort state.
|
|
@@ -14,10 +14,14 @@ type DataTableContextProps<T> = {
|
|
|
14
14
|
rowId: string | number,
|
|
15
15
|
event: React.MouseEvent<HTMLTableRowElement>,
|
|
16
16
|
) => void;
|
|
17
|
-
disableRowSelectionOnClick: boolean;
|
|
18
17
|
isLoading?: boolean;
|
|
19
18
|
showLoadingOverlay: boolean;
|
|
20
19
|
columns: UseColumnOptionsResult<T>["columns"];
|
|
20
|
+
/**
|
|
21
|
+
* Used to set exact colspan for detailsPanel, loadingState and emptyState.
|
|
22
|
+
* This is necessary to ensure that these components span the entire width of the table.
|
|
23
|
+
*/
|
|
24
|
+
fullWidthColSpan: number;
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
const { Provider: DataTableContextProvider, useContext: useDataTableContext } =
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
|
+
import { useId } from "../../../utils-external";
|
|
3
|
+
import { cl } from "../../../utils/helpers";
|
|
4
|
+
import { useMergeRefs } from "../../../utils/hooks";
|
|
5
|
+
import {
|
|
6
|
+
DataTableCaption,
|
|
7
|
+
type DataTableCaptionProps,
|
|
8
|
+
} from "../caption/DataTableCaption";
|
|
9
|
+
import {
|
|
10
|
+
DataTableEmptyState,
|
|
11
|
+
type DataTableEmptyStateProps,
|
|
12
|
+
} from "../empty-state/DataTableEmptyState";
|
|
13
|
+
import { DataTableDetailsPanelProvider } from "../hooks/useTableDetailsPanel";
|
|
14
|
+
import { useTableKeyboardNav } from "../hooks/useTableKeyboardNav";
|
|
15
|
+
import {
|
|
16
|
+
type SelectionProps,
|
|
17
|
+
noSelectionState,
|
|
18
|
+
} from "../hooks/useTableSelection";
|
|
19
|
+
import {
|
|
20
|
+
DataTableLoadingState,
|
|
21
|
+
type DataTableLoadingStateProps,
|
|
22
|
+
} from "../loading-state/DataTableLoadingState";
|
|
23
|
+
import {
|
|
24
|
+
DataTableTbody,
|
|
25
|
+
type DataTableTbodyProps,
|
|
26
|
+
} from "../tbody/DataTableTbody";
|
|
27
|
+
import { DataTableTd, type DataTableTdProps } from "../td/DataTableTd";
|
|
28
|
+
import {
|
|
29
|
+
DataTableTfoot,
|
|
30
|
+
type DataTableTfootProps,
|
|
31
|
+
} from "../tfoot/DataTableTfoot";
|
|
32
|
+
import { DataTableTh, type DataTableThProps } from "../th/DataTableTh";
|
|
33
|
+
import {
|
|
34
|
+
DataTableThead,
|
|
35
|
+
type DataTableTheadProps,
|
|
36
|
+
} from "../thead/DataTableThead";
|
|
37
|
+
import { DataTableTr, type DataTableTrProps } from "../tr/DataTableTr";
|
|
38
|
+
import { DataTableContextProvider } from "./DataTableRoot.context";
|
|
39
|
+
|
|
40
|
+
interface DataTableProps
|
|
41
|
+
extends React.HTMLAttributes<HTMLTableElement>, SelectionProps {
|
|
42
|
+
children: React.ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Controls vertical cell padding.
|
|
45
|
+
* @default "normal"
|
|
46
|
+
*/
|
|
47
|
+
rowDensity?: "condensed" | "normal" | "spacious";
|
|
48
|
+
/**
|
|
49
|
+
* Zebra striped table
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
zebraStripes?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Truncate content in cells and show ellipsis for overflowed text.
|
|
55
|
+
*
|
|
56
|
+
* **NB:** When using `layout="auto"`, you have to manually set a `maxWidth` on columns that should be truncated.
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
truncateContent?: boolean; // TODO: Consider making this default false when layout=auto, and maybe disallow it but add a wrap prop on the td-comp.
|
|
60
|
+
/**
|
|
61
|
+
* Enables keyboard navigation for table rows and cells.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
withKeyboardNav?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Custom callback to determine if navigation should be blocked.
|
|
67
|
+
* Called before default blocking logic.
|
|
68
|
+
* Requires `withKeyboardNav` to be `true`.
|
|
69
|
+
*/
|
|
70
|
+
shouldBlockNavigation?: (event: KeyboardEvent) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Controls table layout.
|
|
73
|
+
*
|
|
74
|
+
* ### fixed
|
|
75
|
+
* Gives you full control of column widths. This is required for resizable columns.
|
|
76
|
+
*
|
|
77
|
+
* ### auto
|
|
78
|
+
* Makes the columns resize automatically based on the content.
|
|
79
|
+
* The table will take up at least 100% of available width.
|
|
80
|
+
*
|
|
81
|
+
* **NB:** When using this with `truncateContent`, you have to manually
|
|
82
|
+
* set a `contentMaxWidth` on cells that should be truncated.
|
|
83
|
+
* @default "fixed"
|
|
84
|
+
*/
|
|
85
|
+
layout?: "fixed" | "auto";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface DataTableRootComponent extends React.ForwardRefExoticComponent<
|
|
89
|
+
DataTableProps & React.RefAttributes<HTMLTableElement>
|
|
90
|
+
> {
|
|
91
|
+
/**
|
|
92
|
+
* @see 🏷️ {@link DataTableCaptionProps}
|
|
93
|
+
* @example
|
|
94
|
+
* ```jsx
|
|
95
|
+
* <DataTable>
|
|
96
|
+
* <DataTable.Caption>
|
|
97
|
+
* Lorem ipsum
|
|
98
|
+
* </DataTable.Caption
|
|
99
|
+
* </DataTable>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
Caption: typeof DataTableCaption;
|
|
103
|
+
/**
|
|
104
|
+
* @see 🏷️ {@link DataTableTheadProps}
|
|
105
|
+
* @example
|
|
106
|
+
* ```jsx
|
|
107
|
+
* <DataTable>
|
|
108
|
+
* <DataTable.Thead>
|
|
109
|
+
* ... TODO
|
|
110
|
+
* </DataTable.Thead>
|
|
111
|
+
* </DataTable>
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
Thead: typeof DataTableThead;
|
|
115
|
+
/**
|
|
116
|
+
* @see 🏷️ {@link DataTableTbodyProps}
|
|
117
|
+
* @example
|
|
118
|
+
* ```jsx
|
|
119
|
+
* <DataTable>
|
|
120
|
+
* <DataTable.Tbody>
|
|
121
|
+
* ... TODO
|
|
122
|
+
* </DataTable.Tbody>
|
|
123
|
+
* </DataTable>
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
Tbody: typeof DataTableTbody;
|
|
127
|
+
/**
|
|
128
|
+
* @see 🏷️ {@link DataTableTrProps}
|
|
129
|
+
* @example
|
|
130
|
+
* ```jsx
|
|
131
|
+
* <DataTable>
|
|
132
|
+
* <DataTable.Tr>
|
|
133
|
+
* ... TODO
|
|
134
|
+
* </DataTable.Tr
|
|
135
|
+
* </DataTable>
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
Tr: typeof DataTableTr;
|
|
139
|
+
/**
|
|
140
|
+
* @see 🏷️ {@link DataTableThProps}
|
|
141
|
+
* @example
|
|
142
|
+
* ```jsx
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
Th: typeof DataTableTh;
|
|
146
|
+
/**
|
|
147
|
+
* @see 🏷️ {@link DataTableTdProps}
|
|
148
|
+
* @example
|
|
149
|
+
* ```jsx
|
|
150
|
+
* <DataTable>
|
|
151
|
+
* <DataTable.Tbody>
|
|
152
|
+
* <DataTable.Td>
|
|
153
|
+
* Lorem ipsum
|
|
154
|
+
* </DataTable.Td>
|
|
155
|
+
* <DataTable.Td>
|
|
156
|
+
* Dolor sit amet
|
|
157
|
+
* </DataTable.Td>
|
|
158
|
+
* </DataTable.Tbody>
|
|
159
|
+
* </DataTable>
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
Td: typeof DataTableTd;
|
|
163
|
+
/**
|
|
164
|
+
* @see 🏷️ {@link DataTableTfootProps}
|
|
165
|
+
* @example
|
|
166
|
+
* ```jsx
|
|
167
|
+
* <DataTable>
|
|
168
|
+
* <DataTable.Tfoot>
|
|
169
|
+
* ...
|
|
170
|
+
* </DataTable.Tfoot>
|
|
171
|
+
* </DataTable>
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
Tfoot: typeof DataTableTfoot;
|
|
175
|
+
/**
|
|
176
|
+
* @see 🏷️ {@link DataTableEmptyStateProps}
|
|
177
|
+
* @example
|
|
178
|
+
* ```jsx
|
|
179
|
+
* <DataTable>
|
|
180
|
+
* <DataTable.TBody>
|
|
181
|
+
* <DataTable.EmptyState />
|
|
182
|
+
* </DataTable.TBody>
|
|
183
|
+
* </DataTable>
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
EmptyState: typeof DataTableEmptyState;
|
|
187
|
+
/**
|
|
188
|
+
* @see 🏷️ {@link DataTableEmptyStateProps}
|
|
189
|
+
* @example
|
|
190
|
+
* ```jsx
|
|
191
|
+
* <DataTable>
|
|
192
|
+
* <DataTable.TBody>
|
|
193
|
+
* <DataTable.LoadingState />
|
|
194
|
+
* </DataTable.TBody>
|
|
195
|
+
* </DataTable>
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
LoadingState: typeof DataTableLoadingState;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* TODO Component description etc.
|
|
203
|
+
*
|
|
204
|
+
* **NB:** To get sticky headers, you have to set a height restriction on the table container. You can use VStack for this:
|
|
205
|
+
* TODO example
|
|
206
|
+
*/
|
|
207
|
+
const DataTable = forwardRef<HTMLTableElement, DataTableProps>(
|
|
208
|
+
(
|
|
209
|
+
{
|
|
210
|
+
className,
|
|
211
|
+
rowDensity = "normal",
|
|
212
|
+
withKeyboardNav = false,
|
|
213
|
+
zebraStripes = false,
|
|
214
|
+
truncateContent = true,
|
|
215
|
+
shouldBlockNavigation,
|
|
216
|
+
layout = "fixed",
|
|
217
|
+
...rest
|
|
218
|
+
},
|
|
219
|
+
forwardedRef,
|
|
220
|
+
) => {
|
|
221
|
+
const { tabIndex, setTableRef } = useTableKeyboardNav({
|
|
222
|
+
enabled: withKeyboardNav,
|
|
223
|
+
shouldBlockNavigation,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const mergedRef = useMergeRefs(forwardedRef, setTableRef);
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<DataTableContextProvider
|
|
230
|
+
layout={layout}
|
|
231
|
+
withKeyboardNav={withKeyboardNav}
|
|
232
|
+
selectionState={noSelectionState}
|
|
233
|
+
stickySelection={false}
|
|
234
|
+
stickyHeader={true}
|
|
235
|
+
tableId={useId()}
|
|
236
|
+
showLoadingSkeletons={false}
|
|
237
|
+
onRowClick={undefined}
|
|
238
|
+
showLoadingOverlay={false}
|
|
239
|
+
columns={[]}
|
|
240
|
+
fullWidthColSpan={9999}
|
|
241
|
+
>
|
|
242
|
+
<DataTableDetailsPanelProvider>
|
|
243
|
+
<div className="aksel-data-table__border-wrapper">
|
|
244
|
+
<div className="aksel-data-table__scroll-wrapper">
|
|
245
|
+
<table
|
|
246
|
+
{...rest}
|
|
247
|
+
ref={mergedRef}
|
|
248
|
+
className={cl("aksel-data-table", className)}
|
|
249
|
+
data-zebra-stripes={zebraStripes}
|
|
250
|
+
data-truncate-content={truncateContent}
|
|
251
|
+
data-density={rowDensity}
|
|
252
|
+
data-layout={layout}
|
|
253
|
+
tabIndex={tabIndex}
|
|
254
|
+
/>
|
|
255
|
+
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</DataTableDetailsPanelProvider>
|
|
258
|
+
</DataTableContextProvider>
|
|
259
|
+
);
|
|
260
|
+
},
|
|
261
|
+
) as DataTableRootComponent;
|
|
262
|
+
|
|
263
|
+
DataTable.Caption = DataTableCaption;
|
|
264
|
+
DataTable.Thead = DataTableThead;
|
|
265
|
+
DataTable.Tbody = DataTableTbody;
|
|
266
|
+
DataTable.Th = DataTableTh;
|
|
267
|
+
DataTable.Tr = DataTableTr;
|
|
268
|
+
DataTable.Td = DataTableTd;
|
|
269
|
+
DataTable.Tfoot = DataTableTfoot;
|
|
270
|
+
DataTable.EmptyState = DataTableEmptyState;
|
|
271
|
+
DataTable.LoadingState = DataTableLoadingState;
|
|
272
|
+
|
|
273
|
+
export {
|
|
274
|
+
DataTable,
|
|
275
|
+
DataTableCaption,
|
|
276
|
+
DataTableEmptyState,
|
|
277
|
+
DataTableLoadingState,
|
|
278
|
+
DataTableTbody,
|
|
279
|
+
DataTableTd,
|
|
280
|
+
DataTableTfoot,
|
|
281
|
+
DataTableTh,
|
|
282
|
+
DataTableThead,
|
|
283
|
+
DataTableTr,
|
|
284
|
+
};
|
|
285
|
+
export default DataTable;
|
|
286
|
+
export type {
|
|
287
|
+
DataTableCaptionProps,
|
|
288
|
+
DataTableEmptyStateProps,
|
|
289
|
+
DataTableLoadingStateProps,
|
|
290
|
+
DataTableProps,
|
|
291
|
+
DataTableTbodyProps,
|
|
292
|
+
DataTableTdProps,
|
|
293
|
+
DataTableTfootProps,
|
|
294
|
+
DataTableTheadProps,
|
|
295
|
+
DataTableThProps,
|
|
296
|
+
DataTableTrProps,
|
|
297
|
+
};
|