@pibit.ai/cure-design-system 0.3.43 → 0.3.48

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 (59) hide show
  1. package/dist/applications/loading-indicator/index.d.ts +2 -0
  2. package/dist/applications/loading-indicator/index.d.ts.map +1 -0
  3. package/dist/applications/loading-indicator/loading-indicator.d.ts +1 -2
  4. package/dist/applications/loading-indicator/loading-indicator.d.ts.map +1 -1
  5. package/dist/index.d.ts +4 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +175 -162
  8. package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
  9. package/dist/patterns/table/TableWrapper.js +538 -564
  10. package/dist/patterns/table/TableZoomControl.d.ts +12 -0
  11. package/dist/patterns/table/TableZoomControl.d.ts.map +1 -0
  12. package/dist/patterns/table/TableZoomControl.js +58 -0
  13. package/dist/patterns/table/index.d.ts +2 -0
  14. package/dist/patterns/table/index.d.ts.map +1 -1
  15. package/dist/patterns/table/tableZoomLayout.d.ts +23 -1
  16. package/dist/patterns/table/tableZoomLayout.d.ts.map +1 -1
  17. package/dist/patterns/table/tableZoomLayout.js +39 -27
  18. package/dist/patterns/table/types.d.ts +3 -0
  19. package/dist/patterns/table/types.d.ts.map +1 -1
  20. package/dist/patterns/table-component/TableComponent.d.ts +6 -0
  21. package/dist/patterns/table-component/TableComponent.d.ts.map +1 -0
  22. package/dist/patterns/table-component/TableComponent.js +814 -0
  23. package/dist/patterns/table-component/buildTableColumns.d.ts +10 -0
  24. package/dist/patterns/table-component/buildTableColumns.d.ts.map +1 -0
  25. package/dist/patterns/table-component/buildTableColumns.js +65 -0
  26. package/dist/patterns/table-component/buildTableColumns.test.d.ts +2 -0
  27. package/dist/patterns/table-component/buildTableColumns.test.d.ts.map +1 -0
  28. package/dist/patterns/table-component/index.d.ts +5 -0
  29. package/dist/patterns/table-component/index.d.ts.map +1 -0
  30. package/dist/patterns/table-component/rowMetrics.d.ts +11 -0
  31. package/dist/patterns/table-component/rowMetrics.d.ts.map +1 -0
  32. package/dist/patterns/table-component/rowMetrics.js +15 -0
  33. package/dist/patterns/table-component/tableFeatures.d.ts +12 -0
  34. package/dist/patterns/table-component/tableFeatures.d.ts.map +1 -0
  35. package/dist/patterns/table-component/tableFeatures.js +14 -0
  36. package/dist/patterns/table-component/types.d.ts +207 -0
  37. package/dist/patterns/table-component/types.d.ts.map +1 -0
  38. package/dist/patterns/table-component/useCellRangeSelection.d.ts +50 -0
  39. package/dist/patterns/table-component/useCellRangeSelection.d.ts.map +1 -0
  40. package/dist/patterns/table-component/useCellRangeSelection.js +218 -0
  41. package/dist/patterns/table-component/useRowReorderDrag.d.ts +17 -0
  42. package/dist/patterns/table-component/useRowReorderDrag.d.ts.map +1 -0
  43. package/dist/patterns/table-component/useRowReorderDrag.js +109 -0
  44. package/dist/primitives/input/hint-text.d.ts +1 -2
  45. package/dist/primitives/input/hint-text.d.ts.map +1 -1
  46. package/dist/primitives/input/index.d.ts +3 -1
  47. package/dist/primitives/input/index.d.ts.map +1 -1
  48. package/dist/primitives/input/input.d.ts +1 -1
  49. package/dist/primitives/input/input.d.ts.map +1 -1
  50. package/dist/primitives/input/input.js +135 -129
  51. package/dist/primitives/input/label.d.ts +1 -2
  52. package/dist/primitives/input/label.d.ts.map +1 -1
  53. package/dist/primitives/select/index.d.ts +1 -0
  54. package/dist/primitives/select/index.d.ts.map +1 -1
  55. package/dist/primitives/select/select-item.d.ts +1 -2
  56. package/dist/primitives/select/select-item.d.ts.map +1 -1
  57. package/dist/styles/components.css +1 -1
  58. package/dist/styles/theme.css +1 -1
  59. package/package.json +6 -1
