@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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { forwardRef, useMemo } from "react";
|
|
13
|
+
import { DataGridTable } from "../../data/table/root/DataGridTableRoot.js";
|
|
14
|
+
import { cl } from "../../utils/helpers/index.js";
|
|
15
|
+
import { DataGridContextProvider } from "./DataGridRoot.context.js";
|
|
16
|
+
/**
|
|
17
|
+
* Component for displaying tabular data.
|
|
18
|
+
*
|
|
19
|
+
* **WARNING: This component is in active development and may receive breaking changes outside major releases!**
|
|
20
|
+
*
|
|
21
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/datagrid)
|
|
22
|
+
* @see 🏷️ {@link DataGridProps}
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```jsx
|
|
26
|
+
* <DataGrid columnDefinitions={columnDefs} data={rowData} getRowId={(row) => row.id}>
|
|
27
|
+
* <DataGrid.Table />
|
|
28
|
+
* </DataGrid>
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
const DataGridInternal = forwardRef((_a, ref) => {
|
|
32
|
+
var { children, className, columns, data, getRowId, selection, isLoading = false, settings } = _a, rest = __rest(_a, ["children", "className", "columns", "data", "getRowId", "selection", "isLoading", "settings"]);
|
|
33
|
+
const resolvedSettings = useMemo(() => {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
return ({
|
|
36
|
+
rowDensity: (_a = settings === null || settings === void 0 ? void 0 : settings.rowDensity) !== null && _a !== void 0 ? _a : "standard",
|
|
37
|
+
zebraStripes: (_b = settings === null || settings === void 0 ? void 0 : settings.zebraStripes) !== null && _b !== void 0 ? _b : false,
|
|
38
|
+
truncateContent: settings === null || settings === void 0 ? void 0 : settings.truncateContent,
|
|
39
|
+
stickyColumns: (_c = settings === null || settings === void 0 ? void 0 : settings.stickyColumns) !== null && _c !== void 0 ? _c : {},
|
|
40
|
+
textSize: (_d = settings === null || settings === void 0 ? void 0 : settings.textSize) !== null && _d !== void 0 ? _d : "medium",
|
|
41
|
+
});
|
|
42
|
+
}, [
|
|
43
|
+
settings === null || settings === void 0 ? void 0 : settings.rowDensity,
|
|
44
|
+
settings === null || settings === void 0 ? void 0 : settings.zebraStripes,
|
|
45
|
+
settings === null || settings === void 0 ? void 0 : settings.truncateContent,
|
|
46
|
+
settings === null || settings === void 0 ? void 0 : settings.stickyColumns,
|
|
47
|
+
settings === null || settings === void 0 ? void 0 : settings.textSize,
|
|
48
|
+
]);
|
|
49
|
+
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cl("aksel-data-grid", className) }),
|
|
50
|
+
React.createElement(DataGridContextProvider, { columnDefinitions: columns, data: data, getRowId: getRowId, selection: selection, isLoading: isLoading, tableSettings: resolvedSettings }, children)));
|
|
51
|
+
});
|
|
52
|
+
const DataGrid = DataGridInternal;
|
|
53
|
+
DataGrid.Table = DataGridTable;
|
|
54
|
+
// eslint-disable-next-line import/export
|
|
55
|
+
export { DataGrid, DataGridInternal }; // DataGridRoot needs to be exported b.c. of docgen
|
|
56
|
+
export default DataGrid;
|
|
57
|
+
//# sourceMappingURL=DataGridRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataGridRoot.js","sourceRoot":"","sources":["../../../src/data-grid/root/DataGridRoot.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AAEzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAwDjE;;;;;;;;;;;;;;GAcG;AACH,MAAM,gBAAgB,GAAG,UAAU,CACjC,CACE,EAUyB,EACzB,GAAG,EACH,EAAE;QAZF,EACE,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,SAAS,GAAG,KAAK,EACjB,QAAQ,OAEe,EADpB,IAAI,cATT,8FAUC,CADQ;IAIT,MAAM,gBAAgB,GAAG,OAAO,CAC9B,GAAG,EAAE;;QAAC,OAAA,CAAC;YACL,UAAU,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,UAAU,mCAAI,UAAU;YAC9C,YAAY,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY,mCAAI,KAAK;YAC7C,eAAe,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,eAAe;YAC1C,aAAa,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa,mCAAI,EAAE;YAC5C,QAAQ,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,mCAAI,QAAQ;SACzC,CAAC,CAAA;KAAA,EACF;QACE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,UAAU;QACpB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,YAAY;QACtB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,eAAe;QACzB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,aAAa;QACvB,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ;KACnB,CACF,CAAC;IAEF,OAAO,CACL,6CAAS,IAAI,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC;QAClE,oBAAC,uBAAuB,IACtB,iBAAiB,EAAE,OAAO,EAC1B,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,gBAAgB,IAE9B,QAAQ,CACe,CACtB,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,MAAM,QAAQ,GAAG,gBAAgD,CAAC;AAClE,QAAQ,CAAC,KAAK,GAAG,aAAa,CAAC;AAsB/B,yCAAyC;AACzC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC,mDAAmD;AAC1F,eAAe,QAAQ,CAAC"}
|
package/esm/preview.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataGrid } from "./data-grid/index.js";
|
package/esm/preview.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../src/preview.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { forwardRef, useContext } from "react";
|
|
13
13
|
import { ArrowsUpDownIcon, SortDownIcon, SortUpIcon, } from "@navikt/aksel-icons";
|
|
14
|
+
import { consoleWarning } from "../utils/helpers/consoleWarning.js";
|
|
14
15
|
import HeaderCell from "./HeaderCell.js";
|
|
15
16
|
import { TableContext } from "./context.js";
|
|
16
17
|
export const ColumnHeader = forwardRef((_a, ref) => {
|
|
@@ -18,7 +19,7 @@ export const ColumnHeader = forwardRef((_a, ref) => {
|
|
|
18
19
|
var { children, sortable = false, sortKey } = _a, rest = __rest(_a, ["children", "sortable", "sortKey"]);
|
|
19
20
|
const context = useContext(TableContext);
|
|
20
21
|
if (sortable && !sortKey) {
|
|
21
|
-
|
|
22
|
+
consoleWarning("ColumnHeader with `sortable=true` must have a sortKey.");
|
|
22
23
|
}
|
|
23
24
|
return (React.createElement(HeaderCell, Object.assign({ scope: "col", ref: ref, "aria-sort": sortable
|
|
24
25
|
? ((_b = context === null || context === void 0 ? void 0 : context.sort) === null || _b === void 0 ? void 0 : _b.orderBy) === sortKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnHeader.js","sourceRoot":"","sources":["../../src/table/ColumnHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,UAA+B,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAkBzC,MAAM,CAAC,MAAM,YAAY,GAAqB,UAAU,CACtD,CAAC,EAAgD,EAAE,GAAG,EAAE,EAAE;;QAAzD,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,OAAW,EAAN,IAAI,cAA9C,mCAAgD,CAAF;IAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEzC,IAAI,QAAQ,IAAI,CAAC,OAAO,EAAE,CAAC;QACzB,
|
|
1
|
+
{"version":3,"file":"ColumnHeader.js","sourceRoot":"","sources":["../../src/table/ColumnHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,UAAU,GACX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,UAA+B,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAkBzC,MAAM,CAAC,MAAM,YAAY,GAAqB,UAAU,CACtD,CAAC,EAAgD,EAAE,GAAG,EAAE,EAAE;;QAAzD,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,OAAO,OAAW,EAAN,IAAI,cAA9C,mCAAgD,CAAF;IAC7C,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAEzC,IAAI,QAAQ,IAAI,CAAC,OAAO,EAAE,CAAC;QACzB,cAAc,CAAC,wDAAwD,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CACL,oBAAC,UAAU,kBACT,KAAK,EAAC,KAAK,EACX,GAAG,EAAE,GAAG,eAEN,QAAQ;YACN,CAAC,CAAC,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,OAAO,MAAK,OAAO;gBAClC,CAAC,CAAC,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,SAAS;gBAC1B,CAAC,CAAC,MAAM;YACV,CAAC,CAAC,SAAS,IAEX,IAAI,GAGP,QAAQ,CAAC,CAAC,CAAC,CACV,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,0BAA0B,EACpC,OAAO,EACL,QAAQ,IAAI,OAAO;YACjB,CAAC,CAAC,GAAG,EAAE,WAAC,OAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,wDAAG,OAAO,CAAC,CAAA,EAAA;YACxC,CAAC,CAAC,SAAS;QAGd,QAAQ;QACR,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,OAAO,MAAK,OAAO,CAAC,CAAC,CAAC,CACpC,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,0CAAE,SAAS,MAAK,YAAY,CAAC,CAAC,CAAC,CAC1C,oBAAC,YAAY,0BAAe,CAC7B,CAAC,CAAC,CAAC,CACF,oBAAC,UAAU,0BAAe,CAC3B,CACF,CAAC,CAAC,CAAC,CACF,oBAAC,gBAAgB,0BAAe,CACjC,CACM,CACV,CAAC,CAAC,CAAC,CACF,QAAQ,CACT,CACU,CACd,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.11.0",
|
|
4
4
|
"description": "React components from the Norwegian Labour and Welfare Administration.",
|
|
5
5
|
"author": "Aksel, a team part of the Norwegian Labour and Welfare Administration.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -46,6 +46,26 @@
|
|
|
46
46
|
"default": "./cjs/index.js"
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
+
"./PREVIEW": {
|
|
50
|
+
"import": {
|
|
51
|
+
"types": "./esm/preview.d.ts",
|
|
52
|
+
"default": "./esm/preview.js"
|
|
53
|
+
},
|
|
54
|
+
"require": {
|
|
55
|
+
"types": "./cjs/preview.d.ts",
|
|
56
|
+
"default": "./cjs/preview.js"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"./PREVIEW/DataGrid": {
|
|
60
|
+
"import": {
|
|
61
|
+
"types": "./esm/data-grid/index.d.ts",
|
|
62
|
+
"default": "./esm/data-grid/index.js"
|
|
63
|
+
},
|
|
64
|
+
"require": {
|
|
65
|
+
"types": "./cjs/data-grid/index.d.ts",
|
|
66
|
+
"default": "./cjs/data-grid/index.js"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
49
69
|
"./types/theme": {
|
|
50
70
|
"types": "./esm/types/theme.d.ts"
|
|
51
71
|
},
|
|
@@ -706,8 +726,8 @@
|
|
|
706
726
|
"dependencies": {
|
|
707
727
|
"@floating-ui/react": "0.27.19",
|
|
708
728
|
"@floating-ui/react-dom": "^2.1.8",
|
|
709
|
-
"@navikt/aksel-icons": "^8.
|
|
710
|
-
"@navikt/ds-tokens": "^8.
|
|
729
|
+
"@navikt/aksel-icons": "^8.11.0",
|
|
730
|
+
"@navikt/ds-tokens": "^8.11.0",
|
|
711
731
|
"date-fns": "^4.0.0",
|
|
712
732
|
"react-day-picker": "9.14.0"
|
|
713
733
|
},
|
|
@@ -10,62 +10,31 @@ import { Floating } from "../../../utils/components/floating/Floating";
|
|
|
10
10
|
import {
|
|
11
11
|
ColumnDefinition,
|
|
12
12
|
ColumnDefinitions,
|
|
13
|
-
} from "../../table/root/
|
|
13
|
+
} from "../../table/root/DataGridTable.types";
|
|
14
14
|
import DragAndDropItem, { DragAndDropItemProps } from "../item/DragAndDropItem";
|
|
15
15
|
import { DragAndDropElement } from "../types";
|
|
16
16
|
import { DragAndDropProvider } from "./DragAndDrop.context";
|
|
17
17
|
|
|
18
|
-
interface DragAndDropProps<
|
|
19
|
-
T
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
items: ColumnDefinitions<T, DetailsT>;
|
|
23
|
-
setItems: React.Dispatch<
|
|
24
|
-
React.SetStateAction<ColumnDefinitions<T, DetailsT>>
|
|
25
|
-
>;
|
|
26
|
-
renderItem: (
|
|
27
|
-
item: ColumnDefinition<T, DetailsT>,
|
|
28
|
-
index: number,
|
|
29
|
-
) => React.ReactNode;
|
|
18
|
+
interface DragAndDropProps<T> extends React.HTMLAttributes<HTMLUListElement> {
|
|
19
|
+
items: ColumnDefinitions<T>;
|
|
20
|
+
setItems: React.Dispatch<React.SetStateAction<ColumnDefinitions<T>>>;
|
|
21
|
+
renderItem: (item: ColumnDefinition<T>, index: number) => React.ReactNode;
|
|
30
22
|
}
|
|
31
23
|
|
|
32
24
|
/**
|
|
33
|
-
* TODO
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* [
|
|
37
|
-
* [x] Overlay - Use floating component
|
|
38
|
-
* [x] Keyboard navigation
|
|
39
|
-
* [x] UU - announce on drag start, item moved, drag end
|
|
40
|
-
* [x] Make overlay same width as the OG item, currently jumps to content width
|
|
41
|
-
* [x] Look into adding a cancel listener event
|
|
42
|
-
* [x] Make onClick work on drag handler button, currently blocked by pointer down/up listeners
|
|
43
|
-
* [x] Talk to design about what should happen on ESC key press, currently just cancels dragging, should it also reset position?
|
|
44
|
-
* [x] Make arrow icons into buttons that react to keyboard events, currently just decorative
|
|
45
|
-
* [x] Keep handler focus after clicking arrows for dragging
|
|
46
|
-
* [x] Look into data-based API vs component-based API
|
|
47
|
-
* [x] Should we have hidden instructions for screen readers on how to use the drag and drop, and should we announce the position of the item while dragging?
|
|
48
|
-
* [x] Discuss if this component should be generic for drag and drop, or if it should be specifically for tables - just for table for now
|
|
49
|
-
* [x] Discuss items type
|
|
50
|
-
* [x] Discuss how to implement label best
|
|
51
|
-
* [ ] Quick nav (< > samtidig) - få piltastene til å fungere
|
|
52
|
-
* [x] Implement new type for items - ColumnDefinitions<T>
|
|
53
|
-
* [x] Remove announcer div and use a live region component instead
|
|
54
|
-
* [x] Make ESC reset position, not just cancel dragging
|
|
55
|
-
* [x] Make instructions for keyboard users (visible?)
|
|
56
|
-
* [ ] Ask design about visible keyboard instructions
|
|
57
|
-
* [ ] Update design from Figma
|
|
25
|
+
* TODO:
|
|
26
|
+
*
|
|
27
|
+
* Backlog:
|
|
28
|
+
* [ ] Quick nav (< > samtidig) - få piltastene til å fungere - ignore?
|
|
58
29
|
* [ ] Look at instructions text
|
|
59
|
-
* [x] Remove default ul styling
|
|
60
|
-
* [x] Fix setItems type
|
|
61
30
|
*
|
|
62
31
|
*/
|
|
63
32
|
|
|
64
33
|
const DRAG_THRESHOLD = 4; // Minimum movement in pixels to start dragging
|
|
65
34
|
const SR_INSTRUCTIONS_ID = "drag-and-drop-instructions-id";
|
|
66
35
|
|
|
67
|
-
function DragAndDropInner<T
|
|
68
|
-
{ items, setItems, renderItem }: DragAndDropProps<T
|
|
36
|
+
function DragAndDropInner<T>(
|
|
37
|
+
{ items, setItems, renderItem }: DragAndDropProps<T>,
|
|
69
38
|
forwardedRef: React.ForwardedRef<HTMLUListElement>,
|
|
70
39
|
) {
|
|
71
40
|
const [activeItem, setActiveItem] = useState<DragAndDropElement | null>(null);
|
|
@@ -74,7 +43,7 @@ function DragAndDropInner<T, DetailsT extends Record<string, any>>(
|
|
|
74
43
|
useState<DragAndDropElement | null>(null);
|
|
75
44
|
const [overlayWidth, setOverlayWidth] = useState<number | null>(null);
|
|
76
45
|
const [announcer, setAnnouncer] = useState("");
|
|
77
|
-
const initialItemsRef = useRef<ColumnDefinitions<T
|
|
46
|
+
const initialItemsRef = useRef<ColumnDefinitions<T> | null>(null);
|
|
78
47
|
const activeData = items.find((item) => item.id === activeItem?.id);
|
|
79
48
|
|
|
80
49
|
const activeItemRef = useRef<DragAndDropElement | null>(null);
|
|
@@ -164,8 +133,8 @@ function DragAndDropInner<T, DetailsT extends Record<string, any>>(
|
|
|
164
133
|
);
|
|
165
134
|
|
|
166
135
|
useEffect(() => {
|
|
167
|
-
/* This useEffect is used to toggle a class on the html element when dragging,
|
|
168
|
-
to prevent cursor issues when dragging over interactive elements,
|
|
136
|
+
/* This useEffect is used to toggle a class on the html element when dragging,
|
|
137
|
+
to prevent cursor issues when dragging over interactive elements,
|
|
169
138
|
and to prevent text selection during dragging. */
|
|
170
139
|
|
|
171
140
|
if (activeItem) {
|
|
@@ -335,7 +304,7 @@ function DragAndDropInner<T, DetailsT extends Record<string, any>>(
|
|
|
335
304
|
key={item.id}
|
|
336
305
|
id={item.id}
|
|
337
306
|
index={index}
|
|
338
|
-
itemLabel={item.
|
|
307
|
+
itemLabel={item.header}
|
|
339
308
|
>
|
|
340
309
|
{renderItem(item, index)}
|
|
341
310
|
</DragAndDropItem>
|
|
@@ -361,7 +330,7 @@ function DragAndDropInner<T, DetailsT extends Record<string, any>>(
|
|
|
361
330
|
id={activeItem.id}
|
|
362
331
|
index={activeItem.index}
|
|
363
332
|
isOverlay
|
|
364
|
-
itemLabel={activeData.
|
|
333
|
+
itemLabel={activeData.header}
|
|
365
334
|
>
|
|
366
335
|
{renderItem(activeData, activeItem.index)}
|
|
367
336
|
</DragAndDropItem>
|
|
@@ -372,11 +341,8 @@ function DragAndDropInner<T, DetailsT extends Record<string, any>>(
|
|
|
372
341
|
);
|
|
373
342
|
}
|
|
374
343
|
|
|
375
|
-
const DragAndDrop = forwardRef(DragAndDropInner) as <
|
|
376
|
-
T
|
|
377
|
-
DetailsT extends Record<string, any>,
|
|
378
|
-
>(
|
|
379
|
-
props: DragAndDropProps<T, DetailsT> & React.RefAttributes<HTMLUListElement>,
|
|
344
|
+
const DragAndDrop = forwardRef(DragAndDropInner) as <T>(
|
|
345
|
+
props: DragAndDropProps<T> & React.RefAttributes<HTMLUListElement>,
|
|
380
346
|
) => React.ReactElement | null;
|
|
381
347
|
|
|
382
348
|
export { DragAndDrop, DragAndDropItem };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { MenuElipsisVerticalIcon } from "@navikt/aksel-icons";
|
|
3
|
+
import { ActionMenu } from "../../action-menu";
|
|
4
|
+
import { Button } from "../../button";
|
|
5
|
+
import { HStack } from "../../primitives/stack";
|
|
2
6
|
import { Tag } from "../../tag";
|
|
3
|
-
import type { ColumnDefinitions } from "../table/root/
|
|
7
|
+
import type { ColumnDefinitions } from "../table/root/DataGridTable.types";
|
|
4
8
|
|
|
5
9
|
type SWData = {
|
|
6
10
|
id: number;
|
|
@@ -17,80 +21,54 @@ type SWData = {
|
|
|
17
21
|
nestedRows: Omit<NestedSWData, "nestedRows">[];
|
|
18
22
|
};
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
visible: boolean;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const columnDef_TEST_DATA: ColumnDefinitions<SWData, Details> = [
|
|
24
|
+
const columnDef_TEST_DATA: ColumnDefinitions<SWData> = [
|
|
25
25
|
{
|
|
26
26
|
id: "id",
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
details: {
|
|
31
|
-
visible: true,
|
|
32
|
-
},
|
|
27
|
+
header: "Id",
|
|
28
|
+
bodyCell: (row) => row.id,
|
|
29
|
+
width: { autoResizeOnce: true },
|
|
33
30
|
},
|
|
34
31
|
{
|
|
35
|
-
|
|
32
|
+
header: "Name",
|
|
36
33
|
id: "name",
|
|
37
|
-
|
|
34
|
+
isRowHeader: true,
|
|
35
|
+
bodyCell: (row) =>
|
|
38
36
|
`${row.name} ${row?.nestedRows?.length > 0 ? `(${row?.nestedRows?.length})` : ""}`,
|
|
39
|
-
details: {
|
|
40
|
-
visible: true,
|
|
41
|
-
},
|
|
42
37
|
},
|
|
43
38
|
{
|
|
44
|
-
|
|
39
|
+
header: "National id",
|
|
45
40
|
id: "nationalId",
|
|
46
|
-
|
|
41
|
+
bodyCell: (row) => row.nationalId,
|
|
47
42
|
align: "right",
|
|
48
|
-
|
|
49
|
-
details: {
|
|
50
|
-
visible: true,
|
|
51
|
-
},
|
|
43
|
+
width: { autoResizeOnce: true },
|
|
52
44
|
},
|
|
53
45
|
{
|
|
54
|
-
|
|
46
|
+
header: "Day job",
|
|
55
47
|
id: "dayJob",
|
|
56
|
-
|
|
57
|
-
details: {
|
|
58
|
-
visible: true,
|
|
59
|
-
},
|
|
48
|
+
bodyCell: (row) => row.dayJob,
|
|
60
49
|
},
|
|
61
50
|
{
|
|
62
|
-
|
|
51
|
+
header: "Supervisor",
|
|
63
52
|
id: "supervisor",
|
|
64
|
-
|
|
65
|
-
details: {
|
|
66
|
-
visible: true,
|
|
67
|
-
},
|
|
53
|
+
bodyCell: (row) => row.supervisor,
|
|
68
54
|
},
|
|
69
55
|
{
|
|
70
|
-
|
|
56
|
+
header: "Date received",
|
|
71
57
|
id: "dateReceived",
|
|
72
|
-
|
|
73
|
-
details: {
|
|
74
|
-
visible: true,
|
|
75
|
-
},
|
|
58
|
+
bodyCell: (row) => row.dateReceived,
|
|
76
59
|
},
|
|
77
60
|
{
|
|
78
|
-
|
|
61
|
+
header: "Message",
|
|
79
62
|
id: "message",
|
|
80
|
-
|
|
81
|
-
details: {
|
|
82
|
-
visible: true,
|
|
83
|
-
},
|
|
63
|
+
bodyCell: (row) => row.message,
|
|
84
64
|
},
|
|
85
65
|
{
|
|
86
|
-
|
|
66
|
+
header: "Age",
|
|
87
67
|
id: "age",
|
|
88
|
-
|
|
68
|
+
bodyCell: (row) => row.age,
|
|
89
69
|
align: "right",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
visible: true,
|
|
93
|
-
},
|
|
70
|
+
width: { autoResizeOnce: true },
|
|
71
|
+
|
|
94
72
|
/* TODO: NOt yet implemented */
|
|
95
73
|
/* footer: ({ table }) => {
|
|
96
74
|
const ages: number[] = [];
|
|
@@ -102,36 +80,69 @@ const columnDef_TEST_DATA: ColumnDefinitions<SWData, Details> = [
|
|
|
102
80
|
}, */
|
|
103
81
|
},
|
|
104
82
|
{
|
|
105
|
-
|
|
83
|
+
header: "Force sensitive",
|
|
106
84
|
id: "forceSensitive",
|
|
107
|
-
|
|
85
|
+
bodyCell: (row) => (
|
|
108
86
|
<Tag
|
|
109
87
|
size="small"
|
|
110
88
|
variant="moderate"
|
|
111
89
|
data-color={row.forceSensitive ? "accent" : "warning"}
|
|
112
90
|
>{`${row.forceSensitive ? "Yes" : "No"}`}</Tag>
|
|
113
91
|
),
|
|
114
|
-
|
|
92
|
+
width: { autoResizeOnce: true },
|
|
115
93
|
align: "center",
|
|
116
|
-
details: {
|
|
117
|
-
visible: true,
|
|
118
|
-
},
|
|
119
94
|
},
|
|
120
95
|
{
|
|
121
|
-
|
|
96
|
+
header: "Home system",
|
|
122
97
|
id: "homeSystem",
|
|
123
|
-
|
|
124
|
-
details: {
|
|
125
|
-
visible: true,
|
|
126
|
-
},
|
|
98
|
+
bodyCell: (row) => row.homeSystem,
|
|
127
99
|
},
|
|
128
100
|
{
|
|
129
|
-
|
|
101
|
+
header: "Skills",
|
|
130
102
|
id: "skills",
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
103
|
+
bodyCell: (row) => (
|
|
104
|
+
<HStack gap="space-8" wrap={false}>
|
|
105
|
+
{row.skills.map((skill) => (
|
|
106
|
+
<Tag key={skill} size="small" variant="moderate">
|
|
107
|
+
{skill}
|
|
108
|
+
</Tag>
|
|
109
|
+
))}
|
|
110
|
+
</HStack>
|
|
111
|
+
),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
header: "Actions",
|
|
115
|
+
id: "actions",
|
|
116
|
+
width: { autoResizeOnce: true },
|
|
117
|
+
bodyCell: (row) => (
|
|
118
|
+
<HStack gap="space-8">
|
|
119
|
+
<Button
|
|
120
|
+
size="xsmall"
|
|
121
|
+
variant="secondary"
|
|
122
|
+
data-color="neutral"
|
|
123
|
+
onClick={() => alert(`Edit ${row.name}`)}
|
|
124
|
+
>
|
|
125
|
+
Edit
|
|
126
|
+
</Button>
|
|
127
|
+
<ActionMenu>
|
|
128
|
+
<ActionMenu.Trigger>
|
|
129
|
+
<Button
|
|
130
|
+
size="xsmall"
|
|
131
|
+
variant="secondary"
|
|
132
|
+
data-color="neutral"
|
|
133
|
+
icon={<MenuElipsisVerticalIcon title="Menu" />}
|
|
134
|
+
/>
|
|
135
|
+
</ActionMenu.Trigger>
|
|
136
|
+
<ActionMenu.Content>
|
|
137
|
+
<ActionMenu.Group label="Actions">
|
|
138
|
+
<ActionMenu.Item>Delete</ActionMenu.Item>
|
|
139
|
+
<ActionMenu.Item>Assign</ActionMenu.Item>
|
|
140
|
+
<ActionMenu.Item>Change status</ActionMenu.Item>
|
|
141
|
+
</ActionMenu.Group>
|
|
142
|
+
</ActionMenu.Content>
|
|
143
|
+
</ActionMenu>
|
|
144
|
+
</HStack>
|
|
145
|
+
),
|
|
135
146
|
},
|
|
136
147
|
];
|
|
137
148
|
|
|
@@ -2,23 +2,25 @@ import React, { forwardRef } from "react";
|
|
|
2
2
|
import { cl } from "../../../utils/helpers";
|
|
3
3
|
import { useDataTableContext } from "../root/DataTableRoot.context";
|
|
4
4
|
|
|
5
|
-
interface DataTableBaseCellProps extends
|
|
5
|
+
interface DataTableBaseCellProps extends Omit<
|
|
6
|
+
React.TdHTMLAttributes<HTMLTableCellElement>,
|
|
7
|
+
"width"
|
|
8
|
+
> {
|
|
6
9
|
/**
|
|
7
|
-
*
|
|
10
|
+
* Text alignment inside cell.
|
|
11
|
+
*
|
|
12
|
+
* Quantitative figures like amounts and percentages should be right‑aligned (but not phone numbers, postal codes etc.)
|
|
8
13
|
* @default "left"
|
|
9
14
|
*/
|
|
10
|
-
|
|
15
|
+
align?: "left" | "center" | "right";
|
|
11
16
|
/**
|
|
12
|
-
*
|
|
17
|
+
* Internal cell type that controls padding, alignment, row-click prevention, and resize behavior.
|
|
18
|
+
* - `"action"`: Centers content, removes cell padding, prevents row click, and disables column resize.
|
|
19
|
+
* Used for selection (checkbox/radio) and expansion (expand/collapse) cells.
|
|
13
20
|
*/
|
|
14
|
-
|
|
15
|
-
rowSpan?: number;
|
|
21
|
+
cellType?: "action";
|
|
16
22
|
/**
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
UNSAFE_isSelection?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* When true, clicking this cell will not trigger `onRowClick` on the row.
|
|
23
|
+
* When true, clicking this cell will not trigger `onRowAction` on the row.
|
|
22
24
|
* Useful for cells that contain their own interactive content or actions
|
|
23
25
|
* that should be independent of row-level click handling.
|
|
24
26
|
*/
|
|
@@ -26,20 +28,15 @@ interface DataTableBaseCellProps extends React.HTMLAttributes<HTMLTableCellEleme
|
|
|
26
28
|
/**
|
|
27
29
|
* Sets a max-width on the content wrapper div inside the cell.
|
|
28
30
|
* This is only needed when using `layout="auto"` together with
|
|
29
|
-
* `truncateContent` on `<
|
|
31
|
+
* `truncateContent` on `<DataGrid.Table>` and you want the cell to be truncated.
|
|
30
32
|
*/
|
|
31
|
-
contentMaxWidth?: number |
|
|
33
|
+
contentMaxWidth?: number | string;
|
|
32
34
|
/**
|
|
33
35
|
* Makes the cell sticky.
|
|
34
36
|
*/
|
|
35
37
|
isSticky?: "start" | "end" | false;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
/**
|
|
39
|
-
* TODO:
|
|
40
|
-
* - Need a "type" or something that centers content instead of relying on isSelection prop.
|
|
41
|
-
* - Need a separate prop do disabled resizing instead of relying on isSelection prop.
|
|
42
|
-
*/
|
|
43
40
|
const DataTableBaseCell = forwardRef<
|
|
44
41
|
HTMLTableCellElement,
|
|
45
42
|
DataTableBaseCellProps & {
|
|
@@ -47,6 +44,12 @@ const DataTableBaseCell = forwardRef<
|
|
|
47
44
|
* Cell type
|
|
48
45
|
*/
|
|
49
46
|
as: "th" | "td";
|
|
47
|
+
/**
|
|
48
|
+
* Content to render before the main cell content.
|
|
49
|
+
*
|
|
50
|
+
* **WARNING: Adding content here that takes up space will probably break auto-resizing!**
|
|
51
|
+
*/
|
|
52
|
+
beforeContent?: React.ReactNode;
|
|
50
53
|
}
|
|
51
54
|
>(
|
|
52
55
|
(
|
|
@@ -54,13 +57,14 @@ const DataTableBaseCell = forwardRef<
|
|
|
54
57
|
className,
|
|
55
58
|
children,
|
|
56
59
|
as: Component,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
beforeContent,
|
|
61
|
+
align = "left",
|
|
62
|
+
cellType,
|
|
60
63
|
preventRowClick,
|
|
61
64
|
contentMaxWidth,
|
|
62
|
-
rowSpan,
|
|
63
65
|
isSticky,
|
|
66
|
+
colSpan,
|
|
67
|
+
rowSpan,
|
|
64
68
|
...rest
|
|
65
69
|
},
|
|
66
70
|
forwardedRef,
|
|
@@ -73,16 +77,22 @@ const DataTableBaseCell = forwardRef<
|
|
|
73
77
|
ref={forwardedRef}
|
|
74
78
|
className={cl("aksel-data-table__cell", className)}
|
|
75
79
|
tabIndex={withKeyboardNav ? -1 : undefined}
|
|
76
|
-
data-align={
|
|
77
|
-
data-
|
|
80
|
+
data-align={align}
|
|
81
|
+
data-cell-type={cellType || undefined}
|
|
78
82
|
data-prevent-row-click={
|
|
79
|
-
preventRowClick ||
|
|
83
|
+
preventRowClick || cellType === "action" || undefined
|
|
80
84
|
}
|
|
81
85
|
data-sticky={isSticky || undefined}
|
|
82
86
|
colSpan={colSpan}
|
|
83
87
|
rowSpan={rowSpan}
|
|
84
88
|
>
|
|
85
|
-
|
|
89
|
+
{beforeContent}
|
|
90
|
+
<div
|
|
91
|
+
className="aksel-data-table__cell-content"
|
|
92
|
+
style={{ maxWidth: contentMaxWidth }}
|
|
93
|
+
>
|
|
94
|
+
{children}
|
|
95
|
+
</div>
|
|
86
96
|
</Component>
|
|
87
97
|
);
|
|
88
98
|
},
|