@navikt/ds-react 8.10.2 → 8.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/action-menu/ActionMenu.js +1 -1
- package/cjs/action-menu/ActionMenu.js.map +1 -1
- package/cjs/data/stories/Data.test-data.d.ts +24 -0
- package/cjs/data/stories/Data.test-data.js +1616 -0
- package/cjs/data/stories/Data.test-data.js.map +1 -0
- package/cjs/data/table/column-header/DataTableColumnHeader.d.ts +4 -1
- package/cjs/data/table/column-header/DataTableColumnHeader.js +4 -2
- package/cjs/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/cjs/data/table/column-header/useTableColumnResize.d.ts +39 -14
- package/cjs/data/table/column-header/useTableColumnResize.js +37 -39
- package/cjs/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +6 -0
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js +32 -0
- package/cjs/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -0
- package/cjs/data/table/helpers/collectTableRowEntries.d.ts +13 -5
- package/cjs/data/table/helpers/collectTableRowEntries.js +26 -19
- package/cjs/data/table/helpers/collectTableRowEntries.js.map +1 -1
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +46 -0
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js +112 -0
- package/cjs/data/table/helpers/selection/SelectionSubtreeHelper.js.map +1 -0
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.d.ts +3 -2
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js +43 -19
- package/cjs/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/cjs/data/table/helpers/selection/selection.types.d.ts +1 -0
- package/cjs/data/table/helpers/table-keyboard.d.ts +1 -2
- package/cjs/data/table/helpers/table-keyboard.js +1 -2
- package/cjs/data/table/helpers/table-keyboard.js.map +1 -1
- package/cjs/data/table/hooks/useColumnOptions.js +18 -5
- package/cjs/data/table/hooks/useColumnOptions.js.map +1 -1
- package/cjs/data/table/hooks/useTableDetailsPanel.d.ts +62 -0
- package/cjs/data/table/hooks/{useTableExpansion.js → useTableDetailsPanel.js} +26 -19
- package/cjs/data/table/hooks/useTableDetailsPanel.js.map +1 -0
- package/cjs/data/table/hooks/useTableItems.d.ts +18 -17
- package/cjs/data/table/hooks/useTableItems.js +27 -15
- package/cjs/data/table/hooks/useTableItems.js.map +1 -1
- package/cjs/data/table/hooks/useTableSelection.d.ts +6 -3
- package/cjs/data/table/hooks/useTableSelection.js +10 -4
- package/cjs/data/table/hooks/useTableSelection.js.map +1 -1
- package/cjs/data/table/index.d.ts +1 -2
- package/cjs/data/table/index.js +22 -12
- package/cjs/data/table/index.js.map +1 -1
- package/cjs/data/table/root/DataTable.types.d.ts +12 -10
- package/cjs/data/table/root/DataTableRoot.context.d.ts +5 -1
- package/cjs/data/table/root/DataTableRoot.context.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.d.ts +79 -115
- package/cjs/data/table/root/DataTableRoot.js +167 -39
- package/cjs/data/table/root/DataTableRoot.js.map +1 -1
- package/cjs/data/table/root/DataTableRoot.legacy.d.ts +177 -0
- package/cjs/data/table/root/DataTableRoot.legacy.js +104 -0
- package/cjs/data/table/root/DataTableRoot.legacy.js.map +1 -0
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.d.ts +6 -0
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js +21 -0
- package/cjs/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -0
- package/cjs/data/table/tr/DataTableTr.js +11 -11
- package/cjs/data/table/tr/DataTableTr.js.map +1 -1
- package/cjs/form/checkbox/Checkbox.js +1 -0
- package/cjs/form/checkbox/Checkbox.js.map +1 -1
- package/cjs/form/radio/Radio.js +7 -1
- package/cjs/form/radio/Radio.js.map +1 -1
- package/cjs/modal/types.d.ts +8 -4
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js +1 -1
- package/cjs/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/cjs/utils/components/floating/Floating.d.ts +16 -1
- package/cjs/utils/components/floating/Floating.js +50 -13
- package/cjs/utils/components/floating/Floating.js.map +1 -1
- package/cjs/utils/components/floating-menu/Menu.js +1 -1
- package/cjs/utils/components/floating-menu/Menu.js.map +1 -1
- package/cjs/utils/helpers/create-strict-context.js +1 -1
- package/cjs/utils/helpers/create-strict-context.js.map +1 -1
- package/cjs/utils/hooks/useControllableState.d.ts +5 -5
- package/cjs/utils/hooks/useControllableState.js.map +1 -1
- package/cjs/utils/hooks/useValueAsRef.js +1 -1
- package/cjs/utils/hooks/useValueAsRef.js.map +1 -1
- package/cjs/utils-external/hooks/useId.js +1 -1
- package/cjs/utils-external/hooks/useId.js.map +1 -1
- package/esm/action-menu/ActionMenu.js +1 -1
- package/esm/action-menu/ActionMenu.js.map +1 -1
- package/esm/data/stories/Data.test-data.d.ts +24 -0
- package/esm/data/stories/Data.test-data.js +1607 -0
- package/esm/data/stories/Data.test-data.js.map +1 -0
- package/esm/data/table/column-header/DataTableColumnHeader.d.ts +4 -1
- package/esm/data/table/column-header/DataTableColumnHeader.js +4 -2
- package/esm/data/table/column-header/DataTableColumnHeader.js.map +1 -1
- package/esm/data/table/column-header/useTableColumnResize.d.ts +39 -14
- package/esm/data/table/column-header/useTableColumnResize.js +38 -40
- package/esm/data/table/column-header/useTableColumnResize.js.map +1 -1
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.d.ts +6 -0
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js +27 -0
- package/esm/data/table/details-panel-row/DataTableDetailsPanelRow.js.map +1 -0
- package/esm/data/table/helpers/collectTableRowEntries.d.ts +13 -5
- package/esm/data/table/helpers/collectTableRowEntries.js +26 -19
- package/esm/data/table/helpers/collectTableRowEntries.js.map +1 -1
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.d.ts +46 -0
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js +109 -0
- package/esm/data/table/helpers/selection/SelectionSubtreeHelper.js.map +1 -0
- package/esm/data/table/helpers/selection/getMultipleSelectProps.d.ts +3 -2
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js +43 -19
- package/esm/data/table/helpers/selection/getMultipleSelectProps.js.map +1 -1
- package/esm/data/table/helpers/selection/selection.types.d.ts +1 -0
- package/esm/data/table/helpers/table-keyboard.d.ts +1 -2
- package/esm/data/table/helpers/table-keyboard.js +1 -2
- package/esm/data/table/helpers/table-keyboard.js.map +1 -1
- package/esm/data/table/hooks/useColumnOptions.js +18 -5
- package/esm/data/table/hooks/useColumnOptions.js.map +1 -1
- package/esm/data/table/hooks/useTableDetailsPanel.d.ts +62 -0
- package/esm/data/table/hooks/useTableDetailsPanel.js +58 -0
- package/esm/data/table/hooks/useTableDetailsPanel.js.map +1 -0
- package/esm/data/table/hooks/useTableItems.d.ts +18 -17
- package/esm/data/table/hooks/useTableItems.js +27 -15
- package/esm/data/table/hooks/useTableItems.js.map +1 -1
- package/esm/data/table/hooks/useTableSelection.d.ts +6 -3
- package/esm/data/table/hooks/useTableSelection.js +10 -4
- package/esm/data/table/hooks/useTableSelection.js.map +1 -1
- package/esm/data/table/index.d.ts +1 -2
- package/esm/data/table/index.js +21 -1
- package/esm/data/table/index.js.map +1 -1
- package/esm/data/table/root/DataTable.types.d.ts +12 -10
- package/esm/data/table/root/DataTableRoot.context.d.ts +5 -1
- package/esm/data/table/root/DataTableRoot.context.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.d.ts +79 -115
- package/esm/data/table/root/DataTableRoot.js +174 -37
- package/esm/data/table/root/DataTableRoot.js.map +1 -1
- package/esm/data/table/root/DataTableRoot.legacy.d.ts +177 -0
- package/esm/data/table/root/DataTableRoot.legacy.js +59 -0
- package/esm/data/table/root/DataTableRoot.legacy.js.map +1 -0
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.d.ts +6 -0
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js +16 -0
- package/esm/data/table/sub-row-toggle/DataTableSubRowToggle.js.map +1 -0
- package/esm/data/table/tr/DataTableTr.js +11 -11
- package/esm/data/table/tr/DataTableTr.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +1 -0
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/radio/Radio.js +7 -1
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/modal/types.d.ts +8 -4
- package/esm/utils/components/dismissablelayer/DismissableLayer.js +1 -1
- package/esm/utils/components/dismissablelayer/DismissableLayer.js.map +1 -1
- package/esm/utils/components/floating/Floating.d.ts +16 -1
- package/esm/utils/components/floating/Floating.js +48 -13
- package/esm/utils/components/floating/Floating.js.map +1 -1
- package/esm/utils/components/floating-menu/Menu.js +2 -2
- package/esm/utils/components/floating-menu/Menu.js.map +1 -1
- package/esm/utils/helpers/create-strict-context.js +1 -1
- package/esm/utils/helpers/create-strict-context.js.map +1 -1
- package/esm/utils/hooks/useControllableState.d.ts +5 -5
- package/esm/utils/hooks/useControllableState.js.map +1 -1
- package/esm/utils/hooks/useValueAsRef.js +1 -1
- package/esm/utils/hooks/useValueAsRef.js.map +1 -1
- package/esm/utils-external/hooks/useId.js +1 -1
- package/esm/utils-external/hooks/useId.js.map +1 -1
- package/package.json +3 -3
- package/src/action-menu/ActionMenu.tsx +1 -1
- package/src/data/stories/Data.test-data.tsx +1703 -0
- package/src/data/table/column-header/DataTableColumnHeader.tsx +11 -7
- package/src/data/table/column-header/useTableColumnResize.ts +95 -54
- package/src/data/table/details-panel-row/DataTableDetailsPanelRow.tsx +53 -0
- package/src/data/table/helpers/collectTableRowEntries.ts +55 -31
- package/src/data/table/helpers/selection/SelectionSubtreeHelper.test.ts +66 -0
- package/src/data/table/helpers/selection/SelectionSubtreeHelper.ts +162 -0
- package/src/data/table/helpers/selection/getMultipleSelectProps.ts +57 -20
- package/src/data/table/helpers/selection/selection.types.ts +1 -0
- package/src/data/table/helpers/table-keyboard.ts +1 -2
- package/src/data/table/hooks/__tests__/useTableItems.test.ts +27 -6
- package/src/data/table/hooks/__tests__/useTableSelection.test.ts +182 -58
- package/src/data/table/hooks/useColumnOptions.ts +19 -5
- package/src/data/table/hooks/useTableDetailsPanel.tsx +182 -0
- package/src/data/table/hooks/useTableItems.ts +74 -60
- package/src/data/table/hooks/useTableSelection.ts +27 -12
- package/src/data/table/index.tsx +5 -3
- package/src/data/table/root/DataTable.types.ts +25 -10
- package/src/data/table/root/DataTableRoot.context.ts +5 -1
- package/src/data/table/root/DataTableRoot.legacy.tsx +297 -0
- package/src/data/table/root/DataTableRoot.tsx +483 -219
- package/src/data/table/sub-row-toggle/DataTableSubRowToggle.tsx +39 -0
- package/src/data/table/tr/DataTableTr.tsx +14 -13
- package/src/form/checkbox/Checkbox.tsx +1 -0
- package/src/form/radio/Radio.tsx +7 -1
- package/src/modal/types.ts +8 -4
- package/src/utils/components/dismissablelayer/DismissableLayer.tsx +1 -1
- package/src/utils/components/floating/Floating.tsx +56 -13
- package/src/utils/components/floating-menu/Menu.tsx +4 -1
- package/src/utils/helpers/create-strict-context.tsx +1 -1
- package/src/utils/hooks/useControllableState.ts +11 -8
- package/src/utils/hooks/useValueAsRef.ts +1 -1
- package/src/utils-external/hooks/useId.ts +1 -1
- package/cjs/data/table/hooks/useTableExpansion.d.ts +0 -29
- package/cjs/data/table/hooks/useTableExpansion.js.map +0 -1
- package/cjs/data/table/root/DataTableAuto.d.ts +0 -174
- package/cjs/data/table/root/DataTableAuto.js +0 -206
- package/cjs/data/table/root/DataTableAuto.js.map +0 -1
- package/esm/data/table/hooks/useTableExpansion.d.ts +0 -29
- package/esm/data/table/hooks/useTableExpansion.js +0 -51
- package/esm/data/table/hooks/useTableExpansion.js.map +0 -1
- package/esm/data/table/root/DataTableAuto.d.ts +0 -174
- package/esm/data/table/root/DataTableAuto.js +0 -170
- package/esm/data/table/root/DataTableAuto.js.map +0 -1
- package/src/data/table/hooks/__tests__/useTableExpansion.test.tsx +0 -115
- package/src/data/table/hooks/useTableExpansion.tsx +0 -141
- package/src/data/table/root/DataTableAuto.test.tsx +0 -118
- package/src/data/table/root/DataTableAuto.tsx +0 -603
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ChevronDownIcon, ChevronRightIcon } from "@navikt/aksel-icons";
|
|
3
|
+
import { Button } from "../../../button";
|
|
4
|
+
import { type ItemDetail, useTableItemsContext } from "../hooks/useTableItems";
|
|
5
|
+
|
|
6
|
+
function DataTableSubRowToggle({ details }: { details: ItemDetail<any> }) {
|
|
7
|
+
const { isSubRowExpanded, onExpandedRowIdsChange } = useTableItemsContext();
|
|
8
|
+
|
|
9
|
+
const subRows = details.children;
|
|
10
|
+
const hasSubRows = subRows && subRows.length > 0;
|
|
11
|
+
const isRowExpanded = isSubRowExpanded(details.id);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className="aksel-data-table__nested-toggle">
|
|
15
|
+
{hasSubRows && (
|
|
16
|
+
<Button
|
|
17
|
+
variant="tertiary"
|
|
18
|
+
data-color="neutral"
|
|
19
|
+
size="small"
|
|
20
|
+
onClick={(e) => {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
onExpandedRowIdsChange(details.id);
|
|
23
|
+
}}
|
|
24
|
+
aria-expanded={isRowExpanded}
|
|
25
|
+
aria-label={isRowExpanded ? "Skjul under-rader" : "Vis under-rader"}
|
|
26
|
+
icon={
|
|
27
|
+
isRowExpanded ? (
|
|
28
|
+
<ChevronDownIcon aria-hidden />
|
|
29
|
+
) : (
|
|
30
|
+
<ChevronRightIcon aria-hidden />
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
/>
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { DataTableSubRowToggle };
|
|
@@ -15,9 +15,9 @@ import { cl, composeEventHandlers } from "../../../utils/helpers";
|
|
|
15
15
|
import { DataTableBaseCell } from "../base-cell/DataTableBaseCell";
|
|
16
16
|
import { DataTableColumnHeader } from "../column-header/DataTableColumnHeader";
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} from "../hooks/
|
|
18
|
+
getDataTableDetailsPanelId,
|
|
19
|
+
useDataTableDetailsPanel,
|
|
20
|
+
} from "../hooks/useTableDetailsPanel";
|
|
21
21
|
import {
|
|
22
22
|
useDataTableContext,
|
|
23
23
|
useDataTableLocation,
|
|
@@ -46,13 +46,8 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
46
46
|
},
|
|
47
47
|
forwardedRef,
|
|
48
48
|
) => {
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
stickyHeader,
|
|
52
|
-
selectionState,
|
|
53
|
-
onRowClick,
|
|
54
|
-
disableRowSelectionOnClick,
|
|
55
|
-
} = useDataTableContext();
|
|
49
|
+
const { layout, stickyHeader, selectionState, onRowClick } =
|
|
50
|
+
useDataTableContext();
|
|
56
51
|
const { location } = useDataTableLocation();
|
|
57
52
|
|
|
58
53
|
const renderFillerCell = layout === "fixed" && children;
|
|
@@ -81,7 +76,7 @@ const DataTableTr = forwardRef<HTMLTableRowElement, DataTableTrProps>(
|
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
if (
|
|
84
|
-
!disableRowSelectionOnClick &&
|
|
79
|
+
!selectionState.disableRowSelectionOnClick &&
|
|
85
80
|
selectionState.selection.selectionMode !== "none"
|
|
86
81
|
) {
|
|
87
82
|
selectionState.selection.toggleSelection(rowId);
|
|
@@ -130,7 +125,7 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
130
125
|
isAllExpanded,
|
|
131
126
|
toggleAll,
|
|
132
127
|
showExpandAll,
|
|
133
|
-
} =
|
|
128
|
+
} = useDataTableDetailsPanel();
|
|
134
129
|
|
|
135
130
|
if (!enableDetailsPanel) {
|
|
136
131
|
return null;
|
|
@@ -143,6 +138,7 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
143
138
|
width={SELECTION_CELL_WIDTH}
|
|
144
139
|
UNSAFE_isSelection
|
|
145
140
|
data-block-keyboard-nav
|
|
141
|
+
label=""
|
|
146
142
|
/* isSticky={stickySelection && "start"} */
|
|
147
143
|
/>
|
|
148
144
|
);
|
|
@@ -160,6 +156,7 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
160
156
|
width={SELECTION_CELL_WIDTH}
|
|
161
157
|
UNSAFE_isSelection
|
|
162
158
|
data-block-keyboard-nav
|
|
159
|
+
label=""
|
|
163
160
|
/* isSticky={stickySelection && "start"} */
|
|
164
161
|
/>
|
|
165
162
|
);
|
|
@@ -171,6 +168,7 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
171
168
|
textAlign="center"
|
|
172
169
|
width={SELECTION_CELL_WIDTH}
|
|
173
170
|
UNSAFE_isSelection
|
|
171
|
+
label=""
|
|
174
172
|
/* isSticky={stickySelection && "start"} */
|
|
175
173
|
>
|
|
176
174
|
<Button
|
|
@@ -198,7 +196,7 @@ function RowExpansionCell({ rowId }: { rowId?: string | number }) {
|
|
|
198
196
|
|
|
199
197
|
const isRowExpanded = isExpanded(rowId);
|
|
200
198
|
const canExpandRow = isDetailsPanelExpandable(rowId);
|
|
201
|
-
const expansionId =
|
|
199
|
+
const expansionId = getDataTableDetailsPanelId(tableId, rowId);
|
|
202
200
|
|
|
203
201
|
if (!canExpandRow) {
|
|
204
202
|
return <DataTableTd UNSAFE_isSelection preventRowClick />;
|
|
@@ -247,6 +245,7 @@ function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
|
247
245
|
<DataTableColumnHeader
|
|
248
246
|
width={SELECTION_CELL_WIDTH}
|
|
249
247
|
UNSAFE_isSelection
|
|
248
|
+
label=""
|
|
250
249
|
data-block-keyboard-nav
|
|
251
250
|
isSticky={stickySelection && "start"}
|
|
252
251
|
/>
|
|
@@ -274,6 +273,7 @@ function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
|
274
273
|
textAlign="center"
|
|
275
274
|
width={SELECTION_CELL_WIDTH}
|
|
276
275
|
UNSAFE_isSelection
|
|
276
|
+
label=""
|
|
277
277
|
isSticky={stickySelection && "start"}
|
|
278
278
|
>
|
|
279
279
|
<Label htmlFor={inputId} visuallyHidden>
|
|
@@ -289,6 +289,7 @@ function RowSelectionCell({ rowId }: { rowId?: string | number }) {
|
|
|
289
289
|
<DataTableColumnHeader
|
|
290
290
|
width={SELECTION_CELL_WIDTH}
|
|
291
291
|
UNSAFE_isSelection
|
|
292
|
+
label=""
|
|
292
293
|
data-block-keyboard-nav
|
|
293
294
|
isSticky={stickySelection && "start"}
|
|
294
295
|
/>
|
package/src/form/radio/Radio.tsx
CHANGED
|
@@ -24,7 +24,13 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>(
|
|
|
24
24
|
>
|
|
25
25
|
<RadioInput
|
|
26
26
|
ref={forwardedRef}
|
|
27
|
-
{...omit(props, [
|
|
27
|
+
{...omit(props, [
|
|
28
|
+
"children",
|
|
29
|
+
"size",
|
|
30
|
+
"description",
|
|
31
|
+
"readOnly",
|
|
32
|
+
"className",
|
|
33
|
+
])}
|
|
28
34
|
{...omit(inputProps, ["aria-invalid", "aria-describedby"])}
|
|
29
35
|
aria-describedby={
|
|
30
36
|
cl(inputProps["aria-describedby"], {
|
package/src/modal/types.ts
CHANGED
|
@@ -39,7 +39,8 @@ interface ModalPropsBase extends React.DialogHTMLAttributes<HTMLDialogElement> {
|
|
|
39
39
|
/**
|
|
40
40
|
* Called when the user tries to close the modal by one of the built-in methods.
|
|
41
41
|
* Used if you want to ask the user for confirmation before closing.
|
|
42
|
-
*
|
|
42
|
+
*
|
|
43
|
+
* **NB:** Will not always be called when pressing Esc. See `onCancel` for more info.
|
|
43
44
|
* @returns Whether to close the modal or not
|
|
44
45
|
*/
|
|
45
46
|
onBeforeClose?: () => boolean;
|
|
@@ -52,7 +53,8 @@ interface ModalPropsBase extends React.DialogHTMLAttributes<HTMLDialogElement> {
|
|
|
52
53
|
onCancel?: React.ReactEventHandler<HTMLDialogElement>;
|
|
53
54
|
/**
|
|
54
55
|
* Whether to close when clicking on the backdrop.
|
|
55
|
-
*
|
|
56
|
+
*
|
|
57
|
+
* **NB:** Users may click outside by accident. Don't use if closing can cause data loss, or the modal contains important info.
|
|
56
58
|
* @default false
|
|
57
59
|
*/
|
|
58
60
|
closeOnBackdropClick?: boolean;
|
|
@@ -77,13 +79,15 @@ interface ModalPropsBase extends React.DialogHTMLAttributes<HTMLDialogElement> {
|
|
|
77
79
|
/**
|
|
78
80
|
* ID of the element that labels the modal.
|
|
79
81
|
* No need to set this manually if the `header` prop is used. A reference to `header.heading` will be created automatically.
|
|
80
|
-
*
|
|
82
|
+
*
|
|
83
|
+
* **NB:** If not using `header`, you should set either `aria-labelledby` or `aria-label`.
|
|
81
84
|
*/
|
|
82
85
|
"aria-labelledby"?: string;
|
|
83
86
|
/**
|
|
84
87
|
* String value that labels the modal.
|
|
85
88
|
* No need to set this if the `header` prop is used.
|
|
86
|
-
*
|
|
89
|
+
*
|
|
90
|
+
* **NB:** If not using `header`, you should set either `aria-labelledby` or `aria-label`.
|
|
87
91
|
*/
|
|
88
92
|
"aria-label"?: string;
|
|
89
93
|
}
|
|
@@ -342,7 +342,7 @@ const DismissableLayer = forwardRef<HTMLDivElement, DismissableLayerProps>(
|
|
|
342
342
|
if (disableOutsidePointerEvents) {
|
|
343
343
|
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
344
344
|
originalBodyPointerEvents = ownerDoc.body.style.pointerEvents;
|
|
345
|
-
ownerDoc.body.style.pointerEvents = "none";
|
|
345
|
+
ownerDoc.body.style.pointerEvents = "none";
|
|
346
346
|
}
|
|
347
347
|
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
348
348
|
}
|
|
@@ -36,6 +36,22 @@ import {
|
|
|
36
36
|
transformOrigin,
|
|
37
37
|
} from "./Floating.utils";
|
|
38
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Used for menus that prefer top/bottom placements and
|
|
41
|
+
* use height-var to limit their height.
|
|
42
|
+
*/
|
|
43
|
+
const MENU_COLLISION_AVOIDANCE = {
|
|
44
|
+
fallbackAxisSide: "none",
|
|
45
|
+
} as const;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Used by regular popovers that usually aren't scrollable and are allowed to
|
|
49
|
+
* freely flip to any axis of placement.
|
|
50
|
+
*/
|
|
51
|
+
const POPOVER_COLLISION_AVOIDANCE = {
|
|
52
|
+
fallbackAxisSide: "end",
|
|
53
|
+
} as const;
|
|
54
|
+
|
|
39
55
|
/**
|
|
40
56
|
* Floating Root
|
|
41
57
|
*/
|
|
@@ -189,6 +205,7 @@ interface FloatingContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
189
205
|
hideWhenDetached?: boolean;
|
|
190
206
|
updatePositionStrategy?: "optimized" | "always";
|
|
191
207
|
fallbackPlacements?: FlipOptions["fallbackPlacements"];
|
|
208
|
+
fallbackAxisSideDirection?: FlipOptions["fallbackAxisSideDirection"];
|
|
192
209
|
onPlaced?: () => void;
|
|
193
210
|
/**
|
|
194
211
|
* @default true
|
|
@@ -225,6 +242,7 @@ const FloatingContent = forwardRef<HTMLDivElement, FloatingContentProps>(
|
|
|
225
242
|
fallbackPlacements,
|
|
226
243
|
enabled = true,
|
|
227
244
|
autoUpdateWhileMounted = true,
|
|
245
|
+
fallbackAxisSideDirection = POPOVER_COLLISION_AVOIDANCE.fallbackAxisSide,
|
|
228
246
|
...contentProps
|
|
229
247
|
}: FloatingContentProps,
|
|
230
248
|
forwardedRef,
|
|
@@ -245,10 +263,31 @@ const FloatingContent = forwardRef<HTMLDivElement, FloatingContentProps>(
|
|
|
245
263
|
const desiredPlacement = (side +
|
|
246
264
|
(align !== "center" ? "-" + align : "")) as Placement;
|
|
247
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Create a bias to the preferred side.
|
|
268
|
+
* On iOS, when the mobile software keyboard opens, the input is exactly centered
|
|
269
|
+
* in the viewport, but this can cause it to flip to the top undesirably.
|
|
270
|
+
*/
|
|
271
|
+
const bias = 1;
|
|
272
|
+
const biasTop = side === "bottom" ? bias : 0;
|
|
273
|
+
const biasBottom = side === "top" ? bias : 0;
|
|
274
|
+
const biasLeft = side === "right" ? bias : 0;
|
|
275
|
+
const biasRight = side === "left" ? bias : 0;
|
|
276
|
+
|
|
248
277
|
const collisionPadding =
|
|
249
278
|
typeof collisionPaddingProp === "number"
|
|
250
|
-
?
|
|
251
|
-
|
|
279
|
+
? {
|
|
280
|
+
top: collisionPaddingProp + biasTop,
|
|
281
|
+
right: collisionPaddingProp + biasRight,
|
|
282
|
+
bottom: collisionPaddingProp + biasBottom,
|
|
283
|
+
left: collisionPaddingProp + biasLeft,
|
|
284
|
+
}
|
|
285
|
+
: {
|
|
286
|
+
top: (collisionPaddingProp.top || 0) + biasTop,
|
|
287
|
+
right: (collisionPaddingProp.right || 0) + biasRight,
|
|
288
|
+
bottom: (collisionPaddingProp.bottom || 0) + biasBottom,
|
|
289
|
+
left: (collisionPaddingProp.left || 0) + biasLeft,
|
|
290
|
+
};
|
|
252
291
|
|
|
253
292
|
const boundary = Array.isArray(collisionBoundary)
|
|
254
293
|
? collisionBoundary
|
|
@@ -256,20 +295,13 @@ const FloatingContent = forwardRef<HTMLDivElement, FloatingContentProps>(
|
|
|
256
295
|
|
|
257
296
|
const hasExplicitBoundaries = boundary.length > 0;
|
|
258
297
|
|
|
259
|
-
|
|
260
|
-
* .filter(x => x !== null) does not narrow the type of the array enough.
|
|
261
|
-
*/
|
|
262
|
-
function isNotNull<T>(value: T | null): value is T {
|
|
263
|
-
return value !== null;
|
|
264
|
-
}
|
|
265
|
-
|
|
298
|
+
/* https://floating-ui.com/docs/detectOverflow#boundary */
|
|
266
299
|
const detectOverflowOptions: FlipOptions = {
|
|
267
300
|
padding: collisionPadding,
|
|
268
301
|
boundary: boundary.filter(isNotNull),
|
|
269
302
|
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
270
303
|
altBoundary: hasExplicitBoundaries,
|
|
271
|
-
|
|
272
|
-
fallbackAxisSideDirection: "end",
|
|
304
|
+
fallbackAxisSideDirection,
|
|
273
305
|
fallbackPlacements,
|
|
274
306
|
};
|
|
275
307
|
|
|
@@ -308,7 +340,11 @@ const FloatingContent = forwardRef<HTMLDivElement, FloatingContentProps>(
|
|
|
308
340
|
crossAxis: false,
|
|
309
341
|
limiter: limitShift(),
|
|
310
342
|
}),
|
|
311
|
-
avoidCollisions &&
|
|
343
|
+
avoidCollisions &&
|
|
344
|
+
flip({
|
|
345
|
+
...detectOverflowOptions,
|
|
346
|
+
padding: collisionPadding,
|
|
347
|
+
}),
|
|
312
348
|
size({
|
|
313
349
|
...detectOverflowOptions,
|
|
314
350
|
apply: ({ elements, rects, availableWidth, availableHeight }) => {
|
|
@@ -437,7 +473,14 @@ const FloatingContent = forwardRef<HTMLDivElement, FloatingContentProps>(
|
|
|
437
473
|
},
|
|
438
474
|
);
|
|
439
475
|
|
|
476
|
+
/**
|
|
477
|
+
* .filter(x => x !== null) does not narrow the type of the array enough.
|
|
478
|
+
*/
|
|
479
|
+
function isNotNull<T>(value: T | null): value is T {
|
|
480
|
+
return value !== null;
|
|
481
|
+
}
|
|
482
|
+
|
|
440
483
|
Floating.Anchor = FloatingAnchor;
|
|
441
484
|
Floating.Content = FloatingContent;
|
|
442
485
|
|
|
443
|
-
export { Floating };
|
|
486
|
+
export { Floating, MENU_COLLISION_AVOIDANCE, POPOVER_COLLISION_AVOIDANCE };
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
useMergeRefs,
|
|
10
10
|
} from "../../hooks";
|
|
11
11
|
import { DismissableLayer } from "../dismissablelayer/DismissableLayer";
|
|
12
|
-
import { Floating } from "../floating/Floating";
|
|
12
|
+
import { Floating, MENU_COLLISION_AVOIDANCE } from "../floating/Floating";
|
|
13
13
|
import { FocusBoundary } from "../focus-boundary/FocusBoundary";
|
|
14
14
|
import { RovingFocus, RovingFocusProps } from "./parts/RovingFocus";
|
|
15
15
|
import {
|
|
@@ -328,6 +328,9 @@ const MenuContentInternal = forwardRef<
|
|
|
328
328
|
data-state={getOpenState(context.open)}
|
|
329
329
|
data-aksel-menu-content=""
|
|
330
330
|
dir="ltr"
|
|
331
|
+
fallbackAxisSideDirection={
|
|
332
|
+
MENU_COLLISION_AVOIDANCE.fallbackAxisSide
|
|
333
|
+
}
|
|
331
334
|
{...rest}
|
|
332
335
|
ref={composedRefs}
|
|
333
336
|
style={{ outline: "none", ...rest.style }}
|
|
@@ -65,7 +65,7 @@ function createStrictContext<T>(options: {
|
|
|
65
65
|
|
|
66
66
|
function Provider({ children, ...context }: ProviderProps<T>) {
|
|
67
67
|
// biome-ignore lint/correctness/useExhaustiveDependencies: Object.values(context) includes all dependencies.
|
|
68
|
-
const value = React.useMemo(() => context, Object.values(context)) as T; // eslint-disable-line react-hooks/exhaustive-deps
|
|
68
|
+
const value = React.useMemo(() => context, Object.values(context)) as T; // eslint-disable-line react-hooks/exhaustive-deps
|
|
69
69
|
|
|
70
70
|
return <Context.Provider value={value}>{children}</Context.Provider>;
|
|
71
71
|
}
|
|
@@ -2,28 +2,31 @@
|
|
|
2
2
|
import { useState } from "react";
|
|
3
3
|
import { useEventCallback } from "./useEventCallback";
|
|
4
4
|
|
|
5
|
-
export interface UseControllableStateProps<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export interface UseControllableStateProps<
|
|
6
|
+
StateT,
|
|
7
|
+
ChangeT extends StateT = StateT,
|
|
8
|
+
> {
|
|
9
|
+
value?: StateT;
|
|
10
|
+
defaultValue: StateT | (() => StateT);
|
|
11
|
+
onChange?: (value: ChangeT) => void;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* `useControllableState` returns the state and function that updates the state, just like React.useState does.
|
|
13
16
|
*/
|
|
14
|
-
export function useControllableState<
|
|
17
|
+
export function useControllableState<StateT, ChangeT extends StateT = StateT>({
|
|
15
18
|
value: valueProp,
|
|
16
19
|
defaultValue,
|
|
17
20
|
onChange,
|
|
18
|
-
}: UseControllableStateProps<
|
|
21
|
+
}: UseControllableStateProps<StateT, ChangeT>) {
|
|
19
22
|
const onChangeProp = useEventCallback(onChange);
|
|
20
23
|
|
|
21
24
|
const [uncontrolledState, setUncontrolledState] = useState(defaultValue);
|
|
22
25
|
const controlled = valueProp !== undefined;
|
|
23
26
|
const value = controlled ? valueProp : uncontrolledState;
|
|
24
27
|
|
|
25
|
-
const setValue = useEventCallback((next: React.SetStateAction<
|
|
26
|
-
const setter = next as (prevState?:
|
|
28
|
+
const setValue = useEventCallback((next: React.SetStateAction<ChangeT>) => {
|
|
29
|
+
const setter = next as (prevState?: StateT) => ChangeT;
|
|
27
30
|
const nextValue = typeof next === "function" ? setter(value) : next;
|
|
28
31
|
|
|
29
32
|
if (!controlled) {
|
|
@@ -6,7 +6,7 @@ import { useRefWithInit } from "./useRefWithInit";
|
|
|
6
6
|
function useValueAsRef<T>(value: T) {
|
|
7
7
|
const latest = useRefWithInit(createLatestRef, value).current!;
|
|
8
8
|
|
|
9
|
-
latest.next = value;
|
|
9
|
+
latest.next = value; // eslint-disable-line react-hooks/immutability
|
|
10
10
|
|
|
11
11
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
12
|
useClientLayoutEffect(latest.effect);
|
|
@@ -19,7 +19,7 @@ function useGlobalId(idOverride?: string): string | undefined {
|
|
|
19
19
|
// We can't use it server-side.
|
|
20
20
|
// If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem
|
|
21
21
|
globalId += 1;
|
|
22
|
-
setDefaultId(`aksel-id-${globalId}`);
|
|
22
|
+
setDefaultId(`aksel-id-${globalId}`); // eslint-disable-line react-hooks/set-state-in-effect
|
|
23
23
|
}
|
|
24
24
|
}, [defaultId]);
|
|
25
25
|
return id;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { ItemDetail } from "./useTableItems";
|
|
3
|
-
type DataTableExpansionContextT = {
|
|
4
|
-
isExpanded: (id: string | number) => boolean;
|
|
5
|
-
isDetailsPanelExpandable: (id: string | number) => boolean;
|
|
6
|
-
toggleExpansion: (id: string | number) => void;
|
|
7
|
-
toggleAll: () => void;
|
|
8
|
-
isAllExpanded: boolean;
|
|
9
|
-
getDetailsPanelContent?: (row: unknown) => React.ReactNode;
|
|
10
|
-
getDetailsPanelHeight?: (row: unknown) => number | "auto";
|
|
11
|
-
showExpandAll: boolean;
|
|
12
|
-
enableDetailsPanel: boolean;
|
|
13
|
-
};
|
|
14
|
-
declare const useDataTableExpansion: <S extends boolean = true>(strict?: S | undefined) => S extends true ? DataTableExpansionContextT : DataTableExpansionContextT | undefined;
|
|
15
|
-
type TableExpansionOptions<T> = {
|
|
16
|
-
detailsPanelRowIds?: (string | number)[];
|
|
17
|
-
defaultDetailsPanelRowIds?: (string | number)[];
|
|
18
|
-
onDetailsPanelChange?: (ids: (string | number)[]) => void;
|
|
19
|
-
itemDetails: Map<T, ItemDetail<T>>;
|
|
20
|
-
getDetailsPanelContent?: (row: T) => React.ReactNode;
|
|
21
|
-
isDetailsPanelExpandable?: (rowData: T) => boolean;
|
|
22
|
-
getDetailsPanelHeight?: (row: T) => number | "auto";
|
|
23
|
-
showExpandAll?: boolean;
|
|
24
|
-
};
|
|
25
|
-
declare function getDataTableExpansionId(tableId: string, rowId: string | number): string;
|
|
26
|
-
declare function DataTableExpansionProvider<T>({ children, detailsPanelRowIds, defaultDetailsPanelRowIds, onDetailsPanelChange, itemDetails, getDetailsPanelContent, isDetailsPanelExpandable, getDetailsPanelHeight, showExpandAll, }: TableExpansionOptions<T> & {
|
|
27
|
-
children: React.ReactNode;
|
|
28
|
-
}): React.JSX.Element;
|
|
29
|
-
export { DataTableExpansionProvider, getDataTableExpansionId, useDataTableExpansion, };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useTableExpansion.js","sourceRoot":"","sources":["../../../../src/data/table/hooks/useTableExpansion.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/** biome-ignore-all lint/correctness/useHookAtTopLevel: False positive because of the way forwardRef() is added */
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { type SelectionProps } from "../hooks/useTableSelection";
|
|
4
|
-
import { type TableSortOptions } from "../hooks/useTableSort";
|
|
5
|
-
import type { ColumnDefinitions } from "./DataTable.types";
|
|
6
|
-
interface DataTableProps<T> extends React.HTMLAttributes<HTMLTableElement>, SelectionProps, TableSortOptions {
|
|
7
|
-
children?: never;
|
|
8
|
-
/**
|
|
9
|
-
* Controls vertical cell padding.
|
|
10
|
-
* @default "normal"
|
|
11
|
-
*/
|
|
12
|
-
rowDensity?: "condensed" | "normal" | "spacious";
|
|
13
|
-
/**
|
|
14
|
-
* Zebra striped table
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
zebraStripes?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Truncate content in cells and show ellipsis for overflowed text.
|
|
20
|
-
*
|
|
21
|
-
* **NB:** When using `layout="auto"`, you have to manually set a `maxWidth` on columns that should be truncated.
|
|
22
|
-
* @default true
|
|
23
|
-
*/
|
|
24
|
-
truncateContent?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Enables keyboard navigation for table rows and cells.
|
|
27
|
-
* @default false
|
|
28
|
-
*/
|
|
29
|
-
withKeyboardNav?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Custom callback to determine if navigation should be blocked.
|
|
32
|
-
* Called before default blocking logic.
|
|
33
|
-
* Requires `withKeyboardNav` to be `true`.
|
|
34
|
-
*/
|
|
35
|
-
shouldBlockNavigation?: (event: KeyboardEvent) => boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Controls table layout.
|
|
38
|
-
*
|
|
39
|
-
* ### fixed
|
|
40
|
-
* Gives you full control of column widths. This is required for resizable columns.
|
|
41
|
-
*
|
|
42
|
-
* ### auto
|
|
43
|
-
* Makes the columns resize automatically based on the content.
|
|
44
|
-
* The table will take up at least 100% of available width.
|
|
45
|
-
*
|
|
46
|
-
* **NB:** When using this with `truncateContent`, you have to manually
|
|
47
|
-
* set a `contentMaxWidth` on cells that should be truncated.
|
|
48
|
-
* @default "fixed"
|
|
49
|
-
*/
|
|
50
|
-
layout?: "fixed" | "auto";
|
|
51
|
-
/**
|
|
52
|
-
* Defines the columns of the table and how to render them.
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* Each column definition should have a unique `id` (or use the column index as fallback) and a `cell`-renderer function that takes the row data as argument and returns a React node.
|
|
56
|
-
*/
|
|
57
|
-
columnDefinitions: ColumnDefinitions<T>;
|
|
58
|
-
/**
|
|
59
|
-
* The data to display in the table.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* Each object in the array represents a row, and the properties of the object are used to render the cells based on the `columnDefinitions`.
|
|
63
|
-
*/
|
|
64
|
-
data: T[];
|
|
65
|
-
/**
|
|
66
|
-
* Function to get unique row id from row data.
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* 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.
|
|
70
|
-
*/
|
|
71
|
-
getRowId?: (rowData: T, index: number) => string | number;
|
|
72
|
-
/**
|
|
73
|
-
* Sticky columns that remain visible when horizontally scrolling the table.
|
|
74
|
-
*
|
|
75
|
-
* You can specify 1 sticky column on the left and 1 on the right.
|
|
76
|
-
*/
|
|
77
|
-
stickyColumns?: {
|
|
78
|
-
first?: "1";
|
|
79
|
-
last?: "1";
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* @default false
|
|
83
|
-
*/
|
|
84
|
-
stickyHeader?: boolean;
|
|
85
|
-
/**
|
|
86
|
-
* Callback invoked when a data row is clicked.
|
|
87
|
-
* Not called when clicking header, loading, or empty-state rows.
|
|
88
|
-
*/
|
|
89
|
-
onRowClick?: (rowId: string | number, event: React.MouseEvent<HTMLTableRowElement>) => void;
|
|
90
|
-
/**
|
|
91
|
-
* Content to render when `data` is empty.
|
|
92
|
-
* Rendered inside a `DataTable.EmptyState` row spanning all columns.
|
|
93
|
-
*/
|
|
94
|
-
emptyState?: React.ReactNode;
|
|
95
|
-
/**
|
|
96
|
-
* Shows the table in a loading state.
|
|
97
|
-
*
|
|
98
|
-
* - When `loadingState` is provided, it is rendered inside a `DataTable.LoadingState` row.
|
|
99
|
-
* - When `loadingState` is **not** provided, skeleton placeholder rows are rendered instead.
|
|
100
|
-
* @default false
|
|
101
|
-
*/
|
|
102
|
-
isLoading?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Custom content to render when `isLoading` is `true`.
|
|
105
|
-
* Rendered inside a `DataTable.LoadingState` row spanning all columns.
|
|
106
|
-
* When omitted, skeleton rows are rendered based on `loadingRows`.
|
|
107
|
-
*/
|
|
108
|
-
loadingState?: React.ReactNode;
|
|
109
|
-
/**
|
|
110
|
-
* Number of skeleton rows to render when `isLoading` is `true` and no `loadingState` is provided.
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* If not provided, the rendered content will get a temporarily overlay while loading
|
|
114
|
-
*/
|
|
115
|
-
loadingRows?: number;
|
|
116
|
-
/**
|
|
117
|
-
* Visually hidden label announced to screen readers when skeleton rows are shown.
|
|
118
|
-
* Only used when `isLoading` is `true` and no `loadingState` is provided.
|
|
119
|
-
* @default "Laster innhold"
|
|
120
|
-
*/
|
|
121
|
-
loadingLabel?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Renders a details panel below the row when expanded.
|
|
124
|
-
* When provided, an expand toggle column is added automatically.
|
|
125
|
-
*/
|
|
126
|
-
getDetailsPanelContent?: (rowData: T) => React.ReactNode;
|
|
127
|
-
/**
|
|
128
|
-
* Determines whether a row can be expanded to show details panel content.
|
|
129
|
-
* @default () => true
|
|
130
|
-
*/
|
|
131
|
-
isDetailsPanelExpandable?: (rowData: T) => boolean;
|
|
132
|
-
/**
|
|
133
|
-
* Controlled list of expanded row IDs.
|
|
134
|
-
* Use with `onDetailsPanelChange` for controlled usage, or `defaultDetailsPanelRowIds` for uncontrolled.
|
|
135
|
-
*/
|
|
136
|
-
detailsPanelRowIds?: (string | number)[];
|
|
137
|
-
/**
|
|
138
|
-
* Initial list of expanded row IDs for uncontrolled usage.
|
|
139
|
-
* @default []
|
|
140
|
-
*/
|
|
141
|
-
defaultDetailsPanelRowIds?: (string | number)[];
|
|
142
|
-
/**
|
|
143
|
-
* Called when the list of expanded row IDs changes.
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* TODO:
|
|
147
|
-
* - Docs: This pattern is called "Master / Detail" in general terms
|
|
148
|
-
*/
|
|
149
|
-
onDetailsPanelChange?: (ids: (string | number)[]) => void;
|
|
150
|
-
/**
|
|
151
|
-
* Returns the height (in px) or `"auto"` for a row's details panel.
|
|
152
|
-
* When a number is returned, the panel scrolls within that fixed height.
|
|
153
|
-
* @default "auto"
|
|
154
|
-
*/
|
|
155
|
-
getDetailsPanelHeight?: (rowData: T) => number | "auto";
|
|
156
|
-
/**
|
|
157
|
-
* Shows an expand-all toggle button in the expand column header.
|
|
158
|
-
* @default false
|
|
159
|
-
*/
|
|
160
|
-
showExpandAll?: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Function to get sub-rows for a given row, used for nested rows.
|
|
163
|
-
* When provided, an expand toggle column is added automatically.
|
|
164
|
-
*/
|
|
165
|
-
getSubRows?: (rowData: T) => T[];
|
|
166
|
-
expandedSubRowIds?: (string | number)[];
|
|
167
|
-
defaultExpandedSubRowIds?: (string | number)[];
|
|
168
|
-
isSubRowExpandable?: (rowData: T) => boolean;
|
|
169
|
-
onExpandedSubRowIdsChange?: (ids: (string | number)[]) => void;
|
|
170
|
-
}
|
|
171
|
-
declare const DataTableAuto: <T>(props: DataTableProps<T> & React.RefAttributes<HTMLTableElement>) => React.ReactElement | null;
|
|
172
|
-
export { DataTableAuto };
|
|
173
|
-
export type { DataTableProps };
|
|
174
|
-
export default DataTableAuto;
|