@overdoser/react-toolkit 0.20.0 → 0.21.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 (273) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +14 -0
  3. package/components/Accordion/Accordion.js +160 -177
  4. package/components/Accordion/Accordion.module.js +20 -0
  5. package/components/ActionButton/ActionButton.js +155 -209
  6. package/components/ActionButton/ActionButton.module.js +25 -0
  7. package/components/ActionButton/CopyButton.js +52 -64
  8. package/components/Alert/Alert.js +92 -95
  9. package/components/Alert/Alert.module.js +18 -0
  10. package/components/Avatar/Avatar.js +44 -55
  11. package/components/Avatar/Avatar.module.js +23 -0
  12. package/components/Badge/Badge.js +16 -38
  13. package/components/Badge/Badge.module.js +17 -0
  14. package/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  15. package/components/Breadcrumbs/Breadcrumbs.js +52 -48
  16. package/components/Breadcrumbs/Breadcrumbs.module.js +10 -0
  17. package/components/Button/Button.js +35 -57
  18. package/components/Button/Button.module.js +25 -0
  19. package/components/Card/Card.js +94 -131
  20. package/components/Card/Card.module.js +35 -0
  21. package/components/Chart/AreaChart.d.ts +1 -1
  22. package/components/Chart/AreaChart.js +248 -249
  23. package/components/Chart/Axis.d.ts +2 -2
  24. package/components/Chart/Axis.js +34 -43
  25. package/components/Chart/BarChart.d.ts +1 -1
  26. package/components/Chart/BarChart.js +307 -348
  27. package/components/Chart/Chart.module.js +32 -0
  28. package/components/Chart/ChartContainer.js +33 -41
  29. package/components/Chart/ChartLegend.d.ts +1 -1
  30. package/components/Chart/ChartLegend.js +31 -30
  31. package/components/Chart/ChartTooltip.d.ts +1 -1
  32. package/components/Chart/ChartTooltip.js +46 -41
  33. package/components/Chart/LineChart.d.ts +1 -1
  34. package/components/Chart/LineChart.js +220 -232
  35. package/components/Chart/PieChart.d.ts +1 -1
  36. package/components/Chart/PieChart.js +224 -240
  37. package/components/Chart/RadarChart.d.ts +1 -1
  38. package/components/Chart/RadarChart.js +166 -215
  39. package/components/Chart/Sparkline.js +73 -68
  40. package/components/Chart/TradingChart.d.ts +1 -1
  41. package/components/Chart/TradingChart.js +804 -701
  42. package/components/Chart/scales.js +28 -35
  43. package/components/Chart/trading/indicators.js +61 -62
  44. package/components/Chart/trading/period.js +46 -68
  45. package/components/Chart/useChartDimensions.js +30 -22
  46. package/components/Chip/Chip.js +98 -141
  47. package/components/Chip/Chip.module.js +32 -0
  48. package/components/CodeBlock/CodeBlock.js +111 -119
  49. package/components/CodeBlock/CodeBlock.module.js +23 -0
  50. package/components/CommandPalette/CommandPalette.js +387 -392
  51. package/components/CommandPalette/CommandPalette.module.js +28 -0
  52. package/components/ConfirmDialog/ConfirmDialog.d.ts +1 -1
  53. package/components/ConfirmDialog/ConfirmDialog.js +184 -199
  54. package/components/ConfirmDialog/ConfirmDialog.module.js +12 -0
  55. package/components/Divider/Divider.js +25 -36
  56. package/components/Divider/Divider.module.js +17 -0
  57. package/components/Draggable/Draggable.d.ts +1 -1
  58. package/components/Draggable/Draggable.js +157 -164
  59. package/components/Draggable/Draggable.module.js +10 -0
  60. package/components/Drawer/Drawer.js +104 -126
  61. package/components/Drawer/Drawer.module.js +66 -0
  62. package/components/Dropdown/Dropdown.js +175 -234
  63. package/components/Dropdown/Dropdown.module.js +29 -0
  64. package/components/Dropdown/DropdownItem.js +55 -58
  65. package/components/Dropdown/DropdownLabel.js +14 -11
  66. package/components/Dropdown/DropdownSeparator.js +12 -10
  67. package/components/Dropdown/dropdownContext.js +4 -5
  68. package/components/Dropdown/useContextMenu.js +27 -17
  69. package/components/Dropzone/Dropzone.js +99 -105
  70. package/components/Dropzone/Dropzone.module.js +12 -0
  71. package/components/EmptyState/EmptyState.js +58 -55
  72. package/components/EmptyState/EmptyState.module.js +14 -0
  73. package/components/Form/Form.d.ts +1 -1
  74. package/components/Form/Form.js +32 -35
  75. package/components/Form/Form.module.js +16 -0
  76. package/components/Form/FormField.d.ts +1 -1
  77. package/components/Form/FormField.js +71 -75
  78. package/components/Form/FormRow.d.ts +1 -1
  79. package/components/Form/FormRow.js +11 -8
  80. package/components/Form/formFieldDefaults.js +4 -5
  81. package/components/ImageViewer/ImageViewer.js +312 -201
  82. package/components/ImageViewer/ImageViewer.module.js +26 -0
  83. package/components/ImageViewer/useZoomPan.js +206 -137
  84. package/components/Kbd/Kbd.js +25 -22
  85. package/components/Kbd/Kbd.module.js +10 -0
  86. package/components/KeyValueList/KeyValueList.js +119 -123
  87. package/components/KeyValueList/KeyValueList.module.js +23 -0
  88. package/components/Link/Link.js +45 -59
  89. package/components/Link/Link.module.js +10 -0
  90. package/components/List/List.js +22 -46
  91. package/components/List/List.module.js +12 -0
  92. package/components/Loader/Loader.js +152 -182
  93. package/components/Loader/Loader.module.js +40 -0
  94. package/components/Modal/Modal.js +93 -105
  95. package/components/Modal/Modal.module.js +18 -0
  96. package/components/PageHeader/PageHeader.js +78 -72
  97. package/components/PageHeader/PageHeader.module.js +23 -0
  98. package/components/Pagination/Pagination.js +63 -84
  99. package/components/Pagination/Pagination.module.js +13 -0
  100. package/components/Pagination/paginationRange.js +15 -22
  101. package/components/Popover/Popover.js +110 -134
  102. package/components/Popover/Popover.module.js +12 -0
  103. package/components/ProgressBar/ProgressBar.d.ts +15 -1
  104. package/components/ProgressBar/ProgressBar.js +57 -90
  105. package/components/ProgressBar/ProgressBar.module.js +29 -0
  106. package/components/RelativeTime/RelativeTime.js +36 -43
  107. package/components/RelativeTime/RelativeTime.module.js +3 -0
  108. package/components/SegmentedControl/SegmentedControl.js +94 -130
  109. package/components/SegmentedControl/SegmentedControl.module.js +21 -0
  110. package/components/Skeleton/Skeleton.js +36 -50
  111. package/components/Skeleton/Skeleton.module.js +15 -0
  112. package/components/Spinner/Spinner.js +25 -25
  113. package/components/Spinner/Spinner.module.js +12 -0
  114. package/components/SplitButton/SplitButton.js +149 -196
  115. package/components/SplitButton/SplitButton.module.js +31 -0
  116. package/components/SplitPane/SplitPane.js +134 -170
  117. package/components/SplitPane/SplitPane.module.js +14 -0
  118. package/components/StatCard/StatCard.js +132 -125
  119. package/components/StatCard/StatCard.module.js +42 -0
  120. package/components/StatusDot/StatusDot.js +28 -39
  121. package/components/StatusDot/StatusDot.module.js +18 -0
  122. package/components/Table/Table.d.ts +1 -1
  123. package/components/Table/Table.js +381 -451
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/useTableSort.js +51 -42
  126. package/components/Tabs/Tabs.js +109 -161
  127. package/components/Tabs/Tabs.module.js +28 -0
  128. package/components/ThemeToggle/ThemeToggle.js +122 -98
  129. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  130. package/components/Timeline/GanttTimeline.js +357 -318
  131. package/components/Timeline/GanttTimeline.module.js +29 -0
  132. package/components/Timeline/HistoryTimeline.js +486 -450
  133. package/components/Timeline/HistoryTimeline.module.js +31 -0
  134. package/components/Timeline/Timeline.module.js +76 -0
  135. package/components/Timeline/TimelineShared.d.ts +7 -7
  136. package/components/Timeline/TimelineShared.js +288 -279
  137. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  138. package/components/Timeline/TraceEventDetails.js +245 -178
  139. package/components/Timeline/TraceTimeline.js +823 -783
  140. package/components/Timeline/TraceTimeline.module.js +98 -0
  141. package/components/Timeline/historyLayout.js +336 -263
  142. package/components/Timeline/timelineCore.js +208 -183
  143. package/components/Timeline/traceEvent.js +59 -61
  144. package/components/Timeline/traceLayout.js +101 -90
  145. package/components/Timeline/useTimeline.js +76 -79
  146. package/components/Timer/Timer.js +190 -156
  147. package/components/Timer/Timer.module.js +29 -0
  148. package/components/Toast/Toast.d.ts +1 -1
  149. package/components/Toast/Toast.js +128 -128
  150. package/components/Toast/Toast.module.js +37 -0
  151. package/components/Toast/toastStore.js +58 -62
  152. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  153. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  154. package/components/Tooltip/Tooltip.d.ts +1 -1
  155. package/components/Tooltip/Tooltip.js +76 -85
  156. package/components/Tooltip/Tooltip.module.js +17 -0
  157. package/components/Typography/Typography.js +11 -36
  158. package/components/Typography/Typography.module.js +30 -0
  159. package/components/inputs/Checkbox/Checkbox.js +27 -51
  160. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  161. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  162. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  163. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  164. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  165. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  166. package/components/inputs/DatePicker/DatePicker.js +115 -142
  167. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  168. package/components/inputs/DatePicker/dateUtils.js +32 -41
  169. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  170. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  171. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  172. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  173. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  174. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  175. package/components/inputs/Input/Input.js +98 -109
  176. package/components/inputs/Input/Input.module.js +15 -0
  177. package/components/inputs/NumberInput/NumberInput.js +112 -132
  178. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  179. package/components/inputs/Radio/Radio.js +50 -73
  180. package/components/inputs/Radio/Radio.module.js +9 -0
  181. package/components/inputs/SearchInput/SearchInput.js +98 -115
  182. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  183. package/components/inputs/Select/Select.js +555 -682
  184. package/components/inputs/Select/Select.module.js +38 -0
  185. package/components/inputs/Slider/Slider.js +97 -128
  186. package/components/inputs/Slider/Slider.module.js +9 -0
  187. package/components/inputs/Switch/Switch.js +11 -8
  188. package/components/inputs/Textarea/Textarea.js +42 -58
  189. package/components/inputs/Textarea/Textarea.module.js +14 -0
  190. package/hooks/useClickOutside.js +17 -14
  191. package/hooks/useDebouncedValue.js +13 -14
  192. package/hooks/useElementSize.js +27 -22
  193. package/hooks/useEscapeLayer.js +28 -29
  194. package/hooks/useFocusTrap.js +27 -38
  195. package/hooks/useKeyboard.js +76 -64
  196. package/hooks/useMediaQuery.js +10 -15
  197. package/hooks/useNow.js +28 -33
  198. package/hooks/usePersistedState.js +98 -94
  199. package/hooks/usePortalPosition.js +25 -19
  200. package/hooks/useResizable.js +106 -104
  201. package/hooks/useTheme.js +28 -23
  202. package/index.css +2 -1
  203. package/index.js +97 -215
  204. package/index.layered.css +2 -3
  205. package/llms.txt +3 -0
  206. package/manifest.json +8 -0
  207. package/package.json +1 -1
  208. package/utils/formatBytes.js +29 -13
  209. package/utils/themeScript.js +6 -8
  210. package/utils/timeAgo.js +59 -32
  211. package/components/Accordion/Accordion.module.scss.js +0 -36
  212. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  213. package/components/Alert/Alert.module.scss.js +0 -33
  214. package/components/Avatar/Avatar.module.scss.js +0 -43
  215. package/components/Badge/Badge.module.scss.js +0 -31
  216. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  217. package/components/Button/Button.module.scss.js +0 -47
  218. package/components/Card/Card.module.scss.js +0 -60
  219. package/components/Chart/Chart.module.scss.js +0 -61
  220. package/components/Chip/Chip.module.scss.js +0 -59
  221. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  222. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  223. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  224. package/components/Divider/Divider.module.scss.js +0 -31
  225. package/components/Draggable/Draggable.module.scss.js +0 -17
  226. package/components/Drawer/Drawer.module.scss.js +0 -119
  227. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  228. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  229. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  230. package/components/Form/Form.module.scss.js +0 -29
  231. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  232. package/components/Kbd/Kbd.module.scss.js +0 -17
  233. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  234. package/components/Link/Link.module.scss.js +0 -16
  235. package/components/List/List.module.scss.js +0 -21
  236. package/components/Loader/Loader.module.scss.js +0 -70
  237. package/components/Modal/Modal.module.scss.js +0 -33
  238. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  239. package/components/Pagination/Pagination.module.scss.js +0 -23
  240. package/components/Popover/Popover.module.scss.js +0 -21
  241. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  242. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  243. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  244. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  245. package/components/Spinner/Spinner.module.scss.js +0 -20
  246. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  247. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  248. package/components/StatCard/StatCard.module.scss.js +0 -72
  249. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  250. package/components/Table/Table.module.scss.js +0 -81
  251. package/components/Tabs/Tabs.module.scss.js +0 -53
  252. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  253. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  254. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  255. package/components/Timeline/Timeline.module.scss.js +0 -141
  256. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  257. package/components/Timer/Timer.module.scss.js +0 -55
  258. package/components/Toast/Toast.module.scss.js +0 -62
  259. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  260. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  261. package/components/Typography/Typography.module.scss.js +0 -53
  262. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  263. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  264. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  265. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  266. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  267. package/components/inputs/Input/Input.module.scss.js +0 -27
  268. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  269. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  270. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  271. package/components/inputs/Select/Select.module.scss.js +0 -73
  272. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  273. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -1,142 +1,115 @@
