@spear-ai/spectral 1.9.0 → 1.9.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/dist/DateTimePicker/DateTimeDisplayInput.js +53 -52
- package/dist/DateTimePicker/DateTimeInput.d.ts +5 -3
- package/dist/DateTimePicker/DateTimeInput.js +122 -69
- package/dist/Icons/IconBase.d.ts +1 -1
- package/dist/Icons/IconBase.js +63 -20
- package/dist/primitives/popover.d.ts.map +1 -1
- package/dist/primitives/popover.js +4 -1
- package/package.json +1 -1
|
@@ -15,8 +15,8 @@ const v = {
|
|
|
15
15
|
hour24: { type: "hour", min: 0, max: 23, length: 2 },
|
|
16
16
|
minute: { type: "minute", min: 0, max: 59, length: 2 },
|
|
17
17
|
period: { type: "period", min: 0, max: 1, length: 2 }
|
|
18
|
-
}, ue = (k, e) => k === 2 ? e % 4 === 0 && e % 100 !== 0 || e % 400 === 0 ? 29 : 28 : [4, 6, 9, 11].includes(k) ? 30 : 31, ce = ({ ariaLabel: k, config: e, disabled: y, onLeftFocus:
|
|
19
|
-
const
|
|
18
|
+
}, ue = (k, e) => k === 2 ? e % 4 === 0 && e % 100 !== 0 || e % 400 === 0 ? 29 : 28 : [4, 6, 9, 11].includes(k) ? 30 : 31, ce = ({ ariaLabel: k, config: e, disabled: y, onLeftFocus: I, onRightFocus: m, onValueChange: u, periodLabels: h, value: s }) => {
|
|
19
|
+
const o = E(null), a = E(""), c = E(!1), M = D(() => {
|
|
20
20
|
switch (e.type) {
|
|
21
21
|
case "month":
|
|
22
22
|
return "MM";
|
|
@@ -33,18 +33,18 @@ const v = {
|
|
|
33
33
|
default:
|
|
34
34
|
return "––";
|
|
35
35
|
}
|
|
36
|
-
}, [e.type, e.max, h]), d = D(() => s === void 0 ?
|
|
36
|
+
}, [e.type, e.max, h]), d = D(() => s === void 0 ? M : e.type === "period" ? (s === 0 ? h?.am ?? "am" : h?.pm ?? "pm").toLowerCase() : s.toString().padStart(e.length, "0"), [s, e, h, M]);
|
|
37
37
|
oe(() => {
|
|
38
|
-
|
|
38
|
+
o.current && !c.current && (o.current.value = d);
|
|
39
39
|
}, [d]);
|
|
40
40
|
const x = w(() => {
|
|
41
41
|
const t = a.current;
|
|
42
42
|
if (t) {
|
|
43
43
|
let r = parseInt(t, 10);
|
|
44
|
-
isNaN(r) || (r = Math.max(e.min, Math.min(e.max, r)),
|
|
44
|
+
isNaN(r) || (r = Math.max(e.min, Math.min(e.max, r)), u(r));
|
|
45
45
|
}
|
|
46
|
-
a.current = "", c.current = !1,
|
|
47
|
-
}, [e.min, e.max, d,
|
|
46
|
+
a.current = "", c.current = !1, o.current && (o.current.value = d);
|
|
47
|
+
}, [e.min, e.max, d, u]), R = w(
|
|
48
48
|
(t) => {
|
|
49
49
|
if (!y) {
|
|
50
50
|
if (t.key === "Tab") {
|
|
@@ -56,31 +56,31 @@ const v = {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
if (t.key === "ArrowLeft") {
|
|
59
|
-
t.preventDefault(), x(),
|
|
59
|
+
t.preventDefault(), x(), I?.();
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
if (e.type === "period") {
|
|
63
|
-
t.preventDefault(), t.key === "ArrowUp" || t.key === "ArrowDown" ?
|
|
63
|
+
t.preventDefault(), t.key === "ArrowUp" || t.key === "ArrowDown" ? u(s === 0 ? 1 : 0) : t.key.toLowerCase() === "a" ? u(0) : t.key.toLowerCase() === "p" && u(1);
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
if (t.key === "ArrowUp") {
|
|
67
67
|
t.preventDefault(), a.current = "", c.current = !1;
|
|
68
68
|
const r = s === void 0 || s >= e.max ? e.min : s + 1;
|
|
69
|
-
|
|
69
|
+
u(r);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
if (t.key === "ArrowDown") {
|
|
73
73
|
t.preventDefault(), a.current = "", c.current = !1;
|
|
74
74
|
const r = s === void 0 || s <= e.min ? e.max : s - 1;
|
|
75
|
-
|
|
75
|
+
u(r);
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
78
|
if (t.key === "Home") {
|
|
79
|
-
t.preventDefault(), a.current = "", c.current = !1,
|
|
79
|
+
t.preventDefault(), a.current = "", c.current = !1, u(e.min);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
if (t.key === "End") {
|
|
83
|
-
t.preventDefault(), a.current = "", c.current = !1,
|
|
83
|
+
t.preventDefault(), a.current = "", c.current = !1, u(e.max);
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
if (t.key >= "0" && t.key <= "9") {
|
|
@@ -89,38 +89,39 @@ const v = {
|
|
|
89
89
|
if (e.length === 2)
|
|
90
90
|
if (r.length >= 2) {
|
|
91
91
|
const L = Math.max(e.min, Math.min(e.max, l));
|
|
92
|
-
a.current = "", c.current = !1,
|
|
92
|
+
a.current = "", c.current = !1, u(L), m?.();
|
|
93
93
|
} else if (l * 10 > e.max) {
|
|
94
94
|
const L = Math.max(e.min, Math.min(e.max, l));
|
|
95
|
-
a.current = "", c.current = !1,
|
|
95
|
+
a.current = "", c.current = !1, u(L), m?.();
|
|
96
96
|
} else
|
|
97
|
-
a.current = r, c.current = !0,
|
|
97
|
+
a.current = r, c.current = !0, o.current && (o.current.value = r);
|
|
98
98
|
else if (e.length === 4)
|
|
99
99
|
if (r.length >= 4) {
|
|
100
100
|
const L = Math.max(e.min, Math.min(e.max, l));
|
|
101
|
-
a.current = "", c.current = !1,
|
|
101
|
+
a.current = "", c.current = !1, u(L), m?.();
|
|
102
102
|
} else
|
|
103
|
-
a.current = r, c.current = !0,
|
|
103
|
+
a.current = r, c.current = !0, o.current && (o.current.value = r);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
if (t.key === "Backspace"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
if (t.key === "Backspace")
|
|
107
|
+
if (t.preventDefault(), a.current) {
|
|
108
|
+
const r = a.current.slice(0, -1);
|
|
109
|
+
a.current = r, c.current = r.length > 0, o.current && (o.current.value = r || d);
|
|
110
|
+
} else s !== void 0 && (a.current = "", c.current = !0, u(e.min), o.current && (o.current.value = M));
|
|
110
111
|
}
|
|
111
112
|
},
|
|
112
|
-
[y, e, s, d,
|
|
113
|
+
[y, e, s, d, M, u, I, m, x]
|
|
113
114
|
), T = w(() => {
|
|
114
115
|
a.current && x();
|
|
115
|
-
}, [x]),
|
|
116
|
+
}, [x]), S = w(() => {
|
|
116
117
|
c.current || (a.current = "");
|
|
117
|
-
const t =
|
|
118
|
+
const t = o.current;
|
|
118
119
|
if (t) {
|
|
119
120
|
const r = t.value.length;
|
|
120
121
|
t.setSelectionRange(r, r);
|
|
121
122
|
}
|
|
122
123
|
}, []), Y = w(() => {
|
|
123
|
-
|
|
124
|
+
o.current && (o.current.value = a.current || d);
|
|
124
125
|
}, [d]), H = w(() => {
|
|
125
126
|
switch (e.type) {
|
|
126
127
|
case "year":
|
|
@@ -138,7 +139,7 @@ const v = {
|
|
|
138
139
|
default:
|
|
139
140
|
return { width: 24, paddingLeft: 0 };
|
|
140
141
|
}
|
|
141
|
-
}, [e.type]), p = D(() => H(), [H]),
|
|
142
|
+
}, [e.type]), p = D(() => H(), [H]), g = D(() => s === void 0, [s]);
|
|
142
143
|
return /* @__PURE__ */ b(
|
|
143
144
|
"input",
|
|
144
145
|
{
|
|
@@ -152,7 +153,7 @@ const v = {
|
|
|
152
153
|
"focus:bg-bg-tertiary focus:text-text-primary focus:ring-accent focus:ring-1",
|
|
153
154
|
"hover:bg-bg-secondary",
|
|
154
155
|
y && "cursor-not-allowed opacity-50",
|
|
155
|
-
|
|
156
|
+
g && "text-text-placeholder text-sm"
|
|
156
157
|
),
|
|
157
158
|
"data-segment": e.type,
|
|
158
159
|
defaultValue: d,
|
|
@@ -160,9 +161,9 @@ const v = {
|
|
|
160
161
|
inputMode: "numeric",
|
|
161
162
|
onBlur: T,
|
|
162
163
|
onChange: Y,
|
|
163
|
-
onFocus:
|
|
164
|
+
onFocus: S,
|
|
164
165
|
onKeyDown: R,
|
|
165
|
-
ref:
|
|
166
|
+
ref: o,
|
|
166
167
|
role: "spinbutton",
|
|
167
168
|
style: p,
|
|
168
169
|
tabIndex: y ? -1 : 0
|
|
@@ -173,21 +174,21 @@ const v = {
|
|
|
173
174
|
className: k,
|
|
174
175
|
defaultValue: e,
|
|
175
176
|
disabled: y,
|
|
176
|
-
endIcon:
|
|
177
|
+
endIcon: I,
|
|
177
178
|
hourFormat: m = "12",
|
|
178
|
-
id:
|
|
179
|
+
id: u,
|
|
179
180
|
label: h,
|
|
180
181
|
locale: s,
|
|
181
|
-
onChange:
|
|
182
|
+
onChange: o,
|
|
182
183
|
showTime: a = !0,
|
|
183
184
|
state: c = "default",
|
|
184
|
-
value:
|
|
185
|
+
value: M,
|
|
185
186
|
// Legacy props (deprecated)
|
|
186
187
|
date: d,
|
|
187
188
|
onDateChange: x,
|
|
188
189
|
...R
|
|
189
190
|
}, T) => {
|
|
190
|
-
const
|
|
191
|
+
const S = E(null), Y = M ?? d, H = o ?? x, [p, g] = ae({
|
|
191
192
|
defaultValue: e,
|
|
192
193
|
onChange: H,
|
|
193
194
|
value: Y
|
|
@@ -207,21 +208,21 @@ const v = {
|
|
|
207
208
|
(i) => {
|
|
208
209
|
const n = { ...l, ...i };
|
|
209
210
|
if (n.month === void 0 && n.day === void 0 && n.year === void 0) {
|
|
210
|
-
|
|
211
|
+
g(void 0);
|
|
211
212
|
return;
|
|
212
213
|
}
|
|
213
|
-
const f = /* @__PURE__ */ new Date(), A = (n.month ?? f.getMonth() + 1) - 1, P = n.day ?? f.getDate(),
|
|
214
|
-
let
|
|
214
|
+
const f = /* @__PURE__ */ new Date(), A = (n.month ?? f.getMonth() + 1) - 1, P = n.day ?? f.getDate(), N = n.year ?? f.getFullYear(), j = ue(A + 1, N), G = Math.min(P, j), W = l.month !== void 0 && l.day !== void 0 && l.year !== void 0, X = n.month !== void 0 && n.day !== void 0 && n.year !== void 0, B = !W && X;
|
|
215
|
+
let C;
|
|
215
216
|
if (m === "24")
|
|
216
|
-
|
|
217
|
+
C = B ? 0 : n.hour ?? 0;
|
|
217
218
|
else {
|
|
218
|
-
const F =
|
|
219
|
-
K === 12 ?
|
|
219
|
+
const F = B ? 12 : n.hour ?? 12, V = B ? 1 : n.period ?? 0, K = F, J = V;
|
|
220
|
+
K === 12 ? C = J === 0 ? 0 : 12 : C = J === 0 ? K : K + 12;
|
|
220
221
|
}
|
|
221
|
-
const Z =
|
|
222
|
-
|
|
222
|
+
const Z = B ? 0 : n.minute ?? 0, $ = new Date(N, A, G, C, Z, 0, 0);
|
|
223
|
+
g($);
|
|
223
224
|
},
|
|
224
|
-
[l, m,
|
|
225
|
+
[l, m, g]
|
|
225
226
|
), q = D(() => {
|
|
226
227
|
const i = [
|
|
227
228
|
{ key: "month", config: v.month, ariaLabel: "Month" },
|
|
@@ -239,15 +240,15 @@ const v = {
|
|
|
239
240
|
];
|
|
240
241
|
return [...i, ...n];
|
|
241
242
|
}, [a, m, r]), z = w((i) => {
|
|
242
|
-
|
|
243
|
+
S.current?.querySelectorAll("[role='spinbutton']")[i]?.focus();
|
|
243
244
|
}, []), Q = U(ie(c, k));
|
|
244
245
|
return /* @__PURE__ */ O("div", { className: "flex flex-col gap-1.5", children: [
|
|
245
|
-
h && /* @__PURE__ */ b(ne, { className: "text-text-primary text-sm font-medium", htmlFor:
|
|
246
|
-
/* @__PURE__ */ O("div", { className: U(Q, "relative", (y ?? c === "disabled") && "cursor-not-allowed", k), "data-slot": "datetime-display-input", id:
|
|
247
|
-
/* @__PURE__ */ b("div", { className: "flex items-center", ref:
|
|
248
|
-
const f = ["month", "day", "year"].includes(i.key), A = ["hour", "minute", "period"].includes(i.key), P = i.key === "year",
|
|
246
|
+
h && /* @__PURE__ */ b(ne, { className: "text-text-primary text-sm font-medium", htmlFor: u, children: h }),
|
|
247
|
+
/* @__PURE__ */ O("div", { className: U(Q, "relative", (y ?? c === "disabled") && "cursor-not-allowed", k), "data-slot": "datetime-display-input", id: u ?? "datetime-display-input", ref: T ?? S, ...R, children: [
|
|
248
|
+
/* @__PURE__ */ b("div", { className: "flex items-center", ref: S, children: q.map((i, n) => {
|
|
249
|
+
const f = ["month", "day", "year"].includes(i.key), A = ["hour", "minute", "period"].includes(i.key), P = i.key === "year", N = i.key === "hour", j = y ?? (A && !L);
|
|
249
250
|
return /* @__PURE__ */ O("span", { className: "flex items-center", children: [
|
|
250
|
-
|
|
251
|
+
N && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: ", " }),
|
|
251
252
|
/* @__PURE__ */ b(
|
|
252
253
|
ce,
|
|
253
254
|
{
|
|
@@ -262,10 +263,10 @@ const v = {
|
|
|
262
263
|
}
|
|
263
264
|
),
|
|
264
265
|
f && !P && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-text-secondary select-none", children: "/" }),
|
|
265
|
-
|
|
266
|
+
N && /* @__PURE__ */ b("span", { "aria-hidden": "true", className: "text-inherit select-none", children: ":" })
|
|
266
267
|
] }, i.key);
|
|
267
268
|
}) }),
|
|
268
|
-
|
|
269
|
+
I
|
|
269
270
|
] })
|
|
270
271
|
] });
|
|
271
272
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Period, TimePickerTranslations, TimePickerType } from './DateTimeUtils';
|
|
2
|
-
import { ComponentProps } from 'react';
|
|
3
|
-
export interface DateTimeInputProps extends Omit<ComponentProps<'input'>, 'onChange'> {
|
|
2
|
+
import { ComponentProps, Ref } from 'react';
|
|
3
|
+
export interface DateTimeInputProps extends Omit<ComponentProps<'input'>, 'onChange' | 'type'> {
|
|
4
4
|
date: Date | undefined;
|
|
5
5
|
/** Locale for number formatting */
|
|
6
6
|
locale?: string;
|
|
@@ -13,7 +13,9 @@ export interface DateTimeInputProps extends Omit<ComponentProps<'input'>, 'onCha
|
|
|
13
13
|
translations?: TimePickerTranslations;
|
|
14
14
|
}
|
|
15
15
|
export declare const DateTimeInput: {
|
|
16
|
-
({ className, date, disabled, id, locale, name, onKeyDown, onLeftFocus, onRightFocus, period, picker, setDate, translations, ...props }: DateTimeInputProps
|
|
16
|
+
({ className, date, disabled, id, locale, name, onKeyDown, onLeftFocus, onRightFocus, period, picker, ref, setDate, translations, ...props }: DateTimeInputProps & {
|
|
17
|
+
ref?: Ref<HTMLInputElement>;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
19
|
displayName: string;
|
|
18
20
|
};
|
|
19
21
|
//# sourceMappingURL=DateTimeInput.d.ts.map
|
|
@@ -1,91 +1,144 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { getResolvedLocale as
|
|
5
|
-
import { Input as
|
|
6
|
-
import { cn as
|
|
7
|
-
import {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
4
|
+
import { getResolvedLocale as P, getAriaValueMinMax as _, getDateByType as $, formatTimeNumber as v, getAriaValueNow as k, getAriaLabel as q, DEFAULT_TRANSLATIONS as z, setDateByType as x, getArrowByType as G } from "./DateTimeUtils.js";
|
|
5
|
+
import { Input as J } from "../primitives/input.js";
|
|
6
|
+
import { cn as Q } from "../utils/twUtils.js";
|
|
7
|
+
import { useRef as V, useMemo as y, useEffect as W, useCallback as M } from "react";
|
|
8
|
+
const X = (...N) => (m) => {
|
|
9
|
+
N.forEach((p) => {
|
|
10
|
+
p && (typeof p == "function" ? p(m) : p.current = m);
|
|
11
|
+
});
|
|
12
|
+
}, Y = ({ className: N, date: m, disabled: p, id: B, locale: A, name: b, onKeyDown: R, onLeftFocus: I, onRightFocus: g, period: w, picker: r, ref: E, setDate: D, translations: T = z, ...L }) => {
|
|
13
|
+
const o = V(null), H = X(o, E), n = V(""), i = V(!1), d = y(() => P(A), [A]), s = y(() => {
|
|
14
|
+
if (m) return m;
|
|
11
15
|
const t = /* @__PURE__ */ new Date();
|
|
12
16
|
return t.setHours(0, 0, 0, 0), t;
|
|
13
|
-
}, [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"aria-
|
|
17
|
-
"aria-
|
|
18
|
-
"aria-
|
|
19
|
-
"aria-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, q);
|
|
28
|
-
return () => clearTimeout(t);
|
|
29
|
-
}, [n]);
|
|
30
|
-
const I = N(
|
|
31
|
-
(t) => e === "12hours" && n && r.startsWith("1") && v === "0" ? `0${t}` : n ? `${r[1]}${t}` : `0${t}`,
|
|
32
|
-
[e, n, r, v]
|
|
33
|
-
), h = N(
|
|
17
|
+
}, [m]), { min: u, max: c } = y(() => _(r), [r]), h = y(() => $(s, r), [s, r]), f = y(() => v(parseInt(h, 10), d), [h, d]), U = y(
|
|
18
|
+
() => ({
|
|
19
|
+
"aria-label": q(r, T),
|
|
20
|
+
"aria-valuemin": u,
|
|
21
|
+
"aria-valuemax": c,
|
|
22
|
+
"aria-valuenow": k(s, r),
|
|
23
|
+
"aria-valuetext": f
|
|
24
|
+
}),
|
|
25
|
+
[s, r, f, T, u, c]
|
|
26
|
+
);
|
|
27
|
+
W(() => {
|
|
28
|
+
o.current && !i.current && (o.current.value = f);
|
|
29
|
+
}, [f]);
|
|
30
|
+
const l = M(
|
|
34
31
|
(t) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return;
|
|
32
|
+
n.current = "", i.current = !1;
|
|
33
|
+
const e = new Date(s);
|
|
34
|
+
D(x(e, r, t, w));
|
|
35
|
+
},
|
|
36
|
+
[s, r, w, D]
|
|
37
|
+
), K = M(
|
|
38
|
+
(t) => {
|
|
39
|
+
if (t.key === "Tab") {
|
|
40
|
+
if (n.current) {
|
|
41
|
+
const e = parseInt(n.current, 10);
|
|
42
|
+
if (!isNaN(e)) {
|
|
43
|
+
const a = Math.max(u, Math.min(c, e));
|
|
44
|
+
l(a.toString().padStart(2, "0"));
|
|
45
|
+
}
|
|
50
46
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (t.key === "ArrowRight") {
|
|
50
|
+
if (t.preventDefault(), n.current) {
|
|
51
|
+
const e = parseInt(n.current, 10);
|
|
52
|
+
if (!isNaN(e)) {
|
|
53
|
+
const a = Math.max(u, Math.min(c, e));
|
|
54
|
+
l(a.toString().padStart(2, "0"));
|
|
55
|
+
}
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
g?.();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (t.key === "ArrowLeft") {
|
|
61
|
+
if (t.preventDefault(), n.current) {
|
|
62
|
+
const e = parseInt(n.current, 10);
|
|
63
|
+
if (!isNaN(e)) {
|
|
64
|
+
const a = Math.max(u, Math.min(c, e));
|
|
65
|
+
l(a.toString().padStart(2, "0"));
|
|
66
|
+
}
|
|
62
67
|
}
|
|
68
|
+
I?.();
|
|
69
|
+
return;
|
|
63
70
|
}
|
|
71
|
+
if (t.key === "ArrowUp" || t.key === "ArrowDown") {
|
|
72
|
+
t.preventDefault(), n.current = "", i.current = !1;
|
|
73
|
+
const e = t.key === "ArrowUp" ? 1 : -1, a = G(e, r, h), S = new Date(s);
|
|
74
|
+
D(x(S, r, a, w));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (t.key === "Home" || t.key === "End") {
|
|
78
|
+
t.preventDefault(), n.current = "", i.current = !1;
|
|
79
|
+
const e = (t.key === "Home" ? u : c).toString().padStart(2, "0"), a = new Date(s);
|
|
80
|
+
D(x(a, r, e, w));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (t.key >= "0" && t.key <= "9") {
|
|
84
|
+
t.preventDefault();
|
|
85
|
+
const e = n.current + t.key, a = parseInt(e, 10);
|
|
86
|
+
if (e.length >= 2) {
|
|
87
|
+
const S = Math.max(u, Math.min(c, a));
|
|
88
|
+
l(S.toString().padStart(2, "0")), g?.();
|
|
89
|
+
} else if (a * 10 > c) {
|
|
90
|
+
const S = Math.max(u, Math.min(c, a));
|
|
91
|
+
l(S.toString().padStart(2, "0")), g?.();
|
|
92
|
+
} else
|
|
93
|
+
n.current = e, i.current = !0, o.current && (o.current.value = v(a, d));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (t.key === "Backspace")
|
|
97
|
+
if (t.preventDefault(), n.current) {
|
|
98
|
+
const e = n.current.slice(0, -1);
|
|
99
|
+
n.current = e, i.current = e.length > 0, o.current && (o.current.value = e ? v(parseInt(e, 10), d) : f);
|
|
100
|
+
} else
|
|
101
|
+
n.current = "", l(u.toString().padStart(2, "0")), o.current && (o.current.value = v(u, d));
|
|
64
102
|
},
|
|
65
|
-
[
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
103
|
+
[h, s, u, c, I, g, w, r, D, l, f, d]
|
|
104
|
+
), O = M(() => {
|
|
105
|
+
i.current || (n.current = "");
|
|
106
|
+
}, []), j = M(() => {
|
|
107
|
+
if (n.current) {
|
|
108
|
+
const t = parseInt(n.current, 10);
|
|
109
|
+
if (isNaN(t))
|
|
110
|
+
n.current = "", i.current = !1;
|
|
111
|
+
else {
|
|
112
|
+
const e = Math.max(u, Math.min(c, t));
|
|
113
|
+
l(e.toString().padStart(2, "0"));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, [u, c, l]);
|
|
117
|
+
return /* @__PURE__ */ C(
|
|
118
|
+
J,
|
|
69
119
|
{
|
|
70
|
-
className:
|
|
120
|
+
className: Q("text-center tabular-nums", N),
|
|
71
121
|
"data-slot": "datetime-input",
|
|
72
|
-
"data-testid": `spectral-datetime-input-${
|
|
73
|
-
|
|
74
|
-
|
|
122
|
+
"data-testid": `spectral-datetime-input-${r}`,
|
|
123
|
+
defaultValue: f,
|
|
124
|
+
disabled: p,
|
|
125
|
+
id: B ?? r,
|
|
75
126
|
inputMode: "numeric",
|
|
76
|
-
name:
|
|
127
|
+
name: b ?? r,
|
|
128
|
+
onBlur: j,
|
|
129
|
+
onFocus: O,
|
|
77
130
|
onKeyDown: (t) => {
|
|
78
|
-
|
|
131
|
+
R?.(t), K(t);
|
|
79
132
|
},
|
|
80
133
|
readOnly: !0,
|
|
134
|
+
ref: H,
|
|
81
135
|
role: "spinbutton",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
...M
|
|
136
|
+
...U,
|
|
137
|
+
...L
|
|
85
138
|
}
|
|
86
139
|
);
|
|
87
140
|
};
|
|
88
|
-
|
|
141
|
+
Y.displayName = "DateTimeInput";
|
|
89
142
|
export {
|
|
90
|
-
|
|
143
|
+
Y as DateTimeInput
|
|
91
144
|
};
|
package/dist/Icons/IconBase.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface IconBaseProps extends Omit<IconProps, 'strokeWidth'>, ComponentPropsWi
|
|
|
9
9
|
title?: string;
|
|
10
10
|
color?: string;
|
|
11
11
|
}
|
|
12
|
-
declare const IconBase: ({ ref, children, title, size, ariaHidden, description, className, disabled, ...rest }: IconBaseProps & {
|
|
12
|
+
declare const IconBase: ({ ref, children, title, size, ariaHidden, description, className, disabled, onClick, onKeyDown, role, tabIndex, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...rest }: IconBaseProps & {
|
|
13
13
|
ref?: Ref<SVGSVGElement>;
|
|
14
14
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
export default IconBase;
|
package/dist/Icons/IconBase.js
CHANGED
|
@@ -1,26 +1,69 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import { jsxs as
|
|
4
|
-
import { createContext as
|
|
5
|
-
const
|
|
6
|
-
ref:
|
|
7
|
-
children:
|
|
8
|
-
title:
|
|
9
|
-
size:
|
|
10
|
-
ariaHidden:
|
|
11
|
-
description:
|
|
12
|
-
className:
|
|
13
|
-
disabled:
|
|
14
|
-
|
|
3
|
+
import { jsxs as _, jsx as u } from "react/jsx-runtime";
|
|
4
|
+
import { createContext as D, useId as O, useCallback as w } from "react";
|
|
5
|
+
const P = D(""), S = function({
|
|
6
|
+
ref: x,
|
|
7
|
+
children: g,
|
|
8
|
+
title: c,
|
|
9
|
+
size: b = 24,
|
|
10
|
+
ariaHidden: p = !0,
|
|
11
|
+
description: s,
|
|
12
|
+
className: B,
|
|
13
|
+
disabled: n,
|
|
14
|
+
onClick: i,
|
|
15
|
+
onKeyDown: l,
|
|
16
|
+
role: y,
|
|
17
|
+
tabIndex: k,
|
|
18
|
+
"aria-label": h,
|
|
19
|
+
"aria-labelledby": f,
|
|
20
|
+
...E
|
|
15
21
|
}) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
const r = O(), t = i !== void 0, o = t && !n, d = c !== void 0 || !!h || !!f;
|
|
23
|
+
process.env.NODE_ENV !== "production" && t && !d && console.warn("IconBase: an onClick handler was provided without an accessible name (title, aria-label, or aria-labelledby). Interactive icons must have an accessible name. The icon will be hidden from the accessibility tree.");
|
|
24
|
+
const v = t && !d, a = (d || t) && !v ? !1 : p, A = y ?? (t && !v ? "button" : "img"), C = k ?? (o && !v ? 0 : void 0), j = w(
|
|
25
|
+
(e) => {
|
|
26
|
+
l?.(e), !e.defaultPrevented && o && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.currentTarget.dispatchEvent(new MouseEvent("click", { bubbles: !0, cancelable: !0 })));
|
|
27
|
+
},
|
|
28
|
+
[o, l]
|
|
29
|
+
), N = w(
|
|
30
|
+
(e) => {
|
|
31
|
+
n || i?.(e);
|
|
32
|
+
},
|
|
33
|
+
[n, i]
|
|
34
|
+
), m = !a && c ? `${r}_title` : "", I = !a && s ? `${r}_desc` : "", T = [m, I].filter(Boolean).join(" ") || void 0;
|
|
35
|
+
return (
|
|
36
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions -- role is dynamic: 'button' when interactive, 'img' otherwise
|
|
37
|
+
/* @__PURE__ */ _(
|
|
38
|
+
"svg",
|
|
39
|
+
{
|
|
40
|
+
...E,
|
|
41
|
+
"aria-disabled": n && t ? !0 : void 0,
|
|
42
|
+
"aria-hidden": a,
|
|
43
|
+
"aria-label": h,
|
|
44
|
+
"aria-labelledby": f ?? T,
|
|
45
|
+
className: B,
|
|
46
|
+
"data-disabled": n,
|
|
47
|
+
fill: "none",
|
|
48
|
+
height: b,
|
|
49
|
+
onClick: i ? N : void 0,
|
|
50
|
+
onKeyDown: o || l ? j : void 0,
|
|
51
|
+
ref: x,
|
|
52
|
+
role: A,
|
|
53
|
+
tabIndex: C,
|
|
54
|
+
viewBox: "0 0 24 24",
|
|
55
|
+
width: b,
|
|
56
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
57
|
+
children: [
|
|
58
|
+
!a && c && /* @__PURE__ */ u("title", { id: m, children: c }),
|
|
59
|
+
!a && s && /* @__PURE__ */ u("desc", { id: I, children: s }),
|
|
60
|
+
/* @__PURE__ */ u(P.Provider, { value: r, children: g })
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
);
|
|
22
65
|
};
|
|
23
66
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
67
|
+
P as SvgIdContext,
|
|
68
|
+
S as default
|
|
26
69
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/primitives/popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,OAAO,CAAA;AAErD,eAAO,MAAM,OAAO,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,4CAE3F,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAErG,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,4CAA2D,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAelJ,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,MAAM,CAAC,4CAEnG,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,yBAAyB,wBAAwB,CAAC,KAAK,CAAC,4CAErF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,yBAAyB,wBAAwB,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../src/primitives/popover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,yBAAyB,CAAA;AAE3D,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,OAAO,CAAA;AAErD,eAAO,MAAM,OAAO,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,IAAI,CAAC,4CAE3F,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAErG,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,4CAA2D,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,OAAO,CAAC,4CAelJ,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,cAAc,wBAAwB,CAAC,OAAO,gBAAgB,CAAC,MAAM,CAAC,4CAEnG,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,yBAAyB,wBAAwB,CAAC,KAAK,CAAC,4CAErF,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,yBAAyB,wBAAwB,CAAC,IAAI,CAAC,4CAKnF,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,yBAAyB,wBAAwB,CAAC,GAAG,CAAC,4CAExF,CAAA"}
|
|
@@ -14,7 +14,10 @@ const v = ({ ...o }) => /* @__PURE__ */ t(s, { "data-slot": "popover", ...o }),
|
|
|
14
14
|
),
|
|
15
15
|
...n
|
|
16
16
|
}
|
|
17
|
-
) }), x = ({ ...o }) => /* @__PURE__ */ t(i, { "data-slot": "popover-anchor", ...o }), P = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { "data-slot": "popover-header", className: a("flex flex-col gap-0.5 text-sm", o), ...e }), N = ({ className: o, ...e }) =>
|
|
17
|
+
) }), x = ({ ...o }) => /* @__PURE__ */ t(i, { "data-slot": "popover-anchor", ...o }), P = ({ className: o, ...e }) => /* @__PURE__ */ t("div", { "data-slot": "popover-header", className: a("flex flex-col gap-0.5 text-sm", o), ...e }), N = ({ className: o, ...e }) => (
|
|
18
|
+
// eslint-disable-next-line jsx-a11y/heading-has-content -- content provided via {...props}
|
|
19
|
+
/* @__PURE__ */ t("h2", { "data-slot": "popover-title", className: a("cn-font-heading font-medium", o), ...e })
|
|
20
|
+
), T = ({ className: o, ...e }) => /* @__PURE__ */ t("p", { "data-slot": "popover-description", className: a("text-muted-foreground", o), ...e });
|
|
18
21
|
export {
|
|
19
22
|
v as Popover,
|
|
20
23
|
x as PopoverAnchor,
|