@spear-ai/spectral 1.8.9 → 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/.js +214 -210
- package/dist/Accordion.js +4 -4
- package/dist/Combobox/ComboboxBase.d.ts +8 -0
- package/dist/Combobox/ComboboxBase.js +80 -0
- package/dist/Combobox.d.ts +20 -0
- package/dist/Combobox.js +175 -0
- package/dist/ComboboxBase-CxNxYtdT.js +408 -0
- package/dist/ControlGroup/ControlGroupSelect.d.ts +33 -0
- package/dist/ControlGroup/ControlGroupSelect.js +104 -0
- package/dist/ControlGroup.d.ts +24 -0
- package/dist/ControlGroup.js +51 -0
- package/dist/DateTimePicker/DateTimeDisplayInput.js +53 -52
- package/dist/DateTimePicker/DateTimeInput.d.ts +5 -3
- package/dist/DateTimePicker/DateTimeInput.js +122 -69
- package/dist/Dialog.js +2 -2
- package/dist/Drawer.js +1 -1
- package/dist/HoverCard.js +4 -4
- package/dist/Icons/IconBase.d.ts +1 -1
- package/dist/Icons/IconBase.js +63 -20
- package/dist/MultiSelect/MultiSelectBase.js +128 -126
- package/dist/Popover.js +1 -1
- package/dist/RadioGroup.js +5 -5
- package/dist/Select.js +1 -1
- package/dist/Slider.js +3 -3
- package/dist/Tooltip.js +6 -6
- package/dist/Tray.d.ts +3 -1
- package/dist/Tray.js +36 -32
- package/dist/{Combination-CQ5bXZqE.js → index-6oYKCvIn.js} +179 -178
- package/dist/{index-CtqlhLRO.js → index-BFOf48AQ.js} +1 -1
- package/dist/{index-BJ6qs9i5.js → index-BlHU_t18.js} +7 -7
- package/dist/{index-D2Qxe4uK.js → index-Bm1RbF6w.js} +1 -1
- package/dist/{index-CXltlPV-.js → index-Bv2OIg5P.js} +6 -6
- package/dist/{index-Cgdmxb3F.js → index-CKEI0pDv.js} +1 -1
- package/dist/{index-CDkQCeZY.js → index-CM_hWgfC.js} +1 -1
- package/dist/{index-CJKg3MVV.js → index-C_YVr64u.js} +2 -2
- package/dist/{index-obMGvcdD.js → index-CwSyIPrv.js} +1 -1
- package/dist/{index-9OmOYyjJ.js → index-Dc0No4pV.js} +2 -1
- package/dist/{index-DqvTB1Bv.js → index-T6XEa11q.js} +7 -7
- package/dist/{index-CmWCa9Ae.js → index-pBCLb6Gr.js} +5 -5
- package/dist/{index-WBfSMXvE.js → index-psiVrsnE.js} +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/primitives/button.d.ts +1 -1
- package/dist/primitives/button.d.ts.map +1 -1
- package/dist/primitives/button.js +4 -4
- package/dist/{InputGroup.d.ts → primitives/input-group.d.ts} +10 -7
- package/dist/primitives/input-group.d.ts.map +1 -0
- package/dist/primitives/input-group.js +74 -0
- package/dist/primitives/input.d.ts +6 -1
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +1 -1
- package/dist/primitives/popover.d.ts +10 -0
- package/dist/primitives/popover.d.ts.map +1 -0
- package/dist/primitives/popover.js +29 -0
- package/dist/primitives/select.js +2 -2
- package/dist/styles/spectral.css +2 -2
- package/package.json +1 -1
- package/dist/InputGroup.js +0 -84
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../styles/main.css";
|
|
3
|
+
import { jsx as e, jsxs as x, Fragment as k } from "react/jsx-runtime";
|
|
4
|
+
import { ControlGroup as F, useControlGroup as j, ControlGroupItem as I } from "../ControlGroup.js";
|
|
5
|
+
import { Label as $ } from "../Label.js";
|
|
6
|
+
import { Input as E } from "../primitives/input.js";
|
|
7
|
+
import { SelectTrigger as z, SelectValue as M, Select as T, SelectContent as V, SelectItem as q } from "../primitives/select.js";
|
|
8
|
+
import { cn as w } from "../utils/twUtils.js";
|
|
9
|
+
import { useId as B } from "react";
|
|
10
|
+
const D = "placeholder:text-small! [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none", y = "flex w-full min-w-0 flex-col gap-1.5", L = ({
|
|
11
|
+
amountStep: v,
|
|
12
|
+
ariaLabel: o,
|
|
13
|
+
captionLayout: C = "inline",
|
|
14
|
+
className: h,
|
|
15
|
+
dataTestId: i = "spectral-control-group-select",
|
|
16
|
+
disabled: l,
|
|
17
|
+
errorMessage: a,
|
|
18
|
+
inputAriaLabel: p,
|
|
19
|
+
inputPlaceholder: r,
|
|
20
|
+
maxAmount: N = 1e6,
|
|
21
|
+
minAmount: S = 0,
|
|
22
|
+
orientation: u = "horizontal",
|
|
23
|
+
selectAriaLabel: b,
|
|
24
|
+
selectOptions: G,
|
|
25
|
+
selectPlaceholder: n,
|
|
26
|
+
state: c = "default",
|
|
27
|
+
type: t = "number",
|
|
28
|
+
...g
|
|
29
|
+
}) => {
|
|
30
|
+
const d = B(), f = `${d}-amount`, s = `${d}-select`, m = C === "above";
|
|
31
|
+
return /* @__PURE__ */ e(F, { "aria-label": o, className: h, "data-testid": i, disabled: l, errorMessage: a, orientation: u, state: c, children: /* @__PURE__ */ e(
|
|
32
|
+
H,
|
|
33
|
+
{
|
|
34
|
+
amountStep: v,
|
|
35
|
+
dataTestId: i,
|
|
36
|
+
inputAccessibleName: m ? r ? void 0 : p ?? void 0 : p ?? r ?? void 0,
|
|
37
|
+
inputCaption: m ? void 0 : r,
|
|
38
|
+
inputId: f,
|
|
39
|
+
isDisabled: !!l || c === "disabled",
|
|
40
|
+
maxAmount: N,
|
|
41
|
+
minAmount: S,
|
|
42
|
+
selectCaption: m ? void 0 : n,
|
|
43
|
+
selectOptions: G,
|
|
44
|
+
selectProps: g,
|
|
45
|
+
selectTriggerAriaLabel: m ? n ? void 0 : b ?? void 0 : b ?? n ?? void 0,
|
|
46
|
+
selectTriggerId: s,
|
|
47
|
+
type: t,
|
|
48
|
+
useAboveLabels: m,
|
|
49
|
+
inputPlaceholder: r,
|
|
50
|
+
selectPlaceholder: n
|
|
51
|
+
}
|
|
52
|
+
) });
|
|
53
|
+
}, H = ({
|
|
54
|
+
amountStep: v,
|
|
55
|
+
dataTestId: o,
|
|
56
|
+
inputAccessibleName: C,
|
|
57
|
+
inputCaption: h,
|
|
58
|
+
inputId: i,
|
|
59
|
+
inputPlaceholder: l,
|
|
60
|
+
isDisabled: a,
|
|
61
|
+
maxAmount: p,
|
|
62
|
+
minAmount: r,
|
|
63
|
+
selectCaption: N,
|
|
64
|
+
selectOptions: S,
|
|
65
|
+
selectPlaceholder: u,
|
|
66
|
+
selectProps: b,
|
|
67
|
+
selectTriggerAriaLabel: G,
|
|
68
|
+
selectTriggerId: n,
|
|
69
|
+
type: c,
|
|
70
|
+
useAboveLabels: t
|
|
71
|
+
}) => {
|
|
72
|
+
const { errorMessageId: g } = j(), d = /* @__PURE__ */ e(
|
|
73
|
+
E,
|
|
74
|
+
{
|
|
75
|
+
"aria-describedby": g,
|
|
76
|
+
"aria-label": C,
|
|
77
|
+
className: w(c === "number" && D, t && "rounded-none rounded-s-md"),
|
|
78
|
+
"data-testid": `${o}-input`,
|
|
79
|
+
disabled: a,
|
|
80
|
+
id: t ? i : void 0,
|
|
81
|
+
type: c === "number" ? "number" : "text",
|
|
82
|
+
placeholder: h,
|
|
83
|
+
min: r ?? 0,
|
|
84
|
+
max: p ?? 1e6,
|
|
85
|
+
step: v ?? 1
|
|
86
|
+
}
|
|
87
|
+
), f = /* @__PURE__ */ e(z, { "aria-describedby": g, "aria-label": G, className: w(t && "rounded-none rounded-e-md"), "data-testid": `${o}-select-trigger`, disabled: a, id: t ? n : void 0, children: /* @__PURE__ */ e(M, { placeholder: N }) });
|
|
88
|
+
return /* @__PURE__ */ x(k, { children: [
|
|
89
|
+
/* @__PURE__ */ e(I, { children: t ? /* @__PURE__ */ x("div", { className: y, children: [
|
|
90
|
+
l ? /* @__PURE__ */ e($, { className: "text-text-primary", htmlFor: i, children: l }) : null,
|
|
91
|
+
d
|
|
92
|
+
] }) : d }),
|
|
93
|
+
/* @__PURE__ */ x(T, { "data-testid": `${o}-select-root`, disabled: a, ...b, children: [
|
|
94
|
+
/* @__PURE__ */ e(I, { children: t ? /* @__PURE__ */ x("div", { className: y, children: [
|
|
95
|
+
u ? /* @__PURE__ */ e($, { className: "text-text-primary", htmlFor: n, children: u }) : null,
|
|
96
|
+
f
|
|
97
|
+
] }) : f }),
|
|
98
|
+
/* @__PURE__ */ e(V, { children: S.map((s) => /* @__PURE__ */ e(q, { value: s.value, children: s.label }, s.value)) })
|
|
99
|
+
] })
|
|
100
|
+
] });
|
|
101
|
+
};
|
|
102
|
+
export {
|
|
103
|
+
L as ControlGroupSelect
|
|
104
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Slot } from './primitives/slot';
|
|
2
|
+
import { FormFieldState } from './utils/formFieldUtils';
|
|
3
|
+
import { ComponentProps } from 'react';
|
|
4
|
+
interface ControlGroupContextValue {
|
|
5
|
+
errorMessageId?: string;
|
|
6
|
+
isDisabled: boolean;
|
|
7
|
+
isInvalid: boolean;
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
orientation: 'horizontal' | 'vertical';
|
|
10
|
+
state: FormFieldState;
|
|
11
|
+
}
|
|
12
|
+
export declare const useControlGroup: () => ControlGroupContextValue;
|
|
13
|
+
export interface ControlGroupProps extends ComponentProps<'div'> {
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
errorMessage?: string | string[] | Record<string, unknown> | null;
|
|
16
|
+
id?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
orientation?: 'horizontal' | 'vertical';
|
|
19
|
+
state?: FormFieldState;
|
|
20
|
+
}
|
|
21
|
+
export declare const ControlGroup: ({ className, disabled, errorMessage, id, name, orientation, state, ...props }: ControlGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare const ControlGroupItem: ({ className, ...props }: ComponentProps<typeof Slot>) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=ControlGroup.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "./styles/main.css";
|
|
3
|
+
import { jsxs as x, jsx as a } from "react/jsx-runtime";
|
|
4
|
+
import { Slot as C } from "./primitives/slot.js";
|
|
5
|
+
import { useFormFieldId as v, useFormFieldState as b, getStateClasses as I, ErrorMessage as h, getErrorMessageId as G } from "./utils/formFieldUtils.js";
|
|
6
|
+
import { cn as u } from "./utils/twUtils.js";
|
|
7
|
+
import { createContext as w, useContext as F } from "react";
|
|
8
|
+
const m = w(null), z = () => {
|
|
9
|
+
const r = F(m);
|
|
10
|
+
if (r === null)
|
|
11
|
+
throw new Error("useControlGroup must be used within a ControlGroup");
|
|
12
|
+
return r;
|
|
13
|
+
}, D = ({ className: r, disabled: s, errorMessage: o, id: c, name: p, orientation: n = "horizontal", state: t = "default", ...f }) => {
|
|
14
|
+
const l = v(c, p), d = G(l), { isDisabled: i, isLoading: g, isInvalid: e } = b(s, t);
|
|
15
|
+
return /* @__PURE__ */ x(m.Provider, { value: { errorMessageId: e && o ? d : void 0, isDisabled: i, isInvalid: e, isLoading: g, orientation: n, state: t }, children: [
|
|
16
|
+
/* @__PURE__ */ a(
|
|
17
|
+
"div",
|
|
18
|
+
{
|
|
19
|
+
"data-slot": "control-group",
|
|
20
|
+
"data-orientation": n,
|
|
21
|
+
"data-state": t,
|
|
22
|
+
id: l,
|
|
23
|
+
role: "group",
|
|
24
|
+
"aria-describedby": e && o ? d : void 0,
|
|
25
|
+
className: u("group flex rounded-lg border-2 border-transparent", n === "vertical" && "flex-col", I(t), i && "pointer-events-none opacity-50", r),
|
|
26
|
+
...f
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
e && o && /* @__PURE__ */ a(h, { dataTestId: "spectral-control-group-error-message", id: d, message: o })
|
|
30
|
+
] });
|
|
31
|
+
}, L = ({ className: r, ...s }) => {
|
|
32
|
+
const { orientation: o } = z();
|
|
33
|
+
return /* @__PURE__ */ a(
|
|
34
|
+
C,
|
|
35
|
+
{
|
|
36
|
+
"data-slot": "control-group-item",
|
|
37
|
+
className: u(
|
|
38
|
+
"rounded-none focus-within:z-10",
|
|
39
|
+
o === "horizontal" && "-me-px h-auto first:rounded-s-md last:me-0 last:rounded-e-md",
|
|
40
|
+
o === "vertical" && "-mbe-px w-auto first:rounded-ss-md first:rounded-se-md last:mbe-0 last:rounded-ee-md last:rounded-es-md",
|
|
41
|
+
r
|
|
42
|
+
),
|
|
43
|
+
...s
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
D as ControlGroup,
|
|
49
|
+
L as ControlGroupItem,
|
|
50
|
+
z as useControlGroup
|
|
51
|
+
};
|
|
@@ -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
|