@@ -0,0 +1,814 @@
1
+ import { jsx as i, jsxs as p, Fragment as rn } from "react/jsx-runtime";
2
+ import { forwardRef as sn, useMemo as y, useState as re, useEffect as ln, useCallback as F, useRef as ie, useLayoutEffect as an, Fragment as dn } from "react";
3
+ import { functionalUpdate as Je, useTable as cn } from "@tanstack/react-table";
4
+ import { ArrowDown as un, ChevronSelectorVertical as mn, ChevronRight as $e } from "@untitledui/icons";
5
+ import { Checkbox as He } from "../../primitives/checkbox/checkbox.js";
6
+ import { ShimmerLine as fn } from "../../primitives/shimmer/shimmer.js";
7
+ import { cn as d } from "../../utils/cn.js";
8
+ import { selectionFromSingleCell as pn, getCellRangeVisualState as hn, cellRangeEdgeBoxShadow as bn } from "../table/cellRangeSelection.js";
9
+ import { useCellRangeSelection as gn } from "./useCellRangeSelection.js";
10
+ import { useRowReorderDrag as xn } from "./useRowReorderDrag.js";
11
+ import { GridNavProvider as yn } from "../table/useGridKeyboardNavigation.js";
12
+ import { ROW_DRAG_SOURCE_STYLE as wn, ROW_SOURCE_INDEX_ATTR as vn, ROW_REORDER_ATTR as Cn, FloatingRowPreview as Sn, DropIndicatorLine as In } from "../table/rowReorderDrag.js";
13
+ import { buildTableComponentColumns as Nn } from "./buildTableColumns.js";
14
+ import { HEADER_PADDING_CLASS as En, ROW_HEIGHT_CLASS as qe, CELL_PADDING_CLASS as Be } from "./rowMetrics.js";
15
+ import { tableComponentFeatures as _n } from "./tableFeatures.js";
16
+ import { TableZoomControl as Ln } from "../table/TableZoomControl.js";
17
+ import { normalizeZoomConfig as Rn, DEFAULT_TABLE_ZOOM as Tn, DEFAULT_TABLE_ZOOM_MIN as Wn, clamp as Dn, parsePxValue as _e, DEFAULT_ZOOMABLE_COLUMN_MIN_WIDTH as Ge, supportsCssZoom as kn, computeFillBaseWidth as On, computeEffectiveTableWidth as An, computeFlexColumnWidth as Fn, getTableZoomFontSize as Zn, computeNeedsHorizontalScroll as Pn, DEFAULT_COLUMN_MAX_WIDTH as Mn } from "../table/tableZoomLayout.js";
18
+ const Vn = 5, jn = kn(), Kn = (r) => r === "center" ? "text-center" : r === "right" ? "text-right" : "text-left", Xe = (r) => r === "center" ? "justify-center" : r === "right" ? "justify-end" : "justify-start", oe = (r, l) => {
19
+ const c = r.__sourceIndex;
20
+ return typeof c == "number" ? c : Number.isFinite(l) ? l : null;
21
+ }, Ye = (r) => r instanceof HTMLElement && !!r.closest(
22
+ 'button,a,input,textarea,select,[contenteditable]:not([contenteditable="false"]),[role="button"],[role="menuitem"]'
23
+ ), A = (r, l, c) => {
24
+ const [T, W] = re(l), h = r ?? T, I = ie(h), b = ie(c);
25
+ I.current = h, b.current = c;
26
+ const le = F(
27
+ (w) => {
28
+ var v;
29
+ const E = Je(w, I.current);
30
+ I.current = E, r === void 0 && W(E), (v = b.current) == null || v.call(b, E);
31
+ },
32
+ [r]
33
+ );
34
+ return [h, le];
35
+ }, Un = (r, l) => {
36
+ if (!r) return;
37
+ const c = r.sticky ? {
38
+ position: "sticky",
39
+ [r.sticky]: r.stickyOffset ?? 0,
40
+ zIndex: l ? 30 : 20,
41
+ backgroundColor: l ? "var(--color-bg-secondary-subtle)" : "var(--color-bg-primary)",
42
+ boxShadow: l || !r.sticky ? void 0 : r.sticky === "right" ? "inset 2px 0 0 0 var(--color-border-tertiary)" : "inset -2px 0 0 0 var(--color-border-tertiary)"
43
+ } : {};
44
+ return {
45
+ width: r.width,
46
+ minWidth: r.minWidth ?? r.width ?? `${se}px`,
47
+ maxWidth: r.maxWidth ?? Mn,
48
+ ...c
49
+ };
50
+ }, se = 120, Ee = (r) => !!(r.maxWidth && r.sticky === "right"), $n = (r, l = se) => _e(r.minWidth) || l, ze = (r, l, c, T) => {
51
+ if (l === "multiple") return r;
52
+ if (r === !0) return T ? { [T]: !0 } : {};
53
+ const W = c && c !== !0 ? new Set(
54
+ Object.keys(c).filter((b) => c[b])
55
+ ) : /* @__PURE__ */ new Set(), h = Object.keys(r).filter((b) => r[b]), I = h.find((b) => !W.has(b)) ?? h[0];
56
+ return I ? { [I]: !0 } : {};
57
+ };
58
+ function Hn({
59
+ data: r,
60
+ columns: l,
61
+ getRowId: c,
62
+ ariaLabel: T,
63
+ headerGroups: W,
64
+ size: h = "xs",
65
+ loading: I = !1,
66
+ loadingRowCount: b = Vn,
67
+ emptyState: le = "No data found",
68
+ showBorders: w = !1,
69
+ removeRowBorders: E = !1,
70
+ fillWidth: v = !1,
71
+ zoom: m,
72
+ zoomDisabled: Qe = !1,
73
+ className: Le,
74
+ rootClassName: et,
75
+ tableClassName: tt,
76
+ headerClassName: nt,
77
+ getRowClassName: ae,
78
+ onRowClick: de,
79
+ onRowHover: U,
80
+ toolbar: ot,
81
+ renderToolbar: ce,
82
+ pagination: Re,
83
+ summaryRow: rt,
84
+ rowGroups: Z,
85
+ renderGroupHeader: ue,
86
+ collapsedGroupIds: it,
87
+ defaultCollapsedGroupIds: st = [],
88
+ onCollapsedGroupIdsChange: lt,
89
+ enableSorting: Te = !1,
90
+ sorting: at,
91
+ defaultSorting: dt = [],
92
+ onSortingChange: ct,
93
+ columnVisibility: ut,
94
+ defaultColumnVisibility: mt = {},
95
+ onColumnVisibilityChange: ft,
96
+ columnOrder: pt,
97
+ defaultColumnOrder: ht = [],
98
+ onColumnOrderChange: bt,
99
+ selectionMode: $ = "none",
100
+ rowSelection: gt,
101
+ defaultRowSelection: xt = {},
102
+ onRowSelectionChange: yt,
103
+ expanded: wt,
104
+ defaultExpanded: vt = {},
105
+ onExpandedChange: Ct,
106
+ expansionMode: me = "multiple",
107
+ getRowCanExpand: fe,
108
+ renderExpandedContent: H,
109
+ onCellClick: pe,
110
+ onCellDoubleClick: he,
111
+ onCellActivate: D,
112
+ cellSelection: q,
113
+ onCellSelectionChange: P,
114
+ onCopyCells: St,
115
+ onPasteCells: It,
116
+ onClearCells: Nt,
117
+ onReorderRows: We,
118
+ enableRowReorder: Et,
119
+ activateOnSingleClick: _t
120
+ }, B) {
121
+ var Ke;
122
+ const u = y(
123
+ () => m ? Rn(m) : null,
124
+ [m == null ? void 0 : m.defaultZoom, m == null ? void 0 : m.minZoom, m == null ? void 0 : m.maxZoom, m == null ? void 0 : m.step]
125
+ ), [G, De] = re(
126
+ () => (u == null ? void 0 : u.defaultZoom) ?? Tn
127
+ ), C = u !== null && jn, M = C ? G / 100 : 1, X = C ? Zn(G) : void 0, Lt = (u == null ? void 0 : u.minZoom) ?? Wn;
128
+ ln(() => {
129
+ u && De(
130
+ (e) => Dn(e, u.minZoom, u.maxZoom)
131
+ );
132
+ }, [u]);
133
+ const [Rt, Tt] = A(
134
+ at,
135
+ dt,
136
+ ct
137
+ ), [Wt, Dt] = A(
138
+ ut,
139
+ mt,
140
+ ft
141
+ ), [kt, Ot] = A(
142
+ pt,
143
+ ht,
144
+ bt
145
+ ), [At, Ft] = A(
146
+ gt,
147
+ xt,
148
+ yt
149
+ ), [Zt, ke] = A(
150
+ wt,
151
+ vt,
152
+ Ct
153
+ ), be = r.length > 0 ? c(r[0], 0) : void 0, Pt = ze(
154
+ Zt,
155
+ me,
156
+ void 0,
157
+ be
158
+ ), Mt = F(
159
+ (e) => {
160
+ ke(
161
+ (t) => ze(
162
+ Je(e, t),
163
+ me,
164
+ t,
165
+ be
166
+ )
167
+ );
168
+ },
169
+ [me, be, ke]
170
+ ), [Oe, Ae] = A(
171
+ it,
172
+ st,
173
+ lt
174
+ ), ge = y(
175
+ () => new Set(Oe),
176
+ [Oe]
177
+ ), Vt = F(
178
+ (e) => Ae(
179
+ (t) => t.includes(e) ? t.filter((o) => o !== e) : [...t, e]
180
+ ),
181
+ [Ae]
182
+ ), V = ie(null), [j, Fe] = re(null);
183
+ an(() => {
184
+ if (!v) {
185
+ Fe(null);
186
+ return;
187
+ }
188
+ const e = V.current;
189
+ if (!e || typeof ResizeObserver > "u") return;
190
+ const t = () => {
191
+ const n = e.clientWidth;
192
+ n > 0 && Fe(
193
+ (s) => s === n ? s : n
194
+ );
195
+ };
196
+ t();
197
+ const o = new ResizeObserver(t);
198
+ return o.observe(e), () => o.disconnect();
199
+ }, [v, l.length, r.length, I]);
200
+ const g = y(() => {
201
+ if (!v) return null;
202
+ const e = l.reduce(
203
+ (n, s) => Ee(s) ? n + _e(s.maxWidth) : n,
204
+ 0
205
+ ), t = l.filter((n) => !Ee(n));
206
+ return { minTableWidth: t.reduce(
207
+ (n, s) => n + $n(
208
+ s,
209
+ C ? _e(Ge) : se
210
+ ),
211
+ 0
212
+ ) + e, fixedTotal: e, flexibleCount: t.length };
213
+ }, [v, l, C]), xe = y(
214
+ () => g ? On(j, g.minTableWidth) : null,
215
+ [j, g]
216
+ ), ye = Pn(
217
+ xe,
218
+ j,
219
+ M
220
+ ), Y = y(
221
+ () => An(xe, j, M),
222
+ [xe, j, M]
223
+ ), Ze = y(() => !g || g.flexibleCount === 0 ? null : Fn(
224
+ Y,
225
+ g.fixedTotal,
226
+ g.flexibleCount
227
+ ), [g, Y]), z = (e, t) => {
228
+ const o = Un(e, t);
229
+ return !v || !e ? o : Ee(e) ? {
230
+ ...o,
231
+ width: e.maxWidth,
232
+ minWidth: e.maxWidth,
233
+ maxWidth: e.maxWidth
234
+ } : Ze == null ? o : {
235
+ ...o,
236
+ width: `${Ze}px`,
237
+ minWidth: e.minWidth ?? (C ? Ge : `${se}px`)
238
+ };
239
+ }, we = y(
240
+ () => new Map(l.map((e) => [e.id, e])),
241
+ [l]
242
+ ), jt = y(
243
+ () => Nn(l, W),
244
+ [l, W]
245
+ ), N = cn({
246
+ features: _n,
247
+ data: r,
248
+ columns: jt,
249
+ getRowId: c,
250
+ enableSorting: Te,
251
+ enableCellSpanning: !0,
252
+ enableRowSelection: $ !== "none",
253
+ enableMultiRowSelection: $ === "multiple",
254
+ getRowCanExpand: fe && H ? (e) => fe(e.original) : () => !1,
255
+ state: {
256
+ sorting: Rt,
257
+ columnVisibility: Wt,
258
+ columnOrder: kt,
259
+ rowSelection: At,
260
+ expanded: Pt
261
+ },
262
+ onSortingChange: Tt,
263
+ onColumnVisibilityChange: Dt,
264
+ onColumnOrderChange: Ot,
265
+ onRowSelectionChange: Ft,
266
+ onExpandedChange: Mt
267
+ }), J = $ !== "none", Kt = !!(fe && H), Ut = J ? 1 : 0, $t = N.getVisibleLeafColumns().length, Q = Math.max(
268
+ $t + Ut,
269
+ 1
270
+ ), Ht = Math.max(N.getHeaderGroups().length, 1), L = N.getRowModel().rows, ve = C && u ? /* @__PURE__ */ i(
271
+ Ln,
272
+ {
273
+ value: G,
274
+ defaultValue: u.defaultZoom,
275
+ minValue: Lt,
276
+ maxValue: u.maxZoom,
277
+ step: u.step,
278
+ onChange: De,
279
+ isDisabled: Qe
280
+ }
281
+ ) : null, Pe = ce ? ce({ zoomControl: ve, zoomPercent: G }) : ot, Me = !ce && ve ? /* @__PURE__ */ i("div", { className: "flex justify-end", children: ve }) : null, qt = !!(Pe || Me || Re), Bt = y(() => {
282
+ const e = C ? {
283
+ zoom: M,
284
+ "--table-zoom-font-size": X ? `${X}px` : void 0
285
+ } : void 0;
286
+ return !v || !g ? C ? { ...e, width: "max-content", minWidth: "100%" } : void 0 : C ? {
287
+ ...e,
288
+ tableLayout: "fixed",
289
+ width: `${Y ?? g.minTableWidth}px`
290
+ } : {
291
+ tableLayout: "fixed",
292
+ width: ye ? `${g.minTableWidth}px` : "100%"
293
+ };
294
+ }, [
295
+ Y,
296
+ v,
297
+ g,
298
+ ye,
299
+ C,
300
+ M,
301
+ X
302
+ ]), Gt = ie(
303
+ null
304
+ ), [k, Xt] = re(null), Yt = !!D, zt = F(
305
+ (e, t, o) => {
306
+ if (Gt.current = { rowId: e, columnKey: t }, !P) return;
307
+ const n = q;
308
+ n != null && n.anchor.rowId === e && n.anchor.columnKey === t && n.focus.rowId === e && n.focus.columnKey === t || P(
309
+ pn({
310
+ rowId: e,
311
+ columnKey: t,
312
+ sourceIndex: o ?? null
313
+ })
314
+ );
315
+ },
316
+ [P, q]
317
+ ), Jt = F(
318
+ (e) => {
319
+ Xt((t) => t === e || t && e && t.rowId === e.rowId && t.columnKey === e.columnKey ? t : e);
320
+ },
321
+ []
322
+ ), ee = !!We && Et !== !1, f = xn({
323
+ enabled: ee,
324
+ onReorderRows: We,
325
+ containerRef: V
326
+ }), Qt = F(
327
+ (e, t, o) => {
328
+ var n;
329
+ return {
330
+ row: e.original,
331
+ rowId: e.id,
332
+ columnId: t,
333
+ value: o,
334
+ rowIndex: e.index,
335
+ sourceIndex: oe(e.original, e.index),
336
+ isRowDragging: ((n = f.session) == null ? void 0 : n.active) === !0 && f.session.rowId === e.id,
337
+ startRowDrag: ee ? (s) => f.startDrag(
338
+ s,
339
+ e.id,
340
+ oe(e.original, e.index) ?? e.index,
341
+ e.original
342
+ ) : void 0
343
+ };
344
+ },
345
+ // eslint-disable-next-line react-hooks/exhaustive-deps
346
+ [ee, f.startDrag, f.session]
347
+ ), Ce = L.map((e) => e.id).join("\0"), Se = y(
348
+ () => Ce ? Ce.split("\0") : [],
349
+ [Ce]
350
+ ), Ie = N.getVisibleLeafColumns().map((e) => e.id).join("\0"), Ne = y(
351
+ () => Ie ? Ie.split("\0") : [],
352
+ [Ie]
353
+ ), O = typeof P == "function", te = gn({
354
+ enabled: O,
355
+ selection: q,
356
+ onSelectionChange: P,
357
+ onCopyCells: St,
358
+ onPasteCells: It,
359
+ onClearCells: Nt,
360
+ onActivateCell: D ? (e) => {
361
+ const t = L.find((o) => o.id === e.rowId);
362
+ t && D({
363
+ row: t.original,
364
+ rowId: e.rowId,
365
+ columnId: e.columnKey,
366
+ value: void 0,
367
+ rowIndex: t.index,
368
+ sourceIndex: e.sourceIndex ?? oe(t.original, t.index)
369
+ });
370
+ } : void 0,
371
+ activateOnSingleClick: _t,
372
+ containerRef: V,
373
+ rowIds: Se,
374
+ columnKeys: Ne
375
+ }), en = y(() => {
376
+ if (!(Z != null && Z.length)) return L.map((n) => ({ kind: "row", row: n }));
377
+ const e = new Map(L.map((n) => [n.id, n])), t = /* @__PURE__ */ new Set(), o = [];
378
+ for (const n of Z) {
379
+ const s = n.rowIds.map((x) => e.get(x)).filter((x) => x !== void 0);
380
+ s.length !== 0 && (o.push({
381
+ kind: "group",
382
+ group: { id: n.id, label: n.label, rowCount: s.length }
383
+ }), s.forEach((x) => t.add(x.id)), !ge.has(n.id) && s.forEach((x) => o.push({ kind: "row", row: x })));
384
+ }
385
+ for (const n of L)
386
+ t.has(n.id) || o.push({ kind: "row", row: n });
387
+ return o;
388
+ }, [Z, L, ge]), tn = (e) => {
389
+ const t = ge.has(e.id), o = () => Vt(e.id);
390
+ return /* @__PURE__ */ i("tr", { className: "bg-secondary_subtle", children: /* @__PURE__ */ i(
391
+ "td",
392
+ {
393
+ colSpan: Q,
394
+ className: d(
395
+ !ue && "py-1.5",
396
+ w && "border-r border-secondary last:border-r-0"
397
+ ),
398
+ children: ue ? ue({
399
+ id: e.id,
400
+ label: e.label,
401
+ rowCount: e.rowCount,
402
+ isCollapsed: t,
403
+ toggle: o
404
+ }) : /* @__PURE__ */ p(
405
+ "button",
406
+ {
407
+ type: "button",
408
+ className: "flex w-full items-center gap-2 px-2 text-left text-xs font-medium text-secondary",
409
+ onClick: o,
410
+ "aria-expanded": !t,
411
+ children: [
412
+ /* @__PURE__ */ i(
413
+ $e,
414
+ {
415
+ className: d(
416
+ "size-4 shrink-0 text-fg-quaternary transition-transform",
417
+ !t && "rotate-90"
418
+ )
419
+ }
420
+ ),
421
+ /* @__PURE__ */ i("span", { className: "truncate", children: e.label || "(Empty)" }),
422
+ /* @__PURE__ */ p("span", { className: "text-tertiary", children: [
423
+ "(",
424
+ e.rowCount,
425
+ ")"
426
+ ] })
427
+ ]
428
+ }
429
+ )
430
+ }
431
+ ) }, `group-${e.id}`);
432
+ }, Ve = /* @__PURE__ */ p(
433
+ "div",
434
+ {
435
+ ref: (e) => {
436
+ V.current = e, typeof B == "function" ? B(e) : B && (B.current = e);
437
+ },
438
+ onPointerDownCapture: O ? te.onPointerDownCapture : void 0,
439
+ onKeyDownCapture: O ? te.onKeyDownCapture : void 0,
440
+ onClickCapture: O ? te.onClickCapture : void 0,
441
+ onDoubleClickCapture: O ? te.onDoubleClickCapture : void 0,
442
+ className: d(
443
+ "w-full rounded-lg bg-primary",
444
+ C || !v || ye ? "overflow-x-auto" : "overflow-x-hidden",
445
+ w && "rounded-xl border border-secondary",
446
+ et
447
+ ),
448
+ children: [
449
+ /* @__PURE__ */ p(
450
+ "table",
451
+ {
452
+ "aria-label": T,
453
+ "data-table-zoom-typography": X !== void 0 ? "" : void 0,
454
+ className: d(
455
+ "w-full border-separate border-spacing-0 overflow-x-hidden",
456
+ tt
457
+ ),
458
+ style: Bt,
459
+ children: [
460
+ /* @__PURE__ */ i(
461
+ "thead",
462
+ {
463
+ className: d(
464
+ "sticky top-0 z-30 rounded-t-lg bg-secondary_subtle [&>tr>th]:h-9 [&>tr>th:first-child]:rounded-tl-lg [&>tr>th:last-child]:rounded-tr-lg",
465
+ w && "[&>tr>th]:border-b [&>tr>th]:border-secondary [&>tr>th:first-child]:rounded-bl-none [&>tr>th:last-child]:rounded-br-none",
466
+ nt
467
+ ),
468
+ children: N.getHeaderGroups().map((e, t) => /* @__PURE__ */ p("tr", { children: [
469
+ J && t === 0 ? /* @__PURE__ */ i(
470
+ "th",
471
+ {
472
+ rowSpan: Ht,
473
+ className: d(
474
+ "relative w-10 min-w-10 p-0 align-middle",
475
+ w && "border-r border-secondary"
476
+ ),
477
+ children: $ === "multiple" ? /* @__PURE__ */ i(
478
+ "div",
479
+ {
480
+ className: "flex items-center justify-center",
481
+ onClick: (o) => o.stopPropagation(),
482
+ children: /* @__PURE__ */ i(
483
+ He,
484
+ {
485
+ checked: N.getIsAllRowsSelected() ? !0 : N.getIsSomeRowsSelected() ? "indeterminate" : !1,
486
+ onCheckedChange: (o) => N.toggleAllRowsSelected(o === !0),
487
+ "aria-label": "Select all rows",
488
+ className: "items-center justify-center"
489
+ }
490
+ )
491
+ }
492
+ ) : null
493
+ }
494
+ ) : null,
495
+ e.headers.map((o) => {
496
+ if (o.rowSpan === 0) return null;
497
+ const n = we.get(o.column.id), s = o.column.getIsSorted(), x = Te && !o.isPlaceholder && o.column.getCanSort(), a = n != null && n.renderHeader ? n.renderHeader({
498
+ columnId: n.id,
499
+ label: n.header
500
+ }) : o.isPlaceholder ? null : N.FlexRender({ header: o });
501
+ return /* @__PURE__ */ i(
502
+ "th",
503
+ {
504
+ colSpan: o.colSpan,
505
+ rowSpan: o.rowSpan,
506
+ scope: o.colSpan > 1 ? "colgroup" : "col",
507
+ "aria-sort": s === "asc" ? "ascending" : s === "desc" ? "descending" : void 0,
508
+ style: z(n, !0),
509
+ className: d(
510
+ "relative overflow-hidden p-0 outline-hidden focus-within:z-1 focus-within:ring-2 focus-within:ring-focus-ring focus-within:ring-inset",
511
+ En[h],
512
+ w && "border-r border-secondary last:border-r-0",
513
+ n == null ? void 0 : n.headerClassName
514
+ ),
515
+ children: x ? /* @__PURE__ */ p(
516
+ "button",
517
+ {
518
+ type: "button",
519
+ className: d(
520
+ "flex w-full items-center gap-1 overflow-hidden rounded outline-none",
521
+ Xe(n == null ? void 0 : n.align)
522
+ ),
523
+ onClick: o.column.getToggleSortingHandler(),
524
+ "aria-label": `Sort by ${String((n == null ? void 0 : n.header) ?? o.column.id)}`,
525
+ children: [
526
+ /* @__PURE__ */ i("span", { className: "overflow-hidden text-ellipsis whitespace-nowrap text-xs font-medium text-secondary", children: a }),
527
+ s ? /* @__PURE__ */ i(
528
+ un,
529
+ {
530
+ className: d(
531
+ "size-3 shrink-0 stroke-[3px] text-fg-quaternary",
532
+ s === "asc" && "rotate-180"
533
+ )
534
+ }
535
+ ) : /* @__PURE__ */ i(
536
+ mn,
537
+ {
538
+ size: 12,
539
+ strokeWidth: 3,
540
+ className: "shrink-0 text-fg-quaternary"
541
+ }
542
+ )
543
+ ]
544
+ }
545
+ ) : /* @__PURE__ */ i(
546
+ "div",
547
+ {
548
+ className: d(
549
+ "flex items-center gap-1 overflow-hidden",
550
+ Xe(n == null ? void 0 : n.align)
551
+ ),
552
+ children: /* @__PURE__ */ i("div", { className: "flex items-center overflow-hidden text-ellipsis whitespace-nowrap text-xs font-medium text-secondary", children: a })
553
+ }
554
+ )
555
+ },
556
+ o.id
557
+ );
558
+ })
559
+ ] }, e.id))
560
+ }
561
+ ),
562
+ /* @__PURE__ */ p("tbody", { children: [
563
+ I ? Array.from({ length: b }, (e, t) => /* @__PURE__ */ p(
564
+ "tr",
565
+ {
566
+ className: qe[h],
567
+ "aria-hidden": "true",
568
+ children: [
569
+ J ? /* @__PURE__ */ i(
570
+ "td",
571
+ {
572
+ className: d(
573
+ "w-10 min-w-10",
574
+ w && "border-r border-secondary",
575
+ !E && "border-b border-tertiary"
576
+ )
577
+ }
578
+ ) : null,
579
+ N.getVisibleLeafColumns().map((o) => {
580
+ const n = we.get(o.id);
581
+ return /* @__PURE__ */ i(
582
+ "td",
583
+ {
584
+ style: z(n, !1),
585
+ className: d(
586
+ "relative overflow-hidden text-secondary",
587
+ Be[h],
588
+ w && "border-r border-secondary last:border-r-0",
589
+ !E && "border-b border-tertiary",
590
+ n == null ? void 0 : n.cellClassName
591
+ ),
592
+ children: /* @__PURE__ */ i(
593
+ fn,
594
+ {
595
+ height: "14px",
596
+ width: "75%",
597
+ className: "rounded"
598
+ }
599
+ )
600
+ },
601
+ o.id
602
+ );
603
+ })
604
+ ]
605
+ },
606
+ `loading-${t}`
607
+ )) : L.length === 0 ? /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i(
608
+ "td",
609
+ {
610
+ colSpan: Q,
611
+ className: "border-b border-secondary px-3 py-3 text-left text-xs text-placeholder_subtle",
612
+ children: le
613
+ }
614
+ ) }) : en.map((e) => {
615
+ var x;
616
+ if (e.kind === "group")
617
+ return tn(e.group);
618
+ const t = e.row, o = Kt && t.getCanExpand(), n = o && t.getIsExpanded(), s = t.getVisibleCells();
619
+ return /* @__PURE__ */ p(dn, { children: [
620
+ /* @__PURE__ */ p(
621
+ "tr",
622
+ {
623
+ ...ee ? {
624
+ [Cn]: t.id,
625
+ [vn]: String(
626
+ oe(t.original, t.index) ?? t.index
627
+ )
628
+ } : {},
629
+ style: (x = f.session) != null && x.active && f.session.rowId === t.id ? wn : void 0,
630
+ className: d(
631
+ // `focus-visible`, not `focus-within`: the ring marks the row itself being keyboard-focused.
632
+ // `focus-within` also fires for anything inside it, so an open cell
633
+ // editor outlined the entire row.
634
+ "relative outline-focus-ring transition-colors hover:bg-secondary_subtle focus-visible:outline-2 focus-visible:-outline-offset-2",
635
+ qe[h],
636
+ t.getIsSelected() && "bg-secondary",
637
+ de && "cursor-pointer",
638
+ ae == null ? void 0 : ae(t.original)
639
+ ),
640
+ onClick: (a) => {
641
+ !de || Ye(a.target) || de(t.original);
642
+ },
643
+ onMouseEnter: U ? () => U(t.original, !0) : void 0,
644
+ onMouseLeave: U ? () => U(t.original, !1) : void 0,
645
+ children: [
646
+ J ? /* @__PURE__ */ i(
647
+ "td",
648
+ {
649
+ className: d(
650
+ "relative w-10 min-w-10 p-0 text-center",
651
+ w && "border-r border-secondary",
652
+ // Matches the data cells, so the row separator
653
+ // runs the full width of the table.
654
+ !E && !n && "border-b border-tertiary"
655
+ ),
656
+ children: /* @__PURE__ */ i(
657
+ "div",
658
+ {
659
+ className: "flex items-center justify-center",
660
+ onClick: (a) => a.stopPropagation(),
661
+ onKeyDown: (a) => a.stopPropagation(),
662
+ children: /* @__PURE__ */ i(
663
+ He,
664
+ {
665
+ checked: t.getIsSelected(),
666
+ onCheckedChange: (a) => t.toggleSelected(a === !0),
667
+ "aria-label": `Select row ${t.id}`,
668
+ className: "items-center justify-center"
669
+ }
670
+ )
671
+ }
672
+ )
673
+ }
674
+ ) : null,
675
+ s.map((a, Ue) => {
676
+ if (a.getIsCovered()) return null;
677
+ const S = we.get(a.column.id);
678
+ if (!S) return null;
679
+ const K = Qt(
680
+ t,
681
+ S.id,
682
+ a.getValue()
683
+ ), nn = S.renderCell ? S.renderCell(K) : String(a.getValue() ?? ""), _ = O ? hn(
684
+ q,
685
+ t.id,
686
+ S.id,
687
+ Se,
688
+ Ne
689
+ ) : null, ne = !!(_ != null && _.inRange), on = (k == null ? void 0 : k.rowId) === t.id && (k == null ? void 0 : k.columnKey) === S.id;
690
+ return /* @__PURE__ */ i(
691
+ "td",
692
+ {
693
+ colSpan: a.getColSpan(),
694
+ rowSpan: a.getRowSpan(),
695
+ style: ne && _ ? {
696
+ ...z(S, !1),
697
+ boxShadow: bn(
698
+ _.edges
699
+ )
700
+ } : z(S, !1),
701
+ "data-table-component-cell": "",
702
+ "data-grid-cell": "",
703
+ "data-grid-row-id": t.id,
704
+ "data-grid-col-key": S.id,
705
+ "data-grid-source-index": K.sourceIndex ?? void 0,
706
+ tabIndex: D ? 0 : void 0,
707
+ className: d(
708
+ // `overflow-hidden`, never `overflow-x-hidden`: when `overflow-x` is not
709
+ // `visible` the browser computes `overflow-y` to `auto`, turning
710
+ // every cell into its own scroll container that swallows the
711
+ // wheel before the table can scroll.
712
+ "relative text-secondary outline-focus-ring focus-visible:z-1 focus-visible:outline-2 focus-visible:-outline-offset-2",
713
+ // The cell holding an open editor must not clip it: a wrapped
714
+ // multi-line value has to be visible, and the row only grows
715
+ // around content the cell is allowed to show.
716
+ on ? "z-1 overflow-visible" : "overflow-hidden",
717
+ Be[h],
718
+ Kn(S.align),
719
+ w && "border-r border-secondary last:border-r-0",
720
+ !E && !n && !ne && "border-b border-tertiary",
721
+ ne && "z-1 outline-hidden",
722
+ ne && !(_ != null && _.isAnchor) && "bg-utility-brand-25",
723
+ S.cellClassName
724
+ ),
725
+ onClick: (R) => {
726
+ pe == null || pe(K), Ue === 0 && o && Ye(R.target) && R.stopPropagation();
727
+ },
728
+ onDoubleClick: () => he == null ? void 0 : he(K),
729
+ onKeyDown: (R) => {
730
+ R.key !== "Enter" || !D || (R.preventDefault(), D(K));
731
+ },
732
+ children: /* @__PURE__ */ p("div", { className: "flex min-w-0 items-center gap-2", children: [
733
+ Ue === 0 && o ? /* @__PURE__ */ i(
734
+ "button",
735
+ {
736
+ type: "button",
737
+ className: d(
738
+ "-ml-1 flex shrink-0 cursor-pointer items-center justify-center rounded p-1 transition-transform duration-200 ease-in-out hover:bg-secondary_subtle",
739
+ n && "rotate-90"
740
+ ),
741
+ "aria-label": n ? "Collapse row" : "Expand row",
742
+ "aria-expanded": n,
743
+ "aria-controls": `${t.id}-detail`,
744
+ onClick: (R) => {
745
+ R.stopPropagation(), t.toggleExpanded();
746
+ },
747
+ children: /* @__PURE__ */ i($e, { className: "size-4 text-fg-quaternary" })
748
+ }
749
+ ) : null,
750
+ /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: nn })
751
+ ] })
752
+ },
753
+ a.id
754
+ );
755
+ })
756
+ ]
757
+ }
758
+ ),
759
+ n && H ? /* @__PURE__ */ i(
760
+ "tr",
761
+ {
762
+ id: `${t.id}-detail`,
763
+ className: "relative bg-secondary_subtle",
764
+ children: /* @__PURE__ */ i("td", { colSpan: Q, className: "p-0", children: H({
765
+ row: t.original,
766
+ rowId: t.id,
767
+ colSpan: Q,
768
+ collapse: () => t.toggleExpanded(!1)
769
+ }) })
770
+ }
771
+ ) : null
772
+ ] }, t.id);
773
+ }),
774
+ !I && rt
775
+ ] })
776
+ ]
777
+ }
778
+ ),
779
+ ((Ke = f.session) == null ? void 0 : Ke.active) && /* @__PURE__ */ p(rn, { children: [
780
+ /* @__PURE__ */ i(Sn, { session: f.session }),
781
+ f.session.dropLineY !== null && /* @__PURE__ */ i(
782
+ In,
783
+ {
784
+ y: f.session.dropLineY,
785
+ left: f.session.dropLineLeft,
786
+ width: f.session.dropLineWidth
787
+ }
788
+ )
789
+ ] })
790
+ ]
791
+ }
792
+ ), je = qt ? /* @__PURE__ */ p("div", { className: d("flex flex-col gap-3", Le), children: [
793
+ Pe,
794
+ Me,
795
+ Ve,
796
+ Re
797
+ ] }) : /* @__PURE__ */ i("div", { className: Le, children: Ve });
798
+ return Yt ? /* @__PURE__ */ i(
799
+ yn,
800
+ {
801
+ rowIds: Se,
802
+ columnKeys: Ne,
803
+ containerRef: V,
804
+ onSelectCell: zt,
805
+ onEditingCellChange: Jt,
806
+ children: je
807
+ }
808
+ ) : je;
809
+ }
810
+ const co = sn(Hn);
811
+ export {
812
+ co as TableComponent,
813
+ co as default
814
+ };