@pibit.ai/cure-design-system 0.3.40 → 0.3.45

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