@spear-ai/spectral 1.3.44 → 1.3.46
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 +150 -146
- package/dist/Accordion/AccordionBase.js +141 -150
- package/dist/ButtonIcon.d.ts +14 -0
- package/dist/ButtonIcon.js +119 -0
- package/dist/Checkbox/CheckboxBase.js +6 -5
- package/dist/Icons/AnnotationsIcon.js +6 -5
- package/dist/Icons/CalendarIcon.js +4 -3
- package/dist/Icons/CheckCircleIcon.js +6 -5
- package/dist/Icons/CheckSquareIcon.js +6 -5
- package/dist/Icons/ChevronDownIcon.js +6 -5
- package/dist/Icons/ChevronUpIcon.js +9 -8
- package/dist/Icons/ClockIcon.js +11 -10
- package/dist/Icons/CloseCircleIcon.js +12 -11
- package/dist/Icons/CloseIcon.js +10 -9
- package/dist/Icons/DashboardIcon.js +6 -5
- package/dist/Icons/DeleteIcon.js +10 -9
- package/dist/Icons/DurationIcon.js +3 -2
- package/dist/Icons/EraserIcon.js +12 -11
- package/dist/Icons/ErrorIcon.js +3 -2
- package/dist/Icons/EyeClosedIcon.js +9 -8
- package/dist/Icons/EyeClosedIcon2.js +6 -5
- package/dist/Icons/EyeOpenIcon.js +11 -10
- package/dist/Icons/GoToFirstIcon.js +5 -4
- package/dist/Icons/GoToLastIcon.js +6 -5
- package/dist/Icons/HarmonicCursorsIcon.js +10 -9
- package/dist/Icons/InfoIcon.js +9 -8
- package/dist/Icons/LabelIcon.js +6 -5
- package/dist/Icons/LassoIcon.js +8 -7
- package/dist/Icons/LineToolIcon.js +9 -8
- package/dist/Icons/LiveViewIcon.js +7 -6
- package/dist/Icons/LoaderIcon.js +6 -5
- package/dist/Icons/LocationIcon.js +12 -11
- package/dist/Icons/LogoutIcon.js +4 -3
- package/dist/Icons/MetadataIcon.js +6 -5
- package/dist/Icons/OntologyIcon.js +3 -2
- package/dist/Icons/PanelIcon.js +4 -3
- package/dist/Icons/PlayIcon.js +8 -7
- package/dist/Icons/PlusIcon.js +8 -7
- package/dist/Icons/ResetIcon.js +14 -13
- package/dist/Icons/ScissorsIcon.js +7 -6
- package/dist/Icons/SettingsIcon.js +3 -2
- package/dist/Icons/TrashIcon.js +9 -8
- package/dist/Icons/UndoIcon.js +6 -5
- package/dist/Icons/UserIcon.js +7 -6
- package/dist/Icons/WarningIcon.js +13 -12
- package/dist/Icons/ZoomAllIcon.js +7 -6
- package/dist/Icons/ZoomXIcon.js +9 -8
- package/dist/Icons/ZoomYIcon.js +9 -8
- package/dist/Input.d.ts +2 -0
- package/dist/Input.js +48 -46
- package/dist/RadioGroup/RadioGroupBase.js +130 -138
- package/dist/Switch/SwitchBase.js +22 -21
- package/dist/Toggle/ToggleBase.js +4 -4
- package/dist/ToggleGroup/ToggleGroupBase.js +6 -5
- package/dist/components/Accordion/AccordionBase.d.ts.map +1 -1
- package/dist/components/ButtonIcon/ButtonIcon.d.ts +14 -0
- package/dist/components/ButtonIcon/ButtonIcon.d.ts.map +1 -0
- package/dist/components/Checkbox/CheckboxBase.d.ts.map +1 -1
- package/dist/components/Input/Input.d.ts +2 -0
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/RadioGroup/RadioGroupBase.d.ts.map +1 -1
- package/dist/components/Switch/SwitchBase.d.ts.map +1 -1
- package/dist/components/Toggle/ToggleBase.d.ts.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroupBase.d.ts.map +1 -1
- package/dist/hooks/useControllableState.d.ts +9 -0
- package/dist/hooks/useControllableState.d.ts.map +1 -0
- package/dist/hooks/useControllableState.js +15 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/styles/main.css +1 -1
- package/dist/utils/sharedUtils.d.ts +2 -0
- package/dist/utils/sharedUtils.d.ts.map +1 -0
- package/dist/utils/sharedUtils.js +6 -0
- package/package.json +1 -1
- package/dist/hooks/useOutsideClick.d.ts +0 -8
- package/dist/hooks/useOutsideClick.d.ts.map +0 -1
- package/dist/hooks/useOutsideClick.js +0 -16
- package/dist/utils/shared.d.ts +0 -24
- package/dist/utils/shared.d.ts.map +0 -1
- package/dist/utils/shared.js +0 -29
package/dist/Input.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./styles/main.css";
|
|
3
3
|
import { jsx as t, jsxs as I } from "react/jsx-runtime";
|
|
4
|
-
import { usePasswordVisibility as
|
|
4
|
+
import { usePasswordVisibility as U, usePrefixWidth as X, useClearOnFocus as Y } from "./Input/InputUtils.js";
|
|
5
5
|
import "./Icons/AnnotationsIcon.js";
|
|
6
6
|
import "./Icons/CalendarIcon.js";
|
|
7
|
-
import { CheckCircleIcon as
|
|
7
|
+
import { CheckCircleIcon as Z } from "./Icons/CheckCircleIcon.js";
|
|
8
8
|
import "./Icons/CheckSquareIcon.js";
|
|
9
9
|
import "./Icons/ChevronDownIcon.js";
|
|
10
10
|
import "./Icons/ChevronUpIcon.js";
|
|
11
11
|
import "./Icons/ClockIcon.js";
|
|
12
|
-
import { CloseCircleIcon as
|
|
12
|
+
import { CloseCircleIcon as _ } from "./Icons/CloseCircleIcon.js";
|
|
13
13
|
import "./Icons/CloseIcon.js";
|
|
14
14
|
import "./Icons/DashboardIcon.js";
|
|
15
15
|
import "./Icons/DeleteIcon.js";
|
|
16
16
|
import "./Icons/DurationIcon.js";
|
|
17
17
|
import "./Icons/EraserIcon.js";
|
|
18
|
-
import { ErrorIcon as
|
|
19
|
-
import { EyeClosedIcon as
|
|
18
|
+
import { ErrorIcon as q } from "./Icons/ErrorIcon.js";
|
|
19
|
+
import { EyeClosedIcon as tt } from "./Icons/EyeClosedIcon.js";
|
|
20
20
|
import "./Icons/EyeClosedIcon2.js";
|
|
21
|
-
import { EyeOpenIcon as
|
|
21
|
+
import { EyeOpenIcon as et } from "./Icons/EyeOpenIcon.js";
|
|
22
22
|
import "./Icons/GoToFirstIcon.js";
|
|
23
23
|
import "./Icons/GoToLastIcon.js";
|
|
24
24
|
import "./Icons/HarmonicCursorsIcon.js";
|
|
@@ -27,7 +27,7 @@ import "./Icons/LabelIcon.js";
|
|
|
27
27
|
import "./Icons/LassoIcon.js";
|
|
28
28
|
import "./Icons/LineToolIcon.js";
|
|
29
29
|
import "./Icons/LiveViewIcon.js";
|
|
30
|
-
import { LoaderIcon as
|
|
30
|
+
import { LoaderIcon as rt } from "./Icons/LoaderIcon.js";
|
|
31
31
|
import "./Icons/LocationIcon.js";
|
|
32
32
|
import "./Icons/LogoutIcon.js";
|
|
33
33
|
import "./Icons/MetadataIcon.js";
|
|
@@ -45,10 +45,10 @@ import "./Icons/WarningIcon.js";
|
|
|
45
45
|
import "./Icons/ZoomAllIcon.js";
|
|
46
46
|
import "./Icons/ZoomXIcon.js";
|
|
47
47
|
import "./Icons/ZoomYIcon.js";
|
|
48
|
-
import { useFormFieldId as
|
|
48
|
+
import { useFormFieldId as ot, getAriaProps as it, getInputClasses as st, useFormFieldState as at, getFormFieldCSSProperties as nt, ErrorMessage as pt } from "./utils/formFieldUtils.js";
|
|
49
49
|
import { c as N } from "./twUtils-CRiPKpXj.js";
|
|
50
|
-
import { forwardRef as
|
|
51
|
-
const
|
|
50
|
+
import { forwardRef as lt, useRef as ct, useCallback as m } from "react";
|
|
51
|
+
const mt = (p) => ({
|
|
52
52
|
email: "email",
|
|
53
53
|
password: "current-password",
|
|
54
54
|
tel: "tel",
|
|
@@ -57,7 +57,7 @@ const ct = (p) => ({
|
|
|
57
57
|
number: "off",
|
|
58
58
|
date: "off",
|
|
59
59
|
"datetime-local": "off"
|
|
60
|
-
})[p] || "off",
|
|
60
|
+
})[p] || "off", dt = lt(
|
|
61
61
|
({
|
|
62
62
|
className: p,
|
|
63
63
|
clearOnFocus: d = !1,
|
|
@@ -71,39 +71,40 @@ const ct = (p) => ({
|
|
|
71
71
|
onFocus: C,
|
|
72
72
|
prefix: a,
|
|
73
73
|
showClearButton: z = !1,
|
|
74
|
+
suppressHydrationWarning: P = !0,
|
|
74
75
|
state: e = "default",
|
|
75
76
|
type: n = "text",
|
|
76
77
|
value: g = "",
|
|
77
78
|
required: x,
|
|
78
|
-
"aria-label":
|
|
79
|
-
"aria-describedby":
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
const l =
|
|
79
|
+
"aria-label": R,
|
|
80
|
+
"aria-describedby": $,
|
|
81
|
+
...k
|
|
82
|
+
}, S) => {
|
|
83
|
+
const l = ot(E, f), w = `${l}-error`, { isDisabled: V, isLoading: M, isInvalid: O } = at(F, e), j = it(e, x, w, $), A = ct(null), r = S || A, { isVisible: c, toggleVisibility: B, inputType: H } = U(), { prefixWidth: L, prefixRef: W } = X(a), { handleFocus: y } = Y(d, b), D = m(
|
|
83
84
|
(o) => {
|
|
84
85
|
h?.(o);
|
|
85
86
|
},
|
|
86
87
|
[h]
|
|
87
|
-
),
|
|
88
|
+
), T = m(
|
|
88
89
|
(o) => {
|
|
89
90
|
y(o, C);
|
|
90
91
|
},
|
|
91
92
|
[y, C]
|
|
92
|
-
),
|
|
93
|
+
), G = m(() => {
|
|
93
94
|
r.current && (r.current.value = "", r.current.dispatchEvent(new Event("input", { bubbles: !0 })), r.current.focus());
|
|
94
|
-
}, [r]), v = z && g.length > 0,
|
|
95
|
+
}, [r]), v = z && g.length > 0, J = () => {
|
|
95
96
|
const o = "absolute right-4 top-1/2 -translate-y-1/2 text-input-icon hover:text-input-icon--hover focus:outline-none cursor-pointer", s = {
|
|
96
97
|
password: () => /* @__PURE__ */ t(
|
|
97
98
|
"button",
|
|
98
99
|
{
|
|
99
100
|
className: o,
|
|
100
101
|
type: "button",
|
|
101
|
-
onClick:
|
|
102
|
+
onClick: B,
|
|
102
103
|
"aria-label": c ? `Hide ${i}` : `Show ${i}`,
|
|
103
104
|
"aria-pressed": c,
|
|
104
105
|
"aria-controls": l,
|
|
105
106
|
"data-testid": "input-password-toggle",
|
|
106
|
-
children: c ? /* @__PURE__ */ t(
|
|
107
|
+
children: c ? /* @__PURE__ */ t(tt, { size: 22 }) : /* @__PURE__ */ t(et, { size: 22 })
|
|
107
108
|
}
|
|
108
109
|
),
|
|
109
110
|
clear: () => /* @__PURE__ */ t(
|
|
@@ -111,60 +112,61 @@ const ct = (p) => ({
|
|
|
111
112
|
{
|
|
112
113
|
className: o,
|
|
113
114
|
type: "button",
|
|
114
|
-
onClick:
|
|
115
|
+
onClick: G,
|
|
115
116
|
"aria-label": `Clear ${i}`,
|
|
116
117
|
"data-testid": "input-clear-button",
|
|
117
|
-
children: /* @__PURE__ */ t(
|
|
118
|
+
children: /* @__PURE__ */ t(_, { size: 24 })
|
|
118
119
|
}
|
|
119
120
|
),
|
|
120
|
-
loading: () => /* @__PURE__ */ t("div", { className: "absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-loading-icon", children: /* @__PURE__ */ t(
|
|
121
|
-
error: () => /* @__PURE__ */ t("div", { className: "text-danger-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-error-icon", children: /* @__PURE__ */ t(
|
|
122
|
-
success: () => /* @__PURE__ */ t("div", { className: "text-success-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-success-icon", children: /* @__PURE__ */ t(
|
|
121
|
+
loading: () => /* @__PURE__ */ t("div", { className: "absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-loading-icon", children: /* @__PURE__ */ t(rt, { size: 24 }) }),
|
|
122
|
+
error: () => /* @__PURE__ */ t("div", { className: "text-danger-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-error-icon", children: /* @__PURE__ */ t(q, { size: 24 }) }),
|
|
123
|
+
success: () => /* @__PURE__ */ t("div", { className: "text-success-400 absolute top-1/2 right-4 -translate-y-1/2", "data-testid": "input-success-icon", children: /* @__PURE__ */ t(Z, { size: 24 }) })
|
|
123
124
|
};
|
|
124
|
-
return n === "password" ? s.password() : v ? s.clear() :
|
|
125
|
-
},
|
|
126
|
-
|
|
125
|
+
return n === "password" ? s.password() : v ? s.clear() : M ? s.loading() : e === "success" ? s.success() : e === "error" ? s.error() : null;
|
|
126
|
+
}, K = N(
|
|
127
|
+
st(e, p),
|
|
127
128
|
"[text-indent:var(--prefix-width)]",
|
|
128
129
|
v && "pr-10"
|
|
129
|
-
),
|
|
130
|
+
), Q = N(
|
|
130
131
|
"pointer-events-none absolute inset-y-0 left-4 flex items-center text-base text-input-text-prefix opacity-100 peer-disabled:opacity-50"
|
|
131
132
|
);
|
|
132
133
|
return /* @__PURE__ */ t("div", { className: "w-full space-y-1.5", "data-testid": "input-root", children: /* @__PURE__ */ I("div", { className: "relative", "data-testid": "input-wrapper", children: [
|
|
133
134
|
/* @__PURE__ */ I("div", { className: "relative", children: [
|
|
134
|
-
a && /* @__PURE__ */ t("span", { ref:
|
|
135
|
+
a && /* @__PURE__ */ t("span", { ref: W, className: Q, children: a }),
|
|
135
136
|
/* @__PURE__ */ t(
|
|
136
137
|
"input",
|
|
137
138
|
{
|
|
138
139
|
id: l,
|
|
139
140
|
name: f,
|
|
140
141
|
ref: r,
|
|
141
|
-
type: n === "password" ?
|
|
142
|
+
type: n === "password" ? H : n,
|
|
142
143
|
value: g,
|
|
143
|
-
disabled:
|
|
144
|
+
disabled: V,
|
|
144
145
|
required: x,
|
|
145
|
-
autoComplete:
|
|
146
|
-
className:
|
|
146
|
+
autoComplete: mt(n),
|
|
147
|
+
className: K,
|
|
147
148
|
onChange: b,
|
|
148
|
-
onFocus:
|
|
149
|
-
onBlur:
|
|
149
|
+
onFocus: T,
|
|
150
|
+
onBlur: D,
|
|
150
151
|
placeholder: i,
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
suppressHydrationWarning: P,
|
|
153
|
+
...j,
|
|
154
|
+
...k,
|
|
153
155
|
"data-testid": "input-input",
|
|
154
156
|
"data-state": e,
|
|
155
|
-
style:
|
|
156
|
-
"--prefix-width": a ? `${
|
|
157
|
+
style: nt({
|
|
158
|
+
"--prefix-width": a ? `${L}px` : "0px"
|
|
157
159
|
}),
|
|
158
|
-
"aria-label":
|
|
160
|
+
"aria-label": R || i
|
|
159
161
|
}
|
|
160
162
|
),
|
|
161
|
-
|
|
163
|
+
J()
|
|
162
164
|
] }),
|
|
163
|
-
|
|
165
|
+
O && u && /* @__PURE__ */ t(pt, { id: w, message: u })
|
|
164
166
|
] }) });
|
|
165
167
|
}
|
|
166
168
|
);
|
|
167
|
-
|
|
169
|
+
dt.displayName = "Input";
|
|
168
170
|
export {
|
|
169
|
-
|
|
171
|
+
dt as Input
|
|
170
172
|
};
|
|
@@ -1,203 +1,195 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
3
|
import { jsx as A, jsxs as T } from "react/jsx-runtime";
|
|
4
|
+
import { useControllableState as z } from "../hooks/useControllableState.js";
|
|
4
5
|
import { Slot as L } from "../primitives/slot.js";
|
|
5
|
-
import { createContext as
|
|
6
|
-
function q(...
|
|
7
|
-
return
|
|
6
|
+
import { createContext as J, forwardRef as P, useId as U, useState as $, useRef as V, useEffect as E, useCallback as G, useContext as B, useImperativeHandle as K } from "react";
|
|
7
|
+
function q(...u) {
|
|
8
|
+
return u.filter(Boolean).join(" ");
|
|
8
9
|
}
|
|
9
|
-
const H =
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
[
|
|
16
|
-
);
|
|
17
|
-
return [g, l];
|
|
18
|
-
}
|
|
19
|
-
function Q(s, i, t, r) {
|
|
20
|
-
const d = s.length;
|
|
21
|
-
let n = i;
|
|
22
|
-
for (let u = 0; u < d; u += 1) {
|
|
23
|
-
if (n = t === "next" ? n + 1 : n - 1, r && (n < 0 && (n = d - 1), n >= d && (n = 0)), n < 0 || n >= d) return i;
|
|
24
|
-
if (!s[n].disabled) return n;
|
|
10
|
+
const H = J(null);
|
|
11
|
+
function Q(u, a, t, o) {
|
|
12
|
+
const l = u.length;
|
|
13
|
+
let n = a;
|
|
14
|
+
for (let f = 0; f < l; f += 1) {
|
|
15
|
+
if (n = t === "next" ? n + 1 : n - 1, o && (n < 0 && (n = l - 1), n >= l && (n = 0)), n < 0 || n >= l) return a;
|
|
16
|
+
if (!u[n].disabled) return n;
|
|
25
17
|
}
|
|
26
|
-
return
|
|
18
|
+
return a;
|
|
27
19
|
}
|
|
28
|
-
function W(
|
|
29
|
-
const { key:
|
|
30
|
-
return
|
|
20
|
+
function W(u, a, t) {
|
|
21
|
+
const { key: o } = u;
|
|
22
|
+
return o === "Home" ? "first" : o === "End" ? "last" : a === "vertical" ? o === "ArrowDown" ? "next" : o === "ArrowUp" ? "prev" : null : o === "ArrowRight" ? t === "rtl" ? "prev" : "next" : o === "ArrowLeft" ? t === "rtl" ? "next" : "prev" : null;
|
|
31
23
|
}
|
|
32
24
|
const X = P(
|
|
33
25
|
({
|
|
34
|
-
asChild:
|
|
35
|
-
className:
|
|
26
|
+
asChild: u,
|
|
27
|
+
className: a,
|
|
36
28
|
value: t,
|
|
37
|
-
defaultValue:
|
|
38
|
-
onValueChange:
|
|
29
|
+
defaultValue: o,
|
|
30
|
+
onValueChange: l,
|
|
39
31
|
name: n,
|
|
40
|
-
required:
|
|
41
|
-
form:
|
|
42
|
-
disabled:
|
|
32
|
+
required: f = !1,
|
|
33
|
+
form: y,
|
|
34
|
+
disabled: b = !1,
|
|
43
35
|
orientation: e = "vertical",
|
|
44
36
|
dir: N = "ltr",
|
|
45
37
|
loop: p = !0,
|
|
46
|
-
variant:
|
|
47
|
-
id:
|
|
48
|
-
...
|
|
49
|
-
},
|
|
50
|
-
const O =
|
|
38
|
+
variant: v = "default",
|
|
39
|
+
id: c,
|
|
40
|
+
...d
|
|
41
|
+
}, m) => {
|
|
42
|
+
const O = U(), F = c ?? `rg-${O}`, [g, k] = z({
|
|
51
43
|
value: t,
|
|
52
|
-
defaultValue:
|
|
53
|
-
onChange:
|
|
54
|
-
}), [w,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}, [
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
const
|
|
61
|
-
|
|
44
|
+
defaultValue: o ?? void 0,
|
|
45
|
+
onChange: l
|
|
46
|
+
}), [w, C] = $(g), R = V([]), I = V(null);
|
|
47
|
+
E(() => {
|
|
48
|
+
g !== void 0 && C(g);
|
|
49
|
+
}, [g]), E(() => {
|
|
50
|
+
const s = I.current;
|
|
51
|
+
if (!s) return;
|
|
52
|
+
const i = () => {
|
|
53
|
+
k(o ?? void 0);
|
|
62
54
|
};
|
|
63
|
-
return
|
|
64
|
-
}, [
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
}), []), h =
|
|
68
|
-
(
|
|
69
|
-
|
|
55
|
+
return s.addEventListener("reset", i), () => s.removeEventListener("reset", i);
|
|
56
|
+
}, [o, k]);
|
|
57
|
+
const r = G((s) => (R.current.push(s), () => {
|
|
58
|
+
R.current = R.current.filter((i) => i.value !== s.value);
|
|
59
|
+
}), []), h = G(
|
|
60
|
+
(s, i) => {
|
|
61
|
+
b || (k(s), i?.focus && (C(s), R.current.find((M) => M.value === s)?.ref.current?.focus()));
|
|
70
62
|
},
|
|
71
|
-
[
|
|
72
|
-
),
|
|
73
|
-
value:
|
|
63
|
+
[b, k]
|
|
64
|
+
), x = {
|
|
65
|
+
value: g,
|
|
74
66
|
setValue: h,
|
|
75
67
|
name: n,
|
|
76
|
-
required:
|
|
77
|
-
form:
|
|
78
|
-
disabled:
|
|
68
|
+
required: f,
|
|
69
|
+
form: y,
|
|
70
|
+
disabled: b,
|
|
79
71
|
orientation: e,
|
|
80
72
|
dir: N,
|
|
81
73
|
loop: p,
|
|
82
|
-
registerItem:
|
|
74
|
+
registerItem: r,
|
|
83
75
|
focusableValue: w,
|
|
84
|
-
setFocusableValue:
|
|
76
|
+
setFocusableValue: C,
|
|
85
77
|
formElRef: I,
|
|
86
|
-
itemsRef:
|
|
87
|
-
variant:
|
|
88
|
-
}, D =
|
|
89
|
-
return /* @__PURE__ */ A(H.Provider, { value:
|
|
78
|
+
itemsRef: R,
|
|
79
|
+
variant: v
|
|
80
|
+
}, D = u ? L : "div", S = m;
|
|
81
|
+
return /* @__PURE__ */ A(H.Provider, { value: x, children: /* @__PURE__ */ A(
|
|
90
82
|
D,
|
|
91
83
|
{
|
|
92
84
|
id: F,
|
|
93
85
|
ref: S,
|
|
94
86
|
role: "radiogroup",
|
|
95
87
|
"aria-orientation": e,
|
|
96
|
-
"data-disabled":
|
|
97
|
-
className: q(
|
|
98
|
-
...
|
|
88
|
+
"data-disabled": b ? "" : void 0,
|
|
89
|
+
className: q(a),
|
|
90
|
+
...d
|
|
99
91
|
}
|
|
100
92
|
) });
|
|
101
93
|
}
|
|
102
94
|
);
|
|
103
95
|
X.displayName = "RadioGroup";
|
|
104
96
|
const Y = P(
|
|
105
|
-
({ asChild:
|
|
97
|
+
({ asChild: u, className: a, value: t, disabled: o, id: l, onKeyDown: n, onClick: f, ...y }, b) => {
|
|
106
98
|
const e = B(H);
|
|
107
99
|
if (!e) throw new Error("RadioGroupItem must be used within RadioGroup");
|
|
108
|
-
const N =
|
|
100
|
+
const N = U(), p = l ?? `rgi-${N}`, v = V(null), c = V(null);
|
|
109
101
|
K(
|
|
110
|
-
|
|
111
|
-
() =>
|
|
102
|
+
b,
|
|
103
|
+
() => v.current,
|
|
112
104
|
[]
|
|
113
105
|
);
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
return e.registerItem(
|
|
118
|
-
}, [t,
|
|
119
|
-
!e.formElRef.current &&
|
|
120
|
-
}, [e.formElRef]),
|
|
121
|
-
|
|
122
|
-
}, [
|
|
123
|
-
const F = (e.focusableValue ? e.focusableValue === t :
|
|
124
|
-
|
|
125
|
-
}, w =
|
|
126
|
-
(
|
|
127
|
-
if (!
|
|
106
|
+
const d = e.value === t, m = !!o || e.disabled;
|
|
107
|
+
E(() => {
|
|
108
|
+
const r = { value: t, ref: v, disabled: !!m, id: p };
|
|
109
|
+
return e.registerItem(r);
|
|
110
|
+
}, [t, m, p]), E(() => {
|
|
111
|
+
!e.formElRef.current && c.current?.form && (e.formElRef.current = c.current.form);
|
|
112
|
+
}, [e.formElRef]), E(() => {
|
|
113
|
+
c.current && (c.current.checked = d);
|
|
114
|
+
}, [d]);
|
|
115
|
+
const F = (e.focusableValue ? e.focusableValue === t : d) && !m ? 0 : -1, g = u ? L : "button", k = (r) => {
|
|
116
|
+
v.current = r;
|
|
117
|
+
}, w = G(
|
|
118
|
+
(r) => {
|
|
119
|
+
if (!m && (e.setValue(t, { focus: !0, user: r }), c.current)) {
|
|
128
120
|
const h = new Event("change", { bubbles: !0 });
|
|
129
|
-
|
|
121
|
+
c.current.dispatchEvent(h);
|
|
130
122
|
}
|
|
131
123
|
},
|
|
132
|
-
[e,
|
|
133
|
-
),
|
|
134
|
-
(
|
|
135
|
-
|
|
124
|
+
[e, m, t]
|
|
125
|
+
), C = G(
|
|
126
|
+
(r) => {
|
|
127
|
+
f?.(r), !r.defaultPrevented && w(!0);
|
|
136
128
|
},
|
|
137
|
-
[
|
|
138
|
-
),
|
|
139
|
-
(
|
|
140
|
-
if (n?.(
|
|
141
|
-
if (
|
|
142
|
-
|
|
129
|
+
[f, w]
|
|
130
|
+
), R = G(
|
|
131
|
+
(r) => {
|
|
132
|
+
if (n?.(r), r.defaultPrevented) return;
|
|
133
|
+
if (r.key === " " || r.key === "Enter") {
|
|
134
|
+
r.preventDefault(), w(!0);
|
|
143
135
|
return;
|
|
144
136
|
}
|
|
145
|
-
const h = W(
|
|
137
|
+
const h = W(r, e.orientation, e.dir);
|
|
146
138
|
if (h) {
|
|
147
|
-
|
|
148
|
-
const
|
|
139
|
+
r.preventDefault();
|
|
140
|
+
const x = [...e.itemsRef.current], D = x.findIndex((i) => i.value === t);
|
|
149
141
|
if (D === -1) return;
|
|
150
142
|
if (h === "first") {
|
|
151
|
-
const
|
|
152
|
-
|
|
143
|
+
const i = x.find((j) => !j.disabled);
|
|
144
|
+
i && e.setValue(i.value, { focus: !0, user: !0 });
|
|
153
145
|
return;
|
|
154
146
|
}
|
|
155
147
|
if (h === "last") {
|
|
156
|
-
const
|
|
157
|
-
|
|
148
|
+
const i = [...x].reverse().find((j) => !j.disabled);
|
|
149
|
+
i && e.setValue(i.value, { focus: !0, user: !0 });
|
|
158
150
|
return;
|
|
159
151
|
}
|
|
160
|
-
const S = Q(
|
|
161
|
-
|
|
152
|
+
const S = Q(x, D, h, e.loop), s = x[S];
|
|
153
|
+
s && !s.disabled && e.setValue(s.value, { focus: !0, user: !0 });
|
|
162
154
|
}
|
|
163
155
|
},
|
|
164
156
|
[e, n, w, t]
|
|
165
157
|
), I = e.variant === "unstyled";
|
|
166
158
|
return /* @__PURE__ */ T(
|
|
167
|
-
|
|
159
|
+
g,
|
|
168
160
|
{
|
|
169
161
|
id: p,
|
|
170
|
-
ref:
|
|
162
|
+
ref: k,
|
|
171
163
|
type: "button",
|
|
172
164
|
role: "radio",
|
|
173
|
-
"aria-checked":
|
|
174
|
-
"aria-disabled":
|
|
175
|
-
"data-state":
|
|
176
|
-
"data-disabled":
|
|
165
|
+
"aria-checked": d,
|
|
166
|
+
"aria-disabled": m || void 0,
|
|
167
|
+
"data-state": d ? "checked" : "unchecked",
|
|
168
|
+
"data-disabled": m ? "" : void 0,
|
|
177
169
|
tabIndex: F,
|
|
178
|
-
onClick:
|
|
179
|
-
onKeyDown:
|
|
170
|
+
onClick: C,
|
|
171
|
+
onKeyDown: R,
|
|
180
172
|
className: q(
|
|
181
173
|
// Only apply default styles when not unstyled
|
|
182
174
|
!I && "border-input bg-background focus-visible:ring-ring inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border focus-visible:ring-2 focus-visible:ring-offset-2",
|
|
183
175
|
!I && "data-[state=checked]:border-primary data-[state=checked]:bg-primary/10 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
184
176
|
// Always preserve basic accessibility for unstyled variant
|
|
185
177
|
I && "border-sm focus-visible:ring-ring data-[state=checked]:border-selected-primary cursor-pointer rounded-sm border-2 border-transparent transition-opacity hover:opacity-70 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
|
|
186
|
-
|
|
178
|
+
a
|
|
187
179
|
),
|
|
188
|
-
...
|
|
180
|
+
...y,
|
|
189
181
|
children: [
|
|
190
182
|
/* @__PURE__ */ A(
|
|
191
183
|
"input",
|
|
192
184
|
{
|
|
193
|
-
ref:
|
|
185
|
+
ref: c,
|
|
194
186
|
type: "radio",
|
|
195
187
|
name: e.name,
|
|
196
188
|
value: t,
|
|
197
189
|
required: e.required,
|
|
198
|
-
disabled:
|
|
190
|
+
disabled: m,
|
|
199
191
|
form: e.form,
|
|
200
|
-
checked:
|
|
192
|
+
checked: d,
|
|
201
193
|
readOnly: !0,
|
|
202
194
|
tabIndex: -1,
|
|
203
195
|
"aria-hidden": "true",
|
|
@@ -210,7 +202,7 @@ const Y = P(
|
|
|
210
202
|
}
|
|
211
203
|
}
|
|
212
204
|
),
|
|
213
|
-
|
|
205
|
+
y.children
|
|
214
206
|
]
|
|
215
207
|
}
|
|
216
208
|
);
|
|
@@ -218,33 +210,33 @@ const Y = P(
|
|
|
218
210
|
);
|
|
219
211
|
Y.displayName = "RadioGroupItem";
|
|
220
212
|
const Z = P(
|
|
221
|
-
({ asChild:
|
|
213
|
+
({ asChild: u, className: a, forceMount: t, ...o }, l) => {
|
|
222
214
|
if (!B(H)) return null;
|
|
223
|
-
const [
|
|
215
|
+
const [f, y] = $(!1), b = V(null);
|
|
224
216
|
return K(
|
|
225
|
-
|
|
226
|
-
() =>
|
|
217
|
+
l,
|
|
218
|
+
() => b.current,
|
|
227
219
|
[]
|
|
228
|
-
),
|
|
229
|
-
const p =
|
|
220
|
+
), E(() => {
|
|
221
|
+
const p = b.current;
|
|
230
222
|
if (!p) return;
|
|
231
|
-
const
|
|
232
|
-
if (!
|
|
233
|
-
const
|
|
234
|
-
|
|
223
|
+
const v = p.closest('[role="radio"]');
|
|
224
|
+
if (!v) return;
|
|
225
|
+
const c = () => {
|
|
226
|
+
y(v.getAttribute("aria-checked") === "true");
|
|
235
227
|
};
|
|
236
|
-
|
|
237
|
-
const
|
|
238
|
-
return
|
|
239
|
-
}, []), !
|
|
240
|
-
|
|
228
|
+
c();
|
|
229
|
+
const d = new MutationObserver(c);
|
|
230
|
+
return d.observe(v, { attributes: !0, attributeFilter: ["aria-checked"] }), () => d.disconnect();
|
|
231
|
+
}, []), !f && !t ? null : /* @__PURE__ */ A(
|
|
232
|
+
u ? L : "span",
|
|
241
233
|
{
|
|
242
234
|
ref: (p) => {
|
|
243
|
-
|
|
235
|
+
b.current = p;
|
|
244
236
|
},
|
|
245
|
-
"data-state":
|
|
246
|
-
className: q("flex items-center justify-center text-current",
|
|
247
|
-
...
|
|
237
|
+
"data-state": f ? "checked" : "unchecked",
|
|
238
|
+
className: q("flex items-center justify-center text-current", a),
|
|
239
|
+
...o
|
|
248
240
|
}
|
|
249
241
|
);
|
|
250
242
|
}
|