@overdoser/react-toolkit 0.0.1

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 (54) hide show
  1. package/README.md +106 -0
  2. package/components/Button/Button.d.ts +17 -0
  3. package/components/Button/Button.stories.d.ts +17 -0
  4. package/components/Button/index.d.ts +2 -0
  5. package/components/Dropdown/Dropdown.d.ts +39 -0
  6. package/components/Dropdown/Dropdown.stories.d.ts +8 -0
  7. package/components/Dropdown/DropdownItem.d.ts +5 -0
  8. package/components/Dropdown/index.d.ts +4 -0
  9. package/components/Form/Form.d.ts +9 -0
  10. package/components/Form/Form.stories.d.ts +8 -0
  11. package/components/Form/FormField.d.ts +19 -0
  12. package/components/Form/index.d.ts +4 -0
  13. package/components/Link/Link.d.ts +6 -0
  14. package/components/Link/Link.stories.d.ts +9 -0
  15. package/components/Link/index.d.ts +2 -0
  16. package/components/List/List.d.ts +9 -0
  17. package/components/List/List.stories.d.ts +9 -0
  18. package/components/List/index.d.ts +2 -0
  19. package/components/Modal/Modal.d.ts +46 -0
  20. package/components/Modal/Modal.stories.d.ts +9 -0
  21. package/components/Modal/index.d.ts +2 -0
  22. package/components/Popover/Popover.d.ts +18 -0
  23. package/components/Popover/Popover.stories.d.ts +9 -0
  24. package/components/Popover/index.d.ts +2 -0
  25. package/components/Table/Table.d.ts +55 -0
  26. package/components/Table/Table.stories.d.ts +20 -0
  27. package/components/Table/index.d.ts +4 -0
  28. package/components/Table/useTableSort.d.ts +33 -0
  29. package/components/Typography/Typography.d.ts +12 -0
  30. package/components/Typography/Typography.stories.d.ts +15 -0
  31. package/components/Typography/index.d.ts +2 -0
  32. package/components/inputs/Checkbox/Checkbox.d.ts +12 -0
  33. package/components/inputs/Checkbox/Checkbox.stories.d.ts +9 -0
  34. package/components/inputs/Checkbox/index.d.ts +2 -0
  35. package/components/inputs/Input/Input.d.ts +15 -0
  36. package/components/inputs/Input/Input.stories.d.ts +13 -0
  37. package/components/inputs/Input/index.d.ts +2 -0
  38. package/components/inputs/Radio/Radio.d.ts +24 -0
  39. package/components/inputs/Radio/Radio.stories.d.ts +7 -0
  40. package/components/inputs/Radio/index.d.ts +2 -0
  41. package/components/inputs/Select/Select.d.ts +19 -0
  42. package/components/inputs/Select/Select.stories.d.ts +9 -0
  43. package/components/inputs/Select/index.d.ts +2 -0
  44. package/components/inputs/Textarea/Textarea.d.ts +7 -0
  45. package/components/inputs/Textarea/Textarea.stories.d.ts +10 -0
  46. package/components/inputs/Textarea/index.d.ts +2 -0
  47. package/hooks/useClickOutside.d.ts +14 -0
  48. package/hooks/useFocusTrap.d.ts +18 -0
  49. package/hooks/useKeyboard.d.ts +12 -0
  50. package/index.css +1 -0
  51. package/index.d.ts +32 -0
  52. package/index.js +1129 -0
  53. package/package.json +31 -0
  54. package/test-setup.d.ts +0 -0
