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