@overdoser/react-toolkit 0.21.0 → 0.22.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 (161) hide show
  1. package/AGENTS.md +1 -0
  2. package/CHANGELOG.md +27 -0
  3. package/components/Accordion/Accordion.js +48 -48
  4. package/components/ActionButton/ActionButton.js +23 -23
  5. package/components/ActionButton/CopyButton.js +5 -5
  6. package/components/Alert/Alert.js +13 -13
  7. package/components/Avatar/Avatar.js +12 -12
  8. package/components/Badge/Badge.js +6 -6
  9. package/components/Breadcrumbs/Breadcrumbs.js +15 -15
  10. package/components/Button/Button.js +14 -14
  11. package/components/Card/Card.js +26 -26
  12. package/components/Chart/AreaChart.js +103 -103
  13. package/components/Chart/Axis.js +7 -7
  14. package/components/Chart/BarChart.js +62 -62
  15. package/components/Chart/ChartContainer.js +11 -11
  16. package/components/Chart/ChartLegend.js +7 -7
  17. package/components/Chart/ChartTooltip.js +13 -13
  18. package/components/Chart/LineChart.js +88 -88
  19. package/components/Chart/PieChart.js +25 -25
  20. package/components/Chart/RadarChart.js +42 -42
  21. package/components/Chart/Sparkline.js +11 -11
  22. package/components/Chart/TradingChart.js +126 -126
  23. package/components/Chart/trading/period.js +3 -3
  24. package/components/Chip/Chip.js +24 -24
  25. package/components/CodeBlock/CodeBlock.js +31 -31
  26. package/components/CommandPalette/CommandPalette.js +166 -166
  27. package/components/ConfirmDialog/ConfirmDialog.js +60 -60
  28. package/components/Divider/Divider.js +10 -10
  29. package/components/Draggable/Draggable.js +29 -29
  30. package/components/Drawer/Drawer.js +53 -53
  31. package/components/Dropdown/Dropdown.js +66 -66
  32. package/components/Dropdown/DropdownItem.js +13 -13
  33. package/components/Dropdown/DropdownLabel.js +5 -5
  34. package/components/Dropdown/DropdownSeparator.js +5 -5
  35. package/components/Dropzone/Dropzone.js +15 -15
  36. package/components/EmptyState/EmptyState.js +11 -11
  37. package/components/Form/Form.js +17 -17
  38. package/components/Form/FormField.js +21 -21
  39. package/components/Form/FormRow.js +3 -3
  40. package/components/ImageViewer/ImageViewer.js +118 -118
  41. package/components/Kbd/Kbd.js +11 -11
  42. package/components/KeyValueList/KeyValueList.js +32 -32
  43. package/components/Link/Link.js +7 -7
  44. package/components/List/List.js +7 -7
  45. package/components/Loader/Loader.js +39 -39
  46. package/components/Modal/Modal.js +48 -48
  47. package/components/PageHeader/PageHeader.js +18 -18
  48. package/components/Pagination/Pagination.js +23 -23
  49. package/components/Popover/Popover.js +25 -25
  50. package/components/ProgressBar/ProgressBar.js +17 -17
  51. package/components/RelativeTime/RelativeTime.js +10 -10
  52. package/components/SegmentedControl/SegmentedControl.js +38 -38
  53. package/components/Skeleton/Skeleton.js +10 -10
  54. package/components/Spinner/Spinner.js +7 -7
  55. package/components/SplitButton/SplitButton.js +63 -63
  56. package/components/SplitPane/SplitPane.js +50 -50
  57. package/components/StatCard/StatCard.js +32 -32
  58. package/components/StatusDot/StatusDot.js +7 -7
  59. package/components/Table/Table.js +174 -174
  60. package/components/Tabs/Tabs.js +47 -47
  61. package/components/ThemeToggle/ThemeToggle.js +31 -31
  62. package/components/Timeline/GanttTimeline.js +213 -213
  63. package/components/Timeline/HistoryTimeline.js +306 -306
  64. package/components/Timeline/TimelineShared.js +103 -103
  65. package/components/Timeline/TraceEventDetails.js +103 -103
  66. package/components/Timeline/TraceTimeline.js +546 -546
  67. package/components/Timeline/historyLayout.js +2 -2
  68. package/components/Timer/Timer.js +39 -39
  69. package/components/Toast/Toast.js +59 -59
  70. package/components/ToggleIconButton/ToggleIconButton.js +9 -9
  71. package/components/Tooltip/Tooltip.js +16 -16
  72. package/components/Typography/Typography.js +5 -5
  73. package/components/inputs/Checkbox/Checkbox.js +11 -11
  74. package/components/inputs/Checkbox/CheckboxGroup.js +21 -21
  75. package/components/inputs/DatePicker/CalendarPanel.js +113 -113
  76. package/components/inputs/DatePicker/DatePicker.js +39 -39
  77. package/components/inputs/DateTimePicker/DateTimePicker.js +119 -119
  78. package/components/inputs/DateTimePicker/DateTimeSegments.js +40 -40
  79. package/components/inputs/DateTimePicker/TimeField.js +34 -34
  80. package/components/inputs/Input/Input.js +13 -13
  81. package/components/inputs/NumberInput/NumberInput.js +16 -16
  82. package/components/inputs/Radio/Radio.js +17 -17
  83. package/components/inputs/SearchInput/SearchInput.js +25 -25
  84. package/components/inputs/Select/Select.d.ts +55 -3
  85. package/components/inputs/Select/Select.js +485 -344
  86. package/components/inputs/Select/{Select.module.js → Select.module.scss.js} +15 -3
  87. package/components/inputs/Slider/Slider.js +21 -21
  88. package/components/inputs/Switch/Switch.js +4 -4
  89. package/components/inputs/Textarea/Textarea.js +8 -8
  90. package/hooks/usePortalPosition.d.ts +2 -1
  91. package/hooks/usePortalPosition.js +6 -3
  92. package/hooks/useResizable.js +1 -1
  93. package/hooks/useTheme.js +7 -7
  94. package/index.css +1 -1
  95. package/index.js +1 -1
  96. package/index.layered.css +1 -1
  97. package/llms.txt +25 -4
  98. package/manifest.json +33 -4
  99. package/package.json +1 -1
  100. /package/components/Accordion/{Accordion.module.js → Accordion.module.scss.js} +0 -0
  101. /package/components/ActionButton/{ActionButton.module.js → ActionButton.module.scss.js} +0 -0
  102. /package/components/Alert/{Alert.module.js → Alert.module.scss.js} +0 -0
  103. /package/components/Avatar/{Avatar.module.js → Avatar.module.scss.js} +0 -0
  104. /package/components/Badge/{Badge.module.js → Badge.module.scss.js} +0 -0
  105. /package/components/Breadcrumbs/{Breadcrumbs.module.js → Breadcrumbs.module.scss.js} +0 -0
  106. /package/components/Button/{Button.module.js → Button.module.scss.js} +0 -0
  107. /package/components/Card/{Card.module.js → Card.module.scss.js} +0 -0
  108. /package/components/Chart/{Chart.module.js → Chart.module.scss.js} +0 -0
  109. /package/components/Chip/{Chip.module.js → Chip.module.scss.js} +0 -0
  110. /package/components/CodeBlock/{CodeBlock.module.js → CodeBlock.module.scss.js} +0 -0
  111. /package/components/CommandPalette/{CommandPalette.module.js → CommandPalette.module.scss.js} +0 -0
  112. /package/components/ConfirmDialog/{ConfirmDialog.module.js → ConfirmDialog.module.scss.js} +0 -0
  113. /package/components/Divider/{Divider.module.js → Divider.module.scss.js} +0 -0
  114. /package/components/Draggable/{Draggable.module.js → Draggable.module.scss.js} +0 -0
  115. /package/components/Drawer/{Drawer.module.js → Drawer.module.scss.js} +0 -0
  116. /package/components/Dropdown/{Dropdown.module.js → Dropdown.module.scss.js} +0 -0
  117. /package/components/Dropzone/{Dropzone.module.js → Dropzone.module.scss.js} +0 -0
  118. /package/components/EmptyState/{EmptyState.module.js → EmptyState.module.scss.js} +0 -0
  119. /package/components/Form/{Form.module.js → Form.module.scss.js} +0 -0
  120. /package/components/ImageViewer/{ImageViewer.module.js → ImageViewer.module.scss.js} +0 -0
  121. /package/components/Kbd/{Kbd.module.js → Kbd.module.scss.js} +0 -0
  122. /package/components/KeyValueList/{KeyValueList.module.js → KeyValueList.module.scss.js} +0 -0
  123. /package/components/Link/{Link.module.js → Link.module.scss.js} +0 -0
  124. /package/components/List/{List.module.js → List.module.scss.js} +0 -0
  125. /package/components/Loader/{Loader.module.js → Loader.module.scss.js} +0 -0
  126. /package/components/Modal/{Modal.module.js → Modal.module.scss.js} +0 -0
  127. /package/components/PageHeader/{PageHeader.module.js → PageHeader.module.scss.js} +0 -0
  128. /package/components/Pagination/{Pagination.module.js → Pagination.module.scss.js} +0 -0
  129. /package/components/Popover/{Popover.module.js → Popover.module.scss.js} +0 -0
  130. /package/components/ProgressBar/{ProgressBar.module.js → ProgressBar.module.scss.js} +0 -0
  131. /package/components/RelativeTime/{RelativeTime.module.js → RelativeTime.module.scss.js} +0 -0
  132. /package/components/SegmentedControl/{SegmentedControl.module.js → SegmentedControl.module.scss.js} +0 -0
  133. /package/components/Skeleton/{Skeleton.module.js → Skeleton.module.scss.js} +0 -0
  134. /package/components/Spinner/{Spinner.module.js → Spinner.module.scss.js} +0 -0
  135. /package/components/SplitButton/{SplitButton.module.js → SplitButton.module.scss.js} +0 -0
  136. /package/components/SplitPane/{SplitPane.module.js → SplitPane.module.scss.js} +0 -0
  137. /package/components/StatCard/{StatCard.module.js → StatCard.module.scss.js} +0 -0
  138. /package/components/StatusDot/{StatusDot.module.js → StatusDot.module.scss.js} +0 -0
  139. /package/components/Table/{Table.module.js → Table.module.scss.js} +0 -0
  140. /package/components/Tabs/{Tabs.module.js → Tabs.module.scss.js} +0 -0
  141. /package/components/ThemeToggle/{ThemeToggle.module.js → ThemeToggle.module.scss.js} +0 -0
  142. /package/components/Timeline/{GanttTimeline.module.js → GanttTimeline.module.scss.js} +0 -0
  143. /package/components/Timeline/{HistoryTimeline.module.js → HistoryTimeline.module.scss.js} +0 -0
  144. /package/components/Timeline/{Timeline.module.js → Timeline.module.scss.js} +0 -0
  145. /package/components/Timeline/{TraceTimeline.module.js → TraceTimeline.module.scss.js} +0 -0
  146. /package/components/Timer/{Timer.module.js → Timer.module.scss.js} +0 -0
  147. /package/components/Toast/{Toast.module.js → Toast.module.scss.js} +0 -0
  148. /package/components/ToggleIconButton/{ToggleIconButton.module.js → ToggleIconButton.module.scss.js} +0 -0
  149. /package/components/Tooltip/{Tooltip.module.js → Tooltip.module.scss.js} +0 -0
  150. /package/components/Typography/{Typography.module.js → Typography.module.scss.js} +0 -0
  151. /package/components/inputs/Checkbox/{Checkbox.module.js → Checkbox.module.scss.js} +0 -0
  152. /package/components/inputs/Checkbox/{CheckboxGroup.module.js → CheckboxGroup.module.scss.js} +0 -0
  153. /package/components/inputs/DatePicker/{CalendarPanel.module.js → CalendarPanel.module.scss.js} +0 -0
  154. /package/components/inputs/DatePicker/{DatePicker.module.js → DatePicker.module.scss.js} +0 -0
  155. /package/components/inputs/DateTimePicker/{DateTimePicker.module.js → DateTimePicker.module.scss.js} +0 -0
  156. /package/components/inputs/Input/{Input.module.js → Input.module.scss.js} +0 -0
  157. /package/components/inputs/NumberInput/{NumberInput.module.js → NumberInput.module.scss.js} +0 -0
  158. /package/components/inputs/Radio/{Radio.module.js → Radio.module.scss.js} +0 -0
  159. /package/components/inputs/SearchInput/{SearchInput.module.js → SearchInput.module.scss.js} +0 -0
  160. /package/components/inputs/Slider/{Slider.module.js → Slider.module.scss.js} +0 -0
  161. /package/components/inputs/Textarea/{Textarea.module.js → Textarea.module.scss.js} +0 -0
