@overdoser/react-toolkit 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -0
- package/CHANGELOG.md +27 -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,16 +1,16 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import p from "
|
|
1
|
+
import { useEffect as e, useMemo as t, useRef as n, useState as r } from "react";
|
|
2
|
+
import i from "clsx";
|
|
3
|
+
import a from "./CalendarPanel.module.scss.js";
|
|
4
|
+
import { addDays as o, addMonths as s, buildCalendarDays as c, isSameDay as l, isSameMonth as u, startOfMonth as d, toISODate as f, weekdayLabels as p } from "./dateUtils.js";
|
|
5
5
|
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
6
6
|
// src/components/inputs/DatePicker/CalendarPanel.tsx
|
|
7
|
-
var _ = 100,
|
|
8
|
-
function
|
|
9
|
-
let
|
|
7
|
+
var _ = 100, ee = 3, v = 4;
|
|
8
|
+
function y({ viewDate: y, focusedDate: b, selected: x, today: S, minDay: C, maxDay: w, locale: T, weekStartsOn: E, isDisabledDay: D, onSelect: te, onViewDateChange: O, onFocusedDateChange: k, onEscape: A, classes: j }) {
|
|
9
|
+
let M = n(null), N = n(null), [P, F] = r("day"), [I, L] = r(0), R = y.getFullYear(), z = y.getMonth(), B = t(() => new Intl.DateTimeFormat(T, {
|
|
10
10
|
month: "long",
|
|
11
11
|
year: "numeric"
|
|
12
|
-
}).format(
|
|
13
|
-
let e = new Intl.DateTimeFormat(
|
|
12
|
+
}).format(y), [T, y]), V = t(() => new Intl.DateTimeFormat(T, { month: "long" }).format(y), [T, y]), H = t(() => new Intl.DateTimeFormat(T, { year: "numeric" }).format(y), [T, y]), U = t(() => {
|
|
13
|
+
let e = new Intl.DateTimeFormat(T, { month: "short" }), t = new Intl.DateTimeFormat(T, { month: "long" });
|
|
14
14
|
return Array.from({ length: 12 }, (n, r) => {
|
|
15
15
|
let i = new Date(2023, r, 1);
|
|
16
16
|
return {
|
|
@@ -18,89 +18,89 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
|
|
|
18
18
|
long: t.format(i)
|
|
19
19
|
};
|
|
20
20
|
});
|
|
21
|
-
}, [
|
|
22
|
-
let e =
|
|
23
|
-
return e = Math.min(e,
|
|
21
|
+
}, [T]), W = t(() => {
|
|
22
|
+
let e = C ? C.getFullYear() : R - _, t = w ? w.getFullYear() : R + _;
|
|
23
|
+
return e = Math.min(e, R), t = Math.max(t, R), Array.from({ length: t - e + 1 }, (t, n) => e + n);
|
|
24
24
|
}, [
|
|
25
|
+
C,
|
|
25
26
|
w,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
P.current?.querySelector(`[data-date="${s(x)}"]`)?.focus();
|
|
27
|
+
R
|
|
28
|
+
]), ne = t(() => p(T, E), [T, E]), re = t(() => c(y, E), [y, E]), ie = t(() => new Intl.DateTimeFormat(T, { dateStyle: "full" }), [T]), G = (e) => {
|
|
29
|
+
let t = new Date(R, e, 1), n = new Date(R, e + 1, 0);
|
|
30
|
+
return !!w && t > w || !!C && n < C;
|
|
31
|
+
}, K = (e) => !!w && new Date(e, 0, 1) > w || !!C && new Date(e, 11, 31) < C;
|
|
32
|
+
e(() => {
|
|
33
|
+
if (P === "day") {
|
|
34
|
+
M.current?.querySelector(`[data-date="${f(b)}"]`)?.focus();
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
let e =
|
|
37
|
+
let e = N.current, t = e?.querySelector("[data-active]");
|
|
38
38
|
e && t && (e.scrollTop = t.offsetTop - e.clientHeight / 2 + t.offsetHeight / 2, t.focus());
|
|
39
39
|
}, [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
P,
|
|
41
|
+
b,
|
|
42
|
+
I
|
|
43
43
|
]);
|
|
44
44
|
let ae = (e) => {
|
|
45
|
-
|
|
45
|
+
k(e), u(e, y) || O(d(e));
|
|
46
46
|
}, q = (e) => {
|
|
47
|
-
|
|
47
|
+
D(e) || te(e);
|
|
48
48
|
}, J = (e) => {
|
|
49
|
-
|
|
49
|
+
P === e ? F("day") : (L(e === "month" ? z : W.indexOf(R)), F(e));
|
|
50
50
|
}, Y = (e, t) => {
|
|
51
|
-
let n = new Date(e, t + 1, 0).getDate(), r = new Date(e, t, Math.min(
|
|
52
|
-
|
|
51
|
+
let n = new Date(e, t + 1, 0).getDate(), r = new Date(e, t, Math.min(b.getDate(), n));
|
|
52
|
+
k(r), O(d(r)), F("day");
|
|
53
53
|
}, oe = (e) => {
|
|
54
|
-
let
|
|
54
|
+
let t = null;
|
|
55
55
|
switch (e.key) {
|
|
56
56
|
case "ArrowLeft":
|
|
57
|
-
|
|
57
|
+
t = o(b, -1);
|
|
58
58
|
break;
|
|
59
59
|
case "ArrowRight":
|
|
60
|
-
|
|
60
|
+
t = o(b, 1);
|
|
61
61
|
break;
|
|
62
62
|
case "ArrowUp":
|
|
63
|
-
|
|
63
|
+
t = o(b, -7);
|
|
64
64
|
break;
|
|
65
65
|
case "ArrowDown":
|
|
66
|
-
|
|
66
|
+
t = o(b, 7);
|
|
67
67
|
break;
|
|
68
68
|
case "Home":
|
|
69
|
-
|
|
69
|
+
t = o(b, -((b.getDay() - E + 7) % 7));
|
|
70
70
|
break;
|
|
71
71
|
case "End":
|
|
72
|
-
|
|
72
|
+
t = o(b, 6 - (b.getDay() - E + 7) % 7);
|
|
73
73
|
break;
|
|
74
74
|
case "PageUp":
|
|
75
|
-
|
|
75
|
+
t = s(b, -1);
|
|
76
76
|
break;
|
|
77
77
|
case "PageDown":
|
|
78
|
-
|
|
78
|
+
t = s(b, 1);
|
|
79
79
|
break;
|
|
80
80
|
case "Enter":
|
|
81
81
|
case " ":
|
|
82
|
-
e.preventDefault(), q(
|
|
82
|
+
e.preventDefault(), q(b);
|
|
83
83
|
return;
|
|
84
84
|
case "Escape":
|
|
85
|
-
e.preventDefault(),
|
|
85
|
+
e.preventDefault(), A();
|
|
86
86
|
return;
|
|
87
87
|
default: return;
|
|
88
88
|
}
|
|
89
|
-
e.preventDefault(), ae(
|
|
89
|
+
e.preventDefault(), ae(t);
|
|
90
90
|
}, X = (e, t, n) => {
|
|
91
|
-
let r =
|
|
91
|
+
let r = I;
|
|
92
92
|
switch (e.key) {
|
|
93
93
|
case "ArrowLeft":
|
|
94
|
-
r =
|
|
94
|
+
r = I - 1;
|
|
95
95
|
break;
|
|
96
96
|
case "ArrowRight":
|
|
97
|
-
r =
|
|
97
|
+
r = I + 1;
|
|
98
98
|
break;
|
|
99
99
|
case "ArrowUp":
|
|
100
|
-
r =
|
|
100
|
+
r = I - n;
|
|
101
101
|
break;
|
|
102
102
|
case "ArrowDown":
|
|
103
|
-
r =
|
|
103
|
+
r = I + n;
|
|
104
104
|
break;
|
|
105
105
|
case "Home":
|
|
106
106
|
r = 0;
|
|
@@ -110,22 +110,22 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
|
|
|
110
110
|
break;
|
|
111
111
|
case "Enter":
|
|
112
112
|
case " ":
|
|
113
|
-
e.preventDefault(),
|
|
113
|
+
e.preventDefault(), P === "month" ? G(I) || Y(R, I) : K(W[I]) || Y(W[I], z);
|
|
114
114
|
return;
|
|
115
115
|
case "Escape":
|
|
116
|
-
e.preventDefault(),
|
|
116
|
+
e.preventDefault(), F("day");
|
|
117
117
|
return;
|
|
118
118
|
default: return;
|
|
119
119
|
}
|
|
120
|
-
e.preventDefault(),
|
|
121
|
-
}, Z =
|
|
120
|
+
e.preventDefault(), L(Math.max(0, Math.min(t - 1, r)));
|
|
121
|
+
}, Z = P === "year", Q = P === "day" ? "month" : "year", $ = (e) => O(P === "day" ? s(y, e) : new Date(R + e, z, 1));
|
|
122
122
|
return /* @__PURE__ */ g(m, { children: [
|
|
123
123
|
/* @__PURE__ */ g("div", {
|
|
124
|
-
className:
|
|
124
|
+
className: i(a.header, j?.header),
|
|
125
125
|
children: [
|
|
126
126
|
/* @__PURE__ */ h("button", {
|
|
127
127
|
type: "button",
|
|
128
|
-
className:
|
|
128
|
+
className: i(a.nav, Z && a.navHidden, j?.nav),
|
|
129
129
|
onClick: () => $(-1),
|
|
130
130
|
"aria-label": `Previous ${Q}`,
|
|
131
131
|
"aria-hidden": Z || void 0,
|
|
@@ -142,34 +142,34 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
|
|
|
142
142
|
})
|
|
143
143
|
}),
|
|
144
144
|
/* @__PURE__ */ g("div", {
|
|
145
|
-
className:
|
|
145
|
+
className: a.title,
|
|
146
146
|
children: [
|
|
147
147
|
/* @__PURE__ */ h("button", {
|
|
148
148
|
type: "button",
|
|
149
|
-
className:
|
|
149
|
+
className: a.titleButton,
|
|
150
150
|
"aria-label": "Choose month",
|
|
151
|
-
"aria-expanded":
|
|
151
|
+
"aria-expanded": P === "month",
|
|
152
152
|
onClick: () => J("month"),
|
|
153
|
-
children:
|
|
153
|
+
children: V
|
|
154
154
|
}),
|
|
155
155
|
/* @__PURE__ */ h("button", {
|
|
156
156
|
type: "button",
|
|
157
|
-
className:
|
|
157
|
+
className: a.titleButton,
|
|
158
158
|
"aria-label": "Choose year",
|
|
159
|
-
"aria-expanded":
|
|
159
|
+
"aria-expanded": P === "year",
|
|
160
160
|
onClick: () => J("year"),
|
|
161
|
-
children:
|
|
161
|
+
children: H
|
|
162
162
|
}),
|
|
163
163
|
/* @__PURE__ */ h("span", {
|
|
164
|
-
className:
|
|
164
|
+
className: a.srOnly,
|
|
165
165
|
"aria-live": "polite",
|
|
166
|
-
children:
|
|
166
|
+
children: B
|
|
167
167
|
})
|
|
168
168
|
]
|
|
169
169
|
}),
|
|
170
170
|
/* @__PURE__ */ h("button", {
|
|
171
171
|
type: "button",
|
|
172
|
-
className:
|
|
172
|
+
className: i(a.nav, Z && a.navHidden, j?.nav),
|
|
173
173
|
onClick: () => $(1),
|
|
174
174
|
"aria-label": `Next ${Q}`,
|
|
175
175
|
"aria-hidden": Z || void 0,
|
|
@@ -187,78 +187,78 @@ function b({ viewDate: b, focusedDate: x, selected: S, today: C, minDay: w, maxD
|
|
|
187
187
|
})
|
|
188
188
|
]
|
|
189
189
|
}),
|
|
190
|
-
|
|
191
|
-
ref:
|
|
190
|
+
P === "month" && /* @__PURE__ */ h("div", {
|
|
191
|
+
ref: N,
|
|
192
192
|
role: "listbox",
|
|
193
193
|
"aria-label": "Month",
|
|
194
|
-
className:
|
|
195
|
-
onKeyDown: (e) => X(e, 12,
|
|
196
|
-
children:
|
|
197
|
-
let
|
|
194
|
+
className: i(a.options, a.months),
|
|
195
|
+
onKeyDown: (e) => X(e, 12, ee),
|
|
196
|
+
children: U.map((e, t) => {
|
|
197
|
+
let n = G(t), r = t === z;
|
|
198
198
|
return /* @__PURE__ */ h("button", {
|
|
199
199
|
type: "button",
|
|
200
200
|
role: "option",
|
|
201
|
-
"aria-selected":
|
|
202
|
-
"aria-disabled":
|
|
203
|
-
"aria-label":
|
|
204
|
-
tabIndex:
|
|
205
|
-
"data-active":
|
|
206
|
-
className:
|
|
207
|
-
onClick: () => !
|
|
208
|
-
children:
|
|
209
|
-
},
|
|
201
|
+
"aria-selected": r,
|
|
202
|
+
"aria-disabled": n || void 0,
|
|
203
|
+
"aria-label": e.long,
|
|
204
|
+
tabIndex: t === I ? 0 : -1,
|
|
205
|
+
"data-active": t === I || void 0,
|
|
206
|
+
className: i(a.option, r && a.optionSelected),
|
|
207
|
+
onClick: () => !n && Y(R, t),
|
|
208
|
+
children: e.short
|
|
209
|
+
}, t);
|
|
210
210
|
})
|
|
211
211
|
}),
|
|
212
|
-
|
|
213
|
-
ref:
|
|
212
|
+
P === "year" && /* @__PURE__ */ h("div", {
|
|
213
|
+
ref: N,
|
|
214
214
|
role: "listbox",
|
|
215
215
|
"aria-label": "Year",
|
|
216
|
-
className:
|
|
217
|
-
onKeyDown: (e) => X(e, W.length,
|
|
218
|
-
children: W.map((
|
|
219
|
-
let
|
|
216
|
+
className: i(a.options, a.years),
|
|
217
|
+
onKeyDown: (e) => X(e, W.length, v),
|
|
218
|
+
children: W.map((e, t) => {
|
|
219
|
+
let n = K(e), r = e === R;
|
|
220
220
|
return /* @__PURE__ */ h("button", {
|
|
221
221
|
type: "button",
|
|
222
222
|
role: "option",
|
|
223
|
-
"aria-selected":
|
|
224
|
-
"aria-disabled":
|
|
225
|
-
tabIndex:
|
|
226
|
-
"data-active":
|
|
227
|
-
className:
|
|
228
|
-
onClick: () => !
|
|
229
|
-
children:
|
|
230
|
-
},
|
|
223
|
+
"aria-selected": r,
|
|
224
|
+
"aria-disabled": n || void 0,
|
|
225
|
+
tabIndex: t === I ? 0 : -1,
|
|
226
|
+
"data-active": t === I || void 0,
|
|
227
|
+
className: i(a.option, r && a.optionSelected),
|
|
228
|
+
onClick: () => !n && Y(e, z),
|
|
229
|
+
children: e
|
|
230
|
+
}, e);
|
|
231
231
|
})
|
|
232
232
|
}),
|
|
233
|
-
|
|
234
|
-
className:
|
|
233
|
+
P === "day" && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("div", {
|
|
234
|
+
className: a.weekdays,
|
|
235
235
|
"aria-hidden": "true",
|
|
236
|
-
children: ne.map((
|
|
237
|
-
className:
|
|
238
|
-
children:
|
|
239
|
-
},
|
|
236
|
+
children: ne.map((e, t) => /* @__PURE__ */ h("span", {
|
|
237
|
+
className: a.weekday,
|
|
238
|
+
children: e
|
|
239
|
+
}, t))
|
|
240
240
|
}), /* @__PURE__ */ h("div", {
|
|
241
|
-
ref:
|
|
241
|
+
ref: M,
|
|
242
242
|
role: "grid",
|
|
243
|
-
className:
|
|
243
|
+
className: i(a.grid, j?.grid),
|
|
244
244
|
onKeyDown: oe,
|
|
245
|
-
children: re.map((
|
|
246
|
-
let
|
|
245
|
+
children: re.map((e) => {
|
|
246
|
+
let t = !u(e, y), n = l(e, x), r = l(e, S), o = D(e), s = l(e, b);
|
|
247
247
|
return /* @__PURE__ */ h("button", {
|
|
248
248
|
type: "button",
|
|
249
249
|
role: "gridcell",
|
|
250
|
-
"data-date":
|
|
251
|
-
tabIndex:
|
|
252
|
-
className:
|
|
253
|
-
"aria-selected":
|
|
254
|
-
"aria-disabled":
|
|
255
|
-
"aria-current":
|
|
256
|
-
"aria-label": ie.format(
|
|
257
|
-
onClick: () => q(
|
|
258
|
-
children:
|
|
259
|
-
},
|
|
250
|
+
"data-date": f(e),
|
|
251
|
+
tabIndex: s ? 0 : -1,
|
|
252
|
+
className: i(a.day, t && a.dayOutside, r && a.dayToday, n && a.daySelected, t && j?.dayOutside, r && j?.dayToday, n && j?.daySelected, j?.day),
|
|
253
|
+
"aria-selected": n,
|
|
254
|
+
"aria-disabled": o || void 0,
|
|
255
|
+
"aria-current": r ? "date" : void 0,
|
|
256
|
+
"aria-label": ie.format(e),
|
|
257
|
+
onClick: () => q(e),
|
|
258
|
+
children: e.getDate()
|
|
259
|
+
}, f(e));
|
|
260
260
|
})
|
|
261
261
|
})] })
|
|
262
262
|
] });
|
|
263
263
|
}
|
|
264
|
-
export {
|
|
264
|
+
export { y as CalendarPanel };
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import u from "
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { forwardRef as e, useCallback as t, useMemo as n, useRef as r, useState as i } from "react";
|
|
2
|
+
import { createPortal as a } from "react-dom";
|
|
3
|
+
import o from "clsx";
|
|
4
|
+
import { useClickOutside as s } from "../../../hooks/useClickOutside.js";
|
|
5
|
+
import { usePortalPosition as c } from "../../../hooks/usePortalPosition.js";
|
|
6
|
+
import l from "./DatePicker.module.scss.js";
|
|
7
|
+
import { CalendarPanel as u } from "./CalendarPanel.js";
|
|
8
|
+
import { startOfDay as d, startOfMonth as f } from "./dateUtils.js";
|
|
9
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
10
10
|
// src/components/inputs/DatePicker/DatePicker.tsx
|
|
11
|
-
var
|
|
12
|
-
let M =
|
|
11
|
+
var h = e(({ value: e, defaultValue: h, onChange: g, min: _, max: v, disabledDate: y, weekStartsOn: b = 0, locale: x, format: S, placeholder: C = "Select date", inputSize: ee = "md", error: w = !1, disabled: T = !1, portal: E = !0, classes: D, className: O, style: k, "aria-label": A }, j) => {
|
|
12
|
+
let M = e !== void 0, [N, P] = i(h ?? null), F = M ? e ?? null : N, [I, L] = i(!1), [R, z] = i(() => f(F ?? /* @__PURE__ */ new Date())), [B, V] = i(() => d(F ?? /* @__PURE__ */ new Date())), H = r(null), U = r(null), W = c(H, I && E), G = n(() => d(/* @__PURE__ */ new Date()), []), K = n(() => S ?? ((e) => new Intl.DateTimeFormat(x, {
|
|
13
13
|
year: "numeric",
|
|
14
14
|
month: "short",
|
|
15
15
|
day: "numeric"
|
|
16
|
-
}).format(e)), [
|
|
16
|
+
}).format(e)), [S, x]), q = n(() => _ ? d(_) : void 0, [_]), J = n(() => v ? d(v) : void 0, [v]), Y = t((e) => q && e < q || J && e > J ? !0 : y?.(e) ?? !1, [
|
|
17
17
|
q,
|
|
18
18
|
J,
|
|
19
|
-
|
|
20
|
-
]), X =
|
|
21
|
-
M || P(e),
|
|
22
|
-
}, [M,
|
|
19
|
+
y
|
|
20
|
+
]), X = t((e) => {
|
|
21
|
+
M || P(e), g?.(e);
|
|
22
|
+
}, [M, g]), Z = t(() => {
|
|
23
23
|
if (T) return;
|
|
24
|
-
let e =
|
|
25
|
-
z(
|
|
26
|
-
}, [T, F]), Q =
|
|
24
|
+
let e = d(F ?? /* @__PURE__ */ new Date());
|
|
25
|
+
z(f(e)), V(e), L(!0);
|
|
26
|
+
}, [T, F]), Q = t((e = !0) => {
|
|
27
27
|
L(!1), e && H.current?.querySelector("input")?.focus();
|
|
28
|
-
}, []), te =
|
|
28
|
+
}, []), te = t((e) => {
|
|
29
29
|
X(e), Q();
|
|
30
30
|
}, [X, Q]);
|
|
31
|
-
|
|
31
|
+
s(U, () => L(!1), I);
|
|
32
32
|
let ne = (e) => {
|
|
33
33
|
e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), Z()) : e.key === "Escape" && I && (e.preventDefault(), L(!1));
|
|
34
|
-
}, $ = /* @__PURE__ */
|
|
34
|
+
}, $ = /* @__PURE__ */ p("div", {
|
|
35
35
|
ref: U,
|
|
36
36
|
onKeyDown: (e) => {
|
|
37
37
|
e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), Q());
|
|
38
38
|
},
|
|
39
|
-
className:
|
|
39
|
+
className: o(l.popover, E && l.portalled, D?.popover),
|
|
40
40
|
style: E ? {
|
|
41
41
|
position: "fixed",
|
|
42
42
|
top: W.top + 4,
|
|
@@ -45,15 +45,15 @@ var m = a(({ value: a, defaultValue: m, onChange: h, min: g, max: _, disabledDat
|
|
|
45
45
|
role: "dialog",
|
|
46
46
|
"aria-modal": "false",
|
|
47
47
|
"aria-label": "Choose date",
|
|
48
|
-
children: /* @__PURE__ */
|
|
48
|
+
children: /* @__PURE__ */ p(u, {
|
|
49
49
|
viewDate: R,
|
|
50
50
|
focusedDate: B,
|
|
51
51
|
selected: F,
|
|
52
52
|
today: G,
|
|
53
53
|
minDay: q,
|
|
54
54
|
maxDay: J,
|
|
55
|
-
locale:
|
|
56
|
-
weekStartsOn:
|
|
55
|
+
locale: x,
|
|
56
|
+
weekStartsOn: b,
|
|
57
57
|
isDisabledDay: Y,
|
|
58
58
|
onSelect: te,
|
|
59
59
|
onViewDateChange: z,
|
|
@@ -62,18 +62,18 @@ var m = a(({ value: a, defaultValue: m, onChange: h, min: g, max: _, disabledDat
|
|
|
62
62
|
classes: D
|
|
63
63
|
})
|
|
64
64
|
});
|
|
65
|
-
return /* @__PURE__ */
|
|
65
|
+
return /* @__PURE__ */ m("div", {
|
|
66
66
|
ref: H,
|
|
67
|
-
className:
|
|
67
|
+
className: o(l.root, l[ee], w && l.error, T && l.disabled, D?.root, O),
|
|
68
68
|
style: k,
|
|
69
69
|
children: [
|
|
70
|
-
/* @__PURE__ */
|
|
70
|
+
/* @__PURE__ */ p("input", {
|
|
71
71
|
ref: j,
|
|
72
72
|
type: "text",
|
|
73
73
|
readOnly: !0,
|
|
74
|
-
className:
|
|
74
|
+
className: o(l.input, D?.input),
|
|
75
75
|
value: F ? K(F) : "",
|
|
76
|
-
placeholder:
|
|
76
|
+
placeholder: C,
|
|
77
77
|
disabled: T,
|
|
78
78
|
"aria-label": A,
|
|
79
79
|
"aria-haspopup": "dialog",
|
|
@@ -82,34 +82,34 @@ var m = a(({ value: a, defaultValue: m, onChange: h, min: g, max: _, disabledDat
|
|
|
82
82
|
onClick: Z,
|
|
83
83
|
onKeyDown: ne
|
|
84
84
|
}),
|
|
85
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ p("button", {
|
|
86
86
|
type: "button",
|
|
87
87
|
tabIndex: -1,
|
|
88
|
-
className:
|
|
88
|
+
className: o(l.icon, D?.icon),
|
|
89
89
|
onClick: Z,
|
|
90
90
|
disabled: T,
|
|
91
91
|
"aria-label": "Open calendar",
|
|
92
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ m("svg", {
|
|
93
93
|
viewBox: "0 0 20 20",
|
|
94
94
|
fill: "none",
|
|
95
95
|
stroke: "currentColor",
|
|
96
96
|
strokeWidth: "1.5",
|
|
97
97
|
"aria-hidden": "true",
|
|
98
|
-
children: [/* @__PURE__ */
|
|
98
|
+
children: [/* @__PURE__ */ p("rect", {
|
|
99
99
|
x: "3",
|
|
100
100
|
y: "4",
|
|
101
101
|
width: "14",
|
|
102
102
|
height: "13",
|
|
103
103
|
rx: "2"
|
|
104
|
-
}), /* @__PURE__ */
|
|
104
|
+
}), /* @__PURE__ */ p("path", {
|
|
105
105
|
d: "M3 8h14M7 2v3M13 2v3",
|
|
106
106
|
strokeLinecap: "round"
|
|
107
107
|
})]
|
|
108
108
|
})
|
|
109
109
|
}),
|
|
110
|
-
I && (E ? typeof document < "u" &&
|
|
110
|
+
I && (E ? typeof document < "u" && a($, document.body) : $)
|
|
111
111
|
]
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
|
-
|
|
115
|
-
export {
|
|
114
|
+
h.displayName = "DatePicker";
|
|
115
|
+
export { h as DatePicker };
|