@navikt/ds-react 8.10.6 → 8.11.1
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 +5 -1
- package/cjs/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.d.ts +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +50 -20
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/cjs/data/stories/Data.test-data.d.ts +2 -2
- package/cjs/data/stories/Data.test-data.js +37 -42
- package/cjs/data/stories/Data.test-data.js.map +1 -1
- package/cjs/data/table/base-cell/DataTableBaseCell.d.ts +4 -4
- package/cjs/data/table/base-cell/DataTableBaseCell.js +2 -2
- package/cjs/data/table/base-cell/DataTableBaseCell.js.map +1 -1
- package/cjs/data/table/column-header/DataTableColumnHeader.d.ts +3 -15
- package/cjs/data/table/column-header/DataTableColumnHeader.js +8 -5
- package/cjs/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/cjs/data/table/column-header/useTableColumnResize.d.ts +2 -4
- package/cjs/data/table/column-header/useTableColumnResize.js +15 -11
- package/cjs/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/cjs/data/table/helpers/collectTableRowEntries.d.ts +1 -1
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.d.ts +6 -5
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js +6 -2
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/getSingleSelectProps.d.ts +3 -3
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js +1 -1
- package/cjs/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/selection.types.d.ts +19 -27
- package/cjs/data/table/helpers/selection/selection.utils.d.ts +1 -1
- package/cjs/data/table/helpers/table-focus.js +1 -1
- package/cjs/data/table/helpers/table-focus.js.map +1 -1
- package/cjs/data/table/hooks/useColumnOptions.d.ts +8 -5
- package/cjs/data/table/hooks/useColumnOptions.js +25 -10
- package/cjs/data/table/hooks/useColumnOptions.js.map +1 -1
- package/cjs/data/table/hooks/useTableDetailsPanel.d.ts +8 -9
- package/cjs/data/table/hooks/useTableDetailsPanel.js.map +1 -1
- package/cjs/data/table/hooks/useTableItems.d.ts +10 -11
- package/cjs/data/table/hooks/useTableItems.js +11 -3
- package/cjs/data/table/hooks/useTableItems.js.map +1 -1
- package/cjs/data/table/hooks/useTableSelection.d.ts +2 -1
- package/cjs/data/table/hooks/useTableSelection.js +46 -29
- package/cjs/data/table/hooks/useTableSelection.js.map +1 -1
- package/cjs/data/table/hooks/useTableSort.d.ts +13 -7
- package/cjs/data/table/hooks/useTableSort.js +8 -9
- 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/{DataTable.types.d.ts → DataGridTable.types.d.ts} +16 -26
- 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/{DataTableRoot.js → DataGridTableRoot.js} +59 -38
- package/cjs/data/table/root/DataGridTableRoot.js.map +1 -0
- package/cjs/data/table/root/DataTableRoot.context.d.ts +6 -2
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/tbody/DataTableTbody.js +3 -3
- package/cjs/data/table/tbody/DataTableTbody.js.map +1 -1
- package/cjs/data/table/tr/DataTableTr.d.ts +3 -3
- package/cjs/data/table/tr/DataTableTr.js +45 -23
- 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 +48 -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/data-grid → data-grid}/root/DataGridRoot.context.js +1 -1
- package/cjs/data-grid/root/DataGridRoot.context.js.map +1 -0
- package/cjs/data-grid/root/DataGridRoot.d.ts +89 -0
- package/cjs/{data/data-grid → data-grid}/root/DataGridRoot.js +35 -8
- package/cjs/data-grid/root/DataGridRoot.js.map +1 -0
- package/cjs/preview.d.ts +1 -0
- package/cjs/{data/data-grid/index.js → preview.js} +3 -3
- package/cjs/preview.js.map +1 -0
- package/cjs/primitives/bleed/Bleed.d.ts +0 -2
- package/cjs/primitives/bleed/Bleed.js.map +1 -1
- package/cjs/table/ColumnHeader.js.map +1 -1
- package/cjs/tabs/Tabs.context.d.ts +1 -1
- package/cjs/tabs/useTabs.d.ts +1 -1
- package/cjs/toggle-group/ToggleGroup.context.d.ts +1 -1
- package/cjs/toggle-group/useToggleGroup.d.ts +1 -1
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js +1 -0
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/cjs/utils/components/dismissablelayer/util/useFocusOutside.d.ts +1 -0
- package/cjs/utils/components/dismissablelayer/util/useFocusOutside.js +11 -1
- package/cjs/utils/components/dismissablelayer/util/useFocusOutside.js.map +1 -1
- package/cjs/utils/hooks/useControllableState.d.ts +1 -1
- package/cjs/utils/hooks/useControllableState.js.map +1 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js +5 -1
- package/esm/data/drag-and-drop/drag-handler/DragAndDropDragHandler.js.map +1 -1
- package/esm/data/drag-and-drop/root/DragAndDropRoot.d.ts +1 -1
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js +51 -21
- package/esm/data/drag-and-drop/root/DragAndDropRoot.js.map +1 -1
- package/esm/data/stories/Data.test-data.d.ts +2 -2
- package/esm/data/stories/Data.test-data.js +37 -42
- package/esm/data/stories/Data.test-data.js.map +1 -1
- package/esm/data/table/base-cell/DataTableBaseCell.d.ts +4 -4
- package/esm/data/table/base-cell/DataTableBaseCell.js +2 -2
- package/esm/data/table/base-cell/DataTableBaseCell.js.map +1 -1
- package/esm/data/table/column-header/DataTableColumnHeader.d.ts +3 -15
- package/esm/data/table/column-header/DataTableColumnHeader.js +8 -5
- package/esm/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/esm/data/table/column-header/useTableColumnResize.d.ts +2 -4
- package/esm/data/table/column-header/useTableColumnResize.js +15 -11
- package/esm/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/esm/data/table/helpers/collectTableRowEntries.d.ts +1 -1
- package/esm/data/table/helpers/selection/getMultipleSelectProps.d.ts +6 -5
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js +6 -2
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/getSingleSelectProps.d.ts +3 -3
- package/esm/data/table/helpers/selection/getSingleSelectProps.js +1 -1
- package/esm/data/table/helpers/selection/getSingleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/selection.types.d.ts +19 -27
- package/esm/data/table/helpers/selection/selection.utils.d.ts +1 -1
- package/esm/data/table/helpers/table-focus.js +1 -1
- package/esm/data/table/helpers/table-focus.js.map +1 -1
- package/esm/data/table/hooks/useColumnOptions.d.ts +8 -5
- package/esm/data/table/hooks/useColumnOptions.js +25 -10
- package/esm/data/table/hooks/useColumnOptions.js.map +1 -1
- package/esm/data/table/hooks/useTableDetailsPanel.d.ts +8 -9
- package/esm/data/table/hooks/useTableDetailsPanel.js.map +1 -1
- package/esm/data/table/hooks/useTableItems.d.ts +10 -11
- package/esm/data/table/hooks/useTableItems.js +11 -3
- package/esm/data/table/hooks/useTableItems.js.map +1 -1
- package/esm/data/table/hooks/useTableSelection.d.ts +2 -1
- package/esm/data/table/hooks/useTableSelection.js +46 -29
- package/esm/data/table/hooks/useTableSelection.js.map +1 -1
- package/esm/data/table/hooks/useTableSort.d.ts +13 -7
- package/esm/data/table/hooks/useTableSort.js +9 -10
- 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/{DataTable.types.d.ts → DataGridTable.types.d.ts} +16 -26
- 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/{DataTableRoot.js → DataGridTableRoot.js} +61 -39
- package/esm/data/table/root/DataGridTableRoot.js.map +1 -0
- package/esm/data/table/root/DataTableRoot.context.d.ts +6 -2
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/tbody/DataTableTbody.js +3 -3
- package/esm/data/table/tbody/DataTableTbody.js.map +1 -1
- package/esm/data/table/tr/DataTableTr.d.ts +3 -3
- package/esm/data/table/tr/DataTableTr.js +45 -23
- 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 +48 -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/data-grid → data-grid}/root/DataGridRoot.context.js +1 -1
- 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 +59 -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/primitives/bleed/Bleed.d.ts +0 -2
- package/esm/primitives/bleed/Bleed.js.map +1 -1
- package/esm/table/ColumnHeader.js.map +1 -1
- package/esm/tabs/Tabs.context.d.ts +1 -1
- package/esm/tabs/useTabs.d.ts +1 -1
- package/esm/toggle-group/ToggleGroup.context.d.ts +1 -1
- package/esm/toggle-group/useToggleGroup.d.ts +1 -1
- package/esm/utils/components/dismissablelayer/DismissableLayer.js +1 -0
- package/esm/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/esm/utils/components/dismissablelayer/util/useFocusOutside.d.ts +1 -0
- package/esm/utils/components/dismissablelayer/util/useFocusOutside.js +12 -2
- package/esm/utils/components/dismissablelayer/util/useFocusOutside.js.map +1 -1
- package/esm/utils/hooks/useControllableState.d.ts +1 -1
- package/esm/utils/hooks/useControllableState.js.map +1 -1
- package/package.json +25 -5
- package/src/data/drag-and-drop/drag-handler/DragAndDropDragHandler.tsx +5 -1
- package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +55 -25
- package/src/data/stories/Data.test-data.tsx +53 -51
- package/src/data/table/base-cell/DataTableBaseCell.tsx +6 -6
- package/src/data/table/column-header/DataTableColumnHeader.tsx +17 -20
- package/src/data/table/column-header/useTableColumnResize.ts +19 -16
- package/src/data/table/helpers/collectTableRowEntries.ts +1 -1
- package/src/data/table/helpers/selection/getMultipleSelectProps.ts +11 -5
- package/src/data/table/helpers/selection/getSingleSelectProps.ts +4 -4
- package/src/data/table/helpers/selection/selection.types.ts +18 -29
- package/src/data/table/helpers/selection/selection.utils.test.ts +1 -1
- package/src/data/table/helpers/selection/selection.utils.ts +1 -1
- package/src/data/table/helpers/table-focus.ts +1 -1
- package/src/data/table/hooks/__tests__/useTableItems.test.ts +1 -1
- package/src/data/table/hooks/useColumnOptions.ts +50 -15
- package/src/data/table/hooks/useTableDetailsPanel.tsx +14 -18
- package/src/data/table/hooks/useTableItems.ts +37 -23
- package/src/data/table/hooks/useTableSelection.ts +62 -45
- package/src/data/table/hooks/useTableSort.ts +29 -17
- package/src/data/table/index.tsx +4 -21
- package/src/data/table/root/{DataTable.types.ts → DataGridTable.types.ts} +17 -30
- package/src/data/table/root/{DataTableRoot.tsx → DataGridTableRoot.tsx} +198 -144
- package/src/data/table/root/DataTableRoot.context.ts +10 -8
- package/src/data/table/sub-row-toggle/DataTableSubRowToggle.tsx +1 -1
- package/src/data/table/tbody/DataTableTbody.tsx +3 -3
- package/src/data/table/tr/DataTableTr.tsx +51 -20
- 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 +46 -0
- package/src/data-grid/root/DataGridRoot.context.ts +21 -0
- package/src/data-grid/root/DataGridRoot.tsx +154 -0
- package/src/preview.ts +2 -0
- package/src/primitives/bleed/Bleed.tsx +0 -2
- package/src/table/ColumnHeader.tsx +1 -0
- package/src/utils/components/dismissablelayer/DismissableLayer.tsx +1 -0
- package/src/utils/components/dismissablelayer/util/useFocusOutside.ts +14 -2
- package/src/utils/hooks/useControllableState.ts +10 -8
- package/cjs/data/data-grid/index.d.ts +0 -2
- package/cjs/data/data-grid/index.js.map +0 -1
- package/cjs/data/data-grid/root/DataGridRoot.context.d.ts +0 -11
- package/cjs/data/data-grid/root/DataGridRoot.context.js.map +0 -1
- package/cjs/data/data-grid/root/DataGridRoot.d.ts +0 -38
- package/cjs/data/data-grid/root/DataGridRoot.js.map +0 -1
- package/cjs/data/table/root/DataTable.types.js.map +0 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +0 -118
- package/cjs/data/table/root/DataTableRoot.js.map +0 -1
- package/cjs/data/table/root/DataTableRoot.legacy.d.ts +0 -172
- package/cjs/data/table/root/DataTableRoot.legacy.js +0 -118
- package/cjs/data/table/root/DataTableRoot.legacy.js.map +0 -1
- package/esm/data/data-grid/index.d.ts +0 -2
- package/esm/data/data-grid/index.js +0 -3
- package/esm/data/data-grid/index.js.map +0 -1
- package/esm/data/data-grid/root/DataGridRoot.context.d.ts +0 -11
- package/esm/data/data-grid/root/DataGridRoot.context.js.map +0 -1
- package/esm/data/data-grid/root/DataGridRoot.d.ts +0 -38
- package/esm/data/data-grid/root/DataGridRoot.js +0 -32
- package/esm/data/data-grid/root/DataGridRoot.js.map +0 -1
- 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 -118
- package/esm/data/table/root/DataTableRoot.js.map +0 -1
- package/esm/data/table/root/DataTableRoot.legacy.d.ts +0 -172
- package/esm/data/table/root/DataTableRoot.legacy.js +0 -73
- package/esm/data/table/root/DataTableRoot.legacy.js.map +0 -1
- package/src/data/data-grid/index.ts +0 -3
- package/src/data/data-grid/root/DataGridRoot.context.ts +0 -16
- package/src/data/data-grid/root/DataGridRoot.tsx +0 -71
- package/src/data/table/Readme.md +0 -11
- package/src/data/table/agent-component-review.md +0 -175
- package/src/data/table/root/DataTableRoot.legacy.tsx +0 -305
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
PlusIcon,
|
|
7
7
|
} from "@navikt/aksel-icons";
|
|
8
8
|
import { Button } from "../../../button";
|
|
9
|
+
import { useDataGridContext } from "../../../data-grid/root/DataGridRoot.context";
|
|
9
10
|
import { CheckboxInput } from "../../../form/checkbox/checkbox-input/CheckboxInput";
|
|
10
11
|
import { RadioInput } from "../../../form/radio/radio-input/RadioInput";
|
|
11
12
|
import { Skeleton } from "../../../skeleton";
|
|
@@ -19,7 +20,7 @@ import {
|
|
|
19
20
|
getDataTableDetailsPanelId,
|
|
20
21
|
useDataTableDetailsPanel,
|
|
21
22
|
} from "../hooks/useTableDetailsPanel";
|
|
22
|
-
import type { TableRowEntryId } from "../root/
|
|
23
|
+
import type { TableRowEntryId } from "../root/DataGridTable.types";
|
|
23
24
|
import {
|
|
24
25
|
useDataTableContext,
|
|
25
26
|
useDataTableLocation,
|
|
@@ -33,7 +34,7 @@ const ACTION_CELL_CSS_WIDTH = `${ACTION_CELL_WIDTH}px`;
|
|
|
33
34
|
type DataTableTrProps = React.HTMLAttributes<HTMLTableRowElement> & {
|
|
34
35
|
selected?: boolean;
|
|
35
36
|
/**
|
|
36
|
-
* Unique identifier for the row, used for selection
|
|
37
|
+
* Unique identifier for the row, used for selection.
|
|
37
38
|
*/
|
|
38
39
|
rowId?: TableRowEntryId;
|
|
39
40
|
};
|
|
@@ -50,20 +51,21 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
50
51
|
},
|
|
51
52
|
forwardedRef,
|
|
52
53
|
) => {
|
|
53
|
-
const { layout,
|
|
54
|
+
const { layout, selectionState, onRowAction, tableItems } =
|
|
54
55
|
useDataTableContext();
|
|
55
56
|
const { location } = useDataTableLocation();
|
|
56
|
-
const { tableItems } = useDataTableContext();
|
|
57
57
|
|
|
58
58
|
const renderFillerCell = layout === "fixed" && children;
|
|
59
59
|
|
|
60
60
|
const selected =
|
|
61
61
|
selectionState.selection.isRowSelected(rowId ?? "") ?? selectedProp;
|
|
62
62
|
|
|
63
|
-
const isSticky = location === "thead" && stickyHeader;
|
|
64
|
-
|
|
65
63
|
const handleClick =
|
|
66
|
-
location === "tbody" &&
|
|
64
|
+
location === "tbody" &&
|
|
65
|
+
rowId !== undefined &&
|
|
66
|
+
((selectionState.selectionTrigger === "row" &&
|
|
67
|
+
selectionState.selection.mode !== "none") ||
|
|
68
|
+
onRowAction)
|
|
67
69
|
? (event: React.MouseEvent<HTMLTableRowElement>) => {
|
|
68
70
|
if (
|
|
69
71
|
rowId === undefined ||
|
|
@@ -75,6 +77,26 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
if (onRowAction) {
|
|
81
|
+
const rowData = tableItems.itemDetails.get(rowId)?.rowData;
|
|
82
|
+
|
|
83
|
+
if (rowData) {
|
|
84
|
+
onRowAction({
|
|
85
|
+
row: rowData,
|
|
86
|
+
id: rowId,
|
|
87
|
+
event,
|
|
88
|
+
});
|
|
89
|
+
} else {
|
|
90
|
+
consoleWarning(
|
|
91
|
+
`DataGrid.Table: Unable to find row data for rowId ${rowId} when calling onRowAction.`,
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (event.defaultPrevented) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
78
100
|
const selection = window.getSelection();
|
|
79
101
|
if (selection && selection.toString().length > 0) {
|
|
80
102
|
return;
|
|
@@ -82,18 +104,17 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
82
104
|
|
|
83
105
|
if (
|
|
84
106
|
selectionState.selectionTrigger === "row" &&
|
|
85
|
-
selectionState.selection.
|
|
107
|
+
selectionState.selection.mode !== "none"
|
|
86
108
|
) {
|
|
87
109
|
const rowData = tableItems.itemDetails.get(rowId)?.rowData;
|
|
88
110
|
|
|
89
111
|
if (!rowData) {
|
|
90
112
|
consoleWarning(
|
|
91
|
-
`No row data found for rowId ${rowId}. This may cause issues with selection if enableRowSelection is used.`,
|
|
113
|
+
`DataGrid.Table: No row data found for rowId ${rowId}. This may cause issues with selection if enableRowSelection is used.`,
|
|
92
114
|
);
|
|
93
115
|
}
|
|
94
116
|
selectionState.selection.toggleSelection(rowId, rowData);
|
|
95
117
|
}
|
|
96
|
-
onRowClick?.(rowId, event);
|
|
97
118
|
}
|
|
98
119
|
: undefined;
|
|
99
120
|
|
|
@@ -107,7 +128,6 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
107
128
|
ref={forwardedRef}
|
|
108
129
|
className={cl("aksel-data-table__tr", className)}
|
|
109
130
|
data-selected={selected}
|
|
110
|
-
data-sticky={isSticky || undefined}
|
|
111
131
|
>
|
|
112
132
|
<RowExpansionCell rowId={rowId} />
|
|
113
133
|
<RowSelectionCell rowId={rowId} />
|
|
@@ -126,9 +146,12 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
126
146
|
);
|
|
127
147
|
|
|
128
148
|
function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
149
|
+
const { isLoading } = useDataGridContext();
|
|
129
150
|
const { tableId, loading, stickyStart } = useDataTableContext();
|
|
130
151
|
const stickyExpansion = stickyStart.expansion;
|
|
131
152
|
|
|
153
|
+
const expansionHeaderId = useId();
|
|
154
|
+
|
|
132
155
|
const { location } = useDataTableLocation();
|
|
133
156
|
|
|
134
157
|
const {
|
|
@@ -145,10 +168,11 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
145
168
|
return null;
|
|
146
169
|
}
|
|
147
170
|
|
|
148
|
-
if (
|
|
171
|
+
if (isLoading && loading?.variant === "skeleton") {
|
|
149
172
|
if (location === "thead") {
|
|
150
173
|
return (
|
|
151
174
|
<DataTableColumnHeader
|
|
175
|
+
id={expansionHeaderId}
|
|
152
176
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
153
177
|
cellType="action"
|
|
154
178
|
data-block-keyboard-nav
|
|
@@ -172,6 +196,7 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
172
196
|
if (location === "thead" && !showExpandAll) {
|
|
173
197
|
return (
|
|
174
198
|
<DataTableColumnHeader
|
|
199
|
+
id={expansionHeaderId}
|
|
175
200
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
176
201
|
cellType="action"
|
|
177
202
|
data-block-keyboard-nav
|
|
@@ -185,7 +210,8 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
185
210
|
if (location === "thead") {
|
|
186
211
|
return (
|
|
187
212
|
<DataTableColumnHeader
|
|
188
|
-
|
|
213
|
+
id={expansionHeaderId}
|
|
214
|
+
align="center"
|
|
189
215
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
190
216
|
cellType="action"
|
|
191
217
|
label=""
|
|
@@ -261,6 +287,7 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
261
287
|
* TODO: a11y for labels
|
|
262
288
|
*/
|
|
263
289
|
function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
290
|
+
const { isLoading } = useDataGridContext();
|
|
264
291
|
const { selectionState, stickyStart, loading } = useDataTableContext();
|
|
265
292
|
const stickySelection = stickyStart.selection;
|
|
266
293
|
const stickySelectionOffset = stickyStart.selectionOffset;
|
|
@@ -269,17 +296,19 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
269
296
|
const { tableItems } = useDataTableContext();
|
|
270
297
|
|
|
271
298
|
const inputId = useId();
|
|
299
|
+
const selectionHeaderId = useId();
|
|
272
300
|
|
|
273
301
|
const { selection, renderSelection } = selectionState;
|
|
274
302
|
|
|
275
|
-
if (selection.
|
|
303
|
+
if (selection.mode === "none" || !renderSelection) {
|
|
276
304
|
return null;
|
|
277
305
|
}
|
|
278
306
|
|
|
279
|
-
if (
|
|
307
|
+
if (isLoading && loading?.variant === "skeleton") {
|
|
280
308
|
if (location === "thead") {
|
|
281
309
|
return (
|
|
282
310
|
<DataTableColumnHeader
|
|
311
|
+
id={selectionHeaderId}
|
|
283
312
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
284
313
|
cellType="action"
|
|
285
314
|
label=""
|
|
@@ -302,7 +331,7 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
302
331
|
}
|
|
303
332
|
|
|
304
333
|
/* TODO: A11y support */
|
|
305
|
-
if (selection.
|
|
334
|
+
if (selection.mode === "multiple" && location === "thead") {
|
|
306
335
|
const theadCheckboxProps = selection.getTheadCheckboxProps();
|
|
307
336
|
|
|
308
337
|
let labelText = "Velg alle synlige rader";
|
|
@@ -312,7 +341,8 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
312
341
|
|
|
313
342
|
return (
|
|
314
343
|
<DataTableColumnHeader
|
|
315
|
-
|
|
344
|
+
id={selectionHeaderId}
|
|
345
|
+
align="center"
|
|
316
346
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
317
347
|
cellType="action"
|
|
318
348
|
label=""
|
|
@@ -327,9 +357,10 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
327
357
|
);
|
|
328
358
|
}
|
|
329
359
|
|
|
330
|
-
if (selection.
|
|
360
|
+
if (selection.mode === "single" && location === "thead") {
|
|
331
361
|
return (
|
|
332
362
|
<DataTableColumnHeader
|
|
363
|
+
id={selectionHeaderId}
|
|
333
364
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
334
365
|
cellType="action"
|
|
335
366
|
label=""
|
|
@@ -344,7 +375,7 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
344
375
|
return null;
|
|
345
376
|
}
|
|
346
377
|
|
|
347
|
-
if (selection.
|
|
378
|
+
if (selection.mode === "multiple" && location === "tbody") {
|
|
348
379
|
return (
|
|
349
380
|
<DataTableTd
|
|
350
381
|
cellType="action"
|
|
@@ -362,7 +393,7 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
362
393
|
);
|
|
363
394
|
}
|
|
364
395
|
|
|
365
|
-
if (selection.
|
|
396
|
+
if (selection.mode === "single" && location === "tbody") {
|
|
366
397
|
return (
|
|
367
398
|
<DataTableTd
|
|
368
399
|
cellType="action"
|
|
@@ -23,7 +23,7 @@ type TokenFilterProps = {
|
|
|
23
23
|
options: ExternalOptions;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
/*
|
|
27
27
|
* TODO:
|
|
28
28
|
* - Implement onChange handler to update query state when user selects an autocomplete option.
|
|
29
29
|
* - Handle token rendering and editing (e.g., show tokens for matched properties/operators/values, allow deleting tokens).
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type DataGridSettings = {
|
|
2
|
+
/**
|
|
3
|
+
* Controls vertical cell padding.
|
|
4
|
+
* @default "standard"
|
|
5
|
+
*/
|
|
6
|
+
rowDensity?: "tight" | "standard" | "loose";
|
|
7
|
+
/**
|
|
8
|
+
* Zebra striped table
|
|
9
|
+
* @default false
|
|
10
|
+
*/
|
|
11
|
+
zebraStripes?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Truncate content in cells and show ellipsis for overflowed text.
|
|
14
|
+
*
|
|
15
|
+
* **NB:** When using this together with `layout="auto"`,
|
|
16
|
+
* you have to manually set a `maxWidth` on columns that should be truncated.
|
|
17
|
+
* @default false if layout="auto", else true
|
|
18
|
+
*/
|
|
19
|
+
truncateContent?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Sticky columns that remain visible when horizontally scrolling the table.
|
|
22
|
+
*
|
|
23
|
+
* You can specify 1 sticky column on the left and 1 on the right.
|
|
24
|
+
*/
|
|
25
|
+
stickyColumns?: {
|
|
26
|
+
start?: 1;
|
|
27
|
+
end?: 1;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Adjusts font-size
|
|
31
|
+
* @default "medium"
|
|
32
|
+
*/
|
|
33
|
+
textSize?: "small" | "medium";
|
|
34
|
+
/**
|
|
35
|
+
* Optional configuration for column order and visibility.
|
|
36
|
+
*
|
|
37
|
+
* If provided, only columns listed here are rendered, and the array order
|
|
38
|
+
* determines the rendered column order.
|
|
39
|
+
*
|
|
40
|
+
* Set `visible: false` to hide a column without removing it from the list.
|
|
41
|
+
* Each `id` must be unique and match a column `id` in the `columns` prop.
|
|
42
|
+
*/
|
|
43
|
+
columnDisplay?: { id: string; visible: boolean }[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type { DataGridSettings };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SelectionProps } from "../../data/table/hooks/useTableSelection";
|
|
2
|
+
import type { ColumnDefinitions } from "../../data/table/root/DataGridTable.types";
|
|
3
|
+
import { createStrictContext } from "../../utils/helpers";
|
|
4
|
+
import type { DataGridSettings } from "./DataGrid.types";
|
|
5
|
+
|
|
6
|
+
type DataGridContextValue<RowT = unknown> = {
|
|
7
|
+
data: RowT[];
|
|
8
|
+
columnDefinitions: ColumnDefinitions<RowT>;
|
|
9
|
+
getRowId?: (rowData: RowT) => string;
|
|
10
|
+
selection?: SelectionProps<RowT>;
|
|
11
|
+
isLoading?: boolean;
|
|
12
|
+
tableSettings?: DataGridSettings;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const { Provider: DataGridContextProvider, useContext: useDataGridContext } =
|
|
16
|
+
createStrictContext<DataGridContextValue>({
|
|
17
|
+
name: "DataGridContext",
|
|
18
|
+
errorMessage: "DataGrid hooks must be used within a <DataGrid />",
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { DataGridContextProvider, useDataGridContext };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import React, { forwardRef, useMemo } from "react";
|
|
2
|
+
import type { SelectionProps } from "../../data/table/hooks/useTableSelection";
|
|
3
|
+
import type { ColumnDefinitions } from "../../data/table/root/DataGridTable.types";
|
|
4
|
+
import { DataGridTable } from "../../data/table/root/DataGridTableRoot";
|
|
5
|
+
import { cl } from "../../utils/helpers";
|
|
6
|
+
import type { DataGridSettings } from "./DataGrid.types";
|
|
7
|
+
import { DataGridContextProvider } from "./DataGridRoot.context";
|
|
8
|
+
|
|
9
|
+
interface DataGridProps<RowT> {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
/**
|
|
14
|
+
* Definitions of the columns to display.
|
|
15
|
+
*/
|
|
16
|
+
columns: ColumnDefinitions<RowT>;
|
|
17
|
+
/**
|
|
18
|
+
* The data to display.
|
|
19
|
+
*
|
|
20
|
+
* Each object in the array represents a row, and the properties of the
|
|
21
|
+
* object are used to render the cells based on `columnDefinitions`.
|
|
22
|
+
*/
|
|
23
|
+
data: RowT[];
|
|
24
|
+
/**
|
|
25
|
+
* Function to get unique row ID from row data.
|
|
26
|
+
*
|
|
27
|
+
* If not provided, the row index will be used as ID.
|
|
28
|
+
* This can cause issues if your data changes dynamically,
|
|
29
|
+
* so it's recommended to provide a stable ID if possible.
|
|
30
|
+
*/
|
|
31
|
+
getRowId?: (rowData: RowT) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Object with props related to row selection.
|
|
34
|
+
*/
|
|
35
|
+
selection?: SelectionProps<RowT>;
|
|
36
|
+
/**
|
|
37
|
+
* Determines if the data grid is in a loading state.
|
|
38
|
+
* See `loadingContent` prop on the `DataGrid.Table` component for display settings.
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
isLoading?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Settings for the data grid.
|
|
44
|
+
*/
|
|
45
|
+
settings?: DataGridSettings;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface DataGridComponent {
|
|
49
|
+
<RowT>(
|
|
50
|
+
props: DataGridProps<RowT> & React.RefAttributes<HTMLDivElement>,
|
|
51
|
+
): React.ReactElement | null;
|
|
52
|
+
/**
|
|
53
|
+
* @see 🏷️ {@link DataGridTableProps}
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* <DataGrid columnDefinitions={columnDefs} data={rowData} getRowId={(row) => row.id}>
|
|
57
|
+
* <DataGrid.Table />
|
|
58
|
+
* </DataGrid>
|
|
59
|
+
*/
|
|
60
|
+
Table: typeof DataGridTable;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Component for displaying tabular data.
|
|
65
|
+
*
|
|
66
|
+
* **WARNING: This component is in active development and may receive breaking changes outside major releases!**
|
|
67
|
+
*
|
|
68
|
+
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/datagrid)
|
|
69
|
+
* @see 🏷️ {@link DataGridProps}
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```jsx
|
|
73
|
+
* <DataGrid columnDefinitions={columnDefs} data={rowData} getRowId={(row) => row.id}>
|
|
74
|
+
* <DataGrid.Table />
|
|
75
|
+
* </DataGrid>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
const DataGridInternal = forwardRef<HTMLDivElement, DataGridProps<any>>(
|
|
79
|
+
(
|
|
80
|
+
{
|
|
81
|
+
children,
|
|
82
|
+
className,
|
|
83
|
+
columns,
|
|
84
|
+
data,
|
|
85
|
+
getRowId,
|
|
86
|
+
selection,
|
|
87
|
+
isLoading = false,
|
|
88
|
+
settings,
|
|
89
|
+
...rest
|
|
90
|
+
}: DataGridProps<unknown>,
|
|
91
|
+
ref,
|
|
92
|
+
) => {
|
|
93
|
+
const resolvedSettings = useMemo(
|
|
94
|
+
() => ({
|
|
95
|
+
rowDensity: settings?.rowDensity ?? "standard",
|
|
96
|
+
zebraStripes: settings?.zebraStripes ?? false,
|
|
97
|
+
truncateContent: settings?.truncateContent,
|
|
98
|
+
stickyColumns: settings?.stickyColumns ?? {},
|
|
99
|
+
textSize: settings?.textSize ?? "medium",
|
|
100
|
+
columnDisplay: settings?.columnDisplay,
|
|
101
|
+
}),
|
|
102
|
+
[
|
|
103
|
+
settings?.rowDensity,
|
|
104
|
+
settings?.zebraStripes,
|
|
105
|
+
settings?.truncateContent,
|
|
106
|
+
settings?.stickyColumns,
|
|
107
|
+
settings?.textSize,
|
|
108
|
+
settings?.columnDisplay,
|
|
109
|
+
],
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div {...rest} ref={ref} className={cl("aksel-data-grid", className)}>
|
|
114
|
+
<DataGridContextProvider
|
|
115
|
+
columnDefinitions={columns}
|
|
116
|
+
data={data}
|
|
117
|
+
getRowId={getRowId}
|
|
118
|
+
selection={selection}
|
|
119
|
+
isLoading={isLoading}
|
|
120
|
+
tableSettings={resolvedSettings}
|
|
121
|
+
>
|
|
122
|
+
{children}
|
|
123
|
+
</DataGridContextProvider>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
},
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const DataGrid = DataGridInternal as unknown as DataGridComponent;
|
|
130
|
+
DataGrid.Table = DataGridTable;
|
|
131
|
+
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace, import/export
|
|
133
|
+
export namespace DataGrid {
|
|
134
|
+
export type Props<T = unknown> = DataGridProps<T>;
|
|
135
|
+
export type Columns<T = unknown> = ColumnDefinitions<T>;
|
|
136
|
+
export type Selection<T = unknown> = SelectionProps<T>;
|
|
137
|
+
export type Settings = DataGridSettings;
|
|
138
|
+
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
140
|
+
export namespace Table {
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
142
|
+
export type Props<T = unknown> = DataGridTable.Props<T>;
|
|
143
|
+
export type Sorting = DataGridTable.Sorting;
|
|
144
|
+
export type SortEntry = DataGridTable.SortEntry;
|
|
145
|
+
export type SortChangeDetail = DataGridTable.SortChangeDetail;
|
|
146
|
+
export type LoadingContent = DataGridTable.LoadingContent;
|
|
147
|
+
export type SubRows<T = unknown> = DataGridTable.SubRows<T>;
|
|
148
|
+
export type DetailsPanel<T = unknown> = DataGridTable.DetailsPanel<T>;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// eslint-disable-next-line import/export
|
|
153
|
+
export { DataGrid, DataGridInternal }; // DataGridRoot needs to be exported b.c. of docgen
|
|
154
|
+
export default DataGrid;
|
package/src/preview.ts
ADDED
|
@@ -13,7 +13,6 @@ export interface BleedProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
13
13
|
* Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#space)
|
|
14
14
|
* or an object of spacing tokens for different breakpoints.
|
|
15
15
|
*
|
|
16
|
-
* The `px` value is useful to nudge by just 1px.
|
|
17
16
|
* The `full` value is used to extend the margin to the full width of the parent.
|
|
18
17
|
*
|
|
19
18
|
* @example
|
|
@@ -29,7 +28,6 @@ export interface BleedProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
29
28
|
* Accepts a [spacing token](https://aksel.nav.no/grunnleggende/styling/design-tokens#space)
|
|
30
29
|
* or an object of spacing tokens for different breakpoints.
|
|
31
30
|
*
|
|
32
|
-
* The `px` value is useful to nudge by just 1px.
|
|
33
31
|
* This prop does **not** accept the `full` value.
|
|
34
32
|
*
|
|
35
33
|
* @example
|
|
@@ -460,6 +460,7 @@ const DismissableLayer = forwardRef<HTMLDivElement, DismissableLayerProps>(
|
|
|
460
460
|
() => {
|
|
461
461
|
pointerDownOutside.onPointerDownCapture();
|
|
462
462
|
pointerUpOutside.onPointerDownCapture();
|
|
463
|
+
focusOutside.onPointerDownCapture();
|
|
463
464
|
},
|
|
464
465
|
)}
|
|
465
466
|
onPointerUpCapture={composeEventHandlers(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
|
-
import { useEventCallback } from "../../../hooks";
|
|
2
|
+
import { useEventCallback, useTimeout } from "../../../hooks";
|
|
3
3
|
import {
|
|
4
4
|
CUSTOM_EVENTS,
|
|
5
5
|
CustomFocusEvent,
|
|
@@ -16,6 +16,8 @@ export function useFocusOutside(
|
|
|
16
16
|
) {
|
|
17
17
|
const handleFocusOutside = useEventCallback(callback) as EventListener;
|
|
18
18
|
const isFocusInsideReactTreeRef = useRef(false);
|
|
19
|
+
const skipFocusCheckRef = useRef(false);
|
|
20
|
+
const timeout = useTimeout();
|
|
19
21
|
|
|
20
22
|
useEffect(() => {
|
|
21
23
|
if (!enabled) {
|
|
@@ -23,7 +25,11 @@ export function useFocusOutside(
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const handleFocus = (event: FocusEvent) => {
|
|
26
|
-
if (
|
|
28
|
+
if (
|
|
29
|
+
event.target &&
|
|
30
|
+
!isFocusInsideReactTreeRef.current &&
|
|
31
|
+
!skipFocusCheckRef.current
|
|
32
|
+
) {
|
|
27
33
|
const eventDetail = { originalEvent: event };
|
|
28
34
|
|
|
29
35
|
/**
|
|
@@ -59,5 +65,11 @@ export function useFocusOutside(
|
|
|
59
65
|
onBlurCapture: () => {
|
|
60
66
|
isFocusInsideReactTreeRef.current = false;
|
|
61
67
|
},
|
|
68
|
+
onPointerDownCapture: () => {
|
|
69
|
+
skipFocusCheckRef.current = true;
|
|
70
|
+
timeout.start(0, () => {
|
|
71
|
+
skipFocusCheckRef.current = false;
|
|
72
|
+
});
|
|
73
|
+
},
|
|
62
74
|
};
|
|
63
75
|
}
|
|
@@ -25,16 +25,18 @@ export function useControllableState<StateT, ChangeT extends StateT = StateT>({
|
|
|
25
25
|
const controlled = valueProp !== undefined;
|
|
26
26
|
const value = controlled ? valueProp : uncontrolledState;
|
|
27
27
|
|
|
28
|
-
const setValue = useEventCallback(
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const setValue = useEventCallback(
|
|
29
|
+
(next: ChangeT | ((prevState: StateT) => ChangeT)) => {
|
|
30
|
+
const setter = next as (prevState?: StateT) => ChangeT;
|
|
31
|
+
const nextValue = typeof next === "function" ? setter(value) : next;
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
if (!controlled) {
|
|
34
|
+
setUncontrolledState(nextValue);
|
|
35
|
+
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
onChangeProp(nextValue);
|
|
38
|
+
},
|
|
39
|
+
);
|
|
38
40
|
|
|
39
41
|
return [value, setValue] as const;
|
|
40
42
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data/data-grid/index.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AACb,oDAA+D;AAAtD,wGAAA,YAAY,OAAY"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ColumnDefinitions } from "../../table/root/DataTable.types";
|
|
2
|
-
type DataGridContextValue<RowDef = unknown> = {
|
|
3
|
-
data: RowDef[];
|
|
4
|
-
columnDefinitions: ColumnDefinitions<RowDef>;
|
|
5
|
-
getRowId?: (rowData: RowDef) => string;
|
|
6
|
-
};
|
|
7
|
-
declare const DataGridContextProvider: import("react").FC<DataGridContextValue<unknown> & {
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
ref?: never;
|
|
10
|
-
}>, useDataGridContext: <S extends boolean = true>(strict?: S | undefined) => S extends true ? DataGridContextValue<unknown> : DataGridContextValue<unknown> | undefined;
|
|
11
|
-
export { DataGridContextProvider, useDataGridContext };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridRoot.context.js","sourceRoot":"","sources":["../../../../src/data/data-grid/root/DataGridRoot.context.ts"],"names":[],"mappings":";;;AAAA,oDAA6D;AAS7D,MAAM,EAAE,QAAQ,EAAE,uBAAuB,EAAE,UAAU,EAAE,kBAAkB,EAAE,GACzE,IAAA,6BAAmB,EAAuB;IACxC,IAAI,EAAE,iBAAiB;IACvB,YAAY,EAAE,mDAAmD;CAClE,CAAC,CAAC;AAEI,0DAAuB;AAAE,gDAAkB"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { HTMLAttributes } from "react";
|
|
2
|
-
import type { ColumnDefinitions } from "../../table/root/DataTable.types";
|
|
3
|
-
type RowTId = string;
|
|
4
|
-
export interface DataGridProps<RowT> extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
/**
|
|
7
|
-
* Definitions of the columns to display in the data grid.
|
|
8
|
-
*
|
|
9
|
-
* Each column definition should have a unique `id` and a `cell`-renderer function that takes the row data as argument and returns a React node.
|
|
10
|
-
*/
|
|
11
|
-
columnDefinitions: ColumnDefinitions<RowT>;
|
|
12
|
-
/**
|
|
13
|
-
* The data to display.
|
|
14
|
-
*
|
|
15
|
-
* Each object in the array represents a row, and the properties of the object are used to render the cells based on the `columnDefinitions`.
|
|
16
|
-
*/
|
|
17
|
-
data: RowT[];
|
|
18
|
-
/**
|
|
19
|
-
* Function to get unique row id from row data.
|
|
20
|
-
*
|
|
21
|
-
* If not provided, the row index will be used as id. This can cause issues if your data changes dynamically, so it's recommended to provide a stable id if possible.
|
|
22
|
-
*/
|
|
23
|
-
getRowId?: (rowData: RowT) => RowTId;
|
|
24
|
-
}
|
|
25
|
-
type DataGridRootComponent = <RowT>(props: DataGridProps<RowT> & React.RefAttributes<HTMLDivElement>) => React.ReactElement | null;
|
|
26
|
-
/**
|
|
27
|
-
* @see [📝 Documentation](https://aksel.nav.no/komponenter/core/data-grid)
|
|
28
|
-
* @see 🏷️ {@link DataGridProps}
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```jsx
|
|
32
|
-
* <DataGrid columnDefinitions={columnDefs} data={rowData} getRowId={(row) => row.id}>
|
|
33
|
-
* <DataTable />
|
|
34
|
-
* </DataGrid>
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
export declare const DataGridRoot: DataGridRootComponent;
|
|
38
|
-
export default DataGridRoot;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataGridRoot.js","sourceRoot":"","sources":["../../../../src/data/data-grid/root/DataGridRoot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0D;AAC1D,oDAA4C;AAE5C,iEAAiE;AA8BjE;;;;;;;;;;GAUG;AACU,QAAA,YAAY,GAAG,IAAA,kBAAU,EACpC,CACE,EAOyB,EACzB,GAAG,EACH,EAAE;QATF,EACE,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,IAAI,EACJ,QAAQ,OAEe,EADpB,IAAI,cANT,kEAOC,CADQ;IAIT,OAAO,CACL,uDAAS,IAAI,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,IAAA,YAAE,EAAC,iBAAiB,EAAE,SAAS,CAAC;QAClE,8BAAC,8CAAuB,IACtB,iBAAiB,EAAE,iBAAiB,EACpC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,QAAQ,IAEjB,QAAQ,CACe,CACtB,CACP,CAAC;AACJ,CAAC,CACuB,CAAC;AAE3B,kBAAe,oBAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.types.js","sourceRoot":"","sources":["../../../../src/data/table/root/DataTable.types.ts"],"names":[],"mappings":""}
|