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