@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,86 @@
1
+ import { jsxs as W, jsx as q } from "react/jsx-runtime";
2
+ import { useRef as b, useState as E, useId as J, useCallback as L, useEffect as A, useLayoutEffect as Q } from "react";
3
+ import { createPortal as U } from "react-dom";
4
+ import x from "clsx";
5
+ import w from "./Tooltip.module.scss.js";
6
+ const e = 8;
7
+ function V({
8
+ content: p,
9
+ children: F,
10
+ placement: r = "top",
11
+ delay: M = 300,
12
+ closeDelay: h = 0,
13
+ disabled: R = !1,
14
+ hideArrow: G = !1,
15
+ classes: v
16
+ }) {
17
+ const T = b(null), N = b(null), s = b(null), [n, a] = E(!1), [K, O] = E(r), [k, P] = E({ top: 0, left: 0 }), B = J(), i = L(() => {
18
+ s.current && (clearTimeout(s.current), s.current = null);
19
+ }, []), C = L(() => {
20
+ R || p == null || p === "" || (i(), s.current = setTimeout(() => a(!0), M));
21
+ }, [R, p, i, M]), j = L(() => {
22
+ i(), h > 0 ? s.current = setTimeout(() => a(!1), h) : a(!1);
23
+ }, [i, h]);
24
+ A(() => i, [i]), Q(() => {
25
+ if (!n) return;
26
+ const o = () => {
27
+ const m = T.current, y = N.current;
28
+ if (!m || !y) return;
29
+ const t = m.getBoundingClientRect(), f = y.offsetWidth, u = y.offsetHeight, z = typeof window < "u" ? window.innerWidth : 0, H = typeof window < "u" ? window.innerHeight : 0, I = (g) => g === "top" ? t.top - u - e >= 0 : g === "bottom" ? t.bottom + u + e <= H : g === "left" ? t.left - f - e >= 0 : t.right + f + e <= z, S = {
30
+ top: "bottom",
31
+ bottom: "top",
32
+ left: "right",
33
+ right: "left"
34
+ }, d = I(r) || !I(S[r]) ? r : S[r];
35
+ let l = 0, c = 0;
36
+ d === "top" || d === "bottom" ? (c = t.left + t.width / 2 - f / 2, l = d === "top" ? t.top - u - e : t.bottom + e) : (l = t.top + t.height / 2 - u / 2, c = d === "left" ? t.left - f - e : t.right + e), c = Math.max(e, Math.min(c, z - f - e)), l = Math.max(e, Math.min(l, H - u - e)), O(d), P({ top: l, left: c });
37
+ };
38
+ if (o(), !(typeof window > "u"))
39
+ return window.addEventListener("scroll", o, !0), window.addEventListener("resize", o), () => {
40
+ window.removeEventListener("scroll", o, !0), window.removeEventListener("resize", o);
41
+ };
42
+ }, [n, r]), A(() => {
43
+ if (!n) return;
44
+ const o = (m) => {
45
+ m.key === "Escape" && a(!1);
46
+ };
47
+ return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
48
+ }, [n]);
49
+ const _ = n ? B : void 0, $ = { position: "fixed", top: k.top, left: k.left };
50
+ return /* @__PURE__ */ W(
51
+ "span",
52
+ {
53
+ ref: T,
54
+ className: x(w.wrapper, v?.wrapper),
55
+ onMouseEnter: C,
56
+ onMouseLeave: j,
57
+ onFocus: C,
58
+ onBlur: j,
59
+ "aria-describedby": _,
60
+ children: [
61
+ F,
62
+ n && typeof document < "u" && U(
63
+ /* @__PURE__ */ W(
64
+ "div",
65
+ {
66
+ ref: N,
67
+ id: B,
68
+ role: "tooltip",
69
+ className: x(w.tooltip, w[`p_${K}`], v?.tooltip),
70
+ style: $,
71
+ children: [
72
+ p,
73
+ !G && /* @__PURE__ */ q("span", { className: x(w.arrow, v?.arrow), "aria-hidden": "true" })
74
+ ]
75
+ }
76
+ ),
77
+ document.body
78
+ )
79
+ ]
80
+ }
81
+ );
82
+ }
83
+ V.displayName = "Tooltip";
84
+ export {
85
+ V as Tooltip
86
+ };
@@ -0,0 +1,30 @@
1
+ const t = "crk-wrapper-V567h", o = "crk-tooltip-LjRUX", p = "crk-crk-tooltip-in-JCAKo", r = "crk-arrow-6yECM", c = "crk-p_top-I9ELz", k = "crk-p_top-I9ELz", n = "crk-p_bottom-S3gQ1", i = "crk-p_bottom-S3gQ1", l = "crk-p_left--Bx3l", s = "crk-p_left--Bx3l", _ = "crk-p_right-3Wuqv", e = "crk-p_right-3Wuqv", a = {
2
+ wrapper: t,
3
+ tooltip: o,
4
+ "crk-tooltip-in": "crk-crk-tooltip-in-JCAKo",
5
+ crkTooltipIn: p,
6
+ arrow: r,
7
+ p_top: c,
8
+ pTop: k,
9
+ p_bottom: n,
10
+ pBottom: i,
11
+ p_left: l,
12
+ pLeft: s,
13
+ p_right: _,
14
+ pRight: e
15
+ };
16
+ export {
17
+ r as arrow,
18
+ p as crkTooltipIn,
19
+ a as default,
20
+ i as pBottom,
21
+ s as pLeft,
22
+ e as pRight,
23
+ k as pTop,
24
+ n as p_bottom,
25
+ l as p_left,
26
+ _ as p_right,
27
+ c as p_top,
28
+ o as tooltip,
29
+ t as wrapper
30
+ };
@@ -0,0 +1,37 @@
1
+ import { forwardRef as c, createElement as n } from "react";
2
+ import d from "clsx";
3
+ import r from "./Typography.module.scss.js";
4
+ const i = c(
5
+ ({
6
+ variant: e = "p",
7
+ weight: o,
8
+ color: p,
9
+ align: t,
10
+ truncate: m = !1,
11
+ className: a,
12
+ style: s,
13
+ children: f,
14
+ ...y
15
+ }, l) => n(
16
+ e,
17
+ {
18
+ ref: l,
19
+ className: d(
20
+ r.root,
21
+ r[e],
22
+ o && r[o],
23
+ p && r[p],
24
+ t && r[`align-${t}`],
25
+ m && r.truncate,
26
+ a
27
+ ),
28
+ style: s,
29
+ ...y
30
+ },
31
+ f
32
+ )
33
+ );
34
+ i.displayName = "Typography";
35
+ export {
36
+ i as Typography
37
+ };
@@ -0,0 +1,53 @@
1
+ const c = "crk-root-U-oiq", r = "crk-h1-Aivwz", t = "crk-h2-CV8Oo", n = "crk-h3-lrbrK", e = "crk-h4--jkC1", o = "crk-h5-GnQvD", s = "crk-h6-MKlIN", l = "crk-p-FzRtm", a = "crk-span-NZvLx", i = "crk-label-Cwi6a", k = "crk-normal-7AeZz", h = "crk-medium-36OXr", g = "crk-semibold-oQixc", m = "crk-bold-bk4b4", d = "crk-muted-itOSW", u = "crk-primary-rp36t", b = "crk-danger-SyOy-", p = "crk-success-w8PpD", f = "crk-align-left-3AGYw", y = "crk-align-center-h-x--", w = "crk-align-right-IXFhK", x = "crk-truncate-eqr85", C = {
2
+ root: c,
3
+ h1: r,
4
+ h2: t,
5
+ h3: n,
6
+ h4: e,
7
+ h5: o,
8
+ h6: s,
9
+ p: l,
10
+ span: a,
11
+ label: i,
12
+ normal: k,
13
+ medium: h,
14
+ semibold: g,
15
+ bold: m,
16
+ default: "crk-default-79lKR",
17
+ muted: d,
18
+ primary: u,
19
+ danger: b,
20
+ success: p,
21
+ "align-left": "crk-align-left-3AGYw",
22
+ alignLeft: f,
23
+ "align-center": "crk-align-center-h-x--",
24
+ alignCenter: y,
25
+ "align-right": "crk-align-right-IXFhK",
26
+ alignRight: w,
27
+ truncate: x
28
+ };
29
+ export {
30
+ y as alignCenter,
31
+ f as alignLeft,
32
+ w as alignRight,
33
+ m as bold,
34
+ b as danger,
35
+ C as default,
36
+ r as h1,
37
+ t as h2,
38
+ n as h3,
39
+ e as h4,
40
+ o as h5,
41
+ s as h6,
42
+ i as label,
43
+ h as medium,
44
+ d as muted,
45
+ k as normal,
46
+ l as p,
47
+ u as primary,
48
+ c as root,
49
+ g as semibold,
50
+ a as span,
51
+ p as success,
52
+ x as truncate
53
+ };
@@ -0,0 +1,50 @@
1
+ import { jsxs as x, jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as b, useRef as d, useEffect as w } from "react";
3
+ import s from "clsx";
4
+ import t from "./Checkbox.module.scss.js";
5
+ const k = b(
6
+ ({
7
+ label: m,
8
+ variant: f = "checkbox",
9
+ indeterminate: l = !1,
10
+ classes: r,
11
+ className: p,
12
+ style: u,
13
+ ...h
14
+ }, e) => {
15
+ const i = d(null), n = f === "switch", c = l && !n;
16
+ return w(() => {
17
+ i.current && (i.current.indeterminate = c);
18
+ }, [c]), /* @__PURE__ */ x(
19
+ "label",
20
+ {
21
+ className: s(
22
+ t.root,
23
+ n && t.switchRoot,
24
+ c && t.indeterminate,
25
+ r?.root,
26
+ p
27
+ ),
28
+ style: u,
29
+ children: [
30
+ /* @__PURE__ */ a(
31
+ "input",
32
+ {
33
+ ref: (o) => {
34
+ i.current = o, typeof e == "function" ? e(o) : e && (e.current = o);
35
+ },
36
+ type: "checkbox",
37
+ className: s(t.input, n && t.switchInput, r?.input),
38
+ ...h
39
+ }
40
+ ),
41
+ m && /* @__PURE__ */ a("span", { className: s(t.label, r?.label), children: m })
42
+ ]
43
+ }
44
+ );
45
+ }
46
+ );
47
+ k.displayName = "Checkbox";
48
+ export {
49
+ k as Checkbox
50
+ };
@@ -0,0 +1,15 @@
1
+ const t = "crk-root-61cKD", n = "crk-input-bAjPU", e = "crk-switchInput-Ichse", c = "crk-label-W9IeS", o = "crk-indeterminate-mLarv", r = {
2
+ root: t,
3
+ input: n,
4
+ switchInput: e,
5
+ label: c,
6
+ indeterminate: o
7
+ };
8
+ export {
9
+ r as default,
10
+ o as indeterminate,
11
+ n as input,
12
+ c as label,
13
+ t as root,
14
+ e as switchInput
15
+ };
@@ -0,0 +1,111 @@
1
+ import { jsx as s, jsxs as w } from "react/jsx-runtime";
2
+ import { forwardRef as z } from "react";
3
+ import o from "clsx";
4
+ import { Checkbox as D } from "./Checkbox.js";
5
+ import i from "./CheckboxGroup.module.scss.js";
6
+ const O = z(
7
+ ({
8
+ options: p,
9
+ value: a = [],
10
+ onChange: t,
11
+ variant: d = "checkbox",
12
+ chipShape: b = "pill",
13
+ chipCheckmark: h = !0,
14
+ orientation: u,
15
+ disabled: m = !1,
16
+ error: f = !1,
17
+ name: x,
18
+ classes: l,
19
+ className: k,
20
+ style: v,
21
+ id: C,
22
+ "aria-label": y,
23
+ "aria-labelledby": g,
24
+ "aria-describedby": N,
25
+ "aria-invalid": q,
26
+ required: G
27
+ }, S) => {
28
+ const j = u ?? (d === "chips" ? "horizontal" : "vertical"), R = {
29
+ pill: i.chipPill,
30
+ rounded: i.chipRounded,
31
+ square: i.chipSquare
32
+ }[b], n = (e) => {
33
+ const r = a.includes(e) ? a.filter((c) => c !== e) : [...a, e];
34
+ t?.(r);
35
+ };
36
+ return /* @__PURE__ */ s(
37
+ "div",
38
+ {
39
+ ref: S,
40
+ id: C,
41
+ role: "group",
42
+ "aria-label": y,
43
+ "aria-labelledby": g,
44
+ "aria-describedby": N,
45
+ "aria-invalid": q,
46
+ "aria-required": G || void 0,
47
+ className: o(
48
+ i.group,
49
+ i[j],
50
+ d === "chips" && i.chipsGroup,
51
+ f && i.error,
52
+ l?.group,
53
+ k
54
+ ),
55
+ style: v,
56
+ children: p.map((e) => {
57
+ const r = a.includes(e.value), c = m || e.disabled;
58
+ return d === "chips" ? /* @__PURE__ */ w(
59
+ "button",
60
+ {
61
+ type: "button",
62
+ role: "checkbox",
63
+ "aria-checked": r,
64
+ disabled: c,
65
+ className: o(
66
+ i.chip,
67
+ R,
68
+ r && i.chipSelected,
69
+ h && r && i.chipChecked,
70
+ l?.option,
71
+ l?.chip,
72
+ r && l?.chipSelected
73
+ ),
74
+ onClick: () => n(e.value),
75
+ children: [
76
+ h && // Always rendered so it can transition; collapsed to zero
77
+ // width when unselected, expanding in when selected. Padding
78
+ // stays symmetric, so the icon + label remain centered.
79
+ /* @__PURE__ */ s(
80
+ "span",
81
+ {
82
+ className: o(i.chipCheck, r && i.chipCheckVisible),
83
+ "aria-hidden": "true"
84
+ }
85
+ ),
86
+ e.label
87
+ ]
88
+ },
89
+ e.value
90
+ ) : /* @__PURE__ */ s(
91
+ D,
92
+ {
93
+ name: x,
94
+ value: e.value,
95
+ label: e.label,
96
+ checked: r,
97
+ disabled: c,
98
+ className: o(i.option, l?.option),
99
+ onChange: () => n(e.value)
100
+ },
101
+ e.value
102
+ );
103
+ })
104
+ }
105
+ );
106
+ }
107
+ );
108
+ O.displayName = "CheckboxGroup";
109
+ export {
110
+ O as CheckboxGroup
111
+ };
@@ -0,0 +1,31 @@
1
+ const c = "crk-group-3jaV7", i = "crk-vertical--i2tD", h = "crk-horizontal-4qzrj", e = "crk-chipsGroup-jyDEd", r = "crk-chip-NYeqm", p = "crk-chipPill-DfnpS", o = "crk-chipRounded-oi-hI", t = "crk-chipSquare-ZcbQB", n = "crk-chipCheck-4nqaQ", s = "crk-chipCheckVisible-nGulJ", k = "crk-chipChecked-4h2bc", l = "crk-chipSelected-qbOpf", d = "crk-error-phPRL", u = {
2
+ group: c,
3
+ vertical: i,
4
+ horizontal: h,
5
+ chipsGroup: e,
6
+ chip: r,
7
+ chipPill: p,
8
+ chipRounded: o,
9
+ chipSquare: t,
10
+ chipCheck: n,
11
+ chipCheckVisible: s,
12
+ chipChecked: k,
13
+ chipSelected: l,
14
+ error: d
15
+ };
16
+ export {
17
+ r as chip,
18
+ n as chipCheck,
19
+ s as chipCheckVisible,
20
+ k as chipChecked,
21
+ p as chipPill,
22
+ o as chipRounded,
23
+ l as chipSelected,
24
+ t as chipSquare,
25
+ e as chipsGroup,
26
+ u as default,
27
+ d as error,
28
+ c as group,
29
+ h as horizontal,
30
+ i as vertical
31
+ };
@@ -0,0 +1,229 @@
1
+ import { jsxs as k, jsx as r } from "react/jsx-runtime";
2
+ import { forwardRef as me, useState as w, useRef as F, useMemo as h, useCallback as f, useEffect as he } from "react";
3
+ import { createPortal as ye } from "react-dom";
4
+ import l from "clsx";
5
+ import { useClickOutside as De } from "../../../hooks/useClickOutside.js";
6
+ import { usePortalPosition as ve } from "../../../hooks/usePortalPosition.js";
7
+ import t from "./DatePicker.module.scss.js";
8
+ import { startOfMonth as R, startOfDay as y, weekdayLabels as be, buildCalendarDays as ke, toISODate as S, isSameMonth as J, addMonths as g, isSameDay as A, addDays as p } from "./dateUtils.js";
9
+ const we = me(
10
+ ({
11
+ value: j,
12
+ defaultValue: Q,
13
+ onChange: K,
14
+ min: C,
15
+ max: N,
16
+ disabledDate: O,
17
+ weekStartsOn: u = 0,
18
+ locale: s,
19
+ format: B,
20
+ placeholder: X = "Select date",
21
+ inputSize: Y = "md",
22
+ error: W = !1,
23
+ disabled: m = !1,
24
+ portal: D = !0,
25
+ classes: n,
26
+ className: Z,
27
+ style: _,
28
+ "aria-label": ee
29
+ }, te) => {
30
+ const x = j !== void 0, [re, ae] = w(Q ?? null), d = x ? j ?? null : re, [c, v] = w(!1), [i, b] = w(() => R(d ?? /* @__PURE__ */ new Date())), [a, q] = w(() => y(d ?? /* @__PURE__ */ new Date())), L = F(null), U = F(null), G = F(null), H = ve(L, c && D), oe = h(() => y(/* @__PURE__ */ new Date()), []), ne = h(
31
+ () => B ?? ((e) => new Intl.DateTimeFormat(s, { year: "numeric", month: "short", day: "numeric" }).format(e)),
32
+ [B, s]
33
+ ), ie = h(
34
+ () => new Intl.DateTimeFormat(s, { month: "long", year: "numeric" }).format(i),
35
+ [s, i]
36
+ ), le = h(() => be(s, u), [s, u]), se = h(() => ke(i, u), [i, u]), M = f(
37
+ (e) => C && e < y(C) || N && e > y(N) ? !0 : O?.(e) ?? !1,
38
+ [C, N, O]
39
+ ), V = f(
40
+ (e) => {
41
+ x || ae(e), K?.(e);
42
+ },
43
+ [x, K]
44
+ ), I = f(() => {
45
+ if (m) return;
46
+ const e = y(d ?? /* @__PURE__ */ new Date());
47
+ b(R(e)), q(e), v(!0);
48
+ }, [m, d]), P = f((e = !0) => {
49
+ v(!1), e && L.current?.querySelector("input")?.focus();
50
+ }, []), $ = f(
51
+ (e) => {
52
+ M(e) || (V(e), P());
53
+ },
54
+ [M, V, P]
55
+ );
56
+ De(U, () => v(!1), c), he(() => {
57
+ if (!c) return;
58
+ G.current?.querySelector(`[data-date="${S(a)}"]`)?.focus();
59
+ }, [c, a]);
60
+ const de = f(
61
+ (e) => {
62
+ q(e), J(e, i) || b(R(e));
63
+ },
64
+ [i]
65
+ ), ce = (e) => {
66
+ let o = null;
67
+ switch (e.key) {
68
+ case "ArrowLeft":
69
+ o = p(a, -1);
70
+ break;
71
+ case "ArrowRight":
72
+ o = p(a, 1);
73
+ break;
74
+ case "ArrowUp":
75
+ o = p(a, -7);
76
+ break;
77
+ case "ArrowDown":
78
+ o = p(a, 7);
79
+ break;
80
+ case "Home":
81
+ o = p(a, -((a.getDay() - u + 7) % 7));
82
+ break;
83
+ case "End":
84
+ o = p(a, 6 - (a.getDay() - u + 7) % 7);
85
+ break;
86
+ case "PageUp":
87
+ o = g(a, -1);
88
+ break;
89
+ case "PageDown":
90
+ o = g(a, 1);
91
+ break;
92
+ case "Enter":
93
+ case " ":
94
+ e.preventDefault(), $(a);
95
+ return;
96
+ case "Escape":
97
+ e.preventDefault(), P();
98
+ return;
99
+ default:
100
+ return;
101
+ }
102
+ e.preventDefault(), de(o);
103
+ }, ue = (e) => {
104
+ e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), I()) : e.key === "Escape" && c && v(!1);
105
+ }, z = /* @__PURE__ */ k(
106
+ "div",
107
+ {
108
+ ref: U,
109
+ className: l(t.popover, D && t.portalled, n?.popover),
110
+ style: D ? { position: "fixed", top: H.top + 4, left: H.left } : void 0,
111
+ role: "dialog",
112
+ "aria-modal": "false",
113
+ "aria-label": "Choose date",
114
+ children: [
115
+ /* @__PURE__ */ k("div", { className: l(t.header, n?.header), children: [
116
+ /* @__PURE__ */ r(
117
+ "button",
118
+ {
119
+ type: "button",
120
+ className: l(t.nav, n?.nav),
121
+ onClick: () => b(g(i, -1)),
122
+ "aria-label": "Previous month",
123
+ children: /* @__PURE__ */ r("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M7 2L3 6l4 4" }) })
124
+ }
125
+ ),
126
+ /* @__PURE__ */ r("span", { className: t.monthLabel, "aria-live": "polite", children: ie }),
127
+ /* @__PURE__ */ r(
128
+ "button",
129
+ {
130
+ type: "button",
131
+ className: l(t.nav, n?.nav),
132
+ onClick: () => b(g(i, 1)),
133
+ "aria-label": "Next month",
134
+ children: /* @__PURE__ */ r("svg", { viewBox: "0 0 12 12", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: /* @__PURE__ */ r("path", { d: "M5 2l4 4-4 4" }) })
135
+ }
136
+ )
137
+ ] }),
138
+ /* @__PURE__ */ r("div", { className: t.weekdays, "aria-hidden": "true", children: le.map((e, o) => /* @__PURE__ */ r("span", { className: t.weekday, children: e }, o)) }),
139
+ /* @__PURE__ */ r(
140
+ "div",
141
+ {
142
+ ref: G,
143
+ role: "grid",
144
+ className: l(t.grid, n?.grid),
145
+ onKeyDown: ce,
146
+ children: se.map((e) => {
147
+ const o = !J(e, i), T = A(e, d), E = A(e, oe), fe = M(e), pe = A(e, a);
148
+ return /* @__PURE__ */ r(
149
+ "button",
150
+ {
151
+ type: "button",
152
+ role: "gridcell",
153
+ "data-date": S(e),
154
+ tabIndex: pe ? 0 : -1,
155
+ className: l(
156
+ t.day,
157
+ o && t.dayOutside,
158
+ E && t.dayToday,
159
+ T && t.daySelected,
160
+ o && n?.dayOutside,
161
+ E && n?.dayToday,
162
+ T && n?.daySelected,
163
+ n?.day
164
+ ),
165
+ "aria-selected": T,
166
+ "aria-disabled": fe || void 0,
167
+ "aria-current": E ? "date" : void 0,
168
+ "aria-label": new Intl.DateTimeFormat(s, { dateStyle: "full" }).format(e),
169
+ onClick: () => $(e),
170
+ children: e.getDate()
171
+ },
172
+ S(e)
173
+ );
174
+ })
175
+ }
176
+ )
177
+ ]
178
+ }
179
+ );
180
+ return /* @__PURE__ */ k(
181
+ "div",
182
+ {
183
+ ref: L,
184
+ className: l(t.root, t[Y], W && t.error, m && t.disabled, n?.root, Z),
185
+ style: _,
186
+ children: [
187
+ /* @__PURE__ */ r(
188
+ "input",
189
+ {
190
+ ref: te,
191
+ type: "text",
192
+ readOnly: !0,
193
+ className: l(t.input, n?.input),
194
+ value: d ? ne(d) : "",
195
+ placeholder: X,
196
+ disabled: m,
197
+ "aria-label": ee,
198
+ "aria-haspopup": "dialog",
199
+ "aria-expanded": c,
200
+ "aria-invalid": W || void 0,
201
+ onClick: I,
202
+ onKeyDown: ue
203
+ }
204
+ ),
205
+ /* @__PURE__ */ r(
206
+ "button",
207
+ {
208
+ type: "button",
209
+ tabIndex: -1,
210
+ className: l(t.icon, n?.icon),
211
+ onClick: I,
212
+ disabled: m,
213
+ "aria-label": "Open calendar",
214
+ children: /* @__PURE__ */ k("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: [
215
+ /* @__PURE__ */ r("rect", { x: "3", y: "4", width: "14", height: "13", rx: "2" }),
216
+ /* @__PURE__ */ r("path", { d: "M3 8h14M7 2v3M13 2v3", strokeLinecap: "round" })
217
+ ] })
218
+ }
219
+ ),
220
+ c && (D ? typeof document < "u" && ye(z, document.body) : z)
221
+ ]
222
+ }
223
+ );
224
+ }
225
+ );
226
+ we.displayName = "DatePicker";
227
+ export {
228
+ we as DatePicker
229
+ };
@@ -0,0 +1,45 @@
1
+ const e = "crk-root-ZBCoP", o = "crk-sm-7EeFF", c = "crk-input-62G21", d = "crk-md-OVdqx", r = "crk-lg-a9KsJ", t = "crk-icon-jS307", a = "crk-error-c4lUO", s = "crk-disabled-3PiA5", n = "crk-popover-x1-UT", k = "crk-portalled-iPe0Y", y = "crk-header-KmYtH", l = "crk-monthLabel-69Pwi", i = "crk-nav-uKYXN", p = "crk-weekdays--RSzS", m = "crk-grid-tf4tT", u = "crk-weekday-Zc1su", h = "crk-day-5SuBX", w = "crk-dayOutside-q3Phh", S = "crk-dayToday-7rRns", b = "crk-daySelected-a3XL4", g = {
2
+ root: e,
3
+ sm: o,
4
+ input: c,
5
+ md: d,
6
+ lg: r,
7
+ icon: t,
8
+ error: a,
9
+ disabled: s,
10
+ popover: n,
11
+ portalled: k,
12
+ header: y,
13
+ monthLabel: l,
14
+ nav: i,
15
+ weekdays: p,
16
+ grid: m,
17
+ weekday: u,
18
+ day: h,
19
+ dayOutside: w,
20
+ dayToday: S,
21
+ daySelected: b
22
+ };
23
+ export {
24
+ h as day,
25
+ w as dayOutside,
26
+ b as daySelected,
27
+ S as dayToday,
28
+ g as default,
29
+ s as disabled,
30
+ a as error,
31
+ m as grid,
32
+ y as header,
33
+ t as icon,
34
+ c as input,
35
+ r as lg,
36
+ d as md,
37
+ l as monthLabel,
38
+ i as nav,
39
+ n as popover,
40
+ k as portalled,
41
+ e as root,
42
+ o as sm,
43
+ u as weekday,
44
+ p as weekdays
45
+ };