@pibit.ai/cure-design-system 0.3.24 → 0.3.28

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