@mortenbrudvik/waveui 0.14.1 → 0.16.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/README.md +413 -53
- package/dist/components/data-display/InfoButton.cjs +1 -1
- package/dist/components/data-display/InfoButton.cjs.map +1 -1
- package/dist/components/data-display/InfoButton.mjs +90 -82
- package/dist/components/data-display/InfoButton.mjs.map +1 -1
- package/dist/components/data-display/InfoLabel.cjs +1 -1
- package/dist/components/data-display/InfoLabel.cjs.map +1 -1
- package/dist/components/data-display/InfoLabel.mjs +19 -18
- package/dist/components/data-display/InfoLabel.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +405 -219
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/List.registry.cjs +1 -1
- package/dist/components/data-display/List.registry.cjs.map +1 -1
- package/dist/components/data-display/List.registry.mjs +12 -6
- package/dist/components/data-display/List.registry.mjs.map +1 -1
- package/dist/components/feedback/MessageBarGroup.cjs +2 -0
- package/dist/components/feedback/MessageBarGroup.cjs.map +1 -0
- package/dist/components/feedback/MessageBarGroup.mjs +63 -0
- package/dist/components/feedback/MessageBarGroup.mjs.map +1 -0
- package/dist/components/feedback/ProgressBar.cjs +1 -1
- package/dist/components/feedback/ProgressBar.cjs.map +1 -1
- package/dist/components/feedback/ProgressBar.mjs +41 -39
- package/dist/components/feedback/ProgressBar.mjs.map +1 -1
- package/dist/components/feedback/Toaster.cjs +1 -1
- package/dist/components/feedback/Toaster.cjs.map +1 -1
- package/dist/components/feedback/Toaster.mjs +222 -216
- package/dist/components/feedback/Toaster.mjs.map +1 -1
- package/dist/components/input/Combobox.cjs +1 -1
- package/dist/components/input/Combobox.cjs.map +1 -1
- package/dist/components/input/Combobox.mjs +163 -148
- package/dist/components/input/Combobox.mjs.map +1 -1
- package/dist/components/input/Dropdown.cjs +1 -1
- package/dist/components/input/Dropdown.cjs.map +1 -1
- package/dist/components/input/Dropdown.mjs +132 -117
- package/dist/components/input/Dropdown.mjs.map +1 -1
- package/dist/components/input/Listbox.cjs +1 -1
- package/dist/components/input/Listbox.cjs.map +1 -1
- package/dist/components/input/Listbox.mjs +90 -78
- package/dist/components/input/Listbox.mjs.map +1 -1
- package/dist/components/input/Option.cjs +1 -1
- package/dist/components/input/Option.cjs.map +1 -1
- package/dist/components/input/Option.data.cjs +2 -0
- package/dist/components/input/Option.data.cjs.map +1 -0
- package/dist/components/input/Option.data.mjs +114 -0
- package/dist/components/input/Option.data.mjs.map +1 -0
- package/dist/components/input/Option.mjs +21 -17
- package/dist/components/input/Option.mjs.map +1 -1
- package/dist/components/layout/Accordion.cjs +1 -1
- package/dist/components/layout/Accordion.cjs.map +1 -1
- package/dist/components/layout/Accordion.mjs +124 -109
- package/dist/components/layout/Accordion.mjs.map +1 -1
- package/dist/components/layout/Carousel.cjs +1 -1
- package/dist/components/layout/Carousel.cjs.map +1 -1
- package/dist/components/layout/Carousel.mjs +207 -193
- package/dist/components/layout/Carousel.mjs.map +1 -1
- package/dist/components/layout/FlatTree.cjs +2 -0
- package/dist/components/layout/FlatTree.cjs.map +1 -0
- package/dist/components/layout/FlatTree.context.cjs +2 -0
- package/dist/components/layout/FlatTree.context.cjs.map +1 -0
- package/dist/components/layout/FlatTree.context.mjs +20 -0
- package/dist/components/layout/FlatTree.context.mjs.map +1 -0
- package/dist/components/layout/FlatTree.item.cjs +2 -0
- package/dist/components/layout/FlatTree.item.cjs.map +1 -0
- package/dist/components/layout/FlatTree.item.mjs +90 -0
- package/dist/components/layout/FlatTree.item.mjs.map +1 -0
- package/dist/components/layout/FlatTree.mjs +276 -0
- package/dist/components/layout/FlatTree.mjs.map +1 -0
- package/dist/components/layout/TabList.cjs +1 -1
- package/dist/components/layout/TabList.cjs.map +1 -1
- package/dist/components/layout/TabList.mjs +149 -108
- package/dist/components/layout/TabList.mjs.map +1 -1
- package/dist/components/layout/Tree.cjs.map +1 -1
- package/dist/components/layout/Tree.context.cjs +1 -1
- package/dist/components/layout/Tree.context.cjs.map +1 -1
- package/dist/components/layout/Tree.context.mjs +2 -1
- package/dist/components/layout/Tree.context.mjs.map +1 -1
- package/dist/components/layout/Tree.core.cjs +1 -1
- package/dist/components/layout/Tree.core.cjs.map +1 -1
- package/dist/components/layout/Tree.core.mjs +162 -148
- package/dist/components/layout/Tree.core.mjs.map +1 -1
- package/dist/components/layout/Tree.mjs.map +1 -1
- package/dist/components/layout/Tree.selection.cjs +1 -1
- package/dist/components/layout/Tree.selection.cjs.map +1 -1
- package/dist/components/layout/Tree.selection.mjs +11 -57
- package/dist/components/layout/Tree.selection.mjs.map +1 -1
- package/dist/components/layout/useFlatTree.cjs +2 -0
- package/dist/components/layout/useFlatTree.cjs.map +1 -0
- package/dist/components/layout/useFlatTree.mjs +83 -0
- package/dist/components/layout/useFlatTree.mjs.map +1 -0
- package/dist/components/navigation/Menu.popover.cjs +1 -1
- package/dist/components/navigation/Menu.popover.cjs.map +1 -1
- package/dist/components/navigation/Menu.popover.mjs +154 -168
- package/dist/components/navigation/Menu.popover.mjs.map +1 -1
- package/dist/components/navigation/Nav.cjs +1 -1
- package/dist/components/navigation/Nav.cjs.map +1 -1
- package/dist/components/navigation/Nav.mjs +156 -136
- package/dist/components/navigation/Nav.mjs.map +1 -1
- package/dist/components/navigation/NavDrawer.cjs +1 -1
- package/dist/components/navigation/NavDrawer.cjs.map +1 -1
- package/dist/components/navigation/NavDrawer.mjs +48 -45
- package/dist/components/navigation/NavDrawer.mjs.map +1 -1
- package/dist/components/overlays/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog.mjs +128 -122
- package/dist/components/overlays/Dialog.mjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.cjs +1 -1
- package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.mjs +12 -12
- package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
- package/dist/components/overlays/Drawer.cjs.map +1 -1
- package/dist/components/overlays/Drawer.mjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.cjs +1 -1
- package/dist/components/overlays/Drawer.panel.cjs.map +1 -1
- package/dist/components/overlays/Drawer.panel.mjs +97 -81
- package/dist/components/overlays/Drawer.panel.mjs.map +1 -1
- package/dist/components/overlays/Drawer.root.cjs +1 -1
- package/dist/components/overlays/Drawer.root.cjs.map +1 -1
- package/dist/components/overlays/Drawer.root.mjs +34 -31
- package/dist/components/overlays/Drawer.root.mjs.map +1 -1
- package/dist/components/overlays/Popover.cjs +1 -1
- package/dist/components/overlays/Popover.cjs.map +1 -1
- package/dist/components/overlays/Popover.mjs +231 -216
- package/dist/components/overlays/Popover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.mjs +199 -177
- package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.root.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.root.mjs +93 -92
- package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -1
- package/dist/components/overlays/Tooltip.cjs +1 -1
- package/dist/components/overlays/Tooltip.cjs.map +1 -1
- package/dist/components/overlays/Tooltip.mjs +66 -61
- package/dist/components/overlays/Tooltip.mjs.map +1 -1
- package/dist/components/provider/WaveProvider.cjs +1 -1
- package/dist/components/provider/WaveProvider.cjs.map +1 -1
- package/dist/components/provider/WaveProvider.mjs +26 -23
- package/dist/components/provider/WaveProvider.mjs.map +1 -1
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.context.cjs +2 -0
- package/dist/components/table/DataGrid.context.cjs.map +1 -0
- package/dist/components/table/DataGrid.context.mjs +74 -0
- package/dist/components/table/DataGrid.context.mjs.map +1 -0
- package/dist/components/table/DataGrid.header.cjs +2 -0
- package/dist/components/table/DataGrid.header.cjs.map +1 -0
- package/dist/components/table/DataGrid.header.mjs +168 -0
- package/dist/components/table/DataGrid.header.mjs.map +1 -0
- package/dist/components/table/DataGrid.mjs +488 -591
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/DataGrid.sizing.cjs +2 -0
- package/dist/components/table/DataGrid.sizing.cjs.map +1 -0
- package/dist/components/table/DataGrid.sizing.mjs +187 -0
- package/dist/components/table/DataGrid.sizing.mjs.map +1 -0
- package/dist/components/table/DataGrid.store.cjs +2 -0
- package/dist/components/table/DataGrid.store.cjs.map +1 -0
- package/dist/components/table/DataGrid.store.mjs +108 -0
- package/dist/components/table/DataGrid.store.mjs.map +1 -0
- package/dist/components/table/DataGrid.window.cjs +2 -0
- package/dist/components/table/DataGrid.window.cjs.map +1 -0
- package/dist/components/table/DataGrid.window.mjs +165 -0
- package/dist/components/table/DataGrid.window.mjs.map +1 -0
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +74 -72
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/table/Table.resize.cjs +2 -0
- package/dist/components/table/Table.resize.cjs.map +1 -0
- package/dist/components/table/Table.resize.mjs +98 -0
- package/dist/components/table/Table.resize.mjs.map +1 -0
- package/dist/components/table/useGridNavigation.cjs +1 -1
- package/dist/components/table/useGridNavigation.cjs.map +1 -1
- package/dist/components/table/useGridNavigation.mjs +343 -140
- package/dist/components/table/useGridNavigation.mjs.map +1 -1
- package/dist/components/table/useTableColumnSizing.cjs +2 -0
- package/dist/components/table/useTableColumnSizing.cjs.map +1 -0
- package/dist/components/table/useTableColumnSizing.mjs +76 -0
- package/dist/components/table/useTableColumnSizing.mjs.map +1 -0
- package/dist/components/table/useTableFeatures.cjs +2 -0
- package/dist/components/table/useTableFeatures.cjs.map +1 -0
- package/dist/components/table/useTableFeatures.mjs +110 -0
- package/dist/components/table/useTableFeatures.mjs.map +1 -0
- package/dist/components/table/useTableSelection.cjs +2 -0
- package/dist/components/table/useTableSelection.cjs.map +1 -0
- package/dist/components/table/useTableSelection.mjs +39 -0
- package/dist/components/table/useTableSelection.mjs.map +1 -0
- package/dist/components/table/useTableSort.cjs +2 -0
- package/dist/components/table/useTableSort.cjs.map +1 -0
- package/dist/components/table/useTableSort.mjs +58 -0
- package/dist/components/table/useTableSort.mjs.map +1 -0
- package/dist/hooks/useActiveDescendant.cjs +1 -1
- package/dist/hooks/useActiveDescendant.cjs.map +1 -1
- package/dist/hooks/useActiveDescendant.mjs +33 -25
- package/dist/hooks/useActiveDescendant.mjs.map +1 -1
- package/dist/hooks/useCollapsePresence.cjs +2 -0
- package/dist/hooks/useCollapsePresence.cjs.map +1 -0
- package/dist/hooks/useCollapsePresence.mjs +21 -0
- package/dist/hooks/useCollapsePresence.mjs.map +1 -0
- package/dist/hooks/useFocusBeforeClose.cjs +2 -0
- package/dist/hooks/useFocusBeforeClose.cjs.map +1 -0
- package/dist/hooks/useFocusBeforeClose.mjs +33 -0
- package/dist/hooks/useFocusBeforeClose.mjs.map +1 -0
- package/dist/hooks/useListbox.cjs +1 -1
- package/dist/hooks/useListbox.cjs.map +1 -1
- package/dist/hooks/useListbox.mjs +140 -130
- package/dist/hooks/useListbox.mjs.map +1 -1
- package/dist/hooks/useMotion.cjs +2 -0
- package/dist/hooks/useMotion.cjs.map +1 -0
- package/dist/hooks/useMotion.mjs +14 -0
- package/dist/hooks/useMotion.mjs.map +1 -0
- package/dist/hooks/usePresenceGroup.cjs +2 -0
- package/dist/hooks/usePresenceGroup.cjs.map +1 -0
- package/dist/hooks/usePresenceGroup.mjs +68 -0
- package/dist/hooks/usePresenceGroup.mjs.map +1 -0
- package/dist/hooks/useRovingTabIndex.cjs +1 -1
- package/dist/hooks/useRovingTabIndex.cjs.map +1 -1
- package/dist/hooks/useRovingTabIndex.mjs +1 -1
- package/dist/hooks/useRovingTabIndex.mjs.map +1 -1
- package/dist/hooks/useSelection.cjs +2 -0
- package/dist/hooks/useSelection.cjs.map +1 -0
- package/dist/hooks/useSelection.mjs +57 -0
- package/dist/hooks/useSelection.mjs.map +1 -0
- package/dist/hooks/useVirtualWindow.cjs +2 -0
- package/dist/hooks/useVirtualWindow.cjs.map +1 -0
- package/dist/hooks/useVirtualWindow.mjs +102 -0
- package/dist/hooks/useVirtualWindow.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2249 -179
- package/dist/index.d.ts +2249 -179
- package/dist/index.mjs +147 -135
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +125 -95
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/columnSizing.cjs +2 -0
- package/dist/lib/columnSizing.cjs.map +1 -0
- package/dist/lib/columnSizing.mjs +27 -0
- package/dist/lib/columnSizing.mjs.map +1 -0
- package/dist/lib/flatTree.cjs +2 -0
- package/dist/lib/flatTree.cjs.map +1 -0
- package/dist/lib/flatTree.mjs +118 -0
- package/dist/lib/flatTree.mjs.map +1 -0
- package/dist/lib/motion.cjs +2 -0
- package/dist/lib/motion.cjs.map +1 -0
- package/dist/lib/motion.mjs +43 -0
- package/dist/lib/motion.mjs.map +1 -0
- package/dist/lib/selection.cjs +2 -0
- package/dist/lib/selection.cjs.map +1 -0
- package/dist/lib/selection.mjs +28 -0
- package/dist/lib/selection.mjs.map +1 -0
- package/dist/lib/treeCascade.cjs +2 -0
- package/dist/lib/treeCascade.cjs.map +1 -0
- package/dist/lib/treeCascade.mjs +52 -0
- package/dist/lib/treeCascade.mjs.map +1 -0
- package/dist/lib/virtual.cjs +2 -0
- package/dist/lib/virtual.cjs.map +1 -0
- package/dist/lib/virtual.mjs +54 -0
- package/dist/lib/virtual.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +2 -1
|
@@ -1,304 +1,121 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn as e } from "../../lib/cn.mjs";
|
|
3
3
|
import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
|
-
import { isDev as r,
|
|
5
|
-
import { composeEventHandlers as
|
|
6
|
-
import { dataGridBodyClassNames as
|
|
7
|
-
import { useControllable as
|
|
8
|
-
import { useId as
|
|
9
|
-
import { useMergedRefs as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
4
|
+
import { isDev as r, resolveDeprecatedProp as i, warnDeprecated as a, warnOnce as o } from "../../lib/dev.mjs";
|
|
5
|
+
import { composeEventHandlers as s } from "../../lib/composeEventHandlers.mjs";
|
|
6
|
+
import { dataGridBodyClassNames as c, dataGridCellClassNames as l, dataGridClassNames as u, dataGridRowClassNames as d, dataGridSelectionCellClassNames as f } from "../../lib/classNames.mjs";
|
|
7
|
+
import { useControllable as p } from "../../hooks/useControllable.mjs";
|
|
8
|
+
import { useId as ee } from "../../hooks/useId.mjs";
|
|
9
|
+
import { useMergedRefs as m } from "../../hooks/useMergedRefs.mjs";
|
|
10
|
+
import { clearIds as h, selectAllIds as g, summarizeSelection as _, toggleId as v } from "../../lib/selection.mjs";
|
|
11
|
+
import { useGridNavigation as te } from "./useGridNavigation.mjs";
|
|
12
|
+
import { focusRingInset as y, forcedColors as b } from "../../lib/styles.mjs";
|
|
13
|
+
import { endsTextSelection as ne, isForeignEvent as x } from "../../lib/events.mjs";
|
|
14
|
+
import { SELECTION_CELL_CLASSES as re, TableSelectionControl as S, markTablePart as C } from "./Table.shared.mjs";
|
|
15
|
+
import { DataGridFixedLayoutContext as w, DataGridResizeContext as ie, useDataGridColumnSizing as ae } from "./DataGrid.sizing.mjs";
|
|
16
|
+
import { DataGridWindowContext as T, DataGridWindowRowContext as E, getWindowNavigationModel as D, renderWindowRows as oe, useDataGridWindow as se } from "./DataGrid.window.mjs";
|
|
17
|
+
import { createSelectionStore as O } from "./DataGrid.store.mjs";
|
|
18
|
+
import { DataGridContext as ce, DataGridHeaderRowHintContext as le, DataGridItemSelectionDisabledContext as ue, DataGridItemsContext as de, DataGridRowContext as fe, DataGridRowIdContext as pe, DataGridSectionContext as k, DataGridSortContext as me, useDataGridContext as A, useDataGridRowContext as j } from "./DataGrid.context.mjs";
|
|
19
|
+
import { DataGridHeader as M, DataGridHeaderCell as he, DataGridSelectionHeaderSlot as ge, cellBase as N, isSelectionCellElement as P } from "./DataGrid.header.mjs";
|
|
20
|
+
import * as F from "react";
|
|
21
|
+
import { jsx as I, jsxs as _e } from "react/jsx-runtime";
|
|
16
22
|
//#region src/components/table/DataGrid.tsx
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
let n = new Set(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = 0, o = 0, s = "none", c = t, l, u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = (e) => {
|
|
20
|
-
for (let t of Array.from(e)) t();
|
|
21
|
-
}, p = () => {
|
|
22
|
-
if (l !== void 0) return l;
|
|
23
|
-
let e = null;
|
|
24
|
-
for (let t of n) {
|
|
25
|
-
if (r.has(t)) {
|
|
26
|
-
e = t;
|
|
27
|
-
break;
|
|
28
|
-
}
|
|
29
|
-
e ??= t;
|
|
30
|
-
}
|
|
31
|
-
return l = e, e;
|
|
32
|
-
}, m = (e) => {
|
|
33
|
-
if (n.size < 2 || !n.has(e)) return;
|
|
34
|
-
let t = l;
|
|
35
|
-
l = void 0, c && p() !== t && f(u);
|
|
36
|
-
}, h = () => {
|
|
37
|
-
let e = o === 0 ? "none" : o === a ? "all" : "some";
|
|
38
|
-
e !== s && (s = e, f(d));
|
|
39
|
-
}, g = (e) => r.has(e) && !i.has(e), _ = (e, t) => {
|
|
40
|
-
let r = g(e);
|
|
41
|
-
t();
|
|
42
|
-
let i = g(e);
|
|
43
|
-
if (r === i) return;
|
|
44
|
-
let s = i ? 1 : -1;
|
|
45
|
-
a += s, n.has(e) && (o += s);
|
|
46
|
-
}, v = (e, t, n) => {
|
|
47
|
-
let r = (e.get(t) ?? 0) + n;
|
|
48
|
-
r > 0 ? e.set(t, r) : e.delete(t);
|
|
49
|
-
}, y = (e) => (t) => (e.add(t), () => {
|
|
50
|
-
e.delete(t);
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
subscribe: y(u),
|
|
54
|
-
subscribeSelectAll: y(d),
|
|
55
|
-
register(e) {
|
|
56
|
-
let t = !r.has(e);
|
|
57
|
-
_(e, () => v(r, e, 1)), h(), t && m(e);
|
|
58
|
-
let n = !1;
|
|
59
|
-
return () => {
|
|
60
|
-
n || (n = !0, _(e, () => v(r, e, -1)), !r.has(e) && (h(), m(e)));
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
disable(e) {
|
|
64
|
-
_(e, () => v(i, e, 1)), h();
|
|
65
|
-
let t = !1;
|
|
66
|
-
return () => {
|
|
67
|
-
t || (t = !0, _(e, () => v(i, e, -1)), h());
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
isDisabled(e) {
|
|
71
|
-
return i.has(e);
|
|
72
|
-
},
|
|
73
|
-
setSelected(e) {
|
|
74
|
-
let t = new Set(e);
|
|
75
|
-
if (!(t.size === n.size && e.every((e) => n.has(e)))) {
|
|
76
|
-
n = t, l = void 0, o = 0;
|
|
77
|
-
for (let e of t) g(e) && (o += 1);
|
|
78
|
-
f(u), h();
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
setSingleMode(e) {
|
|
82
|
-
c = e;
|
|
83
|
-
},
|
|
84
|
-
isSelected(e, t = !1) {
|
|
85
|
-
return t ? p() === e : n.has(e);
|
|
86
|
-
},
|
|
87
|
-
countRegistrations(e) {
|
|
88
|
-
return r.get(e) ?? 0;
|
|
89
|
-
},
|
|
90
|
-
getSelectAllState() {
|
|
91
|
-
return s;
|
|
92
|
-
},
|
|
93
|
-
getRegistered() {
|
|
94
|
-
return Array.from(r.keys());
|
|
95
|
-
},
|
|
96
|
-
prune(e) {
|
|
97
|
-
return e.filter((e) => r.has(e));
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function A() {
|
|
102
|
-
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = null, r = () => {
|
|
103
|
-
let r = null, i = null;
|
|
104
|
-
for (let [t, a] of e) {
|
|
105
|
-
let o = a();
|
|
106
|
-
if (!o) {
|
|
107
|
-
if (n !== null && e.has(n)) return;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
(!i || o.compareDocumentPosition(i) & Node.DOCUMENT_POSITION_FOLLOWING) && (r = t, i = o);
|
|
111
|
-
}
|
|
112
|
-
if (r === null && (r = e.keys().next().value ?? null), r !== n) {
|
|
113
|
-
n = r;
|
|
114
|
-
for (let e of Array.from(t)) e();
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
return {
|
|
118
|
-
subscribe(e) {
|
|
119
|
-
return t.add(e), () => {
|
|
120
|
-
t.delete(e);
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
register(t, n) {
|
|
124
|
-
return e.set(t, n), r(), () => {
|
|
125
|
-
e.delete(t), r();
|
|
126
|
-
};
|
|
127
|
-
},
|
|
128
|
-
getFirst: () => n,
|
|
129
|
-
refresh: r
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
var j = T.createContext(null), M = T.createContext(null), N = T.createContext("body"), P = T.createContext(null), F = T.createContext(!0), ae = T.createContext(null), oe = T.createContext(null), se = T.createContext(null), ce = {
|
|
133
|
-
selectionMode: "none",
|
|
134
|
-
store: k([]),
|
|
135
|
-
toggleRow: () => {},
|
|
136
|
-
toggleAll: () => {},
|
|
137
|
-
radioName: "",
|
|
138
|
-
selectAllLabel: D,
|
|
139
|
-
selectionHeaderLabel: O,
|
|
140
|
-
selectOnRowClick: !1,
|
|
141
|
-
selectionAppearance: "brand",
|
|
142
|
-
subtleSelection: !1
|
|
143
|
-
}, I = {
|
|
144
|
-
sort: null,
|
|
145
|
-
requestSort: () => {}
|
|
146
|
-
}, L = {
|
|
147
|
-
selectionCellProps: void 0,
|
|
148
|
-
hasSelectionCell: !0,
|
|
149
|
-
rowId: void 0,
|
|
150
|
-
isSelected: !1,
|
|
151
|
-
disabled: !1,
|
|
152
|
-
invisible: !1,
|
|
153
|
-
ariaLabel: void 0,
|
|
154
|
-
ariaLabelledBy: void 0
|
|
155
|
-
};
|
|
156
|
-
function R(e) {
|
|
157
|
-
return T.useContext(j) || (i(e, "DataGrid"), ce);
|
|
158
|
-
}
|
|
159
|
-
function le(e) {
|
|
160
|
-
return T.useContext(se) || (i(e, "DataGrid.Row"), L);
|
|
161
|
-
}
|
|
162
|
-
function z(e) {
|
|
163
|
-
return T.useContext(M) || (i(e, "DataGrid"), I);
|
|
164
|
-
}
|
|
165
|
-
var ue = [];
|
|
166
|
-
function de(e) {
|
|
23
|
+
var ve = [], ye = [];
|
|
24
|
+
function L(e) {
|
|
167
25
|
return e === void 0 ? void 0 : Array.from(e);
|
|
168
26
|
}
|
|
169
|
-
function
|
|
27
|
+
function be(e, t) {
|
|
170
28
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
171
29
|
}
|
|
172
|
-
function
|
|
173
|
-
|
|
30
|
+
function xe(e, t, n) {
|
|
31
|
+
if (n.length === 0) return e;
|
|
32
|
+
let r = new Set(e), i = _(r, n).all ? h(r, n) : g(r, n), a = new Set(t);
|
|
33
|
+
return [...Array.from(i).filter((e) => !a.has(e)), ...t.filter((e) => i.has(e))];
|
|
34
|
+
}
|
|
35
|
+
function Se({ key: e, node: t }) {
|
|
36
|
+
return /* @__PURE__ */ I(F.Fragment, { children: t }, e);
|
|
174
37
|
}
|
|
175
|
-
function
|
|
176
|
-
return
|
|
38
|
+
function Ce(e) {
|
|
39
|
+
return t(e).filter(({ node: e }) => F.isValidElement(e)).length;
|
|
177
40
|
}
|
|
178
|
-
function
|
|
179
|
-
|
|
41
|
+
function R(e) {
|
|
42
|
+
return i("DataGrid", e.columnId, e.id, "columns[].id", "columns[].columnId");
|
|
180
43
|
}
|
|
181
|
-
|
|
44
|
+
function we(e) {
|
|
45
|
+
o(`DataGrid:duplicate-rowId:${e}`, `DataGrid: several rows share the rowId "${e}". Row ids must be unique within a DataGrid; rows with the same rowId are selected and deselected together.`);
|
|
46
|
+
}
|
|
47
|
+
var Te = {
|
|
182
48
|
brand: "hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none",
|
|
183
49
|
neutral: "hover:bg-subtle-hover data-[selected]:bg-subtle-selected transition-colors motion-reduce:transition-none",
|
|
184
50
|
none: "hover:bg-subtle-hover transition-colors motion-reduce:transition-none"
|
|
185
51
|
};
|
|
186
|
-
function
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
!
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
ye ? s("DataGrid:mixed-sort", "DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.") : X && s("DataGrid:items-deprecated-sort", "DataGrid: the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection` do not apply to a grid with `items` and are ignored. Pass `sort` or `defaultSort`.");
|
|
197
|
-
}, [ye, X]), T.useEffect(() => {
|
|
198
|
-
W && (p !== void 0 && h === void 0 ? s("DataGrid:sortColumn-without-sortDirection", "DataGrid: `sortColumn` is controlled but `sortDirection` is not (mixed control). The direction is kept internally and toggles on repeated clicks, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both.") : h !== void 0 && p === void 0 && s("DataGrid:sortDirection-without-sortColumn", "DataGrid: `sortDirection` is controlled but `sortColumn` is not (mixed control). The column is kept internally and follows the clicked header, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both."));
|
|
52
|
+
function z(r) {
|
|
53
|
+
let { items: c, getRowId: l, isSelectionDisabled: d, sort: f, defaultSort: h, sortColumn: g, defaultSortColumn: _, sortDirection: y, defaultSortDirection: b, onSortChange: ne, selectionMode: x = "none", selectedItems: re, defaultSelectedItems: S, onSelectedItemsChange: C, selectedKeys: oe, defaultSelectedKeys: le, onSelectionChange: k, labels: A, selectOnRowClick: j = !1, selectionAppearance: ge = "brand", subtleSelection: N = !1, columns: P, resizableColumns: _e = !1, columnSizingOptions: we, columnWidths: Te, defaultColumnWidths: z, onColumnWidthsChange: B, virtualWindow: U, containerProps: W, children: G, className: De, style: Oe, onKeyDown: ke, onFocus: Ae, onBlur: je, onPointerDownCapture: Me, ref: Ne, ...Pe } = r, K = c !== void 0, Fe = f !== void 0 || h !== void 0, q = !Fe && !K, [Ie, Le] = F.useState(!q);
|
|
54
|
+
!q && !Ie && Le(!0);
|
|
55
|
+
let Re = Ie || !q, ze = g !== void 0 || y !== void 0;
|
|
56
|
+
g !== void 0 && a("DataGrid", "sortColumn", "sort"), y !== void 0 && a("DataGrid", "sortDirection", "sort"), _ !== void 0 && a("DataGrid", "defaultSortColumn", "defaultSort"), b !== void 0 && a("DataGrid", "defaultSortDirection", "defaultSort");
|
|
57
|
+
let Be = ze || _ !== void 0 || b !== void 0, Ve = Fe && Be, He = !q && !Fe && Be;
|
|
58
|
+
F.useEffect(() => {
|
|
59
|
+
Ve ? o("DataGrid:mixed-sort", "DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.") : He && o("DataGrid:items-deprecated-sort", "DataGrid: the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection` do not apply to a grid with `items` and are ignored. Pass `sort` or `defaultSort`.");
|
|
60
|
+
}, [Ve, He]), F.useEffect(() => {
|
|
61
|
+
q && (g !== void 0 && y === void 0 ? o("DataGrid:sortColumn-without-sortDirection", "DataGrid: `sortColumn` is controlled but `sortDirection` is not (mixed control). The direction is kept internally and toggles on repeated clicks, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both.") : y !== void 0 && g === void 0 && o("DataGrid:sortDirection-without-sortColumn", "DataGrid: `sortDirection` is controlled but `sortColumn` is not (mixed control). The column is kept internally and follows the clicked header, as in 0.4. Pass `sort` (`{ columnId, direction }`) to control both."));
|
|
199
62
|
}, [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
63
|
+
q,
|
|
64
|
+
g,
|
|
65
|
+
y
|
|
203
66
|
]);
|
|
204
|
-
let [
|
|
205
|
-
column:
|
|
67
|
+
let [Ue, We] = F.useState(() => ({
|
|
68
|
+
column: _ ?? "",
|
|
206
69
|
direction: b ?? "ascending"
|
|
207
|
-
})),
|
|
208
|
-
if (
|
|
209
|
-
let e =
|
|
70
|
+
})), Ge = F.useMemo(() => {
|
|
71
|
+
if (g === void 0 && y === void 0) return;
|
|
72
|
+
let e = g ?? Ue.column;
|
|
210
73
|
return e === "" ? null : {
|
|
211
74
|
columnId: e,
|
|
212
|
-
direction:
|
|
75
|
+
direction: y ?? Ue.direction
|
|
213
76
|
};
|
|
214
77
|
}, [
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
]),
|
|
219
|
-
columnId:
|
|
78
|
+
g,
|
|
79
|
+
y,
|
|
80
|
+
Ue
|
|
81
|
+
]), Ke = F.useMemo(() => _ ? {
|
|
82
|
+
columnId: _,
|
|
220
83
|
direction: b ?? "ascending"
|
|
221
|
-
} : null, [
|
|
222
|
-
|
|
223
|
-
let
|
|
224
|
-
e && (
|
|
84
|
+
} : null, [_, b]), qe = q ? Ge : f, Je = Ke;
|
|
85
|
+
h === void 0 ? He && (Je = null) : Je = h;
|
|
86
|
+
let Ye = F.useRef(void 0), [Xe, Ze] = p(qe, Je, (e) => {
|
|
87
|
+
e && (q && We((t) => t.column === e.columnId && t.direction === e.direction ? t : {
|
|
225
88
|
column: e.columnId,
|
|
226
89
|
direction: e.direction
|
|
227
|
-
}),
|
|
228
|
-
}),
|
|
229
|
-
|
|
90
|
+
}), ne && (Re ? ne(e, Ye.current) : ne(e.columnId, e.direction)));
|
|
91
|
+
}), Qe = F.useCallback((e, t) => {
|
|
92
|
+
Ye.current = { event: t };
|
|
230
93
|
try {
|
|
231
|
-
|
|
94
|
+
Ze((t) => ({
|
|
232
95
|
columnId: e,
|
|
233
96
|
direction: t?.columnId === e && t.direction === "ascending" ? "descending" : "ascending"
|
|
234
97
|
}));
|
|
235
98
|
} finally {
|
|
236
|
-
|
|
99
|
+
Ye.current = void 0;
|
|
237
100
|
}
|
|
238
|
-
}, [
|
|
239
|
-
sort:
|
|
240
|
-
requestSort:
|
|
241
|
-
}), [
|
|
242
|
-
|
|
243
|
-
let
|
|
244
|
-
|
|
245
|
-
}),
|
|
246
|
-
|
|
101
|
+
}, [Ze]), $e = F.useMemo(() => ({
|
|
102
|
+
sort: Xe,
|
|
103
|
+
requestSort: Qe
|
|
104
|
+
}), [Xe, Qe]);
|
|
105
|
+
k !== void 0 && a("DataGrid", "onSelectionChange", "onSelectedItemsChange");
|
|
106
|
+
let et = F.useMemo(() => L(oe), [oe]), tt = F.useMemo(() => L(le), [le]), nt = i("DataGrid", re, et, "selectedKeys", "selectedItems"), rt = i("DataGrid", S, tt, "defaultSelectedKeys", "defaultSelectedItems") ?? ve, it = F.useRef(void 0), [at, ot] = p(nt, rt, (e) => {
|
|
107
|
+
C?.([...e], it.current), k?.(new Set(e));
|
|
108
|
+
}), st = F.useCallback((e, t) => {
|
|
109
|
+
it.current = { event: e };
|
|
247
110
|
try {
|
|
248
|
-
|
|
111
|
+
ot(t);
|
|
249
112
|
} finally {
|
|
250
|
-
|
|
113
|
+
it.current = void 0;
|
|
251
114
|
}
|
|
252
|
-
}, [
|
|
253
|
-
|
|
254
|
-
$.setSelected(Ie);
|
|
255
|
-
}, [$, Ie]), T.useLayoutEffect(() => {
|
|
256
|
-
$.setSingleMode(Q);
|
|
257
|
-
}, [$, Q]);
|
|
258
|
-
let ze = T.useCallback((e, t) => {
|
|
259
|
-
Re(t, (t) => {
|
|
260
|
-
let n = $.prune(t), r;
|
|
261
|
-
return r = Q ? n[0] === e ? [] : [e] : n.includes(e) ? n.filter((t) => t !== e) : [...n, e], fe(r, t) ? t : r;
|
|
262
|
-
});
|
|
263
|
-
}, [
|
|
264
|
-
Q,
|
|
265
|
-
Re,
|
|
266
|
-
$
|
|
267
|
-
]), Be = Ie.length;
|
|
268
|
-
T.useEffect(() => {
|
|
269
|
-
Q && Be > 1 && s("DataGrid:single-several-selected", `DataGrid: a single-selection grid (selectionMode "single") has ${Be} selected row ids; only the first one that is rendered is selected. Pass at most one id in \`selectedItems\`/\`defaultSelectedItems\`, or use selectionMode="multiple".`);
|
|
270
|
-
}, [Q, Be]);
|
|
271
|
-
let Ve = T.useCallback((e) => {
|
|
272
|
-
Re(e, (e) => {
|
|
273
|
-
let t = new Set($.prune(e)), n = $.getRegistered(), r = n.filter((e) => !$.isDisabled(e)), i = r.length > 0 && r.every((e) => t.has(e)) ? n.filter((e) => $.isDisabled(e) && t.has(e)) : n.filter((e) => !$.isDisabled(e) || t.has(e));
|
|
274
|
-
return fe(i, e) ? e : i;
|
|
275
|
-
});
|
|
276
|
-
}, [Re, $]), He = _("wave-datagrid-selection"), Ue = ie?.selectAll ?? D, We = ie?.selectionHeader ?? O, Ge = T.useMemo(() => ({
|
|
277
|
-
selectionMode: S,
|
|
278
|
-
store: $,
|
|
279
|
-
toggleRow: ze,
|
|
280
|
-
toggleAll: Ve,
|
|
281
|
-
radioName: He,
|
|
282
|
-
selectAllLabel: Ue,
|
|
283
|
-
selectionHeaderLabel: We,
|
|
284
|
-
selectOnRowClick: A,
|
|
285
|
-
selectionAppearance: N,
|
|
286
|
-
subtleSelection: P
|
|
287
|
-
}), [
|
|
288
|
-
S,
|
|
289
|
-
$,
|
|
290
|
-
ze,
|
|
291
|
-
Ve,
|
|
292
|
-
He,
|
|
293
|
-
Ue,
|
|
294
|
-
We,
|
|
295
|
-
A,
|
|
296
|
-
N,
|
|
297
|
-
P
|
|
298
|
-
]), { gridRef: Ke, gridProps: qe } = y(), Je = v(me, Ke), Ye = T.useMemo(() => {
|
|
299
|
-
if (i === void 0) return null;
|
|
115
|
+
}, [ot]), J = F.useMemo(() => {
|
|
116
|
+
if (c === void 0) return null;
|
|
300
117
|
let e = /* @__PURE__ */ new Set();
|
|
301
|
-
return
|
|
118
|
+
return c.map((t, n) => {
|
|
302
119
|
let r = l ? l(t) : String(n), i = e.has(r) ? `${r}\u0000${n}` : r;
|
|
303
120
|
return e.add(i), {
|
|
304
121
|
item: t,
|
|
@@ -307,79 +124,221 @@ function W(r) {
|
|
|
307
124
|
key: i
|
|
308
125
|
};
|
|
309
126
|
});
|
|
310
|
-
}, [
|
|
311
|
-
|
|
127
|
+
}, [c, l]), ct = x !== "none", lt = F.useMemo(() => J === null || !d || !ct ? null : J.map((e) => d(e.item, e.index)), [
|
|
128
|
+
J,
|
|
129
|
+
d,
|
|
130
|
+
ct
|
|
131
|
+
]), ut = F.useMemo(() => {
|
|
132
|
+
if (J === null || !ct) return null;
|
|
133
|
+
let e = /* @__PURE__ */ new Set();
|
|
134
|
+
if (lt) for (let t of J) lt[t.index] && e.add(t.rowId);
|
|
135
|
+
return {
|
|
136
|
+
ids: J.map((e) => e.rowId),
|
|
137
|
+
disabled: e
|
|
138
|
+
};
|
|
139
|
+
}, [
|
|
140
|
+
J,
|
|
141
|
+
lt,
|
|
142
|
+
ct
|
|
143
|
+
]), Y = x === "single", [X] = F.useState(() => O(at, Y, ut));
|
|
144
|
+
F.useLayoutEffect(() => {
|
|
145
|
+
X.setUniverse(ut);
|
|
146
|
+
}, [X, ut]), F.useLayoutEffect(() => {
|
|
147
|
+
X.setSelected(at);
|
|
148
|
+
}, [X, at]), F.useLayoutEffect(() => {
|
|
149
|
+
X.setSingleMode(Y);
|
|
150
|
+
}, [X, Y]);
|
|
151
|
+
let dt = F.useCallback((e, t) => {
|
|
152
|
+
st(t, (t) => {
|
|
153
|
+
let n;
|
|
154
|
+
if (K) {
|
|
155
|
+
let r = new Set(Y ? t.slice(0, 1) : t);
|
|
156
|
+
n = Array.from(v(r, e, Y ? "single" : "multiple", { allowEmpty: !0 }));
|
|
157
|
+
} else {
|
|
158
|
+
let r = X.prune(t);
|
|
159
|
+
n = Y ? r[0] === e ? [] : [e] : r.includes(e) ? r.filter((t) => t !== e) : [...r, e];
|
|
160
|
+
}
|
|
161
|
+
return be(n, t) ? t : n;
|
|
162
|
+
});
|
|
312
163
|
}, [
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
164
|
+
K,
|
|
165
|
+
Y,
|
|
166
|
+
st,
|
|
167
|
+
X
|
|
168
|
+
]), ft = at.length;
|
|
169
|
+
F.useEffect(() => {
|
|
170
|
+
Y && ft > 1 && o("DataGrid:single-several-selected", `DataGrid: a single-selection grid (selectionMode "single") has ${ft} selected row ids; only ${K ? "the first one" : "the first one that is rendered"} is selected. Pass at most one id in \`selectedItems\`/\`defaultSelectedItems\`, or use selectionMode="multiple".`);
|
|
320
171
|
}, [
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
])
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
172
|
+
Y,
|
|
173
|
+
ft,
|
|
174
|
+
K
|
|
175
|
+
]);
|
|
176
|
+
let pt = F.useCallback((e) => {
|
|
177
|
+
st(e, (e) => {
|
|
178
|
+
let t;
|
|
179
|
+
if (K) t = xe(e, X.getUniverseIds(), X.getSelectableIds());
|
|
180
|
+
else {
|
|
181
|
+
let n = new Set(X.prune(e)), r = X.getRegistered(), i = r.filter((e) => !X.isDisabled(e));
|
|
182
|
+
t = i.length > 0 && i.every((e) => n.has(e)) ? r.filter((e) => X.isDisabled(e) && n.has(e)) : r.filter((e) => !X.isDisabled(e) || n.has(e));
|
|
183
|
+
}
|
|
184
|
+
return be(t, e) ? e : t;
|
|
185
|
+
});
|
|
186
|
+
}, [
|
|
187
|
+
K,
|
|
188
|
+
st,
|
|
189
|
+
X
|
|
190
|
+
]), mt = ee("wave-datagrid-selection"), ht = A?.selectAll ?? "Select all rows", gt = A?.selectionHeader ?? "Selection", _t = F.useMemo(() => ({
|
|
191
|
+
selectionMode: x,
|
|
192
|
+
store: X,
|
|
193
|
+
toggleRow: dt,
|
|
194
|
+
toggleAll: pt,
|
|
195
|
+
radioName: mt,
|
|
196
|
+
selectAllLabel: ht,
|
|
197
|
+
selectionHeaderLabel: gt,
|
|
198
|
+
selectOnRowClick: j,
|
|
199
|
+
selectionAppearance: ge,
|
|
200
|
+
subtleSelection: N
|
|
201
|
+
}), [
|
|
202
|
+
x,
|
|
203
|
+
X,
|
|
204
|
+
dt,
|
|
205
|
+
pt,
|
|
206
|
+
mt,
|
|
207
|
+
ht,
|
|
208
|
+
gt,
|
|
209
|
+
j,
|
|
210
|
+
ge,
|
|
211
|
+
N
|
|
212
|
+
]), vt = Xe?.columnId, yt = Xe?.direction, bt = F.useMemo(() => {
|
|
213
|
+
if (K && vt !== void 0 && P) return P.find((e) => R(e) === vt)?.compare;
|
|
214
|
+
}, [
|
|
215
|
+
K,
|
|
216
|
+
vt,
|
|
217
|
+
P
|
|
218
|
+
]), xt = F.useMemo(() => {
|
|
219
|
+
if (J === null || !bt) return J;
|
|
220
|
+
let e = bt;
|
|
221
|
+
return J.slice().sort(yt === "descending" ? (t, n) => -e(t.item, n.item) : (t, n) => e(t.item, n.item));
|
|
222
|
+
}, [
|
|
223
|
+
J,
|
|
224
|
+
bt,
|
|
225
|
+
yt
|
|
226
|
+
]), St = F.useMemo(() => {
|
|
227
|
+
if (!P || !K) return null;
|
|
228
|
+
let e = P.map((e, t) => R(e) ?? t);
|
|
229
|
+
return (t) => /* @__PURE__ */ I(H, { children: P.map((n, r) => /* @__PURE__ */ I(Ee, { children: n.renderCell?.(t) }, e[r])) });
|
|
230
|
+
}, [P, K]), Ct = F.useMemo(() => ({
|
|
231
|
+
rows: xt,
|
|
232
|
+
renderColumnsRow: St,
|
|
233
|
+
selectionDisabled: lt
|
|
234
|
+
}), [
|
|
235
|
+
xt,
|
|
236
|
+
St,
|
|
237
|
+
lt
|
|
238
|
+
]), wt = P?.some((e) => e.columnId === void 0 && e.id === void 0) ?? !1;
|
|
239
|
+
F.useEffect(() => {
|
|
240
|
+
wt && o("DataGrid:column-without-columnId", "DataGrid: a column in `columns` has no `columnId` (nor the deprecated `id`), so its header cannot sort. Give every column a unique `columnId`.");
|
|
241
|
+
}, [wt]);
|
|
242
|
+
let Tt = P ? t(G) : [], Et = (e) => Tt.find(({ node: t }) => n(t, e))?.node, Dt = Et(M), Ot = Et(V), kt = n(Ot, V) ? Ot.props.children : void 0, At = U !== void 0 && K && P !== void 0 && (kt === void 0 || typeof kt == "function") ? U : null, Z = At !== null, jt = n(Dt, M) ? Ce(Dt.props.children) : 1, Mt = c?.length ?? 0, { gridRef: Nt, gridProps: Pt, activeRowIndex: Ft, pendingRowIndex: It } = te({ model: D(At, Mt, jt) }), Q = se({
|
|
243
|
+
virtualWindow: At,
|
|
244
|
+
ignored: U !== void 0 && !Z,
|
|
245
|
+
rows: xt,
|
|
246
|
+
headerRowCount: jt,
|
|
247
|
+
columnCount: (P?.length ?? 0) + +!!ct,
|
|
248
|
+
activeRowIndex: Ft,
|
|
249
|
+
pendingRowIndex: It
|
|
250
|
+
}), Lt = m(Ne, Nt, Q.tableRef), Rt = (e) => {
|
|
251
|
+
Pt.onFocus(e), Q.onFocus(e);
|
|
252
|
+
}, zt = (e) => {
|
|
253
|
+
Pt.onBlur(e), Q.onBlur(e);
|
|
254
|
+
}, Bt = _e || we !== void 0 || Te !== void 0 || z !== void 0, Vt = Bt && !(P && K);
|
|
255
|
+
F.useEffect(() => {
|
|
256
|
+
Vt && o("DataGrid:resizable-columns-require-columns", "DataGrid: `resizableColumns`, `columnSizingOptions`, `columnWidths` and `defaultColumnWidths` need the `columns` prop together with `items`, and are ignored without them. Render the grid from `items` and `columns`.");
|
|
257
|
+
}, [Vt]);
|
|
258
|
+
let Ht = Bt && !Vt || Z, Ut = F.useMemo(() => Ht && P ? P.map(R) : ye, [Ht, P]), $ = ae({
|
|
259
|
+
enabled: Ht,
|
|
260
|
+
resizable: _e,
|
|
261
|
+
columnIds: Ut,
|
|
262
|
+
selectionColumn: x !== "none",
|
|
263
|
+
columnSizingOptions: we,
|
|
264
|
+
columnWidths: Te,
|
|
265
|
+
defaultColumnWidths: z,
|
|
266
|
+
onColumnWidthsChange: B,
|
|
267
|
+
resizeColumnLabel: A?.resizeColumn,
|
|
268
|
+
columnWidthText: A?.columnWidth
|
|
269
|
+
}), Wt = G, Gt = P && Dt === void 0 ? /* @__PURE__ */ I(M, { children: /* @__PURE__ */ I("tr", { children: P.map((e, t) => {
|
|
270
|
+
let n = R(e);
|
|
271
|
+
return /* @__PURE__ */ I(he, {
|
|
338
272
|
columnId: n,
|
|
339
273
|
sortable: e.sortable ?? e.compare !== void 0,
|
|
340
274
|
children: e.renderHeaderCell ? e.renderHeaderCell() : e.label
|
|
341
275
|
}, n ?? t);
|
|
342
|
-
}) }) }, "wave-generated-header") : null,
|
|
343
|
-
if (
|
|
344
|
-
let e = ({ node: e }) => n(e, "caption"), t =
|
|
345
|
-
|
|
346
|
-
...
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
276
|
+
}) }) }, "wave-generated-header") : null, Kt = P && K && Ot === void 0 ? /* @__PURE__ */ I(V, {}, "wave-generated-body") : null;
|
|
277
|
+
if (Gt || Kt || $.colgroup) {
|
|
278
|
+
let e = ({ node: e }) => n(e, "caption"), t = Tt.filter((t) => !e(t)), r = Kt ? t.findIndex(({ node: e }) => n(e, "tfoot")) : -1, i = r >= 0 ? r : t.length;
|
|
279
|
+
Wt = [
|
|
280
|
+
...Tt.filter(e).map(Se),
|
|
281
|
+
$.colgroup,
|
|
282
|
+
Gt,
|
|
283
|
+
...t.slice(0, i).map(Se),
|
|
284
|
+
Kt,
|
|
285
|
+
...t.slice(i).map(Se)
|
|
351
286
|
];
|
|
352
287
|
}
|
|
353
|
-
let { className:
|
|
354
|
-
return
|
|
355
|
-
|
|
356
|
-
}, [
|
|
357
|
-
value:
|
|
358
|
-
children: /* @__PURE__ */
|
|
359
|
-
value:
|
|
360
|
-
children: /* @__PURE__ */
|
|
361
|
-
value:
|
|
362
|
-
children: /* @__PURE__ */
|
|
288
|
+
let { className: qt, "aria-label": Jt, "aria-labelledby": Yt, ref: Xt, ...Zt } = W ?? {}, Qt = m(Xt, Q.scrollerRef, At?.scrollRef), $t = Zt.role !== void 0, en = !$t && (Jt !== void 0 || Yt !== void 0);
|
|
289
|
+
return F.useEffect(() => {
|
|
290
|
+
en && o("DataGrid:container-name-without-role", "DataGrid: `containerProps[\"aria-label\"]`/`[\"aria-labelledby\"]` is ignored because the wrapper has no role. Name the grid itself (`aria-label` on DataGrid), or pass a `role` (e.g. \"region\") in `containerProps` too.");
|
|
291
|
+
}, [en]), /* @__PURE__ */ I(ce.Provider, {
|
|
292
|
+
value: _t,
|
|
293
|
+
children: /* @__PURE__ */ I(me.Provider, {
|
|
294
|
+
value: $e,
|
|
295
|
+
children: /* @__PURE__ */ I(de.Provider, {
|
|
296
|
+
value: Ct,
|
|
297
|
+
children: /* @__PURE__ */ I(fe.Provider, {
|
|
363
298
|
value: null,
|
|
364
|
-
children: /* @__PURE__ */
|
|
299
|
+
children: /* @__PURE__ */ I(pe.Provider, {
|
|
365
300
|
value: null,
|
|
366
|
-
children: /* @__PURE__ */
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
301
|
+
children: /* @__PURE__ */ I(ue.Provider, {
|
|
302
|
+
value: void 0,
|
|
303
|
+
children: /* @__PURE__ */ I(ie.Provider, {
|
|
304
|
+
value: $.resizeContext,
|
|
305
|
+
children: /* @__PURE__ */ I(w.Provider, {
|
|
306
|
+
value: $.colgroup !== null,
|
|
307
|
+
children: /* @__PURE__ */ I("div", {
|
|
308
|
+
tabIndex: Z ? -1 : void 0,
|
|
309
|
+
...Zt,
|
|
310
|
+
ref: Qt,
|
|
311
|
+
"aria-label": $t ? Jt : void 0,
|
|
312
|
+
"aria-labelledby": $t ? Yt : void 0,
|
|
313
|
+
className: e(u.container, "overflow-x-auto rounded-md border border-border", Z && "[overflow-anchor:none]", qt),
|
|
314
|
+
children: /* @__PURE__ */ I("table", {
|
|
315
|
+
ref: Lt,
|
|
316
|
+
role: "grid",
|
|
317
|
+
"aria-multiselectable": x === "multiple" || void 0,
|
|
318
|
+
"aria-rowcount": Z ? Mt + jt : void 0,
|
|
319
|
+
"data-selection-appearance": ge,
|
|
320
|
+
"data-subtle-selection": N ? "" : void 0,
|
|
321
|
+
"data-resizing": $.resizing ? "" : void 0,
|
|
322
|
+
className: e(u.root, "w-full border-separate border-spacing-0", N && "group/grid", De),
|
|
323
|
+
style: $.tableStyle ? {
|
|
324
|
+
...$.tableStyle,
|
|
325
|
+
...Oe
|
|
326
|
+
} : Oe,
|
|
327
|
+
...Pe,
|
|
328
|
+
onKeyDown: s(ke, Pt.onKeyDown),
|
|
329
|
+
onFocus: s(Ae, Rt, { checkDefaultPrevented: !1 }),
|
|
330
|
+
onBlur: s(je, zt, { checkDefaultPrevented: !1 }),
|
|
331
|
+
onPointerDownCapture: s(Me, Q.onPointerDownCapture),
|
|
332
|
+
children: /* @__PURE__ */ I(T.Provider, {
|
|
333
|
+
value: Q.context,
|
|
334
|
+
children: /* @__PURE__ */ I(E.Provider, {
|
|
335
|
+
value: null,
|
|
336
|
+
children: Wt
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
})
|
|
340
|
+
})
|
|
341
|
+
})
|
|
383
342
|
})
|
|
384
343
|
})
|
|
385
344
|
})
|
|
@@ -388,332 +347,270 @@ function W(r) {
|
|
|
388
347
|
})
|
|
389
348
|
});
|
|
390
349
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
let
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
ref: i,
|
|
398
|
-
"data-selection-cell": "",
|
|
399
|
-
className: e(n, p.selectionCell, C, "text-start", b, d),
|
|
400
|
-
children: t === "multiple" ? /* @__PURE__ */ E(te, {
|
|
401
|
-
ref: h,
|
|
402
|
-
type: "checkbox",
|
|
403
|
-
"aria-label": g ?? (_ === void 0 ? s : void 0),
|
|
404
|
-
"aria-labelledby": _,
|
|
405
|
-
"aria-describedby": v,
|
|
406
|
-
checked: x,
|
|
407
|
-
disabled: f,
|
|
408
|
-
invisible: m,
|
|
409
|
-
subtle: l,
|
|
410
|
-
reveal: "grid",
|
|
411
|
-
onChange: (e) => o(e.nativeEvent),
|
|
412
|
-
className: p.selectAllCheckbox
|
|
413
|
-
}) : /* @__PURE__ */ E("span", {
|
|
414
|
-
className: "sr-only",
|
|
415
|
-
children: c
|
|
416
|
-
})
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
var K = {
|
|
420
|
-
subscribe: () => () => {},
|
|
421
|
-
register: () => () => {},
|
|
422
|
-
getFirst: () => null,
|
|
423
|
-
refresh: () => {}
|
|
424
|
-
};
|
|
425
|
-
function he({ selectionMode: t, initialFirst: n, stableClassName: r, cellProps: i, ref: a }) {
|
|
426
|
-
let o = T.useContext(P) ?? K, [s] = T.useState(() => ({})), c = T.useRef(null), l = v(c, a), u = T.useCallback(() => {
|
|
427
|
-
let e = o.getFirst();
|
|
428
|
-
return e === null ? n : e === s;
|
|
350
|
+
z.displayName = "DataGrid";
|
|
351
|
+
var B = F.memo(function({ item: e, index: t, rowId: n, selectionDisabled: r, render: i, position: a, ariaRowIndex: o, height: s }) {
|
|
352
|
+
let c = F.useMemo(() => a === void 0 || o === void 0 ? null : {
|
|
353
|
+
index: a,
|
|
354
|
+
ariaRowIndex: o,
|
|
355
|
+
height: s
|
|
429
356
|
}, [
|
|
357
|
+
a,
|
|
430
358
|
o,
|
|
431
|
-
s
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
let { className: m, disabled: h, invisible: g, controlRef: _, "aria-label": y, "aria-labelledby": x, "aria-describedby": S, ...ee } = i ?? {};
|
|
441
|
-
return /* @__PURE__ */ E("td", {
|
|
442
|
-
...ee,
|
|
443
|
-
ref: l,
|
|
444
|
-
"data-selection-cell": "",
|
|
445
|
-
className: e(r, p.selectionCell, C, b, m)
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
function ge(e, r) {
|
|
449
|
-
let i = !0, a = (e) => T.Children.map(e, (e) => {
|
|
450
|
-
if (n(e, T.Fragment)) return T.cloneElement(e, void 0, a(e.props.children));
|
|
451
|
-
if (!T.isValidElement(e)) return e;
|
|
452
|
-
let o = i;
|
|
453
|
-
if (i = !1, n(e, "tr")) {
|
|
454
|
-
let n = e.props.children, i = r === "none" || t(n).some(({ node: e }) => U(e)) ? null : /* @__PURE__ */ E(he, {
|
|
455
|
-
selectionMode: r,
|
|
456
|
-
initialFirst: o
|
|
457
|
-
});
|
|
458
|
-
return T.cloneElement(e, void 0, i, /* @__PURE__ */ E(F.Provider, {
|
|
459
|
-
value: o,
|
|
460
|
-
children: n
|
|
461
|
-
}));
|
|
462
|
-
}
|
|
463
|
-
return /* @__PURE__ */ E(F.Provider, {
|
|
464
|
-
value: o,
|
|
465
|
-
children: e
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
return a(e);
|
|
469
|
-
}
|
|
470
|
-
var q = ({ children: t, className: n, ref: i, ...a }) => {
|
|
471
|
-
let { selectionMode: o } = R("DataGrid.Header"), [c, l] = T.useState(null), u = v(i, l), [d] = T.useState(A), f = ge(t, o);
|
|
472
|
-
return T.useLayoutEffect(() => {
|
|
473
|
-
d.refresh();
|
|
474
|
-
}), T.useEffect(() => {
|
|
475
|
-
if (!r || !c || o === "none") return;
|
|
476
|
-
let e = Array.from(c.rows, (e) => Array.from(e.cells).filter((e) => e.hasAttribute("data-selection-cell")));
|
|
477
|
-
e.some((e, t) => e.length === 0 && c.rows[t].cells.length > 0) && s("DataGrid.Header:missing-selection-cell", "DataGrid.Header: a header row has no selection column header cell, so the header has one column fewer than the selectable rows. Render header rows as `<tr>` children of DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that another component renders."), e.some((e) => e.length > 1) && s("DataGrid.Header:several-selection-cells", "DataGrid.Header: a header row has more than one selection cell. A DataGrid.SelectionCell rendered by another component is not seen, so the row also gets the automatic cell: render DataGrid.SelectionCell as a child of the row (a Fragment is fine).");
|
|
478
|
-
}), /* @__PURE__ */ E(N.Provider, {
|
|
479
|
-
value: "header",
|
|
480
|
-
children: /* @__PURE__ */ E(P.Provider, {
|
|
481
|
-
value: d,
|
|
482
|
-
children: /* @__PURE__ */ E("thead", {
|
|
483
|
-
ref: u,
|
|
484
|
-
className: e(p.root, "bg-card", n),
|
|
485
|
-
...a,
|
|
486
|
-
children: f
|
|
359
|
+
s
|
|
360
|
+
]);
|
|
361
|
+
return /* @__PURE__ */ I(pe.Provider, {
|
|
362
|
+
value: n,
|
|
363
|
+
children: /* @__PURE__ */ I(ue.Provider, {
|
|
364
|
+
value: r,
|
|
365
|
+
children: /* @__PURE__ */ I(E.Provider, {
|
|
366
|
+
value: c,
|
|
367
|
+
children: i(e, t)
|
|
487
368
|
})
|
|
488
369
|
})
|
|
489
370
|
});
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
return /* @__PURE__ */
|
|
522
|
-
value: n,
|
|
523
|
-
children: r(e, t)
|
|
524
|
-
});
|
|
525
|
-
}), Y = ({ children: t, className: n, ref: r, ...i }) => {
|
|
526
|
-
let a = T.useContext(ae), o = a?.rows ?? null, c = typeof t == "function" && o === null;
|
|
527
|
-
T.useEffect(() => {
|
|
528
|
-
c && s("DataGrid.Body:render-without-items", "DataGrid.Body: a render function child renders one row per item of the DataGrid's `items`, which is not set, so the body has no rows.");
|
|
529
|
-
}, [c]);
|
|
530
|
-
let u = (e) => e && o?.map((t) => /* @__PURE__ */ E(_e, {
|
|
531
|
-
item: t.item,
|
|
532
|
-
index: t.index,
|
|
533
|
-
rowId: t.rowId,
|
|
534
|
-
render: e
|
|
535
|
-
}, t.key)), d;
|
|
536
|
-
return d = typeof t == "function" ? u(t) : t === void 0 ? u(a?.renderColumnsRow ?? null) : t, /* @__PURE__ */ E(N.Provider, {
|
|
371
|
+
}), V = ({ children: t, className: n, ref: r, ...i }) => {
|
|
372
|
+
let a = F.useContext(de), s = F.useContext(T), l = a?.rows ?? null, u = typeof t == "function" && l === null;
|
|
373
|
+
F.useEffect(() => {
|
|
374
|
+
u && o("DataGrid.Body:render-without-items", "DataGrid.Body: a render function child renders one row per item of the DataGrid's `items`, which is not set, so the body has no rows.");
|
|
375
|
+
}, [u]);
|
|
376
|
+
let d = a?.selectionDisabled ?? null, f = (e) => {
|
|
377
|
+
if (!e || !l) return null;
|
|
378
|
+
if (s) {
|
|
379
|
+
let { headerRowCount: t, virtualWindow: n } = s;
|
|
380
|
+
return oe(s, l.length, (r) => {
|
|
381
|
+
let i = l[r];
|
|
382
|
+
return /* @__PURE__ */ I(B, {
|
|
383
|
+
item: i.item,
|
|
384
|
+
index: i.index,
|
|
385
|
+
rowId: i.rowId,
|
|
386
|
+
selectionDisabled: d?.[i.index],
|
|
387
|
+
render: e,
|
|
388
|
+
position: r,
|
|
389
|
+
ariaRowIndex: r + t + 1,
|
|
390
|
+
height: n.itemSize
|
|
391
|
+
}, `row:${i.key}`);
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return l.map((t) => /* @__PURE__ */ I(B, {
|
|
395
|
+
item: t.item,
|
|
396
|
+
index: t.index,
|
|
397
|
+
rowId: t.rowId,
|
|
398
|
+
selectionDisabled: d?.[t.index],
|
|
399
|
+
render: e
|
|
400
|
+
}, t.key));
|
|
401
|
+
}, p;
|
|
402
|
+
return p = typeof t == "function" ? f(t) : t === void 0 ? f(a?.renderColumnsRow ?? null) : t, /* @__PURE__ */ I(k.Provider, {
|
|
537
403
|
value: "body",
|
|
538
|
-
children: /* @__PURE__ */
|
|
404
|
+
children: /* @__PURE__ */ I("tbody", {
|
|
539
405
|
ref: r,
|
|
540
|
-
className: e(
|
|
406
|
+
className: e(c.root, n),
|
|
541
407
|
...i,
|
|
542
|
-
children:
|
|
408
|
+
children: p
|
|
543
409
|
})
|
|
544
410
|
});
|
|
545
411
|
};
|
|
546
|
-
|
|
547
|
-
var
|
|
548
|
-
let { selectionMode:
|
|
549
|
-
for (let { node: e } of
|
|
550
|
-
|
|
412
|
+
V.displayName = "DataGridBody";
|
|
413
|
+
var H = ({ rowId: i, selectionLabel: a, selectionCellProps: c, children: l, className: u, style: f, onClick: p, onKeyDown: m, ref: h, ...g }) => {
|
|
414
|
+
let { selectionMode: _, store: v, toggleRow: te, selectOnRowClick: y, selectionAppearance: re } = A("DataGrid.Row"), S = F.useContext(E), C = F.useContext(pe), w = i ?? C ?? void 0, ie = F.useContext(k), ae = F.useContext(le), T = ie === "header", D = _ !== "none" && !T, oe = ee("wave-datagrid-row-label"), se = t(l), O;
|
|
415
|
+
for (let { node: e } of se) if (P(e)) {
|
|
416
|
+
O = e.props;
|
|
551
417
|
break;
|
|
552
418
|
}
|
|
553
|
-
let
|
|
419
|
+
let ce = O !== void 0, de = F.useContext(ue), me = O?.disabled ?? c?.disabled, j = me ?? de ?? !1, M = O?.invisible ?? c?.invisible ?? !1, he = O?.["aria-labelledby"], N = O?.["aria-label"] ?? c?.["aria-label"] ?? a, ve = _ === "single", ye = F.useCallback(() => w !== void 0 && v.isSelected(w, ve), [
|
|
554
420
|
w,
|
|
555
421
|
v,
|
|
556
|
-
|
|
557
|
-
]),
|
|
558
|
-
|
|
559
|
-
if (w === void 0 ||
|
|
422
|
+
ve
|
|
423
|
+
]), L = F.useSyncExternalStore(v.subscribe, ye, ye);
|
|
424
|
+
F.useLayoutEffect(() => {
|
|
425
|
+
if (w === void 0 || T) return;
|
|
560
426
|
let e = v.register(w);
|
|
561
|
-
return r && v.countRegistrations(w) > 1 &&
|
|
427
|
+
return r && v.countRegistrations(w) > 1 && we(w), e;
|
|
562
428
|
}, [
|
|
563
429
|
v,
|
|
564
430
|
w,
|
|
565
|
-
|
|
566
|
-
]),
|
|
567
|
-
if (w !== void 0 && !
|
|
431
|
+
T
|
|
432
|
+
]), F.useLayoutEffect(() => {
|
|
433
|
+
if (w !== void 0 && !T && j) return v.disable(w);
|
|
568
434
|
}, [
|
|
569
435
|
v,
|
|
570
436
|
w,
|
|
437
|
+
T,
|
|
438
|
+
j
|
|
439
|
+
]), F.useEffect(() => {
|
|
440
|
+
D && w === void 0 && o("DataGrid.Row:missing-rowId", "DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.");
|
|
441
|
+
}, [D, w]);
|
|
442
|
+
let be = D && w !== void 0 && de !== void 0 && me !== void 0 && me !== de;
|
|
443
|
+
F.useEffect(() => {
|
|
444
|
+
if (!be) return;
|
|
445
|
+
let e = (e) => e ? "disabled" : "enabled";
|
|
446
|
+
o("DataGrid:selection-disabled-mismatch", `DataGrid: the selection cell of row "${w}" is ${e(j)} (\`DataGrid.SelectionCell disabled\` or \`selectionCellProps.disabled\`), but \`isSelectionDisabled\` says its item is ${e(!j)}. Select-all skips a row that either one disables, and the row's control follows its cell: make them agree, or leave the cell's \`disabled\` unset to take it from \`isSelectionDisabled\`.`);
|
|
447
|
+
}, [
|
|
448
|
+
be,
|
|
449
|
+
w,
|
|
450
|
+
j
|
|
451
|
+
]);
|
|
452
|
+
let xe = D && i !== void 0 && C !== null && i !== C;
|
|
453
|
+
F.useEffect(() => {
|
|
454
|
+
xe ? o("DataGrid.Row:row-id-mismatch", "DataGrid.Row: a row rendered from the grid's `items` sets its own `rowId`, which differs from its item's id (`getRowId`, by default the item's index). Select-all and its checkbox use the ids from `getRowId`, so the row is outside them and select-all selects ids that no row has. Pass a `getRowId` that returns the row's id, and leave out `rowId`.") : D && w !== void 0 && C === null && v.isOutsideUniverse(w) && o("DataGrid.Row:row-id-outside-items", "DataGrid.Row: a selectable row in a grid with `items` has a `rowId` that is no item's id (`getRowId`, by default the item's index). Select-all and its checkbox use the ids of `items`, so the row is outside them. Render the rows from `items` (a `DataGrid.Body` render function, or `columns`) with a `getRowId` that returns their ids.");
|
|
455
|
+
}, [
|
|
456
|
+
xe,
|
|
571
457
|
D,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
let
|
|
577
|
-
if (!
|
|
458
|
+
w,
|
|
459
|
+
C,
|
|
460
|
+
v
|
|
461
|
+
]);
|
|
462
|
+
let Ce = D && w !== void 0 && N === void 0 && he === void 0, R = (e) => {
|
|
463
|
+
if (!D || w === void 0 || e.key !== " ") return;
|
|
578
464
|
let t = e.target;
|
|
579
|
-
(t === e.currentTarget || t.parentElement === e.currentTarget) && (e.preventDefault(),
|
|
580
|
-
},
|
|
581
|
-
if (!
|
|
465
|
+
(t === e.currentTarget || t.parentElement === e.currentTarget) && (e.preventDefault(), j || te(w, e.nativeEvent));
|
|
466
|
+
}, z = (e) => {
|
|
467
|
+
if (!y || !D || w === void 0 || j) return;
|
|
582
468
|
let t = e.currentTarget;
|
|
583
|
-
|
|
469
|
+
x(e, { isOwnPart: (e) => e.parentElement === t }) || ne(e) || te(w, e.nativeEvent);
|
|
584
470
|
}, B, V = -1;
|
|
585
|
-
if (
|
|
586
|
-
let e =
|
|
471
|
+
if (Ce) {
|
|
472
|
+
let e = se.findIndex(({ node: e }) => n(e, Ee, "td", "th"));
|
|
587
473
|
if (e >= 0) {
|
|
588
|
-
let t =
|
|
589
|
-
B = t.props.id ??
|
|
474
|
+
let t = se[e].node;
|
|
475
|
+
B = t.props.id ?? oe, t.props.id === void 0 && (V = e);
|
|
590
476
|
}
|
|
591
477
|
}
|
|
592
|
-
let
|
|
478
|
+
let H = se.map(({ key: e, node: t }, n) => Se({
|
|
593
479
|
key: e,
|
|
594
|
-
node: n === V ?
|
|
595
|
-
})),
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}, [
|
|
599
|
-
let
|
|
600
|
-
selectionCellProps:
|
|
601
|
-
hasSelectionCell:
|
|
602
|
-
rowId:
|
|
603
|
-
isSelected:
|
|
604
|
-
disabled:
|
|
605
|
-
invisible:
|
|
606
|
-
ariaLabel:
|
|
607
|
-
ariaLabelledBy:
|
|
480
|
+
node: n === V ? F.cloneElement(t, { id: oe }) : t
|
|
481
|
+
})), W = Ce && B === void 0;
|
|
482
|
+
F.useEffect(() => {
|
|
483
|
+
W && o("DataGrid.Row:selection-label", "DataGrid.Row: no child is a `DataGrid.Cell`, `<td>` or `<th>` element, so the row selection control is named \"Select row\". Pass `selectionLabel` (a cell rendered by another component is not seen).");
|
|
484
|
+
}, [W]);
|
|
485
|
+
let G = he ?? B, De = N ?? (G === void 0 ? "Select row" : void 0), Oe = F.useMemo(() => ({
|
|
486
|
+
selectionCellProps: c,
|
|
487
|
+
hasSelectionCell: ce,
|
|
488
|
+
rowId: D ? w : void 0,
|
|
489
|
+
isSelected: L,
|
|
490
|
+
disabled: j,
|
|
491
|
+
invisible: M,
|
|
492
|
+
ariaLabel: De,
|
|
493
|
+
ariaLabelledBy: G
|
|
608
494
|
}), [
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
495
|
+
c,
|
|
496
|
+
ce,
|
|
497
|
+
D,
|
|
612
498
|
w,
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
]),
|
|
619
|
-
return !
|
|
620
|
-
selectionMode:
|
|
621
|
-
initialFirst:
|
|
622
|
-
cellProps:
|
|
623
|
-
}) : !
|
|
624
|
-
value:
|
|
625
|
-
children: /* @__PURE__ */
|
|
626
|
-
ref:
|
|
627
|
-
className: e(
|
|
628
|
-
"aria-selected":
|
|
629
|
-
"data-selected":
|
|
630
|
-
...
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
499
|
+
L,
|
|
500
|
+
j,
|
|
501
|
+
M,
|
|
502
|
+
De,
|
|
503
|
+
G
|
|
504
|
+
]), ke = null;
|
|
505
|
+
return !ce && T && _ !== "none" ? ke = /* @__PURE__ */ I(ge, {
|
|
506
|
+
selectionMode: _,
|
|
507
|
+
initialFirst: ae,
|
|
508
|
+
cellProps: c
|
|
509
|
+
}) : !ce && D && (ke = /* @__PURE__ */ I(U, { component: "DataGrid.Row" })), /* @__PURE__ */ I(fe.Provider, {
|
|
510
|
+
value: Oe,
|
|
511
|
+
children: /* @__PURE__ */ _e("tr", {
|
|
512
|
+
ref: h,
|
|
513
|
+
className: e(d.root, "group/table-row", !T && Te[re], D && L && b.selectedContainer, u),
|
|
514
|
+
"aria-selected": D ? L : void 0,
|
|
515
|
+
"data-selected": D && L ? "" : void 0,
|
|
516
|
+
...g,
|
|
517
|
+
style: S?.height === void 0 ? f : {
|
|
518
|
+
...f,
|
|
519
|
+
height: S.height
|
|
520
|
+
},
|
|
521
|
+
...S && {
|
|
522
|
+
"aria-rowindex": S.ariaRowIndex,
|
|
523
|
+
"data-row-index": S.index
|
|
524
|
+
},
|
|
525
|
+
onClick: s(p, z),
|
|
526
|
+
onKeyDown: s(m, R),
|
|
527
|
+
children: [ke, H]
|
|
634
528
|
})
|
|
635
529
|
});
|
|
636
530
|
};
|
|
637
|
-
|
|
638
|
-
function
|
|
639
|
-
let { selectionMode: c, toggleRow: l, radioName: u, subtleSelection:
|
|
640
|
-
return /* @__PURE__ */
|
|
531
|
+
H.displayName = "DataGridRow";
|
|
532
|
+
function U({ component: t, stableClassName: n, className: r, controlRef: i, "aria-describedby": a, ref: o, ...s }) {
|
|
533
|
+
let { selectionMode: c, toggleRow: l, radioName: u, subtleSelection: f } = A(t), p = j(t), ee = F.useContext(E)?.index !== void 0, { rowId: m } = p, h = c === "single";
|
|
534
|
+
return /* @__PURE__ */ I("td", {
|
|
641
535
|
role: "gridcell",
|
|
642
536
|
...s,
|
|
643
537
|
ref: o,
|
|
644
538
|
"data-selection-cell": "",
|
|
645
|
-
className: e(n,
|
|
646
|
-
children:
|
|
539
|
+
className: e(n, d.selectionCell, re, ee && "py-0 align-middle", y, p.selectionCellProps?.className, r),
|
|
540
|
+
children: m !== void 0 && c !== "none" && /* @__PURE__ */ I(S, {
|
|
647
541
|
ref: i,
|
|
648
542
|
type: h ? "radio" : "checkbox",
|
|
649
543
|
name: h ? u : void 0,
|
|
650
544
|
form: h ? "" : void 0,
|
|
651
|
-
checked:
|
|
652
|
-
disabled:
|
|
653
|
-
invisible:
|
|
654
|
-
subtle:
|
|
655
|
-
onChange: (e) => l(
|
|
656
|
-
"aria-label":
|
|
657
|
-
"aria-labelledby":
|
|
545
|
+
checked: p.isSelected,
|
|
546
|
+
disabled: p.disabled,
|
|
547
|
+
invisible: p.invisible,
|
|
548
|
+
subtle: f,
|
|
549
|
+
onChange: (e) => l(m, e.nativeEvent),
|
|
550
|
+
"aria-label": p.ariaLabel,
|
|
551
|
+
"aria-labelledby": p.ariaLabelledBy,
|
|
658
552
|
"aria-describedby": a,
|
|
659
|
-
className:
|
|
553
|
+
className: d.selectionControl
|
|
660
554
|
})
|
|
661
555
|
});
|
|
662
556
|
}
|
|
663
|
-
var
|
|
664
|
-
let { selectionMode: d } =
|
|
665
|
-
if (
|
|
666
|
-
|
|
667
|
-
}, [
|
|
668
|
-
|
|
669
|
-
}, [
|
|
670
|
-
if (
|
|
671
|
-
let
|
|
672
|
-
return /* @__PURE__ */
|
|
557
|
+
var W = ({ disabled: t, invisible: n, className: r, "aria-label": i, "aria-labelledby": a, "aria-describedby": s, controlRef: c, ref: l, ...u }) => {
|
|
558
|
+
let { selectionMode: d } = A("DataGrid.SelectionCell"), p = F.useContext(k), ee = F.useContext(le), m = F.useContext(fe), h = d === "none", g = !h && m !== null && !m.hasSelectionCell;
|
|
559
|
+
if (F.useEffect(() => {
|
|
560
|
+
h && o("DataGrid.SelectionCell:not-selectable", "DataGrid.SelectionCell: the grid has no row selection (`selectionMode` is \"none\"), so the cell renders nothing. Set `selectionMode` on the DataGrid, or remove the cell.");
|
|
561
|
+
}, [h]), F.useEffect(() => {
|
|
562
|
+
g && o("DataGrid.SelectionCell:unseen", "DataGrid.SelectionCell: rendered by another component, so its DataGrid.Row did not see it and added its own selection cell. Render DataGrid.SelectionCell as a child of DataGrid.Row (a Fragment is fine).");
|
|
563
|
+
}, [g]), h) return null;
|
|
564
|
+
if (p === "header") {
|
|
565
|
+
let o = m?.selectionCellProps;
|
|
566
|
+
return /* @__PURE__ */ I(ge, {
|
|
673
567
|
ref: l,
|
|
674
568
|
selectionMode: d,
|
|
675
|
-
initialFirst:
|
|
676
|
-
stableClassName:
|
|
569
|
+
initialFirst: ee,
|
|
570
|
+
stableClassName: f.root,
|
|
677
571
|
cellProps: {
|
|
678
572
|
...u,
|
|
679
|
-
className: e(
|
|
680
|
-
disabled: t ??
|
|
681
|
-
invisible: n ??
|
|
682
|
-
"aria-label": i ??
|
|
573
|
+
className: e(o?.className, r),
|
|
574
|
+
disabled: t ?? o?.disabled,
|
|
575
|
+
invisible: n ?? o?.invisible,
|
|
576
|
+
"aria-label": i ?? o?.["aria-label"],
|
|
683
577
|
"aria-labelledby": a,
|
|
684
|
-
"aria-describedby":
|
|
578
|
+
"aria-describedby": s,
|
|
685
579
|
controlRef: c
|
|
686
580
|
}
|
|
687
581
|
});
|
|
688
582
|
}
|
|
689
|
-
return /* @__PURE__ */
|
|
583
|
+
return /* @__PURE__ */ I(U, {
|
|
690
584
|
...u,
|
|
691
585
|
ref: l,
|
|
692
586
|
component: "DataGrid.SelectionCell",
|
|
693
|
-
stableClassName:
|
|
587
|
+
stableClassName: f.root,
|
|
694
588
|
className: r,
|
|
695
589
|
controlRef: c,
|
|
696
|
-
"aria-describedby":
|
|
590
|
+
"aria-describedby": s
|
|
697
591
|
});
|
|
698
592
|
};
|
|
699
|
-
|
|
700
|
-
var
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
593
|
+
W.displayName = "DataGridSelectionCell", C(W, "dataGridSelectionCell");
|
|
594
|
+
var Ee = ({ children: t, className: n, ref: r, ...i }) => {
|
|
595
|
+
let a = F.useContext(w), o = F.useContext(E)?.index !== void 0;
|
|
596
|
+
return /* @__PURE__ */ I("td", {
|
|
597
|
+
ref: r,
|
|
598
|
+
role: "gridcell",
|
|
599
|
+
className: e(l.root, N, "relative text-body-1", (a || o) && "overflow-hidden text-ellipsis whitespace-nowrap", o && "py-0 align-middle", y, n),
|
|
600
|
+
...i,
|
|
601
|
+
children: t
|
|
602
|
+
});
|
|
603
|
+
};
|
|
604
|
+
Ee.displayName = "DataGridCell";
|
|
605
|
+
var G = /* @__PURE__ */ Object.assign(z, {
|
|
606
|
+
Header: M,
|
|
607
|
+
HeaderCell: he,
|
|
608
|
+
Body: V,
|
|
609
|
+
Row: H,
|
|
610
|
+
Cell: Ee,
|
|
611
|
+
SelectionCell: W
|
|
715
612
|
});
|
|
716
613
|
//#endregion
|
|
717
|
-
export {
|
|
614
|
+
export { G as DataGrid, V as DataGridBody, Ee as DataGridCell, M as DataGridHeader, he as DataGridHeaderCell, H as DataGridRow, W as DataGridSelectionCell, O as createSelectionStore };
|
|
718
615
|
|
|
719
616
|
//# sourceMappingURL=DataGrid.mjs.map
|