package/index.js ADDED
@@ -0,0 +1,1129 @@
1
+ import { forwardRef as $, createElement as he, useState as oe, useCallback as C, useMemo as X, useEffect as O, useRef as j, createContext as ae, useContext as Z, cloneElement as ke } from "react";
2
+ import { jsxs as b, jsx as c } from "react/jsx-runtime";
3
+ import { FormProvider as fe, useFormContext as ge, useController as be } from "react-hook-form";
4
+ import { createPortal as ye } from "react-dom";
5
+ function le(e) {
6
+ var r, t, o = "";
7
+ if (typeof e == "string" || typeof e == "number") o += e;
8
+ else if (typeof e == "object") if (Array.isArray(e)) {
9
+ var n = e.length;
10
+ for (r = 0; r < n; r++) e[r] && (t = le(e[r])) && (o && (o += " "), o += t);
11
+ } else for (t in e) e[t] && (o && (o += " "), o += t);
12
+ return o;
13
+ }
14
+ function s() {
15
+ for (var e, r, t = 0, o = "", n = arguments.length; t < n; t++) (e = arguments[t]) && (r = le(e)) && (o && (o += " "), o += r);
16
+ return o;
17
+ }
18
+ const Ne = "crk-root-8RX49", ve = "crk-loading-QfItr", we = "crk-primary-st6yY", xe = "crk-secondary-j-3rj", $e = "crk-danger-Hxs5n", Se = "crk-ghost-kQ0A8", Ce = "crk-sm-RXFPY", Ie = "crk-md-nDnOD", Be = "crk-lg-qD-Qh", De = "crk-fullWidth-AHpSl", Ae = "crk-content-PpYVU", Le = "crk-shimmer-8iQSU", Re = "crk-loadingShimmer-BVvFw", Ee = "crk-shimmerSweep-uiZ01", Te = "crk-dots-U8wss", Fe = "crk-loadingDots-eKv64", Pe = "crk-dot-Owuk1", Me = "crk-dotBounce-FwdcC", We = "crk-loadingBorder-9ULFw", ze = "crk-borderSpin-EJ2gW", x = {
19
+ root: Ne,
20
+ loading: ve,
21
+ primary: we,
22
+ secondary: xe,
23
+ danger: $e,
24
+ ghost: Se,
25
+ sm: Ce,
26
+ md: Ie,
27
+ lg: Be,
28
+ fullWidth: De,
29
+ content: Ae,
30
+ shimmer: Le,
31
+ loadingShimmer: Re,
32
+ shimmerSweep: Ee,
33
+ dots: Te,
34
+ loadingDots: Fe,
35
+ dot: Pe,
36
+ dotBounce: Me,
37
+ loadingBorder: We,
38
+ borderSpin: ze
39
+ }, qe = {
40
+ dots: x.loadingDots,
41
+ shimmer: x.loadingShimmer,
42
+ border: x.loadingBorder
43
+ }, Oe = $(
44
+ ({
45
+ variant: e = "primary",
46
+ size: r = "md",
47
+ loading: t = !1,
48
+ loadingStyle: o = "dots",
49
+ fullWidth: n = !1,
50
+ disabled: i,
51
+ classes: l,
52
+ className: u,
53
+ style: d,
54
+ children: m,
55
+ ...a
56
+ }, p) => /* @__PURE__ */ b(
57
+ "button",
58
+ {
59
+ ref: p,
60
+ className: s(
61
+ x.root,
62
+ x[e],
63
+ x[r],
64
+ n && x.fullWidth,
65
+ t && x.loading,
66
+ t && qe[o],
67
+ l?.root,
68
+ u
69
+ ),
70
+ style: d,
71
+ disabled: i || t,
72
+ ...a,
73
+ children: [
74
+ /* @__PURE__ */ c("div", { className: s(x.shimmer, l?.shimmer) }),
75
+ /* @__PURE__ */ c("span", { className: s(x.content, l?.content), children: m }),
76
+ /* @__PURE__ */ b("span", { className: s(x.dots, l?.dots), "aria-hidden": "true", children: [
77
+ /* @__PURE__ */ c("span", { className: s(x.dot, l?.dot) }),
78
+ /* @__PURE__ */ c("span", { className: s(x.dot, l?.dot) }),
79
+ /* @__PURE__ */ c("span", { className: s(x.dot, l?.dot) })
80
+ ] })
81
+ ]
82
+ }
83
+ )
84
+ );
85
+ Oe.displayName = "Button";
86
+ const je = "crk-root-2j4Vp", He = "crk-muted-vReNc", Ue = "crk-danger-ugf9r", ce = {
87
+ root: je,
88
+ default: "crk-default-3TBlr",
89
+ muted: He,
90
+ danger: Ue
91
+ }, Ge = $(
92
+ ({
93
+ variant: e = "default",
94
+ external: r = !1,
95
+ className: t,
96
+ style: o,
97
+ children: n,
98
+ ...i
99
+ }, l) => /* @__PURE__ */ c(
100
+ "a",
101
+ {
102
+ ref: l,
103
+ className: s(ce.root, ce[e], t),
104
+ style: o,
105
+ ...r && {
106
+ target: "_blank",
107
+ rel: "noopener noreferrer"
108
+ },
109
+ ...i,
110
+ children: n
111
+ }
112
+ )
113
+ );
114
+ Ge.displayName = "Link";
115
+ const Ke = "crk-root-U-oiq", Qe = "crk-h1-Aivwz", Ve = "crk-h2-CV8Oo", Ye = "crk-h3-lrbrK", Xe = "crk-h4--jkC1", Ze = "crk-h5-GnQvD", Je = "crk-h6-MKlIN", _e = "crk-p-FzRtm", er = "crk-span-NZvLx", rr = "crk-label-Cwi6a", tr = "crk-normal-7AeZz", or = "crk-medium-36OXr", nr = "crk-semibold-oQixc", cr = "crk-bold-bk4b4", sr = "crk-muted-itOSW", ar = "crk-primary-rp36t", lr = "crk-danger-SyOy-", ir = "crk-success-w8PpD", dr = "crk-align-left-3AGYw", ur = "crk-align-center-h-x--", mr = "crk-align-right-IXFhK", pr = "crk-truncate-eqr85", W = {
116
+ root: Ke,
117
+ h1: Qe,
118
+ h2: Ve,
119
+ h3: Ye,
120
+ h4: Xe,
121
+ h5: Ze,
122
+ h6: Je,
123
+ p: _e,
124
+ span: er,
125
+ label: rr,
126
+ normal: tr,
127
+ medium: or,
128
+ semibold: nr,
129
+ bold: cr,
130
+ default: "crk-default-79lKR",
131
+ muted: sr,
132
+ primary: ar,
133
+ danger: lr,
134
+ success: ir,
135
+ alignLeft: dr,
136
+ alignCenter: ur,
137
+ alignRight: mr,
138
+ truncate: pr
139
+ }, hr = $(
140
+ ({
141
+ variant: e = "p",
142
+ weight: r,
143
+ color: t,
144
+ align: o,
145
+ truncate: n = !1,
146
+ className: i,
147
+ style: l,
148
+ children: u,
149
+ ...d
150
+ }, m) => he(
151
+ e,
152
+ {
153
+ ref: m,
154
+ className: s(
155
+ W.root,
156
+ W[e],
157
+ r && W[r],
158
+ t && W[t],
159
+ o && W[`align-${o}`],
160
+ n && W.truncate,
161
+ i
162
+ ),
163
+ style: l,
164
+ ...d
165
+ },
166
+ u
167
+ )
168
+ );
169
+ hr.displayName = "Typography";
170
+ const kr = "crk-root-PVrgx", fr = "crk-unordered-FhCWT", gr = "crk-item-TfW82", br = "crk-ordered-8x4YC", yr = "crk-none-f03Kx", Nr = "crk-sm-Rg4Mv", vr = "crk-md-X4Icb", wr = "crk-lg-JjNKZ", V = {
171
+ root: kr,
172
+ unordered: fr,
173
+ item: gr,
174
+ ordered: br,
175
+ none: yr,
176
+ sm: Nr,
177
+ md: vr,
178
+ lg: wr
179
+ }, xr = $(
180
+ ({
181
+ variant: e = "unordered",
182
+ spacing: r = "md",
183
+ className: t,
184
+ style: o,
185
+ children: n,
186
+ ...i
187
+ }, l) => /* @__PURE__ */ c(
188
+ e === "ordered" ? "ol" : "ul",
189
+ {
190
+ ref: l,
191
+ className: s(
192
+ V.root,
193
+ V[e],
194
+ V[r],
195
+ t
196
+ ),
197
+ style: o,
198
+ ...i,
199
+ children: n
200
+ }
201
+ )
202
+ );
203
+ xr.displayName = "List";
204
+ const $r = $(
205
+ ({ className: e, style: r, children: t, ...o }, n) => /* @__PURE__ */ c(
206
+ "li",
207
+ {
208
+ ref: n,
209
+ className: s(V.item, e),
210
+ style: r,
211
+ ...o,
212
+ children: t
213
+ }
214
+ )
215
+ );
216
+ $r.displayName = "ListItem";
217
+ const Sr = "crk-wrapper-zxjMt", Cr = "crk-root-Gf85-", Ir = "crk-headerCell-ePPZW", Br = "crk-headerCellSortable-NMybk", Dr = "crk-sortIndicator-WGD2S", Ar = "crk-sortArrow-1-ok4", Lr = "crk-sortArrowActive-yhWrO", Rr = "crk-sortIndex-HGoca", Er = "crk-row-H0wL1", Tr = "crk-cell-ZfnbG", Fr = "crk-emptyRow-AoPfj", Pr = "crk-emptyCell-99-7C", Mr = "crk-striped-6Qckq", Wr = "crk-hoverable-ljU9B", zr = "crk-compact-2-UWr", qr = "crk-paginator-UlYIY", Or = "crk-paginatorInfo-BVca4", jr = "crk-paginatorText-sqWS0", Hr = "crk-pageSizeSelect-yhqJQ", Ur = "crk-paginatorNav-MDSui", Gr = "crk-pageButton-1PX-g", Kr = "crk-pageButtonActive--D7Q7", Qr = "crk-pageEllipsis-en59J", g = {
218
+ wrapper: Sr,
219
+ root: Cr,
220
+ headerCell: Ir,
221
+ headerCellSortable: Br,
222
+ sortIndicator: Dr,
223
+ sortArrow: Ar,
224
+ sortArrowActive: Lr,
225
+ sortIndex: Rr,
226
+ row: Er,
227
+ cell: Tr,
228
+ emptyRow: Fr,
229
+ emptyCell: Pr,
230
+ striped: Mr,
231
+ hoverable: Wr,
232
+ compact: zr,
233
+ paginator: qr,
234
+ paginatorInfo: Or,
235
+ paginatorText: jr,
236
+ pageSizeSelect: Hr,
237
+ paginatorNav: Ur,
238
+ pageButton: Gr,
239
+ pageButtonActive: Kr,
240
+ pageEllipsis: Qr
241
+ };
242
+ function Vr(e, r) {
243
+ return e == null && r == null ? 0 : e == null ? -1 : r == null ? 1 : typeof e == "number" && typeof r == "number" ? e - r : String(e).localeCompare(String(r));
244
+ }
245
+ function Yr(e, r = []) {
246
+ const [t, o] = oe(r), n = C((d) => {
247
+ o((m) => {
248
+ const a = m.find((p) => p.key === d);
249
+ return a ? a.direction === "asc" ? [{ key: d, direction: "desc" }] : [] : [{ key: d, direction: "asc" }];
250
+ });
251
+ }, []), i = C((d) => {
252
+ o((m) => {
253
+ const a = m.findIndex((h) => h.key === d);
254
+ if (a === -1)
255
+ return [...m, { key: d, direction: "asc" }];
256
+ if (m[a].direction === "asc") {
257
+ const h = [...m];
258
+ return h[a] = { key: d, direction: "desc" }, h;
259
+ }
260
+ return m.filter((h, f) => f !== a);
261
+ });
262
+ }, []), l = C(() => {
263
+ o([]);
264
+ }, []);
265
+ return { sortedData: X(() => t.length === 0 ? e : [...e].sort((d, m) => {
266
+ for (const { key: a, direction: p } of t) {
267
+ const h = Vr(d[a], m[a]);
268
+ if (h !== 0)
269
+ return p === "asc" ? h : -h;
270
+ }
271
+ return 0;
272
+ }), [e, t]), sortConfig: t, requestSort: n, requestMultiSort: i, resetSort: l };
273
+ }
274
+ function Xr({ direction: e, sortIndex: r }) {
275
+ return /* @__PURE__ */ b("span", { className: g.sortIndicator, children: [
276
+ /* @__PURE__ */ c("span", { className: s(g.sortArrow, e === "asc" && g.sortArrowActive), children: "▲" }),
277
+ /* @__PURE__ */ c("span", { className: s(g.sortArrow, e === "desc" && g.sortArrowActive), children: "▼" }),
278
+ r !== void 0 && r >= 0 && /* @__PURE__ */ c("span", { className: g.sortIndex, children: r + 1 })
279
+ ] });
280
+ }
281
+ function Zr({
282
+ page: e,
283
+ pageSize: r,
284
+ totalRows: t,
285
+ pageSizeOptions: o = [10, 25, 50, 100],
286
+ onPageChange: n,
287
+ paginatorClasses: i
288
+ }) {
289
+ const l = Math.max(1, Math.ceil(t / r)), u = (e - 1) * r + 1, d = Math.min(e * r, t), m = X(() => {
290
+ const a = [];
291
+ if (l <= 7)
292
+ for (let p = 1; p <= l; p++) a.push(p);
293
+ else {
294
+ a.push(1), e > 3 && a.push("ellipsis");
295
+ for (let p = Math.max(2, e - 1); p <= Math.min(l - 1, e + 1); p++)
296
+ a.push(p);
297
+ e < l - 2 && a.push("ellipsis"), a.push(l);
298
+ }
299
+ return a;
300
+ }, [e, l]);
301
+ return /* @__PURE__ */ b("div", { className: s(g.paginator, i?.paginator), children: [
302
+ /* @__PURE__ */ b("div", { className: g.paginatorInfo, children: [
303
+ /* @__PURE__ */ c("span", { className: g.paginatorText, children: t > 0 ? `${u}–${d} of ${t}` : "No results" }),
304
+ o.length > 1 && /* @__PURE__ */ c(
305
+ "select",
306
+ {
307
+ className: g.pageSizeSelect,
308
+ value: r,
309
+ onChange: (a) => n(1, Number(a.target.value)),
310
+ children: o.map((a) => /* @__PURE__ */ b("option", { value: a, children: [
311
+ a,
312
+ " / page"
313
+ ] }, a))
314
+ }
315
+ )
316
+ ] }),
317
+ /* @__PURE__ */ b("div", { className: g.paginatorNav, children: [
318
+ /* @__PURE__ */ c(
319
+ "button",
320
+ {
321
+ type: "button",
322
+ className: s(g.pageButton, i?.pageButton),
323
+ disabled: e <= 1,
324
+ onClick: () => n(e - 1, r),
325
+ "aria-label": "Previous page",
326
+ children: "‹"
327
+ }
328
+ ),
329
+ m.map(
330
+ (a, p) => a === "ellipsis" ? /* @__PURE__ */ c("span", { className: g.pageEllipsis, children: "…" }, `ellipsis-${p}`) : /* @__PURE__ */ c(
331
+ "button",
332
+ {
333
+ type: "button",
334
+ className: s(g.pageButton, a === e && g.pageButtonActive, i?.pageButton),
335
+ onClick: () => n(a, r),
336
+ children: a
337
+ },
338
+ a
339
+ )
340
+ ),
341
+ /* @__PURE__ */ c(
342
+ "button",
343
+ {
344
+ type: "button",
345
+ className: s(g.pageButton, i?.pageButton),
346
+ disabled: e >= l,
347
+ onClick: () => n(e + 1, r),
348
+ "aria-label": "Next page",
349
+ children: "›"
350
+ }
351
+ )
352
+ ] })
353
+ ] });
354
+ }
355
+ function Jr({
356
+ data: e,
357
+ columns: r,
358
+ sortConfig: t,
359
+ onSort: o,
360
+ multiSort: n = !0,
361
+ striped: i = !1,
362
+ hoverable: l = !1,
363
+ compact: u = !1,
364
+ className: d,
365
+ style: m,
366
+ rowKey: a,
367
+ emptyMessage: p = "No data",
368
+ pagination: h,
369
+ classes: f
370
+ }) {
371
+ const y = o !== void 0, {
372
+ sortedData: D,
373
+ sortConfig: P,
374
+ requestSort: A,
375
+ requestMultiSort: E
376
+ } = Yr(e, t), S = y ? t ?? [] : P, T = y ? e : D, q = X(() => {
377
+ if (!h || y) return T;
378
+ const k = (h.page - 1) * h.pageSize;
379
+ return T.slice(k, k + h.pageSize);
380
+ }, [T, h, y]), ee = h?.totalRows ?? T.length, re = C(
381
+ (k, I) => {
382
+ const L = n && (I.ctrlKey || I.metaKey);
383
+ if (y)
384
+ if (L) {
385
+ const w = S.findIndex((U) => U.key === k);
386
+ let M;
387
+ w === -1 ? M = [...S, { key: k, direction: "asc" }] : S[w].direction === "asc" ? M = S.map(
388
+ (U, te) => te === w ? { key: k, direction: "desc" } : U
389
+ ) : M = S.filter((U, te) => te !== w), o(M);
390
+ } else {
391
+ const w = S.find((M) => M.key === k);
392
+ w ? w.direction === "asc" ? o([{ key: k, direction: "desc" }]) : o([]) : o([{ key: k, direction: "asc" }]);
393
+ }
394
+ else
395
+ L ? E(k) : A(k);
396
+ },
397
+ [
398
+ y,
399
+ n,
400
+ S,
401
+ o,
402
+ A,
403
+ E
404
+ ]
405
+ ), v = (k) => S.find((L) => L.key === k)?.direction, H = (k) => {
406
+ if (S.length <= 1) return;
407
+ const I = S.findIndex((L) => L.key === k);
408
+ return I >= 0 ? I : void 0;
409
+ };
410
+ return /* @__PURE__ */ b("div", { className: s(g.wrapper, f?.wrapper), children: [
411
+ /* @__PURE__ */ b(
412
+ "table",
413
+ {
414
+ className: s(
415
+ g.root,
416
+ i && g.striped,
417
+ l && g.hoverable,
418
+ u && g.compact,
419
+ f?.root,
420
+ d
421
+ ),
422
+ style: m,
423
+ children: [
424
+ /* @__PURE__ */ c("thead", { children: /* @__PURE__ */ c("tr", { children: r.map((k) => /* @__PURE__ */ b(
425
+ "th",
426
+ {
427
+ className: s(
428
+ g.headerCell,
429
+ k.sortable && g.headerCellSortable,
430
+ f?.headerCell
431
+ ),
432
+ style: {
433
+ width: k.width,
434
+ textAlign: k.align
435
+ },
436
+ onClick: k.sortable ? (I) => re(k.key, I) : void 0,
437
+ children: [
438
+ k.header,
439
+ k.sortable && /* @__PURE__ */ c(
440
+ Xr,
441
+ {
442
+ direction: v(k.key),
443
+ sortIndex: H(k.key)
444
+ }
445
+ )
446
+ ]
447
+ },
448
+ k.key
449
+ )) }) }),
450
+ /* @__PURE__ */ c("tbody", { children: q.length === 0 ? /* @__PURE__ */ c("tr", { className: g.emptyRow, children: /* @__PURE__ */ c("td", { className: s(g.emptyCell, f?.emptyCell), colSpan: r.length, children: p }) }) : q.map((k, I) => {
451
+ const L = a ? String(k[a]) : I;
452
+ return /* @__PURE__ */ c("tr", { className: s(g.row, f?.row), children: r.map((w) => /* @__PURE__ */ c(
453
+ "td",
454
+ {
455
+ className: s(g.cell, f?.cell),
456
+ style: { textAlign: w.align },
457
+ children: w.render ? w.render(k[w.key], k, I) : k[w.key]
458
+ },
459
+ w.key
460
+ )) }, L);
461
+ }) })
462
+ ]
463
+ }
464
+ ),
465
+ h && /* @__PURE__ */ c(
466
+ Zr,
467
+ {
468
+ ...h,
469
+ totalRows: ee,
470
+ paginatorClasses: { paginator: f?.paginator, pageButton: f?.pageButton }
471
+ }
472
+ )
473
+ ] });
474
+ }
475
+ const Mo = Jr, _r = "crk-root-an8Cf", et = "crk-fullWidth-S-uVk", rt = "crk-trigger-LwPaD", tt = "crk-triggerOpen-U4pa9", ot = "crk-triggerLabel-QLITs", nt = "crk-triggerError-3jlu1", ct = "crk-placeholder-fWdch", st = "crk-chevron-jmDNe", at = "crk-menu-fxnKL", lt = "crk-menuOpen-HF-Y1", it = "crk-alignLeft-buCDJ", dt = "crk-alignRight-05P9w", ut = "crk-item-f-Rhh", mt = "crk-itemDisabled-L-d6i", pt = "crk-itemSelected-Fwmuo", N = {
476
+ root: _r,
477
+ fullWidth: et,
478
+ trigger: rt,
479
+ triggerOpen: tt,
480
+ triggerLabel: ot,
481
+ triggerError: nt,
482
+ placeholder: ct,
483
+ chevron: st,
484
+ menu: at,
485
+ menuOpen: lt,
486
+ alignLeft: it,
487
+ alignRight: dt,
488
+ item: ut,
489
+ itemDisabled: mt,
490
+ itemSelected: pt
491
+ };
492
+ function ie(e, r) {
493
+ O(() => {
494
+ const t = (o) => {
495
+ !e.current || e.current.contains(o.target) || r();
496
+ };
497
+ return document.addEventListener("mousedown", t), () => {
498
+ document.removeEventListener("mousedown", t);
499
+ };
500
+ }, [e, r]);
501
+ }
502
+ function ne(e, r = !0) {
503
+ const t = C(
504
+ (o) => {
505
+ const n = e[o.key];
506
+ n && n(o);
507
+ },
508
+ [e]
509
+ );
510
+ O(() => {
511
+ if (r)
512
+ return document.addEventListener("keydown", t), () => {
513
+ document.removeEventListener("keydown", t);
514
+ };
515
+ }, [r, t]);
516
+ }
517
+ const ht = $(
518
+ ({
519
+ trigger: e,
520
+ children: r,
521
+ align: t = "left",
522
+ className: o,
523
+ style: n,
524
+ onOpen: i,
525
+ onClose: l,
526
+ options: u,
527
+ placeholder: d = "Select...",
528
+ value: m,
529
+ onChange: a,
530
+ error: p = !1,
531
+ fullWidth: h = !0,
532
+ classes: f
533
+ }, y) => {
534
+ const [D, P] = oe(!1), A = j(null), E = C(() => {
535
+ P(!1), l?.();
536
+ }, [l]), S = C(() => {
537
+ P((v) => {
538
+ const H = !v;
539
+ return H ? i?.() : l?.(), H;
540
+ });
541
+ }, [i, l]), T = C(
542
+ (v) => {
543
+ a?.(v), E();
544
+ },
545
+ [a, E]
546
+ );
547
+ ie(A, E), ne(
548
+ {
549
+ Escape: () => E()
550
+ },
551
+ D
552
+ );
553
+ const q = u?.find((v) => v.value === m)?.label, ee = u ? q || d : e, re = u && !q;
554
+ return /* @__PURE__ */ c(
555
+ "div",
556
+ {
557
+ ref: y,
558
+ className: s(N.root, h && N.fullWidth, f?.root, o),
559
+ style: n,
560
+ children: /* @__PURE__ */ b("div", { ref: A, style: h ? { width: "100%" } : void 0, children: [
561
+ /* @__PURE__ */ b(
562
+ "button",
563
+ {
564
+ type: "button",
565
+ className: s(
566
+ N.trigger,
567
+ D && N.triggerOpen,
568
+ p && N.triggerError,
569
+ h && N.fullWidth,
570
+ f?.trigger
571
+ ),
572
+ onClick: S,
573
+ "aria-expanded": D,
574
+ "aria-haspopup": "true",
575
+ children: [
576
+ /* @__PURE__ */ c("span", { className: s(N.triggerLabel, re && N.placeholder, f?.triggerLabel), children: ee }),
577
+ /* @__PURE__ */ c("span", { className: s(N.chevron, f?.chevron), "aria-hidden": "true" })
578
+ ]
579
+ }
580
+ ),
581
+ /* @__PURE__ */ c(
582
+ "div",
583
+ {
584
+ className: s(
585
+ N.menu,
586
+ D && N.menuOpen,
587
+ t === "left" ? N.alignLeft : N.alignRight,
588
+ h && N.fullWidth,
589
+ f?.menu
590
+ ),
591
+ role: "menu",
592
+ children: u ? u.map((v) => /* @__PURE__ */ c(
593
+ "button",
594
+ {
595
+ type: "button",
596
+ role: "menuitem",
597
+ className: s(
598
+ N.item,
599
+ v.disabled && N.itemDisabled,
600
+ v.value === m && N.itemSelected,
601
+ f?.item
602
+ ),
603
+ disabled: v.disabled,
604
+ onClick: () => T(v.value),
605
+ children: v.label
606
+ },
607
+ v.value
608
+ )) : r
609
+ }
610
+ )
611
+ ] })
612
+ }
613
+ );
614
+ }
615
+ );
616
+ ht.displayName = "Dropdown";
617
+ const kt = $(
618
+ ({
619
+ disabled: e = !1,
620
+ className: r,
621
+ children: t,
622
+ ...o
623
+ }, n) => /* @__PURE__ */ c(
624
+ "button",
625
+ {
626
+ ref: n,
627
+ type: "button",
628
+ role: "menuitem",
629
+ className: s(
630
+ N.item,
631
+ e && N.itemDisabled,
632
+ r
633
+ ),
634
+ disabled: e,
635
+ ...o,
636
+ children: t
637
+ }
638
+ )
639
+ );
640
+ kt.displayName = "DropdownItem";
641
+ const ft = "crk-root-8H-L9", gt = "crk-trigger-Zn1nQ", bt = "crk-popover-rvS3X", yt = "crk-popoverFade-hj41M", Nt = "crk-bottom-lawQw", vt = "crk-top-rqvC6", wt = "crk-left-J6exv", xt = "crk-right-3y20l", G = {
642
+ root: ft,
643
+ trigger: gt,
644
+ popover: bt,
645
+ popoverFade: yt,
646
+ bottom: Nt,
647
+ top: vt,
648
+ left: wt,
649
+ right: xt
650
+ }, $t = $(
651
+ ({
652
+ trigger: e,
653
+ content: r,
654
+ position: t = "bottom",
655
+ open: o,
656
+ onOpenChange: n,
657
+ classes: i,
658
+ className: l,
659
+ style: u
660
+ }, d) => {
661
+ const [m, a] = oe(!1), p = j(null), h = o !== void 0, f = h ? o : m, y = C(
662
+ (A) => {
663
+ h || a(A), n?.(A);
664
+ },
665
+ [h, n]
666
+ ), D = C(() => y(!1), [y]), P = C(() => {
667
+ y(!f);
668
+ }, [f, y]);
669
+ return ie(p, D), ne(
670
+ {
671
+ Escape: () => D()
672
+ },
673
+ f
674
+ ), /* @__PURE__ */ c(
675
+ "div",
676
+ {
677
+ ref: d,
678
+ className: s(G.root, i?.root, l),
679
+ style: u,
680
+ children: /* @__PURE__ */ b("div", { ref: p, children: [
681
+ /* @__PURE__ */ c(
682
+ "button",
683
+ {
684
+ type: "button",
685
+ className: s(G.trigger, i?.trigger),
686
+ onClick: P,
687
+ "aria-expanded": f,
688
+ children: e
689
+ }
690
+ ),
691
+ f && /* @__PURE__ */ c("div", { className: s(G.popover, G[t], i?.popover), children: r })
692
+ ] })
693
+ }
694
+ );
695
+ }
696
+ );
697
+ $t.displayName = "Popover";
698
+ const se = [
699
+ 'input:not([disabled]):not([type="hidden"])',
700
+ "button:not([disabled])",
701
+ "select:not([disabled])",
702
+ "textarea:not([disabled])",
703
+ "a[href]",
704
+ '[tabindex]:not([tabindex="-1"])'
705
+ ].join(", ");
706
+ function St(e, r) {
707
+ const t = j(null), o = C(
708
+ (n) => {
709
+ if (n.key !== "Tab" || !e.current)
710
+ return;
711
+ const i = Array.from(
712
+ e.current.querySelectorAll(se)
713
+ );
714
+ if (i.length === 0) {
715
+ n.preventDefault();
716
+ return;
717
+ }
718
+ const l = i[0], u = i[i.length - 1];
719
+ n.shiftKey ? document.activeElement === l && (n.preventDefault(), u.focus()) : document.activeElement === u && (n.preventDefault(), l.focus());
720
+ },
721
+ [e]
722
+ );
723
+ O(() => {
724
+ if (!r || !e.current)
725
+ return;
726
+ t.current = document.activeElement;
727
+ const n = e.current.querySelectorAll(se);
728
+ return n.length > 0 && n[0].focus(), document.addEventListener("keydown", o), () => {
729
+ document.removeEventListener("keydown", o), t.current instanceof HTMLElement && t.current.focus();
730
+ };
731
+ }, [r, e, o]);
732
+ }
733
+ const Ct = "crk-backdrop-jYpTA", It = "crk-backdropIn-x5Z-A", Bt = "crk-modal-yNG-7", Dt = "crk-modalIn-xFUwm", At = "crk-sm--xyY9", Lt = "crk-md-ETTfh", Rt = "crk-lg-5DBb7", Et = "crk-fullscreen-b4jQ-", Tt = "crk-header-NS30G", Ft = "crk-headerWithClose-4davm", Pt = "crk-closeButton-JX-aq", Mt = "crk-body-3zIj9", Wt = "crk-footer-Oyz-R", R = {
734
+ backdrop: Ct,
735
+ backdropIn: It,
736
+ modal: Bt,
737
+ modalIn: Dt,
738
+ sm: At,
739
+ md: Lt,
740
+ lg: Rt,
741
+ fullscreen: Et,
742
+ header: Tt,
743
+ headerWithClose: Ft,
744
+ closeButton: Pt,
745
+ body: Mt,
746
+ footer: Wt
747
+ }, J = ae({}), de = ({ children: e, className: r, style: t, onClose: o }) => {
748
+ const n = Z(J);
749
+ return /* @__PURE__ */ b(
750
+ "div",
751
+ {
752
+ className: s(R.header, o && R.headerWithClose, n.header, r),
753
+ style: t,
754
+ children: [
755
+ e,
756
+ o && /* @__PURE__ */ c(
757
+ "button",
758
+ {
759
+ type: "button",
760
+ className: s(R.closeButton, n.closeButton),
761
+ onClick: o,
762
+ "aria-label": "Close",
763
+ children: "×"
764
+ }
765
+ )
766
+ ]
767
+ }
768
+ );
769
+ };
770
+ de.displayName = "Modal.Header";
771
+ const ue = ({ children: e, className: r, style: t }) => {
772
+ const o = Z(J);
773
+ return /* @__PURE__ */ c("div", { className: s(R.body, o.body, r), style: t, children: e });
774
+ };
775
+ ue.displayName = "Modal.Body";
776
+ const me = ({ children: e, className: r, style: t }) => {
777
+ const o = Z(J);
778
+ return /* @__PURE__ */ c("div", { className: s(R.footer, o.footer, r), style: t, children: e });
779
+ };
780
+ me.displayName = "Modal.Footer";
781
+ const _ = $(
782
+ ({
783
+ open: e,
784
+ onClose: r,
785
+ closeOnBackdrop: t = !0,
786
+ closeOnEscape: o = !0,
787
+ size: n = "md",
788
+ classes: i,
789
+ className: l,
790
+ style: u,
791
+ children: d
792
+ }, m) => {
793
+ const a = j(null), p = m ?? a;
794
+ St(p, e);
795
+ const h = X(
796
+ () => ({
797
+ Escape: () => {
798
+ o && r();
799
+ }
800
+ }),
801
+ [o, r]
802
+ );
803
+ ne(h, e), O(() => {
804
+ if (!e) return;
805
+ const y = document.body.style.overflow;
806
+ return document.body.style.overflow = "hidden", () => {
807
+ document.body.style.overflow = y;
808
+ };
809
+ }, [e]);
810
+ const f = (y) => {
811
+ t && y.target === y.currentTarget && r();
812
+ };
813
+ return e ? ye(
814
+ /* @__PURE__ */ c(
815
+ "div",
816
+ {
817
+ className: s(R.backdrop, i?.backdrop),
818
+ onClick: f,
819
+ role: "presentation",
820
+ children: /* @__PURE__ */ c(
821
+ "div",
822
+ {
823
+ ref: p,
824
+ className: s(R.modal, R[n], i?.modal, l),
825
+ style: u,
826
+ role: "dialog",
827
+ "aria-modal": "true",
828
+ children: /* @__PURE__ */ c(J.Provider, { value: i ?? {}, children: d })
829
+ }
830
+ )
831
+ }
832
+ ),
833
+ document.body
834
+ ) : null;
835
+ }
836
+ );
837
+ _.displayName = "Modal";
838
+ _.Header = de;
839
+ _.Body = ue;
840
+ _.Footer = me;
841
+ const zt = "crk-root-jHIIP", qt = "crk-field-OUlYz", Ot = "crk-label-udkR7", jt = "crk-required-IYiA2", Ht = "crk-error-yFZXm", Ut = "crk-helperText-Dm-rb", z = {
842
+ root: zt,
843
+ field: qt,
844
+ label: Ot,
845
+ required: jt,
846
+ error: Ht,
847
+ helperText: Ut
848
+ };
849
+ function Wo({
850
+ form: e,
851
+ onSubmit: r,
852
+ className: t,
853
+ style: o,
854
+ children: n
855
+ }) {
856
+ return /* @__PURE__ */ c(fe, { ...e, children: /* @__PURE__ */ c(
857
+ "form",
858
+ {
859
+ onSubmit: e.handleSubmit(r),
860
+ className: s(z.root, t),
861
+ style: o,
862
+ children: n
863
+ }
864
+ ) });
865
+ }
866
+ function zo({
867
+ name: e,
868
+ label: r,
869
+ helperText: t,
870
+ required: o,
871
+ rules: n,
872
+ classes: i,
873
+ className: l,
874
+ style: u,
875
+ children: d
876
+ }) {
877
+ const { control: m } = ge(), { field: a, fieldState: p } = be({ name: e, control: m, rules: n });
878
+ return /* @__PURE__ */ b("div", { className: s(z.field, i?.field, l), style: u, children: [
879
+ r && /* @__PURE__ */ b("label", { className: s(z.label, i?.label), htmlFor: e, children: [
880
+ r,
881
+ o && /* @__PURE__ */ c("span", { className: z.required, children: "*" })
882
+ ] }),
883
+ ke(d, { ...a, id: e, error: !!p.error }),
884
+ p.error?.message ? /* @__PURE__ */ c("span", { className: s(z.error, i?.error), children: p.error.message }) : t ? /* @__PURE__ */ c("span", { className: s(z.helperText, i?.helperText), children: t }) : null
885
+ ] });
886
+ }
887
+ const Gt = "crk-root-rSgdy", Kt = "crk-wrapper-GHy8V", Qt = "crk-sm-DptM5", Vt = "crk-md-F4B0G", Yt = "crk-lg-pBxwX", Xt = "crk-error-fucxe", Zt = "crk-prefix-w53Md", Jt = "crk-suffix-fcNgR", _t = "crk-hasPrefix--bqPD", eo = "crk-hasSuffix-zO0nX", B = {
888
+ root: Gt,
889
+ wrapper: Kt,
890
+ sm: Qt,
891
+ md: Vt,
892
+ lg: Yt,
893
+ error: Xt,
894
+ prefix: Zt,
895
+ suffix: Jt,
896
+ hasPrefix: _t,
897
+ hasSuffix: eo
898
+ }, ro = $(
899
+ ({
900
+ inputSize: e = "md",
901
+ error: r = !1,
902
+ prefix: t,
903
+ suffix: o,
904
+ classes: n,
905
+ className: i,
906
+ style: l,
907
+ ...u
908
+ }, d) => {
909
+ const m = /* @__PURE__ */ c(
910
+ "input",
911
+ {
912
+ ref: d,
913
+ className: s(
914
+ B.root,
915
+ B[e],
916
+ r && B.error,
917
+ t && B.hasPrefix,
918
+ o && B.hasSuffix,
919
+ n?.root,
920
+ !t && !o && i
921
+ ),
922
+ style: !t && !o ? l : void 0,
923
+ ...u
924
+ }
925
+ );
926
+ return t || o ? /* @__PURE__ */ b(
927
+ "div",
928
+ {
929
+ className: s(B.wrapper, B[e], r && B.error, n?.wrapper, i),
930
+ style: l,
931
+ children: [
932
+ t && /* @__PURE__ */ c("span", { className: s(B.prefix, n?.prefix), children: t }),
933
+ m,
934
+ o && /* @__PURE__ */ c("span", { className: s(B.suffix, n?.suffix), children: o })
935
+ ]
936
+ }
937
+ ) : m;
938
+ }
939
+ );
940
+ ro.displayName = "Input";
941
+ const to = "crk-wrapper-SP2JE", oo = "crk-root-Uu9Ah", no = "crk-sm-DqshL", co = "crk-md-j4AKI", so = "crk-lg-24Xd3", ao = "crk-error-9oRU6", lo = "crk-arrow-WU8ZW", F = {
942
+ wrapper: to,
943
+ root: oo,
944
+ sm: no,
945
+ md: co,
946
+ lg: so,
947
+ error: ao,
948
+ arrow: lo
949
+ }, io = $(
950
+ ({
951
+ inputSize: e = "md",
952
+ error: r = !1,
953
+ options: t,
954
+ placeholder: o,
955
+ classes: n,
956
+ className: i,
957
+ style: l,
958
+ children: u,
959
+ ...d
960
+ }, m) => /* @__PURE__ */ b("div", { className: s(F.wrapper, F[e], r && F.error, n?.wrapper, i), style: l, children: [
961
+ /* @__PURE__ */ b(
962
+ "select",
963
+ {
964
+ ref: m,
965
+ className: s(F.root, F[e], r && F.error, n?.root),
966
+ ...d,
967
+ children: [
968
+ o && /* @__PURE__ */ c("option", { value: "", disabled: !0, children: o }),
969
+ t ? t.map((a) => /* @__PURE__ */ c("option", { value: a.value, disabled: a.disabled, children: a.label }, a.value)) : u
970
+ ]
971
+ }
972
+ ),
973
+ /* @__PURE__ */ c("span", { className: s(F.arrow, n?.arrow) })
974
+ ] })
975
+ );
976
+ io.displayName = "Select";
977
+ const uo = "crk-root-61cKD", mo = "crk-input-bAjPU", po = "crk-label-W9IeS", ho = "crk-indeterminate-mLarv", K = {
978
+ root: uo,
979
+ input: mo,
980
+ label: po,
981
+ indeterminate: ho
982
+ }, ko = $(
983
+ ({
984
+ label: e,
985
+ indeterminate: r = !1,
986
+ classes: t,
987
+ className: o,
988
+ style: n,
989
+ ...i
990
+ }, l) => {
991
+ const u = j(null);
992
+ return O(() => {
993
+ u.current && (u.current.indeterminate = r);
994
+ }, [r]), /* @__PURE__ */ b(
995
+ "label",
996
+ {
997
+ className: s(K.root, r && K.indeterminate, t?.root, o),
998
+ style: n,
999
+ children: [
1000
+ /* @__PURE__ */ c(
1001
+ "input",
1002
+ {
1003
+ ref: (d) => {
1004
+ u.current = d, typeof l == "function" ? l(d) : l && (l.current = d);
1005
+ },
1006
+ type: "checkbox",
1007
+ className: s(K.input, t?.input),
1008
+ ...i
1009
+ }
1010
+ ),
1011
+ e && /* @__PURE__ */ c("span", { className: s(K.label, t?.label), children: e })
1012
+ ]
1013
+ }
1014
+ );
1015
+ }
1016
+ );
1017
+ ko.displayName = "Checkbox";
1018
+ const fo = "crk-group-NNwCD", go = "crk-root-7fGik", bo = "crk-input-43PQW", yo = "crk-label-aW30x", Y = {
1019
+ group: fo,
1020
+ root: go,
1021
+ input: bo,
1022
+ label: yo
1023
+ }, pe = ae(null), No = ({
1024
+ name: e,
1025
+ value: r,
1026
+ onChange: t,
1027
+ className: o,
1028
+ style: n,
1029
+ children: i
1030
+ }) => /* @__PURE__ */ c(pe.Provider, { value: { name: e, value: r, onChange: t }, children: /* @__PURE__ */ c("div", { className: s(Y.group, o), style: n, role: "radiogroup", children: i }) });
1031
+ No.displayName = "RadioGroup";
1032
+ const vo = $(
1033
+ ({
1034
+ label: e,
1035
+ value: r,
1036
+ classes: t,
1037
+ className: o,
1038
+ style: n,
1039
+ onChange: i,
1040
+ checked: l,
1041
+ name: u,
1042
+ ...d
1043
+ }, m) => {
1044
+ const a = Z(pe), p = a?.name ?? u, h = a ? a.value === r : l, f = (y) => {
1045
+ a?.onChange?.(r), i?.(y);
1046
+ };
1047
+ return /* @__PURE__ */ b("label", { className: s(Y.root, t?.root, o), style: n, children: [
1048
+ /* @__PURE__ */ c(
1049
+ "input",
1050
+ {
1051
+ ref: m,
1052
+ type: "radio",
1053
+ className: s(Y.input, t?.input),
1054
+ name: p,
1055
+ value: r,
1056
+ checked: h,
1057
+ onChange: f,
1058
+ ...d
1059
+ }
1060
+ ),
1061
+ e && /* @__PURE__ */ c("span", { className: s(Y.label, t?.label), children: e })
1062
+ ] });
1063
+ }
1064
+ );
1065
+ vo.displayName = "Radio";
1066
+ const wo = "crk-root-IGgdn", xo = "crk-sm-N-5I2", $o = "crk-md-bbyFl", So = "crk-lg-Pd-Iq", Co = "crk-error-fyu3i", Io = "crk-resizeNone-SmNT4", Bo = "crk-resizeVertical-oi8vP", Do = "crk-resizeHorizontal-riMLL", Ao = "crk-resizeBoth-NYSh4", Q = {
1067
+ root: wo,
1068
+ sm: xo,
1069
+ md: $o,
1070
+ lg: So,
1071
+ error: Co,
1072
+ resizeNone: Io,
1073
+ resizeVertical: Bo,
1074
+ resizeHorizontal: Do,
1075
+ resizeBoth: Ao
1076
+ }, Lo = {
1077
+ none: "resizeNone",
1078
+ vertical: "resizeVertical",
1079
+ horizontal: "resizeHorizontal",
1080
+ both: "resizeBoth"
1081
+ }, Ro = $(
1082
+ ({
1083
+ inputSize: e = "md",
1084
+ error: r = !1,
1085
+ resize: t = "vertical",
1086
+ className: o,
1087
+ style: n,
1088
+ ...i
1089
+ }, l) => /* @__PURE__ */ c(
1090
+ "textarea",
1091
+ {
1092
+ ref: l,
1093
+ className: s(
1094
+ Q.root,
1095
+ Q[e],
1096
+ r && Q.error,
1097
+ Q[Lo[t]],
1098
+ o
1099
+ ),
1100
+ style: n,
1101
+ ...i
1102
+ }
1103
+ )
1104
+ );
1105
+ Ro.displayName = "Textarea";
1106
+ export {
1107
+ Oe as Button,
1108
+ ko as Checkbox,
1109
+ ht as Dropdown,
1110
+ kt as DropdownItem,
1111
+ Wo as Form,
1112
+ zo as FormField,
1113
+ ro as Input,
1114
+ Ge as Link,
1115
+ xr as List,
1116
+ $r as ListItem,
1117
+ _ as Modal,
1118
+ $t as Popover,
1119
+ vo as Radio,
1120
+ No as RadioGroup,
1121
+ io as Select,
1122
+ Mo as Table,
1123
+ Ro as Textarea,
1124
+ hr as Typography,
1125
+ ie as useClickOutside,
1126
+ St as useFocusTrap,
1127
+ ne as useKeyboard,
1128
+ Yr as useTableSort
1129
+ };