@pibit.ai/cure-design-system 0.3.20 → 0.3.23

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.
Files changed (61) hide show
  1. package/README.md +1 -0
  2. package/dist/applications/schedule-calendar/schedule-calendar.d.ts.map +1 -1
  3. package/dist/applications/schedule-calendar/schedule-calendar.js +24 -22
  4. package/dist/applications/schedule-calendar/utils.d.ts +13 -3
  5. package/dist/applications/schedule-calendar/utils.d.ts.map +1 -1
  6. package/dist/applications/schedule-calendar/utils.js +136 -117
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +92 -88
  10. package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
  11. package/dist/patterns/table/TableWrapper.js +784 -665
  12. package/dist/patterns/table/index.d.ts +1 -1
  13. package/dist/patterns/table/index.d.ts.map +1 -1
  14. package/dist/patterns/table/storyHelpers/useMockTableState.d.ts.map +1 -1
  15. package/dist/patterns/table/table.d.ts.map +1 -1
  16. package/dist/patterns/table/table.js +44 -43
  17. package/dist/patterns/table/toolbar/AlignDropdown.d.ts.map +1 -1
  18. package/dist/patterns/table/toolbar/AlignDropdown.js +19 -25
  19. package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts +9 -0
  20. package/dist/patterns/table/toolbar/ColumnHeaderMenu.d.ts.map +1 -1
  21. package/dist/patterns/table/toolbar/ColumnHeaderMenu.js +115 -81
  22. package/dist/patterns/table/toolbar/GroupByDropdown.d.ts.map +1 -1
  23. package/dist/patterns/table/toolbar/GroupByDropdown.js +48 -43
  24. package/dist/patterns/table/toolbar/SummaryFooter.d.ts.map +1 -1
  25. package/dist/patterns/table/toolbar/SummaryFooter.js +34 -27
  26. package/dist/patterns/table/toolbar/TableToolbar.d.ts +2 -0
  27. package/dist/patterns/table/toolbar/TableToolbar.d.ts.map +1 -1
  28. package/dist/patterns/table/toolbar/TableToolbar.js +2 -1
  29. package/dist/patterns/table/toolbar/index.d.ts +2 -2
  30. package/dist/patterns/table/toolbar/index.d.ts.map +1 -1
  31. package/dist/patterns/table/toolbar/tableToolbarHelpers.d.ts +10 -1
  32. package/dist/patterns/table/toolbar/tableToolbarHelpers.d.ts.map +1 -1
  33. package/dist/patterns/table/toolbar/tableToolbarHelpers.js +117 -117
  34. package/dist/patterns/table/types.d.ts +1 -0
  35. package/dist/patterns/table/types.d.ts.map +1 -1
  36. package/dist/primitives/multi-chips-select/MultiChipsSelect.d.ts +20 -0
  37. package/dist/primitives/multi-chips-select/MultiChipsSelect.d.ts.map +1 -0
  38. package/dist/primitives/multi-chips-select/MultiChipsSelect.js +233 -0
  39. package/dist/primitives/multi-chips-select/index.d.ts +3 -0
  40. package/dist/primitives/multi-chips-select/index.d.ts.map +1 -0
  41. package/dist/primitives/multi-chips-select/tagKeyFromLabel.d.ts +3 -0
  42. package/dist/primitives/multi-chips-select/tagKeyFromLabel.d.ts.map +1 -0
  43. package/dist/primitives/multi-chips-select/tagKeyFromLabel.js +6 -0
  44. package/dist/primitives/select/ExpandableSearchInput.d.ts +3 -1
  45. package/dist/primitives/select/ExpandableSearchInput.d.ts.map +1 -1
  46. package/dist/primitives/select/ExpandableSearchInput.js +100 -78
  47. package/dist/primitives/select/SearchInput.d.ts +5 -1
  48. package/dist/primitives/select/SearchInput.d.ts.map +1 -1
  49. package/dist/primitives/select/SearchInput.js +94 -74
  50. package/dist/primitives/select/searchable-select.d.ts +5 -3
  51. package/dist/primitives/select/searchable-select.d.ts.map +1 -1
  52. package/dist/primitives/select/searchable-select.js +196 -177
  53. package/dist/primitives/select/select-item.d.ts.map +1 -1
  54. package/dist/primitives/select/select-item.js +70 -54
  55. package/dist/primitives/select/select.d.ts +7 -2
  56. package/dist/primitives/select/select.d.ts.map +1 -1
  57. package/dist/primitives/select/select.js +161 -137
  58. package/dist/primitives/tooltip/ellipsis-content.d.ts.map +1 -1
  59. package/dist/primitives/tooltip/ellipsis-content.js +46 -43
  60. package/dist/styles/components.css +1 -1
  61. package/package.json +1 -1
@@ -1,736 +1,855 @@
1
1
  import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
- import { forwardRef as Dt, useState as q, useMemo as h, useCallback as B, useRef as qt, useEffect as Bt, useLayoutEffect as Jt } from "react";
3
- import { ChevronRight as Vt } from "@untitledui/icons";
2
+ import { forwardRef as Bt, useState as J, useMemo as h, useCallback as V, useRef as Jt, useEffect as Vt, useLayoutEffect as Xt } from "react";
3
+ import { ChevronRight as Yt } from "@untitledui/icons";
4
4
  import { cx as c } from "../../utils/cn.js";
5
- import { TableCard as Yt, Table as d } from "./table.js";
6
- import { TablePagination as Qt } from "./TablePagination.js";
7
- import { getEffectiveAlignment as ot, resolveColumnLabel as Xt, alignmentClass as Zt } from "./toolbar/tableToolbarHelpers.js";
8
- import { findGridCell as Kt, isWithinCellEditor as er, getGridNeighbor as tr, getGridTabNeighbor as rr, focusGridCell as nr, GridNavProvider as ir } from "./useGridKeyboardNavigation.js";
9
- import { BulkActionBar as sr } from "./toolbar/BulkActionBar.js";
10
- import { TableToolbar as ar } from "./toolbar/TableToolbar.js";
11
- import { Checkbox as rt } from "../../primitives/checkbox/checkbox.js";
5
+ import { TableCard as Qt, Table as d } from "./table.js";
6
+ import { TablePagination as Zt } from "./TablePagination.js";
7
+ import { getEffectiveAlignment as ot, resolveColumnLabel as Ht, alignmentClass as Kt } from "./toolbar/tableToolbarHelpers.js";
8
+ import { findGridCell as er, isWithinCellEditor as tr, getGridNeighbor as rr, getGridTabNeighbor as nr, focusGridCell as ir, GridNavProvider as sr } from "./useGridKeyboardNavigation.js";
9
+ import { BulkActionBar as ar } from "./toolbar/BulkActionBar.js";
10
+ import { TableToolbar as lr } from "./toolbar/TableToolbar.js";
11
+ import { Checkbox as nt } from "../../primitives/checkbox/checkbox.js";
12
12
  import { ColumnHeaderMenu as or } from "./toolbar/ColumnHeaderMenu.js";