1
- import { jsx as n, jsxs as F } from "react/jsx-runtime";
2
- import { forwardRef as ee, useState as m, useRef as j, useMemo as y, useCallback as s } from "react";
3
- import { createPortal as te } from "react-dom";
4
- import D from "clsx";
5
- import { useClickOutside as oe } from "../../../hooks/useClickOutside.js";
6
- import { usePortalPosition as ne } from "../../../hooks/usePortalPosition.js";
7
- import t from "./DatePicker.module.scss.js";
8
- import { CalendarPanel as re } from "./CalendarPanel.js";
9
- import { startOfMonth as V, startOfDay as l } from "./dateUtils.js";
10
- const ae = ee(
11
- ({
12
- value: P,
13
- defaultValue: q,
14
- onChange: b,
15
- min: v,
16
- max: w,
17
- disabledDate: O,
18
- weekStartsOn: A = 0,
19
- locale: h,
20
- format: g,
21
- placeholder: B = "Select date",
22
- inputSize: L = "md",
23
- error: K = !1,
24
- disabled: r = !1,
25
- portal: c = !0,
26
- classes: a,
27
- className: T,
28
- style: W,
29
- "aria-label": z
30
- }, G) => {
31
- const k = P !== void 0, [H, J] = m(q ?? null), o = k ? P ?? null : H, [i, f] = m(!1), [Q, M] = m(() => V(o ?? /* @__PURE__ */ new Date())), [U, N] = m(() => l(o ?? /* @__PURE__ */ new Date())), C = j(null), S = j(null), E = ne(C, i && c), X = y(() => l(/* @__PURE__ */ new Date()), []), Y = y(
32
- () => g ?? ((e) => new Intl.DateTimeFormat(h, { year: "numeric", month: "short", day: "numeric" }).format(e)),
33
- [g, h]
34
- ), u = y(() => v ? l(v) : void 0, [v]), p = y(() => w ? l(w) : void 0, [w]), Z = s(
35
- (e) => u && e < u || p && e > p ? !0 : O?.(e) ?? !1,
36
- [u, p, O]
37
- ), I = s(
38
- (e) => {
39
- k || J(e), b?.(e);
40
- },
41
- [k, b]
42
- ), x = s(() => {
43
- if (r) return;
44
- const e = l(o ?? /* @__PURE__ */ new Date());
45
- M(V(e)), N(e), f(!0);
46
- }, [r, o]), d = s((e = !0) => {
47
- f(!1), e && C.current?.querySelector("input")?.focus();
48
- }, []), _ = s(
49
- (e) => {
50
- I(e), d();
51
- },
52
- [I, d]
53
- );
54
- oe(S, () => f(!1), i);
55
- const $ = (e) => {
56
- e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), x()) : e.key === "Escape" && i && (e.preventDefault(), f(!1));
57
- }, R = (
58
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
59
- /* @__PURE__ */ n(
60
- "div",
61
- {
62
- ref: S,
63
- onKeyDown: (e) => {
64
- e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), d());
65
- },
66
- className: D(t.popover, c && t.portalled, a?.popover),
67
- style: c ? { position: "fixed", top: E.top + 4, left: E.left } : void 0,
68
- role: "dialog",
69
- "aria-modal": "false",
70
- "aria-label": "Choose date",
71
- children: /* @__PURE__ */ n(
72
- re,
73
- {
74
- viewDate: Q,
75
- focusedDate: U,
76
- selected: o,
77
- today: X,
78
- minDay: u,
79
- maxDay: p,
80
- locale: h,
81
- weekStartsOn: A,
82
- isDisabledDay: Z,
83
- onSelect: _,
84
- onViewDateChange: M,
85
- onFocusedDateChange: N,
86
- onEscape: d,
87
- classes: a
88
- }
89
- )
90
- }
91
- )
92
- );
93
- return /* @__PURE__ */ F(
94
- "div",
95
- {
96
- ref: C,
97
- className: D(t.root, t[L], K && t.error, r && t.disabled, a?.root, T),
98
- style: W,
99
- children: [
100
- /* @__PURE__ */ n(
101
- "input",
102
- {
103
- ref: G,
104
- type: "text",
105
- readOnly: !0,
106
- className: D(t.input, a?.input),
107
- value: o ? Y(o) : "",
108
- placeholder: B,
109
- disabled: r,
110
- "aria-label": z,
111
- "aria-haspopup": "dialog",
112
- "aria-expanded": i,
113
- "aria-invalid": K || void 0,
114
- onClick: x,
115
- onKeyDown: $
116
- }
117
- ),
118
- /* @__PURE__ */ n(
119
- "button",
120
- {
121
- type: "button",
122
- tabIndex: -1,
123
- className: D(t.icon, a?.icon),
124
- onClick: x,
125
- disabled: r,
126
- "aria-label": "Open calendar",
127
- children: /* @__PURE__ */ F("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: [
128
- /* @__PURE__ */ n("rect", { x: "3", y: "4", width: "14", height: "13", rx: "2" }),
129
- /* @__PURE__ */ n("path", { d: "M3 8h14M7 2v3M13 2v3", strokeLinecap: "round" })
130
- ] })
131
- }
132
- ),
133
- i && (c ? typeof document < "u" && te(R, document.body) : R)
134
- ]
135
- }
136
- );
137
- }
138
- );
139
- ae.displayName = "DatePicker";
140
- export {
141
- ae as DatePicker
142
- };
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";
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, {
13
+ year: "numeric",
14
+ month: "short",
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, [
17
+ q,
18
+ J,
19
+ v
20
+ ]), X = o((e) => {
21
+ M || P(e), h?.(e);
22
+ }, [M, h]), Z = o(() => {
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) => {
27
+ L(!1), e && H.current?.querySelector("input")?.focus();
28
+ }, []), te = o((e) => {
29
+ X(e), Q();
30
+ }, [X, Q]);
31
+ e(U, () => L(!1), I);
32
+ let ne = (e) => {
33
+ e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), Z()) : e.key === "Escape" && I && (e.preventDefault(), L(!1));
34
+ }, $ = /* @__PURE__ */ d("div", {
35
+ ref: U,
36
+ onKeyDown: (e) => {
37
+ e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), Q());
38
+ },
39
+ className: u(n.popover, E && n.portalled, D?.popover),
40
+ style: E ? {
41
+ position: "fixed",
42
+ top: W.top + 4,
43
+ left: W.left
44
+ } : void 0,
45
+ role: "dialog",
46
+ "aria-modal": "false",
47
+ "aria-label": "Choose date",
48
+ children: /* @__PURE__ */ d(ee, {
49
+ viewDate: R,
50
+ focusedDate: B,
51
+ selected: F,
52
+ today: G,
53
+ minDay: q,
54
+ maxDay: J,
55
+ locale: b,
56
+ weekStartsOn: y,
57
+ isDisabledDay: Y,
58
+ onSelect: te,
59
+ onViewDateChange: z,
60
+ onFocusedDateChange: V,
61
+ onEscape: Q,
62
+ classes: D
63
+ })
64
+ });
65
+ return /* @__PURE__ */ f("div", {
66
+ ref: H,
67
+ className: u(n.root, n[C], w && n.error, T && n.disabled, D?.root, O),
68
+ style: k,
69
+ children: [
70
+ /* @__PURE__ */ d("input", {
71
+ ref: j,
72
+ type: "text",
73
+ readOnly: !0,
74
+ className: u(n.input, D?.input),
75
+ value: F ? K(F) : "",
76
+ placeholder: S,
77
+ disabled: T,
78
+ "aria-label": A,
79
+ "aria-haspopup": "dialog",
80
+ "aria-expanded": I,
81
+ "aria-invalid": w || void 0,
82
+ onClick: Z,
83
+ onKeyDown: ne
84
+ }),
85
+ /* @__PURE__ */ d("button", {
86
+ type: "button",
87
+ tabIndex: -1,
88
+ className: u(n.icon, D?.icon),
89
+ onClick: Z,
90
+ disabled: T,
91
+ "aria-label": "Open calendar",
92
+ children: /* @__PURE__ */ f("svg", {
93
+ viewBox: "0 0 20 20",
94
+ fill: "none",
95
+ stroke: "currentColor",
96
+ strokeWidth: "1.5",
97
+ "aria-hidden": "true",
98
+ children: [/* @__PURE__ */ d("rect", {
99
+ x: "3",
100
+ y: "4",
101
+ width: "14",
102
+ height: "13",
103
+ rx: "2"
104
+ }), /* @__PURE__ */ d("path", {
105
+ d: "M3 8h14M7 2v3M13 2v3",
106
+ strokeLinecap: "round"
107
+ })]
108
+ })
109
+ }),
110
+ I && (E ? typeof document < "u" && p($, document.body) : $)
111
+ ]
112
+ });
113
+ });
114
+ m.displayName = "DatePicker";
115
+ export { m as DatePicker };
@@ -0,0 +1,14 @@
1
+ // src/components/inputs/DatePicker/DatePicker.module.scss
2
+ var e = "crk-root-ZBCoP", t = "crk-sm-7EeFF", n = "crk-input-62G21", r = "crk-md-OVdqx", i = "crk-lg-a9KsJ", a = "crk-icon-jS307", o = "crk-error-c4lUO", s = "crk-disabled-3PiA5", c = "crk-popover-x1-UT", l = "crk-portalled-iPe0Y", u = {
3
+ root: e,
4
+ sm: t,
5
+ input: n,
6
+ md: r,
7
+ lg: i,
8
+ icon: a,
9
+ error: o,
10
+ disabled: s,
11
+ popover: c,
12
+ portalled: l
13
+ };
14
+ export { u as default, s as disabled, o as error, a as icon, n as input, i as lg, r as md, c as popover, l as portalled, e as root, t as sm };
@@ -1,41 +1,32 @@
1
- function f(t) {
2
- return new Date(t.getFullYear(), t.getMonth(), t.getDate());
3
- }
4
- function s(t, e) {
5
- return !t || !e ? !1 : t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate();
6
- }
7
- function i(t, e) {
8
- return t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth();
9
- }
10
- function a(t, e) {
11
- return new Date(t.getFullYear(), t.getMonth(), t.getDate() + e);
12
- }
13
- function D(t, e) {
14
- return new Date(t.getFullYear(), t.getMonth() + e, 1);
15
- }
16
- function l(t) {
17
- return new Date(t.getFullYear(), t.getMonth(), 1);
18
- }
19
- function c(t) {
20
- const e = (n) => String(n).padStart(2, "0");
21
- return `${t.getFullYear()}-${e(t.getMonth() + 1)}-${e(t.getDate())}`;
22
- }
23
- function h(t, e) {
24
- const n = l(t), r = (n.getDay() - e + 7) % 7, o = a(n, -r);
25
- return Array.from({ length: 42 }, (u, g) => a(o, g));
26
- }
27
- function M(t, e) {
28
- const n = new Intl.DateTimeFormat(t, { weekday: "short" }), r = new Date(2023, 0, 1);
29
- return Array.from({ length: 7 }, (o, u) => n.format(a(r, (e + u) % 7)));
30
- }
31
- export {
32
- a as addDays,
33
- D as addMonths,
34
- h as buildCalendarDays,
35
- s as isSameDay,
36
- i as isSameMonth,
37
- f as startOfDay,
38
- l as startOfMonth,
39
- c as toISODate,
40
- M as weekdayLabels
41
- };
1
+ // src/components/inputs/DatePicker/dateUtils.ts
2
+ function e(e) {
3
+ return new Date(e.getFullYear(), e.getMonth(), e.getDate());
4
+ }
5
+ function t(e, t) {
6
+ return !e || !t ? !1 : e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
7
+ }
8
+ function n(e, t) {
9
+ return e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth();
10
+ }
11
+ function r(e, t) {
12
+ return new Date(e.getFullYear(), e.getMonth(), e.getDate() + t);
13
+ }
14
+ function i(e, t) {
15
+ return new Date(e.getFullYear(), e.getMonth() + t, 1);
16
+ }
17
+ function a(e) {
18
+ return new Date(e.getFullYear(), e.getMonth(), 1);
19
+ }
20
+ function o(e) {
21
+ let t = (e) => String(e).padStart(2, "0");
22
+ return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}`;
23
+ }
24
+ function s(e, t) {
25
+ let n = a(e), i = r(n, -((n.getDay() - t + 7) % 7));
26
+ return Array.from({ length: 42 }, (e, t) => r(i, t));
27
+ }
28
+ function c(e, t) {
29
+ let n = new Intl.DateTimeFormat(e, { weekday: "short" }), i = new Date(2023, 0, 1);
30
+ return Array.from({ length: 7 }, (e, a) => n.format(r(i, (t + a) % 7)));
31
+ }
32
+ export { r as addDays, i as addMonths, s as buildCalendarDays, t as isSameDay, n as isSameMonth, e as startOfDay, a as startOfMonth, o as toISODate, c as weekdayLabels };