@@ -1,16 +1,16 @@
1
- import e from "./CalendarPanel.module.js";
2
- import { addDays as t, addMonths as n, buildCalendarDays as r, isSameDay as i, isSameMonth as a, startOfMonth as o, toISODate as s, weekdayLabels as c } from "./dateUtils.js";
3
- import { useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
4
- import p from "clsx";
1
+ import { useEffect as e, useMemo as t, useRef as n, useState as r } from "react";
2
+ import i from "clsx";
3
+ import a from "./CalendarPanel.module.scss.js";
4
+ import { addDays as o, addMonths as s, buildCalendarDays as c, isSameDay as l, isSameMonth as u, startOfMonth as d, toISODate as f, weekdayLabels as p } from "./dateUtils.js";
5
5
  import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
6
6
  // src/components/inputs/DatePicker/CalendarPanel.tsx
7
- var _ = 100, v = 3, y = 4;
8
- function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxDay: T, locale: E, weekStartsOn: D, isDisabledDay: O, onSelect: k, onViewDateChange: A, onFocusedDateChange: j, onEscape: M, classes: N }) {
9
- let P = d(null), F = d(null), [I, L] = f("day"), [R, z] = f(0), B = b.getFullYear(), V = b.getMonth(), H = u(() => new Intl.DateTimeFormat(E, {
7
+ var _ = 100, ee = 3, v = 4;
8
+ function y({ viewDate: y, focusedDate: b, selected: x, today: S, minDay: C, maxDay: w, locale: T, weekStartsOn: E, isDisabledDay: D, onSelect: te, onViewDateChange: O, onFocusedDateChange: k, onEscape: A, classes: j }) {
9
+ let M = n(null), N = n(null), [P, F] = r("day"), [I, L] = r(0), R = y.getFullYear(), z = y.getMonth(), B = t(() => new Intl.DateTimeFormat(T, {
10
10
  month: "long",
11
11
  year: "numeric"
12
- }).format(b), [E, b]), U = u(() => new Intl.DateTimeFormat(E, { month: "long" }).format(b), [E, b]), ee = u(() => new Intl.DateTimeFormat(E, { year: "numeric" }).format(b), [E, b]), te = u(() => {
13
- let e = new Intl.DateTimeFormat(E, { month: "short" }), t = new Intl.DateTimeFormat(E, { month: "long" });
12
+ }).format(y), [T, y]), V = t(() => new Intl.DateTimeFormat(T, { month: "long" }).format(y), [T, y]), H = t(() => new Intl.DateTimeFormat(T, { year: "numeric" }).format(y), [T, y]), U = t(() => {
13
+ let e = new Intl.DateTimeFormat(T, { month: "short" }), t = new Intl.DateTimeFormat(T, { month: "long" });
14
14
  return Array.from({ length: 12 }, (n, r) => {
15
15
  let i = new Date(2023, r, 1);
16
16
  return {
@@ -18,89 +18,89 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
18
18
  long: t.format(i)
19
19
  };
20
20
  });
21
- }, [E]), W = u(() => {
22
- let e = w ? w.getFullYear() : B - _, t = T ? T.getFullYear() : B + _;
23
- return e = Math.min(e, B), t = Math.max(t, B), Array.from({ length: t - e + 1 }, (t, n) => e + n);
21
+ }, [T]), W = t(() => {
22
+ let e = C ? C.getFullYear() : R - _, t = w ? w.getFullYear() : R + _;
23
+ return e = Math.min(e, R), t = Math.max(t, R), Array.from({ length: t - e + 1 }, (t, n) => e + n);
24
24
  }, [
25
+ C,
25
26
  w,
26
- T,
27
- B
28
- ]), ne = u(() => c(E, D), [E, D]), re = u(() => r(b, D), [b, D]), ie = u(() => new Intl.DateTimeFormat(E, { dateStyle: "full" }), [E]), G = (e) => {
29
- let t = new Date(B, e, 1), n = new Date(B, e + 1, 0);
30
- return !!T && t > T || !!w && n < w;
31
- }, K = (e) => !!T && new Date(e, 0, 1) > T || !!w && new Date(e, 11, 31) < w;
32
- l(() => {
33
- if (I === "day") {
34
- P.current?.querySelector(`[data-date="${s(x)}"]`)?.focus();
27
+ R
28
+ ]), ne = t(() => p(T, E), [T, E]), re = t(() => c(y, E), [y, E]), ie = t(() => new Intl.DateTimeFormat(T, { dateStyle: "full" }), [T]), G = (e) => {
29
+ let t = new Date(R, e, 1), n = new Date(R, e + 1, 0);
30
+ return !!w && t > w || !!C && n < C;
31
+ }, K = (e) => !!w && new Date(e, 0, 1) > w || !!C && new Date(e, 11, 31) < C;
32
+ e(() => {
33
+ if (P === "day") {
34
+ M.current?.querySelector(`[data-date="${f(b)}"]`)?.focus();
35
35
  return;
36
36
  }
37
- let e = F.current, t = e?.querySelector("[data-active]");
37
+ let e = N.current, t = e?.querySelector("[data-active]");
38
38
  e && t && (e.scrollTop = t.offsetTop - e.clientHeight / 2 + t.offsetHeight / 2, t.focus());
39
39
  }, [
40
- I,
41
- x,
42
- R
40
+ P,
41
+ b,
42
+ I
43
43
  ]);
44
44
  let ae = (e) => {
45
- j(e), a(e, b) || A(o(e));
45
+ k(e), u(e, y) || O(d(e));
46
46
  }, q = (e) => {
47
- O(e) || k(e);
47
+ D(e) || te(e);
48
48
  }, J = (e) => {
49
- I === e ? L("day") : (z(e === "month" ? V : W.indexOf(B)), L(e));
49
+ P === e ? F("day") : (L(e === "month" ? z : W.indexOf(R)), F(e));
50
50
  }, Y = (e, t) => {
51
- let n = new Date(e, t + 1, 0).getDate(), r = new Date(e, t, Math.min(x.getDate(), n));
52
- j(r), A(o(r)), L("day");
51
+ let n = new Date(e, t + 1, 0).getDate(), r = new Date(e, t, Math.min(b.getDate(), n));
52
+ k(r), O(d(r)), F("day");
53
53
  }, oe = (e) => {
54
- let r = null;
54
+ let t = null;
55
55
  switch (e.key) {
56
56
  case "ArrowLeft":
57
- r = t(x, -1);
57
+ t = o(b, -1);
58
58
  break;
59
59
  case "ArrowRight":
60
- r = t(x, 1);
60
+ t = o(b, 1);
61
61
  break;
62
62
  case "ArrowUp":
63
- r = t(x, -7);
63
+ t = o(b, -7);
64
64
  break;
65
65
  case "ArrowDown":
66
- r = t(x, 7);
66
+ t = o(b, 7);
67
67
  break;
68
68
  case "Home":
69
- r = t(x, -((x.getDay() - D + 7) % 7));
69
+ t = o(b, -((b.getDay() - E + 7) % 7));
70
70
  break;
71
71
  case "End":
72
- r = t(x, 6 - (x.getDay() - D + 7) % 7);
72
+ t = o(b, 6 - (b.getDay() - E + 7) % 7);
73
73
  break;
74
74
  case "PageUp":
75
- r = n(x, -1);
75
+ t = s(b, -1);
76
76
  break;
77
77
  case "PageDown":
78
- r = n(x, 1);
78
+ t = s(b, 1);
79
79
  break;
80
80
  case "Enter":
81
81
  case " ":
82
- e.preventDefault(), q(x);
82
+ e.preventDefault(), q(b);
83
83
  return;
84
84
  case "Escape":
85
- e.preventDefault(), M();
85
+ e.preventDefault(), A();
86
86
  return;
87
87
  default: return;
88
88
  }
89
- e.preventDefault(), ae(r);
89
+ e.preventDefault(), ae(t);
90
90
  }, X = (e, t, n) => {
91
- let r = R;
91
+ let r = I;
92
92
  switch (e.key) {
93
93
  case "ArrowLeft":
94
- r = R - 1;
94
+ r = I - 1;
95
95
  break;
96
96
  case "ArrowRight":
97
- r = R + 1;
97
+ r = I + 1;
98
98
  break;
99
99
  case "ArrowUp":
100
- r = R - n;
100
+ r = I - n;
101
101
  break;
102
102
  case "ArrowDown":
103
- r = R + n;
103
+ r = I + n;
104
104
  break;
105
105
  case "Home":
106
106
  r = 0;
@@ -110,22 +110,22 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
110
110
  break;
111
111
  case "Enter":
112
112
  case " ":
113
- e.preventDefault(), I === "month" ? G(R) || Y(B, R) : K(W[R]) || Y(W[R], V);
113
+ e.preventDefault(), P === "month" ? G(I) || Y(R, I) : K(W[I]) || Y(W[I], z);
114
114
  return;
115
115
  case "Escape":
116
- e.preventDefault(), L("day");
116
+ e.preventDefault(), F("day");
117
117
  return;
118
118
  default: return;
119
119
  }
120
- e.preventDefault(), z(Math.max(0, Math.min(t - 1, r)));
121
- }, Z = I === "year", Q = I === "day" ? "month" : "year", $ = (e) => A(I === "day" ? n(b, e) : new Date(B + e, V, 1));
120
+ e.preventDefault(), L(Math.max(0, Math.min(t - 1, r)));
121
+ }, Z = P === "year", Q = P === "day" ? "month" : "year", $ = (e) => O(P === "day" ? s(y, e) : new Date(R + e, z, 1));
122
122
  return /* @__PURE__ */ g(m, { children: [
123
123
  /* @__PURE__ */ g("div", {
124
- className: p(e.header, N?.header),
124
+ className: i(a.header, j?.header),
125
125
  children: [
126
126
  /* @__PURE__ */ h("button", {
127
127
  type: "button",
128
- className: p(e.nav, Z && e.navHidden, N?.nav),
128
+ className: i(a.nav, Z && a.navHidden, j?.nav),
129
129
  onClick: () => $(-1),
130
130
  "aria-label": `Previous ${Q}`,
131
131
  "aria-hidden": Z || void 0,
@@ -142,34 +142,34 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
142
142
  })
143
143
  }),
144
144
  /* @__PURE__ */ g("div", {
145
- className: e.title,
145
+ className: a.title,
146
146
  children: [
147
147
  /* @__PURE__ */ h("button", {
148
148
  type: "button",
149
- className: e.titleButton,
149
+ className: a.titleButton,
150
150
  "aria-label": "Choose month",
151
- "aria-expanded": I === "month",
151
+ "aria-expanded": P === "month",
152
152
  onClick: () => J("month"),
153
- children: U
153
+ children: V
154
154
  }),
155
155
  /* @__PURE__ */ h("button", {
156
156
  type: "button",
157
- className: e.titleButton,
157
+ className: a.titleButton,
158
158
  "aria-label": "Choose year",
159
- "aria-expanded": I === "year",
159
+ "aria-expanded": P === "year",
160
160
  onClick: () => J("year"),
161
- children: ee
161
+ children: H
162
162
  }),
163
163
  /* @__PURE__ */ h("span", {
164
- className: e.srOnly,
164
+ className: a.srOnly,
165
165
  "aria-live": "polite",
166
- children: H
166
+ children: B
167
167
  })
168
168
  ]
169
169
  }),
170
170
  /* @__PURE__ */ h("button", {
171
171
  type: "button",
172
- className: p(e.nav, Z && e.navHidden, N?.nav),
172
+ className: i(a.nav, Z && a.navHidden, j?.nav),
173
173
  onClick: () => $(1),
174
174
  "aria-label": `Next ${Q}`,
175
175
  "aria-hidden": Z || void 0,
@@ -187,78 +187,78 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
187
187
  })
188
188
  ]
189
189
  }),
190
- I === "month" && /* @__PURE__ */ h("div", {
191
- ref: F,
190
+ P === "month" && /* @__PURE__ */ h("div", {
191
+ ref: N,
192
192
  role: "listbox",
193
193
  "aria-label": "Month",
194
- className: p(e.options, e.months),
195
- onKeyDown: (e) => X(e, 12, v),
196
- children: te.map((t, n) => {
197
- let r = G(n), i = n === V;
194
+ className: i(a.options, a.months),
195
+ onKeyDown: (e) => X(e, 12, ee),
196
+ children: U.map((e, t) => {
197
+ let n = G(t), r = t === z;
198
198
  return /* @__PURE__ */ h("button", {
199
199
  type: "button",
200
200
  role: "option",
201
- "aria-selected": i,
202
- "aria-disabled": r || void 0,
203
- "aria-label": t.long,
204
- tabIndex: n === R ? 0 : -1,
205
- "data-active": n === R || void 0,
206
- className: p(e.option, i && e.optionSelected),
207
- onClick: () => !r && Y(B, n),
208
- children: t.short
209
- }, n);
201
+ "aria-selected": r,
202
+ "aria-disabled": n || void 0,
203
+ "aria-label": e.long,
204
+ tabIndex: t === I ? 0 : -1,
205
+ "data-active": t === I || void 0,
206
+ className: i(a.option, r && a.optionSelected),
207
+ onClick: () => !n && Y(R, t),
208
+ children: e.short
209
+ }, t);
210
210
  })
211
211
  }),
212
- I === "year" && /* @__PURE__ */ h("div", {
213
- ref: F,
212
+ P === "year" && /* @__PURE__ */ h("div", {
213
+ ref: N,
214
214
  role: "listbox",
215
215
  "aria-label": "Year",
216
- className: p(e.options, e.years),
217
- onKeyDown: (e) => X(e, W.length, y),
218
- children: W.map((t, n) => {
219
- let r = K(t), i = t === B;
216
+ className: i(a.options, a.years),
217
+ onKeyDown: (e) => X(e, W.length, v),
218
+ children: W.map((e, t) => {
219
+ let n = K(e), r = e === R;
220
220
  return /* @__PURE__ */ h("button", {
221
221
  type: "button",
222
222
  role: "option",
223
- "aria-selected": i,
224
- "aria-disabled": r || void 0,
225
- tabIndex: n === R ? 0 : -1,
226
- "data-active": n === R || void 0,
227
- className: p(e.option, i && e.optionSelected),
228
- onClick: () => !r && Y(t, V),
229
- children: t
230
- }, t);
223
+ "aria-selected": r,
224
+ "aria-disabled": n || void 0,
225
+ tabIndex: t === I ? 0 : -1,
226
+ "data-active": t === I || void 0,
227
+ className: i(a.option, r && a.optionSelected),
228
+ onClick: () => !n && Y(e, z),
229
+ children: e
230
+ }, e);
231
231
  })
232
232
  }),
233
- I === "day" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
234
- className: e.weekdays,
233
+ P === "day" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
234
+ className: a.weekdays,
235
235
  "aria-hidden": "true",
236
- children: ne.map((t, n) => /* @__PURE__ */ h("span", {
237
- className: e.weekday,
238
- children: t
239
- }, n))
236
+ children: ne.map((e, t) => /* @__PURE__ */ h("span", {
237
+ className: a.weekday,
238
+ children: e
239
+ }, t))
240
240
  }), /* @__PURE__ */ h("div", {
241
- ref: P,
241
+ ref: M,
242
242
  role: "grid",
243
- className: p(e.grid, N?.grid),
243
+ className: i(a.grid, j?.grid),
244
244
  onKeyDown: oe,
245
- children: re.map((t) => {
246
- let n = !a(t, b), r = i(t, S), o = i(t, C), c = O(t), l = i(t, x);
245
+ children: re.map((e) => {
246
+ let t = !u(e, y), n = l(e, x), r = l(e, S), o = D(e), s = l(e, b);
247
247
  return /* @__PURE__ */ h("button", {
248
248
  type: "button",
249
249
  role: "gridcell",
250
- "data-date": s(t),
251
- tabIndex: l ? 0 : -1,
252
- className: p(e.day, n && e.dayOutside, o && e.dayToday, r && e.daySelected, n && N?.dayOutside, o && N?.dayToday, r && N?.daySelected, N?.day),
253
- "aria-selected": r,
254
- "aria-disabled": c || void 0,
255
- "aria-current": o ? "date" : void 0,
256
- "aria-label": ie.format(t),
257
- onClick: () => q(t),
258
- children: t.getDate()
259
- }, s(t));
250
+ "data-date": f(e),
251
+ tabIndex: s ? 0 : -1,
252
+ className: i(a.day, t && a.dayOutside, r && a.dayToday, n && a.daySelected, t && j?.dayOutside, r && j?.dayToday, n && j?.daySelected, j?.day),
253
+ "aria-selected": n,
254
+ "aria-disabled": o || void 0,
255
+ "aria-current": r ? "date" : void 0,
256
+ "aria-label": ie.format(e),
257
+ onClick: () => q(e),
258
+ children: e.getDate()
259
+ }, f(e));
260
260
  })
261
261
  })] })
262
262
  ] });
263
263
  }
