@spark-ui/components 17.3.2 → 17.4.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.
@@ -5,64 +5,65 @@ 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 { 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";
8
+ import { Cell as y, TableBody as b, TableHeader as x, useTableColumnResizeState as S, useTableState as C } from "@react-stately/table";
9
+ import { mergeProps as w, useFocusRing as T, useTable as ee, useTableCell as E, useTableColumnHeader as te, useTableHeaderRow as D, useTableRow as ne, useTableRowGroup as O } from "react-aria";
10
+ import { useTableColumnResize as re, useTableSelectAllCheckbox as ie, useTableSelectionCheckbox as ae } from "@react-aria/table";
11
+ import { ArrowDown as oe } from "@spark-ui/icons/ArrowDown";
12
+ import { ArrowUp as se } from "@spark-ui/icons/ArrowUp";
13
+ import { Sort as ce } from "@spark-ui/icons/Sort";
14
14
  //#region src/table/internal/TableContext.tsx
15
- var fe = o({
15
+ var le = o({
16
16
  isResizable: !1,
17
17
  tableWidth: 0
18
18
  });
19
- function pe() {
20
- return c(fe);
19
+ function ue() {
20
+ return c(le);
21
21
  }
22
- var me = o({
22
+ var de = o({
23
23
  selectedCount: 0,
24
24
  onClearSelection: () => {}
25
25
  });
26
- function E() {
27
- return c(me);
26
+ function k() {
27
+ return c(de);
28
28
  }
29
29
  //#endregion
30
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,
31
+ function fe({ 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
+ let x = 0;
33
+ n === "all" ? x = a ?? 0 : n instanceof Set ? x = n.size : n && (x = new Set(n).size);
34
+ let S = s ?? (() => r?.(/* @__PURE__ */ new Set())), C = {
35
+ ...b,
36
36
  selectedKeys: n,
37
37
  onSelectionChange: r,
38
38
  totalCount: a,
39
39
  hasMultiplePages: o,
40
40
  onSelectAll: c,
41
- selectedCount: b,
42
- onClearSelection: x,
41
+ selectedCount: x,
42
+ onClearSelection: S,
43
43
  allowsResizing: l,
44
44
  resizeColumnAriaLabel: u,
45
45
  maxHeight: d,
46
- onResizeStart: f,
47
- onResize: p,
48
- onResizeEnd: h,
49
- onKeyDownCapture: g,
50
- sortDescriptor: _,
51
- onSortChange: v,
46
+ stickyHeader: f,
47
+ onResizeStart: p,
48
+ onResize: h,
49
+ onResizeEnd: g,
50
+ onKeyDownCapture: _,
51
+ sortDescriptor: v,
52
+ onSortChange: y,
52
53
  className: t
53
54
  };
54
- return /* @__PURE__ */ m(me.Provider, {
55
- value: S,
55
+ return /* @__PURE__ */ m(de.Provider, {
56
+ value: C,
56
57
  children: /* @__PURE__ */ m("div", {
57
58
  className: i("gap-md flex flex-col", t),
58
59
  children: e
59
60
  })
60
61
  });
61
62
  }
62
- D.displayName = "Table";
63
+ fe.displayName = "Table";
63
64
  //#endregion
64
65
  //#region src/table/internal/ResizableTableContainer.tsx
65
- function O({ className: e, children: t, ...n }) {
66
+ function A({ className: e, children: t, ...n }) {
66
67
  let r = f(null), [a, o] = p(0);
67
68
  return u(() => {
68
69
  let e = r.current;
@@ -73,7 +74,7 @@ function O({ className: e, children: t, ...n }) {
73
74
  let e = r.current;
74
75
  e && o(e.clientWidth);
75
76
  }
76
- }), /* @__PURE__ */ m(fe.Provider, {
77
+ }), /* @__PURE__ */ m(le.Provider, {
77
78
  value: {
78
79
  isResizable: !0,
79
80
  tableWidth: a
@@ -87,59 +88,19 @@ function O({ className: e, children: t, ...n }) {
87
88
  })
88
89
  });
89
90
  }
90
- O.displayName = "ResizableTableContainer";
91
+ A.displayName = "ResizableTableContainer";
91
92
  //#endregion
92
- //#region src/table/internal/Table.styles.tsx
93
- var k = r([
94
- "h-sz-64 min-w-sz-64",
95
- "relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container",
96
- "pl-lg pr-lg py-sm text-left outline-none box-border",
97
- "cursor-default",
98
- "data-focus-visible:u-outline data-focus-visible:-outline-offset-2"
99
- ], {
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([
109
- "flex flex-1 justify-between items-center gap-md",
110
- "font-inherit text-left text-inherit",
111
- "whitespace-nowrap text-ellipsis",
112
- "border-transparent",
113
- "data-focus-visible:u-outline data-focus-visible:outline-offset-2"
114
- ], {
115
- variants: {},
116
- defaultVariants: {}
117
- });
118
- r(["empty:italic empty:text-center empty:text-body-2 empty:py-lg"], {
119
- variants: {},
120
- defaultVariants: {}
121
- });
122
- var A = r([
123
- "p-lg outline-none box-border default:overflow-hidden",
124
- "border-b-sm border-outline [tr:last-child>&]:border-b-0",
125
- "[-webkit-tap-highlight-color:transparent]",
126
- "data-focus-visible:u-outline-inset data-focus-visible:outline-dashed"
127
- ], {
128
- variants: { checkbox: { true: ["w-sz-64 py-sm px-0 align-middle"] } },
129
- defaultVariants: { checkbox: !1 }
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"], {
131
- variants: {},
132
- defaultVariants: {}
133
- }), j = "[data-spark-component=\"table-cell\"]";
93
+ //#region src/table/internal/table-keyboard.ts
94
+ var j = "[data-spark-component=\"table-cell\"]";
134
95
  function M(e) {
135
96
  return !e || !(e instanceof Element) ? !1 : !!e.closest("[role=\"combobox\"],select,[data-spark-component=\"dropdown-trigger\"],[data-spark-component=\"combobox-input\"]");
136
97
  }
137
- function _e(e) {
98
+ function pe(e) {
138
99
  if (!e || !(e instanceof Element)) return !1;
139
100
  let t = e.closest("[role=\"combobox\"],[data-spark-component=\"dropdown-trigger\"],[data-spark-component=\"combobox-input\"]");
140
101
  return t ? t.getAttribute("aria-expanded") === "true" : !1;
141
102
  }
142
- var ve = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
103
+ var me = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
143
104
  function N(e) {
144
105
  return !e || !(e instanceof Element) ? null : e.closest(j);
145
106
  }
@@ -147,7 +108,7 @@ function P(e) {
147
108
  return e.getAttribute("data-table-cell-kind") === "selection";
148
109
  }
149
110
  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));
111
+ return Array.from(e.querySelectorAll(me)).filter((t) => !(t === e || t.hasAttribute("disabled") || t.getAttribute("aria-disabled") === "true" || t.getAttribute("hidden") !== null));
151
112
  }
152
113
  function I(e, t) {
153
114
  for (let n of F(e)) {
@@ -164,12 +125,12 @@ function L(e) {
164
125
  let t = Array.from(e.querySelectorAll(j));
165
126
  for (let e of t) I(e, !1);
166
127
  }
167
- function ye({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
128
+ function he({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
168
129
  let [i, a] = p("grid"), o = f("grid"), s = f(null), c = f(!1), u = d(() => {
169
130
  let { onKeyDown: l, ...u } = t, d = (e) => {
170
131
  s.current = e, o.current = "interaction", a("interaction"), I(e, !0);
171
132
  };
172
- return C(u, {
133
+ return w(u, {
173
134
  onKeyDown: (e) => {
174
135
  if (o.current === "interaction" && (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown")) {
175
136
  let e = s.current, t = document.activeElement;
@@ -224,7 +185,7 @@ function ye({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
224
185
  return;
225
186
  }
226
187
  if (o.current === "interaction" && e.key === "Escape") {
227
- if (_e(e.target)) return;
188
+ if (pe(e.target)) return;
228
189
  let t = s.current;
229
190
  if (!t) return;
230
191
  e.preventDefault(), e.stopPropagation(), o.current = "grid", a("grid"), t.focus();
@@ -285,33 +246,73 @@ function ye({ ref: e, gridProps: t, onKeyDownCapture: n, onFocusCapture: r }) {
285
246
  };
286
247
  }
287
248
  //#endregion
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) {
249
+ //#region src/table/internal/Table.styles.tsx
250
+ var R = r([
251
+ "h-sz-64 min-w-sz-64",
252
+ "relative group/column first:rounded-l-xl last:rounded-r-xl bg-neutral-container",
253
+ "pl-lg pr-lg py-sm text-left outline-none box-border",
254
+ "cursor-default",
255
+ "data-focus-visible:u-outline data-focus-visible:-outline-offset-2"
256
+ ], {
257
+ variants: {
258
+ checkbox: { true: ["w-sz-64 min-w-sz-64 max-w-sz-64", "px-0 align-middle"] },
259
+ resizable: { true: ["pr-xl"] }
260
+ },
261
+ defaultVariants: {
262
+ checkbox: !1,
263
+ resizable: !1
264
+ }
265
+ }), ge = r([
266
+ "flex flex-1 justify-between items-center gap-md",
267
+ "font-inherit text-left text-inherit",
268
+ "whitespace-nowrap text-ellipsis",
269
+ "border-transparent",
270
+ "data-focus-visible:u-outline data-focus-visible:outline-offset-2"
271
+ ], {
272
+ variants: {},
273
+ defaultVariants: {}
274
+ });
275
+ r(["empty:italic empty:text-center empty:text-body-2 empty:py-lg"], {
276
+ variants: {},
277
+ defaultVariants: {}
278
+ });
279
+ var z = r([
280
+ "p-lg outline-none box-border default:overflow-hidden",
281
+ "border-b-sm border-outline [tr:last-child>&]:border-b-0",
282
+ "[-webkit-tap-highlight-color:transparent]",
283
+ "data-focus-visible:u-outline-inset data-focus-visible:outline-dashed"
284
+ ], {
285
+ variants: { checkbox: { true: ["w-sz-64 py-sm px-0 align-middle"] } },
286
+ defaultVariants: { checkbox: !1 }
287
+ }), _e = 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
+ variants: {},
289
+ defaultVariants: {}
290
+ }), B = "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\"]", ve = "a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]";
291
+ function ye(e) {
291
292
  if (!e || !(e instanceof Element)) return !1;
292
293
  let t = e;
293
- return t.matches(R) || t.closest(R) !== null;
294
+ return t.matches(B) || t.closest(B) !== null;
294
295
  }
295
- function Se(e) {
296
+ function be(e) {
296
297
  return e ? e instanceof Element ? e : e instanceof Text ? e.parentElement : null : null;
297
298
  }
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;
299
+ function xe(e) {
300
+ for (let t of e.querySelectorAll(ve)) if (t !== e && !t.hasAttribute("disabled") && t.getAttribute("aria-disabled") !== "true" && t.getAttribute("hidden") === null) return !0;
300
301
  return !1;
301
302
  }
302
- function we(e) {
303
- let t = Se(e);
303
+ function Se(e) {
304
+ let t = be(e);
304
305
  if (!t) return !1;
305
- if (xe(t)) return !0;
306
+ if (ye(t)) return !0;
306
307
  let n = t.closest("[data-spark-component=\"table-cell\"]");
307
- return !n || n.getAttribute("data-table-cell-kind") === "selection" ? !1 : Ce(n);
308
+ return !n || n.getAttribute("data-table-cell-kind") === "selection" ? !1 : xe(n);
308
309
  }
309
310
  //#endregion
310
311
  //#region src/table/internal/TableKeyboardModeContext.tsx
311
- var z = o("grid");
312
+ var V = o("grid");
312
313
  //#endregion
313
314
  //#region src/table/internal/TableSelectionCheckbox.tsx
314
- function B({ checkboxProps: e, className: t, suppressFocusWalker: r }) {
315
+ function H({ checkboxProps: e, className: t, suppressFocusWalker: r }) {
315
316
  let { isSelected: i, isIndeterminate: a, isDisabled: o, onChange: s, ...c } = e, l = a === !0 ? "indeterminate" : !!i;
316
317
  return /* @__PURE__ */ m("span", {
317
318
  ...r ? { "data-react-aria-prevent-focus": !0 } : void 0,
@@ -326,11 +327,11 @@ function B({ checkboxProps: e, className: t, suppressFocusWalker: r }) {
326
327
  })
327
328
  });
328
329
  }
329
- B.displayName = "Table.SelectionCheckbox";
330
+ H.displayName = "Table.SelectionCheckbox";
330
331
  //#endregion
331
332
  //#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) => {
333
+ function Ce({ cell: e, state: t, resizeState: n }) {
334
+ let r = f(null), { gridCellProps: i } = E({ node: e }, t, r), { isFocusVisible: a, focusProps: o } = T(), l = c(V), u = s((e) => {
334
335
  l === "interaction" && (e.key !== " " && e.key !== "Enter" || e.stopPropagation());
335
336
  }, [l]), { onKeyDownCapture: d, ...p } = i, h = s((e) => {
336
337
  [
@@ -339,63 +340,63 @@ function V({ cell: e, state: t, resizeState: n }) {
339
340
  "ArrowUp",
340
341
  "ArrowDown"
341
342
  ].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
+ }, [d]), g = ae({ key: e.parentKey ?? e.key }, t), _ = t.collection.columns[e.index ?? 0]?.key ?? null, v = _ ? n?.columnWidths?.get?.(_) : void 0;
343
344
  return e.props?.isSelectionCell ? /* @__PURE__ */ m("td", {
344
- ...C(p, { onKeyDownCapture: h }, o, { onKeyDown: u }),
345
+ ...w(p, { onKeyDownCapture: h }, o, { onKeyDown: u }),
345
346
  ref: r,
346
347
  "data-spark-component": "table-cell",
347
348
  "data-table-cell-kind": "selection",
348
- className: A({ checkbox: !0 }),
349
+ className: z({ checkbox: !0 }),
349
350
  "data-focus-visible": a || void 0,
350
- children: /* @__PURE__ */ m(B, {
351
+ children: /* @__PURE__ */ m(H, {
351
352
  suppressFocusWalker: l === "grid",
352
353
  checkboxProps: g.checkboxProps
353
354
  })
354
355
  }) : /* @__PURE__ */ m("td", {
355
- ...C(p, { onKeyDownCapture: h }, o, { onKeyDown: u }),
356
+ ...w(p, { onKeyDownCapture: h }, o, { onKeyDown: u }),
356
357
  ref: r,
357
358
  "data-spark-component": "table-cell",
358
- className: A(),
359
+ className: z(),
359
360
  "data-focus-visible": a || void 0,
360
361
  style: v ? { width: v } : void 0,
361
362
  children: e.rendered
362
363
  });
363
364
  }
364
- V.displayName = "Table.BodyCellRenderer";
365
+ Ce.displayName = "Table.BodyCellRenderer";
365
366
  //#endregion
366
367
  //#region src/table/internal/TableBodyRowRenderer.tsx
367
- function H(e) {
368
+ function U(e) {
368
369
  if (e) return (t) => {
369
- we(_(t.nativeEvent)) || e(t);
370
+ Se(_(t.nativeEvent)) || e(t);
370
371
  };
371
372
  }
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");
373
+ function W({ item: e, state: t, resizeState: n }) {
374
+ let r = f(null), { rowProps: a, isSelected: o } = ne({ node: e }, t, r), { isFocusVisible: s, focusProps: c } = T(), { 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
375
  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),
376
+ ...w(g, c),
377
+ onPointerDown: U(u),
378
+ onMouseDown: U(d),
379
+ onPointerUp: U(p),
380
+ onPointerCancel: U(h),
381
+ onClick: U(l),
381
382
  ref: r,
382
383
  "data-spark-component": "table-row",
383
384
  "data-selected": o || void 0,
384
385
  "data-focus-visible": s || void 0,
385
386
  className: _,
386
387
  tabIndex: -1,
387
- children: [...e.childNodes].map((e) => /* @__PURE__ */ m(V, {
388
+ children: [...e.childNodes].map((e) => /* @__PURE__ */ m(Ce, {
388
389
  cell: e,
389
390
  state: t,
390
391
  resizeState: n
391
392
  }, e.key))
392
393
  });
393
394
  }
394
- U.displayName = "Table.BodyRowRenderer";
395
+ W.displayName = "Table.BodyRowRenderer";
395
396
  //#endregion
396
397
  //#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({
398
+ function G({ column: e, ariaLabel: t, resizeState: n, resizeCallbacks: r }) {
399
+ let a = f(null), { resizerProps: o, inputProps: s, isResizing: c } = re({
399
400
  column: e,
400
401
  "aria-label": t ?? "Resize column",
401
402
  onResizeStart: r.onResizeStart,
@@ -404,7 +405,7 @@ function W({ column: e, ariaLabel: t, resizeState: n, resizeCallbacks: r }) {
404
405
  }, n, a);
405
406
  return /* @__PURE__ */ m("div", {
406
407
  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
+ 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 after:transition-all after:duration-75", "has-[input:focus-visible]:after:u-outline has-[input:focus-visible]:after:outline-offset-2", c && "after:bg-outline-high after:scale-120"),
408
409
  "data-resizable-direction": "both",
409
410
  ...o,
410
411
  children: /* @__PURE__ */ m("input", {
@@ -414,14 +415,14 @@ function W({ column: e, ariaLabel: t, resizeState: n, resizeCallbacks: r }) {
414
415
  })
415
416
  });
416
417
  }
417
- W.displayName = "Table.ColumnResizer";
418
+ G.displayName = "Table.ColumnResizer";
418
419
  //#endregion
419
420
  //#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) => {
421
+ function K({ state: e }) {
422
+ let { checkboxProps: t } = ie(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
423
  (e.key === " " || e.key === "Enter") && e.stopPropagation(), e.key === "Enter" && (e.preventDefault(), t.isDisabled || g?.(!d));
423
424
  };
424
- return /* @__PURE__ */ m(B, { checkboxProps: {
425
+ return /* @__PURE__ */ m(H, { checkboxProps: {
425
426
  ..._,
426
427
  isSelected: d,
427
428
  isIndeterminate: f,
@@ -429,135 +430,138 @@ function G({ state: e }) {
429
430
  onKeyDown: v
430
431
  } });
431
432
  }
432
- G.displayName = "Table.HeaderSelectionCheckbox";
433
+ K.displayName = "Table.HeaderSelectionCheckbox";
433
434
  //#endregion
434
435
  //#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);
436
+ var we = i("sticky top-0 z-sticky");
437
+ function Te({ column: t, state: n, resizeState: r, stickyHeader: a, resizeCallbacks: o, isLastColumnInRow: s = !1 }) {
438
+ let c = f(null), { resizeColumnAriaLabel: l } = k(), { columnHeaderProps: u } = te({ node: t }, n, c), { isFocusVisible: d, focusProps: p } = T(), g = t.props?.allowsResizing !== !1 && !s, _ = r?.columnWidths?.get?.(t.key), v = !!(r && g);
437
439
  if (t.props?.isSelectionCell) return /* @__PURE__ */ m("th", {
438
- ...l,
439
- ref: s,
440
+ ...u,
441
+ ref: c,
440
442
  role: "columnheader",
441
- className: k({ checkbox: !0 }),
443
+ className: i(R({ checkbox: !0 }), a && we),
442
444
  "data-spark-component": "table-column",
443
445
  "data-table-selection-columnheader": !0,
444
- "data-focus-visible": u || void 0,
445
- children: /* @__PURE__ */ m(G, { state: n })
446
+ "data-focus-visible": d || void 0,
447
+ children: /* @__PURE__ */ m(K, { state: n })
446
448
  });
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
+ let y = !!t.props?.allowsSorting, b = n.sortDescriptor?.column === t.key, x = n.sortDescriptor?.direction ?? "ascending", S = m(b ? x === "descending" ? oe : se : ce, {}), C = (e) => {
450
+ y && (e.key !== "Enter" && e.key !== " " || (e.preventDefault(), e.stopPropagation(), n.sort?.(t.key)));
449
451
  };
450
452
  return /* @__PURE__ */ h("th", {
451
- ...C(l, d),
452
- ref: s,
453
+ ...w(u, p),
454
+ ref: c,
453
455
  role: "columnheader",
454
- className: i(k({ resizable: _ })),
455
- style: g ? { width: g } : void 0,
456
+ className: i(R({ resizable: v }), a && we),
457
+ style: _ ? { width: _ } : void 0,
456
458
  "data-spark-component": "table-column",
457
- "data-focus-visible": u || void 0,
458
- onKeyDown: S,
459
+ "data-focus-visible": d || void 0,
460
+ onKeyDown: C,
459
461
  children: [/* @__PURE__ */ h("div", {
460
- className: he(),
462
+ className: ge(),
461
463
  children: [/* @__PURE__ */ m("button", {
462
464
  type: "button",
463
465
  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,
466
+ onKeyDown: C,
465
467
  children: /* @__PURE__ */ m("span", {
466
468
  className: "min-w-0 overflow-hidden text-ellipsis whitespace-nowrap",
467
469
  children: t.rendered
468
470
  })
469
- }), v ? /* @__PURE__ */ m("span", {
471
+ }), y ? /* @__PURE__ */ m("span", {
470
472
  "aria-hidden": "true",
471
- className: i("shrink-0 opacity-dim-2 group-hover/column:opacity-100", y && "opacity-100"),
473
+ className: i("shrink-0 opacity-dim-2 group-hover/column:opacity-100", b && "opacity-100"),
472
474
  children: /* @__PURE__ */ m(e, {
473
475
  size: "sm",
474
- children: x
476
+ children: S
475
477
  })
476
478
  }) : null]
477
- }), r && p ? /* @__PURE__ */ m(W, {
479
+ }), r && g ? /* @__PURE__ */ m(G, {
478
480
  column: t,
479
- ariaLabel: typeof c == "function" ? c(t) : c,
481
+ ariaLabel: typeof l == "function" ? l(t) : l,
480
482
  resizeState: r,
481
- resizeCallbacks: a
483
+ resizeCallbacks: o
482
484
  }) : null]
483
485
  });
484
486
  }
485
487
  Te.displayName = "Table.ColumnHeader";
486
488
  //#endregion
487
489
  //#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
+ function Ee({ item: e, state: t, resizeState: n, stickyHeader: r, resizeCallbacks: i }) {
491
+ let a = f(null), { rowProps: o } = D({ node: e }, t, a), s = [...e.childNodes];
490
492
  return /* @__PURE__ */ m("tr", {
491
- ...a,
492
- ref: i,
493
- children: o.map((e, i) => /* @__PURE__ */ m(Te, {
493
+ ...o,
494
+ ref: a,
495
+ children: s.map((e, a) => /* @__PURE__ */ m(Te, {
494
496
  column: e,
495
497
  state: t,
496
498
  resizeState: n,
497
- resizeCallbacks: r,
498
- isLastColumnInRow: i === o.length - 1
499
+ stickyHeader: r,
500
+ resizeCallbacks: i,
501
+ isLastColumnInRow: a === s.length - 1
499
502
  }, e.key))
500
503
  });
501
504
  }
502
505
  Ee.displayName = "Table.HeaderRowRenderer";
503
506
  //#endregion
504
507
  //#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",
508
+ function De({ className: e, children: t, stickyHeader: n, ...r }) {
509
+ let a = !!n, o = f(null), s = ue(), c = r.selectionMode === "multiple", l = C({
510
+ ...r,
511
+ showSelectionCheckboxes: r.selectionMode === "multiple",
509
512
  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
513
+ }), u = S({ tableWidth: s.tableWidth }, l), d = s.isResizable && r.allowsResizing !== !1 ? u : null, { gridProps: p } = ee({ ...r }, l, o), _ = l.collection.headerRows, v = [...l.collection.body.childNodes], y = l.collection.body.props?.renderEmptyState, b = l.collection.columns.length || 1, x = v.length > 0 || !!y, { rowGroupProps: T } = O(), { rowGroupProps: E } = O(), { gridProps: te, keyboardMode: D } = he({
514
+ ref: o,
515
+ gridProps: p,
516
+ onKeyDownCapture: r.onKeyDownCapture,
517
+ onFocusCapture: r.onFocusCapture
515
518
  });
516
- return /* @__PURE__ */ m(z.Provider, {
517
- value: T,
519
+ return /* @__PURE__ */ m(V.Provider, {
520
+ value: D,
518
521
  children: /* @__PURE__ */ h("table", {
519
- ...C(w, g(n, { global: !0 })),
520
- ref: r,
522
+ ...w(te, g(r, { global: !0 })),
523
+ ref: o,
521
524
  "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),
525
+ 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),
523
526
  children: [/* @__PURE__ */ m("thead", {
524
- ...b,
527
+ ...T,
525
528
  "data-spark-component": "table-header",
526
- children: d.map((e) => /* @__PURE__ */ m(Ee, {
529
+ children: _.map((e) => /* @__PURE__ */ m(Ee, {
527
530
  item: e,
528
- state: s,
529
- resizeState: l,
531
+ state: l,
532
+ resizeState: d,
533
+ stickyHeader: a,
530
534
  resizeCallbacks: {
531
- onResizeStart: n.onResizeStart,
532
- onResize: n.onResize,
533
- onResizeEnd: n.onResizeEnd
535
+ onResizeStart: r.onResizeStart,
536
+ onResize: r.onResize,
537
+ onResizeEnd: r.onResizeEnd
534
538
  }
535
539
  }, e.key))
536
540
  }), /* @__PURE__ */ h("tbody", {
537
- ...x,
541
+ ...E,
538
542
  "data-spark-component": "table-body",
539
543
  children: [
540
- y ? /* @__PURE__ */ m("tr", {
544
+ x ? /* @__PURE__ */ m("tr", {
541
545
  "aria-hidden": "true",
542
- className: ge(),
546
+ className: _e(),
543
547
  role: "presentation",
544
548
  "data-spark-component": "table-body-spacer",
545
549
  children: /* @__PURE__ */ m("td", {
546
- colSpan: v,
550
+ colSpan: b,
547
551
  role: "presentation"
548
552
  })
549
553
  }) : null,
550
- p.length === 0 && _ ? /* @__PURE__ */ m("tr", {
554
+ v.length === 0 && y ? /* @__PURE__ */ m("tr", {
551
555
  "data-empty": !0,
552
556
  children: /* @__PURE__ */ m("td", {
553
- colSpan: v,
554
- children: _({ isEmpty: !0 })
557
+ colSpan: b,
558
+ children: y({ isEmpty: !0 })
555
559
  })
556
560
  }) : null,
557
- p.map((e) => /* @__PURE__ */ m(U, {
561
+ v.map((e) => /* @__PURE__ */ m(W, {
558
562
  item: e,
559
- state: s,
560
- resizeState: l
563
+ state: l,
564
+ resizeState: d
561
565
  }, e.key))
562
566
  ]
563
567
  })]
@@ -571,30 +575,31 @@ function Oe(e) {
571
575
  return typeof e == "number" ? `${e}px` : e;
572
576
  }
573
577
  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,
578
+ let { allowsResizing: i = !0, maxHeight: a, stickyHeader: o, onResizeStart: s, onResize: c, onResizeEnd: l, onKeyDownCapture: u, sortDescriptor: d, onSortChange: f, className: p, ...h } = k(), g = a == null ? void 0 : { maxHeight: Oe(a) }, _ = n ?? p, v = {
579
+ ...h,
576
580
  ...e != null && { "aria-label": e },
577
581
  ...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
- ..._,
582
+ sortDescriptor: d,
583
+ onSortChange: f,
584
+ onKeyDownCapture: u,
585
+ className: _,
586
+ stickyHeader: o
587
+ }, y = De;
588
+ return i ? /* @__PURE__ */ m(A, {
589
+ className: _,
590
+ style: g,
591
+ onResizeStart: s,
592
+ onResize: c,
593
+ onResizeEnd: l,
594
+ children: /* @__PURE__ */ m(y, {
595
+ ...v,
591
596
  children: r
592
597
  })
593
598
  }) : /* @__PURE__ */ m("div", {
594
599
  className: "relative w-full overflow-auto",
595
- style: h,
596
- children: /* @__PURE__ */ m(v, {
597
- ..._,
600
+ style: g,
601
+ children: /* @__PURE__ */ m(y, {
602
+ ...v,
598
603
  children: r
599
604
  })
600
605
  });
@@ -602,20 +607,20 @@ function ke({ "aria-label": e, "aria-labelledby": t, className: n, children: r }
602
607
  ke.displayName = "Table.Grid";
603
608
  //#endregion
604
609
  //#region src/table/TableBody.tsx
605
- function K(e) {
610
+ function q(e) {
606
611
  return /* @__PURE__ */ m(b, { ...e });
607
612
  }
608
- K.displayName = "Table.Body", K.getCollectionNode = b.getCollectionNode;
613
+ q.displayName = "Table.Body", q.getCollectionNode = b.getCollectionNode;
609
614
  //#endregion
610
615
  //#region src/table/TableBulkBar.tsx
611
616
  var Ae = o(null);
612
- function q() {
617
+ function J() {
613
618
  let e = c(Ae);
614
619
  if (!e) throw Error("Table.BulkBar subcomponents must be used within Table.BulkBar");
615
620
  return e;
616
621
  }
617
622
  function je({ children: e, className: t, rootProps: n, ...r }) {
618
- let { selectedCount: a, totalCount: o, onClearSelection: s, onSelectAll: c, hasMultiplePages: l } = E(), u = {
623
+ let { selectedCount: a, totalCount: o, onClearSelection: s, onSelectAll: c, hasMultiplePages: l } = k(), u = {
619
624
  selectedCount: a,
620
625
  totalCount: o,
621
626
  onClearSelection: s,
@@ -635,13 +640,13 @@ function je({ children: e, className: t, rootProps: n, ...r }) {
635
640
  });
636
641
  }
637
642
  function Me({ children: e }) {
638
- return q(), /* @__PURE__ */ m("span", {
643
+ return J(), /* @__PURE__ */ m("span", {
639
644
  className: "text-body-1 font-bold",
640
645
  children: e
641
646
  });
642
647
  }
643
- function J({ className: e, children: n, ...r }) {
644
- let { selectedCount: a, onClearSelection: o, hasMultiplePages: s } = q();
648
+ function Ne({ className: e, children: n, ...r }) {
649
+ let { selectedCount: a, onClearSelection: o, hasMultiplePages: s } = J();
645
650
  return s ? /* @__PURE__ */ m(t, {
646
651
  size: "sm",
647
652
  design: "ghost",
@@ -654,8 +659,8 @@ function J({ className: e, children: n, ...r }) {
654
659
  children: n
655
660
  }) : null;
656
661
  }
657
- function Ne({ className: e, children: n, ...r }) {
658
- let { selectedCount: a, totalCount: o, onSelectAll: s, hasMultiplePages: c } = q();
662
+ function Pe({ className: e, children: n, ...r }) {
663
+ let { selectedCount: a, totalCount: o, onSelectAll: s, hasMultiplePages: c } = J();
659
664
  return c ? /* @__PURE__ */ m(t, {
660
665
  size: "sm",
661
666
  design: "ghost",
@@ -669,8 +674,8 @@ function Ne({ className: e, children: n, ...r }) {
669
674
  }) : null;
670
675
  }
671
676
  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";
677
+ var Fe = je;
678
+ Fe.displayName = "Table.BulkBar", Me.displayName = "Table.BulkBarSelectedCount", Ne.displayName = "Table.BulkBarClearButton", Pe.displayName = "Table.BulkBarSelectAllButton";
674
679
  //#endregion
675
680
  //#region src/table/TableCell.tsx
676
681
  function Y(e) {
@@ -780,13 +785,13 @@ Q.displayName = "Table.Row", Q.getCollectionNode = function* (e, t) {
780
785
  };
781
786
  //#endregion
782
787
  //#region src/table/useTableSort.ts
783
- function Fe(e, t, n, r) {
788
+ function Ie(e, t, n, r) {
784
789
  let i = e[n], a = t[n];
785
790
  if (i === a) return 0;
786
791
  let o;
787
792
  return o = typeof i == "number" && typeof a == "number" ? i < a ? -1 : 1 : String(i).localeCompare(String(a)), r === "descending" ? -o : o;
788
793
  }
789
- function Ie(e, t = {}) {
794
+ function Le(e, t = {}) {
790
795
  let { initialSort: n, compare: r } = t, [i, a] = p(() => n ? {
791
796
  column: n.column,
792
797
  direction: n.direction
@@ -801,7 +806,7 @@ function Ie(e, t = {}) {
801
806
  sortedItems: d(() => {
802
807
  let t = i.column;
803
808
  if (!t) return [...e];
804
- let n = r ?? Fe, a = i.direction ?? "ascending";
809
+ let n = r ?? Ie, a = i.direction ?? "ascending";
805
810
  return [...e].sort((e, r) => n(e, r, t, a));
806
811
  }, [
807
812
  e,
@@ -813,7 +818,7 @@ function Ie(e, t = {}) {
813
818
  }
814
819
  //#endregion
815
820
  //#region src/table/useTablePagination.ts
816
- function Le(e, t) {
821
+ function Re(e, t) {
817
822
  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
823
  l(() => {
819
824
  o((e) => e < 1 ? 1 : e > f ? f : e);
@@ -868,20 +873,20 @@ function Le(e, t) {
868
873
  }
869
874
  //#endregion
870
875
  //#region src/table/index.ts
871
- var $ = Object.assign(D, {
876
+ var $ = Object.assign(fe, {
872
877
  Grid: ke,
873
878
  Header: Z,
874
879
  Column: X,
875
- Body: K,
880
+ Body: q,
876
881
  Row: Q,
877
882
  Cell: Y,
878
- BulkBar: Pe,
883
+ BulkBar: Fe,
879
884
  BulkBarSelectedCount: Me,
880
- BulkBarClearButton: J,
881
- BulkBarSelectAllButton: Ne
885
+ BulkBarClearButton: Ne,
886
+ BulkBarSelectAllButton: Pe
882
887
  });
883
- $.displayName = "Table", Z.displayName = "Table.Header", X.displayName = "Table.Column", K.displayName = "Table.Body", Q.displayName = "Table.Row", Y.displayName = "Table.Cell";
888
+ $.displayName = "Table", Z.displayName = "Table.Header", X.displayName = "Table.Column", q.displayName = "Table.Body", Q.displayName = "Table.Row", Y.displayName = "Table.Cell";
884
889
  //#endregion
885
- export { $ as Table, $ as TableWithSubcomponents, Le as useTablePagination, Ie as useTableSort };
890
+ export { $ as Table, $ as TableWithSubcomponents, Re as useTablePagination, Le as useTableSort };
886
891
 
887
892
  //# sourceMappingURL=index.mjs.map