@pibit.ai/cure-design-system 0.3.16 → 1.0.0

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