264
- export { b as CalendarPanel };
264
+ export { y as CalendarPanel };
@@ -1,42 +1,42 @@
1
- import { useClickOutside as e } from "../../../hooks/useClickOutside.js";
2
- import { usePortalPosition as t } from "../../../hooks/usePortalPosition.js";
3
- import n from "./DatePicker.module.js";
4
- import { CalendarPanel as ee } from "./CalendarPanel.js";
5
- import { startOfDay as r, startOfMonth as i } from "./dateUtils.js";
6
- import { forwardRef as a, useCallback as o, useMemo as s, useRef as c, useState as l } from "react";
7
- import u from "clsx";
8
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
9
- import { createPortal as p } from "react-dom";
1
+ import { forwardRef as e, useCallback as t, useMemo as n, useRef as r, useState as i } from "react";
2
+ import { createPortal as a } from "react-dom";
3
+ import o from "clsx";
4
+ import { useClickOutside as s } from "../../../hooks/useClickOutside.js";
5
+ import { usePortalPosition as c } from "../../../hooks/usePortalPosition.js";
6
+ import l from "./DatePicker.module.scss.js";
7
+ import { CalendarPanel as u } from "./CalendarPanel.js";
8
+ import { startOfDay as d, startOfMonth as f } from "./dateUtils.js";
9
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
10
  // src/components/inputs/DatePicker/DatePicker.tsx
