@overdoser/react-toolkit 0.21.0 → 0.22.1
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.
- package/AGENTS.md +1 -0
- package/CHANGELOG.md +35 -0
- package/components/Accordion/Accordion.js +48 -48
- package/components/ActionButton/ActionButton.js +23 -23
- package/components/ActionButton/CopyButton.js +5 -5
- package/components/Alert/Alert.js +13 -13
- package/components/Avatar/Avatar.js +12 -12
- package/components/Badge/Badge.js +6 -6
- package/components/Breadcrumbs/Breadcrumbs.js +15 -15
- package/components/Button/Button.js +14 -14
- package/components/Card/Card.js +26 -26
- package/components/Chart/AreaChart.js +103 -103
- package/components/Chart/Axis.js +7 -7
- package/components/Chart/BarChart.js +62 -62
- package/components/Chart/ChartContainer.js +11 -11
- package/components/Chart/ChartLegend.js +7 -7
- package/components/Chart/ChartTooltip.js +13 -13
- package/components/Chart/LineChart.js +88 -88
- package/components/Chart/PieChart.js +25 -25
- package/components/Chart/RadarChart.js +42 -42
- package/components/Chart/Sparkline.js +11 -11
- package/components/Chart/TradingChart.js +126 -126
- package/components/Chart/trading/period.js +3 -3
- package/components/Chip/Chip.js +24 -24
- package/components/CodeBlock/CodeBlock.js +31 -31
- package/components/CommandPalette/CommandPalette.js +166 -166
- package/components/ConfirmDialog/ConfirmDialog.js +60 -60
- package/components/Divider/Divider.js +10 -10
- package/components/Draggable/Draggable.js +29 -29
- package/components/Drawer/Drawer.js +53 -53
- package/components/Dropdown/Dropdown.js +66 -66
- package/components/Dropdown/DropdownItem.js +13 -13
- package/components/Dropdown/DropdownLabel.js +5 -5
- package/components/Dropdown/DropdownSeparator.js +5 -5
- package/components/Dropzone/Dropzone.js +15 -15
- package/components/EmptyState/EmptyState.js +11 -11
- package/components/Form/Form.js +17 -17
- package/components/Form/FormField.js +21 -21
- package/components/Form/FormRow.js +3 -3
- package/components/ImageViewer/ImageViewer.js +118 -118
- package/components/Kbd/Kbd.js +11 -11
- package/components/KeyValueList/KeyValueList.js +32 -32
- package/components/Link/Link.js +7 -7
- package/components/List/List.js +7 -7
- package/components/Loader/Loader.js +39 -39
- package/components/Modal/Modal.js +48 -48
- package/components/PageHeader/PageHeader.js +18 -18
- package/components/Pagination/Pagination.js +23 -23
- package/components/Popover/Popover.js +25 -25
- package/components/ProgressBar/ProgressBar.js +17 -17
- package/components/RelativeTime/RelativeTime.js +10 -10
- package/components/SegmentedControl/SegmentedControl.js +38 -38
- package/components/Skeleton/Skeleton.js +10 -10
- package/components/Spinner/Spinner.js +7 -7
- package/components/SplitButton/SplitButton.js +63 -63
- package/components/SplitPane/SplitPane.js +50 -50
- package/components/StatCard/StatCard.js +32 -32
- package/components/StatusDot/StatusDot.js +7 -7
- package/components/Table/Table.js +174 -174
- package/components/Tabs/Tabs.js +47 -47
- package/components/ThemeToggle/ThemeToggle.js +31 -31
- package/components/Timeline/GanttTimeline.js +213 -213
- package/components/Timeline/HistoryTimeline.js +306 -306
- package/components/Timeline/TimelineShared.js +103 -103
- package/components/Timeline/TraceEventDetails.js +103 -103
- package/components/Timeline/TraceTimeline.js +546 -546
- package/components/Timeline/historyLayout.js +2 -2
- package/components/Timer/Timer.js +39 -39
- package/components/Toast/Toast.js +59 -59
- package/components/ToggleIconButton/ToggleIconButton.js +9 -9
- package/components/Tooltip/Tooltip.js +16 -16
- package/components/Typography/Typography.js +5 -5
- package/components/inputs/Checkbox/Checkbox.js +11 -11
- package/components/inputs/Checkbox/CheckboxGroup.js +21 -21
- package/components/inputs/DatePicker/CalendarPanel.js +113 -113
- package/components/inputs/DatePicker/DatePicker.js +39 -39
- package/components/inputs/DateTimePicker/DateTimePicker.js +119 -119
- package/components/inputs/DateTimePicker/DateTimeSegments.js +40 -40
- package/components/inputs/DateTimePicker/TimeField.js +34 -34
- package/components/inputs/Input/Input.js +13 -13
- package/components/inputs/NumberInput/NumberInput.js +16 -16
- package/components/inputs/Radio/Radio.js +17 -17
- package/components/inputs/SearchInput/SearchInput.js +25 -25
- package/components/inputs/Select/Select.d.ts +55 -3
- package/components/inputs/Select/Select.js +485 -344
- package/components/inputs/Select/{Select.module.js → Select.module.scss.js} +15 -3
- package/components/inputs/Slider/Slider.js +21 -21
- package/components/inputs/Switch/Switch.js +4 -4
- package/components/inputs/Textarea/Textarea.js +8 -8
- package/hooks/usePortalPosition.d.ts +2 -1
- package/hooks/usePortalPosition.js +6 -3
- package/hooks/useResizable.js +1 -1
- package/hooks/useTheme.js +7 -7
- package/index.css +1 -1
- package/index.js +1 -1
- package/index.layered.css +1 -1
- package/llms.txt +25 -4
- package/manifest.json +33 -4
- package/package.json +1 -1
- /package/components/Accordion/{Accordion.module.js → Accordion.module.scss.js} +0 -0
- /package/components/ActionButton/{ActionButton.module.js → ActionButton.module.scss.js} +0 -0
- /package/components/Alert/{Alert.module.js → Alert.module.scss.js} +0 -0
- /package/components/Avatar/{Avatar.module.js → Avatar.module.scss.js} +0 -0
- /package/components/Badge/{Badge.module.js → Badge.module.scss.js} +0 -0
- /package/components/Breadcrumbs/{Breadcrumbs.module.js → Breadcrumbs.module.scss.js} +0 -0
- /package/components/Button/{Button.module.js → Button.module.scss.js} +0 -0
- /package/components/Card/{Card.module.js → Card.module.scss.js} +0 -0
- /package/components/Chart/{Chart.module.js → Chart.module.scss.js} +0 -0
- /package/components/Chip/{Chip.module.js → Chip.module.scss.js} +0 -0
- /package/components/CodeBlock/{CodeBlock.module.js → CodeBlock.module.scss.js} +0 -0
- /package/components/CommandPalette/{CommandPalette.module.js → CommandPalette.module.scss.js} +0 -0
- /package/components/ConfirmDialog/{ConfirmDialog.module.js → ConfirmDialog.module.scss.js} +0 -0
- /package/components/Divider/{Divider.module.js → Divider.module.scss.js} +0 -0
- /package/components/Draggable/{Draggable.module.js → Draggable.module.scss.js} +0 -0
- /package/components/Drawer/{Drawer.module.js → Drawer.module.scss.js} +0 -0
- /package/components/Dropdown/{Dropdown.module.js → Dropdown.module.scss.js} +0 -0
- /package/components/Dropzone/{Dropzone.module.js → Dropzone.module.scss.js} +0 -0
- /package/components/EmptyState/{EmptyState.module.js → EmptyState.module.scss.js} +0 -0
- /package/components/Form/{Form.module.js → Form.module.scss.js} +0 -0
- /package/components/ImageViewer/{ImageViewer.module.js → ImageViewer.module.scss.js} +0 -0
- /package/components/Kbd/{Kbd.module.js → Kbd.module.scss.js} +0 -0
- /package/components/KeyValueList/{KeyValueList.module.js → KeyValueList.module.scss.js} +0 -0
- /package/components/Link/{Link.module.js → Link.module.scss.js} +0 -0
- /package/components/List/{List.module.js → List.module.scss.js} +0 -0
- /package/components/Loader/{Loader.module.js → Loader.module.scss.js} +0 -0
- /package/components/Modal/{Modal.module.js → Modal.module.scss.js} +0 -0
- /package/components/PageHeader/{PageHeader.module.js → PageHeader.module.scss.js} +0 -0
- /package/components/Pagination/{Pagination.module.js → Pagination.module.scss.js} +0 -0
- /package/components/Popover/{Popover.module.js → Popover.module.scss.js} +0 -0
- /package/components/ProgressBar/{ProgressBar.module.js → ProgressBar.module.scss.js} +0 -0
- /package/components/RelativeTime/{RelativeTime.module.js → RelativeTime.module.scss.js} +0 -0
- /package/components/SegmentedControl/{SegmentedControl.module.js → SegmentedControl.module.scss.js} +0 -0
- /package/components/Skeleton/{Skeleton.module.js → Skeleton.module.scss.js} +0 -0
- /package/components/Spinner/{Spinner.module.js → Spinner.module.scss.js} +0 -0
- /package/components/SplitButton/{SplitButton.module.js → SplitButton.module.scss.js} +0 -0
- /package/components/SplitPane/{SplitPane.module.js → SplitPane.module.scss.js} +0 -0
- /package/components/StatCard/{StatCard.module.js → StatCard.module.scss.js} +0 -0
- /package/components/StatusDot/{StatusDot.module.js → StatusDot.module.scss.js} +0 -0
- /package/components/Table/{Table.module.js → Table.module.scss.js} +0 -0
- /package/components/Tabs/{Tabs.module.js → Tabs.module.scss.js} +0 -0
- /package/components/ThemeToggle/{ThemeToggle.module.js → ThemeToggle.module.scss.js} +0 -0
- /package/components/Timeline/{GanttTimeline.module.js → GanttTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{HistoryTimeline.module.js → HistoryTimeline.module.scss.js} +0 -0
- /package/components/Timeline/{Timeline.module.js → Timeline.module.scss.js} +0 -0
- /package/components/Timeline/{TraceTimeline.module.js → TraceTimeline.module.scss.js} +0 -0
- /package/components/Timer/{Timer.module.js → Timer.module.scss.js} +0 -0
- /package/components/Toast/{Toast.module.js → Toast.module.scss.js} +0 -0
- /package/components/ToggleIconButton/{ToggleIconButton.module.js → ToggleIconButton.module.scss.js} +0 -0
- /package/components/Tooltip/{Tooltip.module.js → Tooltip.module.scss.js} +0 -0
- /package/components/Typography/{Typography.module.js → Typography.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{Checkbox.module.js → Checkbox.module.scss.js} +0 -0
- /package/components/inputs/Checkbox/{CheckboxGroup.module.js → CheckboxGroup.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{CalendarPanel.module.js → CalendarPanel.module.scss.js} +0 -0
- /package/components/inputs/DatePicker/{DatePicker.module.js → DatePicker.module.scss.js} +0 -0
- /package/components/inputs/DateTimePicker/{DateTimePicker.module.js → DateTimePicker.module.scss.js} +0 -0
- /package/components/inputs/Input/{Input.module.js → Input.module.scss.js} +0 -0
- /package/components/inputs/NumberInput/{NumberInput.module.js → NumberInput.module.scss.js} +0 -0
- /package/components/inputs/Radio/{Radio.module.js → Radio.module.scss.js} +0 -0
- /package/components/inputs/SearchInput/{SearchInput.module.js → SearchInput.module.scss.js} +0 -0
- /package/components/inputs/Slider/{Slider.module.js → Slider.module.scss.js} +0 -0
- /package/components/inputs/Textarea/{Textarea.module.js → Textarea.module.scss.js} +0 -0
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
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
15
|
// src/components/inputs/DateTimePicker/DateTimePicker.tsx
|
|
16
|
-
var
|
|
16
|
+
var fe = {
|
|
17
17
|
hour: 0,
|
|
18
18
|
minute: 0,
|
|
19
19
|
second: 0
|
|
20
|
-
},
|
|
21
|
-
let A =
|
|
22
|
-
if (M !== "system") return
|
|
23
|
-
}, [M]), P =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]), F =
|
|
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
28
|
hour: F.hour,
|
|
29
29
|
minute: F.minute,
|
|
30
30
|
second: F.second
|
|
31
|
-
} :
|
|
32
|
-
|
|
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
33
|
j,
|
|
34
34
|
N,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]),
|
|
38
|
-
q,
|
|
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, [
|
|
39
38
|
J,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
45
|
year: e.getFullYear(),
|
|
46
46
|
month: e.getMonth(),
|
|
47
47
|
day: e.getDate(),
|
|
48
|
-
...
|
|
48
|
+
...t
|
|
49
49
|
}, N);
|
|
50
|
-
|
|
50
|
+
h && n < h && (n = new Date(h.getTime())), g && n > g && (n = new Date(g.getTime())), X(n);
|
|
51
51
|
}, [
|
|
52
52
|
N,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
]),
|
|
53
|
+
h,
|
|
54
|
+
g,
|
|
55
|
+
X
|
|
56
|
+
]), Q = t(() => {
|
|
57
57
|
if (w) return;
|
|
58
58
|
let e = I ?? R();
|
|
59
|
-
|
|
59
|
+
V(o(e)), U(e), B(!0);
|
|
60
60
|
}, [
|
|
61
61
|
w,
|
|
62
62
|
I,
|
|
63
63
|
R
|
|
64
|
-
]),
|
|
65
|
-
B(!1), e && (
|
|
66
|
-
}, []),
|
|
67
|
-
|
|
68
|
-
}, [
|
|
69
|
-
|
|
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
70
|
I,
|
|
71
|
-
|
|
72
|
-
]),
|
|
71
|
+
H
|
|
72
|
+
]), Me = t((e) => Z(u(e), {
|
|
73
73
|
hour: e.hour,
|
|
74
74
|
minute: e.minute,
|
|
75
75
|
second: e.second
|
|
76
|
-
}), [
|
|
77
|
-
|
|
78
|
-
let
|
|
79
|
-
e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(),
|
|
80
|
-
},
|
|
81
|
-
ref:
|
|
82
|
-
className:
|
|
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
83
|
style: T ? {
|
|
84
84
|
position: "fixed",
|
|
85
|
-
top:
|
|
86
|
-
left:
|
|
85
|
+
top: Oe.top + 4,
|
|
86
|
+
left: Oe.left
|
|
87
87
|
} : void 0,
|
|
88
88
|
role: "dialog",
|
|
89
89
|
"aria-modal": "false",
|
|
90
90
|
"aria-label": "Choose date and time",
|
|
91
91
|
onKeyDown: (e) => {
|
|
92
|
-
e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(),
|
|
92
|
+
e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), $());
|
|
93
93
|
},
|
|
94
|
-
children: [/* @__PURE__ */
|
|
95
|
-
className:
|
|
96
|
-
children: [/* @__PURE__ */
|
|
97
|
-
className:
|
|
98
|
-
children: /* @__PURE__ */
|
|
94
|
+
children: [/* @__PURE__ */ f("div", {
|
|
95
|
+
className: c.body,
|
|
96
|
+
children: [/* @__PURE__ */ d("div", {
|
|
97
|
+
className: c.calendar,
|
|
98
|
+
children: /* @__PURE__ */ d(ie, {
|
|
99
99
|
viewDate: Ee,
|
|
100
|
-
focusedDate:
|
|
100
|
+
focusedDate: H,
|
|
101
101
|
selected: I,
|
|
102
102
|
today: Te,
|
|
103
|
-
minDay:
|
|
104
|
-
maxDay:
|
|
105
|
-
locale:
|
|
106
|
-
weekStartsOn:
|
|
107
|
-
isDisabledDay:
|
|
108
|
-
onSelect:
|
|
109
|
-
onViewDateChange:
|
|
110
|
-
onFocusedDateChange:
|
|
111
|
-
onEscape:
|
|
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
112
|
classes: E
|
|
113
113
|
})
|
|
114
|
-
}), /* @__PURE__ */
|
|
114
|
+
}), /* @__PURE__ */ d(ae, {
|
|
115
115
|
...L,
|
|
116
|
-
onChange:
|
|
116
|
+
onChange: je,
|
|
117
117
|
hourCycle: P,
|
|
118
|
-
showSeconds:
|
|
119
|
-
minuteStep:
|
|
118
|
+
showSeconds: x,
|
|
119
|
+
minuteStep: _e,
|
|
120
120
|
disabled: w,
|
|
121
121
|
classes: E
|
|
122
122
|
})]
|
|
123
|
-
}), /* @__PURE__ */
|
|
124
|
-
className:
|
|
125
|
-
children: [
|
|
126
|
-
className:
|
|
127
|
-
title:
|
|
128
|
-
children:
|
|
129
|
-
}), /* @__PURE__ */
|
|
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
130
|
type: "button",
|
|
131
131
|
size: "sm",
|
|
132
|
-
onClick: () =>
|
|
132
|
+
onClick: () => $(),
|
|
133
133
|
children: ye
|
|
134
134
|
})]
|
|
135
135
|
})]
|
|
136
136
|
});
|
|
137
|
-
return /* @__PURE__ */
|
|
137
|
+
return /* @__PURE__ */ f("div", {
|
|
138
138
|
ref: (e) => {
|
|
139
|
-
|
|
139
|
+
W.current = e, typeof k == "function" ? k(e) : k && (k.current = e);
|
|
140
140
|
},
|
|
141
|
-
className:
|
|
141
|
+
className: a(s.root, s[be], C && s.error, w && s.disabled, E?.root, xe),
|
|
142
142
|
style: Se,
|
|
143
143
|
children: [
|
|
144
|
-
S ? /* @__PURE__ */
|
|
144
|
+
S ? /* @__PURE__ */ d("input", {
|
|
145
145
|
type: "text",
|
|
146
146
|
readOnly: !0,
|
|
147
|
-
className:
|
|
147
|
+
className: a(s.input, E?.input),
|
|
148
148
|
value: j ? S(j) : "",
|
|
149
149
|
placeholder: ve,
|
|
150
150
|
disabled: w,
|
|
@@ -153,74 +153,74 @@ var ue = {
|
|
|
153
153
|
"aria-haspopup": "dialog",
|
|
154
154
|
"aria-expanded": z,
|
|
155
155
|
"aria-invalid": C || void 0,
|
|
156
|
-
onClick:
|
|
157
|
-
onKeyDown:
|
|
158
|
-
}) : /* @__PURE__ */
|
|
159
|
-
ref:
|
|
156
|
+
onClick: Q,
|
|
157
|
+
onKeyDown: Ne
|
|
158
|
+
}) : /* @__PURE__ */ d(oe, {
|
|
159
|
+
ref: G,
|
|
160
160
|
value: j,
|
|
161
161
|
timeZone: N,
|
|
162
|
-
locale:
|
|
163
|
-
layout:
|
|
162
|
+
locale: v,
|
|
163
|
+
layout: b,
|
|
164
164
|
hourCycle: P,
|
|
165
|
-
showSeconds:
|
|
166
|
-
onChange:
|
|
167
|
-
onClear: () =>
|
|
168
|
-
onOpenRequest:
|
|
165
|
+
showSeconds: x,
|
|
166
|
+
onChange: Me,
|
|
167
|
+
onClear: () => X(null),
|
|
168
|
+
onOpenRequest: Q,
|
|
169
169
|
onEscape: (e) => {
|
|
170
170
|
z && (e.preventDefault(), B(!1));
|
|
171
171
|
},
|
|
172
|
-
suffix:
|
|
173
|
-
suffixTitle:
|
|
172
|
+
suffix: K,
|
|
173
|
+
suffixTitle: q,
|
|
174
174
|
suffixClassName: E?.timeZone,
|
|
175
175
|
disabled: w,
|
|
176
|
-
className:
|
|
176
|
+
className: a(s.input, E?.input),
|
|
177
177
|
classes: { segment: E?.segment },
|
|
178
178
|
"aria-label": D,
|
|
179
179
|
"aria-describedby": O,
|
|
180
180
|
"aria-invalid": C
|
|
181
181
|
}),
|
|
182
|
-
S &&
|
|
183
|
-
className:
|
|
184
|
-
title:
|
|
185
|
-
children:
|
|
182
|
+
S && K && /* @__PURE__ */ d("span", {
|
|
183
|
+
className: a(c.timeZone, E?.timeZone),
|
|
184
|
+
title: q,
|
|
185
|
+
children: K
|
|
186
186
|
}),
|
|
187
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ d("button", {
|
|
188
188
|
type: "button",
|
|
189
189
|
tabIndex: -1,
|
|
190
|
-
className:
|
|
191
|
-
onClick:
|
|
190
|
+
className: a(s.icon, E?.icon),
|
|
191
|
+
onClick: Q,
|
|
192
192
|
disabled: w,
|
|
193
193
|
"aria-label": "Open date and time picker",
|
|
194
|
-
children: /* @__PURE__ */
|
|
194
|
+
children: /* @__PURE__ */ f("svg", {
|
|
195
195
|
viewBox: "0 0 20 20",
|
|
196
196
|
fill: "none",
|
|
197
197
|
stroke: "currentColor",
|
|
198
198
|
strokeWidth: "1.5",
|
|
199
199
|
"aria-hidden": "true",
|
|
200
200
|
children: [
|
|
201
|
-
/* @__PURE__ */
|
|
201
|
+
/* @__PURE__ */ d("path", {
|
|
202
202
|
d: "M3 8h14M7 2v3M13 2v3",
|
|
203
203
|
strokeLinecap: "round"
|
|
204
204
|
}),
|
|
205
|
-
/* @__PURE__ */
|
|
205
|
+
/* @__PURE__ */ d("path", {
|
|
206
206
|
d: "M17 10V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h4",
|
|
207
207
|
strokeLinecap: "round"
|
|
208
208
|
}),
|
|
209
|
-
/* @__PURE__ */
|
|
209
|
+
/* @__PURE__ */ d("circle", {
|
|
210
210
|
cx: "14.5",
|
|
211
211
|
cy: "14.5",
|
|
212
212
|
r: "3.5"
|
|
213
213
|
}),
|
|
214
|
-
/* @__PURE__ */
|
|
214
|
+
/* @__PURE__ */ d("path", {
|
|
215
215
|
d: "M14.5 12.75v1.75l1.25 1",
|
|
216
216
|
strokeLinecap: "round"
|
|
217
217
|
})
|
|
218
218
|
]
|
|
219
219
|
})
|
|
220
220
|
}),
|
|
221
|
-
z && (T ? typeof document < "u" &&
|
|
221
|
+
z && (T ? typeof document < "u" && ee(Pe, document.body) : Pe)
|
|
222
222
|
]
|
|
223
223
|
});
|
|
224
224
|
});
|
|
225
|
-
|
|
226
|
-
export {
|
|
225
|
+
p.displayName = "DateTimePicker";
|
|
226
|
+
export { p as DateTimePicker };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import l from "
|
|
1
|
+
import { forwardRef as e, useCallback as t, useEffect as n, useImperativeHandle as r, useMemo as i, useRef as a, useState as o } from "react";
|
|
2
|
+
import s from "clsx";
|
|
3
|
+
import c from "./DateTimePicker.module.scss.js";
|
|
4
|
+
import { getWallClock as l } from "./timeZoneUtils.js";
|
|
5
5
|
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
6
|
// src/components/inputs/DateTimePicker/DateTimeSegments.tsx
|
|
7
7
|
var p = /* @__PURE__ */ new Set([
|
|
@@ -31,8 +31,8 @@ var p = /* @__PURE__ */ new Set([
|
|
|
31
31
|
}, g = (e, t) => new Date(e, t + 1, 0).getDate(), _ = (e, t, n) => {
|
|
32
32
|
let r = n - t + 1;
|
|
33
33
|
return ((e - t) % r + r) % r + t;
|
|
34
|
-
}, v =
|
|
35
|
-
let L =
|
|
34
|
+
}, v = e(({ value: e, timeZone: v, locale: y, layout: b, hourCycle: x, showSeconds: S, onChange: C, onClear: w, onOpenRequest: T, onEscape: E, suffix: D, suffixTitle: O, suffixClassName: k, disabled: A = !1, classes: j, className: M, "aria-label": N, "aria-describedby": P, "aria-invalid": F }, I) => {
|
|
35
|
+
let L = a(null), [R, z] = o(0), [B, V] = o(""), H = a(!1), U = i(() => new Intl.DateTimeFormat(y, {
|
|
36
36
|
year: "numeric",
|
|
37
37
|
month: "2-digit",
|
|
38
38
|
day: "2-digit",
|
|
@@ -46,22 +46,22 @@ var p = /* @__PURE__ */ new Set([
|
|
|
46
46
|
S,
|
|
47
47
|
x,
|
|
48
48
|
v
|
|
49
|
-
]), W =
|
|
50
|
-
if (b === "locale") return U.formatToParts(
|
|
49
|
+
]), W = i(() => e ? l(e, v) : null, [e, v]), G = i(() => {
|
|
50
|
+
if (b === "locale") return U.formatToParts(e ?? new Date(2001, 11, 21, 15, 45, 30)).filter((e) => p.has(e.type) || e.type === "literal").map((e) => ({
|
|
51
51
|
type: e.type,
|
|
52
52
|
text: e.value
|
|
53
53
|
}));
|
|
54
|
-
let
|
|
54
|
+
let t = (e, t = 2) => String(e).padStart(t, "0"), n = W ?? {
|
|
55
55
|
year: 0,
|
|
56
56
|
month: 0,
|
|
57
57
|
day: 0,
|
|
58
58
|
hour: 0,
|
|
59
59
|
minute: 0,
|
|
60
60
|
second: 0
|
|
61
|
-
}, r = x === 12 ?
|
|
61
|
+
}, r = x === 12 ? n.hour % 12 || 12 : n.hour, i = [
|
|
62
62
|
{
|
|
63
63
|
type: "year",
|
|
64
|
-
text:
|
|
64
|
+
text: t(n.year, 4)
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
type: "literal",
|
|
@@ -69,7 +69,7 @@ var p = /* @__PURE__ */ new Set([
|
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
type: "month",
|
|
72
|
-
text:
|
|
72
|
+
text: t(n.month + 1)
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
75
|
type: "literal",
|
|
@@ -77,7 +77,7 @@ var p = /* @__PURE__ */ new Set([
|
|
|
77
77
|
},
|
|
78
78
|
{
|
|
79
79
|
type: "day",
|
|
80
|
-
text:
|
|
80
|
+
text: t(n.day)
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
type: "literal",
|
|
@@ -85,7 +85,7 @@ var p = /* @__PURE__ */ new Set([
|
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
87
|
type: "hour",
|
|
88
|
-
text:
|
|
88
|
+
text: t(r)
|
|
89
89
|
},
|
|
90
90
|
{
|
|
91
91
|
type: "literal",
|
|
@@ -93,7 +93,7 @@ var p = /* @__PURE__ */ new Set([
|
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
type: "minute",
|
|
96
|
-
text:
|
|
96
|
+
text: t(n.minute)
|
|
97
97
|
}
|
|
98
98
|
];
|
|
99
99
|
return S && i.push({
|
|
@@ -101,28 +101,28 @@ var p = /* @__PURE__ */ new Set([
|
|
|
101
101
|
text: ":"
|
|
102
102
|
}, {
|
|
103
103
|
type: "second",
|
|
104
|
-
text:
|
|
104
|
+
text: t(n.second)
|
|
105
105
|
}), x === 12 && i.push({
|
|
106
106
|
type: "literal",
|
|
107
107
|
text: " "
|
|
108
108
|
}, {
|
|
109
109
|
type: "dayPeriod",
|
|
110
|
-
text:
|
|
110
|
+
text: n.hour >= 12 ? "PM" : "AM"
|
|
111
111
|
}), i;
|
|
112
112
|
}, [
|
|
113
113
|
b,
|
|
114
114
|
U,
|
|
115
|
-
|
|
115
|
+
e,
|
|
116
116
|
W,
|
|
117
117
|
x,
|
|
118
118
|
S
|
|
119
|
-
]), K =
|
|
120
|
-
...
|
|
119
|
+
]), K = i(() => G.map((e, t) => e.type === "literal" ? -1 : t).filter((e) => e >= 0), [G]), q = t(() => W ? { ...W } : {
|
|
120
|
+
...l(/* @__PURE__ */ new Date(), v),
|
|
121
121
|
second: 0
|
|
122
122
|
}, [W, v]);
|
|
123
|
-
|
|
123
|
+
r(I, () => ({ focus: () => {
|
|
124
124
|
L.current?.querySelector("[role=\"spinbutton\"][tabindex=\"0\"]")?.focus();
|
|
125
|
-
} }), []),
|
|
125
|
+
} }), []), n(() => {
|
|
126
126
|
H.current && (H.current = !1, L.current?.querySelector(`[data-segment="${R}"]`)?.focus());
|
|
127
127
|
}, [R]);
|
|
128
128
|
let J = (e) => {
|
|
@@ -235,35 +235,35 @@ var p = /* @__PURE__ */ new Set([
|
|
|
235
235
|
"aria-describedby": P,
|
|
236
236
|
"aria-invalid": F || void 0,
|
|
237
237
|
"aria-disabled": A || void 0,
|
|
238
|
-
className:
|
|
238
|
+
className: s(c.segments, j?.segments, M),
|
|
239
239
|
onMouseDown: (e) => {
|
|
240
240
|
A || e.target.closest("[role=\"spinbutton\"]") || (e.preventDefault(), L.current?.querySelector(`[data-segment="${R}"]`)?.focus());
|
|
241
241
|
},
|
|
242
|
-
children: [G.map((
|
|
243
|
-
if (
|
|
244
|
-
className:
|
|
242
|
+
children: [G.map((e, t) => {
|
|
243
|
+
if (e.type === "literal") return /* @__PURE__ */ d("span", {
|
|
244
|
+
className: c.literal,
|
|
245
245
|
"aria-hidden": "true",
|
|
246
|
-
children:
|
|
247
|
-
},
|
|
248
|
-
let
|
|
246
|
+
children: e.text
|
|
247
|
+
}, t);
|
|
248
|
+
let n = e.type, r = t === R, i = r && B !== "", a = !W && !i, o = i ? B : a ? m[n] : e.text, l = W ? Z(n, W) + +(n === "month") : void 0;
|
|
249
249
|
return /* @__PURE__ */ d("span", {
|
|
250
250
|
role: "spinbutton",
|
|
251
|
-
tabIndex: A ? -1 :
|
|
252
|
-
"data-segment":
|
|
253
|
-
"aria-label": h[
|
|
254
|
-
"aria-valuenow":
|
|
255
|
-
"aria-valuetext":
|
|
251
|
+
tabIndex: A ? -1 : r ? 0 : -1,
|
|
252
|
+
"data-segment": t,
|
|
253
|
+
"aria-label": h[n],
|
|
254
|
+
"aria-valuenow": l,
|
|
255
|
+
"aria-valuetext": a ? "Empty" : n === "dayPeriod" ? e.text : void 0,
|
|
256
256
|
"aria-disabled": A || void 0,
|
|
257
|
-
className:
|
|
257
|
+
className: s(c.segment, a && c.segmentEmpty, j?.segment),
|
|
258
258
|
onFocus: () => {
|
|
259
|
-
V(""), z(
|
|
259
|
+
V(""), z(t);
|
|
260
260
|
},
|
|
261
261
|
onBlur: () => V(""),
|
|
262
|
-
onKeyDown: (e) => ee(e,
|
|
263
|
-
children:
|
|
264
|
-
},
|
|
262
|
+
onKeyDown: (e) => ee(e, n),
|
|
263
|
+
children: o
|
|
264
|
+
}, t);
|
|
265
265
|
}), D && /* @__PURE__ */ f(u, { children: [" ", /* @__PURE__ */ d("span", {
|
|
266
|
-
className:
|
|
266
|
+
className: s(c.suffix, k),
|
|
267
267
|
title: O,
|
|
268
268
|
children: D
|
|
269
269
|
})] })]
|