@spark-ui/components 17.3.1 → 17.3.2
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/dropdown/index.js +1 -1
- package/dist/dropdown/index.js.map +1 -1
- package/dist/dropdown/index.mjs +10 -10
- package/dist/dropdown/index.mjs.map +1 -1
- package/dist/src/dropdown/DropdownItems.d.ts +3 -0
- package/dist/src/table/Table.d.ts +2 -45
- package/dist/src/table/TableBody.d.ts +8 -3
- package/dist/src/table/TableBulkBar.d.ts +9 -2
- package/dist/src/table/TableCell.d.ts +3 -4
- package/dist/src/table/TableColumn.d.ts +11 -5
- package/dist/src/table/TableHeader.d.ts +7 -4
- package/dist/src/table/TableRow.d.ts +8 -3
- package/dist/src/table/index.d.mts +1 -1
- package/dist/src/table/index.d.ts +1 -1
- package/dist/src/table/internal/ResizableTableContainer.d.ts +13 -0
- package/dist/src/table/{Table.styles.d.ts → internal/Table.styles.d.ts} +4 -1
- package/dist/src/table/internal/TableBodyCellRenderer.d.ts +10 -0
- package/dist/src/table/internal/TableBodyRowRenderer.d.ts +10 -0
- package/dist/src/table/internal/TableColumnHeader.d.ts +17 -0
- package/dist/src/table/internal/TableColumnResizer.d.ts +14 -0
- package/dist/src/table/{TableContext.d.ts → internal/TableContext.d.ts} +9 -2
- package/dist/src/table/internal/TableGrid.d.ts +12 -0
- package/dist/src/table/internal/TableHeaderRowRenderer.d.ts +15 -0
- package/dist/src/table/internal/TableHeaderSelectionCheckbox.d.ts +18 -0
- package/dist/src/table/internal/TableKeyboardModeContext.d.ts +2 -0
- package/dist/src/table/internal/TableRoot.d.ts +8 -0
- package/dist/src/table/internal/TableRootWrapper.d.ts +37 -0
- package/dist/src/table/internal/TableSelectionCheckbox.d.ts +18 -0
- package/dist/src/table/internal/table-keyboard.d.ts +26 -0
- package/dist/src/table/internal/table-utils.d.ts +8 -0
- package/dist/src/table/useTablePagination.d.ts +1 -1
- package/dist/src/table/useTableSort.d.ts +1 -1
- package/dist/table/index.js +1 -1
- package/dist/table/index.js.map +1 -1
- package/dist/table/index.mjs +694 -336
- package/dist/table/index.mjs.map +1 -1
- package/package.json +4 -4
- package/dist/src/table/ResizableTableContainer.d.ts +0 -9
- package/dist/src/table/TableHeaderSelectionCheckbox.d.ts +0 -13
- package/dist/src/table/TableSelectionCheckbox.d.ts +0 -7
- package/dist/src/table/table-utils.d.ts +0 -2
package/dist/table/index.mjs
CHANGED
|
@@ -2,156 +2,110 @@ import { t as e } from "../icon-D05Uqh8_.mjs";
|
|
|
2
2
|
import { t } from "../button-C6nlNPdv.mjs";
|
|
3
3
|
import { n } from "../checkbox-xsURzANi.mjs";
|
|
4
4
|
import { cva as r, cx as i } from "class-variance-authority";
|
|
5
|
-
import { createContext as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//#region src/table/TableContext.tsx
|
|
22
|
-
var A = a({ isResizable: !1 });
|
|
23
|
-
function j() {
|
|
24
|
-
return s(A);
|
|
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
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
7
|
+
import { filterDOMProps as g, getEventTarget as _, useResizeObserver as v } from "@react-aria/utils";
|
|
8
|
+
import { Cell as y, TableBody as b, TableHeader as x, useTableColumnResizeState as S, useTableState as ee } from "@react-stately/table";
|
|
9
|
+
import { mergeProps as C, useFocusRing as w, useTable as te, useTableCell as T, useTableColumnHeader as ne, useTableHeaderRow as re, useTableRow as ie, useTableRowGroup as ae } from "react-aria";
|
|
10
|
+
import { useTableColumnResize as oe, useTableSelectAllCheckbox as se, useTableSelectionCheckbox as ce } from "@react-aria/table";
|
|
11
|
+
import { ArrowDown as le } from "@spark-ui/icons/ArrowDown";
|
|
12
|
+
import { ArrowUp as ue } from "@spark-ui/icons/ArrowUp";
|
|
13
|
+
import { Sort as de } from "@spark-ui/icons/Sort";
|
|
14
|
+
//#region src/table/internal/TableContext.tsx
|
|
15
|
+
var fe = o({
|
|
16
|
+
isResizable: !1,
|
|
17
|
+
tableWidth: 0
|
|
18
|
+
});
|
|
19
|
+
function pe() {
|
|
20
|
+
return c(fe);
|
|
25
21
|
}
|
|
26
|
-
var
|
|
22
|
+
var me = o({
|
|
27
23
|
selectedCount: 0,
|
|
28
24
|
onClearSelection: () => {}
|
|
29
25
|
});
|
|
30
|
-
function
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
|
-
//#region src/table/ResizableTableContainer.tsx
|
|
35
|
-
function P({ className: e, children: t, ...n }) {
|
|
36
|
-
let r = d(null);
|
|
37
|
-
return l(() => {
|
|
38
|
-
let e = r.current;
|
|
39
|
-
if (!e) return;
|
|
40
|
-
let t = (t) => {
|
|
41
|
-
t.key !== " " && t.key !== "Enter" || O(t.target) && e.contains(t.target) && (k(t.target) || (t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), t.target.click()));
|
|
42
|
-
};
|
|
43
|
-
return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
|
|
44
|
-
}, []), /* @__PURE__ */ m(A.Provider, {
|
|
45
|
-
value: { isResizable: !0 },
|
|
46
|
-
children: /* @__PURE__ */ m(S, {
|
|
47
|
-
ref: r,
|
|
48
|
-
"data-spark-component": "resizable-table-container",
|
|
49
|
-
className: i("relative w-full overflow-auto", e),
|
|
50
|
-
...n,
|
|
51
|
-
children: t
|
|
52
|
-
})
|
|
53
|
-
});
|
|
26
|
+
function E() {
|
|
27
|
+
return c(me);
|
|
54
28
|
}
|
|
55
|
-
P.displayName = "ResizableTableContainer";
|
|
56
29
|
//#endregion
|
|
57
|
-
//#region src/table/
|
|
58
|
-
function
|
|
59
|
-
let
|
|
60
|
-
n === "all" ?
|
|
61
|
-
let
|
|
62
|
-
...
|
|
30
|
+
//#region src/table/internal/TableRootWrapper.tsx
|
|
31
|
+
function D({ children: e, className: t, selectedKeys: n, onSelectionChange: r, totalCount: a, hasMultiplePages: o, onClearSelection: s, onSelectAll: c, allowsResizing: l = !0, resizeColumnAriaLabel: u, maxHeight: d, onResizeStart: f, onResize: p, onResizeEnd: h, onKeyDownCapture: g, sortDescriptor: _, onSortChange: v, ...y }) {
|
|
32
|
+
let b = 0;
|
|
33
|
+
n === "all" ? b = a ?? 0 : n instanceof Set ? b = n.size : n && (b = new Set(n).size);
|
|
34
|
+
let x = s ?? (() => r?.(/* @__PURE__ */ new Set())), S = {
|
|
35
|
+
...y,
|
|
63
36
|
selectedKeys: n,
|
|
64
37
|
onSelectionChange: r,
|
|
65
38
|
totalCount: a,
|
|
66
39
|
hasMultiplePages: o,
|
|
67
40
|
onSelectAll: c,
|
|
68
|
-
selectedCount:
|
|
69
|
-
onClearSelection:
|
|
41
|
+
selectedCount: b,
|
|
42
|
+
onClearSelection: x,
|
|
70
43
|
allowsResizing: l,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
resizeColumnAriaLabel: u,
|
|
45
|
+
maxHeight: d,
|
|
46
|
+
onResizeStart: f,
|
|
47
|
+
onResize: p,
|
|
48
|
+
onResizeEnd: h,
|
|
49
|
+
onKeyDownCapture: g,
|
|
50
|
+
sortDescriptor: _,
|
|
51
|
+
onSortChange: v,
|
|
78
52
|
className: t
|
|
79
53
|
};
|
|
80
|
-
return /* @__PURE__ */ m(
|
|
81
|
-
value:
|
|
54
|
+
return /* @__PURE__ */ m(me.Provider, {
|
|
55
|
+
value: S,
|
|
82
56
|
children: /* @__PURE__ */ m("div", {
|
|
83
57
|
className: i("gap-md flex flex-col", t),
|
|
84
58
|
children: e
|
|
85
59
|
})
|
|
86
60
|
});
|
|
87
61
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
62
|
+
D.displayName = "Table";
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/table/internal/ResizableTableContainer.tsx
|
|
65
|
+
function O({ className: e, children: t, ...n }) {
|
|
66
|
+
let r = f(null), [a, o] = p(0);
|
|
67
|
+
return u(() => {
|
|
92
68
|
let e = r.current;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
t.key !== " " && t.key !== "Enter" || O(t.target) && e.contains(t.target) && (k(t.target) || (t.preventDefault(), t.stopPropagation(), t.stopImmediatePropagation(), t.target.click()));
|
|
96
|
-
};
|
|
97
|
-
return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
|
|
98
|
-
}, []), /* @__PURE__ */ m(ne, {
|
|
69
|
+
e && o(e.clientWidth);
|
|
70
|
+
}, []), v({
|
|
99
71
|
ref: r,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
72
|
+
onResize: () => {
|
|
73
|
+
let e = r.current;
|
|
74
|
+
e && o(e.clientWidth);
|
|
75
|
+
}
|
|
76
|
+
}), /* @__PURE__ */ m(fe.Provider, {
|
|
77
|
+
value: {
|
|
78
|
+
isResizable: !0,
|
|
79
|
+
tableWidth: a
|
|
80
|
+
},
|
|
81
|
+
children: /* @__PURE__ */ m("div", {
|
|
82
|
+
ref: r,
|
|
83
|
+
"data-spark-component": "resizable-table-container",
|
|
84
|
+
className: i("relative w-full overflow-auto", e),
|
|
103
85
|
...n,
|
|
104
|
-
|
|
105
|
-
} : n
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
I.displayName = "Table.Grid.Inner";
|
|
109
|
-
function ce(e) {
|
|
110
|
-
return typeof e == "number" ? `${e}px` : e;
|
|
111
|
-
}
|
|
112
|
-
function L({ "aria-label": e, "aria-labelledby": t, className: n, children: r }) {
|
|
113
|
-
let { allowsResizing: i = !0, maxHeight: a, onResizeStart: o, onResize: s, onResizeEnd: c, onKeyDownCapture: l, sortDescriptor: u, onSortChange: d, className: f, ...p } = N(), h = a == null ? void 0 : { maxHeight: ce(a) }, g = n ?? f, _ = {
|
|
114
|
-
...p,
|
|
115
|
-
...e != null && { "aria-label": e },
|
|
116
|
-
...t != null && { "aria-labelledby": t },
|
|
117
|
-
sortDescriptor: u,
|
|
118
|
-
onSortChange: d,
|
|
119
|
-
onKeyDownCapture: l,
|
|
120
|
-
className: g
|
|
121
|
-
};
|
|
122
|
-
return i ? /* @__PURE__ */ m(P, {
|
|
123
|
-
className: g,
|
|
124
|
-
style: h,
|
|
125
|
-
onResizeStart: o,
|
|
126
|
-
onResize: s,
|
|
127
|
-
onResizeEnd: c,
|
|
128
|
-
children: /* @__PURE__ */ m(I, {
|
|
129
|
-
..._,
|
|
130
|
-
children: r
|
|
131
|
-
})
|
|
132
|
-
}) : /* @__PURE__ */ m("div", {
|
|
133
|
-
className: "relative w-full overflow-auto",
|
|
134
|
-
style: h,
|
|
135
|
-
children: /* @__PURE__ */ m(I, {
|
|
136
|
-
..._,
|
|
137
|
-
children: r
|
|
86
|
+
children: t
|
|
138
87
|
})
|
|
139
88
|
});
|
|
140
89
|
}
|
|
141
|
-
|
|
90
|
+
O.displayName = "ResizableTableContainer";
|
|
142
91
|
//#endregion
|
|
143
|
-
//#region src/table/Table.styles.tsx
|
|
144
|
-
var
|
|
92
|
+
//#region src/table/internal/Table.styles.tsx
|
|
93
|
+
var k = r([
|
|
145
94
|
"h-sz-64 min-w-sz-64",
|
|
146
95
|
"relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container",
|
|
147
|
-
"
|
|
96
|
+
"pl-lg pr-lg py-sm text-left outline-none box-border",
|
|
148
97
|
"cursor-default",
|
|
149
98
|
"data-focus-visible:u-outline data-focus-visible:-outline-offset-2"
|
|
150
99
|
], {
|
|
151
|
-
variants: {
|
|
152
|
-
|
|
153
|
-
}
|
|
154
|
-
|
|
100
|
+
variants: {
|
|
101
|
+
checkbox: { true: ["w-sz-64 min-w-sz-64 max-w-sz-64", "px-0 align-middle"] },
|
|
102
|
+
resizable: { true: ["pr-xl"] }
|
|
103
|
+
},
|
|
104
|
+
defaultVariants: {
|
|
105
|
+
checkbox: !1,
|
|
106
|
+
resizable: !1
|
|
107
|
+
}
|
|
108
|
+
}), he = r([
|
|
155
109
|
"flex flex-1 justify-between items-center gap-md",
|
|
156
110
|
"font-inherit text-left text-inherit",
|
|
157
111
|
"whitespace-nowrap text-ellipsis",
|
|
@@ -161,10 +115,11 @@ r([
|
|
|
161
115
|
variants: {},
|
|
162
116
|
defaultVariants: {}
|
|
163
117
|
});
|
|
164
|
-
|
|
118
|
+
r(["empty:italic empty:text-center empty:text-body-2 empty:py-lg"], {
|
|
165
119
|
variants: {},
|
|
166
120
|
defaultVariants: {}
|
|
167
|
-
})
|
|
121
|
+
});
|
|
122
|
+
var A = r([
|
|
168
123
|
"p-lg outline-none box-border default:overflow-hidden",
|
|
169
124
|
"border-b-sm border-outline [tr:last-child>&]:border-b-0",
|
|
170
125
|
"[-webkit-tap-highlight-color:transparent]",
|
|
@@ -172,62 +127,521 @@ var le = r(["empty:italic empty:text-center empty:text-body-2 empty:py-lg"], {
|
|
|
172
127
|
], {
|
|
173
128
|
variants: { checkbox: { true: ["w-sz-64 py-sm px-0 align-middle"] } },
|
|
174
129
|
defaultVariants: { checkbox: !1 }
|
|
175
|
-
})
|
|
176
|
-
r(["pointer-events-none", "[&_td]:h-sz-16 [&_td]:p-0 [&_td]:border-0 [&_td]:border-b-0 [&_td]:bg-surface [&_td]:align-middle"], {
|
|
130
|
+
}), ge = r(["pointer-events-none", "[&_td]:h-sz-16 [&_td]:p-0 [&_td]:border-0 [&_td]:border-b-0 [&_td]:bg-surface [&_td]:align-middle"], {
|
|
177
131
|
variants: {},
|
|
178
132
|
defaultVariants: {}
|
|
179
|
-
});
|
|
133
|
+
}), j = "[data-spark-component=\"table-cell\"]";
|
|
134
|
+
function M(e) {
|
|
135
|
+
return !e || !(e instanceof Element) ? !1 : !!e.closest("[role=\"combobox\"],select,[data-spark-component=\"dropdown-trigger\"],[data-spark-component=\"combobox-input\"]");
|
|
136
|
+
}
|
|
137
|
+
function _e(e) {
|
|
138
|
+
if (!e || !(e instanceof Element)) return !1;
|
|
139
|
+
let t = e.closest("[role=\"combobox\"],[data-spark-component=\"dropdown-trigger\"],[data-spark-component=\"combobox-input\"]");
|
|
140
|
+
return t ? t.getAttribute("aria-expanded") === "true" : !1;
|
|
141
|
+
}
|
|
142
|
+
var ve = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
|
|
143
|
+
function N(e) {
|
|
144
|
+
return !e || !(e instanceof Element) ? null : e.closest(j);
|
|
145
|
+
}
|
|
146
|
+
function P(e) {
|
|
147
|
+
return e.getAttribute("data-table-cell-kind") === "selection";
|
|
148
|
+
}
|
|
149
|
+
function F(e) {
|
|
150
|
+
return Array.from(e.querySelectorAll(ve)).filter((t) => !(t === e || t.hasAttribute("disabled") || t.getAttribute("aria-disabled") === "true" || t.getAttribute("hidden") !== null));
|
|
151
|
+
}
|
|
152
|
+
function I(e, t) {
|
|
153
|
+
for (let n of F(e)) {
|
|
154
|
+
let e = "data-prev-tabindex";
|
|
155
|
+
if (!t) n.hasAttribute(e) || n.setAttribute(e, n.getAttribute("tabindex") ?? ""), n.setAttribute("tabindex", "-1");
|
|
156
|
+
else {
|
|
157
|
+
let t = n.getAttribute(e);
|
|
158
|
+
if (t === null) continue;
|
|
159
|
+
n.removeAttribute(e), t === "" ? n.removeAttribute("tabindex") : n.setAttribute("tabindex", t);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function L(e) {
|
|
164
|
+
let t = Array.from(e.querySelectorAll(j));
|
|
165
|
+
for (let e of t) I(e, !1);
|
|
166
|
+
}
|
|
167
|
+
function ye({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
|
|
168
|
+
let [i, a] = p("grid"), o = f("grid"), s = f(null), c = f(!1), u = d(() => {
|
|
169
|
+
let { onKeyDown: l, ...u } = t, d = (e) => {
|
|
170
|
+
s.current = e, o.current = "interaction", a("interaction"), I(e, !0);
|
|
171
|
+
};
|
|
172
|
+
return C(u, {
|
|
173
|
+
onKeyDown: (e) => {
|
|
174
|
+
if (o.current === "interaction" && (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
175
|
+
let e = s.current, t = document.activeElement;
|
|
176
|
+
if (e && t instanceof Node && e.contains(t)) return;
|
|
177
|
+
}
|
|
178
|
+
o.current === "interaction" && (e.key === "ArrowUp" || e.key === "ArrowDown") && M(e.target) && N(e.target) === s.current || l?.(e);
|
|
179
|
+
},
|
|
180
|
+
onKeyDownCapture: (e) => {
|
|
181
|
+
if (n?.(e), o.current === "interaction" && e.key === "Tab") {
|
|
182
|
+
let t = N(e.target);
|
|
183
|
+
t && t === s.current && e.stopPropagation();
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (M(e.target) && o.current === "interaction" && (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
187
|
+
let t = N(e.target);
|
|
188
|
+
if (t && t === s.current) return;
|
|
189
|
+
}
|
|
190
|
+
if (o.current === "interaction" && (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
191
|
+
let t = N(e.target);
|
|
192
|
+
if (t && t === s.current) {
|
|
193
|
+
e.stopPropagation();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (o.current === "grid" && e.key === "ArrowRight") {
|
|
198
|
+
let t = N(e.target);
|
|
199
|
+
if (t) {
|
|
200
|
+
let n = t.closest("tr");
|
|
201
|
+
if (n) {
|
|
202
|
+
let r = Array.from(n.querySelectorAll(j));
|
|
203
|
+
if (r.length > 0 && r[r.length - 1] === t) {
|
|
204
|
+
e.preventDefault(), e.stopPropagation(), n.focus();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (o.current === "grid" && e.key === "Enter") {
|
|
211
|
+
let t = N(e.target);
|
|
212
|
+
if (!t || P(t)) return;
|
|
213
|
+
let n = F(t);
|
|
214
|
+
if (n.length === 0) return;
|
|
215
|
+
e.preventDefault(), e.stopPropagation(), d(t), n[0]?.focus();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
if (o.current === "grid" && e.key === "F2") {
|
|
219
|
+
let t = N(e.target);
|
|
220
|
+
if (!t || P(t)) return;
|
|
221
|
+
let n = F(t);
|
|
222
|
+
if (n.length === 0) return;
|
|
223
|
+
e.preventDefault(), e.stopPropagation(), d(t), n[0]?.focus();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (o.current === "interaction" && e.key === "Escape") {
|
|
227
|
+
if (_e(e.target)) return;
|
|
228
|
+
let t = s.current;
|
|
229
|
+
if (!t) return;
|
|
230
|
+
e.preventDefault(), e.stopPropagation(), o.current = "grid", a("grid"), t.focus();
|
|
231
|
+
}
|
|
232
|
+
if (o.current === "interaction" && e.key === "F2") {
|
|
233
|
+
let t = s.current;
|
|
234
|
+
if (!t) return;
|
|
235
|
+
e.preventDefault(), e.stopPropagation(), o.current = "grid", a("grid"), t.focus();
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
onBlurCapture: (t) => {
|
|
239
|
+
if (o.current !== "interaction") return;
|
|
240
|
+
let n = e.current;
|
|
241
|
+
if (!n) return;
|
|
242
|
+
let r = t.relatedTarget;
|
|
243
|
+
r instanceof Node && n.contains(r) || (s.current = null, o.current = "grid", a("grid"));
|
|
244
|
+
},
|
|
245
|
+
onFocusCapture: (t) => {
|
|
246
|
+
r?.(t);
|
|
247
|
+
let n = c.current;
|
|
248
|
+
c.current = !1;
|
|
249
|
+
let i = e.current, l = N(t.target);
|
|
250
|
+
if (o.current === "interaction" && s.current && i) {
|
|
251
|
+
let e = !!(l && l !== s.current), n = !l && t.target instanceof Element && i.contains(t.target) && !s.current.contains(t.target);
|
|
252
|
+
(e || n) && (o.current = "grid", a("grid"), n && (s.current = null));
|
|
253
|
+
}
|
|
254
|
+
if (!l) return;
|
|
255
|
+
s.current = l;
|
|
256
|
+
let u = t.target instanceof Element ? t.target : null, f = l.matches(j), p = o.current === "grid", m = !!(u && u !== l && l.contains(u)), h = F(l).length > 0;
|
|
257
|
+
p && f && m && h && !n && queueMicrotask(() => l.focus()), n && p && m && f && h && !P(l) && d(l);
|
|
258
|
+
},
|
|
259
|
+
onPointerDownCapture: (e) => {
|
|
260
|
+
let t = N(e.target);
|
|
261
|
+
t?.matches(j) && e.target instanceof Element && e.target !== t && t.contains(e.target) && (c.current = !0);
|
|
262
|
+
},
|
|
263
|
+
"data-table-keyboard-mode": i
|
|
264
|
+
});
|
|
265
|
+
}, [
|
|
266
|
+
t,
|
|
267
|
+
i,
|
|
268
|
+
e,
|
|
269
|
+
r,
|
|
270
|
+
n
|
|
271
|
+
]);
|
|
272
|
+
return l(() => {
|
|
273
|
+
o.current = i;
|
|
274
|
+
let t = e.current;
|
|
275
|
+
if (t) {
|
|
276
|
+
if (i === "grid") {
|
|
277
|
+
L(t), s.current?.focus?.();
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
L(t), s.current && I(s.current, !0);
|
|
281
|
+
}
|
|
282
|
+
}, [i, e]), {
|
|
283
|
+
gridProps: u,
|
|
284
|
+
keyboardMode: i
|
|
285
|
+
};
|
|
286
|
+
}
|
|
180
287
|
//#endregion
|
|
181
|
-
//#region src/table/
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
288
|
+
//#region src/table/internal/table-utils.ts
|
|
289
|
+
var R = "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\"]", be = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
|
|
290
|
+
function xe(e) {
|
|
291
|
+
if (!e || !(e instanceof Element)) return !1;
|
|
292
|
+
let t = e;
|
|
293
|
+
return t.matches(R) || t.closest(R) !== null;
|
|
294
|
+
}
|
|
295
|
+
function Se(e) {
|
|
296
|
+
return e ? e instanceof Element ? e : e instanceof Text ? e.parentElement : null : null;
|
|
297
|
+
}
|
|
298
|
+
function Ce(e) {
|
|
299
|
+
for (let t of e.querySelectorAll(be)) if (t !== e && !t.hasAttribute("disabled") && t.getAttribute("aria-disabled") !== "true" && t.getAttribute("hidden") === null) return !0;
|
|
300
|
+
return !1;
|
|
301
|
+
}
|
|
302
|
+
function we(e) {
|
|
303
|
+
let t = Se(e);
|
|
304
|
+
if (!t) return !1;
|
|
305
|
+
if (xe(t)) return !0;
|
|
306
|
+
let n = t.closest("[data-spark-component=\"table-cell\"]");
|
|
307
|
+
return !n || n.getAttribute("data-table-cell-kind") === "selection" ? !1 : Ce(n);
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/table/internal/TableKeyboardModeContext.tsx
|
|
311
|
+
var z = o("grid");
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/table/internal/TableSelectionCheckbox.tsx
|
|
314
|
+
function B({ checkboxProps: e, className: t, suppressFocusWalker: r }) {
|
|
315
|
+
let { isSelected: i, isIndeterminate: a, isDisabled: o, onChange: s, ...c } = e, l = a === !0 ? "indeterminate" : !!i;
|
|
316
|
+
return /* @__PURE__ */ m("span", {
|
|
317
|
+
...r ? { "data-react-aria-prevent-focus": !0 } : void 0,
|
|
318
|
+
onClick: (e) => e.stopPropagation(),
|
|
319
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
320
|
+
className: t ?? "flex h-full min-h-full items-center justify-center",
|
|
321
|
+
children: /* @__PURE__ */ m(n, {
|
|
322
|
+
checked: l,
|
|
323
|
+
disabled: o,
|
|
324
|
+
onCheckedChange: s,
|
|
325
|
+
...c
|
|
326
|
+
})
|
|
187
327
|
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
328
|
+
}
|
|
329
|
+
B.displayName = "Table.SelectionCheckbox";
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/table/internal/TableBodyCellRenderer.tsx
|
|
332
|
+
function V({ cell: e, state: t, resizeState: n }) {
|
|
333
|
+
let r = f(null), { gridCellProps: i } = T({ node: e }, t, r), { isFocusVisible: a, focusProps: o } = w(), l = c(z), u = s((e) => {
|
|
334
|
+
l === "interaction" && (e.key !== " " && e.key !== "Enter" || e.stopPropagation());
|
|
335
|
+
}, [l]), { onKeyDownCapture: d, ...p } = i, h = s((e) => {
|
|
336
|
+
[
|
|
337
|
+
"ArrowLeft",
|
|
338
|
+
"ArrowRight",
|
|
339
|
+
"ArrowUp",
|
|
340
|
+
"ArrowDown"
|
|
341
|
+
].includes(e.key) || d?.(e);
|
|
342
|
+
}, [d]), g = ce({ key: e.parentKey ?? e.key }, t), _ = t.collection.columns[e.index ?? 0]?.key ?? null, v = _ ? n?.columnWidths?.get?.(_) : void 0;
|
|
343
|
+
return e.props?.isSelectionCell ? /* @__PURE__ */ m("td", {
|
|
344
|
+
...C(p, { onKeyDownCapture: h }, o, { onKeyDown: u }),
|
|
345
|
+
ref: r,
|
|
346
|
+
"data-spark-component": "table-cell",
|
|
347
|
+
"data-table-cell-kind": "selection",
|
|
348
|
+
className: A({ checkbox: !0 }),
|
|
349
|
+
"data-focus-visible": a || void 0,
|
|
350
|
+
children: /* @__PURE__ */ m(B, {
|
|
351
|
+
suppressFocusWalker: l === "grid",
|
|
352
|
+
checkboxProps: g.checkboxProps
|
|
353
|
+
})
|
|
354
|
+
}) : /* @__PURE__ */ m("td", {
|
|
355
|
+
...C(p, { onKeyDownCapture: h }, o, { onKeyDown: u }),
|
|
356
|
+
ref: r,
|
|
357
|
+
"data-spark-component": "table-cell",
|
|
358
|
+
className: A(),
|
|
359
|
+
"data-focus-visible": a || void 0,
|
|
360
|
+
style: v ? { width: v } : void 0,
|
|
361
|
+
children: e.rendered
|
|
193
362
|
});
|
|
194
363
|
}
|
|
195
|
-
|
|
364
|
+
V.displayName = "Table.BodyCellRenderer";
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/table/internal/TableBodyRowRenderer.tsx
|
|
367
|
+
function H(e) {
|
|
368
|
+
if (e) return (t) => {
|
|
369
|
+
we(_(t.nativeEvent)) || e(t);
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
function U({ item: e, state: t, resizeState: n }) {
|
|
373
|
+
let r = f(null), { rowProps: a, isSelected: o } = ie({ node: e }, t, r), { isFocusVisible: s, focusProps: c } = w(), { 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");
|
|
374
|
+
return /* @__PURE__ */ m("tr", {
|
|
375
|
+
...C(g, c),
|
|
376
|
+
onPointerDown: H(u),
|
|
377
|
+
onMouseDown: H(d),
|
|
378
|
+
onPointerUp: H(p),
|
|
379
|
+
onPointerCancel: H(h),
|
|
380
|
+
onClick: H(l),
|
|
381
|
+
ref: r,
|
|
382
|
+
"data-spark-component": "table-row",
|
|
383
|
+
"data-selected": o || void 0,
|
|
384
|
+
"data-focus-visible": s || void 0,
|
|
385
|
+
className: _,
|
|
386
|
+
tabIndex: -1,
|
|
387
|
+
children: [...e.childNodes].map((e) => /* @__PURE__ */ m(V, {
|
|
388
|
+
cell: e,
|
|
389
|
+
state: t,
|
|
390
|
+
resizeState: n
|
|
391
|
+
}, e.key))
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
U.displayName = "Table.BodyRowRenderer";
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/table/internal/TableColumnResizer.tsx
|
|
397
|
+
function W({ column: e, ariaLabel: t, resizeState: n, resizeCallbacks: r }) {
|
|
398
|
+
let a = f(null), { resizerProps: o, inputProps: s, isResizing: c } = oe({
|
|
399
|
+
column: e,
|
|
400
|
+
"aria-label": t ?? "Resize column",
|
|
401
|
+
onResizeStart: r.onResizeStart,
|
|
402
|
+
onResize: r.onResize,
|
|
403
|
+
onResizeEnd: r.onResizeEnd
|
|
404
|
+
}, n, a);
|
|
405
|
+
return /* @__PURE__ */ m("div", {
|
|
406
|
+
role: "presentation",
|
|
407
|
+
className: i("cursor-col-resize absolute inset-y-lg right-0 flex w-lg items-center justify-center", "after:block after:h-full after:w-[2px] after:bg-outline", "has-[input:focus-visible]:after:u-outline has-[input:focus-visible]:after:outline-offset-2"),
|
|
408
|
+
"data-resizable-direction": "both",
|
|
409
|
+
...o,
|
|
410
|
+
children: /* @__PURE__ */ m("input", {
|
|
411
|
+
ref: a,
|
|
412
|
+
disabled: !c,
|
|
413
|
+
...s
|
|
414
|
+
})
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
W.displayName = "Table.ColumnResizer";
|
|
418
|
+
//#endregion
|
|
419
|
+
//#region src/table/internal/TableHeaderSelectionCheckbox.tsx
|
|
420
|
+
function G({ state: e }) {
|
|
421
|
+
let { checkboxProps: t } = se(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) => {
|
|
422
|
+
(e.key === " " || e.key === "Enter") && e.stopPropagation(), e.key === "Enter" && (e.preventDefault(), t.isDisabled || g?.(!d));
|
|
423
|
+
};
|
|
424
|
+
return /* @__PURE__ */ m(B, { checkboxProps: {
|
|
425
|
+
..._,
|
|
426
|
+
isSelected: d,
|
|
427
|
+
isIndeterminate: f,
|
|
428
|
+
onChange: g,
|
|
429
|
+
onKeyDown: v
|
|
430
|
+
} });
|
|
431
|
+
}
|
|
432
|
+
G.displayName = "Table.HeaderSelectionCheckbox";
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region src/table/internal/TableColumnHeader.tsx
|
|
435
|
+
function Te({ column: t, state: n, resizeState: r, resizeCallbacks: a, isLastColumnInRow: o = !1 }) {
|
|
436
|
+
let s = f(null), { resizeColumnAriaLabel: c } = E(), { columnHeaderProps: l } = ne({ node: t }, n, s), { isFocusVisible: u, focusProps: d } = w(), p = t.props?.allowsResizing !== !1 && !o, g = r?.columnWidths?.get?.(t.key), _ = !!(r && p);
|
|
437
|
+
if (t.props?.isSelectionCell) return /* @__PURE__ */ m("th", {
|
|
438
|
+
...l,
|
|
439
|
+
ref: s,
|
|
440
|
+
role: "columnheader",
|
|
441
|
+
className: k({ checkbox: !0 }),
|
|
442
|
+
"data-spark-component": "table-column",
|
|
443
|
+
"data-table-selection-columnheader": !0,
|
|
444
|
+
"data-focus-visible": u || void 0,
|
|
445
|
+
children: /* @__PURE__ */ m(G, { state: n })
|
|
446
|
+
});
|
|
447
|
+
let v = !!t.props?.allowsSorting, y = n.sortDescriptor?.column === t.key, b = n.sortDescriptor?.direction ?? "ascending", x = m(y ? b === "descending" ? le : ue : de, {}), S = (e) => {
|
|
448
|
+
v && (e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.stopPropagation(), n.sort?.(t.key)));
|
|
449
|
+
};
|
|
450
|
+
return /* @__PURE__ */ h("th", {
|
|
451
|
+
...C(l, d),
|
|
452
|
+
ref: s,
|
|
453
|
+
role: "columnheader",
|
|
454
|
+
className: i(k({ resizable: _ })),
|
|
455
|
+
style: g ? { width: g } : void 0,
|
|
456
|
+
"data-spark-component": "table-column",
|
|
457
|
+
"data-focus-visible": u || void 0,
|
|
458
|
+
onKeyDown: S,
|
|
459
|
+
children: [/* @__PURE__ */ h("div", {
|
|
460
|
+
className: he(),
|
|
461
|
+
children: [/* @__PURE__ */ m("button", {
|
|
462
|
+
type: "button",
|
|
463
|
+
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"),
|
|
464
|
+
onKeyDown: S,
|
|
465
|
+
children: /* @__PURE__ */ m("span", {
|
|
466
|
+
className: "min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",
|
|
467
|
+
children: t.rendered
|
|
468
|
+
})
|
|
469
|
+
}), v ? /* @__PURE__ */ m("span", {
|
|
470
|
+
"aria-hidden": "true",
|
|
471
|
+
className: i("shrink-0 opacity-dim-2 group-hover/column:opacity-100", y && "opacity-100"),
|
|
472
|
+
children: /* @__PURE__ */ m(e, {
|
|
473
|
+
size: "sm",
|
|
474
|
+
children: x
|
|
475
|
+
})
|
|
476
|
+
}) : null]
|
|
477
|
+
}), r && p ? /* @__PURE__ */ m(W, {
|
|
478
|
+
column: t,
|
|
479
|
+
ariaLabel: typeof c == "function" ? c(t) : c,
|
|
480
|
+
resizeState: r,
|
|
481
|
+
resizeCallbacks: a
|
|
482
|
+
}) : null]
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
Te.displayName = "Table.ColumnHeader";
|
|
486
|
+
//#endregion
|
|
487
|
+
//#region src/table/internal/TableHeaderRowRenderer.tsx
|
|
488
|
+
function Ee({ item: e, state: t, resizeState: n, resizeCallbacks: r }) {
|
|
489
|
+
let i = f(null), { rowProps: a } = re({ node: e }, t, i), o = [...e.childNodes];
|
|
490
|
+
return /* @__PURE__ */ m("tr", {
|
|
491
|
+
...a,
|
|
492
|
+
ref: i,
|
|
493
|
+
children: o.map((e, i) => /* @__PURE__ */ m(Te, {
|
|
494
|
+
column: e,
|
|
495
|
+
state: t,
|
|
496
|
+
resizeState: n,
|
|
497
|
+
resizeCallbacks: r,
|
|
498
|
+
isLastColumnInRow: i === o.length - 1
|
|
499
|
+
}, e.key))
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
Ee.displayName = "Table.HeaderRowRenderer";
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/table/internal/TableRoot.tsx
|
|
505
|
+
function De({ className: e, children: t, ...n }) {
|
|
506
|
+
let r = f(null), a = pe(), o = n.selectionMode === "multiple", s = ee({
|
|
507
|
+
...n,
|
|
508
|
+
showSelectionCheckboxes: n.selectionMode === "multiple",
|
|
509
|
+
children: t
|
|
510
|
+
}), c = S({ tableWidth: a.tableWidth }, s), l = a.isResizable && n.allowsResizing !== !1 ? c : null, { gridProps: u } = te({ ...n }, s, r), d = s.collection.headerRows, p = [...s.collection.body.childNodes], _ = s.collection.body.props?.renderEmptyState, v = s.collection.columns.length || 1, y = p.length > 0 || !!_, { rowGroupProps: b } = ae(), { rowGroupProps: x } = ae(), { gridProps: w, keyboardMode: T } = ye({
|
|
511
|
+
ref: r,
|
|
512
|
+
gridProps: u,
|
|
513
|
+
onKeyDownCapture: n.onKeyDownCapture,
|
|
514
|
+
onFocusCapture: n.onFocusCapture
|
|
515
|
+
});
|
|
516
|
+
return /* @__PURE__ */ m(z.Provider, {
|
|
517
|
+
value: T,
|
|
518
|
+
children: /* @__PURE__ */ h("table", {
|
|
519
|
+
...C(w, g(n, { global: !0 })),
|
|
520
|
+
ref: r,
|
|
521
|
+
"data-spark-component": "table",
|
|
522
|
+
className: i("default:w-full", o ? "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),
|
|
523
|
+
children: [/* @__PURE__ */ m("thead", {
|
|
524
|
+
...b,
|
|
525
|
+
"data-spark-component": "table-header",
|
|
526
|
+
children: d.map((e) => /* @__PURE__ */ m(Ee, {
|
|
527
|
+
item: e,
|
|
528
|
+
state: s,
|
|
529
|
+
resizeState: l,
|
|
530
|
+
resizeCallbacks: {
|
|
531
|
+
onResizeStart: n.onResizeStart,
|
|
532
|
+
onResize: n.onResize,
|
|
533
|
+
onResizeEnd: n.onResizeEnd
|
|
534
|
+
}
|
|
535
|
+
}, e.key))
|
|
536
|
+
}), /* @__PURE__ */ h("tbody", {
|
|
537
|
+
...x,
|
|
538
|
+
"data-spark-component": "table-body",
|
|
539
|
+
children: [
|
|
540
|
+
y ? /* @__PURE__ */ m("tr", {
|
|
541
|
+
"aria-hidden": "true",
|
|
542
|
+
className: ge(),
|
|
543
|
+
role: "presentation",
|
|
544
|
+
"data-spark-component": "table-body-spacer",
|
|
545
|
+
children: /* @__PURE__ */ m("td", {
|
|
546
|
+
colSpan: v,
|
|
547
|
+
role: "presentation"
|
|
548
|
+
})
|
|
549
|
+
}) : null,
|
|
550
|
+
p.length === 0 && _ ? /* @__PURE__ */ m("tr", {
|
|
551
|
+
"data-empty": !0,
|
|
552
|
+
children: /* @__PURE__ */ m("td", {
|
|
553
|
+
colSpan: v,
|
|
554
|
+
children: _({ isEmpty: !0 })
|
|
555
|
+
})
|
|
556
|
+
}) : null,
|
|
557
|
+
p.map((e) => /* @__PURE__ */ m(U, {
|
|
558
|
+
item: e,
|
|
559
|
+
state: s,
|
|
560
|
+
resizeState: l
|
|
561
|
+
}, e.key))
|
|
562
|
+
]
|
|
563
|
+
})]
|
|
564
|
+
})
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
De.displayName = "Table.Grid.Inner";
|
|
568
|
+
//#endregion
|
|
569
|
+
//#region src/table/internal/TableGrid.tsx
|
|
570
|
+
function Oe(e) {
|
|
571
|
+
return typeof e == "number" ? `${e}px` : e;
|
|
572
|
+
}
|
|
573
|
+
function ke({ "aria-label": e, "aria-labelledby": t, className: n, children: r }) {
|
|
574
|
+
let { allowsResizing: i = !0, maxHeight: a, onResizeStart: o, onResize: s, onResizeEnd: c, onKeyDownCapture: l, sortDescriptor: u, onSortChange: d, className: f, ...p } = E(), h = a == null ? void 0 : { maxHeight: Oe(a) }, g = n ?? f, _ = {
|
|
575
|
+
...p,
|
|
576
|
+
...e != null && { "aria-label": e },
|
|
577
|
+
...t != null && { "aria-labelledby": t },
|
|
578
|
+
sortDescriptor: u,
|
|
579
|
+
onSortChange: d,
|
|
580
|
+
onKeyDownCapture: l,
|
|
581
|
+
className: g
|
|
582
|
+
}, v = De;
|
|
583
|
+
return i ? /* @__PURE__ */ m(O, {
|
|
584
|
+
className: g,
|
|
585
|
+
style: h,
|
|
586
|
+
onResizeStart: o,
|
|
587
|
+
onResize: s,
|
|
588
|
+
onResizeEnd: c,
|
|
589
|
+
children: /* @__PURE__ */ m(v, {
|
|
590
|
+
..._,
|
|
591
|
+
children: r
|
|
592
|
+
})
|
|
593
|
+
}) : /* @__PURE__ */ m("div", {
|
|
594
|
+
className: "relative w-full overflow-auto",
|
|
595
|
+
style: h,
|
|
596
|
+
children: /* @__PURE__ */ m(v, {
|
|
597
|
+
..._,
|
|
598
|
+
children: r
|
|
599
|
+
})
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
ke.displayName = "Table.Grid";
|
|
603
|
+
//#endregion
|
|
604
|
+
//#region src/table/TableBody.tsx
|
|
605
|
+
function K(e) {
|
|
606
|
+
return /* @__PURE__ */ m(b, { ...e });
|
|
607
|
+
}
|
|
608
|
+
K.displayName = "Table.Body", K.getCollectionNode = b.getCollectionNode;
|
|
196
609
|
//#endregion
|
|
197
610
|
//#region src/table/TableBulkBar.tsx
|
|
198
|
-
var
|
|
199
|
-
function
|
|
200
|
-
let e =
|
|
611
|
+
var Ae = o(null);
|
|
612
|
+
function q() {
|
|
613
|
+
let e = c(Ae);
|
|
201
614
|
if (!e) throw Error("Table.BulkBar subcomponents must be used within Table.BulkBar");
|
|
202
615
|
return e;
|
|
203
616
|
}
|
|
204
|
-
function
|
|
205
|
-
let { selectedCount:
|
|
206
|
-
selectedCount:
|
|
207
|
-
totalCount:
|
|
208
|
-
onClearSelection:
|
|
209
|
-
onSelectAll:
|
|
210
|
-
hasMultiplePages:
|
|
617
|
+
function je({ children: e, className: t, rootProps: n, ...r }) {
|
|
618
|
+
let { selectedCount: a, totalCount: o, onClearSelection: s, onSelectAll: c, hasMultiplePages: l } = E(), u = {
|
|
619
|
+
selectedCount: a,
|
|
620
|
+
totalCount: o,
|
|
621
|
+
onClearSelection: s,
|
|
622
|
+
onSelectAll: c,
|
|
623
|
+
hasMultiplePages: l
|
|
211
624
|
};
|
|
212
|
-
return /* @__PURE__ */ m(
|
|
213
|
-
value:
|
|
625
|
+
return /* @__PURE__ */ m(Ae.Provider, {
|
|
626
|
+
value: u,
|
|
214
627
|
children: /* @__PURE__ */ m("div", {
|
|
215
628
|
role: "toolbar",
|
|
216
|
-
"aria-label": "Table bulk actions",
|
|
629
|
+
"aria-label": r["aria-label"] ?? "Table bulk actions",
|
|
217
630
|
"data-spark-component": "table-bulk-bar",
|
|
218
631
|
className: i("gap-lg min-h-sz-64 flex w-full flex-wrap items-center justify-between", "rounded-lg", "bg-support-container text-on-support-container p-lg", t),
|
|
632
|
+
...n,
|
|
219
633
|
children: e
|
|
220
634
|
})
|
|
221
635
|
});
|
|
222
636
|
}
|
|
223
|
-
function
|
|
224
|
-
return
|
|
637
|
+
function Me({ children: e }) {
|
|
638
|
+
return q(), /* @__PURE__ */ m("span", {
|
|
225
639
|
className: "text-body-1 font-bold",
|
|
226
640
|
children: e
|
|
227
641
|
});
|
|
228
642
|
}
|
|
229
|
-
function
|
|
230
|
-
let { selectedCount: a, onClearSelection: o, hasMultiplePages: s } =
|
|
643
|
+
function J({ className: e, children: n, ...r }) {
|
|
644
|
+
let { selectedCount: a, onClearSelection: o, hasMultiplePages: s } = q();
|
|
231
645
|
return s ? /* @__PURE__ */ m(t, {
|
|
232
646
|
size: "sm",
|
|
233
647
|
design: "ghost",
|
|
@@ -240,8 +654,8 @@ function W({ className: e, children: n, ...r }) {
|
|
|
240
654
|
children: n
|
|
241
655
|
}) : null;
|
|
242
656
|
}
|
|
243
|
-
function
|
|
244
|
-
let { selectedCount: a, totalCount: o, onSelectAll: s, hasMultiplePages: c } =
|
|
657
|
+
function Ne({ className: e, children: n, ...r }) {
|
|
658
|
+
let { selectedCount: a, totalCount: o, onSelectAll: s, hasMultiplePages: c } = q();
|
|
245
659
|
return c ? /* @__PURE__ */ m(t, {
|
|
246
660
|
size: "sm",
|
|
247
661
|
design: "ghost",
|
|
@@ -254,182 +668,126 @@ function G({ className: e, children: n, ...r }) {
|
|
|
254
668
|
children: n
|
|
255
669
|
}) : null;
|
|
256
670
|
}
|
|
257
|
-
|
|
258
|
-
var
|
|
259
|
-
|
|
671
|
+
je.displayName = "Table.BulkBar";
|
|
672
|
+
var Pe = je;
|
|
673
|
+
Pe.displayName = "Table.BulkBar", Me.displayName = "Table.BulkBarSelectedCount", J.displayName = "Table.BulkBarClearButton", Ne.displayName = "Table.BulkBarSelectAllButton";
|
|
260
674
|
//#endregion
|
|
261
675
|
//#region src/table/TableCell.tsx
|
|
262
|
-
function
|
|
263
|
-
|
|
264
|
-
O(e.target) && e.stopPropagation();
|
|
265
|
-
};
|
|
266
|
-
return /* @__PURE__ */ m(_, {
|
|
267
|
-
"data-spark-component": "table-cell",
|
|
268
|
-
className: i(ue({ checkbox: t }), e),
|
|
269
|
-
onClick: (e) => {
|
|
270
|
-
o(e), n?.(e);
|
|
271
|
-
},
|
|
272
|
-
onPointerDown: (e) => {
|
|
273
|
-
o(e), r?.(e);
|
|
274
|
-
},
|
|
275
|
-
...a
|
|
276
|
-
});
|
|
676
|
+
function Y(e) {
|
|
677
|
+
return /* @__PURE__ */ m(y, { ...e });
|
|
277
678
|
}
|
|
278
|
-
|
|
679
|
+
Y.displayName = "Table.Cell", Y.getCollectionNode = y.getCollectionNode;
|
|
279
680
|
//#endregion
|
|
280
681
|
//#region src/table/TableColumn.tsx
|
|
281
|
-
function
|
|
282
|
-
|
|
283
|
-
return /* @__PURE__ */ m(b, {
|
|
284
|
-
"data-spark-component": "table-column",
|
|
285
|
-
className: i(R(), t),
|
|
286
|
-
minWidth: o,
|
|
287
|
-
...s,
|
|
288
|
-
children: ie(l, (t, o) => {
|
|
289
|
-
let { allowsSorting: l, sortDirection: u } = o, d = (e) => {
|
|
290
|
-
O(e.target) && e.stopPropagation();
|
|
291
|
-
};
|
|
292
|
-
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ h(ee, {
|
|
293
|
-
role: "presentation",
|
|
294
|
-
tabIndex: -1,
|
|
295
|
-
className: i("border-transparent", "focus-visible:u-outline focus-visible:outline-offset-2", "gap-sm box-border flex flex-1 items-center"),
|
|
296
|
-
onClick: d,
|
|
297
|
-
onPointerDown: d,
|
|
298
|
-
children: [/* @__PURE__ */ h("div", {
|
|
299
|
-
className: "gap-md flex min-w-0 shrink items-center",
|
|
300
|
-
children: [/* @__PURE__ */ m("p", {
|
|
301
|
-
className: "truncate",
|
|
302
|
-
children: n
|
|
303
|
-
}), r && /* @__PURE__ */ m("div", {
|
|
304
|
-
className: "inline-flex shrink-0 items-center",
|
|
305
|
-
children: typeof t == "function" ? t({
|
|
306
|
-
...o,
|
|
307
|
-
defaultChildren: void 0
|
|
308
|
-
}) : t
|
|
309
|
-
})]
|
|
310
|
-
}), l && /* @__PURE__ */ m("span", {
|
|
311
|
-
className: "size-sz-32 ml-auto inline-flex shrink-0 cursor-pointer items-center justify-center rounded-full",
|
|
312
|
-
children: /* @__PURE__ */ m(e, {
|
|
313
|
-
size: "sm",
|
|
314
|
-
className: i(u === "descending" && "rotate-180"),
|
|
315
|
-
children: m(u ? E : oe, {})
|
|
316
|
-
})
|
|
317
|
-
})]
|
|
318
|
-
}), c && a && !s.width && /* @__PURE__ */ m(x, { className: i("z-raised absolute top-0 right-[-8px]", "group-last/column:hidden", "h-full w-[16px] touch-none", "mx-0 cursor-col-resize", "data-focus-visible:after:u-outline", "data-resizing:after:bg-outline-high after:transition-transform after:duration-200 data-resizing:after:scale-125", "after:h-sz-32 after:bg-outline after:absolute after:top-1/2 after:left-1/2 after:w-[2px] after:-translate-y-1/2") })] });
|
|
319
|
-
})
|
|
320
|
-
});
|
|
682
|
+
function X({ label: e, allowsResizing: t = !0, ...n }) {
|
|
683
|
+
return null;
|
|
321
684
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
if (!e) return /* @__PURE__ */ m(Y, {});
|
|
348
|
-
let { collection: t, selectionManager: r } = e, i = r.selectedKeys, a = t, o = a.body, c = o == null ? new Set(t.getKeys()) : new Set([...a.getChildren(o.key)].map((e) => e.key)), l = i === "all" ? c : i, u = [...c].filter((e) => l.has(e)).length, d = c.size;
|
|
349
|
-
return /* @__PURE__ */ m("span", {
|
|
350
|
-
onClick: (e) => e.stopPropagation(),
|
|
351
|
-
onPointerDown: (e) => e.stopPropagation(),
|
|
352
|
-
className: "flex h-full min-h-full items-center justify-center",
|
|
353
|
-
children: /* @__PURE__ */ m(n, {
|
|
354
|
-
checked: u > 0 && u < d ? "indeterminate" : d > 0 && u === d,
|
|
355
|
-
onCheckedChange: () => {
|
|
356
|
-
r.toggleSelectAll();
|
|
685
|
+
X.displayName = "Table.Column", X.getCollectionNode = function* (e, t) {
|
|
686
|
+
let n = e.title ?? e.label ?? e.children ?? null, r = e.textValue || (typeof n == "string" ? n : "") || e["aria-label"], i = yield {
|
|
687
|
+
type: "column",
|
|
688
|
+
key: e.id ?? null,
|
|
689
|
+
hasChildNodes: !!e.childColumns || !!e.title && a.Children.count(e.children) > 0,
|
|
690
|
+
rendered: n,
|
|
691
|
+
textValue: r,
|
|
692
|
+
props: {
|
|
693
|
+
...e,
|
|
694
|
+
title: e.title ?? e.label,
|
|
695
|
+
allowsResizing: e.allowsResizing
|
|
696
|
+
},
|
|
697
|
+
*childNodes() {
|
|
698
|
+
if (e.childColumns) for (let t of e.childColumns) yield {
|
|
699
|
+
type: "column",
|
|
700
|
+
value: t
|
|
701
|
+
};
|
|
702
|
+
else if (e.title) {
|
|
703
|
+
let t = [];
|
|
704
|
+
a.Children.forEach(e.children, (e) => {
|
|
705
|
+
t.push({
|
|
706
|
+
type: "column",
|
|
707
|
+
element: e
|
|
708
|
+
});
|
|
709
|
+
}), yield* t;
|
|
357
710
|
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
711
|
+
},
|
|
712
|
+
shouldInvalidate(e) {
|
|
713
|
+
return o(e), !1;
|
|
714
|
+
}
|
|
715
|
+
}, o = (e) => {
|
|
716
|
+
for (let t of i) t.hasChildNodes || e.columns.push(t);
|
|
717
|
+
};
|
|
718
|
+
o(t);
|
|
719
|
+
};
|
|
362
720
|
//#endregion
|
|
363
721
|
//#region src/table/TableHeader.tsx
|
|
364
|
-
function Z(
|
|
365
|
-
|
|
366
|
-
return /* @__PURE__ */ h(C, {
|
|
367
|
-
"data-spark-component": "table-header",
|
|
368
|
-
className: i([
|
|
369
|
-
r && "z-raised sticky top-0",
|
|
370
|
-
"text-on-neutral-container text-body-1 font-semibold",
|
|
371
|
-
"after:pt-md after:block after:size-0"
|
|
372
|
-
], e),
|
|
373
|
-
columns: t,
|
|
374
|
-
...a,
|
|
375
|
-
children: [
|
|
376
|
-
c && /* @__PURE__ */ m(b, {
|
|
377
|
-
width: 20,
|
|
378
|
-
minWidth: 20,
|
|
379
|
-
className: "w-sz-20 min-w-sz-20 box-border"
|
|
380
|
-
}),
|
|
381
|
-
o === "toggle" && /* @__PURE__ */ m(b, {
|
|
382
|
-
width: 56,
|
|
383
|
-
minWidth: 56,
|
|
384
|
-
className: i(R()),
|
|
385
|
-
children: s === "multiple" && /* @__PURE__ */ m(X, {})
|
|
386
|
-
}),
|
|
387
|
-
t == null ? n : /* @__PURE__ */ m(y, {
|
|
388
|
-
items: t,
|
|
389
|
-
children: n
|
|
390
|
-
})
|
|
391
|
-
]
|
|
392
|
-
});
|
|
722
|
+
function Z(e) {
|
|
723
|
+
return /* @__PURE__ */ m(x, { ...e });
|
|
393
724
|
}
|
|
394
|
-
Z.displayName = "Table.Header";
|
|
725
|
+
Z.displayName = "Table.Header", Z.getCollectionNode = x.getCollectionNode;
|
|
395
726
|
//#endregion
|
|
396
727
|
//#region src/table/TableRow.tsx
|
|
397
|
-
function Q(
|
|
398
|
-
|
|
399
|
-
return /* @__PURE__ */ h(te, {
|
|
400
|
-
id: e,
|
|
401
|
-
"data-spark-component": "table-row",
|
|
402
|
-
className: i("group/row", "h-sz-80", "group/row text-on-surface relative cursor-default select-none", "[-webkit-tap-highlight-color:transparent]", "data-focus-visible:u-outline-inset outline-none data-focus-visible:outline-dashed", "data-react-aria-pressable:hover:bg-surface-hovered data-react-aria-pressable:pressed:bg-surface-hovered", "data-selected:bg-support-container data-selected:text-on-support-container", "data-selected:hover:bg-support-container-hovered data-selected:data-pressed:bg-support-container-hovered", "data-disabled:text-on-surface/dim-3", "data-href:cursor-pointer", r),
|
|
403
|
-
columns: t,
|
|
404
|
-
...a,
|
|
405
|
-
children: [
|
|
406
|
-
s && /* @__PURE__ */ m(q, { children: /* @__PURE__ */ m(g, {
|
|
407
|
-
slot: "drag",
|
|
408
|
-
className: "w-sz-15 data-focus-visible:u-outline flex items-center justify-center text-center outline-none data-[focus-visible]:rounded-md",
|
|
409
|
-
children: "≡"
|
|
410
|
-
}) }),
|
|
411
|
-
o === "toggle" && /* @__PURE__ */ m(q, {
|
|
412
|
-
checkbox: !0,
|
|
413
|
-
children: /* @__PURE__ */ m(Y, {})
|
|
414
|
-
}),
|
|
415
|
-
t == null ? n : /* @__PURE__ */ m(y, {
|
|
416
|
-
items: t,
|
|
417
|
-
children: n
|
|
418
|
-
})
|
|
419
|
-
]
|
|
420
|
-
});
|
|
728
|
+
function Q(e) {
|
|
729
|
+
return null;
|
|
421
730
|
}
|
|
422
|
-
Q.displayName = "Table.Row"
|
|
731
|
+
Q.displayName = "Table.Row", Q.getCollectionNode = function* (e, t) {
|
|
732
|
+
let { children: n, textValue: r, UNSTABLE_childItems: i } = e;
|
|
733
|
+
yield {
|
|
734
|
+
type: "item",
|
|
735
|
+
key: e.id ?? null,
|
|
736
|
+
props: e,
|
|
737
|
+
textValue: r,
|
|
738
|
+
"aria-label": e["aria-label"],
|
|
739
|
+
hasChildNodes: !0,
|
|
740
|
+
*childNodes() {
|
|
741
|
+
if (t.showDragButtons && (yield {
|
|
742
|
+
type: "cell",
|
|
743
|
+
key: "header-drag",
|
|
744
|
+
props: { isDragButtonCell: !0 }
|
|
745
|
+
}), t.showSelectionCheckboxes && t.selectionMode !== "none" && (yield {
|
|
746
|
+
type: "cell",
|
|
747
|
+
key: "header",
|
|
748
|
+
props: { isSelectionCell: !0 }
|
|
749
|
+
}), typeof n == "function") {
|
|
750
|
+
for (let e of t.columns) yield {
|
|
751
|
+
type: "cell",
|
|
752
|
+
element: n(e.key),
|
|
753
|
+
key: e.key
|
|
754
|
+
};
|
|
755
|
+
if (i) for (let e of i) yield {
|
|
756
|
+
type: "item",
|
|
757
|
+
value: e
|
|
758
|
+
};
|
|
759
|
+
} else {
|
|
760
|
+
let e = [], r = [], i = 0;
|
|
761
|
+
if (a.Children.forEach(n, (n) => {
|
|
762
|
+
if (n) if (n.type === Q) {
|
|
763
|
+
if (e.length < t.columns.length) throw Error("All of a Row's child Cells must be positioned before any child Rows.");
|
|
764
|
+
r.push({
|
|
765
|
+
type: "item",
|
|
766
|
+
element: n
|
|
767
|
+
});
|
|
768
|
+
} else e.push({
|
|
769
|
+
type: "cell",
|
|
770
|
+
element: n
|
|
771
|
+
}), i += n.props?.colSpan ?? 1;
|
|
772
|
+
}), i !== t.columns.length) throw Error(`Cell count must match column count. Found ${i} cells and ${t.columns.length} columns.`);
|
|
773
|
+
yield* e, yield* r;
|
|
774
|
+
}
|
|
775
|
+
},
|
|
776
|
+
shouldInvalidate(e) {
|
|
777
|
+
return e.columns.length !== t.columns.length || e.columns.some((e, n) => e.key !== t.columns[n].key) || e.showSelectionCheckboxes !== t.showSelectionCheckboxes || e.showDragButtons !== t.showDragButtons || e.selectionMode !== t.selectionMode;
|
|
778
|
+
}
|
|
779
|
+
};
|
|
780
|
+
};
|
|
423
781
|
//#endregion
|
|
424
782
|
//#region src/table/useTableSort.ts
|
|
425
|
-
function
|
|
783
|
+
function Fe(e, t, n, r) {
|
|
426
784
|
let i = e[n], a = t[n];
|
|
427
785
|
if (i === a) return 0;
|
|
428
786
|
let o;
|
|
429
787
|
return o = typeof i == "number" && typeof a == "number" ? i < a ? -1 : 1 : String(i).localeCompare(String(a)), r === "descending" ? -o : o;
|
|
430
788
|
}
|
|
431
|
-
function
|
|
432
|
-
let { initialSort: n, compare: r } = t, [i, a] =
|
|
789
|
+
function Ie(e, t = {}) {
|
|
790
|
+
let { initialSort: n, compare: r } = t, [i, a] = p(() => n ? {
|
|
433
791
|
column: n.column,
|
|
434
792
|
direction: n.direction
|
|
435
793
|
} : {
|
|
@@ -440,10 +798,10 @@ function fe(e, t = {}) {
|
|
|
440
798
|
sortDescriptor: i,
|
|
441
799
|
onSortChange: a,
|
|
442
800
|
setSortDescriptor: a,
|
|
443
|
-
sortedItems:
|
|
801
|
+
sortedItems: d(() => {
|
|
444
802
|
let t = i.column;
|
|
445
803
|
if (!t) return [...e];
|
|
446
|
-
let n = r ??
|
|
804
|
+
let n = r ?? Fe, a = i.direction ?? "ascending";
|
|
447
805
|
return [...e].sort((e, r) => n(e, r, t, a));
|
|
448
806
|
}, [
|
|
449
807
|
e,
|
|
@@ -455,28 +813,28 @@ function fe(e, t = {}) {
|
|
|
455
813
|
}
|
|
456
814
|
//#endregion
|
|
457
815
|
//#region src/table/useTablePagination.ts
|
|
458
|
-
function
|
|
459
|
-
let { pageSize: n, initialPage: r = 1, getId: i } = t, [a, o] =
|
|
460
|
-
|
|
461
|
-
o((e) => e < 1 ? 1 : e >
|
|
462
|
-
}, [
|
|
816
|
+
function Le(e, t) {
|
|
817
|
+
let { pageSize: n, initialPage: r = 1, getId: i } = t, [a, o] = p(r), [s, c] = p(() => /* @__PURE__ */ new Set()), u = e.length, f = Math.max(1, Math.ceil(u / n));
|
|
818
|
+
l(() => {
|
|
819
|
+
o((e) => e < 1 ? 1 : e > f ? f : e);
|
|
820
|
+
}, [f]);
|
|
463
821
|
let m = a;
|
|
464
|
-
m < 1 ? m = 1 : m >
|
|
465
|
-
let h =
|
|
822
|
+
m < 1 ? m = 1 : m > f && (m = f);
|
|
823
|
+
let h = d(() => {
|
|
466
824
|
let t = (m - 1) * n, r = t + n;
|
|
467
825
|
return e.slice(t, r);
|
|
468
826
|
}, [
|
|
469
827
|
e,
|
|
470
828
|
m,
|
|
471
829
|
n
|
|
472
|
-
]), g =
|
|
830
|
+
]), g = d(() => {
|
|
473
831
|
let t = i ?? ((e) => {
|
|
474
832
|
let t = e.id;
|
|
475
833
|
if (t == null) throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");
|
|
476
834
|
return t;
|
|
477
835
|
});
|
|
478
836
|
return new Set(e.map((e) => t(e)));
|
|
479
|
-
}, [i, e]), _ =
|
|
837
|
+
}, [i, e]), _ = d(() => {
|
|
480
838
|
let e = i ?? ((e) => {
|
|
481
839
|
let t = e.id;
|
|
482
840
|
if (t == null) throw Error("useTablePagination: item.id is undefined. Provide a `getId` option to extract a stable key.");
|
|
@@ -488,13 +846,13 @@ function pe(e, t) {
|
|
|
488
846
|
page: m,
|
|
489
847
|
setPage: o,
|
|
490
848
|
pageItems: h,
|
|
491
|
-
totalItems:
|
|
492
|
-
totalPages:
|
|
849
|
+
totalItems: u,
|
|
850
|
+
totalPages: f,
|
|
493
851
|
allKeys: g,
|
|
494
852
|
selectedKeys: s,
|
|
495
853
|
onSelectionChange: (e) => {
|
|
496
854
|
let t = e === "all" ? new Set(_) : new Set(e);
|
|
497
|
-
|
|
855
|
+
c((e) => {
|
|
498
856
|
let n = new Set(t);
|
|
499
857
|
for (let t of e) _.has(t) || n.add(t);
|
|
500
858
|
return n;
|
|
@@ -504,26 +862,26 @@ function pe(e, t) {
|
|
|
504
862
|
o(e.page);
|
|
505
863
|
},
|
|
506
864
|
clearSelection: () => {
|
|
507
|
-
|
|
865
|
+
c(() => /* @__PURE__ */ new Set());
|
|
508
866
|
}
|
|
509
867
|
};
|
|
510
868
|
}
|
|
511
869
|
//#endregion
|
|
512
870
|
//#region src/table/index.ts
|
|
513
|
-
var $ = Object.assign(
|
|
514
|
-
Grid:
|
|
871
|
+
var $ = Object.assign(D, {
|
|
872
|
+
Grid: ke,
|
|
515
873
|
Header: Z,
|
|
516
|
-
Column:
|
|
517
|
-
Body:
|
|
874
|
+
Column: X,
|
|
875
|
+
Body: K,
|
|
518
876
|
Row: Q,
|
|
519
|
-
Cell:
|
|
520
|
-
BulkBar:
|
|
521
|
-
BulkBarSelectedCount:
|
|
522
|
-
BulkBarClearButton:
|
|
523
|
-
BulkBarSelectAllButton:
|
|
877
|
+
Cell: Y,
|
|
878
|
+
BulkBar: Pe,
|
|
879
|
+
BulkBarSelectedCount: Me,
|
|
880
|
+
BulkBarClearButton: J,
|
|
881
|
+
BulkBarSelectAllButton: Ne
|
|
524
882
|
});
|
|
525
|
-
$.displayName = "Table", Z.displayName = "Table.Header",
|
|
883
|
+
$.displayName = "Table", Z.displayName = "Table.Header", X.displayName = "Table.Column", K.displayName = "Table.Body", Q.displayName = "Table.Row", Y.displayName = "Table.Cell";
|
|
526
884
|
//#endregion
|
|
527
|
-
export { $ as Table, $ as TableWithSubcomponents,
|
|
885
|
+
export { $ as Table, $ as TableWithSubcomponents, Le as useTablePagination, Ie as useTableSort };
|
|
528
886
|
|
|
529
887
|
//# sourceMappingURL=index.mjs.map
|