11
- var m = a(({ value: a, defaultValue: m, onChange: h, min: g, max: _, disabledDate: v, weekStartsOn: y = 0, locale: b, format: x, placeholder: S = "Select date", inputSize: C = "md", error: w = !1, disabled: T = !1, portal: E = !0, classes: D, className: O, style: k, "aria-label": A }, j) => {
12
- let M = a !== void 0, [N, P] = l(m ?? null), F = M ? a ?? null : N, [I, L] = l(!1), [R, z] = l(() => i(F ?? /* @__PURE__ */ new Date())), [B, V] = l(() => r(F ?? /* @__PURE__ */ new Date())), H = c(null), U = c(null), W = t(H, I && E), G = s(() => r(/* @__PURE__ */ new Date()), []), K = s(() => x ?? ((e) => new Intl.DateTimeFormat(b, {
11
+ var h = e(({ value: e, defaultValue: h, onChange: g, min: _, max: v, disabledDate: y, weekStartsOn: b = 0, locale: x, format: S, placeholder: C = "Select date", inputSize: ee = "md", error: w = !1, disabled: T = !1, portal: E = !0, classes: D, className: O, style: k, "aria-label": A }, j) => {
12
+ let M = e !== void 0, [N, P] = i(h ?? null), F = M ? e ?? null : N, [I, L] = i(!1), [R, z] = i(() => f(F ?? /* @__PURE__ */ new Date())), [B, V] = i(() => d(F ?? /* @__PURE__ */ new Date())), H = r(null), U = r(null), W = c(H, I && E), G = n(() => d(/* @__PURE__ */ new Date()), []), K = n(() => S ?? ((e) => new Intl.DateTimeFormat(x, {
13
13
  year: "numeric",
14
14
  month: "short",
15
15
  day: "numeric"
16
- }).format(e)), [x, b]), q = s(() => g ? r(g) : void 0, [g]), J = s(() => _ ? r(_) : void 0, [_]), Y = o((e) => q && e < q || J && e > J ? !0 : v?.(e) ?? !1, [
16
+ }).format(e)), [S, x]), q = n(() => _ ? d(_) : void 0, [_]), J = n(() => v ? d(v) : void 0, [v]), Y = t((e) => q && e < q || J && e > J ? !0 : y?.(e) ?? !1, [
17
17
  q,
18
18
  J,
19
- v
20
- ]), X = o((e) => {
21
- M || P(e), h?.(e);
22
- }, [M, h]), Z = o(() => {
19
+ y
20
+ ]), X = t((e) => {
21
+ M || P(e), g?.(e);
22
+ }, [M, g]), Z = t(() => {
23
23
  if (T) return;
24
- let e = r(F ?? /* @__PURE__ */ new Date());
25
- z(i(e)), V(e), L(!0);
26
- }, [T, F]), Q = o((e = !0) => {
24
+ let e = d(F ?? /* @__PURE__ */ new Date());
25
+ z(f(e)), V(e), L(!0);
26
+ }, [T, F]), Q = t((e = !0) => {
27
27
  L(!1), e && H.current?.querySelector("input")?.focus();
28
- }, []), te = o((e) => {
28
+ }, []), te = t((e) => {
29
29
  X(e), Q();
30
30
  }, [X, Q]);
31
- e(U, () => L(!1), I);
31
+ s(U, () => L(!1), I);
32
32
  let ne = (e) => {
33
33
  e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), Z()) : e.key === "Escape" && I && (e.preventDefault(), L(!1));
34
- }, $ = /* @__PURE__ */ d("div", {
34
+ }, $ = /* @__PURE__ */ p("div", {
35
35
  ref: U,
36
36
  onKeyDown: (e) => {
37
37
  e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), Q());
38
38
  },
39
- className: u(n.popover, E && n.portalled, D?.popover),
39
+ className: o(l.popover, E && l.portalled, D?.popover),
40
40
  style: E ? {
41
41
  position: "fixed",
42
42
  top: W.top + 4,
@@ -45,15 +45,15 @@ var m = a(({ value: a, defaultValue: m, onChange: h, min: g, max: _, disabledDat
45
45
  role: "dialog",
46
46
  "aria-modal": "false",
47
47
  "aria-label": "Choose date",
48
- children: /* @__PURE__ */ d(ee, {
48
+ children: /* @__PURE__ */ p(u, {
49
49
  viewDate: R,
50
50
  focusedDate: B,
51
51
  selected: F,
52
52
  today: G,
53
53
  minDay: q,
54
54
  maxDay: J,
55
- locale: b,
56
- weekStartsOn: y,
55
+ locale: x,
56
+ weekStartsOn: b,
57
57
  isDisabledDay: Y,
58
58
  onSelect: te,
59
59
  onViewDateChange: z,
@@ -62,18 +62,18 @@ var m = a(({ value: a, defaultValue: m, onChange: h, min: g, max: _, disabledDat
62
62
  classes: D
63
63
  })
64
64
  });
65
- return /* @__PURE__ */ f("div", {
65
+ return /* @__PURE__ */ m("div", {
66
66
  ref: H,
67
- className: u(n.root, n[C], w && n.error, T && n.disabled, D?.root, O),
67
+ className: o(l.root, l[ee], w && l.error, T && l.disabled, D?.root, O),
68
68
  style: k,
69
69
  children: [
70
- /* @__PURE__ */ d("input", {
70
+ /* @__PURE__ */ p("input", {
71
71
  ref: j,
72
72
  type: "text",
73
73
  readOnly: !0,
74
- className: u(n.input, D?.input),
74
+ className: o(l.input, D?.input),
75
75
  value: F ? K(F) : "",
76
- placeholder: S,
76
+ placeholder: C,
77
77
  disabled: T,
78
78
  "aria-label": A,
79
79
  "aria-haspopup": "dialog",
@@ -82,34 +82,34 @@ var m = a(({ value: a, defaultValue: m, onChange: h, min: g, max: _, disabledDat
82
82
  onClick: Z,
83
83
  onKeyDown: ne
84
84
  }),
85
- /* @__PURE__ */ d("button", {
85
+ /* @__PURE__ */ p("button", {
86
86
  type: "button",
87
87
  tabIndex: -1,
88
- className: u(n.icon, D?.icon),
88
+ className: o(l.icon, D?.icon),
89
89
  onClick: Z,
90
90
  disabled: T,
91
91
  "aria-label": "Open calendar",
92
- children: /* @__PURE__ */ f("svg", {
92
+ children: /* @__PURE__ */ m("svg", {
93
93
  viewBox: "0 0 20 20",
94
94
  fill: "none",
95
95
  stroke: "currentColor",
96
96
  strokeWidth: "1.5",
97
97
  "aria-hidden": "true",
98
- children: [/* @__PURE__ */ d("rect", {
98
+ children: [/* @__PURE__ */ p("rect", {
99
99
  x: "3",
100
100
  y: "4",
101
101
  width: "14",
102
102
  height: "13",
103
103
  rx: "2"
104
- }), /* @__PURE__ */ d("path", {
104
+ }), /* @__PURE__ */ p("path", {
105
105
  d: "M3 8h14M7 2v3M13 2v3",
106
106
  strokeLinecap: "round"
107
107
  })]
108
108
  })
109
109
  }),
110
- I && (E ? typeof document < "u" && p($, document.body) : $)
110
+ I && (E ? typeof document < "u" && a($, document.body) : $)
111
111
  ]
112
112
  });
113
113
  });
114
- m.displayName = "DatePicker";
115
- export { m as DatePicker };
114
+ h.displayName = "DatePicker";
115
+ export { h as DatePicker };