@overdoser/react-toolkit 0.6.0 → 0.8.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 (116) hide show
  1. package/AGENTS.md +6 -0
  2. package/CHANGELOG.md +82 -0
  3. package/components/ActionButton/ActionButton.d.ts +105 -0
  4. package/components/ActionButton/ActionButton.js +211 -0
  5. package/components/ActionButton/ActionButton.module.scss.js +47 -0
  6. package/components/ActionButton/CopyButton.d.ts +31 -0
  7. package/components/ActionButton/CopyButton.js +66 -0
  8. package/components/ActionButton/index.d.ts +4 -0
  9. package/components/Alert/Alert.js +82 -0
  10. package/components/Alert/Alert.module.scss.js +25 -0
  11. package/components/Avatar/Avatar.js +57 -0
  12. package/components/Avatar/Avatar.module.scss.js +43 -0
  13. package/components/Badge/Badge.js +38 -0
  14. package/components/Badge/Badge.module.scss.js +31 -0
  15. package/components/Breadcrumbs/Breadcrumbs.js +49 -0
  16. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +17 -0
  17. package/components/Button/Button.js +57 -0
  18. package/components/Button/Button.module.scss.js +47 -0
  19. package/components/Chart/AreaChart.js +244 -0
  20. package/components/Chart/Axis.js +45 -0
  21. package/components/Chart/BarChart.js +353 -0
  22. package/components/Chart/Chart.module.scss.js +61 -0
  23. package/components/Chart/ChartContainer.js +41 -0
  24. package/components/Chart/ChartLegend.js +31 -0
  25. package/components/Chart/ChartTooltip.js +42 -0
  26. package/components/Chart/LineChart.js +236 -0
  27. package/components/Chart/PieChart.js +248 -0
  28. package/components/Chart/RadarChart.js +221 -0
  29. package/components/Chart/Sparkline.js +69 -0
  30. package/components/Chart/TradingChart.js +732 -0
  31. package/components/Chart/scales.js +39 -0
  32. package/components/Chart/trading/indicators.js +68 -0
  33. package/components/Chart/trading/period.js +71 -0
  34. package/components/Chart/useChartDimensions.js +23 -0
  35. package/components/Divider/Divider.js +36 -0
  36. package/components/Divider/Divider.module.scss.js +31 -0
  37. package/components/Draggable/Draggable.js +155 -0
  38. package/components/Draggable/Draggable.module.scss.js +17 -0
  39. package/components/Drawer/Drawer.js +126 -0
  40. package/components/Drawer/Drawer.module.scss.js +117 -0
  41. package/components/Dropdown/Dropdown.js +142 -0
  42. package/components/Dropdown/Dropdown.module.scss.js +35 -0
  43. package/components/Dropdown/DropdownItem.js +31 -0
  44. package/components/Dropzone/Dropzone.js +107 -0
  45. package/components/Dropzone/Dropzone.module.scss.js +21 -0
  46. package/components/Form/Form.js +36 -0
  47. package/components/Form/Form.module.scss.js +29 -0
  48. package/components/Form/FormField.js +76 -0
  49. package/components/Form/FormRow.js +9 -0
  50. package/components/Form/formFieldDefaults.js +5 -0
  51. package/components/Link/Link.js +59 -0
  52. package/components/Link/Link.module.scss.js +16 -0
  53. package/components/List/List.js +46 -0
  54. package/components/List/List.module.scss.js +21 -0
  55. package/components/Modal/Modal.js +109 -0
  56. package/components/Modal/Modal.module.scss.js +31 -0
  57. package/components/Pagination/Pagination.js +84 -0
  58. package/components/Pagination/Pagination.module.scss.js +23 -0
  59. package/components/Pagination/paginationRange.js +24 -0
  60. package/components/Popover/Popover.js +138 -0
  61. package/components/Popover/Popover.module.scss.js +21 -0
  62. package/components/Skeleton/Skeleton.js +50 -0
  63. package/components/Skeleton/Skeleton.module.scss.js +25 -0
  64. package/components/Spinner/Spinner.js +25 -0
  65. package/components/Spinner/Spinner.module.scss.js +20 -0
  66. package/components/Table/Table.d.ts +61 -6
  67. package/components/Table/Table.js +284 -0
  68. package/components/Table/Table.module.scss.js +59 -0
  69. package/components/Table/useTableSort.d.ts +7 -5
  70. package/components/Table/useTableSort.js +44 -0
  71. package/components/Tabs/Tabs.js +163 -0
  72. package/components/Tabs/Tabs.module.scss.js +53 -0
  73. package/components/Timer/Timer.js +159 -0
  74. package/components/Timer/Timer.module.scss.js +55 -0
  75. package/components/Toast/Toast.js +133 -0
  76. package/components/Toast/Toast.module.scss.js +62 -0
  77. package/components/Toast/toastStore.js +62 -0
  78. package/components/ToggleIconButton/ToggleIconButton.d.ts +62 -0
  79. package/components/ToggleIconButton/ToggleIconButton.js +58 -0
  80. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +27 -0
  81. package/components/ToggleIconButton/index.d.ts +2 -0
  82. package/components/Tooltip/Tooltip.js +86 -0
  83. package/components/Tooltip/Tooltip.module.scss.js +30 -0
  84. package/components/Typography/Typography.js +37 -0
  85. package/components/Typography/Typography.module.scss.js +53 -0
  86. package/components/inputs/Checkbox/Checkbox.js +50 -0
  87. package/components/inputs/Checkbox/Checkbox.module.scss.js +15 -0
  88. package/components/inputs/Checkbox/CheckboxGroup.js +111 -0
  89. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +31 -0
  90. package/components/inputs/DatePicker/DatePicker.js +229 -0
  91. package/components/inputs/DatePicker/DatePicker.module.scss.js +45 -0
  92. package/components/inputs/DatePicker/dateUtils.js +41 -0
  93. package/components/inputs/Input/Input.js +50 -0
  94. package/components/inputs/Input/Input.module.scss.js +25 -0
  95. package/components/inputs/NumberInput/NumberInput.js +134 -0
  96. package/components/inputs/NumberInput/NumberInput.module.scss.js +25 -0
  97. package/components/inputs/Radio/Radio.js +68 -0
  98. package/components/inputs/Radio/Radio.module.scss.js +13 -0
  99. package/components/inputs/Select/Select.js +520 -0
  100. package/components/inputs/Select/Select.module.scss.js +69 -0
  101. package/components/inputs/Slider/Slider.js +128 -0
  102. package/components/inputs/Slider/Slider.module.scss.js +15 -0
  103. package/components/inputs/Textarea/Textarea.js +58 -0
  104. package/components/inputs/Textarea/Textarea.module.scss.js +25 -0
  105. package/hooks/useClickOutside.js +15 -0
  106. package/hooks/useFocusTrap.js +39 -0
  107. package/hooks/useKeyboard.js +19 -0
  108. package/hooks/usePortalPosition.js +20 -0
  109. package/index.css +1 -1
  110. package/index.d.ts +4 -0
  111. package/index.js +119 -6575
  112. package/index.layered.css +1 -1
  113. package/llms.txt +123 -5
  114. package/manifest.json +230 -2
  115. package/package.json +3 -2
  116. package/recipes/comparison-table.tsx +123 -0
