@overdoser/react-toolkit 0.19.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 (279) hide show
  1. package/AGENTS.md +2 -2
  2. package/CHANGELOG.md +47 -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 +41 -16
  123. package/components/Table/Table.js +383 -442
  124. package/components/Table/Table.module.js +42 -0
  125. package/components/Table/index.d.ts +1 -1
  126. package/components/Table/useTableSort.d.ts +1 -1
  127. package/components/Table/useTableSort.js +51 -42
  128. package/components/Tabs/Tabs.js +109 -161
  129. package/components/Tabs/Tabs.module.js +28 -0
  130. package/components/ThemeToggle/ThemeToggle.d.ts +2 -0
  131. package/components/ThemeToggle/ThemeToggle.js +122 -97
  132. package/components/ThemeToggle/ThemeToggle.module.js +13 -0
  133. package/components/Timeline/GanttTimeline.js +357 -318
  134. package/components/Timeline/GanttTimeline.module.js +29 -0
  135. package/components/Timeline/HistoryTimeline.js +486 -450
  136. package/components/Timeline/HistoryTimeline.module.js +31 -0
  137. package/components/Timeline/Timeline.module.js +76 -0
  138. package/components/Timeline/TimelineShared.d.ts +7 -7
  139. package/components/Timeline/TimelineShared.js +288 -279
  140. package/components/Timeline/TraceEventDetails.d.ts +3 -3
  141. package/components/Timeline/TraceEventDetails.js +245 -178
  142. package/components/Timeline/TraceTimeline.js +823 -783
  143. package/components/Timeline/TraceTimeline.module.js +98 -0
  144. package/components/Timeline/historyLayout.js +336 -263
  145. package/components/Timeline/timelineCore.js +208 -183
  146. package/components/Timeline/traceEvent.js +59 -61
  147. package/components/Timeline/traceLayout.js +101 -90
  148. package/components/Timeline/useTimeline.js +76 -79
  149. package/components/Timer/Timer.js +190 -156
  150. package/components/Timer/Timer.module.js +29 -0
  151. package/components/Toast/Toast.d.ts +1 -1
  152. package/components/Toast/Toast.js +128 -128
  153. package/components/Toast/Toast.module.js +37 -0
  154. package/components/Toast/toastStore.js +58 -62
  155. package/components/ToggleIconButton/ToggleIconButton.js +35 -57
  156. package/components/ToggleIconButton/ToggleIconButton.module.js +15 -0
  157. package/components/Tooltip/Tooltip.d.ts +1 -1
  158. package/components/Tooltip/Tooltip.js +76 -85
  159. package/components/Tooltip/Tooltip.module.js +17 -0
  160. package/components/Typography/Typography.js +11 -36
  161. package/components/Typography/Typography.module.js +30 -0
  162. package/components/inputs/Checkbox/Checkbox.js +27 -51
  163. package/components/inputs/Checkbox/Checkbox.module.js +10 -0
  164. package/components/inputs/Checkbox/CheckboxGroup.js +53 -111
  165. package/components/inputs/Checkbox/CheckboxGroup.module.js +17 -0
  166. package/components/inputs/DatePicker/CalendarPanel.d.ts +1 -1
  167. package/components/inputs/DatePicker/CalendarPanel.js +263 -286
  168. package/components/inputs/DatePicker/CalendarPanel.module.js +23 -0
  169. package/components/inputs/DatePicker/DatePicker.js +115 -142
  170. package/components/inputs/DatePicker/DatePicker.module.js +14 -0
  171. package/components/inputs/DatePicker/dateUtils.js +32 -41
  172. package/components/inputs/DateTimePicker/DateTimePicker.js +226 -232
  173. package/components/inputs/DateTimePicker/DateTimePicker.module.js +20 -0
  174. package/components/inputs/DateTimePicker/DateTimeSegments.js +273 -252
  175. package/components/inputs/DateTimePicker/TimeField.d.ts +1 -1
  176. package/components/inputs/DateTimePicker/TimeField.js +131 -132
  177. package/components/inputs/DateTimePicker/timeZoneUtils.js +95 -92
  178. package/components/inputs/Input/Input.js +98 -109
  179. package/components/inputs/Input/Input.module.js +15 -0
  180. package/components/inputs/NumberInput/NumberInput.js +112 -132
  181. package/components/inputs/NumberInput/NumberInput.module.js +14 -0
  182. package/components/inputs/Radio/Radio.js +50 -73
  183. package/components/inputs/Radio/Radio.module.js +9 -0
  184. package/components/inputs/SearchInput/SearchInput.js +98 -115
  185. package/components/inputs/SearchInput/SearchInput.module.js +8 -0
  186. package/components/inputs/Select/Select.js +555 -682
  187. package/components/inputs/Select/Select.module.js +38 -0
  188. package/components/inputs/Slider/Slider.js +97 -128
  189. package/components/inputs/Slider/Slider.module.js +9 -0
  190. package/components/inputs/Switch/Switch.js +11 -8
  191. package/components/inputs/Textarea/Textarea.js +42 -58
  192. package/components/inputs/Textarea/Textarea.module.js +14 -0
  193. package/hooks/useClickOutside.js +17 -14
  194. package/hooks/useDebouncedValue.js +13 -14
  195. package/hooks/useElementSize.js +27 -22
  196. package/hooks/useEscapeLayer.js +28 -29
  197. package/hooks/useFocusTrap.js +27 -38
  198. package/hooks/useKeyboard.js +76 -64
  199. package/hooks/useMediaQuery.js +10 -15
  200. package/hooks/useNow.js +28 -33
  201. package/hooks/usePersistedState.js +98 -91
  202. package/hooks/usePortalPosition.js +25 -19
  203. package/hooks/useResizable.js +106 -104
  204. package/hooks/useTheme.d.ts +2 -2
  205. package/hooks/useTheme.js +28 -25
  206. package/index.css +2 -1
  207. package/index.d.ts +1 -1
  208. package/index.js +97 -215
  209. package/index.layered.css +2 -3
  210. package/llms.txt +9 -6
  211. package/manifest.json +66 -10
  212. package/package.json +1 -1
  213. package/utils/formatBytes.js +29 -13
  214. package/utils/themeScript.d.ts +2 -0
  215. package/utils/themeScript.js +6 -8
  216. package/utils/timeAgo.js +59 -32
  217. package/components/Accordion/Accordion.module.scss.js +0 -36
  218. package/components/ActionButton/ActionButton.module.scss.js +0 -47
  219. package/components/Alert/Alert.module.scss.js +0 -33
  220. package/components/Avatar/Avatar.module.scss.js +0 -43
  221. package/components/Badge/Badge.module.scss.js +0 -31
  222. package/components/Breadcrumbs/Breadcrumbs.module.scss.js +0 -17
  223. package/components/Button/Button.module.scss.js +0 -47
  224. package/components/Card/Card.module.scss.js +0 -60
  225. package/components/Chart/Chart.module.scss.js +0 -61
  226. package/components/Chip/Chip.module.scss.js +0 -59
  227. package/components/CodeBlock/CodeBlock.module.scss.js +0 -43
  228. package/components/CommandPalette/CommandPalette.module.scss.js +0 -49
  229. package/components/ConfirmDialog/ConfirmDialog.module.scss.js +0 -21
  230. package/components/Divider/Divider.module.scss.js +0 -31
  231. package/components/Draggable/Draggable.module.scss.js +0 -17
  232. package/components/Drawer/Drawer.module.scss.js +0 -119
  233. package/components/Dropdown/Dropdown.module.scss.js +0 -53
  234. package/components/Dropzone/Dropzone.module.scss.js +0 -21
  235. package/components/EmptyState/EmptyState.module.scss.js +0 -25
  236. package/components/Form/Form.module.scss.js +0 -29
  237. package/components/ImageViewer/ImageViewer.module.scss.js +0 -47
  238. package/components/Kbd/Kbd.module.scss.js +0 -17
  239. package/components/KeyValueList/KeyValueList.module.scss.js +0 -43
  240. package/components/Link/Link.module.scss.js +0 -16
  241. package/components/List/List.module.scss.js +0 -21
  242. package/components/Loader/Loader.module.scss.js +0 -70
  243. package/components/Modal/Modal.module.scss.js +0 -33
  244. package/components/PageHeader/PageHeader.module.scss.js +0 -43
  245. package/components/Pagination/Pagination.module.scss.js +0 -23
  246. package/components/Popover/Popover.module.scss.js +0 -21
  247. package/components/ProgressBar/ProgressBar.module.scss.js +0 -51
  248. package/components/RelativeTime/RelativeTime.module.scss.js +0 -7
  249. package/components/SegmentedControl/SegmentedControl.module.scss.js +0 -39
  250. package/components/Skeleton/Skeleton.module.scss.js +0 -25
  251. package/components/Spinner/Spinner.module.scss.js +0 -20
  252. package/components/SplitButton/SplitButton.module.scss.js +0 -57
  253. package/components/SplitPane/SplitPane.module.scss.js +0 -25
  254. package/components/StatCard/StatCard.module.scss.js +0 -72
  255. package/components/StatusDot/StatusDot.module.scss.js +0 -32
  256. package/components/Table/Table.module.scss.js +0 -81
  257. package/components/Tabs/Tabs.module.scss.js +0 -53
  258. package/components/ThemeToggle/ThemeToggle.module.scss.js +0 -23
  259. package/components/Timeline/GanttTimeline.module.scss.js +0 -55
  260. package/components/Timeline/HistoryTimeline.module.scss.js +0 -59
  261. package/components/Timeline/Timeline.module.scss.js +0 -141
  262. package/components/Timeline/TraceTimeline.module.scss.js +0 -189
  263. package/components/Timer/Timer.module.scss.js +0 -55
  264. package/components/Toast/Toast.module.scss.js +0 -62
  265. package/components/ToggleIconButton/ToggleIconButton.module.scss.js +0 -27
  266. package/components/Tooltip/Tooltip.module.scss.js +0 -30
  267. package/components/Typography/Typography.module.scss.js +0 -53
  268. package/components/inputs/Checkbox/Checkbox.module.scss.js +0 -17
  269. package/components/inputs/Checkbox/CheckboxGroup.module.scss.js +0 -31
  270. package/components/inputs/DatePicker/CalendarPanel.module.scss.js +0 -41
  271. package/components/inputs/DatePicker/DatePicker.module.scss.js +0 -25
  272. package/components/inputs/DateTimePicker/DateTimePicker.module.scss.js +0 -37
  273. package/components/inputs/Input/Input.module.scss.js +0 -27
  274. package/components/inputs/NumberInput/NumberInput.module.scss.js +0 -25
  275. package/components/inputs/Radio/Radio.module.scss.js +0 -15
  276. package/components/inputs/SearchInput/SearchInput.module.scss.js +0 -13
  277. package/components/inputs/Select/Select.module.scss.js +0 -73
  278. package/components/inputs/Slider/Slider.module.scss.js +0 -15
  279. package/components/inputs/Textarea/Textarea.module.scss.js +0 -25
