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