@@ -0,0 +1,284 @@
1
+ import { jsxs as y, jsx as s } from "react/jsx-runtime";
2
+ import { useMemo as _, useCallback as A, useRef as X, useState as ne } from "react";
3
+ import d from "clsx";
4
+ import n from "./Table.module.scss.js";
5
+ import { useTableSort as re } from "./useTableSort.js";
6
+ function ae({ direction: i, sortIndex: o }) {
7
+ return /* @__PURE__ */ y("span", { className: n.sortIndicator, "aria-hidden": "true", children: [
8
+ /* @__PURE__ */ s("span", { className: d(n.sortArrow, i === "asc" && n.sortArrowActive), children: "▲" }),
9
+ /* @__PURE__ */ s("span", { className: d(n.sortArrow, i === "desc" && n.sortArrowActive), children: "▼" }),
10
+ o !== void 0 && o >= 0 && /* @__PURE__ */ s("span", { className: n.sortIndex, children: o + 1 })
11
+ ] });
12
+ }
13
+ function ie({
14
+ page: i,
15
+ pageSize: o,
16
+ totalRows: b,
17
+ pageSizeOptions: h = [10, 25, 50, 100],
18
+ onPageChange: v,
19
+ paginatorClasses: C
20
+ }) {
21
+ const c = Math.max(1, Math.ceil(b / o)), P = (i - 1) * o + 1, R = Math.min(i * o, b), S = _(() => {
22
+ const r = [];
23
+ if (c <= 7)
24
+ for (let u = 1; u <= c; u++) r.push(u);
25
+ else {
26
+ r.push(1), i > 3 && r.push("ellipsis");
27
+ for (let u = Math.max(2, i - 1); u <= Math.min(c - 1, i + 1); u++)
28
+ r.push(u);
29
+ i < c - 2 && r.push("ellipsis"), r.push(c);
30
+ }
31
+ return r;
32
+ }, [i, c]);
33
+ return /* @__PURE__ */ y("nav", { className: d(n.paginator, C?.paginator), "aria-label": "Table pagination", children: [
34
+ /* @__PURE__ */ y("div", { className: n.paginatorInfo, children: [
35
+ /* @__PURE__ */ s("span", { className: n.paginatorText, children: b > 0 ? `${P}–${R} of ${b}` : "No results" }),
36
+ h.length > 1 && /* @__PURE__ */ s(
37
+ "select",
38
+ {
39
+ className: n.pageSizeSelect,
40
+ value: o,
41
+ onChange: (r) => v(1, Number(r.target.value)),
42
+ "aria-label": "Rows per page",
43
+ children: h.map((r) => /* @__PURE__ */ y("option", { value: r, children: [
44
+ r,
45
+ " / page"
46
+ ] }, r))
47
+ }
48
+ )
49
+ ] }),
50
+ /* @__PURE__ */ y("div", { className: n.paginatorNav, children: [
51
+ /* @__PURE__ */ s(
52
+ "button",
53
+ {
54
+ type: "button",
55
+ className: d(n.pageButton, C?.pageButton),
56
+ disabled: i <= 1,
57
+ onClick: () => v(i - 1, o),
58
+ "aria-label": "Previous page",
59
+ children: "‹"
60
+ }
61
+ ),
62
+ S.map(
63
+ (r, u) => r === "ellipsis" ? /* @__PURE__ */ s("span", { className: n.pageEllipsis, children: "…" }, `ellipsis-${u}`) : /* @__PURE__ */ s(
64
+ "button",
65
+ {
66
+ type: "button",
67
+ className: d(n.pageButton, r === i && n.pageButtonActive, C?.pageButton),
68
+ onClick: () => v(r, o),
69
+ "aria-label": `Page ${r}`,
70
+ "aria-current": r === i ? "page" : void 0,
71
+ children: r
72
+ },
73
+ r
74
+ )
75
+ ),
76
+ /* @__PURE__ */ s(
77
+ "button",
78
+ {
79
+ type: "button",
80
+ className: d(n.pageButton, C?.pageButton),
81
+ disabled: i >= c,
82
+ onClick: () => v(i + 1, o),
83
+ "aria-label": "Next page",
84
+ children: "›"
85
+ }
86
+ )
87
+ ] })
88
+ ] });
89
+ }
90
+ function se({
91
+ data: i,
92
+ columns: o,
93
+ sortConfig: b,
94
+ onSort: h,
95
+ multiSort: v = !0,
96
+ scrollable: C = !1,
97
+ dragScroll: c = !1,
98
+ striped: P = !1,
99
+ hoverable: R = !1,
100
+ compact: S = !1,
101
+ className: r,
102
+ style: u,
103
+ rowKey: j,
104
+ rowClassName: T,
105
+ rowStyle: $,
106
+ emptyMessage: F = "No data",
107
+ pagination: m,
108
+ classes: g
109
+ }) {
110
+ const x = h !== void 0, G = C || c, {
111
+ sortedData: J,
112
+ sortConfig: Q,
113
+ requestSort: E,
114
+ requestMultiSort: K
115
+ } = re(i, b), p = x ? b ?? [] : Q, M = x ? i : J, W = _(() => {
116
+ if (!m || x) return M;
117
+ const e = (m.page - 1) * m.pageSize;
118
+ return M.slice(e, e + m.pageSize);
119
+ }, [M, m, x]), V = m?.totalRows ?? M.length, Y = A(
120
+ (e, t, l) => {
121
+ const N = v && (t.ctrlKey || t.metaKey || t.shiftKey), B = l === "asc" ? "desc" : "asc";
122
+ if (x)
123
+ if (N) {
124
+ const a = p.findIndex((I) => I.key === e);
125
+ let f;
126
+ a === -1 ? f = [...p, { key: e, direction: l }] : p[a].direction === l ? f = p.map(
127
+ (I, w) => w === a ? { key: e, direction: B } : I
128
+ ) : f = p.filter((I, w) => w !== a), h(f);
129
+ } else {
130
+ const a = p.find((f) => f.key === e);
131
+ a ? a.direction === l ? h([{ key: e, direction: B }]) : h([]) : h([{ key: e, direction: l }]);
132
+ }
133
+ else
134
+ N ? K(e, l) : E(e, l);
135
+ },
136
+ [
137
+ x,
138
+ v,
139
+ p,
140
+ h,
141
+ E,
142
+ K
143
+ ]
144
+ ), q = X(null), k = X(null), D = X(!1), [Z, H] = ne(!1), O = A((e) => {
145
+ const t = q.current;
146
+ t && (D.current = !1, !(e.button !== 1 && e.button !== 2) && (t.scrollWidth <= t.clientWidth || (e.button === 1 && e.preventDefault(), k.current = {
147
+ pointerId: e.pointerId,
148
+ button: e.button,
149
+ startX: e.clientX,
150
+ startScrollLeft: t.scrollLeft,
151
+ downAt: performance.now(),
152
+ dragging: !1
153
+ })));
154
+ }, []), z = A((e) => {
155
+ const t = k.current, l = q.current;
156
+ if (!t || !l || e.pointerId !== t.pointerId) return;
157
+ const N = e.clientX - t.startX;
158
+ if (!t.dragging) {
159
+ if (t.button === 2 && performance.now() - t.downAt > 200) {
160
+ k.current = null;
161
+ return;
162
+ }
163
+ if (Math.abs(N) < 5) return;
164
+ t.dragging = !0, H(!0);
165
+ try {
166
+ l.setPointerCapture(t.pointerId);
167
+ } catch {
168
+ }
169
+ }
170
+ l.scrollLeft = t.startScrollLeft - N;
171
+ }, []), U = A((e) => {
172
+ const t = k.current;
173
+ !t || e.pointerId !== t.pointerId || (k.current = null, t.dragging && (t.button === 2 && (D.current = !0), H(!1)));
174
+ }, []), ee = A((e) => {
175
+ (k.current?.dragging || D.current) && (D.current = !1, e.preventDefault());
176
+ }, []), L = (e) => p.find((l) => l.key === e)?.direction, te = (e) => {
177
+ if (p.length <= 1) return;
178
+ const t = p.findIndex((l) => l.key === e);
179
+ return t >= 0 ? t : void 0;
180
+ };
181
+ return /* @__PURE__ */ y(
182
+ "div",
183
+ {
184
+ ref: q,
185
+ className: d(
186
+ n.wrapper,
187
+ G && n.scrollable,
188
+ Z && n.dragging,
189
+ g?.wrapper
190
+ ),
191
+ onPointerDown: c ? O : void 0,
192
+ onPointerMove: c ? z : void 0,
193
+ onPointerUp: c ? U : void 0,
194
+ onPointerCancel: c ? U : void 0,
195
+ onContextMenu: c ? ee : void 0,
196
+ children: [
197
+ /* @__PURE__ */ y(
198
+ "table",
199
+ {
200
+ className: d(
201
+ n.root,
202
+ P && n.striped,
203
+ R && n.hoverable,
204
+ S && n.compact,
205
+ g?.root,
206
+ r
207
+ ),
208
+ style: u,
209
+ children: [
210
+ /* @__PURE__ */ s("thead", { children: /* @__PURE__ */ s("tr", { children: o.map((e) => /* @__PURE__ */ y(
211
+ "th",
212
+ {
213
+ className: d(
214
+ n.headerCell,
215
+ e.sortable && n.headerCellSortable,
216
+ e.sticky && n.headerCellSticky,
217
+ g?.headerCell
218
+ ),
219
+ style: {
220
+ width: e.width,
221
+ textAlign: e.align
222
+ },
223
+ onClick: e.sortable ? (t) => Y(e.key, t, e.defaultSortDirection ?? "asc") : void 0,
224
+ "aria-sort": e.sortable ? L(e.key) === "asc" ? "ascending" : L(e.key) === "desc" ? "descending" : "none" : void 0,
225
+ children: [
226
+ e.header,
227
+ e.sortable && /* @__PURE__ */ s(
228
+ ae,
229
+ {
230
+ direction: L(e.key),
231
+ sortIndex: te(e.key)
232
+ }
233
+ )
234
+ ]
235
+ },
236
+ e.key
237
+ )) }) }),
238
+ /* @__PURE__ */ s("tbody", { children: W.length === 0 ? /* @__PURE__ */ s("tr", { className: n.emptyRow, children: /* @__PURE__ */ s("td", { className: d(n.emptyCell, g?.emptyCell), colSpan: o.length, children: F }) }) : W.map((e, t) => {
239
+ const l = j ? String(e[j]) : t, N = typeof T == "function" ? T(e, t) : T, B = typeof $ == "function" ? $(e, t) : $;
240
+ return /* @__PURE__ */ s(
241
+ "tr",
242
+ {
243
+ className: d(n.row, g?.row, N),
244
+ style: B,
245
+ children: o.map((a) => {
246
+ const f = e[a.key], I = typeof a.cellClassName == "function" ? a.cellClassName(f, e, t) : a.cellClassName, w = typeof a.cellStyle == "function" ? a.cellStyle(f, e, t) : a.cellStyle;
247
+ return /* @__PURE__ */ s(
248
+ "td",
249
+ {
250
+ className: d(
251
+ n.cell,
252
+ a.sticky && n.cellSticky,
253
+ g?.cell,
254
+ I
255
+ ),
256
+ style: { textAlign: a.align, ...w },
257
+ children: a.render ? a.render(f, e, t) : f
258
+ },
259
+ a.key
260
+ );
261
+ })
262
+ },
263
+ l
264
+ );
265
+ }) })
266
+ ]
267
+ }
268
+ ),
269
+ m && /* @__PURE__ */ s(
270
+ ie,
271
+ {
272
+ ...m,
273
+ totalRows: V,
274
+ paginatorClasses: { paginator: g?.paginator, pageButton: g?.pageButton }
275
+ }
276
+ )
277
+ ]
278
+ }
279
+ );
280
+ }
281
+ const fe = se;
282
+ export {
283
+ fe as Table
284
+ };
@@ -0,0 +1,59 @@
1
+ const t = "crk-wrapper-zxjMt", r = "crk-scrollable-Apjbs", e = "crk-root-Gf85-", o = "crk-paginator-UlYIY", c = "crk-dragging-dAaIR", a = "crk-headerCell-ePPZW", l = "crk-headerCellSticky-Qwz3q", n = "crk-cellSticky-LwmbD", s = "crk-headerCellSortable-NMybk", p = "crk-sortIndicator-WGD2S", i = "crk-sortArrow-1-ok4", k = "crk-sortArrowActive-yhWrO", g = "crk-sortIndex-HGoca", d = "crk-row-H0wL1", w = "crk-cell-ZfnbG", S = "crk-emptyRow-AoPfj", y = "crk-emptyCell-99-7C", A = "crk-striped-6Qckq", h = "crk-hoverable-ljU9B", b = "crk-compact-2-UWr", C = "crk-paginatorInfo-BVca4", v = "crk-paginatorText-sqWS0", I = "crk-pageSizeSelect-yhqJQ", m = "crk-paginatorNav-MDSui", u = "crk-pageButton-1PX-g", x = "crk-pageButtonActive--D7Q7", B = "crk-pageEllipsis-en59J", f = {
2
+ wrapper: t,
3
+ scrollable: r,
4
+ root: e,
5
+ paginator: o,
6
+ dragging: c,
7
+ headerCell: a,
8
+ headerCellSticky: l,
9
+ cellSticky: n,
10
+ headerCellSortable: s,
11
+ sortIndicator: p,
12
+ sortArrow: i,
13
+ sortArrowActive: k,
14
+ sortIndex: g,
15
+ row: d,
16
+ cell: w,
17
+ emptyRow: S,
18
+ emptyCell: y,
19
+ striped: A,
20
+ hoverable: h,
21
+ compact: b,
22
+ paginatorInfo: C,
23
+ paginatorText: v,
24
+ pageSizeSelect: I,
25
+ paginatorNav: m,
26
+ pageButton: u,
27
+ pageButtonActive: x,
28
+ pageEllipsis: B
29
+ };
30
+ export {
31
+ w as cell,
32
+ n as cellSticky,
33
+ b as compact,
34
+ f as default,
35
+ c as dragging,
36
+ y as emptyCell,
37
+ S as emptyRow,
38
+ a as headerCell,
39
+ s as headerCellSortable,
40
+ l as headerCellSticky,
41
+ h as hoverable,
42
+ u as pageButton,
43
+ x as pageButtonActive,
44
+ B as pageEllipsis,
45
+ I as pageSizeSelect,
46
+ o as paginator,
47
+ C as paginatorInfo,
48
+ m as paginatorNav,
49
+ v as paginatorText,
50
+ e as root,
51
+ d as row,
52
+ r as scrollable,
53
+ i as sortArrow,
54
+ k as sortArrowActive,
55
+ g as sortIndex,
56
+ p as sortIndicator,
57
+ A as striped,
58
+ t as wrapper
59
+ };
@@ -8,15 +8,17 @@ export interface SortConfig {
8
8
  /**
9
9
  * Client-side sorting hook for tabular data.
10
10
  *
11
- * Supports single and multi-column sort with asc → desc → none cycling.
11
+ * Supports single and multi-column sort. The cycle is
12
+ * `none → startDirection → opposite → none`, where `startDirection`
13
+ * defaults to `'asc'` (pass `'desc'` for "highest first" columns).
12
14
  *
13
15
  * @param data - Array of row objects to sort.
14
16
  * @param initialSort - Optional initial sort configuration.
15
17
  * @returns An object containing:
16
18
  * - `sortedData` — the sorted copy of `data`.
17
19
  * - `sortConfig` — current active sort columns and directions.
18
- * - `requestSort(key)` — single-column sort (replaces any existing sort).
19
- * - `requestMultiSort(key)` — adds/toggles a column in multi-sort mode.
20
+ * - `requestSort(key, startDirection?)` — single-column sort (replaces any existing sort).
21
+ * - `requestMultiSort(key, startDirection?)` — adds/toggles a column in multi-sort mode.
20
22
  * - `resetSort()` — clears all sorting.
21
23
  *
22
24
  * @example
@@ -27,7 +29,7 @@ export interface SortConfig {
27
29
  export declare function useTableSort<T extends Record<string, unknown>>(data: T[], initialSort?: SortConfig[]): {
28
30
  sortedData: T[];
29
31
  sortConfig: SortConfig[];
30
- requestSort: (key: keyof T & string) => void;
31
- requestMultiSort: (key: keyof T & string) => void;
32
+ requestSort: (key: keyof T & string, startDirection?: 'asc' | 'desc') => void;
33
+ requestMultiSort: (key: keyof T & string, startDirection?: 'asc' | 'desc') => void;
32
34
  resetSort: () => void;
33
35
  };
@@ -0,0 +1,44 @@
1
+ import { useState as m, useCallback as l, useMemo as p } from "react";
2
+ function C(n, s) {
3
+ return n == null && s == null ? 0 : n == null ? -1 : s == null ? 1 : typeof n == "number" && typeof s == "number" ? n - s : String(n).localeCompare(String(s));
4
+ }
5
+ function M(n, s = []) {
6
+ const [c, f] = m(s), g = l(
7
+ (e, r = "asc") => {
8
+ const i = r === "asc" ? "desc" : "asc";
9
+ f((o) => {
10
+ const t = o.find((d) => d.key === e);
11
+ return t ? t.direction === r ? [{ key: e, direction: i }] : [] : [{ key: e, direction: r }];
12
+ });
13
+ },
14
+ []
15
+ ), x = l(
16
+ (e, r = "asc") => {
17
+ const i = r === "asc" ? "desc" : "asc";
18
+ f((o) => {
19
+ const t = o.findIndex((u) => u.key === e);
20
+ if (t === -1)
21
+ return [...o, { key: e, direction: r }];
22
+ if (o[t].direction === r) {
23
+ const u = [...o];
24
+ return u[t] = { key: e, direction: i }, u;
25
+ }
26
+ return o.filter((u, a) => a !== t);
27
+ });
28
+ },
29
+ []
30
+ ), S = l(() => {
31
+ f([]);
32
+ }, []);
33
+ return { sortedData: p(() => c.length === 0 ? n : [...n].sort((e, r) => {
34
+ for (const { key: i, direction: o } of c) {
35
+ const t = C(e[i], r[i]);
36
+ if (t !== 0)
37
+ return o === "asc" ? t : -t;
38
+ }
39
+ return 0;
40
+ }), [n, c]), sortConfig: c, requestSort: g, requestMultiSort: x, resetSort: S };
41
+ }
42
+ export {
43
+ M as useTableSort
44
+ };
@@ -0,0 +1,163 @@
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { forwardRef as x, useId as R, useState as L, useCallback as g, useRef as V, createContext as D, useContext as S } from "react";
3
+ import $ from "clsx";
4
+ import d from "./Tabs.module.scss.js";
5
+ const N = D(null);
6
+ function I(e) {
7
+ const n = S(N);
8
+ if (!n) throw new Error(`${e} must be rendered inside a <Tabs>.`);
9
+ return n;
10
+ }
11
+ const k = x(
12
+ ({
13
+ value: e,
14
+ defaultValue: n,
15
+ onValueChange: b,
16
+ orientation: o = "horizontal",
17
+ variant: r = "line",
18
+ size: s = "md",
19
+ classes: i,
20
+ className: a,
21
+ children: l,
22
+ ...t
23
+ }, p) => {
24
+ const c = R(), f = e !== void 0, [h, T] = L(n), u = f ? e : h, y = g(
25
+ (w) => {
26
+ f || T(w), b?.(w);
27
+ },
28
+ [f, b]
29
+ ), v = {
30
+ value: u,
31
+ setValue: y,
32
+ baseId: c,
33
+ orientation: o,
34
+ variant: r,
35
+ size: s,
36
+ classes: i
37
+ };
38
+ return /* @__PURE__ */ m(N.Provider, { value: v, children: /* @__PURE__ */ m(
39
+ "div",
40
+ {
41
+ ref: p,
42
+ className: $(
43
+ d.root,
44
+ o === "vertical" && d.vertical,
45
+ i?.root,
46
+ a
47
+ ),
48
+ ...t,
49
+ children: l
50
+ }
51
+ ) });
52
+ }
53
+ );
54
+ k.displayName = "Tabs";
55
+ const A = x(
56
+ ({ className: e, children: n, onKeyDown: b, ...o }, r) => {
57
+ const s = I("Tabs.List"), i = V(null), a = g(
58
+ (t) => {
59
+ i.current = t, typeof r == "function" ? r(t) : r && (r.current = t);
60
+ },
61
+ [r]
62
+ ), l = (t) => {
63
+ if (b?.(t), t.defaultPrevented) return;
64
+ const p = i.current;
65
+ if (!p) return;
66
+ const c = Array.from(
67
+ p.querySelectorAll('[role="tab"]:not([aria-disabled="true"])')
68
+ );
69
+ if (c.length === 0) return;
70
+ const f = s.orientation === "vertical" ? "ArrowDown" : "ArrowRight", h = s.orientation === "vertical" ? "ArrowUp" : "ArrowLeft", T = c.indexOf(document.activeElement);
71
+ let u = null;
72
+ if (t.key === f ? u = (T + 1) % c.length : t.key === h ? u = (T - 1 + c.length) % c.length : t.key === "Home" ? u = 0 : t.key === "End" && (u = c.length - 1), u === null) return;
73
+ t.preventDefault();
74
+ const y = c[u];
75
+ y.focus();
76
+ const v = y.dataset.value;
77
+ v !== void 0 && s.setValue(v);
78
+ };
79
+ return /* @__PURE__ */ m(
80
+ "div",
81
+ {
82
+ ref: a,
83
+ role: "tablist",
84
+ "aria-orientation": s.orientation,
85
+ className: $(
86
+ d.list,
87
+ d[`list_${s.variant}`],
88
+ d[`list_${s.size}`],
89
+ s.classes?.list,
90
+ e
91
+ ),
92
+ onKeyDown: l,
93
+ ...o,
94
+ children: n
95
+ }
96
+ );
97
+ }
98
+ );
99
+ A.displayName = "Tabs.List";
100
+ const C = x(
101
+ ({ value: e, disabled: n = !1, className: b, children: o, onClick: r, ...s }, i) => {
102
+ const a = I("Tabs.Tab"), l = a.value === e;
103
+ return /* @__PURE__ */ m(
104
+ "button",
105
+ {
106
+ ref: i,
107
+ type: "button",
108
+ role: "tab",
109
+ id: `${a.baseId}-tab-${e}`,
110
+ "data-value": e,
111
+ "aria-selected": l,
112
+ "aria-controls": `${a.baseId}-panel-${e}`,
113
+ "aria-disabled": n || void 0,
114
+ tabIndex: l ? 0 : -1,
115
+ disabled: n,
116
+ className: $(
117
+ d.tab,
118
+ d[`tab_${a.variant}`],
119
+ l && d.tabSelected,
120
+ a.classes?.tab,
121
+ b
122
+ ),
123
+ onClick: (t) => {
124
+ r?.(t), n || a.setValue(e);
125
+ },
126
+ ...s,
127
+ children: o
128
+ }
129
+ );
130
+ }
131
+ );
132
+ C.displayName = "Tabs.Tab";
133
+ const P = x(
134
+ ({ value: e, keepMounted: n = !1, className: b, style: o, children: r, ...s }, i) => {
135
+ const a = I("Tabs.Panel"), l = a.value === e;
136
+ if (!l && !n) return null;
137
+ const t = l ? o : { display: "none", ...o };
138
+ return /* @__PURE__ */ m(
139
+ "div",
140
+ {
141
+ ref: i,
142
+ role: "tabpanel",
143
+ id: `${a.baseId}-panel-${e}`,
144
+ "aria-labelledby": `${a.baseId}-tab-${e}`,
145
+ hidden: !l,
146
+ tabIndex: 0,
147
+ className: $(d.panel, a.classes?.panel, b),
148
+ style: t,
149
+ ...s,
150
+ children: r
151
+ }
152
+ );
153
+ }
154
+ );
155
+ P.displayName = "Tabs.Panel";
156
+ const K = Object.assign(k, {
157
+ List: A,
158
+ Tab: C,
159
+ Panel: P
160
+ });
161
+ export {
162
+ K as Tabs
163
+ };
@@ -0,0 +1,53 @@
1
+ const l = "crk-root-2x4fl", t = "crk-vertical-D93pf", i = "crk-list-6iAKX", s = "crk-list_line-ZazHL", c = "crk-list_line-ZazHL", o = "crk-list_solid-Lbmnx", n = "crk-list_solid-Lbmnx", a = "crk-list_pill-g90VV", _ = "crk-list_pill-g90VV", e = "crk-list_sm-U-pax", r = "crk-list_sm-U-pax", b = "crk-tab-LYqhc", k = "crk-list_md-0H3Fg", d = "crk-list_md-0H3Fg", p = "crk-list_lg-vxB6m", m = "crk-list_lg-vxB6m", L = "crk-tab_line-8v4fZ", g = "crk-tab_line-8v4fZ", x = "crk-tabSelected-lZne9", v = "crk-tab_solid-4RJvK", S = "crk-tab_solid-4RJvK", f = "crk-tab_pill-qGlBx", Z = "crk-tab_pill-qGlBx", B = "crk-panel-0OUR6", H = {
2
+ root: l,
3
+ vertical: t,
4
+ list: i,
5
+ list_line: s,
6
+ listLine: c,
7
+ list_solid: o,
8
+ listSolid: n,
9
+ list_pill: a,
10
+ listPill: _,
11
+ list_sm: e,
12
+ listSm: r,
13
+ tab: b,
14
+ list_md: k,
15
+ listMd: d,
16
+ list_lg: p,
17
+ listLg: m,
18
+ tab_line: L,
19
+ tabLine: g,
20
+ tabSelected: x,
21
+ tab_solid: v,
22
+ tabSolid: S,
23
+ tab_pill: f,
24
+ tabPill: Z,
25
+ panel: B
26
+ };
27
+ export {
28
+ H as default,
29
+ i as list,
30
+ m as listLg,
31
+ c as listLine,
32
+ d as listMd,
33
+ _ as listPill,
34
+ r as listSm,
35
+ n as listSolid,
36
+ p as list_lg,
37
+ s as list_line,
38
+ k as list_md,
39
+ a as list_pill,
40
+ e as list_sm,
41
+ o as list_solid,
42
+ B as panel,
43
+ l as root,
44
+ b as tab,
45
+ g as tabLine,
46
+ Z as tabPill,
47
+ x as tabSelected,
48
+ S as tabSolid,
49
+ L as tab_line,
50
+ f as tab_pill,
51
+ v as tab_solid,
52
+ t as vertical
53
+ };