@navikt/ds-react 8.10.6 → 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/root/DragAndDropRoot.d.ts +1 -1
- package/cjs/data/drag-and-drop/root/DragAndDropRoot.js +2 -2
- 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 -2
- package/cjs/data/table/column-header/useTableColumnResize.js +10 -10
- 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/hooks/useColumnOptions.d.ts +3 -3
- package/cjs/data/table/hooks/useColumnOptions.js +2 -2
- 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} +57 -37
- 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 +44 -20
- 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/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 +33 -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/table/ColumnHeader.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 +2 -2
- 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 -2
- package/esm/data/table/column-header/useTableColumnResize.js +10 -10
- 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/hooks/useColumnOptions.d.ts +3 -3
- package/esm/data/table/hooks/useColumnOptions.js +2 -2
- 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} +59 -38
- 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 +44 -20
- 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/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 +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.map +1 -1
- package/package.json +23 -3
- package/src/data/drag-and-drop/root/DragAndDropRoot.tsx +3 -3
- 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 +14 -14
- 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 +19 -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/hooks/__tests__/useTableItems.test.ts +1 -1
- package/src/data/table/hooks/useColumnOptions.ts +5 -5
- 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} +196 -143
- 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 -16
- 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 +1 -0
- 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,7 +51,7 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
50
51
|
},
|
|
51
52
|
forwardedRef,
|
|
52
53
|
) => {
|
|
53
|
-
const { layout, stickyHeader, selectionState,
|
|
54
|
+
const { layout, stickyHeader, selectionState, onRowAction } =
|
|
54
55
|
useDataTableContext();
|
|
55
56
|
const { location } = useDataTableLocation();
|
|
56
57
|
const { tableItems } = useDataTableContext();
|
|
@@ -63,7 +64,11 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
63
64
|
const isSticky = location === "thead" && stickyHeader;
|
|
64
65
|
|
|
65
66
|
const handleClick =
|
|
66
|
-
location === "tbody" &&
|
|
67
|
+
location === "tbody" &&
|
|
68
|
+
rowId !== undefined &&
|
|
69
|
+
((selectionState.selectionTrigger === "row" &&
|
|
70
|
+
selectionState.selection.mode !== "none") ||
|
|
71
|
+
onRowAction)
|
|
67
72
|
? (event: React.MouseEvent<HTMLTableRowElement>) => {
|
|
68
73
|
if (
|
|
69
74
|
rowId === undefined ||
|
|
@@ -75,6 +80,26 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
75
80
|
return;
|
|
76
81
|
}
|
|
77
82
|
|
|
83
|
+
if (onRowAction) {
|
|
84
|
+
const rowData = tableItems.itemDetails.get(rowId)?.rowData;
|
|
85
|
+
|
|
86
|
+
if (rowData) {
|
|
87
|
+
onRowAction({
|
|
88
|
+
row: rowData,
|
|
89
|
+
id: rowId,
|
|
90
|
+
event,
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
consoleWarning(
|
|
94
|
+
`DataGrid.Table: Unable to find row data for rowId ${rowId} when calling onRowAction.`,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (event.defaultPrevented) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
78
103
|
const selection = window.getSelection();
|
|
79
104
|
if (selection && selection.toString().length > 0) {
|
|
80
105
|
return;
|
|
@@ -82,18 +107,17 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
82
107
|
|
|
83
108
|
if (
|
|
84
109
|
selectionState.selectionTrigger === "row" &&
|
|
85
|
-
selectionState.selection.
|
|
110
|
+
selectionState.selection.mode !== "none"
|
|
86
111
|
) {
|
|
87
112
|
const rowData = tableItems.itemDetails.get(rowId)?.rowData;
|
|
88
113
|
|
|
89
114
|
if (!rowData) {
|
|
90
115
|
consoleWarning(
|
|
91
|
-
`No row data found for rowId ${rowId}. This may cause issues with selection if enableRowSelection is used.`,
|
|
116
|
+
`DataGrid.Table: No row data found for rowId ${rowId}. This may cause issues with selection if enableRowSelection is used.`,
|
|
92
117
|
);
|
|
93
118
|
}
|
|
94
119
|
selectionState.selection.toggleSelection(rowId, rowData);
|
|
95
120
|
}
|
|
96
|
-
onRowClick?.(rowId, event);
|
|
97
121
|
}
|
|
98
122
|
: undefined;
|
|
99
123
|
|
|
@@ -126,9 +150,12 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
126
150
|
);
|
|
127
151
|
|
|
128
152
|
function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
153
|
+
const { isLoading } = useDataGridContext();
|
|
129
154
|
const { tableId, loading, stickyStart } = useDataTableContext();
|
|
130
155
|
const stickyExpansion = stickyStart.expansion;
|
|
131
156
|
|
|
157
|
+
const expansionHeaderId = useId();
|
|
158
|
+
|
|
132
159
|
const { location } = useDataTableLocation();
|
|
133
160
|
|
|
134
161
|
const {
|
|
@@ -145,10 +172,11 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
145
172
|
return null;
|
|
146
173
|
}
|
|
147
174
|
|
|
148
|
-
if (
|
|
175
|
+
if (isLoading && loading?.variant === "skeleton") {
|
|
149
176
|
if (location === "thead") {
|
|
150
177
|
return (
|
|
151
178
|
<DataTableColumnHeader
|
|
179
|
+
id={expansionHeaderId}
|
|
152
180
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
153
181
|
cellType="action"
|
|
154
182
|
data-block-keyboard-nav
|
|
@@ -172,6 +200,7 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
172
200
|
if (location === "thead" && !showExpandAll) {
|
|
173
201
|
return (
|
|
174
202
|
<DataTableColumnHeader
|
|
203
|
+
id={expansionHeaderId}
|
|
175
204
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
176
205
|
cellType="action"
|
|
177
206
|
data-block-keyboard-nav
|
|
@@ -185,7 +214,8 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
185
214
|
if (location === "thead") {
|
|
186
215
|
return (
|
|
187
216
|
<DataTableColumnHeader
|
|
188
|
-
|
|
217
|
+
id={expansionHeaderId}
|
|
218
|
+
align="center"
|
|
189
219
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
190
220
|
cellType="action"
|
|
191
221
|
label=""
|
|
@@ -261,6 +291,7 @@ function RowExpansionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
261
291
|
* TODO: a11y for labels
|
|
262
292
|
*/
|
|
263
293
|
function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
294
|
+
const { isLoading } = useDataGridContext();
|
|
264
295
|
const { selectionState, stickyStart, loading } = useDataTableContext();
|
|
265
296
|
const stickySelection = stickyStart.selection;
|
|
266
297
|
const stickySelectionOffset = stickyStart.selectionOffset;
|
|
@@ -269,17 +300,19 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
269
300
|
const { tableItems } = useDataTableContext();
|
|
270
301
|
|
|
271
302
|
const inputId = useId();
|
|
303
|
+
const selectionHeaderId = useId();
|
|
272
304
|
|
|
273
305
|
const { selection, renderSelection } = selectionState;
|
|
274
306
|
|
|
275
|
-
if (selection.
|
|
307
|
+
if (selection.mode === "none" || !renderSelection) {
|
|
276
308
|
return null;
|
|
277
309
|
}
|
|
278
310
|
|
|
279
|
-
if (
|
|
311
|
+
if (isLoading && loading?.variant === "skeleton") {
|
|
280
312
|
if (location === "thead") {
|
|
281
313
|
return (
|
|
282
314
|
<DataTableColumnHeader
|
|
315
|
+
id={selectionHeaderId}
|
|
283
316
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
284
317
|
cellType="action"
|
|
285
318
|
label=""
|
|
@@ -302,7 +335,7 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
302
335
|
}
|
|
303
336
|
|
|
304
337
|
/* TODO: A11y support */
|
|
305
|
-
if (selection.
|
|
338
|
+
if (selection.mode === "multiple" && location === "thead") {
|
|
306
339
|
const theadCheckboxProps = selection.getTheadCheckboxProps();
|
|
307
340
|
|
|
308
341
|
let labelText = "Velg alle synlige rader";
|
|
@@ -312,7 +345,8 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
312
345
|
|
|
313
346
|
return (
|
|
314
347
|
<DataTableColumnHeader
|
|
315
|
-
|
|
348
|
+
id={selectionHeaderId}
|
|
349
|
+
align="center"
|
|
316
350
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
317
351
|
cellType="action"
|
|
318
352
|
label=""
|
|
@@ -327,9 +361,10 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
327
361
|
);
|
|
328
362
|
}
|
|
329
363
|
|
|
330
|
-
if (selection.
|
|
364
|
+
if (selection.mode === "single" && location === "thead") {
|
|
331
365
|
return (
|
|
332
366
|
<DataTableColumnHeader
|
|
367
|
+
id={selectionHeaderId}
|
|
333
368
|
width={{ value: ACTION_CELL_CSS_WIDTH }}
|
|
334
369
|
cellType="action"
|
|
335
370
|
label=""
|
|
@@ -344,7 +379,7 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
344
379
|
return null;
|
|
345
380
|
}
|
|
346
381
|
|
|
347
|
-
if (selection.
|
|
382
|
+
if (selection.mode === "multiple" && location === "tbody") {
|
|
348
383
|
return (
|
|
349
384
|
<DataTableTd
|
|
350
385
|
cellType="action"
|
|
@@ -362,7 +397,7 @@ function RowSelectionCell({ rowId }: { rowId?: TableRowEntryId }) {
|
|
|
362
397
|
);
|
|
363
398
|
}
|
|
364
399
|
|
|
365
|
-
if (selection.
|
|
400
|
+
if (selection.mode === "single" && location === "tbody") {
|
|
366
401
|
return (
|
|
367
402
|
<DataTableTd
|
|
368
403
|
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,36 @@
|
|
|
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
|
+
|
|
36
|
+
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,152 @@
|
|
|
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
|
+
}),
|
|
101
|
+
[
|
|
102
|
+
settings?.rowDensity,
|
|
103
|
+
settings?.zebraStripes,
|
|
104
|
+
settings?.truncateContent,
|
|
105
|
+
settings?.stickyColumns,
|
|
106
|
+
settings?.textSize,
|
|
107
|
+
],
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<div {...rest} ref={ref} className={cl("aksel-data-grid", className)}>
|
|
112
|
+
<DataGridContextProvider
|
|
113
|
+
columnDefinitions={columns}
|
|
114
|
+
data={data}
|
|
115
|
+
getRowId={getRowId}
|
|
116
|
+
selection={selection}
|
|
117
|
+
isLoading={isLoading}
|
|
118
|
+
tableSettings={resolvedSettings}
|
|
119
|
+
>
|
|
120
|
+
{children}
|
|
121
|
+
</DataGridContextProvider>
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const DataGrid = DataGridInternal as unknown as DataGridComponent;
|
|
128
|
+
DataGrid.Table = DataGridTable;
|
|
129
|
+
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace, import/export
|
|
131
|
+
export namespace DataGrid {
|
|
132
|
+
export type Props<T = unknown> = DataGridProps<T>;
|
|
133
|
+
export type Columns<T = unknown> = ColumnDefinitions<T>;
|
|
134
|
+
export type Selection<T = unknown> = SelectionProps<T>;
|
|
135
|
+
export type Settings = DataGridSettings;
|
|
136
|
+
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
138
|
+
export namespace Table {
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
140
|
+
export type Props<T = unknown> = DataGridTable.Props<T>;
|
|
141
|
+
export type Sorting = DataGridTable.Sorting;
|
|
142
|
+
export type SortEntry = DataGridTable.SortEntry;
|
|
143
|
+
export type SortChangeDetail = DataGridTable.SortChangeDetail;
|
|
144
|
+
export type LoadingContent = DataGridTable.LoadingContent;
|
|
145
|
+
export type SubRows<T = unknown> = DataGridTable.SubRows<T>;
|
|
146
|
+
export type DetailsPanel<T = unknown> = DataGridTable.DetailsPanel<T>;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// eslint-disable-next-line import/export
|
|
151
|
+
export { DataGrid, DataGridInternal }; // DataGridRoot needs to be exported b.c. of docgen
|
|
152
|
+
export default DataGrid;
|
package/src/preview.ts
ADDED
|
@@ -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":""}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { type DetailsPanelProps } from "../hooks/useTableDetailsPanel";
|
|
3
|
-
import { type SubRowsProps } from "../hooks/useTableItems";
|
|
4
|
-
import { type SelectionProps } from "../hooks/useTableSelection";
|
|
5
|
-
import { type TableSortOptions } from "../hooks/useTableSort";
|
|
6
|
-
import type { DataTableLoadingConfig, TableRowEntryId } from "./DataTable.types";
|
|
7
|
-
/**
|
|
8
|
-
* TODO: For consideration:
|
|
9
|
-
* - Use namespacing for types. There will be a lot of standalone types connected to this component,
|
|
10
|
-
* it could make sense to access them under DataTable.X instead of separate imports.
|
|
11
|
-
* - Consider having a "Wrapper" component that only handles context and logic like,
|
|
12
|
-
* "DataTableRoot" or "DataGrid" or something, and then have the main "DataTable" component only handle rendering of table itself.
|
|
13
|
-
* This would make props more focused and discoverable since its not mixed with htmltable-props.
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* TODO:
|
|
17
|
-
* - Test `onColumnDefinitionChange` callback that is called when resize, sort, order etc changes
|
|
18
|
-
*/
|
|
19
|
-
interface DataTableProps<T> extends React.HTMLAttributes<HTMLTableElement> {
|
|
20
|
-
children?: never;
|
|
21
|
-
/**
|
|
22
|
-
* Controls vertical cell padding.
|
|
23
|
-
* @default "normal"
|
|
24
|
-
*/
|
|
25
|
-
rowDensity?: "condensed" | "normal" | "spacious";
|
|
26
|
-
/**
|
|
27
|
-
* Zebra striped table
|
|
28
|
-
* @default false
|
|
29
|
-
*/
|
|
30
|
-
zebraStripes?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Truncate content in cells and show ellipsis for overflowed text.
|
|
33
|
-
*
|
|
34
|
-
* **NB:** When using this together with `layout="auto"`,
|
|
35
|
-
* you have to manually set a `maxWidth` on columns that should be truncated.
|
|
36
|
-
* @default false if layout="auto", else true
|
|
37
|
-
*/
|
|
38
|
-
truncateContent?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Enables keyboard navigation for table rows and cells.
|
|
41
|
-
* @default true
|
|
42
|
-
*/
|
|
43
|
-
withKeyboardNav?: boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Controls table layout.
|
|
46
|
-
*
|
|
47
|
-
* ### fixed
|
|
48
|
-
* Gives you full control of column widths. This is required for resizable columns.
|
|
49
|
-
*
|
|
50
|
-
* ### auto
|
|
51
|
-
* Makes the columns resize automatically based on the content.
|
|
52
|
-
* The table will take up at least 100% of available width.
|
|
53
|
-
*
|
|
54
|
-
* **NB:** When using this with `truncateContent`, you have to manually
|
|
55
|
-
* set a `contentMaxWidth` on cells that should be truncated.
|
|
56
|
-
* @default "fixed"
|
|
57
|
-
*/
|
|
58
|
-
layout?: "fixed" | "auto";
|
|
59
|
-
/**
|
|
60
|
-
* Sticky columns that remain visible when horizontally scrolling the table.
|
|
61
|
-
*
|
|
62
|
-
* You can specify 1 sticky column on the left and 1 on the right.
|
|
63
|
-
*/
|
|
64
|
-
stickyColumns?: {
|
|
65
|
-
start?: "1";
|
|
66
|
-
end?: "1";
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* @default true
|
|
70
|
-
*/
|
|
71
|
-
stickyHeader?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Callback invoked when a data row is clicked.
|
|
74
|
-
* Not called when clicking header, loading, or empty-state rows.
|
|
75
|
-
*/
|
|
76
|
-
onRowClick?: (rowId: TableRowEntryId, event: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
77
|
-
/**
|
|
78
|
-
* Content to render when `data` is empty.
|
|
79
|
-
* Rendered inside a `DataTable.EmptyState` row spanning all columns.
|
|
80
|
-
*/
|
|
81
|
-
emptyContent?: React.ReactNode;
|
|
82
|
-
/**
|
|
83
|
-
* Configures how the table behaves during loading.
|
|
84
|
-
*
|
|
85
|
-
* Use `variant` to select the loading strategy:
|
|
86
|
-
* - `"content"` — renders custom content inside a full-width row.
|
|
87
|
-
* - `"skeleton"` — renders skeleton placeholder rows.
|
|
88
|
-
* - `"overlay"` — keeps existing data visible with a loading overlay.
|
|
89
|
-
*/
|
|
90
|
-
loading?: DataTableLoadingConfig;
|
|
91
|
-
/**
|
|
92
|
-
* Adjusts font-size
|
|
93
|
-
* @default "medium"
|
|
94
|
-
*/
|
|
95
|
-
textSize?: "small" | "medium";
|
|
96
|
-
/**
|
|
97
|
-
* Object with props related to row selection.
|
|
98
|
-
*/
|
|
99
|
-
selection?: SelectionProps<T>;
|
|
100
|
-
/**
|
|
101
|
-
* Object with props related to nested rows (sub-rows).
|
|
102
|
-
*/
|
|
103
|
-
subRows?: SubRowsProps<T>;
|
|
104
|
-
/**
|
|
105
|
-
* Object with props related to details panel.
|
|
106
|
-
* This is a panel that can be expanded below each row to show arbitrary content.
|
|
107
|
-
*/
|
|
108
|
-
detailsPanel?: DetailsPanelProps<T>;
|
|
109
|
-
/**
|
|
110
|
-
* Object with props related to sorting.
|
|
111
|
-
*/
|
|
112
|
-
sorting?: TableSortOptions;
|
|
113
|
-
}
|
|
114
|
-
declare const DataTableInternal: React.ForwardRefExoticComponent<DataTableProps<any> & React.RefAttributes<HTMLTableElement>>;
|
|
115
|
-
declare const DataTable: <T>(props: DataTableProps<T> & React.RefAttributes<HTMLTableElement>) => React.ReactElement | null;
|
|
116
|
-
export { DataTable, DataTableInternal };
|
|
117
|
-
export type { DataTableProps };
|
|
118
|
-
export default DataTable;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DataTableRoot.js","sourceRoot":"","sources":["../../../../src/data/table/root/DataTableRoot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAMe;AACf,gDAA6C;AAC7C,4DAAgD;AAChD,8DAA2D;AAC3D,oDAA4C;AAC5C,gDAAoD;AACpD,oFAA+E;AAC/E,sEAAmE;AACnE,kFAA+E;AAC/E,4FAAyF;AACzF,4EAAyE;AACzE,gEAA6D;AAC7D,wEAGuC;AACvC,0DAA0E;AAC1E,sEAAmE;AACnE,kEAGoC;AACpC,wDAA4E;AAC5E,kFAA+E;AAC/E,mFAAgF;AAChF,4DAAyD;AACzD,4DAAyD;AACzD,mDAAgD;AAKhD,mEAGiC;AAkHjC,MAAM,iBAAiB,GAAG,IAAA,kBAAU,EAClC,CACE,EAmBsB,EAAE,uCAAuC;AAC/D,YAAY,EACZ,EAAE;QArBF,EACE,SAAS,EACT,EAAE,EACF,UAAU,GAAG,QAAQ,EACrB,QAAQ,GAAG,QAAQ,EACnB,eAAe,GAAG,IAAI,EACtB,YAAY,GAAG,KAAK,EACpB,eAAe,EAAE,mBAAmB,EACpC,MAAM,GAAG,OAAO,EAChB,aAAa,EACb,YAAY,GAAG,IAAI,EACnB,UAAU,EACV,YAAY,EACZ,SAAS,EACT,OAAO,EACP,YAAY,EACZ,OAAO,EACP,OAAO,OAEa,EAD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