@spark-ui/components 18.0.16 → 18.0.18
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/dist/table/TableBody.d.ts +1 -1
- package/dist/table/TableCell.d.ts +1 -1
- package/dist/table/TableColumn.d.ts +1 -1
- package/dist/table/TableHeader.d.ts +1 -1
- package/dist/table/TableRow.d.ts +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/index.js.map +1 -1
- package/dist/table/index.mjs +140 -141
- package/dist/table/index.mjs.map +1 -1
- package/dist/table/internal/ResizableTableContainer.d.ts +1 -1
- package/dist/table/internal/TableBodyCellRenderer.d.ts +1 -1
- package/dist/table/internal/TableBodyRowRenderer.d.ts +1 -1
- package/dist/table/internal/TableColumnHeader.d.ts +1 -1
- package/dist/table/internal/TableGrid.d.ts +1 -1
- package/dist/table/internal/TableHeaderRowRenderer.d.ts +1 -1
- package/dist/table/internal/TableHeaderSelectionCheckbox.d.ts +1 -1
- package/dist/table/internal/TableRoot.d.ts +1 -1
- package/dist/table/internal/TableRootWrapper.d.ts +1 -1
- package/package.json +12 -7
package/dist/table/index.mjs
CHANGED
|
@@ -5,34 +5,33 @@ import { cva as r, cx as i } from "class-variance-authority";
|
|
|
5
5
|
import a, { createContext as o, useCallback as s, useContext as c, useEffect as l, useLayoutEffect as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
6
6
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
7
7
|
import { filterDOMProps as g, getEventTarget as _, useResizeObserver as v } from "@react-aria/utils";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { Sort as ce } from "@spark-ui/icons/Sort";
|
|
8
|
+
import { mergeProps as y, useFocusRing as b, useTable as x, useTableCell as S, useTableColumnHeader as C, useTableColumnResize as w, useTableHeaderRow as T, useTableRow as E, useTableRowGroup as D, useTableSelectAllCheckbox as ee, useTableSelectionCheckbox as te } from "react-aria";
|
|
9
|
+
import { Cell as O, TableBody as k, TableHeader as A, useTableColumnResizeState as ne, useTableState as re } from "react-stately";
|
|
10
|
+
import { ArrowDown as ie } from "@spark-ui/icons/ArrowDown";
|
|
11
|
+
import { ArrowUp as ae } from "@spark-ui/icons/ArrowUp";
|
|
12
|
+
import { Sort as oe } from "@spark-ui/icons/Sort";
|
|
14
13
|
//#region src/table/internal/TableContext.tsx
|
|
15
|
-
var
|
|
14
|
+
var se = o({
|
|
16
15
|
isResizable: !1,
|
|
17
16
|
tableWidth: 0
|
|
18
17
|
});
|
|
19
|
-
function
|
|
20
|
-
return c(
|
|
18
|
+
function ce() {
|
|
19
|
+
return c(se);
|
|
21
20
|
}
|
|
22
|
-
var
|
|
21
|
+
var le = o({
|
|
23
22
|
selectedCount: 0,
|
|
24
23
|
onClearSelection: () => {}
|
|
25
24
|
});
|
|
26
|
-
function
|
|
27
|
-
return c(
|
|
25
|
+
function j() {
|
|
26
|
+
return c(le);
|
|
28
27
|
}
|
|
29
28
|
//#endregion
|
|
30
29
|
//#region src/table/internal/TableRootWrapper.tsx
|
|
31
|
-
function
|
|
30
|
+
function M({ children: e, className: t, selectedKeys: n, onSelectionChange: r, totalCount: a, hasMultiplePages: o, onClearSelection: s, onSelectAll: c, allowsResizing: l = !0, resizeColumnAriaLabel: u, maxHeight: d, stickyHeader: f, onResizeStart: p, onResize: h, onResizeEnd: g, onKeyDownCapture: _, sortDescriptor: v, onSortChange: y, ...b }) {
|
|
32
31
|
let x = 0;
|
|
33
32
|
n === "all" ? x = a ?? 0 : n instanceof Set ? x = n.size : n && (x = new Set(n).size);
|
|
34
33
|
let S = s ?? (() => r?.(/* @__PURE__ */ new Set()));
|
|
35
|
-
return /* @__PURE__ */ m(
|
|
34
|
+
return /* @__PURE__ */ m(le, {
|
|
36
35
|
value: {
|
|
37
36
|
...b,
|
|
38
37
|
selectedKeys: n,
|
|
@@ -60,10 +59,10 @@ function fe({ children: e, className: t, selectedKeys: n, onSelectionChange: r,
|
|
|
60
59
|
})
|
|
61
60
|
});
|
|
62
61
|
}
|
|
63
|
-
|
|
62
|
+
M.displayName = "Table";
|
|
64
63
|
//#endregion
|
|
65
64
|
//#region src/table/internal/ResizableTableContainer.tsx
|
|
66
|
-
function
|
|
65
|
+
function ue({ className: e, children: t, ...n }) {
|
|
67
66
|
let r = f(null), [a, o] = p(0);
|
|
68
67
|
return u(() => {
|
|
69
68
|
let e = r.current;
|
|
@@ -74,7 +73,7 @@ function A({ className: e, children: t, ...n }) {
|
|
|
74
73
|
let e = r.current;
|
|
75
74
|
e && o(e.clientWidth);
|
|
76
75
|
}
|
|
77
|
-
}), /* @__PURE__ */ m(
|
|
76
|
+
}), /* @__PURE__ */ m(se, {
|
|
78
77
|
value: {
|
|
79
78
|
isResizable: !0,
|
|
80
79
|
tableWidth: a
|
|
@@ -88,30 +87,30 @@ function A({ className: e, children: t, ...n }) {
|
|
|
88
87
|
})
|
|
89
88
|
});
|
|
90
89
|
}
|
|
91
|
-
|
|
90
|
+
ue.displayName = "ResizableTableContainer";
|
|
92
91
|
//#endregion
|
|
93
92
|
//#region src/table/internal/table-keyboard.ts
|
|
94
|
-
var
|
|
95
|
-
function
|
|
93
|
+
var N = "[data-spark-component=\"table-cell\"]";
|
|
94
|
+
function P(e) {
|
|
96
95
|
return !e || !(e instanceof Element) ? !1 : !!e.closest("[role=\"combobox\"],select,[data-spark-component=\"dropdown-trigger\"],[data-spark-component=\"combobox-input\"]");
|
|
97
96
|
}
|
|
98
|
-
function
|
|
97
|
+
function de(e) {
|
|
99
98
|
if (!e || !(e instanceof Element)) return !1;
|
|
100
99
|
let t = e.closest("[role=\"combobox\"],[data-spark-component=\"dropdown-trigger\"],[data-spark-component=\"combobox-input\"]");
|
|
101
100
|
return t ? t.getAttribute("aria-expanded") === "true" : !1;
|
|
102
101
|
}
|
|
103
|
-
var
|
|
104
|
-
function
|
|
105
|
-
return !e || !(e instanceof Element) ? null : e.closest(
|
|
102
|
+
var fe = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
|
|
103
|
+
function F(e) {
|
|
104
|
+
return !e || !(e instanceof Element) ? null : e.closest(N);
|
|
106
105
|
}
|
|
107
|
-
function
|
|
106
|
+
function I(e) {
|
|
108
107
|
return e.getAttribute("data-table-cell-kind") === "selection";
|
|
109
108
|
}
|
|
110
|
-
function
|
|
111
|
-
return Array.from(e.querySelectorAll(
|
|
109
|
+
function L(e) {
|
|
110
|
+
return Array.from(e.querySelectorAll(fe)).filter((t) => !(t === e || t.hasAttribute("disabled") || t.getAttribute("aria-disabled") === "true" || t.getAttribute("hidden") !== null));
|
|
112
111
|
}
|
|
113
|
-
function
|
|
114
|
-
for (let n of
|
|
112
|
+
function R(e, t) {
|
|
113
|
+
for (let n of L(e)) {
|
|
115
114
|
let e = "data-prev-tabindex";
|
|
116
115
|
if (!t) n.hasAttribute(e) || n.setAttribute(e, n.getAttribute("tabindex") ?? ""), n.setAttribute("tabindex", "-1");
|
|
117
116
|
else {
|
|
@@ -121,46 +120,46 @@ function I(e, t) {
|
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
|
-
function
|
|
125
|
-
let t = Array.from(e.querySelectorAll(
|
|
126
|
-
for (let e of t)
|
|
123
|
+
function z(e) {
|
|
124
|
+
let t = Array.from(e.querySelectorAll(N));
|
|
125
|
+
for (let e of t) R(e, !1);
|
|
127
126
|
}
|
|
128
|
-
function
|
|
127
|
+
function pe({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
|
|
129
128
|
let [i, a] = p("grid"), o = f("grid"), s = f(null), c = f(!1), u = d(() => {
|
|
130
129
|
let { onKeyDown: l, ...u } = t, d = (e) => {
|
|
131
|
-
s.current = e, o.current = "interaction", a("interaction"),
|
|
130
|
+
s.current = e, o.current = "interaction", a("interaction"), R(e, !0);
|
|
132
131
|
};
|
|
133
|
-
return
|
|
132
|
+
return y(u, {
|
|
134
133
|
onKeyDown: (e) => {
|
|
135
134
|
if (o.current === "interaction" && (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
136
135
|
let e = s.current, t = document.activeElement;
|
|
137
136
|
if (e && t instanceof Node && e.contains(t)) return;
|
|
138
137
|
}
|
|
139
|
-
o.current === "interaction" && (e.key === "ArrowUp" || e.key === "ArrowDown") &&
|
|
138
|
+
o.current === "interaction" && (e.key === "ArrowUp" || e.key === "ArrowDown") && P(e.target) && F(e.target) === s.current || l?.(e);
|
|
140
139
|
},
|
|
141
140
|
onKeyDownCapture: (e) => {
|
|
142
141
|
if (n?.(e), o.current === "interaction" && e.key === "Tab") {
|
|
143
|
-
let t =
|
|
142
|
+
let t = F(e.target);
|
|
144
143
|
t && t === s.current && e.stopPropagation();
|
|
145
144
|
return;
|
|
146
145
|
}
|
|
147
|
-
if (
|
|
148
|
-
let t =
|
|
146
|
+
if (P(e.target) && o.current === "interaction" && (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
147
|
+
let t = F(e.target);
|
|
149
148
|
if (t && t === s.current) return;
|
|
150
149
|
}
|
|
151
150
|
if (o.current === "interaction" && (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
152
|
-
let t =
|
|
151
|
+
let t = F(e.target);
|
|
153
152
|
if (t && t === s.current) {
|
|
154
153
|
e.stopPropagation();
|
|
155
154
|
return;
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
if (o.current === "grid" && e.key === "ArrowRight") {
|
|
159
|
-
let t =
|
|
158
|
+
let t = F(e.target);
|
|
160
159
|
if (t) {
|
|
161
160
|
let n = t.closest("tr");
|
|
162
161
|
if (n) {
|
|
163
|
-
let r = Array.from(n.querySelectorAll(
|
|
162
|
+
let r = Array.from(n.querySelectorAll(N));
|
|
164
163
|
if (r.length > 0 && r[r.length - 1] === t) {
|
|
165
164
|
e.preventDefault(), e.stopPropagation(), n.focus();
|
|
166
165
|
return;
|
|
@@ -169,23 +168,23 @@ function he({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
|
|
|
169
168
|
}
|
|
170
169
|
}
|
|
171
170
|
if (o.current === "grid" && e.key === "Enter") {
|
|
172
|
-
let t =
|
|
173
|
-
if (!t ||
|
|
174
|
-
let n =
|
|
171
|
+
let t = F(e.target);
|
|
172
|
+
if (!t || I(t)) return;
|
|
173
|
+
let n = L(t);
|
|
175
174
|
if (n.length === 0) return;
|
|
176
175
|
e.preventDefault(), e.stopPropagation(), d(t), n[0]?.focus();
|
|
177
176
|
return;
|
|
178
177
|
}
|
|
179
178
|
if (o.current === "grid" && e.key === "F2") {
|
|
180
|
-
let t =
|
|
181
|
-
if (!t ||
|
|
182
|
-
let n =
|
|
179
|
+
let t = F(e.target);
|
|
180
|
+
if (!t || I(t)) return;
|
|
181
|
+
let n = L(t);
|
|
183
182
|
if (n.length === 0) return;
|
|
184
183
|
e.preventDefault(), e.stopPropagation(), d(t), n[0]?.focus();
|
|
185
184
|
return;
|
|
186
185
|
}
|
|
187
186
|
if (o.current === "interaction" && e.key === "Escape") {
|
|
188
|
-
if (
|
|
187
|
+
if (de(e.target)) return;
|
|
189
188
|
let t = s.current;
|
|
190
189
|
if (!t) return;
|
|
191
190
|
e.preventDefault(), e.stopPropagation(), o.current = "grid", a("grid"), t.focus();
|
|
@@ -207,19 +206,19 @@ function he({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
|
|
|
207
206
|
r?.(t);
|
|
208
207
|
let n = c.current;
|
|
209
208
|
c.current = !1;
|
|
210
|
-
let i = e.current, l =
|
|
209
|
+
let i = e.current, l = F(t.target);
|
|
211
210
|
if (o.current === "interaction" && s.current && i) {
|
|
212
211
|
let e = !!(l && l !== s.current), n = !l && t.target instanceof Element && i.contains(t.target) && !s.current.contains(t.target);
|
|
213
212
|
(e || n) && (o.current = "grid", a("grid"), n && (s.current = null));
|
|
214
213
|
}
|
|
215
214
|
if (!l) return;
|
|
216
215
|
s.current = l;
|
|
217
|
-
let u = t.target instanceof Element ? t.target : null, f = l.matches(
|
|
218
|
-
p && f && m && h && !n && queueMicrotask(() => l.focus()), n && p && m && f && h && !
|
|
216
|
+
let u = t.target instanceof Element ? t.target : null, f = l.matches(N), p = o.current === "grid", m = !!(u && u !== l && l.contains(u)), h = L(l).length > 0;
|
|
217
|
+
p && f && m && h && !n && queueMicrotask(() => l.focus()), n && p && m && f && h && !I(l) && d(l);
|
|
219
218
|
},
|
|
220
219
|
onPointerDownCapture: (e) => {
|
|
221
|
-
let t =
|
|
222
|
-
t?.matches(
|
|
220
|
+
let t = F(e.target);
|
|
221
|
+
t?.matches(N) && e.target instanceof Element && e.target !== t && t.contains(e.target) && (c.current = !0);
|
|
223
222
|
},
|
|
224
223
|
"data-table-keyboard-mode": i
|
|
225
224
|
});
|
|
@@ -235,10 +234,10 @@ function he({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
|
|
|
235
234
|
let t = e.current;
|
|
236
235
|
if (t) {
|
|
237
236
|
if (i === "grid") {
|
|
238
|
-
|
|
237
|
+
z(t), s.current?.focus?.();
|
|
239
238
|
return;
|
|
240
239
|
}
|
|
241
|
-
|
|
240
|
+
z(t), s.current && R(s.current, !0);
|
|
242
241
|
}
|
|
243
242
|
}, [i, e]), {
|
|
244
243
|
gridProps: u,
|
|
@@ -247,7 +246,7 @@ function he({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
|
|
|
247
246
|
}
|
|
248
247
|
//#endregion
|
|
249
248
|
//#region src/table/internal/Table.styles.tsx
|
|
250
|
-
var
|
|
249
|
+
var B = r([
|
|
251
250
|
"h-sz-64 min-w-sz-64",
|
|
252
251
|
"relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container",
|
|
253
252
|
"pl-lg pr-lg py-sm text-left outline-none box-border",
|
|
@@ -262,7 +261,7 @@ var R = r([
|
|
|
262
261
|
checkbox: !1,
|
|
263
262
|
resizable: !1
|
|
264
263
|
}
|
|
265
|
-
}),
|
|
264
|
+
}), me = r([
|
|
266
265
|
"flex flex-1 justify-between items-center gap-md",
|
|
267
266
|
"font-inherit text-left text-inherit",
|
|
268
267
|
"whitespace-nowrap text-ellipsis",
|
|
@@ -276,7 +275,7 @@ r(["empty:italic empty:text-center empty:text-body-2 empty:py-lg"], {
|
|
|
276
275
|
variants: {},
|
|
277
276
|
defaultVariants: {}
|
|
278
277
|
});
|
|
279
|
-
var
|
|
278
|
+
var V = r([
|
|
280
279
|
"p-lg outline-none box-border default:overflow-hidden",
|
|
281
280
|
"border-b-sm border-outline [tr:last-child>&]:border-b-0",
|
|
282
281
|
"[-webkit-tap-highlight-color:transparent]",
|
|
@@ -284,35 +283,35 @@ var z = r([
|
|
|
284
283
|
], {
|
|
285
284
|
variants: { checkbox: { true: ["w-sz-64 py-sm px-0 align-middle"] } },
|
|
286
285
|
defaultVariants: { checkbox: !1 }
|
|
287
|
-
}),
|
|
286
|
+
}), he = r(["pointer-events-none", "[&_td]:h-sz-16 [&_td]:p-0 [&_td]:border-0 [&_td]:border-b-0 [&_td]:bg-surface [&_td]:align-middle"], {
|
|
288
287
|
variants: {},
|
|
289
288
|
defaultVariants: {}
|
|
290
|
-
}),
|
|
291
|
-
function
|
|
289
|
+
}), H = "button, [role=\"button\"], [role=\"switch\"], [role=\"checkbox\"], [role=\"option\"], input:not([type=\"hidden\"]), select, textarea, [href], [data-spark-component=\"dropdown-trigger\"], [data-spark-component=\"icon-button\"], [data-spark-component=\"switch\"], [data-spark-component=\"switch-input\"], [data-spark-component=\"combobox-input\"]", ge = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
|
|
290
|
+
function _e(e) {
|
|
292
291
|
if (!e || !(e instanceof Element)) return !1;
|
|
293
292
|
let t = e;
|
|
294
|
-
return t.matches(
|
|
293
|
+
return t.matches(H) || t.closest(H) !== null;
|
|
295
294
|
}
|
|
296
|
-
function
|
|
295
|
+
function ve(e) {
|
|
297
296
|
return e ? e instanceof Element ? e : e instanceof Text ? e.parentElement : null : null;
|
|
298
297
|
}
|
|
299
|
-
function
|
|
300
|
-
for (let t of e.querySelectorAll(
|
|
298
|
+
function ye(e) {
|
|
299
|
+
for (let t of e.querySelectorAll(ge)) if (t !== e && !t.hasAttribute("disabled") && t.getAttribute("aria-disabled") !== "true" && t.getAttribute("hidden") === null) return !0;
|
|
301
300
|
return !1;
|
|
302
301
|
}
|
|
303
|
-
function
|
|
304
|
-
let t =
|
|
302
|
+
function be(e) {
|
|
303
|
+
let t = ve(e);
|
|
305
304
|
if (!t) return !1;
|
|
306
|
-
if (
|
|
305
|
+
if (_e(t)) return !0;
|
|
307
306
|
let n = t.closest("[data-spark-component=\"table-cell\"]");
|
|
308
|
-
return !n || n.getAttribute("data-table-cell-kind") === "selection" ? !1 :
|
|
307
|
+
return !n || n.getAttribute("data-table-cell-kind") === "selection" ? !1 : ye(n);
|
|
309
308
|
}
|
|
310
309
|
//#endregion
|
|
311
310
|
//#region src/table/internal/TableKeyboardModeContext.tsx
|
|
312
|
-
var
|
|
311
|
+
var U = o("grid");
|
|
313
312
|
//#endregion
|
|
314
313
|
//#region src/table/internal/TableSelectionCheckbox.tsx
|
|
315
|
-
function
|
|
314
|
+
function W({ checkboxProps: e, className: t, suppressFocusWalker: r }) {
|
|
316
315
|
let { isSelected: i, isIndeterminate: a, isDisabled: o, onChange: s, ...c } = e, l = a === !0 ? "indeterminate" : !!i;
|
|
317
316
|
return /* @__PURE__ */ m("span", {
|
|
318
317
|
...r ? { "data-react-aria-prevent-focus": !0 } : void 0,
|
|
@@ -327,11 +326,11 @@ function H({ checkboxProps: e, className: t, suppressFocusWalker: r }) {
|
|
|
327
326
|
})
|
|
328
327
|
});
|
|
329
328
|
}
|
|
330
|
-
|
|
329
|
+
W.displayName = "Table.SelectionCheckbox";
|
|
331
330
|
//#endregion
|
|
332
331
|
//#region src/table/internal/TableBodyCellRenderer.tsx
|
|
333
|
-
function
|
|
334
|
-
let r = f(null), { gridCellProps: a } =
|
|
332
|
+
function G({ cell: e, state: t, resizeState: n }) {
|
|
333
|
+
let r = f(null), { gridCellProps: a } = S({ node: e }, t, r), { isFocusVisible: o, focusProps: l } = b({ within: !0 }), u = c(U), d = s((e) => {
|
|
335
334
|
u === "interaction" && (e.key !== " " && e.key !== "Enter" || e.stopPropagation());
|
|
336
335
|
}, [u]), { onKeyDownCapture: p, ...h } = a, g = s((e) => {
|
|
337
336
|
[
|
|
@@ -340,63 +339,63 @@ function Ce({ cell: e, state: t, resizeState: n }) {
|
|
|
340
339
|
"ArrowUp",
|
|
341
340
|
"ArrowDown"
|
|
342
341
|
].includes(e.key) || p?.(e);
|
|
343
|
-
}, [p]), _ =
|
|
342
|
+
}, [p]), _ = te({ key: e.parentKey ?? e.key }, t), v = t.collection.columns[e.index ?? 0]?.key ?? null, x = v ? n?.columnWidths?.get?.(v) : void 0, C = e.props?.className;
|
|
344
343
|
return e.props?.isSelectionCell ? /* @__PURE__ */ m("td", {
|
|
345
|
-
...
|
|
344
|
+
...y(h, { onKeyDownCapture: g }, l, { onKeyDown: d }),
|
|
346
345
|
ref: r,
|
|
347
346
|
"data-spark-component": "table-cell",
|
|
348
347
|
"data-table-cell-kind": "selection",
|
|
349
|
-
className:
|
|
348
|
+
className: V({ checkbox: !0 }),
|
|
350
349
|
"data-focus-visible": o || void 0,
|
|
351
|
-
children: /* @__PURE__ */ m(
|
|
350
|
+
children: /* @__PURE__ */ m(W, {
|
|
352
351
|
suppressFocusWalker: u === "grid",
|
|
353
352
|
checkboxProps: _.checkboxProps
|
|
354
353
|
})
|
|
355
354
|
}) : /* @__PURE__ */ m("td", {
|
|
356
|
-
...
|
|
355
|
+
...y(h, { onKeyDownCapture: g }, l, { onKeyDown: d }),
|
|
357
356
|
ref: r,
|
|
358
357
|
"data-spark-component": "table-cell",
|
|
359
|
-
className: i(
|
|
358
|
+
className: i(V(), C),
|
|
360
359
|
"data-focus-visible": o || void 0,
|
|
361
|
-
style:
|
|
360
|
+
style: x ? { width: x } : void 0,
|
|
362
361
|
children: e.rendered
|
|
363
362
|
});
|
|
364
363
|
}
|
|
365
|
-
|
|
364
|
+
G.displayName = "Table.BodyCellRenderer";
|
|
366
365
|
//#endregion
|
|
367
366
|
//#region src/table/internal/TableBodyRowRenderer.tsx
|
|
368
|
-
function
|
|
367
|
+
function K(e) {
|
|
369
368
|
if (e) return (t) => {
|
|
370
|
-
|
|
369
|
+
be(_(t.nativeEvent)) || e(t);
|
|
371
370
|
};
|
|
372
371
|
}
|
|
373
|
-
function
|
|
374
|
-
let r = f(null), { rowProps: a, isSelected: o } =
|
|
372
|
+
function xe({ item: e, state: t, resizeState: n }) {
|
|
373
|
+
let r = f(null), { rowProps: a, isSelected: o } = E({ node: e }, t, r), { isFocusVisible: s, focusProps: c } = b(), { onClick: l, onPointerDown: u, onMouseDown: d, onPointerUp: p, onPointerCancel: h, ...g } = a, _ = i("outline-none box-border data-focus-visible:u-outline-inset data-focus-visible:outline-dashed", g.className, o && "bg-support-container text-on-support-container");
|
|
375
374
|
return /* @__PURE__ */ m("tr", {
|
|
376
|
-
...
|
|
377
|
-
onPointerDown:
|
|
378
|
-
onMouseDown:
|
|
379
|
-
onPointerUp:
|
|
380
|
-
onPointerCancel:
|
|
381
|
-
onClick:
|
|
375
|
+
...y(g, c),
|
|
376
|
+
onPointerDown: K(u),
|
|
377
|
+
onMouseDown: K(d),
|
|
378
|
+
onPointerUp: K(p),
|
|
379
|
+
onPointerCancel: K(h),
|
|
380
|
+
onClick: K(l),
|
|
382
381
|
ref: r,
|
|
383
382
|
"data-spark-component": "table-row",
|
|
384
383
|
"data-selected": o || void 0,
|
|
385
384
|
"data-focus-visible": s || void 0,
|
|
386
385
|
className: _,
|
|
387
386
|
tabIndex: -1,
|
|
388
|
-
children: [...e.childNodes].map((e) => /* @__PURE__ */ m(
|
|
387
|
+
children: [...e.childNodes].map((e) => /* @__PURE__ */ m(G, {
|
|
389
388
|
cell: e,
|
|
390
389
|
state: t,
|
|
391
390
|
resizeState: n
|
|
392
391
|
}, e.key))
|
|
393
392
|
});
|
|
394
393
|
}
|
|
395
|
-
|
|
394
|
+
xe.displayName = "Table.BodyRowRenderer";
|
|
396
395
|
//#endregion
|
|
397
396
|
//#region src/table/internal/TableColumnResizer.tsx
|
|
398
|
-
function
|
|
399
|
-
let a = f(null), { resizerProps: o, inputProps: s, isResizing: c } =
|
|
397
|
+
function Se({ column: e, ariaLabel: t, resizeState: n, resizeCallbacks: r }) {
|
|
398
|
+
let a = f(null), { resizerProps: o, inputProps: s, isResizing: c } = w({
|
|
400
399
|
column: e,
|
|
401
400
|
"aria-label": t ?? "Resize column",
|
|
402
401
|
onResizeStart: r.onResizeStart,
|
|
@@ -415,14 +414,14 @@ function G({ column: e, ariaLabel: t, resizeState: n, resizeCallbacks: r }) {
|
|
|
415
414
|
})
|
|
416
415
|
});
|
|
417
416
|
}
|
|
418
|
-
|
|
417
|
+
Se.displayName = "Table.ColumnResizer";
|
|
419
418
|
//#endregion
|
|
420
419
|
//#region src/table/internal/TableHeaderSelectionCheckbox.tsx
|
|
421
|
-
function
|
|
422
|
-
let { checkboxProps: t } =
|
|
420
|
+
function Ce({ state: e }) {
|
|
421
|
+
let { checkboxProps: t } = ee(e), { collection: n, selectionManager: r } = e, i = r.selectedKeys, a = n, o = a.body, s = o == null ? new Set(n.getKeys()) : new Set([...a.getChildren(o.key)].map((e) => e.key)), c = i === "all" ? s : i, l = [...s].filter((e) => c.has(e)).length, u = s.size, d = u > 0 && l === u, f = l > 0 && l < u, { isSelected: p, isIndeterminate: h, onChange: g, ..._ } = t, v = (e) => {
|
|
423
422
|
(e.key === " " || e.key === "Enter") && e.stopPropagation(), e.key === "Enter" && (e.preventDefault(), t.isDisabled || g?.(!d));
|
|
424
423
|
};
|
|
425
|
-
return /* @__PURE__ */ m(
|
|
424
|
+
return /* @__PURE__ */ m(W, { checkboxProps: {
|
|
426
425
|
..._,
|
|
427
426
|
isSelected: d,
|
|
428
427
|
isIndeterminate: f,
|
|
@@ -430,53 +429,53 @@ function K({ state: e }) {
|
|
|
430
429
|
onKeyDown: v
|
|
431
430
|
} });
|
|
432
431
|
}
|
|
433
|
-
|
|
432
|
+
Ce.displayName = "Table.HeaderSelectionCheckbox";
|
|
434
433
|
//#endregion
|
|
435
434
|
//#region src/table/internal/TableColumnHeader.tsx
|
|
436
435
|
var we = i("sticky top-0 z-sticky");
|
|
437
436
|
function Te({ column: t, state: n, resizeState: r, stickyHeader: a, resizeCallbacks: o, isLastColumnInRow: s = !1 }) {
|
|
438
|
-
let c = f(null), { resizeColumnAriaLabel: l } =
|
|
437
|
+
let c = f(null), { resizeColumnAriaLabel: l } = j(), { columnHeaderProps: u } = C({ node: t }, n, c), { isFocusVisible: d, focusProps: p } = b(), g = t.props?.allowsResizing !== !1 && !s, _ = r?.columnWidths?.get?.(t.key), v = !!(r && g);
|
|
439
438
|
if (t.props?.isSelectionCell) return /* @__PURE__ */ m("th", {
|
|
440
439
|
...u,
|
|
441
440
|
ref: c,
|
|
442
441
|
role: "columnheader",
|
|
443
|
-
className: i(
|
|
442
|
+
className: i(B({ checkbox: !0 }), a && we),
|
|
444
443
|
"data-spark-component": "table-column",
|
|
445
444
|
"data-table-selection-columnheader": !0,
|
|
446
445
|
"data-focus-visible": d || void 0,
|
|
447
|
-
children: /* @__PURE__ */ m(
|
|
446
|
+
children: /* @__PURE__ */ m(Ce, { state: n })
|
|
448
447
|
});
|
|
449
|
-
let
|
|
450
|
-
|
|
448
|
+
let x = !!t.props?.allowsSorting, S = n.sortDescriptor?.column === t.key, w = n.sortDescriptor?.direction ?? "ascending", T = m(S ? w === "descending" ? ie : ae : oe, {}), E = (e) => {
|
|
449
|
+
x && (e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.stopPropagation(), n.sort?.(t.key)));
|
|
451
450
|
};
|
|
452
451
|
return /* @__PURE__ */ h("th", {
|
|
453
|
-
...
|
|
452
|
+
...y(u, p),
|
|
454
453
|
ref: c,
|
|
455
454
|
role: "columnheader",
|
|
456
|
-
className: i(
|
|
455
|
+
className: i(B({ resizable: v }), a && we),
|
|
457
456
|
style: _ ? { width: _ } : void 0,
|
|
458
457
|
"data-spark-component": "table-column",
|
|
459
458
|
"data-focus-visible": d || void 0,
|
|
460
|
-
onKeyDown:
|
|
459
|
+
onKeyDown: E,
|
|
461
460
|
children: [/* @__PURE__ */ h("div", {
|
|
462
|
-
className:
|
|
461
|
+
className: me(),
|
|
463
462
|
children: [/* @__PURE__ */ m("button", {
|
|
464
463
|
type: "button",
|
|
465
464
|
className: i("gap-md flex min-w-0 flex-1 items-center text-left", "focus-visible:u-outline outline-none", "bg-transparent p-0 border-0"),
|
|
466
|
-
onKeyDown:
|
|
465
|
+
onKeyDown: E,
|
|
467
466
|
children: /* @__PURE__ */ m("span", {
|
|
468
467
|
className: "min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",
|
|
469
468
|
children: t.rendered
|
|
470
469
|
})
|
|
471
|
-
}),
|
|
470
|
+
}), x ? /* @__PURE__ */ m("span", {
|
|
472
471
|
"aria-hidden": "true",
|
|
473
|
-
className: i("shrink-0 opacity-dim-2 group-hover/column:opacity-100",
|
|
472
|
+
className: i("shrink-0 opacity-dim-2 group-hover/column:opacity-100", S && "opacity-100"),
|
|
474
473
|
children: /* @__PURE__ */ m(e, {
|
|
475
474
|
size: "sm",
|
|
476
|
-
children:
|
|
475
|
+
children: T
|
|
477
476
|
})
|
|
478
477
|
}) : null]
|
|
479
|
-
}), r && g ? /* @__PURE__ */ m(
|
|
478
|
+
}), r && g ? /* @__PURE__ */ m(Se, {
|
|
480
479
|
column: t,
|
|
481
480
|
ariaLabel: typeof l == "function" ? l(t) : l,
|
|
482
481
|
resizeState: r,
|
|
@@ -488,7 +487,7 @@ Te.displayName = "Table.ColumnHeader";
|
|
|
488
487
|
//#endregion
|
|
489
488
|
//#region src/table/internal/TableHeaderRowRenderer.tsx
|
|
490
489
|
function Ee({ item: e, state: t, resizeState: n, stickyHeader: r, resizeCallbacks: i }) {
|
|
491
|
-
let a = f(null), { rowProps: o } =
|
|
490
|
+
let a = f(null), { rowProps: o } = T({ node: e }, t, a), s = [...e.childNodes];
|
|
492
491
|
return /* @__PURE__ */ m("tr", {
|
|
493
492
|
...o,
|
|
494
493
|
ref: a,
|
|
@@ -506,25 +505,25 @@ Ee.displayName = "Table.HeaderRowRenderer";
|
|
|
506
505
|
//#endregion
|
|
507
506
|
//#region src/table/internal/TableRoot.tsx
|
|
508
507
|
function De({ className: e, children: t, stickyHeader: n, ...r }) {
|
|
509
|
-
let a = !!n, o = f(null), s =
|
|
508
|
+
let a = !!n, o = f(null), s = ce(), c = r.selectionMode === "multiple", l = re({
|
|
510
509
|
...r,
|
|
511
510
|
showSelectionCheckboxes: r.selectionMode === "multiple",
|
|
512
511
|
children: t
|
|
513
|
-
}), u =
|
|
512
|
+
}), u = ne({ tableWidth: s.tableWidth }, l), d = s.isResizable && r.allowsResizing !== !1 ? u : null, { gridProps: p } = x({ ...r }, l, o), _ = l.collection.headerRows, v = [...l.collection.body.childNodes], b = l.collection.body.props?.renderEmptyState, S = l.collection.columns.length || 1, C = v.length > 0 || !!b, { rowGroupProps: w } = D(), { rowGroupProps: T } = D(), { gridProps: E, keyboardMode: ee } = pe({
|
|
514
513
|
ref: o,
|
|
515
514
|
gridProps: p,
|
|
516
515
|
onKeyDownCapture: r.onKeyDownCapture,
|
|
517
516
|
onFocusCapture: r.onFocusCapture
|
|
518
517
|
});
|
|
519
|
-
return /* @__PURE__ */ m(
|
|
520
|
-
value:
|
|
518
|
+
return /* @__PURE__ */ m(U, {
|
|
519
|
+
value: ee,
|
|
521
520
|
children: /* @__PURE__ */ h("table", {
|
|
522
|
-
...
|
|
521
|
+
...y(E, g(r, { global: !0 })),
|
|
523
522
|
ref: o,
|
|
524
523
|
"data-spark-component": "table",
|
|
525
524
|
className: i("default:w-full", c ? "table-fixed" : void 0, "border-separate border-spacing-y-0", "bg-surface", "outline-none", "text-body-1", "forced-color-adjust-none", "data-focus-visible:u-outline-inset", "has-[>[data-empty]]:h-full", e),
|
|
526
525
|
children: [/* @__PURE__ */ m("thead", {
|
|
527
|
-
...
|
|
526
|
+
...w,
|
|
528
527
|
"data-spark-component": "table-header",
|
|
529
528
|
children: _.map((e) => /* @__PURE__ */ m(Ee, {
|
|
530
529
|
item: e,
|
|
@@ -538,27 +537,27 @@ function De({ className: e, children: t, stickyHeader: n, ...r }) {
|
|
|
538
537
|
}
|
|
539
538
|
}, e.key))
|
|
540
539
|
}), /* @__PURE__ */ h("tbody", {
|
|
541
|
-
...
|
|
540
|
+
...T,
|
|
542
541
|
"data-spark-component": "table-body",
|
|
543
542
|
children: [
|
|
544
|
-
|
|
543
|
+
C ? /* @__PURE__ */ m("tr", {
|
|
545
544
|
"aria-hidden": "true",
|
|
546
|
-
className:
|
|
545
|
+
className: he(),
|
|
547
546
|
role: "presentation",
|
|
548
547
|
"data-spark-component": "table-body-spacer",
|
|
549
548
|
children: /* @__PURE__ */ m("td", {
|
|
550
|
-
colSpan:
|
|
549
|
+
colSpan: S,
|
|
551
550
|
role: "presentation"
|
|
552
551
|
})
|
|
553
552
|
}) : null,
|
|
554
|
-
v.length === 0 &&
|
|
553
|
+
v.length === 0 && b ? /* @__PURE__ */ m("tr", {
|
|
555
554
|
"data-empty": !0,
|
|
556
555
|
children: /* @__PURE__ */ m("td", {
|
|
557
|
-
colSpan:
|
|
558
|
-
children:
|
|
556
|
+
colSpan: S,
|
|
557
|
+
children: b({ isEmpty: !0 })
|
|
559
558
|
})
|
|
560
559
|
}) : null,
|
|
561
|
-
v.map((e) => /* @__PURE__ */ m(
|
|
560
|
+
v.map((e) => /* @__PURE__ */ m(xe, {
|
|
562
561
|
item: e,
|
|
563
562
|
state: l,
|
|
564
563
|
resizeState: d
|
|
@@ -575,7 +574,7 @@ function Oe(e) {
|
|
|
575
574
|
return typeof e == "number" ? `${e}px` : e;
|
|
576
575
|
}
|
|
577
576
|
function ke({ "aria-label": e, "aria-labelledby": t, className: n, children: r }) {
|
|
578
|
-
let { allowsResizing: i = !0, maxHeight: a, stickyHeader: o, onResizeStart: s, onResize: c, onResizeEnd: l, onKeyDownCapture: u, sortDescriptor: d, onSortChange: f, className: p, ...h } =
|
|
577
|
+
let { allowsResizing: i = !0, maxHeight: a, stickyHeader: o, onResizeStart: s, onResize: c, onResizeEnd: l, onKeyDownCapture: u, sortDescriptor: d, onSortChange: f, className: p, ...h } = j(), g = a == null ? void 0 : { maxHeight: Oe(a) }, _ = n ?? p, v = {
|
|
579
578
|
...h,
|
|
580
579
|
...e != null && { "aria-label": e },
|
|
581
580
|
...t != null && { "aria-labelledby": t },
|
|
@@ -585,7 +584,7 @@ function ke({ "aria-label": e, "aria-labelledby": t, className: n, children: r }
|
|
|
585
584
|
className: _,
|
|
586
585
|
stickyHeader: o
|
|
587
586
|
}, y = De;
|
|
588
|
-
return i ? /* @__PURE__ */ m(
|
|
587
|
+
return i ? /* @__PURE__ */ m(ue, {
|
|
589
588
|
className: _,
|
|
590
589
|
style: g,
|
|
591
590
|
onResizeStart: s,
|
|
@@ -608,9 +607,9 @@ ke.displayName = "Table.Grid";
|
|
|
608
607
|
//#endregion
|
|
609
608
|
//#region src/table/TableBody.tsx
|
|
610
609
|
function q(e) {
|
|
611
|
-
return /* @__PURE__ */ m(
|
|
610
|
+
return /* @__PURE__ */ m(k, { ...e });
|
|
612
611
|
}
|
|
613
|
-
q.displayName = "Table.Body", q.getCollectionNode =
|
|
612
|
+
q.displayName = "Table.Body", q.getCollectionNode = k.getCollectionNode;
|
|
614
613
|
//#endregion
|
|
615
614
|
//#region src/table/TableBulkBar.tsx
|
|
616
615
|
var Ae = o(null);
|
|
@@ -620,7 +619,7 @@ function J() {
|
|
|
620
619
|
return e;
|
|
621
620
|
}
|
|
622
621
|
function je({ children: e, className: t, rootProps: n, ...r }) {
|
|
623
|
-
let { selectedCount: a, totalCount: o, onClearSelection: s, onSelectAll: c, hasMultiplePages: l } =
|
|
622
|
+
let { selectedCount: a, totalCount: o, onClearSelection: s, onSelectAll: c, hasMultiplePages: l } = j();
|
|
624
623
|
return /* @__PURE__ */ m(Ae, {
|
|
625
624
|
value: {
|
|
626
625
|
selectedCount: a,
|
|
@@ -679,9 +678,9 @@ Fe.displayName = "Table.BulkBar", Me.displayName = "Table.BulkBarSelectedCount",
|
|
|
679
678
|
//#endregion
|
|
680
679
|
//#region src/table/TableCell.tsx
|
|
681
680
|
function Y(e) {
|
|
682
|
-
return /* @__PURE__ */ m(
|
|
681
|
+
return /* @__PURE__ */ m(O, { ...e });
|
|
683
682
|
}
|
|
684
|
-
Y.displayName = "Table.Cell", Y.getCollectionNode =
|
|
683
|
+
Y.displayName = "Table.Cell", Y.getCollectionNode = O.getCollectionNode;
|
|
685
684
|
//#endregion
|
|
686
685
|
//#region src/table/TableColumn.tsx
|
|
687
686
|
function X({ label: e, allowsResizing: t = !0, ...n }) {
|
|
@@ -725,9 +724,9 @@ X.displayName = "Table.Column", X.getCollectionNode = function* (e, t) {
|
|
|
725
724
|
//#endregion
|
|
726
725
|
//#region src/table/TableHeader.tsx
|
|
727
726
|
function Z(e) {
|
|
728
|
-
return /* @__PURE__ */ m(
|
|
727
|
+
return /* @__PURE__ */ m(A, { ...e });
|
|
729
728
|
}
|
|
730
|
-
Z.displayName = "Table.Header", Z.getCollectionNode =
|
|
729
|
+
Z.displayName = "Table.Header", Z.getCollectionNode = A.getCollectionNode;
|
|
731
730
|
//#endregion
|
|
732
731
|
//#region src/table/TableRow.tsx
|
|
733
732
|
function Q(e) {
|
|
@@ -873,7 +872,7 @@ function Re(e, t) {
|
|
|
873
872
|
}
|
|
874
873
|
//#endregion
|
|
875
874
|
//#region src/table/index.ts
|
|
876
|
-
var $ = Object.assign(
|
|
875
|
+
var $ = Object.assign(M, {
|
|
877
876
|
Grid: ke,
|
|
878
877
|
Header: Z,
|
|
879
878
|
Column: X,
|