@mortenbrudvik/waveui 0.13.0 → 0.14.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 +302 -49
- package/dist/components/data-display/Avatar.context.cjs.map +1 -1
- package/dist/components/data-display/Avatar.context.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 +245 -195
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/List.registry.cjs.map +1 -1
- package/dist/components/data-display/List.registry.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +240 -192
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Overflow.store.cjs +2 -0
- package/dist/components/layout/Overflow.store.cjs.map +1 -0
- package/dist/components/layout/Overflow.store.mjs +209 -0
- package/dist/components/layout/Overflow.store.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +239 -84
- package/dist/components/navigation/Breadcrumb.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 +19 -15
- package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.context.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.context.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.context.mjs +51 -0
- package/dist/components/overlays/TeachingPopover.context.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.mjs +15 -185
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs +398 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.mjs +150 -0
- package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs +86 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs.map +1 -0
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +540 -311
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +183 -60
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/table/Table.shared.cjs +2 -0
- package/dist/components/table/Table.shared.cjs.map +1 -0
- package/dist/components/table/Table.shared.mjs +65 -0
- package/dist/components/table/Table.shared.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1742 -158
- package/dist/index.d.ts +1742 -158
- package/dist/index.mjs +135 -132
- package/dist/lib/breadcrumb.cjs +2 -0
- package/dist/lib/breadcrumb.cjs.map +1 -0
- package/dist/lib/breadcrumb.mjs +26 -0
- package/dist/lib/breadcrumb.mjs.map +1 -0
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +66 -38
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/events.cjs +1 -1
- package/dist/lib/events.cjs.map +1 -1
- package/dist/lib/events.mjs +35 -8
- package/dist/lib/events.mjs.map +1 -1
- package/dist/lib/icons.cjs +1 -1
- package/dist/lib/icons.cjs.map +1 -1
- package/dist/lib/icons.mjs +34 -20
- package/dist/lib/icons.mjs.map +1 -1
- package/dist/lib/table.cjs +2 -0
- package/dist/lib/table.cjs.map +1 -0
- package/dist/lib/table.mjs +16 -0
- package/dist/lib/table.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -3,21 +3,23 @@ import { cn as e } from "../../lib/cn.mjs";
|
|
|
3
3
|
import { flattenChildren as t, isElementOfType as n } from "../../lib/children.mjs";
|
|
4
4
|
import { isDev as r, reportMissingContext as i, resolveDeprecatedProp as a, warnDeprecated as o, warnOnce as s } from "../../lib/dev.mjs";
|
|
5
5
|
import { composeEventHandlers as c } from "../../lib/composeEventHandlers.mjs";
|
|
6
|
-
import { dataGridBodyClassNames as l, dataGridCellClassNames as u, dataGridClassNames as d, dataGridHeaderCellClassNames as f, dataGridHeaderClassNames as p, dataGridRowClassNames as m } from "../../lib/classNames.mjs";
|
|
7
|
-
import { useControllable as
|
|
8
|
-
import { useId as
|
|
9
|
-
import { useMergedRefs as
|
|
10
|
-
import { useGridNavigation as
|
|
11
|
-
import { focusRingInset as
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
6
|
+
import { dataGridBodyClassNames as l, dataGridCellClassNames as u, dataGridClassNames as d, dataGridHeaderCellClassNames as f, dataGridHeaderClassNames as p, dataGridRowClassNames as m, dataGridSelectionCellClassNames as h } from "../../lib/classNames.mjs";
|
|
7
|
+
import { useControllable as g } from "../../hooks/useControllable.mjs";
|
|
8
|
+
import { useId as _ } from "../../hooks/useId.mjs";
|
|
9
|
+
import { useMergedRefs as v } from "../../hooks/useMergedRefs.mjs";
|
|
10
|
+
import { useGridNavigation as y } from "./useGridNavigation.mjs";
|
|
11
|
+
import { focusRingInset as b, forcedColors as x } from "../../lib/styles.mjs";
|
|
12
|
+
import { endsTextSelection as S, isForeignEvent as ee } from "../../lib/events.mjs";
|
|
13
|
+
import { SELECTION_CELL_CLASSES as C, TableSelectionControl as te, TableSortButton as w, getTablePartKind as ne, markTablePart as re } from "./Table.shared.mjs";
|
|
14
|
+
import * as T from "react";
|
|
15
|
+
import { jsx as E, jsxs as ie } from "react/jsx-runtime";
|
|
14
16
|
//#region src/components/table/DataGrid.tsx
|
|
15
|
-
var
|
|
16
|
-
function
|
|
17
|
-
let n = new Set(e), r = /* @__PURE__ */ new Map(), i =
|
|
17
|
+
var D = "Select all rows", O = "Selection";
|
|
18
|
+
function k(e, t = !1) {
|
|
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) => {
|
|
18
20
|
for (let t of Array.from(e)) t();
|
|
19
|
-
},
|
|
20
|
-
if (
|
|
21
|
+
}, p = () => {
|
|
22
|
+
if (l !== void 0) return l;
|
|
21
23
|
let e = null;
|
|
22
24
|
for (let t of n) {
|
|
23
25
|
if (r.has(t)) {
|
|
@@ -26,54 +28,67 @@ function w(e, t = !1) {
|
|
|
26
28
|
}
|
|
27
29
|
e ??= t;
|
|
28
30
|
}
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
+
return l = e, e;
|
|
32
|
+
}, m = (e) => {
|
|
31
33
|
if (n.size < 2 || !n.has(e)) return;
|
|
32
|
-
let t =
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
let e =
|
|
36
|
-
e !==
|
|
37
|
-
},
|
|
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), () => {
|
|
38
50
|
e.delete(t);
|
|
39
51
|
});
|
|
40
52
|
return {
|
|
41
|
-
subscribe:
|
|
42
|
-
subscribeSelectAll:
|
|
53
|
+
subscribe: y(u),
|
|
54
|
+
subscribeSelectAll: y(d),
|
|
43
55
|
register(e) {
|
|
44
|
-
let t = r.
|
|
45
|
-
|
|
46
|
-
let
|
|
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;
|
|
47
66
|
return () => {
|
|
48
|
-
|
|
49
|
-
a = !0;
|
|
50
|
-
let t = (r.get(e) ?? 0) - 1;
|
|
51
|
-
if (t > 0) {
|
|
52
|
-
r.set(e, t);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
r.delete(e), n.has(e) && --i, p(), f(e);
|
|
67
|
+
t || (t = !0, _(e, () => v(i, e, -1)), h());
|
|
56
68
|
};
|
|
57
69
|
},
|
|
70
|
+
isDisabled(e) {
|
|
71
|
+
return i.has(e);
|
|
72
|
+
},
|
|
58
73
|
setSelected(e) {
|
|
59
74
|
let t = new Set(e);
|
|
60
75
|
if (!(t.size === n.size && e.every((e) => n.has(e)))) {
|
|
61
|
-
n = t,
|
|
62
|
-
for (let e of t)
|
|
63
|
-
u
|
|
76
|
+
n = t, l = void 0, o = 0;
|
|
77
|
+
for (let e of t) g(e) && (o += 1);
|
|
78
|
+
f(u), h();
|
|
64
79
|
}
|
|
65
80
|
},
|
|
66
81
|
setSingleMode(e) {
|
|
67
|
-
|
|
82
|
+
c = e;
|
|
68
83
|
},
|
|
69
84
|
isSelected(e, t = !1) {
|
|
70
|
-
return t ?
|
|
85
|
+
return t ? p() === e : n.has(e);
|
|
71
86
|
},
|
|
72
87
|
countRegistrations(e) {
|
|
73
88
|
return r.get(e) ?? 0;
|
|
74
89
|
},
|
|
75
90
|
getSelectAllState() {
|
|
76
|
-
return
|
|
91
|
+
return s;
|
|
77
92
|
},
|
|
78
93
|
getRegistered() {
|
|
79
94
|
return Array.from(r.keys());
|
|
@@ -83,7 +98,7 @@ function w(e, t = !1) {
|
|
|
83
98
|
}
|
|
84
99
|
};
|
|
85
100
|
}
|
|
86
|
-
function
|
|
101
|
+
function A() {
|
|
87
102
|
let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set(), n = null, r = () => {
|
|
88
103
|
let r = null, i = null;
|
|
89
104
|
for (let [t, a] of e) {
|
|
@@ -114,245 +129,357 @@ function T() {
|
|
|
114
129
|
refresh: r
|
|
115
130
|
};
|
|
116
131
|
}
|
|
117
|
-
var
|
|
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 = {
|
|
118
133
|
selectionMode: "none",
|
|
119
|
-
store:
|
|
134
|
+
store: k([]),
|
|
120
135
|
toggleRow: () => {},
|
|
121
136
|
toggleAll: () => {},
|
|
122
137
|
radioName: "",
|
|
123
|
-
selectAllLabel:
|
|
124
|
-
selectionHeaderLabel:
|
|
125
|
-
|
|
138
|
+
selectAllLabel: D,
|
|
139
|
+
selectionHeaderLabel: O,
|
|
140
|
+
selectOnRowClick: !1,
|
|
141
|
+
selectionAppearance: "brand",
|
|
142
|
+
subtleSelection: !1
|
|
143
|
+
}, I = {
|
|
126
144
|
sort: null,
|
|
127
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
|
|
128
155
|
};
|
|
129
|
-
function
|
|
130
|
-
return
|
|
156
|
+
function R(e) {
|
|
157
|
+
return T.useContext(j) || (i(e, "DataGrid"), ce);
|
|
131
158
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
159
|
+
function le(e) {
|
|
160
|
+
return T.useContext(se) || (i(e, "DataGrid.Row"), L);
|
|
134
161
|
}
|
|
135
|
-
|
|
136
|
-
|
|
162
|
+
function z(e) {
|
|
163
|
+
return T.useContext(M) || (i(e, "DataGrid"), I);
|
|
164
|
+
}
|
|
165
|
+
var ue = [];
|
|
166
|
+
function de(e) {
|
|
137
167
|
return e === void 0 ? void 0 : Array.from(e);
|
|
138
168
|
}
|
|
139
|
-
function
|
|
169
|
+
function fe(e, t) {
|
|
140
170
|
return e.length === t.length && e.every((e, n) => e === t[n]);
|
|
141
171
|
}
|
|
142
|
-
function
|
|
143
|
-
return /* @__PURE__ */
|
|
172
|
+
function pe({ key: e, node: t }) {
|
|
173
|
+
return /* @__PURE__ */ E(T.Fragment, { children: t }, e);
|
|
174
|
+
}
|
|
175
|
+
function B(e) {
|
|
176
|
+
return a("DataGrid", e.columnId, e.id, "columns[].id", "columns[].columnId");
|
|
144
177
|
}
|
|
145
|
-
function
|
|
178
|
+
function me(e) {
|
|
146
179
|
s(`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.`);
|
|
147
180
|
}
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
181
|
+
var V = "px-4 py-3 border-b border-border", H = {
|
|
182
|
+
brand: "hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none",
|
|
183
|
+
neutral: "hover:bg-subtle-hover data-[selected]:bg-subtle-selected transition-colors motion-reduce:transition-none",
|
|
184
|
+
none: "hover:bg-subtle-hover transition-colors motion-reduce:transition-none"
|
|
185
|
+
};
|
|
186
|
+
function U(e) {
|
|
187
|
+
return ne(e) === "dataGridSelectionCell";
|
|
188
|
+
}
|
|
189
|
+
function W(r) {
|
|
190
|
+
let { items: i, getRowId: l, sort: u, defaultSort: f, sortColumn: p, defaultSortColumn: m, sortDirection: h, defaultSortDirection: b, onSortChange: x, selectionMode: S = "none", selectedItems: ee, defaultSelectedItems: C, onSelectedItemsChange: te, selectedKeys: w, defaultSelectedKeys: ne, onSelectionChange: re, labels: ie, selectOnRowClick: A = !1, selectionAppearance: N = "brand", subtleSelection: P = !1, columns: F, containerProps: ce, children: I, className: L, onKeyDown: R, onFocus: le, onBlur: z, ref: me, ...V } = r, H = i !== void 0, U = u !== void 0 || f !== void 0, W = !U && !H, [G, K] = T.useState(!W);
|
|
191
|
+
!W && !G && K(!0);
|
|
192
|
+
let he = G || !W, ge = p !== void 0 || h !== void 0;
|
|
193
|
+
p !== void 0 && o("DataGrid", "sortColumn", "sort"), h !== void 0 && o("DataGrid", "sortDirection", "sort"), m !== void 0 && o("DataGrid", "defaultSortColumn", "defaultSort"), b !== void 0 && o("DataGrid", "defaultSortDirection", "defaultSort");
|
|
194
|
+
let _e = ge || m !== void 0 || b !== void 0, ye = U && _e, X = !W && !U && _e;
|
|
195
|
+
T.useEffect(() => {
|
|
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."));
|
|
158
199
|
}, [
|
|
159
200
|
W,
|
|
160
|
-
|
|
161
|
-
|
|
201
|
+
p,
|
|
202
|
+
h
|
|
162
203
|
]);
|
|
163
|
-
let [
|
|
164
|
-
column:
|
|
165
|
-
direction:
|
|
166
|
-
})),
|
|
167
|
-
if (
|
|
168
|
-
let e =
|
|
204
|
+
let [be, xe] = T.useState(() => ({
|
|
205
|
+
column: m ?? "",
|
|
206
|
+
direction: b ?? "ascending"
|
|
207
|
+
})), Se = T.useMemo(() => {
|
|
208
|
+
if (p === void 0 && h === void 0) return;
|
|
209
|
+
let e = p ?? be.column;
|
|
169
210
|
return e === "" ? null : {
|
|
170
211
|
columnId: e,
|
|
171
|
-
direction:
|
|
212
|
+
direction: h ?? be.direction
|
|
172
213
|
};
|
|
173
214
|
}, [
|
|
174
|
-
u,
|
|
175
215
|
p,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
216
|
+
h,
|
|
217
|
+
be
|
|
218
|
+
]), Ce = T.useMemo(() => m ? {
|
|
219
|
+
columnId: m,
|
|
220
|
+
direction: b ?? "ascending"
|
|
221
|
+
} : null, [m, b]), we = W ? Se : u, Te = Ce;
|
|
222
|
+
f === void 0 ? X && (Te = null) : Te = f;
|
|
223
|
+
let Ee = T.useRef(void 0), [De, Oe] = g(we, Te, (e) => {
|
|
224
|
+
e && (W && xe((t) => t.column === e.columnId && t.direction === e.direction ? t : {
|
|
182
225
|
column: e.columnId,
|
|
183
226
|
direction: e.direction
|
|
184
|
-
}),
|
|
185
|
-
}),
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
227
|
+
}), x && (he ? x(e, Ee.current) : x(e.columnId, e.direction)));
|
|
228
|
+
}), ke = T.useCallback((e, t) => {
|
|
229
|
+
Ee.current = { event: t };
|
|
230
|
+
try {
|
|
231
|
+
Oe((t) => ({
|
|
232
|
+
columnId: e,
|
|
233
|
+
direction: t?.columnId === e && t.direction === "ascending" ? "descending" : "ascending"
|
|
234
|
+
}));
|
|
235
|
+
} finally {
|
|
236
|
+
Ee.current = void 0;
|
|
237
|
+
}
|
|
238
|
+
}, [Oe]), Ae = T.useMemo(() => ({
|
|
239
|
+
sort: De,
|
|
240
|
+
requestSort: ke
|
|
241
|
+
}), [De, ke]);
|
|
242
|
+
re !== void 0 && o("DataGrid", "onSelectionChange", "onSelectedItemsChange");
|
|
243
|
+
let je = T.useMemo(() => de(w), [w]), Me = T.useMemo(() => de(ne), [ne]), Ne = a("DataGrid", ee, je, "selectedKeys", "selectedItems"), Pe = a("DataGrid", C, Me, "defaultSelectedKeys", "defaultSelectedItems") ?? ue, Fe = T.useRef(void 0), [Ie, Le] = g(Ne, Pe, (e) => {
|
|
244
|
+
te?.([...e], Fe.current), re?.(new Set(e));
|
|
245
|
+
}), Re = T.useCallback((e, t) => {
|
|
246
|
+
Fe.current = { event: e };
|
|
247
|
+
try {
|
|
248
|
+
Le(t);
|
|
249
|
+
} finally {
|
|
250
|
+
Fe.current = void 0;
|
|
251
|
+
}
|
|
252
|
+
}, [Le]), Q = S === "single", [$] = T.useState(() => k(Ie, Q));
|
|
253
|
+
T.useLayoutEffect(() => {
|
|
254
|
+
$.setSelected(Ie);
|
|
255
|
+
}, [$, Ie]), T.useLayoutEffect(() => {
|
|
201
256
|
$.setSingleMode(Q);
|
|
202
257
|
}, [$, Q]);
|
|
203
|
-
let
|
|
204
|
-
|
|
258
|
+
let ze = T.useCallback((e, t) => {
|
|
259
|
+
Re(t, (t) => {
|
|
205
260
|
let n = $.prune(t), r;
|
|
206
|
-
return r = Q ? n[0] === e ? [] : [e] : n.includes(e) ? n.filter((t) => t !== e) : [...n, e],
|
|
261
|
+
return r = Q ? n[0] === e ? [] : [e] : n.includes(e) ? n.filter((t) => t !== e) : [...n, e], fe(r, t) ? t : r;
|
|
207
262
|
});
|
|
208
263
|
}, [
|
|
209
264
|
Q,
|
|
210
|
-
|
|
265
|
+
Re,
|
|
211
266
|
$
|
|
212
|
-
]),
|
|
213
|
-
|
|
214
|
-
Q &&
|
|
215
|
-
}, [Q,
|
|
216
|
-
let
|
|
217
|
-
|
|
218
|
-
let t = $.prune(e), n = $.getRegistered(), r = n.length > 0 &&
|
|
219
|
-
return
|
|
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;
|
|
220
275
|
});
|
|
221
|
-
}, [
|
|
222
|
-
selectionMode:
|
|
276
|
+
}, [Re, $]), He = _("wave-datagrid-selection"), Ue = ie?.selectAll ?? D, We = ie?.selectionHeader ?? O, Ge = T.useMemo(() => ({
|
|
277
|
+
selectionMode: S,
|
|
223
278
|
store: $,
|
|
224
|
-
toggleRow:
|
|
225
|
-
toggleAll:
|
|
226
|
-
radioName:
|
|
227
|
-
selectAllLabel:
|
|
228
|
-
selectionHeaderLabel:
|
|
279
|
+
toggleRow: ze,
|
|
280
|
+
toggleAll: Ve,
|
|
281
|
+
radioName: He,
|
|
282
|
+
selectAllLabel: Ue,
|
|
283
|
+
selectionHeaderLabel: We,
|
|
284
|
+
selectOnRowClick: A,
|
|
285
|
+
selectionAppearance: N,
|
|
286
|
+
subtleSelection: P
|
|
229
287
|
}), [
|
|
230
|
-
|
|
288
|
+
S,
|
|
231
289
|
$,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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;
|
|
300
|
+
let e = /* @__PURE__ */ new Set();
|
|
301
|
+
return i.map((t, n) => {
|
|
302
|
+
let r = l ? l(t) : String(n), i = e.has(r) ? `${r}\u0000${n}` : r;
|
|
303
|
+
return e.add(i), {
|
|
304
|
+
item: t,
|
|
305
|
+
index: n,
|
|
306
|
+
rowId: r,
|
|
307
|
+
key: i
|
|
308
|
+
};
|
|
309
|
+
});
|
|
310
|
+
}, [i, l]), Xe = De?.columnId, Ze = De?.direction, Qe = T.useMemo(() => {
|
|
311
|
+
if (H && Xe !== void 0 && F) return F.find((e) => B(e) === Xe)?.compare;
|
|
312
|
+
}, [
|
|
313
|
+
H,
|
|
314
|
+
Xe,
|
|
315
|
+
F
|
|
316
|
+
]), $e = T.useMemo(() => {
|
|
317
|
+
if (Ye === null || !Qe) return Ye;
|
|
318
|
+
let e = Qe;
|
|
319
|
+
return Ye.slice().sort(Ze === "descending" ? (t, n) => -e(t.item, n.item) : (t, n) => e(t.item, n.item));
|
|
320
|
+
}, [
|
|
321
|
+
Ye,
|
|
322
|
+
Qe,
|
|
323
|
+
Ze
|
|
324
|
+
]), et = T.useMemo(() => {
|
|
325
|
+
if (!F || !H) return null;
|
|
326
|
+
let e = F.map((e, t) => B(e) ?? t);
|
|
327
|
+
return (t) => /* @__PURE__ */ E(ve, { children: F.map((n, r) => /* @__PURE__ */ E(Z, { children: n.renderCell?.(t) }, e[r])) });
|
|
328
|
+
}, [F, H]), tt = T.useMemo(() => ({
|
|
329
|
+
rows: $e,
|
|
330
|
+
renderColumnsRow: et
|
|
331
|
+
}), [$e, et]), nt = F?.some((e) => e.columnId === void 0 && e.id === void 0) ?? !1;
|
|
332
|
+
T.useEffect(() => {
|
|
333
|
+
nt && s("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`.");
|
|
334
|
+
}, [nt]);
|
|
335
|
+
let rt = I, it = F ? t(I) : [], at = (e) => it.some(({ node: t }) => n(t, e)), ot = F && !at(q) ? /* @__PURE__ */ E(q, { children: /* @__PURE__ */ E("tr", { children: F.map((e, t) => {
|
|
336
|
+
let n = B(e);
|
|
337
|
+
return /* @__PURE__ */ E(J, {
|
|
338
|
+
columnId: n,
|
|
339
|
+
sortable: e.sortable ?? e.compare !== void 0,
|
|
340
|
+
children: e.renderHeaderCell ? e.renderHeaderCell() : e.label
|
|
341
|
+
}, n ?? t);
|
|
342
|
+
}) }) }, "wave-generated-header") : null, st = F && H && !at(Y) ? /* @__PURE__ */ E(Y, {}, "wave-generated-body") : null;
|
|
343
|
+
if (ot || st) {
|
|
344
|
+
let e = ({ node: e }) => n(e, "caption"), t = it.filter((t) => !e(t)), r = st ? t.findIndex(({ node: e }) => n(e, "tfoot")) : -1, i = r >= 0 ? r : t.length;
|
|
345
|
+
rt = [
|
|
346
|
+
...it.filter(e).map(pe),
|
|
347
|
+
ot,
|
|
348
|
+
...t.slice(0, i).map(pe),
|
|
349
|
+
st,
|
|
350
|
+
...t.slice(i).map(pe)
|
|
351
|
+
];
|
|
249
352
|
}
|
|
250
|
-
let { className:
|
|
251
|
-
return
|
|
252
|
-
|
|
253
|
-
}, [
|
|
254
|
-
value:
|
|
255
|
-
children: /* @__PURE__ */
|
|
256
|
-
value:
|
|
257
|
-
children: /* @__PURE__ */
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
353
|
+
let { className: ct, "aria-label": lt, "aria-labelledby": ut, ...dt } = ce ?? {}, ft = dt.role !== void 0, pt = !ft && (lt !== void 0 || ut !== void 0);
|
|
354
|
+
return T.useEffect(() => {
|
|
355
|
+
pt && s("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.");
|
|
356
|
+
}, [pt]), /* @__PURE__ */ E(j.Provider, {
|
|
357
|
+
value: Ge,
|
|
358
|
+
children: /* @__PURE__ */ E(M.Provider, {
|
|
359
|
+
value: Ae,
|
|
360
|
+
children: /* @__PURE__ */ E(ae.Provider, {
|
|
361
|
+
value: tt,
|
|
362
|
+
children: /* @__PURE__ */ E(se.Provider, {
|
|
363
|
+
value: null,
|
|
364
|
+
children: /* @__PURE__ */ E(oe.Provider, {
|
|
365
|
+
value: null,
|
|
366
|
+
children: /* @__PURE__ */ E("div", {
|
|
367
|
+
...dt,
|
|
368
|
+
"aria-label": ft ? lt : void 0,
|
|
369
|
+
"aria-labelledby": ft ? ut : void 0,
|
|
370
|
+
className: e(d.container, "overflow-x-auto rounded-md border border-border", ct),
|
|
371
|
+
children: /* @__PURE__ */ E("table", {
|
|
372
|
+
ref: Je,
|
|
373
|
+
role: "grid",
|
|
374
|
+
"aria-multiselectable": S === "multiple" || void 0,
|
|
375
|
+
"data-selection-appearance": N,
|
|
376
|
+
"data-subtle-selection": P ? "" : void 0,
|
|
377
|
+
className: e(d.root, "w-full border-separate border-spacing-0", P && "group/grid", L),
|
|
378
|
+
...V,
|
|
379
|
+
onKeyDown: c(R, qe.onKeyDown),
|
|
380
|
+
onFocus: c(le, qe.onFocus, { checkDefaultPrevented: !1 }),
|
|
381
|
+
onBlur: c(z, qe.onBlur, { checkDefaultPrevented: !1 }),
|
|
382
|
+
children: rt
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
})
|
|
272
386
|
})
|
|
273
387
|
})
|
|
274
388
|
})
|
|
275
389
|
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function
|
|
279
|
-
let { store:
|
|
280
|
-
return
|
|
281
|
-
c.current && (c.current.indeterminate = s === "some");
|
|
282
|
-
}, [s, l]), /* @__PURE__ */ b("th", {
|
|
283
|
-
ref: n,
|
|
390
|
+
}
|
|
391
|
+
W.displayName = "DataGrid";
|
|
392
|
+
function G({ selectionMode: t, stableClassName: n, cellProps: r, ref: i }) {
|
|
393
|
+
let { store: a, toggleAll: o, selectAllLabel: s, selectionHeaderLabel: c, subtleSelection: l } = R("DataGrid.Header"), u = T.useSyncExternalStore(a.subscribeSelectAll, a.getSelectAllState, a.getSelectAllState), { className: d, disabled: f, invisible: m, controlRef: h, "aria-label": g, "aria-labelledby": _, "aria-describedby": v, ...y } = r ?? {}, x = !1;
|
|
394
|
+
return u === "all" ? x = !0 : u === "some" && (x = "mixed"), /* @__PURE__ */ E("th", {
|
|
284
395
|
scope: "col",
|
|
396
|
+
...y,
|
|
397
|
+
ref: i,
|
|
285
398
|
"data-selection-cell": "",
|
|
286
|
-
className: e(p.selectionCell,
|
|
287
|
-
children: t === "multiple" ? /* @__PURE__ */
|
|
288
|
-
ref:
|
|
399
|
+
className: e(n, p.selectionCell, C, "text-start", b, d),
|
|
400
|
+
children: t === "multiple" ? /* @__PURE__ */ E(te, {
|
|
401
|
+
ref: h,
|
|
289
402
|
type: "checkbox",
|
|
290
|
-
"aria-label":
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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", {
|
|
297
414
|
className: "sr-only",
|
|
298
|
-
children:
|
|
415
|
+
children: c
|
|
299
416
|
})
|
|
300
417
|
});
|
|
301
418
|
}
|
|
302
|
-
var
|
|
419
|
+
var K = {
|
|
303
420
|
subscribe: () => () => {},
|
|
304
421
|
register: () => () => {},
|
|
305
422
|
getFirst: () => null,
|
|
306
423
|
refresh: () => {}
|
|
307
424
|
};
|
|
308
|
-
function
|
|
309
|
-
let
|
|
310
|
-
let e =
|
|
311
|
-
return e === null ? n : e ===
|
|
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;
|
|
312
429
|
}, [
|
|
313
|
-
|
|
314
|
-
|
|
430
|
+
o,
|
|
431
|
+
s,
|
|
315
432
|
n
|
|
316
|
-
]),
|
|
317
|
-
|
|
318
|
-
ref:
|
|
319
|
-
selectionMode: t
|
|
320
|
-
|
|
321
|
-
|
|
433
|
+
]), d = T.useCallback(() => n, [n]), f = T.useSyncExternalStore(o.subscribe, u, d);
|
|
434
|
+
if (T.useLayoutEffect(() => o.register(s, () => c.current), [o, s]), f) return /* @__PURE__ */ E(G, {
|
|
435
|
+
ref: l,
|
|
436
|
+
selectionMode: t,
|
|
437
|
+
stableClassName: r,
|
|
438
|
+
cellProps: i
|
|
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,
|
|
322
444
|
"data-selection-cell": "",
|
|
323
|
-
className: e(p.selectionCell,
|
|
445
|
+
className: e(r, p.selectionCell, C, b, m)
|
|
324
446
|
});
|
|
325
447
|
}
|
|
326
|
-
function
|
|
327
|
-
let
|
|
328
|
-
if (n(e,
|
|
329
|
-
if (!
|
|
330
|
-
let
|
|
331
|
-
if (
|
|
332
|
-
let n =
|
|
333
|
-
selectionMode:
|
|
334
|
-
initialFirst:
|
|
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
|
|
335
457
|
});
|
|
336
|
-
return
|
|
458
|
+
return T.cloneElement(e, void 0, i, /* @__PURE__ */ E(F.Provider, {
|
|
459
|
+
value: o,
|
|
460
|
+
children: n
|
|
461
|
+
}));
|
|
337
462
|
}
|
|
338
|
-
return /* @__PURE__ */
|
|
339
|
-
value:
|
|
463
|
+
return /* @__PURE__ */ E(F.Provider, {
|
|
464
|
+
value: o,
|
|
340
465
|
children: e
|
|
341
466
|
});
|
|
342
467
|
});
|
|
343
|
-
return
|
|
468
|
+
return a(e);
|
|
344
469
|
}
|
|
345
|
-
var
|
|
346
|
-
let { selectionMode: o } =
|
|
347
|
-
return
|
|
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(() => {
|
|
348
473
|
d.refresh();
|
|
349
|
-
}),
|
|
350
|
-
r
|
|
351
|
-
|
|
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, {
|
|
352
479
|
value: "header",
|
|
353
|
-
children: /* @__PURE__ */
|
|
480
|
+
children: /* @__PURE__ */ E(P.Provider, {
|
|
354
481
|
value: d,
|
|
355
|
-
children: /* @__PURE__ */
|
|
482
|
+
children: /* @__PURE__ */ E("thead", {
|
|
356
483
|
ref: u,
|
|
357
484
|
className: e(p.root, "bg-card", n),
|
|
358
485
|
...a,
|
|
@@ -361,130 +488,232 @@ var G = ({ children: t, className: n, ref: i, ...a }) => {
|
|
|
361
488
|
})
|
|
362
489
|
});
|
|
363
490
|
};
|
|
364
|
-
|
|
365
|
-
var
|
|
366
|
-
|
|
367
|
-
viewBox: "0 0 12 12",
|
|
368
|
-
fill: "currentColor",
|
|
369
|
-
"aria-hidden": "true",
|
|
370
|
-
focusable: "false",
|
|
371
|
-
children: t === "ascending" ? /* @__PURE__ */ b("path", { d: "M6 2L10 8H2L6 2Z" }) : /* @__PURE__ */ b("path", { d: "M6 10L2 4H10L6 10Z" })
|
|
372
|
-
}), K = ({ columnId: t, sortable: n = !1, children: r, className: i, onClick: a, ref: o, ...l }) => {
|
|
373
|
-
let { sort: u, requestSort: d } = P("DataGrid.HeaderCell"), p = n && t ? t : void 0, m = p !== void 0 && u?.columnId === p ? u.direction : null, h = (e) => {
|
|
491
|
+
q.displayName = "DataGridHeader";
|
|
492
|
+
var J = ({ columnId: t, sortable: n = !1, sortIcon: r, children: i, className: a, onClick: o, ref: l, ...u }) => {
|
|
493
|
+
let { sort: d, requestSort: p } = z("DataGrid.HeaderCell"), m = n && t ? t : void 0, h = m !== void 0 && d?.columnId === m ? d.direction : null, g = (e) => {
|
|
374
494
|
let t = e.currentTarget.firstElementChild;
|
|
375
|
-
|
|
495
|
+
m !== void 0 && t?.localName === "button" && t.contains(e.target) && p(m, e.nativeEvent);
|
|
376
496
|
};
|
|
377
|
-
return
|
|
497
|
+
return T.useEffect(() => {
|
|
378
498
|
n && !t && s("DataGrid.HeaderCell:sortable-without-columnId", "DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.");
|
|
379
|
-
}, [n, t]), /* @__PURE__ */
|
|
380
|
-
ref:
|
|
499
|
+
}, [n, t]), /* @__PURE__ */ E("th", {
|
|
500
|
+
ref: l,
|
|
381
501
|
scope: "col",
|
|
382
|
-
"aria-sort":
|
|
383
|
-
className: e(f.root,
|
|
384
|
-
...
|
|
385
|
-
onClick:
|
|
386
|
-
children:
|
|
502
|
+
"aria-sort": m === void 0 ? void 0 : h ?? "none",
|
|
503
|
+
className: e(f.root, V, "text-start align-middle font-semibold text-caption-1 uppercase tracking-wider", b, m !== void 0 && "p-0 hover:bg-subtle-hover", a),
|
|
504
|
+
...u,
|
|
505
|
+
onClick: m === void 0 ? o : c(o, g),
|
|
506
|
+
children: m === void 0 ? /* @__PURE__ */ E("span", {
|
|
387
507
|
className: "inline-flex items-center gap-1",
|
|
388
|
-
children:
|
|
389
|
-
}) : /* @__PURE__ */
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
508
|
+
children: i
|
|
509
|
+
}) : /* @__PURE__ */ E(w, {
|
|
510
|
+
component: "DataGrid.HeaderCell",
|
|
511
|
+
direction: h,
|
|
512
|
+
sortIcon: r,
|
|
513
|
+
className: f.button,
|
|
514
|
+
iconClassName: f.sortIcon,
|
|
515
|
+
children: i
|
|
393
516
|
})
|
|
394
517
|
});
|
|
395
518
|
};
|
|
396
|
-
|
|
397
|
-
var
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
519
|
+
J.displayName = "DataGridHeaderCell";
|
|
520
|
+
var _e = T.memo(function({ item: e, index: t, rowId: n, render: r }) {
|
|
521
|
+
return /* @__PURE__ */ E(oe.Provider, {
|
|
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, {
|
|
537
|
+
value: "body",
|
|
538
|
+
children: /* @__PURE__ */ E("tbody", {
|
|
539
|
+
ref: r,
|
|
540
|
+
className: e(l.root, n),
|
|
541
|
+
...i,
|
|
542
|
+
children: d
|
|
543
|
+
})
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
Y.displayName = "DataGridBody";
|
|
547
|
+
var ve = ({ rowId: i, selectionLabel: a, selectionCellProps: o, children: l, className: u, onClick: d, onKeyDown: f, ref: p, ...h }) => {
|
|
548
|
+
let { selectionMode: g, store: v, toggleRow: y, selectOnRowClick: b, selectionAppearance: C } = R("DataGrid.Row"), te = T.useContext(oe), w = i ?? te ?? void 0, ne = T.useContext(N), re = T.useContext(F), D = ne === "header", O = g !== "none" && !D, k = _("wave-datagrid-row-label"), A = t(l), j;
|
|
549
|
+
for (let { node: e } of A) if (U(e)) {
|
|
550
|
+
j = e.props;
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
let M = j !== void 0, P = j?.disabled ?? o?.disabled ?? !1, ae = j?.invisible ?? o?.invisible ?? !1, ce = j?.["aria-labelledby"], I = j?.["aria-label"] ?? o?.["aria-label"] ?? a, L = g === "single", le = T.useCallback(() => w !== void 0 && v.isSelected(w, L), [
|
|
554
|
+
w,
|
|
555
|
+
v,
|
|
556
|
+
L
|
|
557
|
+
]), z = T.useSyncExternalStore(v.subscribe, le, le);
|
|
558
|
+
T.useLayoutEffect(() => {
|
|
559
|
+
if (w === void 0 || D) return;
|
|
560
|
+
let e = v.register(w);
|
|
561
|
+
return r && v.countRegistrations(w) > 1 && me(w), e;
|
|
417
562
|
}, [
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
]),
|
|
422
|
-
w
|
|
423
|
-
}, [
|
|
424
|
-
|
|
425
|
-
|
|
563
|
+
v,
|
|
564
|
+
w,
|
|
565
|
+
D
|
|
566
|
+
]), T.useLayoutEffect(() => {
|
|
567
|
+
if (w !== void 0 && !D && P) return v.disable(w);
|
|
568
|
+
}, [
|
|
569
|
+
v,
|
|
570
|
+
w,
|
|
571
|
+
D,
|
|
572
|
+
P
|
|
573
|
+
]), T.useEffect(() => {
|
|
574
|
+
O && w === void 0 && s("DataGrid.Row:missing-rowId", "DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.");
|
|
575
|
+
}, [O, w]);
|
|
576
|
+
let ue = O && w !== void 0 && I === void 0 && ce === void 0, de = (e) => {
|
|
577
|
+
if (!O || w === void 0 || e.key !== " ") return;
|
|
426
578
|
let t = e.target;
|
|
427
|
-
(t === e.currentTarget || t.parentElement === e.currentTarget) && (e.preventDefault(),
|
|
428
|
-
},
|
|
429
|
-
|
|
430
|
-
let
|
|
579
|
+
(t === e.currentTarget || t.parentElement === e.currentTarget) && (e.preventDefault(), P || y(w, e.nativeEvent));
|
|
580
|
+
}, fe = (e) => {
|
|
581
|
+
if (!b || !O || w === void 0 || P) return;
|
|
582
|
+
let t = e.currentTarget;
|
|
583
|
+
ee(e, { isOwnPart: (e) => e.parentElement === t }) || S(e) || y(w, e.nativeEvent);
|
|
584
|
+
}, B, V = -1;
|
|
585
|
+
if (ue) {
|
|
586
|
+
let e = A.findIndex(({ node: e }) => n(e, Z, "td", "th"));
|
|
431
587
|
if (e >= 0) {
|
|
432
|
-
let t =
|
|
433
|
-
|
|
588
|
+
let t = A[e].node;
|
|
589
|
+
B = t.props.id ?? k, t.props.id === void 0 && (V = e);
|
|
434
590
|
}
|
|
435
591
|
}
|
|
436
|
-
let
|
|
592
|
+
let W = A.map(({ key: e, node: t }, n) => pe({
|
|
437
593
|
key: e,
|
|
438
|
-
node: n ===
|
|
439
|
-
})),
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}, [
|
|
443
|
-
let
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
594
|
+
node: n === V ? T.cloneElement(t, { id: k }) : t
|
|
595
|
+
})), G = ue && B === void 0;
|
|
596
|
+
T.useEffect(() => {
|
|
597
|
+
G && s("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).");
|
|
598
|
+
}, [G]);
|
|
599
|
+
let K = ce ?? B, ge = I ?? (K === void 0 ? "Select row" : void 0), q = T.useMemo(() => ({
|
|
600
|
+
selectionCellProps: o,
|
|
601
|
+
hasSelectionCell: M,
|
|
602
|
+
rowId: O ? w : void 0,
|
|
603
|
+
isSelected: z,
|
|
604
|
+
disabled: P,
|
|
605
|
+
invisible: ae,
|
|
606
|
+
ariaLabel: ge,
|
|
607
|
+
ariaLabelledBy: K
|
|
608
|
+
}), [
|
|
609
|
+
o,
|
|
610
|
+
M,
|
|
611
|
+
O,
|
|
612
|
+
w,
|
|
613
|
+
z,
|
|
614
|
+
P,
|
|
615
|
+
ae,
|
|
616
|
+
ge,
|
|
617
|
+
K
|
|
618
|
+
]), J = null;
|
|
619
|
+
return !M && D && g !== "none" ? J = /* @__PURE__ */ E(he, {
|
|
620
|
+
selectionMode: g,
|
|
621
|
+
initialFirst: re,
|
|
622
|
+
cellProps: o
|
|
623
|
+
}) : !M && O && (J = /* @__PURE__ */ E(ye, { component: "DataGrid.Row" })), /* @__PURE__ */ E(se.Provider, {
|
|
624
|
+
value: q,
|
|
625
|
+
children: /* @__PURE__ */ ie("tr", {
|
|
626
|
+
ref: p,
|
|
627
|
+
className: e(m.root, "group/table-row", !D && H[C], O && z && x.selectedContainer, u),
|
|
628
|
+
"aria-selected": O ? z : void 0,
|
|
629
|
+
"data-selected": O && z ? "" : void 0,
|
|
630
|
+
...h,
|
|
631
|
+
onClick: c(d, fe),
|
|
632
|
+
onKeyDown: c(f, de),
|
|
633
|
+
children: [J, W]
|
|
634
|
+
})
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
ve.displayName = "DataGridRow";
|
|
638
|
+
function ye({ component: t, stableClassName: n, className: r, controlRef: i, "aria-describedby": a, ref: o, ...s }) {
|
|
639
|
+
let { selectionMode: c, toggleRow: l, radioName: u, subtleSelection: d } = R(t), f = le(t), { rowId: p } = f, h = c === "single";
|
|
640
|
+
return /* @__PURE__ */ E("td", {
|
|
448
641
|
role: "gridcell",
|
|
642
|
+
...s,
|
|
643
|
+
ref: o,
|
|
449
644
|
"data-selection-cell": "",
|
|
450
|
-
className: e(m.selectionCell,
|
|
451
|
-
children:
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
645
|
+
className: e(n, m.selectionCell, C, b, f.selectionCellProps?.className, r),
|
|
646
|
+
children: p !== void 0 && c !== "none" && /* @__PURE__ */ E(te, {
|
|
647
|
+
ref: i,
|
|
648
|
+
type: h ? "radio" : "checkbox",
|
|
649
|
+
name: h ? u : void 0,
|
|
650
|
+
form: h ? "" : void 0,
|
|
651
|
+
checked: f.isSelected,
|
|
652
|
+
disabled: f.disabled,
|
|
653
|
+
invisible: f.invisible,
|
|
654
|
+
subtle: d,
|
|
655
|
+
onChange: (e) => l(p, e.nativeEvent),
|
|
656
|
+
"aria-label": f.ariaLabel,
|
|
657
|
+
"aria-labelledby": f.ariaLabelledBy,
|
|
658
|
+
"aria-describedby": a,
|
|
659
|
+
className: m.selectionControl
|
|
460
660
|
})
|
|
461
|
-
})
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
var X = ({ disabled: t, invisible: n, className: r, "aria-label": i, "aria-labelledby": a, "aria-describedby": o, controlRef: c, ref: l, ...u }) => {
|
|
664
|
+
let { selectionMode: d } = R("DataGrid.SelectionCell"), f = T.useContext(N), p = T.useContext(F), m = T.useContext(se), g = d === "none", _ = !g && m !== null && !m.hasSelectionCell;
|
|
665
|
+
if (T.useEffect(() => {
|
|
666
|
+
g && s("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.");
|
|
667
|
+
}, [g]), T.useEffect(() => {
|
|
668
|
+
_ && s("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).");
|
|
669
|
+
}, [_]), g) return null;
|
|
670
|
+
if (f === "header") {
|
|
671
|
+
let s = m?.selectionCellProps;
|
|
672
|
+
return /* @__PURE__ */ E(he, {
|
|
673
|
+
ref: l,
|
|
674
|
+
selectionMode: d,
|
|
675
|
+
initialFirst: p,
|
|
676
|
+
stableClassName: h.root,
|
|
677
|
+
cellProps: {
|
|
678
|
+
...u,
|
|
679
|
+
className: e(s?.className, r),
|
|
680
|
+
disabled: t ?? s?.disabled,
|
|
681
|
+
invisible: n ?? s?.invisible,
|
|
682
|
+
"aria-label": i ?? s?.["aria-label"],
|
|
683
|
+
"aria-labelledby": a,
|
|
684
|
+
"aria-describedby": o,
|
|
685
|
+
controlRef: c
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
return /* @__PURE__ */ E(ye, {
|
|
690
|
+
...u,
|
|
691
|
+
ref: l,
|
|
692
|
+
component: "DataGrid.SelectionCell",
|
|
693
|
+
stableClassName: h.root,
|
|
694
|
+
className: r,
|
|
695
|
+
controlRef: c,
|
|
696
|
+
"aria-describedby": o
|
|
469
697
|
});
|
|
470
698
|
};
|
|
471
|
-
|
|
472
|
-
var
|
|
699
|
+
X.displayName = "DataGridSelectionCell", re(X, "dataGridSelectionCell");
|
|
700
|
+
var Z = ({ children: t, className: n, ref: r, ...i }) => /* @__PURE__ */ E("td", {
|
|
473
701
|
ref: r,
|
|
474
702
|
role: "gridcell",
|
|
475
|
-
className: e(u.root,
|
|
703
|
+
className: e(u.root, V, "relative text-body-1", b, n),
|
|
476
704
|
...i,
|
|
477
705
|
children: t
|
|
478
706
|
});
|
|
479
|
-
|
|
480
|
-
var
|
|
481
|
-
Header:
|
|
482
|
-
HeaderCell:
|
|
483
|
-
Body:
|
|
484
|
-
Row:
|
|
485
|
-
Cell:
|
|
707
|
+
Z.displayName = "DataGridCell";
|
|
708
|
+
var be = /* @__PURE__ */ Object.assign(W, {
|
|
709
|
+
Header: q,
|
|
710
|
+
HeaderCell: J,
|
|
711
|
+
Body: Y,
|
|
712
|
+
Row: ve,
|
|
713
|
+
Cell: Z,
|
|
714
|
+
SelectionCell: X
|
|
486
715
|
});
|
|
487
716
|
//#endregion
|
|
488
|
-
export {
|
|
717
|
+
export { be as DataGrid, Y as DataGridBody, Z as DataGridCell, q as DataGridHeader, J as DataGridHeaderCell, ve as DataGridRow, X as DataGridSelectionCell, k as createSelectionStore };
|
|
489
718
|
|
|
490
719
|
//# sourceMappingURL=DataGrid.mjs.map
|