13
- import { Button as lr } from "../../primitives/button/button.js";
14
- import { SummaryFooterRow as dr } from "./toolbar/SummaryFooter.js";
15
- import { RowActionsMenu as cr } from "./toolbar/RowActionsMenu.js";
16
- import { Icon as fr } from "../../primitives/icon/icon.js";
17
- import { ShimmerLine as hr } from "../../primitives/shimmer/shimmer.js";
18
- const ur = 5, wr = "__all__", nt = {
13
+ import { Button as dr } from "../../primitives/button/button.js";
14
+ import { SummaryFooterRow as cr } from "./toolbar/SummaryFooter.js";
15
+ import { RowActionsMenu as fr } from "./toolbar/RowActionsMenu.js";
16
+ import { Icon as hr } from "../../primitives/icon/icon.js";
17
+ import { ShimmerLine as ur } from "../../primitives/shimmer/shimmer.js";
18
+ const yr = 5, pr = "__all__", it = {
19
19
  ArrowUp: "up",
20
20
  ArrowDown: "down",
21
21
  ArrowLeft: "left",
22
22
  ArrowRight: "right"
23
- }, J = (t) => t.__rowId ?? t.id ?? t.rule_id ?? String(t);
24
- function it(t, a) {
23
+ }, X = (t) => t.__rowId ?? t.id ?? t.rule_id ?? String(t);
24
+ function st(t, a) {
25
25
  return t === "all" ? new Set(a) : t ?? /* @__PURE__ */ new Set();
26
26
  }
27
- function yr(t, a, o) {
28
- return t ? t === "all" ? o.includes(a) : t.has(a) : !1;
27
+ function wr(t, a, l) {
28
+ return t ? t === "all" ? l.includes(a) : t.has(a) : !1;
29
29
  }
30
- function pr(t, a) {
30
+ function xr(t, a) {
31
31
  return t ? t === "all" ? a.length : t.size : 0;
32
32
  }
33
- function xr(t, a) {
34
- return a.length === 0 ? !1 : t === "all" ? !0 : a.every((o) => (t == null ? void 0 : t.has(o)) ?? !1);
33
+ function br(t, a) {
34
+ return a.length === 0 ? !1 : t === "all" ? !0 : a.every((l) => (t == null ? void 0 : t.has(l)) ?? !1);
35
35
  }
36
36
  function gr(t, a) {
37
- return t === "all" ? a.length > 0 : a.some((o) => (t == null ? void 0 : t.has(o)) ?? !1);
37
+ return t === "all" ? a.length > 0 : a.some((l) => (t == null ? void 0 : t.has(l)) ?? !1);
38
38
  }
39
- function br(t) {
39
+ function mr(t) {
40
40
  if (t)
41
41
  return (a) => {
42
42
  t(a === "all" ? "all" : new Set([...a].map(String)));
43
43
  };
44
44
  }
45
- function mr(t) {
45
+ function Nr(t) {
46
46
  var a;
47
- return t != null && t.length ? t.length > 1 ? !0 : ((a = t[0]) == null ? void 0 : a.key) !== wr : !1;
47
+ return t != null && t.length ? t.length > 1 ? !0 : ((a = t[0]) == null ? void 0 : a.key) !== pr : !1;
48
48
  }
49
- function st(t, a, o) {
50
- return o ? ot(o, a ?? /* @__PURE__ */ new Map()) : (a == null ? void 0 : a.get(t)) ?? "left";
49
+ function at(t, a, l) {
50
+ return l ? ot(l, a ?? /* @__PURE__ */ new Map()) : (a == null ? void 0 : a.get(t)) ?? "left";
51
51
  }
52
- const de = "120px", Pe = (t) => {
52
+ const Te = "300px", Pe = (t) => {
53
53
  if (!t) return 0;
54
54
  const a = t.match(/^(\d+(?:\.\d+)?)px$/);
55
55
  return a ? Number(a[1]) : 0;
56
- }, G = (t) => !!(t.maxWidth && t.sticky === "right"), Nr = (t) => ({
57
- maxWidth: t.maxWidth,
58
- minWidth: t.maxWidth ?? t.minWidth ?? de,
59
- width: t.maxWidth
60
- }), at = (t) => G(t) && t.maxWidth ? {
56
+ }, A = (t) => !!(t.maxWidth && t.sticky === "right"), kr = (t) => ({
57
+ maxWidth: t.maxWidth ?? Te,
58
+ minWidth: t.minWidth
59
+ }), lt = (t) => A(t) && t.maxWidth ? {
61
60
  minWidth: t.maxWidth,
62
61
  width: t.maxWidth,
63
62
  maxWidth: t.maxWidth
64
63
  } : {
65
- minWidth: t.minWidth ?? de
66
- }, Fr = Dt(function({
67
- data: a,
68
- columns: o,
69
- renderRowCell: Te,
70
- onRowClick: V,
71
- arialabel: lt,
72
- size: Oe = "sm",
73
- allowDefaultRowClass: dt = !1,
74
- centeredHeaders: ct = [],
75
- rootClassName: ft,
76
- removeBorders: Le,
77
- headerClassName: ht,
78
- isRowExpandable: ze,
79
- renderExpandedContent: ut,
80
- loading: P = !1,
81
- loadingRowCount: Ge = ur,
82
- renderHeaderCell: ce,
83
- tableClassName: wt,
84
- getRowClassName: fe,
85
- selectionMode: A = "none",
86
- selectedKeys: C,
87
- onSelectionChange: y,
88
- inlineSelection: he = !1,
89
- toolbar: p,
90
- showToolbar: yt,
91
- toolbarTitle: Ae,
92
- toolbarTrailing: $e,
93
- disableExtendedTools: je,
94
- pagination: x,
95
- showBorders: Y,
96
- emptyState: Fe,
97
- editChrome: S,
98
- showEditActions: pt = !1,
99
- searchCollapsible: He,
100
- isEditable: xt,
101
- toolbarSlot: ue,
102
- rowHeightClass: Me,
103
- groupedData: O,
104
- showSummaryFooter: gt,
105
- summaryFooterProps: we,
106
- bulkActionBar: Q,
107
- renderBulkActionBar: X,
108
- onBulkDuplicate: Z,
109
- onBulkDelete: K,
110
- bulkActionBusy: ee,
111
- columnAlignments: L,
112
- onColumnHeaderAction: te,
113
- showColumnHeaderMenu: bt,
114
- columnMenuCapabilities: mt,
115
- renderGroupHeader: Ue,
116
- columnMenuSchema: $,
117
- columnSchema: j,
118
- labelMeta: Nt,
119
- renderColumnHeaderMenuExtraItems: kt,
120
- fillWidth: w = !1,
121
- rowActions: ye,
122
- onCellActivate: pe
123
- }, F) {
124
- const [re, Ct] = q(() => /* @__PURE__ */ new Set()), [vt, St] = q(null), [b, xe] = q(null), [z, Rt] = q(null), ne = A === "single" || A === "multiple", ge = !!ye, R = ne && !he, be = mr(O), Wt = h(() => $ != null && $.length ? new Map($.map((e) => [e.key, e])) : /* @__PURE__ */ new Map(), [$]), De = h(() => j != null && j.length ? new Map(j.map((e) => [e.value, e])) : /* @__PURE__ */ new Map(), [j]), ie = h(() => o.map((e) => e.key), [o]), It = B((e) => {
125
- Ct((r) => {
126
- const n = new Set(r);
127
- return n.has(e) ? n.delete(e) : n.add(e), n;
128
- });
129
- }, []), se = h(() => P ? Array.from({ length: Ge }, (e, r) => ({ id: `loading-${r}` })) : a.map((e) => {
130
- const r = e;
131
- if (r.__rowId != null)
132
- return r;
133
- const n = J(r);
134
- return r.id != null && String(r.id) === n ? r : { ...r, id: n };
135
- }), [P, a, Ge]), g = h(() => P ? [] : be && O ? O.flatMap(
136
- (e) => re.has(e.key) ? [] : e.rows.map((r) => J(r))
137
- ) : se.map((e) => J(e)), [P, be, O, re, se]), me = h(
138
- () => it(C, g),
139
- [C, g]
140
- ), Ne = pr(C, g), ke = Ne > 0, qe = ke && !!(Q ?? X ?? Z ?? K), H = h(() => {
141
- if (!ke) return;
142
- const e = a.filter(
143
- (r) => me.has(J(r))
144
- );
145
- return {
146
- selectedKeys: me,
147
- selectedRows: e,
148
- clearSelection: () => y == null ? void 0 : y(/* @__PURE__ */ new Set()),
149
- busy: ee
150
- };
151
- }, [ke, me, a, y, ee]), Be = h(() => {
152
- if (ue != null) return ue;
153
- if (qe) {
154
- if (Q != null) return Q;
155
- if (X && H)
156
- return X(H);
157
- if (H && (Z || K))
158
- return /* @__PURE__ */ i(
159
- sr,
160
- {
161
- count: Ne,
162
- onDuplicate: Z,
163
- onDelete: K,
164
- onClearSelection: H.clearSelection,
165
- busy: ee
166
- }
167
- );
168
- }
169
- return p ? /* @__PURE__ */ i(
170
- ar,
171
- {
172
- sort: p.sort,
173
- filter: p.filter,
174
- search: p.search,
175
- rowHeight: p.rowHeight,
176
- hideFields: p.hideFields,
177
- align: p.align,
178
- groupBy: p.groupBy,
179
- summary: p.summary,
180
- sortContent: p.sortContent,
181
- filterContent: p.filterContent,
182
- fallbackTitle: Ae,
183
- trailing: $e,
184
- searchCollapsible: He,
185
- disableExtendedTools: je
186
- }
187
- ) : null;
188
- }, [
189
- ue,
190
- qe,
191
- Q,
192
- X,
193
- H,
194
- Z,
195
- K,
196
- ee,
197
- Ne,
198
- p,
199
- Ae,
200
- $e,
201
- He,
202
- je
203
- ]), Je = Be != null && yt !== !1, Ve = !!x && (x == null ? void 0 : x.showPagination) !== !1, Et = Je || Ve, Ye = !P && a.length === 0 && Fe != null, m = !!(pt && S), Ce = !!(S != null && S.showFooterRow), T = xt ?? (m || Ce || ge), _t = Ye && !(Ce && S), M = o.length + (R ? 1 : 0) + (m ? 1 : 0), Pt = !!(gt && we), u = Y ? "border-r border-secondary last:border-r-0" : void 0, I = h(() => {
204
- if (!w) return null;
205
- const e = o.reduce(
206
- (s, f) => G(f) ? s + Pe(f.maxWidth) : s,
207
- 0
208
- );
209
- return { minTableWidth: o.filter((s) => !G(s)).reduce(
210
- (s, f) => s + Pe(f.minWidth ?? de),
211
- 0
212
- ) + e };
213
- }, [o, w]), Tt = h(() => {
214
- const e = /* @__PURE__ */ new Map();
215
- return te && o.forEach((r) => {
216
- e.set(r.key, (n) => te(r.key, n));
217
- }), e;
218
- }, [o, te]), W = qt(null), [U, Qe] = q(null), ve = B((e, r, n) => {
219
- var f;
220
- let s = n ?? null;
221
- if (s == null) {
222
- const N = (f = Kt(W.current, e, r)) == null ? void 0 : f.getAttribute("data-grid-source-index"), E = N != null && N !== "" ? Number(N) : NaN;
223
- s = Number.isNaN(E) ? null : E;
224
- }
225
- xe({ rowId: e, columnKey: r, sourceIndex: s });
226
- }, []), Ot = B(
227
- (e) => {
228
- var ae, oe, le;
229
- const r = e.key in nt;
230
- if (e.key !== "Enter" && e.key !== "Tab" && e.key !== "Escape" && !r || er(e.target)) return;
231
- if (e.key === "Escape") {
232
- if (!b) return;
233
- e.preventDefault(), e.stopPropagation(), xe(null), (ae = W.current) != null && ae.contains(document.activeElement) && document.activeElement.blur();
234
- return;
235
- }
236
- const n = (le = (oe = e.target).closest) == null ? void 0 : le.call(oe, "[data-grid-cell]"), s = n == null ? void 0 : n.getAttribute("data-grid-row-id"), f = n == null ? void 0 : n.getAttribute("data-grid-col-key"), N = n == null ? void 0 : n.getAttribute("data-grid-source-index"), E = N != null && N !== "" ? Number(N) : NaN, l = Number.isNaN(E) ? null : E, v = b ?? (s && f ? {
237
- rowId: s,
238
- columnKey: f,
239
- sourceIndex: l
240
- } : null);
241
- if (!v) return;
242
- if (e.key === "Enter") {
243
- if (!pe) return;
244
- e.preventDefault(), e.stopPropagation(), pe({
245
- rowId: v.rowId,
246
- columnKey: v.columnKey,
247
- sourceIndex: v.sourceIndex
248
- });
249
- return;
64
+ minWidth: t.minWidth,
65
+ maxWidth: t.maxWidth ?? Te
66
+ }, Mr = Bt(
67
+ function({
68
+ data: a,
69
+ columns: l,
70
+ renderRowCell: Le,
71
+ onRowClick: Y,
72
+ onRowHover: L,
73
+ arialabel: dt,
74
+ size: Oe = "sm",
75
+ allowDefaultRowClass: ct = !1,
76
+ centeredHeaders: ft = [],
77
+ rootClassName: ht,
78
+ removeBorders: ze,
79
+ headerClassName: ut,
80
+ isRowExpandable: Ge,
81
+ renderExpandedContent: yt,
82
+ loading: P = !1,
83
+ loadingRowCount: Ae = yr,
84
+ renderHeaderCell: ce,
85
+ tableClassName: pt,
86
+ getRowClassName: fe,
87
+ selectionMode: $ = "none",
88
+ selectedKeys: C,
89
+ onSelectionChange: p,
90
+ inlineSelection: he = !1,
91
+ toolbar: w,
92
+ showToolbar: wt,
93
+ toolbarTitle: $e,
94
+ toolbarTrailing: je,
95
+ disableExtendedTools: Fe,
96
+ pagination: x,
97
+ showBorders: Q,
98
+ emptyState: Me,
99
+ editChrome: v,
100
+ showEditActions: xt = !1,
101
+ searchCollapsible: Ue,
102
+ isEditable: bt,
103
+ toolbarSlot: ue,
104
+ rowHeightClass: De,
105
+ groupedData: O,
106
+ showSummaryFooter: gt,
107
+ summaryFooterProps: ye,
108
+ bulkActionBar: Z,
109
+ renderBulkActionBar: H,
110
+ onBulkDuplicate: K,
111
+ onBulkDelete: ee,
112
+ bulkActionBusy: te,
113
+ columnAlignments: z,
114
+ onColumnHeaderAction: re,
115
+ showColumnHeaderMenu: mt,
116
+ columnMenuCapabilities: Nt,
117
+ renderGroupHeader: qe,
118
+ columnMenuSchema: j,
119
+ columnSchema: F,
120
+ labelMeta: kt,
121
+ renderColumnHeaderMenuExtraItems: Ct,
122
+ fillWidth: y = !1,
123
+ rowActions: pe,
124
+ onCellActivate: we
125
+ }, M) {
126
+ const [ne, St] = J(
127
+ () => /* @__PURE__ */ new Set()
128
+ ), [vt, Wt] = J(
129
+ null
130
+ ), [g, xe] = J(null), [G, Rt] = J(null), ie = $ === "single" || $ === "multiple", be = !!pe, W = ie && !he, ge = Nr(O), It = h(() => j != null && j.length ? new Map(j.map((e) => [e.key, e])) : /* @__PURE__ */ new Map(), [j]), Be = h(() => F != null && F.length ? new Map(F.map((e) => [e.value, e])) : /* @__PURE__ */ new Map(), [F]), se = h(
131
+ () => l.map((e) => e.key),
132
+ [l]
133
+ ), Et = V((e) => {
134
+ St((r) => {
135
+ const n = new Set(r);
136
+ return n.has(e) ? n.delete(e) : n.add(e), n;
137
+ });
138
+ }, []), ae = h(() => P ? Array.from({ length: Ae }, (e, r) => ({
139
+ id: `loading-${r}`
140
+ })) : a.map((e) => {
141
+ const r = e;
142
+ if (r.__rowId != null)
143
+ return r;
144
+ const n = X(r);
145
+ return r.id != null && String(r.id) === n ? r : { ...r, id: n };
146
+ }), [P, a, Ae]), b = h(() => P ? [] : ge && O ? O.flatMap(
147
+ (e) => ne.has(e.key) ? [] : e.rows.map((r) => X(r))
148
+ ) : ae.map((e) => X(e)), [P, ge, O, ne, ae]), me = h(
149
+ () => st(C, b),
150
+ [C, b]
151
+ ), Ne = xr(C, b), ke = Ne > 0, Je = ke && !!(Z ?? H ?? K ?? ee), U = h(() => {
152
+ if (!ke) return;
153
+ const e = a.filter(
154
+ (r) => me.has(X(r))
155
+ );
156
+ return {
157
+ selectedKeys: me,
158
+ selectedRows: e,
159
+ clearSelection: () => p == null ? void 0 : p(/* @__PURE__ */ new Set()),
160
+ busy: te
161
+ };
162
+ }, [
163
+ ke,
164
+ me,
165
+ a,
166
+ p,
167
+ te
168
+ ]), Ve = h(() => {
169
+ if (ue != null) return ue;
170
+ if (Je) {
171
+ if (Z != null) return Z;
172
+ if (H && U)
173
+ return H(U);
174
+ if (U && (K || ee))
175
+ return /* @__PURE__ */ i(
176
+ ar,
177
+ {
178
+ count: Ne,
179
+ onDuplicate: K,
180
+ onDelete: ee,
181
+ onClearSelection: U.clearSelection,
182
+ busy: te
183
+ }
184
+ );
250
185
  }
251
- const _ = r ? tr(
252
- W.current,
253
- g,
254
- ie,
255
- v.rowId,
256
- v.columnKey,
257
- nt[e.key]
258
- ) : rr(
259
- W.current,
260
- g,
261
- ie,
262
- v.rowId,
263
- v.columnKey,
264
- !e.shiftKey
186
+ return w ? /* @__PURE__ */ i(
187
+ lr,
188
+ {
189
+ sort: w.sort,
190
+ filter: w.filter,
191
+ search: w.search,
192
+ rowHeight: w.rowHeight,
193
+ hideFields: w.hideFields,
194
+ align: w.align,
195
+ groupBy: w.groupBy,
196
+ summary: w.summary,
197
+ sortContent: w.sortContent,
198
+ filterContent: w.filterContent,
199
+ fallbackTitle: $e,
200
+ trailing: je,
201
+ searchCollapsible: Ue,
202
+ disableExtendedTools: Fe
203
+ }
204
+ ) : null;
205
+ }, [
206
+ ue,
207
+ Je,
208
+ Z,
209
+ H,
210
+ U,
211
+ K,
212
+ ee,
213
+ te,
214
+ Ne,
215
+ w,
216
+ $e,
217
+ je,
218
+ Ue,
219
+ Fe
220
+ ]), Xe = Ve != null && wt !== !1, Ye = !!x && (x == null ? void 0 : x.showPagination) !== !1, _t = Xe || Ye, Qe = !P && a.length === 0 && Me != null, m = !!(xt && v), Ce = !!(v != null && v.showFooterRow), T = bt ?? (m || Ce || be), Pt = Qe && !(Ce && v), D = l.length + (W ? 1 : 0) + (m ? 1 : 0), Tt = !!(gt && ye), u = Q ? "border-r border-secondary last:border-r-0" : void 0, I = h(() => {
221
+ if (!y) return null;
222
+ const e = l.reduce(
223
+ (s, f) => A(f) ? s + Pe(f.maxWidth) : s,
224
+ 0
265
225
  );
266
- if (!_) {
267
- r && (e.preventDefault(), e.stopPropagation());
226
+ return { minTableWidth: l.filter(
227
+ (s) => !A(s)
228
+ ).reduce(
229
+ (s, f) => s + Pe(f.minWidth),
230
+ 0
231
+ ) + e };
232
+ }, [l, y]), Lt = h(() => {
233
+ const e = /* @__PURE__ */ new Map();
234
+ return re && l.forEach((r) => {
235
+ e.set(
236
+ r.key,
237
+ (n) => re(r.key, n)
238
+ );
239
+ }), e;
240
+ }, [l, re]), R = Jt(null), [q, Ze] = J(null), Se = V(
241
+ (e, r, n) => {
242
+ var f;
243
+ let s = n ?? null;
244
+ if (s == null) {
245
+ const N = (f = er(
246
+ R.current,
247
+ e,
248
+ r
249
+ )) == null ? void 0 : f.getAttribute("data-grid-source-index"), E = N != null && N !== "" ? Number(N) : NaN;
250
+ s = Number.isNaN(E) ? null : E;
251
+ }
252
+ xe({ rowId: e, columnKey: r, sourceIndex: s });
253
+ },
254
+ []
255
+ ), Ot = V(
256
+ (e) => {
257
+ var le, oe, de;
258
+ const r = e.key in it;
259
+ if (e.key !== "Enter" && e.key !== "Tab" && e.key !== "Escape" && !r || tr(e.target)) return;
260
+ if (e.key === "Escape") {
261
+ if (!g) return;
262
+ e.preventDefault(), e.stopPropagation(), xe(null), (le = R.current) != null && le.contains(document.activeElement) && document.activeElement.blur();
263
+ return;
264
+ }
265
+ const n = (de = (oe = e.target).closest) == null ? void 0 : de.call(
266
+ oe,
267
+ "[data-grid-cell]"
268
+ ), s = n == null ? void 0 : n.getAttribute("data-grid-row-id"), f = n == null ? void 0 : n.getAttribute("data-grid-col-key"), N = n == null ? void 0 : n.getAttribute(
269
+ "data-grid-source-index"
270
+ ), E = N != null && N !== "" ? Number(N) : NaN, o = Number.isNaN(E) ? null : E, S = g ?? (s && f ? {
271
+ rowId: s,
272
+ columnKey: f,
273
+ sourceIndex: o
274
+ } : null);
275
+ if (!S) return;
276
+ if (e.key === "Enter") {
277
+ if (!we) return;
278
+ e.preventDefault(), e.stopPropagation(), we({
279
+ rowId: S.rowId,
280
+ columnKey: S.columnKey,
281
+ sourceIndex: S.sourceIndex
282
+ });
283
+ return;
284
+ }
285
+ const _ = r ? rr(
286
+ R.current,
287
+ b,
288
+ se,
289
+ S.rowId,
290
+ S.columnKey,
291
+ it[e.key]
292
+ ) : nr(
293
+ R.current,
294
+ b,
295
+ se,
296
+ S.rowId,
297
+ S.columnKey,
298
+ !e.shiftKey
299
+ );
300
+ if (!_) {
301
+ r && (e.preventDefault(), e.stopPropagation());
302
+ return;
303
+ }
304
+ e.preventDefault(), e.stopPropagation(), Se(_.rowId, _.columnKey, _.sourceIndex), requestAnimationFrame(
305
+ () => ir(
306
+ R.current,
307
+ _.rowId,
308
+ _.columnKey
309
+ )
310
+ );
311
+ },
312
+ [g, b, se, we, Se]
313
+ );
314
+ Vt(() => {
315
+ if (!T || !g) return;
316
+ const e = (r) => {
317
+ const n = R.current;
318
+ n && !n.contains(r.target) && xe(null);
319
+ };
320
+ return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
321
+ }, [T, g]);
322
+ const He = h(() => {
323
+ let e = 0;
324
+ return W && (e += 40), m && (e += 56), l.forEach((r) => {
325
+ A(r) && (e += Pe(r.maxWidth));
326
+ }), e;
327
+ }, [l, m, W]), ve = h(
328
+ () => l.filter((e) => !A(e)).length,
329
+ [l]
330
+ ), We = h(() => {
331
+ if (!y || !I) return null;
332
+ const { minTableWidth: e } = I;
333
+ return q ? Math.max(q, e) : e;
334
+ }, [q, y, I]), Re = !!(y && I && q && q < I.minTableWidth), Ie = h(() => !We || ve === 0 ? null : Math.max(
335
+ 0,
336
+ (We - He) / ve
337
+ ), [We, He, ve]);
338
+ Xt(() => {
339
+ if (!y) {
340
+ Ze(null);
268
341
  return;
269
342
  }
270
- e.preventDefault(), e.stopPropagation(), ve(_.rowId, _.columnKey, _.sourceIndex), requestAnimationFrame(() => nr(W.current, _.rowId, _.columnKey));
271
- },
272
- [b, g, ie, pe, ve]
273
- );
274
- Bt(() => {
275
- if (!T || !b) return;
276
- const e = (r) => {
277
- const n = W.current;
278
- n && !n.contains(r.target) && xe(null);
279
- };
280
- return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
281
- }, [T, b]);
282
- const Xe = h(() => {
283
- let e = 0;
284
- return R && (e += 40), m && (e += 56), o.forEach((r) => {
285
- G(r) && (e += Pe(r.maxWidth));
286
- }), e;
287
- }, [o, m, R]), Se = h(
288
- () => o.filter((e) => !G(e)).length,
289
- [o]
290
- ), Re = h(() => {
291
- if (!w || !I) return null;
292
- const { minTableWidth: e } = I;
293
- return U ? Math.max(U, e) : e;
294
- }, [U, w, I]), We = !!(w && I && U && U < I.minTableWidth), Ie = h(() => !Re || Se === 0 ? null : Math.max(0, (Re - Xe) / Se), [Re, Xe, Se]);
295
- Jt(() => {
296
- if (!w) {
297
- Qe(null);
298
- return;
299
- }
300
- const e = W.current;
301
- if (!e) return;
302
- const r = () => {
303
- const s = e.clientWidth;
304
- s > 0 && Qe((f) => f === s ? f : s);
305
- };
306
- r();
307
- const n = new ResizeObserver(r);
308
- return n.observe(e), () => {
309
- n.disconnect();
310
- };
311
- }, [o.length, a.length, w, P, m, R]);
312
- const Ee = B(
313
- (e) => w ? G(e) && e.maxWidth ? at(e) : Ie != null ? {
314
- width: `${Ie}px`,
315
- minWidth: e.minWidth ?? de
316
- } : at(e) : Nr(e),
317
- [w, Ie]
318
- ), Lt = h(() => {
319
- if (!(!w || !I))
320
- return We ? {
321
- width: `${I.minTableWidth}px`,
322
- tableLayout: "fixed"
323
- } : {
324
- width: "100%",
325
- tableLayout: "fixed"
343
+ const e = R.current;
344
+ if (!e) return;
345
+ const r = () => {
346
+ const s = e.clientWidth;
347
+ s > 0 && Ze((f) => f === s ? f : s);
348
+ };
349
+ r();
350
+ const n = new ResizeObserver(r);
351
+ return n.observe(e), () => {
352
+ n.disconnect();
326
353
  };
327
- }, [w, I, We]), zt = B(
328
- (e) => {
329
- W.current = e, typeof F == "function" ? F(e) : F && (F.current = e);
330
- },
331
- [F]
332
- ), Gt = ne ? {
333
- selectionMode: A,
334
- selectedKeys: C === "all" ? "all" : C,
335
- onSelectionChange: br(y)
336
- } : {}, At = (e) => {
337
- const r = e.__sourceIndex;
338
- return typeof r == "number" ? r : 0;
339
- }, _e = ne && xr(C, g), $t = ne && gr(C, g), jt = () => {
340
- if (y) {
341
- if (_e) {
342
- y(/* @__PURE__ */ new Set());
354
+ }, [
355
+ l.length,
356
+ a.length,
357
+ y,
358
+ P,
359
+ m,
360
+ W
361
+ ]);
362
+ const Ee = V(
363
+ (e) => y ? A(e) && e.maxWidth ? lt(e) : Ie != null ? {
364
+ width: `${Ie}px`,
365
+ minWidth: e.minWidth,
366
+ maxWidth: e.maxWidth ?? Te
367
+ } : lt(e) : kr(e),
368
+ [y, Ie]
369
+ ), zt = h(() => {
370
+ if (!(!y || !I))
371
+ return Re ? {
372
+ width: `${I.minTableWidth}px`,
373
+ tableLayout: "fixed"
374
+ } : {
375
+ width: "100%",
376
+ tableLayout: "fixed"
377
+ };
378
+ }, [y, I, Re]), Gt = V(
379
+ (e) => {
380
+ R.current = e, typeof M == "function" ? M(e) : M && (M.current = e);
381
+ },
382
+ [M]
383
+ ), At = ie ? {
384
+ selectionMode: $,
385
+ selectedKeys: C === "all" ? "all" : C,
386
+ onSelectionChange: mr(p)
387
+ } : {}, $t = (e) => {
388
+ const r = e.__sourceIndex;
389
+ return typeof r == "number" ? r : 0;
390
+ }, _e = ie && br(C, b), jt = ie && gr(C, b), Ft = () => {
391
+ if (p) {
392
+ if (_e) {
393
+ p(/* @__PURE__ */ new Set());
394
+ return;
395
+ }
396
+ p("all");
397
+ }
398
+ }, Mt = (e, r) => {
399
+ if (!p) return;
400
+ if ($ === "single") {
401
+ p(r ? /* @__PURE__ */ new Set([e]) : /* @__PURE__ */ new Set());
343
402
  return;
344
403
  }
345
- y("all");
346
- }
347
- }, Ft = (e, r) => {
348
- if (!y) return;
349
- if (A === "single") {
350
- y(r ? /* @__PURE__ */ new Set([e]) : /* @__PURE__ */ new Set());
351
- return;
352
- }
353
- const n = C === "all" ? new Set(g) : new Set(it(C, g));
354
- r ? n.add(e) : n.delete(e), y(n);
355
- }, Ht = (e) => {
356
- const r = re.has(e.key);
357
- return Ue ? /* @__PURE__ */ i(
358
- d.Row,
359
- {
360
- id: `group-${e.key}`,
361
- highlightSelectedRow: !1,
362
- className: "bg-secondary_subtle hover:bg-secondary_subtle",
363
- children: /* @__PURE__ */ i(d.Cell, { colSpan: M, className: c(u), children: Ue(e) })
364
- },
365
- `group-${e.key}`
366
- ) : /* @__PURE__ */ i(
367
- d.Row,
368
- {
369
- id: `group-${e.key}`,
370
- highlightSelectedRow: !1,
371
- className: "bg-secondary_subtle hover:bg-secondary_subtle",
372
- children: /* @__PURE__ */ i(d.Cell, { colSpan: M, className: c("py-1.5", u), children: /* @__PURE__ */ k(
373
- "button",
374
- {
375
- type: "button",
376
- className: "flex w-full items-center gap-2 px-2 text-left text-xs font-medium text-secondary",
377
- onClick: () => It(e.key),
378
- "aria-expanded": !r,
379
- children: [
380
- /* @__PURE__ */ i(
381
- Vt,
382
- {
383
- className: c(
384
- "size-4 shrink-0 text-fg-quaternary transition-transform",
385
- !r && "rotate-90"
386
- )
387
- }
388
- ),
389
- /* @__PURE__ */ i("span", { className: "truncate", children: e.label || "(Empty)" }),
390
- /* @__PURE__ */ k("span", { className: "text-tertiary", children: [
391
- "(",
392
- e.rows.length,
393
- ")"
394
- ] })
395
- ]
396
- }
397
- ) })
398
- },
399
- `group-${e.key}`
400
- );
401
- }, Ze = (e, r) => {
402
- const n = ze ? ze(e) : !1, s = J(e), f = At(e), N = yr(C, s, g), E = vt === s;
403
- return /* @__PURE__ */ k(
404
- d.Row,
405
- {
406
- onAction: () => V == null ? void 0 : V(e),
407
- id: s,
408
- value: e,
409
- columns: o,
410
- expandedColSpan: M,
411
- isExpandable: n,
412
- highlightSelectedRow: !he,
413
- renderExpandedContent: n ? ut : void 0,
414
- className: c(
415
- V && "cursor-pointer",
416
- dt ? "prose" : "",
417
- Le && "[&>td]:after:hidden",
418
- ge && "group/rowactions",
419
- E && "bg-utility-brand-25 hover:bg-utility-brand-25",
420
- Me,
421
- fe == null ? void 0 : fe(e)
422
- ),
423
- children: [
424
- R && /* @__PURE__ */ i(
404
+ const n = C === "all" ? new Set(b) : new Set(st(C, b));
405
+ r ? n.add(e) : n.delete(e), p(n);
406
+ }, Ut = (e) => {
407
+ const r = ne.has(e.key);
408
+ return qe ? /* @__PURE__ */ i(
409
+ d.Row,
410
+ {
411
+ id: `group-${e.key}`,
412
+ highlightSelectedRow: !1,
413
+ className: "bg-secondary_subtle hover:bg-secondary_subtle",
414
+ children: /* @__PURE__ */ i(d.Cell, { colSpan: D, className: c(u), children: qe(e) })
415
+ },
416
+ `group-${e.key}`
417
+ ) : /* @__PURE__ */ i(
418
+ d.Row,
419
+ {
420
+ id: `group-${e.key}`,
421
+ highlightSelectedRow: !1,
422
+ className: "bg-secondary_subtle hover:bg-secondary_subtle",
423
+ children: /* @__PURE__ */ i(
425
424
  d.Cell,
426
425
  {
427
- className: c("relative w-10 text-center", u),
428
- style: { minWidth: "40px", width: "40px" },
429
- children: /* @__PURE__ */ i(
430
- "div",
426
+ colSpan: D,
427
+ className: c("py-1.5", u),
428
+ children: /* @__PURE__ */ k(
429
+ "button",
431
430
  {
432
- className: "flex items-center justify-center",
433
- onClick: (l) => l.stopPropagation(),
434
- onKeyDown: (l) => l.stopPropagation(),
435
- children: /* @__PURE__ */ i(
436
- rt,
437
- {
438
- checked: N,
439
- onCheckedChange: (l) => Ft(s, l === !0),
440
- "aria-label": `Select row ${s}`,
441
- className: "items-center justify-center"
442
- }
443
- )
431
+ type: "button",
432
+ className: "flex w-full items-center gap-2 px-2 text-left text-xs font-medium text-secondary",
433
+ onClick: () => Et(e.key),
434
+ "aria-expanded": !r,
435
+ children: [
436
+ /* @__PURE__ */ i(
437
+ Yt,
438
+ {
439
+ className: c(
440
+ "size-4 shrink-0 text-fg-quaternary transition-transform",
441
+ !r && "rotate-90"
442
+ )
443
+ }
444
+ ),
445
+ /* @__PURE__ */ i("span", { className: "truncate", children: e.label || "(Empty)" }),
446
+ /* @__PURE__ */ k("span", { className: "text-tertiary", children: [
447
+ "(",
448
+ e.rows.length,
449
+ ")"
450
+ ] })
451
+ ]
444
452
  }
445
453
  )
446
454
  }
455
+ )
456
+ },
457
+ `group-${e.key}`
458
+ );
459
+ }, Ke = (e, r) => {
460
+ const n = Ge ? Ge(e) : !1, s = X(e), f = $t(e), N = wr(C, s, b), E = vt === s;
461
+ return /* @__PURE__ */ k(
462
+ d.Row,
463
+ {
464
+ onAction: () => Y == null ? void 0 : Y(e),
465
+ onMouseEnter: () => L == null ? void 0 : L(e, !0),
466
+ onMouseLeave: () => L == null ? void 0 : L(e, !1),
467
+ id: s,
468
+ value: e,
469
+ columns: l,
470
+ expandedColSpan: D,
471
+ isExpandable: n,
472
+ highlightSelectedRow: !he,
473
+ renderExpandedContent: n ? yt : void 0,
474
+ className: c(
475
+ Y && "cursor-pointer",
476
+ ct ? "prose" : "",
477
+ ze && "[&>td]:after:hidden",
478
+ be && "group/rowactions",
479
+ E && "bg-utility-brand-25 hover:bg-utility-brand-25",
480
+ De,
481
+ fe == null ? void 0 : fe(e)
447
482
  ),
448
- o.map((l, v) => {
449
- const _ = De.get(l.key), ae = st(l.key, L, _), oe = (z == null ? void 0 : z.rowId) === s && (z == null ? void 0 : z.columnKey) === l.key, le = T && !oe && (b == null ? void 0 : b.rowId) === s && (b == null ? void 0 : b.columnKey) === l.key;
450
- return /* @__PURE__ */ i(
483
+ children: [
484
+ W && /* @__PURE__ */ i(
451
485
  d.Cell,
452
486
  {
453
- sticky: l.sticky,
454
- stickyOffset: l.stickyOffset,
455
- style: Ee(l),
456
- "data-grid-cell": "",
457
- "data-grid-row-id": s,
458
- "data-grid-col-key": l.key,
459
- "data-grid-source-index": f,
460
- className: c(
461
- "relative overflow-x-hidden",
462
- // Excel-style selected-cell highlight: an inset brand border on the
463
- // selected cell (state-driven). Inset so it sits at the cell edge
464
- // without shifting layout. `after:opacity-0` hides the row's bottom-
465
- // border pseudo-element so it doesn't overlap the ring's bottom edge.
466
- le && "z-1 outline-hidden ring-2 ring-inset ring-brand after:opacity-0",
467
- l.cellClassName,
468
- Zt(ae),
469
- u
470
- ),
471
- children: (() => {
472
- const tt = v === 0 && (n || ge) ? /* @__PURE__ */ k("div", { className: "flex items-center", children: [
473
- ye && /* @__PURE__ */ i(
487
+ className: c("relative w-10 text-center", u),
488
+ style: { minWidth: "40px", width: "40px" },
489
+ children: /* @__PURE__ */ i(
490
+ "div",
491
+ {
492
+ className: "flex items-center justify-center",
493
+ onClick: (o) => o.stopPropagation(),
494
+ onKeyDown: (o) => o.stopPropagation(),
495
+ children: /* @__PURE__ */ i(
496
+ nt,
497
+ {
498
+ checked: N,
499
+ onCheckedChange: (o) => Mt(s, o === !0),
500
+ "aria-label": `Select row ${s}`,
501
+ className: "items-center justify-center"
502
+ }
503
+ )
504
+ }
505
+ )
506
+ }
507
+ ),
508
+ l.map((o, S) => {
509
+ const _ = Be.get(o.key), le = at(
510
+ o.key,
511
+ z,
512
+ _
513
+ ), oe = (G == null ? void 0 : G.rowId) === s && (G == null ? void 0 : G.columnKey) === o.key, de = T && !oe && (g == null ? void 0 : g.rowId) === s && (g == null ? void 0 : g.columnKey) === o.key;
514
+ return /* @__PURE__ */ i(
515
+ d.Cell,
516
+ {
517
+ sticky: o.sticky,
518
+ stickyOffset: o.stickyOffset,
519
+ style: Ee(o),
520
+ "data-grid-cell": "",
521
+ "data-grid-row-id": s,
522
+ "data-grid-col-key": o.key,
523
+ "data-grid-source-index": f,
524
+ className: c(
525
+ "relative overflow-x-hidden",
526
+ // Excel-style selected-cell highlight: an inset brand border on the
527
+ // selected cell (state-driven). Inset so it sits at the cell edge
528
+ // without shifting layout. `after:opacity-0` hides the row's bottom-
529
+ // border pseudo-element so it doesn't overlap the ring's bottom edge.
530
+ de && "z-1 outline-hidden ring-2 ring-inset ring-brand after:opacity-0",
531
+ o.cellClassName,
532
+ Kt(le),
533
+ u
534
+ ),
535
+ children: (() => {
536
+ const rt = S === 0 && (n || be) ? /* @__PURE__ */ k("div", { className: "flex items-center", children: [
537
+ pe && /* @__PURE__ */ i(
538
+ "div",
539
+ {
540
+ className: "flex items-center justify-center",
541
+ onClick: (B) => B.stopPropagation(),
542
+ onKeyDown: (B) => B.stopPropagation(),
543
+ children: /* @__PURE__ */ i(
544
+ fr,
545
+ {
546
+ config: pe,
547
+ sourceRowIndex: f,
548
+ item: e,
549
+ triggerClassName: c(
550
+ "transition-opacity group-hover/rowactions:opacity-100 focus-visible:opacity-100",
551
+ E ? "opacity-100" : "opacity-0"
552
+ ),
553
+ onOpenChange: (B) => Wt(B ? s : null)
554
+ }
555
+ )
556
+ }
557
+ ),
558
+ /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: Le(o.key, e[o.key], e) })
559
+ ] }) : Le(o.key, e[o.key], e);
560
+ return T ? /* @__PURE__ */ i(
474
561
  "div",
475
562
  {
476
- className: "flex items-center justify-center",
477
- onClick: (D) => D.stopPropagation(),
478
- onKeyDown: (D) => D.stopPropagation(),
479
- children: /* @__PURE__ */ i(
480
- cr,
481
- {
482
- config: ye,
483
- sourceRowIndex: f,
484
- item: e,
485
- triggerClassName: c(
486
- "transition-opacity group-hover/rowactions:opacity-100 focus-visible:opacity-100",
487
- E ? "opacity-100" : "opacity-0"
488
- ),
489
- onOpenChange: (D) => St(D ? s : null)
490
- }
491
- )
563
+ "data-grid-focus": !0,
564
+ tabIndex: -1,
565
+ className: "outline-hidden",
566
+ children: rt
492
567
  }
493
- ),
494
- Te(l.key, e[l.key], e)
495
- ] }) : Te(l.key, e[l.key], e);
496
- return T ? /* @__PURE__ */ i("div", { "data-grid-focus": !0, tabIndex: -1, className: "outline-hidden", children: tt }) : tt;
497
- })()
498
- },
499
- l.key
500
- );
501
- }),
502
- m && S && /* @__PURE__ */ i(
568
+ ) : rt;
569
+ })()
570
+ },
571
+ o.key
572
+ );
573
+ }),
574
+ m && v && /* @__PURE__ */ i(
575
+ d.Cell,
576
+ {
577
+ className: c("relative w-14 text-center", u),
578
+ style: { minWidth: "56px", width: "56px" },
579
+ children: /* @__PURE__ */ i(
580
+ "button",
581
+ {
582
+ type: "button",
583
+ title: "Delete row",
584
+ "aria-label": "Delete row",
585
+ className: "inline-flex items-center justify-center rounded p-1 text-fg-quaternary hover:bg-secondary_subtle hover:text-fg-secondary",
586
+ onClick: (o) => {
587
+ o.stopPropagation(), v.onDeleteRow(f);
588
+ },
589
+ children: /* @__PURE__ */ i(hr, { name: "Trash02", className: "size-3" })
590
+ }
591
+ )
592
+ }
593
+ )
594
+ ]
595
+ },
596
+ s
597
+ );
598
+ }, Dt = (e) => /* @__PURE__ */ k(
599
+ d.Row,
600
+ {
601
+ id: String(e.id),
602
+ isExpandable: !1,
603
+ className: c(ze && "[&>td]:after:hidden", De),
604
+ children: [
605
+ W && /* @__PURE__ */ i(
503
606
  d.Cell,
504
607
  {
505
- className: c("relative w-14 text-center", u),
506
- style: { minWidth: "56px", width: "56px" },
507
- children: /* @__PURE__ */ i(
508
- "button",
509
- {
510
- type: "button",
511
- title: "Delete row",
512
- "aria-label": "Delete row",
513
- className: "inline-flex items-center justify-center rounded p-1 text-fg-quaternary hover:bg-secondary_subtle hover:text-fg-secondary",
514
- onClick: (l) => {
515
- l.stopPropagation(), S.onDeleteRow(f);
516
- },
517
- children: /* @__PURE__ */ i(fr, { name: "Trash02", className: "size-3" })
518
- }
519
- )
608
+ className: c("relative w-10", u),
609
+ style: { minWidth: "40px", width: "40px" }
610
+ }
611
+ ),
612
+ l.map((r) => /* @__PURE__ */ i(
613
+ d.Cell,
614
+ {
615
+ sticky: r.sticky,
616
+ stickyOffset: r.stickyOffset,
617
+ style: Ee(r),
618
+ className: c(
619
+ "overflow-x-hidden text-left",
620
+ r.cellClassName,
621
+ u
622
+ ),
623
+ children: /* @__PURE__ */ i(ur, { height: "14px", width: "75%", className: "rounded" })
624
+ },
625
+ r.key
626
+ )),
627
+ m && /* @__PURE__ */ i(
628
+ d.Cell,
629
+ {
630
+ className: c("w-14", u),
631
+ style: { minWidth: "56px", width: "56px" }
520
632
  }
521
633
  )
522
634
  ]
523
635
  },
524
- s
525
- );
526
- }, Mt = (e) => /* @__PURE__ */ k(
527
- d.Row,
528
- {
529
- id: String(e.id),
530
- isExpandable: !1,
531
- className: c(Le && "[&>td]:after:hidden", Me),
532
- children: [
533
- R && /* @__PURE__ */ i(
534
- d.Cell,
535
- {
536
- className: c("relative w-10", u),
537
- style: { minWidth: "40px", width: "40px" }
538
- }
636
+ String(e.id)
637
+ ), qt = () => P ? ae.map((e) => Dt(e)) : ge && O ? O.flatMap((e) => {
638
+ const r = ne.has(e.key);
639
+ return [
640
+ Ut(e),
641
+ ...r ? [] : e.rows.map((n) => Ke(n))
642
+ ];
643
+ }) : ae.map((e) => Ke(e)), et = /* @__PURE__ */ i(
644
+ Qt.Root,
645
+ {
646
+ ref: Gt,
647
+ onKeyDownCapture: T ? Ot : void 0,
648
+ className: c(
649
+ "w-full",
650
+ !y || Re ? "overflow-x-auto" : "overflow-x-hidden",
651
+ Q && "border border-secondary rounded-xl",
652
+ "[&_tr:hover>td]:!bg-secondary_subtle",
653
+ ht
539
654
  ),
540
- o.map((r) => /* @__PURE__ */ i(
541
- d.Cell,
655
+ size: Oe,
656
+ children: /* @__PURE__ */ k(
657
+ d,
542
658
  {
543
- sticky: r.sticky,
544
- stickyOffset: r.stickyOffset,
545
- style: Ee(r),
546
- className: c("overflow-x-hidden text-left", r.cellClassName, u),
547
- children: /* @__PURE__ */ i(hr, { height: "14px", width: "75%", className: "rounded" })
548
- },
549
- r.key
550
- )),
551
- m && /* @__PURE__ */ i(d.Cell, { className: c("w-14", u), style: { minWidth: "56px", width: "56px" } })
552
- ]
553
- },
554
- String(e.id)
555
- ), Ut = () => P ? se.map((e) => Mt(e)) : be && O ? O.flatMap((e) => {
556
- const r = re.has(e.key);
557
- return [
558
- Ht(e),
559
- ...r ? [] : e.rows.map((n) => Ze(n))
560
- ];
561
- }) : se.map((e) => Ze(e)), Ke = /* @__PURE__ */ i(
562
- Yt.Root,
563
- {
564
- ref: zt,
565
- onKeyDownCapture: T ? Ot : void 0,
566
- className: c(
567
- "w-full",
568
- !w || We ? "overflow-x-auto" : "overflow-x-hidden",
569
- Y && "border border-secondary rounded-xl",
570
- ft
571
- ),
572
- size: Oe,
573
- children: /* @__PURE__ */ k(
574
- d,
575
- {
576
- "aria-label": lt,
577
- size: Oe,
578
- isEditable: T,
579
- inlineSelection: he,
580
- className: c(w && "min-w-full", wt),
581
- style: Lt,
582
- ...Gt,
583
- children: [
584
- /* @__PURE__ */ k(
585
- d.Header,
586
- {
587
- className: c(
588
- "sticky top-0",
589
- Y && "[&>tr>th:first-child]:rounded-bl-none [&>tr>th:last-child]:rounded-br-none z-1",
590
- ht
591
- ),
592
- children: [
593
- R && /* @__PURE__ */ i(
594
- d.Head,
595
- {
596
- label: "",
597
- allowsSorting: !1,
598
- isRowHeader: !1,
599
- style: { minWidth: "40px", width: "40px" },
600
- className: c(u),
601
- headerCellClass: "justify-center",
602
- children: A === "multiple" && y && /* @__PURE__ */ i("div", { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ i(
603
- rt,
604
- {
605
- checked: _e ? !0 : $t && !_e ? "indeterminate" : !1,
606
- onCheckedChange: () => jt(),
607
- "aria-label": "Select all rows",
608
- className: "items-center justify-center"
609
- }
610
- ) })
611
- },
612
- "selection"
659
+ "aria-label": dt,
660
+ size: Oe,
661
+ isEditable: T,
662
+ inlineSelection: he,
663
+ className: c(y && "min-w-full", pt),
664
+ style: zt,
665
+ ...At,
666
+ children: [
667
+ /* @__PURE__ */ k(
668
+ d.Header,
669
+ {
670
+ className: c(
671
+ "sticky top-0",
672
+ Q && "[&>tr>th:first-child]:rounded-bl-none [&>tr>th:last-child]:rounded-br-none z-1",
673
+ ut
613
674
  ),
614
- o.map((e, r) => {
615
- const n = bt ? Wt.get(e.key) : void 0, s = De.get(e.key), f = st(e.key, L, s), N = ct.includes(e.key) || f === "center" ? "justify-center" : f === "right" ? "justify-end" : "";
616
- return /* @__PURE__ */ k(
675
+ children: [
676
+ W && /* @__PURE__ */ i(
617
677
  d.Head,
618
678
  {
619
- sticky: e.sticky,
620
- stickyOffset: e.stickyOffset,
621
- id: e.key,
622
- label: e.label,
623
- isRowHeader: r === 0 && !R,
624
- allowsSorting: e.allowsSorting,
625
- headerCellClass: `${e.headerCellClass} ${N}`,
626
- style: Ee(e),
627
- className: c("overflow-hidden", e.headClassName, u),
628
- children: [
629
- n && te && /* @__PURE__ */ i(
630
- or,
631
- {
632
- column: n,
633
- columnLabel: n.label ?? (s ? Xt(s, Nt) : e.label),
634
- currentAlignment: s ? ot(s, L ?? /* @__PURE__ */ new Map()) : (L == null ? void 0 : L.get(e.key)) ?? "left",
635
- capabilities: mt,
636
- onAction: Tt.get(e.key),
637
- renderExtraItems: kt
638
- }
679
+ label: "",
680
+ allowsSorting: !1,
681
+ isRowHeader: !1,
682
+ style: { minWidth: "40px", width: "40px" },
683
+ className: c(u),
684
+ headerCellClass: "justify-center",
685
+ children: $ === "multiple" && p && /* @__PURE__ */ i("div", { onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ i(
686
+ nt,
687
+ {
688
+ checked: _e ? !0 : jt && !_e ? "indeterminate" : !1,
689
+ onCheckedChange: () => Ft(),
690
+ "aria-label": "Select all rows",
691
+ className: "items-center justify-center"
692
+ }
693
+ ) })
694
+ },
695
+ "selection"
696
+ ),
697
+ l.map((e, r) => {
698
+ const n = mt ? It.get(e.key) : void 0, s = Be.get(e.key), f = at(
699
+ e.key,
700
+ z,
701
+ s
702
+ ), N = ft.includes(e.key) || f === "center" ? "justify-center" : f === "right" ? "justify-end" : "";
703
+ return /* @__PURE__ */ k(
704
+ d.Head,
705
+ {
706
+ sticky: e.sticky,
707
+ stickyOffset: e.stickyOffset,
708
+ id: e.key,
709
+ label: e.label,
710
+ isRowHeader: r === 0 && !W,
711
+ allowsSorting: e.allowsSorting,
712
+ headerCellClass: `${e.headerCellClass} ${N}`,
713
+ style: Ee(e),
714
+ className: c(
715
+ "overflow-hidden",
716
+ e.headClassName,
717
+ u
639
718
  ),
640
- (ce == null ? void 0 : ce(e.key)) ?? null
641
- ]
719
+ children: [
720
+ n && re && /* @__PURE__ */ i(
721
+ or,
722
+ {
723
+ column: n,
724
+ columnLabel: n.label ?? (s ? Ht(s, kt) : e.label),
725
+ currentAlignment: s ? ot(
726
+ s,
727
+ z ?? /* @__PURE__ */ new Map()
728
+ ) : (z == null ? void 0 : z.get(e.key)) ?? "left",
729
+ capabilities: Nt,
730
+ hideDisabled: l.length <= 1,
731
+ onAction: Lt.get(e.key),
732
+ renderExtraItems: Ct
733
+ }
734
+ ),
735
+ (ce == null ? void 0 : ce(e.key)) ?? null
736
+ ]
737
+ },
738
+ e.key
739
+ );
740
+ }),
741
+ m && /* @__PURE__ */ i(
742
+ d.Head,
743
+ {
744
+ label: "",
745
+ allowsSorting: !1,
746
+ isRowHeader: !1,
747
+ style: { minWidth: "56px", width: "56px" },
748
+ className: c(u)
642
749
  },
643
- e.key
644
- );
645
- }),
646
- m && /* @__PURE__ */ i(
647
- d.Head,
648
- {
649
- label: "",
650
- allowsSorting: !1,
651
- isRowHeader: !1,
652
- style: { minWidth: "56px", width: "56px" },
653
- className: c(u)
654
- },
655
- "actions"
656
- )
657
- ]
658
- }
659
- ),
660
- /* @__PURE__ */ k(d.Body, { children: [
661
- !Ye && Ut(),
662
- _t && /* @__PURE__ */ i(d.Row, { id: "empty-state", highlightSelectedRow: !1, children: /* @__PURE__ */ i(
663
- d.Cell,
664
- {
665
- colSpan: M,
666
- className: c(
667
- "text-left text-placeholder_subtle border-b border-secondary py-3",
668
- u
669
- ),
670
- children: Fe
750
+ "actions"
751
+ )
752
+ ]
671
753
  }
672
- ) }, "empty-state"),
673
- Ce && S && /* @__PURE__ */ k(d.Row, { id: "add-row-footer", highlightSelectedRow: !1, children: [
674
- /* @__PURE__ */ i(d.Cell, { colSpan: M - (m ? 1 : 0), className: c(u), children: /* @__PURE__ */ i(
675
- lr,
754
+ ),
755
+ /* @__PURE__ */ k(d.Body, { children: [
756
+ !Qe && qt(),
757
+ Pt && /* @__PURE__ */ i(
758
+ d.Row,
676
759
  {
677
- color: "tertiary",
678
- className: "bg-secondary text-primary",
679
- size: "xs",
680
- onClick: S.onAddRow,
681
- children: "+ Add Row"
682
- }
683
- ) }),
684
- m && /* @__PURE__ */ i(
685
- d.Cell,
760
+ id: "empty-state",
761
+ highlightSelectedRow: !1,
762
+ children: /* @__PURE__ */ i(
763
+ d.Cell,
764
+ {
765
+ colSpan: D,
766
+ className: c(
767
+ "text-left text-placeholder_subtle border-b border-secondary py-3",
768
+ u
769
+ ),
770
+ children: Me
771
+ }
772
+ )
773
+ },
774
+ "empty-state"
775
+ ),
776
+ Ce && v && /* @__PURE__ */ k(
777
+ d.Row,
686
778
  {
687
- className: c("w-14", u),
688
- style: { minWidth: "56px", width: "56px" }
779
+ id: "add-row-footer",
780
+ highlightSelectedRow: !1,
781
+ children: [
782
+ /* @__PURE__ */ i(
783
+ d.Cell,
784
+ {
785
+ colSpan: D - (m ? 1 : 0),
786
+ className: c(u),
787
+ children: /* @__PURE__ */ i(
788
+ dr,
789
+ {
790
+ color: "tertiary",
791
+ className: "bg-secondary text-primary",
792
+ size: "xs",
793
+ onClick: v.onAddRow,
794
+ children: "+ Add Row"
795
+ }
796
+ )
797
+ }
798
+ ),
799
+ m && /* @__PURE__ */ i(
800
+ d.Cell,
801
+ {
802
+ className: c("w-14", u),
803
+ style: { minWidth: "56px", width: "56px" }
804
+ }
805
+ )
806
+ ]
807
+ },
808
+ "add-row-footer"
809
+ ),
810
+ Tt && ye && /* @__PURE__ */ i(
811
+ cr,
812
+ {
813
+ ...ye,
814
+ hasActionsColumn: m,
815
+ hasSelectionColumn: W,
816
+ showBorders: !!Q
689
817
  }
690
818
  )
691
- ] }, "add-row-footer"),
692
- Pt && we && /* @__PURE__ */ i(
693
- dr,
694
- {
695
- ...we,
696
- hasActionsColumn: m,
697
- hasSelectionColumn: R,
698
- showBorders: !!Y
699
- }
700
- )
701
- ] })
702
- ]
703
- }
704
- )
705
- }
706
- ), et = T ? /* @__PURE__ */ i(
707
- ir,
708
- {
709
- rowIds: g,
710
- columnKeys: ie,
711
- containerRef: W,
712
- onSelectCell: ve,
713
- onEditingCellChange: Rt,
714
- children: Ke
715
- }
716
- ) : Ke;
717
- return Et ? /* @__PURE__ */ k("div", { className: "flex flex-col gap-3", children: [
718
- Je && Be,
719
- et,
720
- Ve && x && /* @__PURE__ */ i(
721
- Qt,
819
+ ] })
820
+ ]
821
+ }
822
+ )
823
+ }
824
+ ), tt = T ? /* @__PURE__ */ i(
825
+ sr,
722
826
  {
723
- currentPage: x.currentPage,
724
- pageSize: x.pageSize,
725
- totalPages: x.totalPages,
726
- totalItems: x.totalItems,
727
- onPageChange: x.onPageChange,
728
- onPageSizeChange: x.onPageSizeChange,
729
- showPagination: x.showPagination
827
+ rowIds: b,
828
+ columnKeys: se,
829
+ containerRef: R,
830
+ onSelectCell: Se,
831
+ onEditingCellChange: Rt,
832
+ children: et
730
833
  }
731
- )
732
- ] }) : et;
733
- });
834
+ ) : et;
835
+ return _t ? /* @__PURE__ */ k("div", { className: "flex flex-col gap-3", children: [
836
+ Xe && Ve,
837
+ tt,
838
+ Ye && x && /* @__PURE__ */ i(
839
+ Zt,
840
+ {
841
+ currentPage: x.currentPage,
842
+ pageSize: x.pageSize,
843
+ totalPages: x.totalPages,
844
+ totalItems: x.totalItems,
845
+ onPageChange: x.onPageChange,
846
+ onPageSizeChange: x.onPageSizeChange,
847
+ showPagination: x.showPagination
848
+ }
849
+ )
850
+ ] }) : tt;
851
+ }
852
+ );
734
853
  export {
735
- Fr as TableWrapper
854
+ Mr as TableWrapper
736
855
  };