@overdoser/react-toolkit 0.16.0 → 0.17.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/CHANGELOG.md +54 -0
- package/components/Chart/AreaChart.d.ts +5 -1
- package/components/Chart/AreaChart.js +155 -144
- package/components/Chart/BarChart.js +5 -5
- package/components/Chart/PieChart.js +2 -5
- package/components/Chart/RadarChart.js +2 -5
- package/components/Chart/TradingChart.js +258 -257
- package/components/Drawer/Drawer.js +69 -70
- package/components/Dropdown/Dropdown.js +51 -56
- package/components/Modal/Modal.js +42 -47
- package/components/Popover/Popover.js +52 -55
- package/components/SplitButton/SplitButton.js +50 -55
- package/components/inputs/DatePicker/DatePicker.js +82 -76
- package/components/inputs/DateTimePicker/DateTimePicker.js +4 -2
- package/components/inputs/DateTimePicker/DateTimeSegments.d.ts +2 -1
- package/components/inputs/DateTimePicker/DateTimeSegments.js +1 -1
- package/components/inputs/NumberInput/NumberInput.js +79 -81
- package/components/inputs/Select/Select.d.ts +5 -0
- package/components/inputs/Select/Select.js +340 -285
- package/hooks/useEscapeLayer.d.ts +36 -0
- package/hooks/useEscapeLayer.js +33 -0
- package/llms.txt +3 -2
- package/package.json +1 -1
|
@@ -1,75 +1,72 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useClickOutside as
|
|
6
|
-
import {
|
|
7
|
-
function
|
|
1
|
+
import { jsx as y, jsxs as K } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Q, useState as E, useRef as B, useId as U, useCallback as O, useLayoutEffect as Z, useEffect as _, isValidElement as ee, cloneElement as te } from "react";
|
|
3
|
+
import R from "clsx";
|
|
4
|
+
import L from "./Popover.module.scss.js";
|
|
5
|
+
import { useClickOutside as oe } from "../../hooks/useClickOutside.js";
|
|
6
|
+
import { useEscapeLayer as re, EscapeLayerProvider as ne } from "../../hooks/useEscapeLayer.js";
|
|
7
|
+
function ie(...a) {
|
|
8
8
|
return (h) => {
|
|
9
|
-
for (const
|
|
10
|
-
|
|
9
|
+
for (const l of a)
|
|
10
|
+
l && (typeof l == "function" ? l(h) : l.current = h);
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const se = Q(
|
|
14
14
|
({
|
|
15
15
|
trigger: a,
|
|
16
16
|
asChild: h = !1,
|
|
17
|
-
content:
|
|
17
|
+
content: l,
|
|
18
18
|
position: n = "bottom",
|
|
19
19
|
autoPosition: m = !0,
|
|
20
20
|
open: j,
|
|
21
21
|
onOpenChange: z,
|
|
22
22
|
classes: g,
|
|
23
|
-
className:
|
|
24
|
-
style:
|
|
25
|
-
},
|
|
26
|
-
const [
|
|
23
|
+
className: H,
|
|
24
|
+
style: T
|
|
25
|
+
}, V) => {
|
|
26
|
+
const [W, A] = E(!1), [D, M] = E(n), [F, P] = E(0), [G, X] = E(0), Y = B(null), u = B(null), v = B(null), k = U(), C = j !== void 0, o = C ? j : W, w = O(
|
|
27
27
|
(t) => {
|
|
28
|
-
C ||
|
|
28
|
+
C || A(t), z?.(t);
|
|
29
29
|
},
|
|
30
30
|
[C, z]
|
|
31
|
-
),
|
|
31
|
+
), $ = O(() => {
|
|
32
32
|
w(!1), v.current?.focus();
|
|
33
|
-
}, [w]),
|
|
33
|
+
}, [w]), q = O(() => {
|
|
34
34
|
w(!o);
|
|
35
35
|
}, [o, w]);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
o
|
|
41
|
-
), U(() => {
|
|
36
|
+
oe(Y, $, o);
|
|
37
|
+
const J = re($, o);
|
|
38
|
+
Z(() => {
|
|
42
39
|
if (!o || !m) {
|
|
43
|
-
M(n),
|
|
40
|
+
M(n), P(0), X(0);
|
|
44
41
|
return;
|
|
45
42
|
}
|
|
46
43
|
if (typeof window > "u") return;
|
|
47
44
|
const t = () => {
|
|
48
45
|
const b = v.current, x = u.current;
|
|
49
46
|
if (!b || !x) return;
|
|
50
|
-
const s = b.getBoundingClientRect(), i = x.getBoundingClientRect(),
|
|
47
|
+
const s = b.getBoundingClientRect(), i = x.getBoundingClientRect(), I = window.innerWidth, S = window.innerHeight, r = 8;
|
|
51
48
|
let c = n;
|
|
52
49
|
if (n === "bottom" || n === "top") {
|
|
53
|
-
const e = s.bottom + r + i.height <=
|
|
50
|
+
const e = s.bottom + r + i.height <= S, p = s.top - r - i.height >= 0;
|
|
54
51
|
n === "bottom" && !e && p ? c = "top" : n === "top" && !p && e && (c = "bottom");
|
|
55
52
|
} else {
|
|
56
|
-
const e = s.right + r + i.width <=
|
|
53
|
+
const e = s.right + r + i.width <= I, p = s.left - r - i.width >= 0;
|
|
57
54
|
n === "right" && !e && p ? c = "left" : n === "left" && !p && e && (c = "right");
|
|
58
55
|
}
|
|
59
|
-
let
|
|
56
|
+
let f = 0, d = 0;
|
|
60
57
|
if (c === "bottom" || c === "top") {
|
|
61
58
|
const e = s.left + s.width / 2 - i.width / 2;
|
|
62
|
-
e < r ?
|
|
59
|
+
e < r ? f = r - e : e + i.width > I - r && (f = I - r - (e + i.width));
|
|
63
60
|
} else {
|
|
64
61
|
const e = s.top + s.height / 2 - i.height / 2;
|
|
65
|
-
e < r ? d = r - e : e + i.height >
|
|
62
|
+
e < r ? d = r - e : e + i.height > S - r && (d = S - r - (e + i.height));
|
|
66
63
|
}
|
|
67
|
-
|
|
64
|
+
f = Math.round(f), d = Math.round(d), M((e) => e === c ? e : c), P((e) => e === f ? e : f), X((e) => e === d ? e : d);
|
|
68
65
|
};
|
|
69
66
|
return t(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", t), () => {
|
|
70
67
|
window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", t);
|
|
71
68
|
};
|
|
72
|
-
}, [o, m, n]),
|
|
69
|
+
}, [o, m, n]), _(() => {
|
|
73
70
|
if (o && u.current) {
|
|
74
71
|
const t = u.current.querySelector(
|
|
75
72
|
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
|
|
@@ -77,54 +74,54 @@ const ne = J(
|
|
|
77
74
|
t ? t.focus() : u.current.focus();
|
|
78
75
|
}
|
|
79
76
|
}, [o]);
|
|
80
|
-
let
|
|
81
|
-
if (h &&
|
|
77
|
+
let N;
|
|
78
|
+
if (h && ee(a)) {
|
|
82
79
|
const t = a, b = t.ref;
|
|
83
|
-
|
|
84
|
-
ref:
|
|
80
|
+
N = te(t, {
|
|
81
|
+
ref: ie(v, b),
|
|
85
82
|
onClick: (x) => {
|
|
86
|
-
t.props.onClick?.(x),
|
|
83
|
+
t.props.onClick?.(x), q();
|
|
87
84
|
},
|
|
88
|
-
className:
|
|
85
|
+
className: R(t.props.className, g?.trigger),
|
|
89
86
|
"aria-expanded": o,
|
|
90
87
|
"aria-haspopup": "dialog",
|
|
91
88
|
"aria-controls": o ? k : void 0
|
|
92
89
|
});
|
|
93
90
|
} else
|
|
94
|
-
|
|
91
|
+
N = /* @__PURE__ */ y(
|
|
95
92
|
"button",
|
|
96
93
|
{
|
|
97
94
|
ref: v,
|
|
98
95
|
type: "button",
|
|
99
|
-
className:
|
|
100
|
-
onClick:
|
|
96
|
+
className: R(L.trigger, g?.trigger),
|
|
97
|
+
onClick: q,
|
|
101
98
|
"aria-expanded": o,
|
|
102
99
|
"aria-haspopup": "dialog",
|
|
103
100
|
"aria-controls": o ? k : void 0,
|
|
104
101
|
children: a
|
|
105
102
|
}
|
|
106
103
|
);
|
|
107
|
-
return /* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ y(
|
|
108
105
|
"div",
|
|
109
106
|
{
|
|
110
|
-
ref:
|
|
111
|
-
className:
|
|
112
|
-
style:
|
|
113
|
-
children: /* @__PURE__ */
|
|
114
|
-
|
|
115
|
-
o && /* @__PURE__ */
|
|
107
|
+
ref: V,
|
|
108
|
+
className: R(L.root, g?.root, H),
|
|
109
|
+
style: T,
|
|
110
|
+
children: /* @__PURE__ */ K("div", { ref: Y, children: [
|
|
111
|
+
N,
|
|
112
|
+
o && /* @__PURE__ */ y(
|
|
116
113
|
"div",
|
|
117
114
|
{
|
|
118
115
|
ref: u,
|
|
119
116
|
id: k,
|
|
120
117
|
role: "dialog",
|
|
121
118
|
tabIndex: -1,
|
|
122
|
-
className:
|
|
119
|
+
className: R(L.popover, L[m ? D : n], g?.popover),
|
|
123
120
|
style: m ? {
|
|
124
|
-
"--crk-popover-shift-x": `${
|
|
125
|
-
"--crk-popover-shift-y": `${
|
|
121
|
+
"--crk-popover-shift-x": `${F}px`,
|
|
122
|
+
"--crk-popover-shift-y": `${G}px`
|
|
126
123
|
} : void 0,
|
|
127
|
-
children:
|
|
124
|
+
children: /* @__PURE__ */ y(ne, { value: J, children: l })
|
|
128
125
|
}
|
|
129
126
|
)
|
|
130
127
|
] })
|
|
@@ -132,7 +129,7 @@ const ne = J(
|
|
|
132
129
|
);
|
|
133
130
|
}
|
|
134
131
|
);
|
|
135
|
-
|
|
132
|
+
se.displayName = "Popover";
|
|
136
133
|
export {
|
|
137
|
-
|
|
134
|
+
se as Popover
|
|
138
135
|
};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { jsxs as N, jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { createPortal as
|
|
2
|
+
import { forwardRef as Y, useState as Z, useRef as L, useId as $, useEffect as q, useCallback as F } from "react";
|
|
3
|
+
import { createPortal as ee } from "react-dom";
|
|
4
4
|
import i from "clsx";
|
|
5
5
|
import t from "./SplitButton.module.scss.js";
|
|
6
6
|
import h from "../Button/Button.module.scss.js";
|
|
7
|
-
import {
|
|
8
|
-
import { usePortalPosition as
|
|
9
|
-
const
|
|
7
|
+
import { useEscapeLayer as te, EscapeLayerProvider as ne } from "../../hooks/useEscapeLayer.js";
|
|
8
|
+
import { usePortalPosition as re } from "../../hooks/usePortalPosition.js";
|
|
9
|
+
const oe = Y(
|
|
10
10
|
({
|
|
11
11
|
actions: g,
|
|
12
12
|
variant: b = "secondary",
|
|
13
|
-
size:
|
|
14
|
-
disabled:
|
|
13
|
+
size: S = "md",
|
|
14
|
+
disabled: O = !1,
|
|
15
15
|
align: v = "right",
|
|
16
|
-
portal:
|
|
17
|
-
menuLabel:
|
|
18
|
-
maxWidth:
|
|
19
|
-
className:
|
|
20
|
-
style:
|
|
21
|
-
id:
|
|
22
|
-
onOpen:
|
|
16
|
+
portal: y = !0,
|
|
17
|
+
menuLabel: G = "More actions",
|
|
18
|
+
maxWidth: k,
|
|
19
|
+
className: H,
|
|
20
|
+
style: w,
|
|
21
|
+
id: x,
|
|
22
|
+
onOpen: I,
|
|
23
23
|
onClose: c,
|
|
24
24
|
classes: s
|
|
25
|
-
},
|
|
26
|
-
const [n,
|
|
25
|
+
}, J) => {
|
|
26
|
+
const [n, E] = Z(!1), C = L(null), u = L(null), R = L(null), M = $();
|
|
27
27
|
q(() => {
|
|
28
28
|
n && u.current && u.current.querySelector('[role="menuitem"]:not([disabled])')?.focus();
|
|
29
29
|
}, [n]);
|
|
30
30
|
const f = F(() => {
|
|
31
|
-
|
|
32
|
-
}, [c]),
|
|
33
|
-
|
|
31
|
+
E(!1), c?.(), R.current?.focus();
|
|
32
|
+
}, [c]), K = F(() => {
|
|
33
|
+
E((e) => {
|
|
34
34
|
const l = !e;
|
|
35
|
-
return l ?
|
|
35
|
+
return l ? I?.() : c?.(), l;
|
|
36
36
|
});
|
|
37
|
-
}, [
|
|
37
|
+
}, [I, c]);
|
|
38
38
|
q(() => {
|
|
39
39
|
if (!n) return;
|
|
40
40
|
const e = (l) => {
|
|
@@ -42,27 +42,22 @@ const ne = X(
|
|
|
42
42
|
C.current?.contains(m) || u.current?.contains(m) || f();
|
|
43
43
|
};
|
|
44
44
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
45
|
-
}, [n, f])
|
|
46
|
-
|
|
47
|
-
Escape: () => f()
|
|
48
|
-
},
|
|
49
|
-
n
|
|
50
|
-
);
|
|
51
|
-
const d = te(C, n && k);
|
|
45
|
+
}, [n, f]);
|
|
46
|
+
const Q = te(f, n), d = re(C, n && y);
|
|
52
47
|
if (g.length === 0) return null;
|
|
53
|
-
const [o, ...
|
|
54
|
-
|
|
48
|
+
const [o, ...P] = g, a = P.length > 0, z = O || o.disabled, B = i(h.root, h[b], h[S]), T = b === "secondary" ? t.overlapOutline : b === "ghost" ? t.dividerSubtle : t.dividerOnFill, j = i(
|
|
49
|
+
B,
|
|
55
50
|
t.main,
|
|
56
51
|
a && t.mainAttached,
|
|
57
52
|
a && n && t.mainOpen,
|
|
58
53
|
s?.main
|
|
59
|
-
), p = (e) =>
|
|
54
|
+
), p = (e) => k !== void 0 && (typeof e == "string" || typeof e == "number") ? String(e) : void 0, D = /* @__PURE__ */ N("span", { className: t.mainContent, children: [
|
|
60
55
|
/* @__PURE__ */ r("span", { className: t.mainLabel, children: o.label }),
|
|
61
56
|
a && /* @__PURE__ */ r("span", { className: t.sizer, "aria-hidden": "true", children: g.map((e, l) => /* @__PURE__ */ r("span", { className: t.sizerItem, children: e.label }, l)) })
|
|
62
|
-
] }),
|
|
57
|
+
] }), U = o.href && !z ? /* @__PURE__ */ r(
|
|
63
58
|
"a",
|
|
64
59
|
{
|
|
65
|
-
id:
|
|
60
|
+
id: x,
|
|
66
61
|
className: j,
|
|
67
62
|
href: o.href,
|
|
68
63
|
target: o.target,
|
|
@@ -74,22 +69,22 @@ const ne = X(
|
|
|
74
69
|
) : /* @__PURE__ */ r(
|
|
75
70
|
"button",
|
|
76
71
|
{
|
|
77
|
-
id:
|
|
72
|
+
id: x,
|
|
78
73
|
type: "button",
|
|
79
74
|
className: j,
|
|
80
|
-
disabled:
|
|
75
|
+
disabled: z,
|
|
81
76
|
title: p(o.label),
|
|
82
77
|
onClick: o.onClick,
|
|
83
78
|
children: D
|
|
84
79
|
}
|
|
85
|
-
),
|
|
80
|
+
), V = P.map((e, l) => {
|
|
86
81
|
const m = i(
|
|
87
82
|
t.item,
|
|
88
83
|
e.disabled && t.itemDisabled,
|
|
89
84
|
e.danger && t.itemDanger,
|
|
90
85
|
s?.item
|
|
91
|
-
), _ = (
|
|
92
|
-
e.onClick?.(
|
|
86
|
+
), _ = (X) => {
|
|
87
|
+
e.onClick?.(X), f();
|
|
93
88
|
};
|
|
94
89
|
return e.href && !e.disabled ? /* @__PURE__ */ r(
|
|
95
90
|
"a",
|
|
@@ -117,51 +112,51 @@ const ne = X(
|
|
|
117
112
|
},
|
|
118
113
|
l
|
|
119
114
|
);
|
|
120
|
-
}),
|
|
115
|
+
}), W = { sm: t.menuSm, md: t.menuMd, lg: t.menuLg }[S], A = (e) => /* @__PURE__ */ r(
|
|
121
116
|
"div",
|
|
122
117
|
{
|
|
123
118
|
ref: u,
|
|
124
119
|
id: M,
|
|
125
120
|
className: i(
|
|
126
121
|
t.menu,
|
|
127
|
-
|
|
122
|
+
W,
|
|
128
123
|
n && t.menuOpen,
|
|
129
124
|
v === "left" ? t.alignLeft : t.alignRight,
|
|
130
125
|
s?.menu
|
|
131
126
|
),
|
|
132
127
|
style: e,
|
|
133
128
|
role: "menu",
|
|
134
|
-
children:
|
|
129
|
+
children: /* @__PURE__ */ r(ne, { value: Q, children: V })
|
|
135
130
|
}
|
|
136
131
|
);
|
|
137
132
|
return /* @__PURE__ */ N(
|
|
138
133
|
"div",
|
|
139
134
|
{
|
|
140
|
-
ref:
|
|
141
|
-
className: i(t.root, s?.root,
|
|
142
|
-
style:
|
|
135
|
+
ref: J,
|
|
136
|
+
className: i(t.root, s?.root, H),
|
|
137
|
+
style: k !== void 0 ? { maxWidth: k, ...w } : w,
|
|
143
138
|
children: [
|
|
144
139
|
/* @__PURE__ */ N("div", { ref: C, className: i(t.group, s?.group), children: [
|
|
145
|
-
|
|
140
|
+
U,
|
|
146
141
|
a && /* @__PURE__ */ r(
|
|
147
142
|
"button",
|
|
148
143
|
{
|
|
149
|
-
ref:
|
|
144
|
+
ref: R,
|
|
150
145
|
type: "button",
|
|
151
146
|
className: i(
|
|
152
|
-
|
|
147
|
+
B,
|
|
153
148
|
h.iconOnly,
|
|
154
149
|
t.toggle,
|
|
155
150
|
n && t.toggleOpen,
|
|
156
|
-
|
|
151
|
+
T,
|
|
157
152
|
s?.toggle
|
|
158
153
|
),
|
|
159
|
-
disabled:
|
|
160
|
-
onClick:
|
|
154
|
+
disabled: O,
|
|
155
|
+
onClick: K,
|
|
161
156
|
"aria-haspopup": "menu",
|
|
162
157
|
"aria-expanded": n,
|
|
163
158
|
"aria-controls": n ? M : void 0,
|
|
164
|
-
"aria-label":
|
|
159
|
+
"aria-label": G,
|
|
165
160
|
children: /* @__PURE__ */ r(
|
|
166
161
|
"svg",
|
|
167
162
|
{
|
|
@@ -174,8 +169,8 @@ const ne = X(
|
|
|
174
169
|
}
|
|
175
170
|
)
|
|
176
171
|
] }),
|
|
177
|
-
a && !
|
|
178
|
-
a &&
|
|
172
|
+
a && !y && A(),
|
|
173
|
+
a && y && n && typeof document < "u" && ee(
|
|
179
174
|
A({
|
|
180
175
|
position: "fixed",
|
|
181
176
|
top: d.top,
|
|
@@ -195,7 +190,7 @@ const ne = X(
|
|
|
195
190
|
);
|
|
196
191
|
}
|
|
197
192
|
);
|
|
198
|
-
|
|
193
|
+
oe.displayName = "SplitButton";
|
|
199
194
|
export {
|
|
200
|
-
|
|
195
|
+
oe as SplitButton
|
|
201
196
|
};
|
|
@@ -1,130 +1,136 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as ee, useState as
|
|
1
|
+
import { jsx as n, jsxs as F } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ee, useState as m, useRef as j, useMemo as y, useCallback as s } from "react";
|
|
3
3
|
import { createPortal as te } from "react-dom";
|
|
4
|
-
import
|
|
4
|
+
import D from "clsx";
|
|
5
5
|
import { useClickOutside as oe } from "../../../hooks/useClickOutside.js";
|
|
6
|
-
import { usePortalPosition as
|
|
6
|
+
import { usePortalPosition as ne } from "../../../hooks/usePortalPosition.js";
|
|
7
7
|
import t from "./DatePicker.module.scss.js";
|
|
8
|
-
import { CalendarPanel as
|
|
8
|
+
import { CalendarPanel as re } from "./CalendarPanel.js";
|
|
9
9
|
import { startOfMonth as V, startOfDay as l } from "./dateUtils.js";
|
|
10
10
|
const ae = ee(
|
|
11
11
|
({
|
|
12
|
-
value:
|
|
12
|
+
value: P,
|
|
13
13
|
defaultValue: q,
|
|
14
|
-
onChange:
|
|
15
|
-
min:
|
|
16
|
-
max:
|
|
17
|
-
disabledDate:
|
|
14
|
+
onChange: b,
|
|
15
|
+
min: v,
|
|
16
|
+
max: w,
|
|
17
|
+
disabledDate: O,
|
|
18
18
|
weekStartsOn: A = 0,
|
|
19
|
-
locale:
|
|
19
|
+
locale: h,
|
|
20
20
|
format: g,
|
|
21
21
|
placeholder: B = "Select date",
|
|
22
22
|
inputSize: L = "md",
|
|
23
|
-
error:
|
|
24
|
-
disabled:
|
|
23
|
+
error: K = !1,
|
|
24
|
+
disabled: r = !1,
|
|
25
25
|
portal: c = !0,
|
|
26
26
|
classes: a,
|
|
27
27
|
className: T,
|
|
28
28
|
style: W,
|
|
29
29
|
"aria-label": z
|
|
30
30
|
}, G) => {
|
|
31
|
-
const
|
|
32
|
-
() => g ?? ((e) => new Intl.DateTimeFormat(
|
|
33
|
-
[g,
|
|
34
|
-
),
|
|
35
|
-
(e) =>
|
|
36
|
-
[
|
|
37
|
-
),
|
|
31
|
+
const k = P !== void 0, [H, J] = m(q ?? null), o = k ? P ?? null : H, [i, f] = m(!1), [Q, M] = m(() => V(o ?? /* @__PURE__ */ new Date())), [U, N] = m(() => l(o ?? /* @__PURE__ */ new Date())), C = j(null), S = j(null), E = ne(C, i && c), X = y(() => l(/* @__PURE__ */ new Date()), []), Y = y(
|
|
32
|
+
() => g ?? ((e) => new Intl.DateTimeFormat(h, { year: "numeric", month: "short", day: "numeric" }).format(e)),
|
|
33
|
+
[g, h]
|
|
34
|
+
), u = y(() => v ? l(v) : void 0, [v]), p = y(() => w ? l(w) : void 0, [w]), Z = s(
|
|
35
|
+
(e) => u && e < u || p && e > p ? !0 : O?.(e) ?? !1,
|
|
36
|
+
[u, p, O]
|
|
37
|
+
), I = s(
|
|
38
38
|
(e) => {
|
|
39
|
-
|
|
39
|
+
k || J(e), b?.(e);
|
|
40
40
|
},
|
|
41
|
-
[
|
|
42
|
-
),
|
|
43
|
-
if (
|
|
41
|
+
[k, b]
|
|
42
|
+
), x = s(() => {
|
|
43
|
+
if (r) return;
|
|
44
44
|
const e = l(o ?? /* @__PURE__ */ new Date());
|
|
45
|
-
|
|
46
|
-
}, [
|
|
47
|
-
|
|
45
|
+
M(V(e)), N(e), f(!0);
|
|
46
|
+
}, [r, o]), d = s((e = !0) => {
|
|
47
|
+
f(!1), e && C.current?.querySelector("input")?.focus();
|
|
48
48
|
}, []), _ = s(
|
|
49
49
|
(e) => {
|
|
50
|
-
|
|
50
|
+
I(e), d();
|
|
51
51
|
},
|
|
52
|
-
[
|
|
52
|
+
[I, d]
|
|
53
53
|
);
|
|
54
|
-
oe(
|
|
54
|
+
oe(S, () => f(!1), i);
|
|
55
55
|
const $ = (e) => {
|
|
56
|
-
e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(),
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
56
|
+
e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), x()) : e.key === "Escape" && i && (e.preventDefault(), f(!1));
|
|
57
|
+
}, R = (
|
|
58
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
59
|
+
/* @__PURE__ */ n(
|
|
60
|
+
"div",
|
|
61
|
+
{
|
|
62
|
+
ref: S,
|
|
63
|
+
onKeyDown: (e) => {
|
|
64
|
+
e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), d());
|
|
65
|
+
},
|
|
66
|
+
className: D(t.popover, c && t.portalled, a?.popover),
|
|
67
|
+
style: c ? { position: "fixed", top: E.top + 4, left: E.left } : void 0,
|
|
68
|
+
role: "dialog",
|
|
69
|
+
"aria-modal": "false",
|
|
70
|
+
"aria-label": "Choose date",
|
|
71
|
+
children: /* @__PURE__ */ n(
|
|
72
|
+
re,
|
|
73
|
+
{
|
|
74
|
+
viewDate: Q,
|
|
75
|
+
focusedDate: U,
|
|
76
|
+
selected: o,
|
|
77
|
+
today: X,
|
|
78
|
+
minDay: u,
|
|
79
|
+
maxDay: p,
|
|
80
|
+
locale: h,
|
|
81
|
+
weekStartsOn: A,
|
|
82
|
+
isDisabledDay: Z,
|
|
83
|
+
onSelect: _,
|
|
84
|
+
onViewDateChange: M,
|
|
85
|
+
onFocusedDateChange: N,
|
|
86
|
+
onEscape: d,
|
|
87
|
+
classes: a
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
)
|
|
86
92
|
);
|
|
87
|
-
return /* @__PURE__ */
|
|
93
|
+
return /* @__PURE__ */ F(
|
|
88
94
|
"div",
|
|
89
95
|
{
|
|
90
|
-
ref:
|
|
91
|
-
className:
|
|
96
|
+
ref: C,
|
|
97
|
+
className: D(t.root, t[L], K && t.error, r && t.disabled, a?.root, T),
|
|
92
98
|
style: W,
|
|
93
99
|
children: [
|
|
94
|
-
/* @__PURE__ */
|
|
100
|
+
/* @__PURE__ */ n(
|
|
95
101
|
"input",
|
|
96
102
|
{
|
|
97
103
|
ref: G,
|
|
98
104
|
type: "text",
|
|
99
105
|
readOnly: !0,
|
|
100
|
-
className:
|
|
106
|
+
className: D(t.input, a?.input),
|
|
101
107
|
value: o ? Y(o) : "",
|
|
102
108
|
placeholder: B,
|
|
103
|
-
disabled:
|
|
109
|
+
disabled: r,
|
|
104
110
|
"aria-label": z,
|
|
105
111
|
"aria-haspopup": "dialog",
|
|
106
112
|
"aria-expanded": i,
|
|
107
|
-
"aria-invalid":
|
|
108
|
-
onClick:
|
|
113
|
+
"aria-invalid": K || void 0,
|
|
114
|
+
onClick: x,
|
|
109
115
|
onKeyDown: $
|
|
110
116
|
}
|
|
111
117
|
),
|
|
112
|
-
/* @__PURE__ */
|
|
118
|
+
/* @__PURE__ */ n(
|
|
113
119
|
"button",
|
|
114
120
|
{
|
|
115
121
|
type: "button",
|
|
116
122
|
tabIndex: -1,
|
|
117
|
-
className:
|
|
118
|
-
onClick:
|
|
119
|
-
disabled:
|
|
123
|
+
className: D(t.icon, a?.icon),
|
|
124
|
+
onClick: x,
|
|
125
|
+
disabled: r,
|
|
120
126
|
"aria-label": "Open calendar",
|
|
121
|
-
children: /* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
/* @__PURE__ */
|
|
127
|
+
children: /* @__PURE__ */ F("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5", "aria-hidden": "true", children: [
|
|
128
|
+
/* @__PURE__ */ n("rect", { x: "3", y: "4", width: "14", height: "13", rx: "2" }),
|
|
129
|
+
/* @__PURE__ */ n("path", { d: "M3 8h14M7 2v3M13 2v3", strokeLinecap: "round" })
|
|
124
130
|
] })
|
|
125
131
|
}
|
|
126
132
|
),
|
|
127
|
-
i && (c ? typeof document < "u" && te(
|
|
133
|
+
i && (c ? typeof document < "u" && te(R, document.body) : R)
|
|
128
134
|
]
|
|
129
135
|
}
|
|
130
136
|
);
|
|
@@ -85,7 +85,7 @@ const Ve = { hour: 0, minute: 0, second: 0 }, Le = Pe(
|
|
|
85
85
|
);
|
|
86
86
|
Ze(oe, () => C(!1), v);
|
|
87
87
|
const we = (e) => {
|
|
88
|
-
e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), x()) : e.key === "Escape" && v && C(!1);
|
|
88
|
+
e.key === "ArrowDown" || e.key === "Enter" ? (e.preventDefault(), x()) : e.key === "Escape" && v && (e.preventDefault(), C(!1));
|
|
89
89
|
}, be = (e) => {
|
|
90
90
|
e.key === "Escape" && !e.defaultPrevented && (e.preventDefault(), F());
|
|
91
91
|
}, re = (
|
|
@@ -188,7 +188,9 @@ const Ve = { hour: 0, minute: 0, second: 0 }, Le = Pe(
|
|
|
188
188
|
onChange: Te,
|
|
189
189
|
onClear: () => q(null),
|
|
190
190
|
onOpenRequest: x,
|
|
191
|
-
onEscape: () =>
|
|
191
|
+
onEscape: (e) => {
|
|
192
|
+
v && (e.preventDefault(), C(!1));
|
|
193
|
+
},
|
|
192
194
|
suffix: g,
|
|
193
195
|
suffixTitle: j,
|
|
194
196
|
suffixClassName: n?.timeZone,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KeyboardEvent } from 'react';
|
|
1
2
|
import { WallClock } from './timeZoneUtils';
|
|
2
3
|
export type SegmentType = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'dayPeriod';
|
|
3
4
|
export interface DateTimeSegmentsClasses {
|
|
@@ -24,7 +25,7 @@ export interface DateTimeSegmentsProps {
|
|
|
24
25
|
onClear: () => void;
|
|
25
26
|
/** Alt+ArrowDown — the user asked for the popover. */
|
|
26
27
|
onOpenRequest: () => void;
|
|
27
|
-
onEscape: () => void;
|
|
28
|
+
onEscape: (e: KeyboardEvent<HTMLElement>) => void;
|
|
28
29
|
/** Plain trailing label (the zone name) rendered after the last segment. */
|
|
29
30
|
suffix?: string | null;
|
|
30
31
|
suffixTitle?: string;
|