@@ -1,232 +1,226 @@
1
- import { jsxs as w, jsx as o } from "react/jsx-runtime";
2
- import { forwardRef as Pe, useState as E, useMemo as a, useCallback as r, useRef as H } from "react";
3
- import { createPortal as Me } from "react-dom";
4
- import l from "clsx";
5
- import { useClickOutside as Ze } from "../../../hooks/useClickOutside.js";
6
- import { usePortalPosition as xe } from "../../../hooks/usePortalPosition.js";
7
- import { CalendarPanel as Ee } from "../DatePicker/CalendarPanel.js";
8
- import { startOfMonth as ie } from "../DatePicker/dateUtils.js";
9
- import p from "../DatePicker/DatePicker.module.scss.js";
10
- import d from "./DateTimePicker.module.scss.js";
11
- import { TimeField as Oe } from "./TimeField.js";
12
- import { DateTimeSegments as Re } from "./DateTimeSegments.js";
13
- import { isValidTimeZone as Ue, localeHourCycle as ze, getWallClock as O, wallClockDay as b, timeZoneName as We, localTimeZone as Ie, fromWallClock as Ke } from "./timeZoneUtils.js";
14
- import { Button as Se } from "../../Button/Button.js";
15
- const Ve = { hour: 0, minute: 0, second: 0 }, Le = Pe(
16
- ({
17
- value: A,
18
- defaultValue: ae,
19
- onChange: B,
20
- min: c,
21
- max: s,
22
- disabledDate: Y,
23
- weekStartsOn: le = 0,
24
- locale: y,
25
- timeZone: ce,
26
- showTimeZone: _ = !0,
27
- timeZoneStyle: $ = "longOffset",
28
- fieldFormat: R = "iso",
29
- hourCycle: G,
30
- minuteStep: se = 5,
31
- showSeconds: J = !0,
32
- format: U,
33
- placeholder: ue = "Select date and time",
34
- doneLabel: fe = "Done",
35
- inputSize: me = "md",
36
- error: z = !1,
37
- disabled: u = !1,
38
- portal: N = !0,
39
- classes: n,
40
- className: pe,
41
- style: de,
42
- "aria-label": Q,
43
- "aria-describedby": X
44
- }, P) => {
45
- const W = A !== void 0, [ye, he] = E(ae ?? null), i = W ? A ?? null : ye, k = ce ?? "UTC", t = a(() => {
46
- if (k !== "system")
47
- return Ue(k) ? k : (console.warn(`[DateTimePicker] Unknown time zone "${k}" — falling back to UTC.`), "UTC");
48
- }, [k]), ee = a(
49
- () => G ?? (R === "locale" ? ze(y) : 24),
50
- [G, R, y]
51
- ), f = a(() => i ? O(i, t) : null, [i, t]), m = a(() => f ? b(f) : null, [f]), I = f ? { hour: f.hour, minute: f.minute, second: f.second } : Ve, h = r(() => b(O(/* @__PURE__ */ new Date(), t)), [t]), ve = a(() => h(), [h]), [v, C] = E(!1), [De, te] = E(() => ie(m ?? h())), [K, S] = E(() => m ?? h()), V = H(null), L = H(null), oe = H(null), ne = xe(V, v && N), g = a(() => _ ? t === "UTC" || t === "Etc/UTC" ? "UTC" : We(i ?? /* @__PURE__ */ new Date(), t, y, $) : null, [_, i, t, y, $]), j = t ?? Ie(), M = a(() => c ? b(O(c, t)) : void 0, [c, t]), Z = a(() => s ? b(O(s, t)) : void 0, [s, t]), ke = r(
52
- (e) => M && e < M || Z && e > Z ? !0 : Y?.(e) ?? !1,
53
- [M, Z, Y]
54
- ), q = r(
55
- (e) => {
56
- W || he(e), B?.(e);
57
- },
58
- [W, B]
59
- ), D = r(
60
- (e, Ne) => {
61
- let T = Ke(
62
- { year: e.getFullYear(), month: e.getMonth(), day: e.getDate(), ...Ne },
63
- t
64
- );
65
- c && T < c && (T = new Date(c.getTime())), s && T > s && (T = new Date(s.getTime())), q(T);
66
- },
67
- [t, c, s, q]
68
- ), x = r(() => {
69
- if (u) return;
70
- const e = m ?? h();
71
- te(ie(e)), S(e), C(!0);
72
- }, [u, m, h]), F = r((e = !0) => {
73
- C(!1), e && (L.current ? L.current.focus() : V.current?.querySelector("input")?.focus());
74
- }, []), Ce = r(
75
- (e) => {
76
- S(e), D(e, I);
77
- },
78
- [D, I]
79
- ), ge = r(
80
- (e) => D(m ?? K, e),
81
- [D, m, K]
82
- ), Te = r(
83
- (e) => D(b(e), { hour: e.hour, minute: e.minute, second: e.second }),
84
- [D]
85
- );
86
- Ze(oe, () => C(!1), v);
87
- const we = (e) => {
88
- e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), x()) : e.key === "Escape" && v && (e.preventDefault(), C(!1));
89
- }, be = (e) => {
90
- e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), F());
91
- }, re = (
92
- // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
93
- /* @__PURE__ */ w(
94
- "div",
95
- {
96
- ref: oe,
97
- className: l(d.popover, N && d.portalled, n?.popover),
98
- style: N ? { position: "fixed", top: ne.top + 4, left: ne.left } : void 0,
99
- role: "dialog",
100
- "aria-modal": "false",
101
- "aria-label": "Choose date and time",
102
- onKeyDown: be,
103
- children: [
104
- /* @__PURE__ */ w("div", { className: d.body, children: [
105
- /* @__PURE__ */ o("div", { className: d.calendar, children: /* @__PURE__ */ o(
106
- Ee,
107
- {
108
- viewDate: De,
109
- focusedDate: K,
110
- selected: m,
111
- today: ve,
112
- minDay: M,
113
- maxDay: Z,
114
- locale: y,
115
- weekStartsOn: le,
116
- isDisabledDay: ke,
117
- onSelect: Ce,
118
- onViewDateChange: te,
119
- onFocusedDateChange: S,
120
- onEscape: F,
121
- classes: n
122
- }
123
- ) }),
124
- /* @__PURE__ */ o(
125
- Oe,
126
- {
127
- ...I,
128
- onChange: ge,
129
- hourCycle: ee,
130
- showSeconds: J,
131
- minuteStep: se,
132
- disabled: u,
133
- classes: n
134
- }
135
- )
136
- ] }),
137
- /* @__PURE__ */ w("div", { className: l(d.footer, n?.footer), children: [
138
- g && /* @__PURE__ */ o("span", { className: l(d.zone, n?.timeZone), title: j, children: g }),
139
- /* @__PURE__ */ o(Se, { type: "button", size: "sm", onClick: () => F(), children: fe })
140
- ] })
141
- ]
142
- }
143
- )
144
- );
145
- return /* @__PURE__ */ w(
146
- "div",
147
- {
148
- ref: (e) => {
149
- V.current = e, typeof P == "function" ? P(e) : P && (P.current = e);
150
- },
151
- className: l(
152
- p.root,
153
- p[me],
154
- z && p.error,
155
- u && p.disabled,
156
- n?.root,
157
- pe
158
- ),
159
- style: de,
160
- children: [
161
- U ? /* @__PURE__ */ o(
162
- "input",
163
- {
164
- type: "text",
165
- readOnly: !0,
166
- className: l(p.input, n?.input),
167
- value: i ? U(i) : "",
168
- placeholder: ue,
169
- disabled: u,
170
- "aria-label": Q,
171
- "aria-describedby": X,
172
- "aria-haspopup": "dialog",
173
- "aria-expanded": v,
174
- "aria-invalid": z || void 0,
175
- onClick: x,
176
- onKeyDown: we
177
- }
178
- ) : /* @__PURE__ */ o(
179
- Re,
180
- {
181
- ref: L,
182
- value: i,
183
- timeZone: t,
184
- locale: y,
185
- layout: R,
186
- hourCycle: ee,
187
- showSeconds: J,
188
- onChange: Te,
189
- onClear: () => q(null),
190
- onOpenRequest: x,
191
- onEscape: (e) => {
192
- v && (e.preventDefault(), C(!1));
193
- },
194
- suffix: g,
195
- suffixTitle: j,
196
- suffixClassName: n?.timeZone,
197
- disabled: u,
198
- className: l(p.input, n?.input),
199
- classes: { segment: n?.segment },
200
- "aria-label": Q,
201
- "aria-describedby": X,
202
- "aria-invalid": z
203
- }
204
- ),
205
- U && g && /* @__PURE__ */ o("span", { className: l(d.timeZone, n?.timeZone), title: j, children: g }),
206
- /* @__PURE__ */ o(
207
- "button",
208
- {
209
- type: "button",
210
- tabIndex: -1,
211
- className: l(p.icon, n?.icon),
212
- onClick: x,
213
- disabled: u,
214
- "aria-label": "Open date and time picker",
215
- children: /* @__PURE__ */ w("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: [
216
- /* @__PURE__ */ o("path", { d: "M3 8h14M7 2v3M13 2v3", strokeLinecap: "round" }),
217
- /* @__PURE__ */ o("path", { d: "M17 10V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h4", strokeLinecap: "round" }),
218
- /* @__PURE__ */ o("circle", { cx: "14.5", cy: "14.5", r: "3.5" }),
219
- /* @__PURE__ */ o("path", { d: "M14.5 12.75v1.75l1.25 1", strokeLinecap: "round" })
220
- ] })
221
- }
222
- ),
223
- v && (N ? typeof document < "u" && Me(re, document.body) : re)
224
- ]
225
- }
226
- );
227
- }
228
- );
229
- Le.displayName = "DateTimePicker";
230
- export {
231
- Le as DateTimePicker
232
- };
1
+ import { useClickOutside as e } from "../../../hooks/useClickOutside.js";
2
+ import { usePortalPosition as ee } from "../../../hooks/usePortalPosition.js";
3
+ import { Button as t } from "../../Button/Button.js";
4
+ import { CalendarPanel as te } from "../DatePicker/CalendarPanel.js";
5
+ import { startOfMonth as n } from "../DatePicker/dateUtils.js";
6
+ import r from "../DatePicker/DatePicker.module.js";
7
+ import i from "./DateTimePicker.module.js";
8
+ import { TimeField as ne } from "./TimeField.js";
9
+ import { DateTimeSegments as re } from "./DateTimeSegments.js";
10
+ import { fromWallClock as ie, getWallClock as a, isValidTimeZone as ae, localTimeZone as oe, localeHourCycle as se, timeZoneName as ce, wallClockDay as o } from "./timeZoneUtils.js";
11
+ import { forwardRef as s, useCallback as c, useMemo as l, useRef as u, useState as d } from "react";
12
+ import f from "clsx";
13
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
14
+ import { createPortal as le } from "react-dom";
15
+ // src/components/inputs/DateTimePicker/DateTimePicker.tsx
16
+ var ue = {
17
+ hour: 0,
18
+ minute: 0,
19
+ second: 0
20
+ }, h = s(({ value: s, defaultValue: h, onChange: g, min: _, max: v, disabledDate: y, weekStartsOn: de = 0, locale: b, timeZone: fe, showTimeZone: pe = !0, timeZoneStyle: me = "longOffset", fieldFormat: x = "iso", hourCycle: he, minuteStep: ge = 5, showSeconds: _e = !0, format: S, placeholder: ve = "Select date and time", doneLabel: ye = "Done", inputSize: be = "md", error: C = !1, disabled: w = !1, portal: T = !0, classes: E, className: xe, style: Se, "aria-label": D, "aria-describedby": O }, k) => {
21
+ let A = s !== void 0, [Ce, we] = d(h ?? null), j = A ? s ?? null : Ce, M = fe ?? "UTC", N = l(() => {
22
+ if (M !== "system") return ae(M) ? M : (console.warn(`[DateTimePicker] Unknown time zone "${M}" — falling back to UTC.`), "UTC");
23
+ }, [M]), P = l(() => he ?? (x === "locale" ? se(b) : 24), [
24
+ he,
25
+ x,
26
+ b
27
+ ]), F = l(() => j ? a(j, N) : null, [j, N]), I = l(() => F ? o(F) : null, [F]), L = F ? {
28
+ hour: F.hour,
29
+ minute: F.minute,
30
+ second: F.second
31
+ } : ue, R = c(() => o(a(/* @__PURE__ */ new Date(), N)), [N]), Te = l(() => R(), [R]), [z, B] = d(!1), [Ee, De] = d(() => n(I ?? R())), [V, H] = d(() => I ?? R()), U = u(null), W = u(null), Oe = u(null), ke = ee(U, z && T), G = l(() => pe ? N === "UTC" || N === "Etc/UTC" ? "UTC" : ce(j ?? /* @__PURE__ */ new Date(), N, b, me) : null, [
32
+ pe,
33
+ j,
34
+ N,
35
+ b,
36
+ me
37
+ ]), K = N ?? oe(), q = l(() => _ ? o(a(_, N)) : void 0, [_, N]), J = l(() => v ? o(a(v, N)) : void 0, [v, N]), Ae = c((e) => q && e < q || J && e > J ? !0 : y?.(e) ?? !1, [
38
+ q,
39
+ J,
40
+ y
41
+ ]), Y = c((e) => {
42
+ A || we(e), g?.(e);
43
+ }, [A, g]), X = c((e, ee) => {
44
+ let t = ie({
45
+ year: e.getFullYear(),
46
+ month: e.getMonth(),
47
+ day: e.getDate(),
48
+ ...ee
49
+ }, N);
50
+ _ && t < _ && (t = new Date(_.getTime())), v && t > v && (t = new Date(v.getTime())), Y(t);
51
+ }, [
52
+ N,
53
+ _,
54
+ v,
55
+ Y
56
+ ]), Z = c(() => {
57
+ if (w) return;
58
+ let e = I ?? R();
59
+ De(n(e)), H(e), B(!0);
60
+ }, [
61
+ w,
62
+ I,
63
+ R
64
+ ]), Q = c((e = !0) => {
65
+ B(!1), e && (W.current ? W.current.focus() : U.current?.querySelector("input")?.focus());
66
+ }, []), je = c((e) => {
67
+ H(e), X(e, L);
68
+ }, [X, L]), Me = c((e) => X(I ?? V, e), [
69
+ X,
70
+ I,
71
+ V
72
+ ]), Ne = c((e) => X(o(e), {
73
+ hour: e.hour,
74
+ minute: e.minute,
75
+ second: e.second
76
+ }), [X]);
77
+ e(Oe, () => B(!1), z);
78
+ let Pe = (e) => {
79
+ e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), Z()) : e.key === "Escape" && z && (e.preventDefault(), B(!1));
80
+ }, $ = /* @__PURE__ */ m("div", {
81
+ ref: Oe,
82
+ className: f(i.popover, T && i.portalled, E?.popover),
83
+ style: T ? {
84
+ position: "fixed",
85
+ top: ke.top + 4,
86
+ left: ke.left
87
+ } : void 0,
88
+ role: "dialog",
89
+ "aria-modal": "false",
90
+ "aria-label": "Choose date and time",
91
+ onKeyDown: (e) => {
92
+ e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), Q());
93
+ },
94
+ children: [/* @__PURE__ */ m("div", {
95
+ className: i.body,
96
+ children: [/* @__PURE__ */ p("div", {
97
+ className: i.calendar,
98
+ children: /* @__PURE__ */ p(te, {
99
+ viewDate: Ee,
100
+ focusedDate: V,
101
+ selected: I,
102
+ today: Te,
103
+ minDay: q,
104
+ maxDay: J,
105
+ locale: b,
106
+ weekStartsOn: de,
107
+ isDisabledDay: Ae,
108
+ onSelect: je,
109
+ onViewDateChange: De,
110
+ onFocusedDateChange: H,
111
+ onEscape: Q,
112
+ classes: E
113
+ })
114
+ }), /* @__PURE__ */ p(ne, {
115
+ ...L,
116
+ onChange: Me,
117
+ hourCycle: P,
118
+ showSeconds: _e,
119
+ minuteStep: ge,
120
+ disabled: w,
121
+ classes: E
122
+ })]
123
+ }), /* @__PURE__ */ m("div", {
124
+ className: f(i.footer, E?.footer),
125
+ children: [G && /* @__PURE__ */ p("span", {
126
+ className: f(i.zone, E?.timeZone),
127
+ title: K,
128
+ children: G
129
+ }), /* @__PURE__ */ p(t, {
130
+ type: "button",
131
+ size: "sm",
132
+ onClick: () => Q(),
133
+ children: ye
134
+ })]
135
+ })]
136
+ });
137
+ return /* @__PURE__ */ m("div", {
138
+ ref: (e) => {
139
+ U.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
140
+ },
141
+ className: f(r.root, r[be], C && r.error, w && r.disabled, E?.root, xe),
142
+ style: Se,
143
+ children: [
144
+ S ? /* @__PURE__ */ p("input", {
145
+ type: "text",
146
+ readOnly: !0,
147
+ className: f(r.input, E?.input),
148
+ value: j ? S(j) : "",
149
+ placeholder: ve,
150
+ disabled: w,
151
+ "aria-label": D,
152
+ "aria-describedby": O,
153
+ "aria-haspopup": "dialog",
154
+ "aria-expanded": z,
155
+ "aria-invalid": C || void 0,
156
+ onClick: Z,
157
+ onKeyDown: Pe
158
+ }) : /* @__PURE__ */ p(re, {
159
+ ref: W,
160
+ value: j,
161
+ timeZone: N,
162
+ locale: b,
163
+ layout: x,
164
+ hourCycle: P,
165
+ showSeconds: _e,
166
+ onChange: Ne,
167
+ onClear: () => Y(null),
168
+ onOpenRequest: Z,
169
+ onEscape: (e) => {
170
+ z && (e.preventDefault(), B(!1));
171
+ },
172
+ suffix: G,
173
+ suffixTitle: K,
174
+ suffixClassName: E?.timeZone,
175
+ disabled: w,
176
+ className: f(r.input, E?.input),
177
+ classes: { segment: E?.segment },
178
+ "aria-label": D,
179
+ "aria-describedby": O,
180
+ "aria-invalid": C
181
+ }),
182
+ S && G && /* @__PURE__ */ p("span", {
183
+ className: f(i.timeZone, E?.timeZone),
184
+ title: K,
185
+ children: G
186
+ }),
187
+ /* @__PURE__ */ p("button", {
188
+ type: "button",
189
+ tabIndex: -1,
190
+ className: f(r.icon, E?.icon),
191
+ onClick: Z,
192
+ disabled: w,
193
+ "aria-label": "Open date and time picker",
194
+ children: /* @__PURE__ */ m("svg", {
195
+ viewBox: "0 0 20 20",
196
+ fill: "none",
197
+ stroke: "currentColor",
198
+ strokeWidth: "1.5",
199
+ "aria-hidden": "true",
200
+ children: [
201
+ /* @__PURE__ */ p("path", {
202
+ d: "M3 8h14M7 2v3M13 2v3",
203
+ strokeLinecap: "round"
204
+ }),
205
+ /* @__PURE__ */ p("path", {
206
+ d: "M17 10V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h4",
207
+ strokeLinecap: "round"
208
+ }),
209
+ /* @__PURE__ */ p("circle", {
210
+ cx: "14.5",
211
+ cy: "14.5",
212
+ r: "3.5"
213
+ }),
214
+ /* @__PURE__ */ p("path", {
215
+ d: "M14.5 12.75v1.75l1.25 1",
216
+ strokeLinecap: "round"
217
+ })
218
+ ]
219
+ })
220
+ }),
221
+ z && (T ? typeof document < "u" && le($, document.body) : $)
222
+ ]
223
+ });
224
+ });
225
+ h.displayName = "DateTimePicker";
226
+ export { h as DateTimePicker };
@@ -0,0 +1,20 @@
1
+ // src/components/inputs/DateTimePicker/DateTimePicker.module.scss
2
+ var e = "crk-popover-RmMhf", t = "crk-portalled-Yh6Wl", n = "crk-segments-BIpWS", r = "crk-segment-ETxcK", i = "crk-segmentEmpty-OjqG3", a = "crk-literal-iZcwW", o = "crk-suffix-l1MSH", s = "crk-timeZone-27ID1", c = "crk-body-5FqOt", l = "crk-calendar-EjUxD", u = "crk-time-F5Zb0", d = "crk-column-bRLrD", f = "crk-option-JF-Fj", p = "crk-optionSelected-nlh39", m = "crk-footer-q3V1M", h = "crk-zone-QFZBW", g = {
3
+ popover: e,
4
+ portalled: t,
5
+ segments: n,
6
+ segment: r,
7
+ segmentEmpty: i,
8
+ literal: a,
9
+ suffix: o,
10
+ timeZone: s,
11
+ body: c,
12
+ calendar: l,
13
+ time: u,
14
+ column: d,
15
+ option: f,
16
+ optionSelected: p,
17
+ footer: m,
18
+ zone: h
19
+ };
20
+ export { c as body, l as calendar, d as column, g as default, m as footer, a as literal, f as option, p as optionSelected, e as popover, t as portalled, r as segment, i as segmentEmpty, n as segments, o as suffix, u as time, s as timeZone, h as zone };