@spear-ai/spectral 1.4.1 → 1.4.3
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/Accordion.d.ts +7 -7
- package/dist/Accordion.js +53 -51
- package/dist/Alert/AlertBase.js +6 -6
- package/dist/Alert.js +1 -1
- package/dist/Avatar.d.ts +2 -2
- package/dist/Avatar.js +46 -46
- package/dist/Badge.js +3 -3
- package/dist/Button.js +19 -12
- package/dist/ButtonGroup/ButtonGroupButton.d.ts +1 -1
- package/dist/ButtonGroup/ButtonGroupButton.js +10 -10
- package/dist/ButtonGroup.d.ts +8 -5
- package/dist/ButtonGroup.js +22 -14
- package/dist/ButtonIcon.d.ts +1 -1
- package/dist/ButtonIcon.js +5 -5
- package/dist/Card.d.ts +1 -1
- package/dist/Card.js +10 -10
- package/dist/Checkbox/CheckboxBase.d.ts +6 -6
- package/dist/Checkbox/CheckboxBase.js +65 -63
- package/dist/Checkbox.js +16 -14
- package/dist/Dialog/DialogBase.d.ts +37 -25
- package/dist/Dialog/DialogBase.js +130 -104
- package/dist/Dialog.d.ts +8 -8
- package/dist/Dialog.js +46 -36
- package/dist/Drawer.js +17 -17
- package/dist/HoverCard.d.ts +4 -4
- package/dist/HoverCard.js +34 -33
- package/dist/Input.js +58 -58
- package/dist/InputOTP.d.ts +1 -1
- package/dist/InputOTP.js +113 -112
- package/dist/MultiSelect/MultiSelectBase.d.ts +16 -16
- package/dist/MultiSelect/MultiSelectBase.js +236 -177
- package/dist/MultiSelect/MutiSelect.d.ts +6 -4
- package/dist/MultiSelect/MutiSelect.js +13 -12
- package/dist/Popover.js +2 -1
- package/dist/RadioButtonGroup/RadioButtonGroupBase.js +18 -17
- package/dist/RadioGroup.js +5 -3
- package/dist/Select.js +70 -51
- package/dist/Slider.js +8 -4
- package/dist/Switch/SwitchBase.d.ts +6 -6
- package/dist/Switch/SwitchBase.js +39 -38
- package/dist/Switch.js +17 -16
- package/dist/Tabs/TabsBase.js +40 -25
- package/dist/Tabs.js +18 -21
- package/dist/Textarea.d.ts +1 -0
- package/dist/Textarea.js +33 -33
- package/dist/Toggle.js +4 -4
- package/dist/ToggleGroup/ToggleGroupBase.d.ts +7 -7
- package/dist/ToggleGroup/ToggleGroupBase.js +64 -64
- package/dist/ToggleGroup.js +19 -17
- package/dist/Tooltip/TooltipBase.d.ts +8 -8
- package/dist/Tooltip/TooltipBase.js +76 -74
- package/dist/Tooltip.d.ts +1 -1
- package/dist/Tooltip.js +12 -11
- package/dist/Tray.d.ts +1 -1
- package/dist/Tray.js +4910 -117
- package/dist/primitives/input.js +4 -4
- package/dist/primitives/select.d.ts +11 -11
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +28 -21
- package/dist/styles/main.css +1 -1
- package/dist/utils/{refs.d.ts → createForwardRef.d.ts} +1 -1
- package/dist/utils/createForwardRef.d.ts.map +1 -0
- package/dist/utils/formFieldUtils.d.ts +22 -18
- package/dist/utils/formFieldUtils.d.ts.map +1 -1
- package/dist/utils/formFieldUtils.js +46 -46
- package/package.json +9 -5
- package/dist/analyzer/list.yml.webp +0 -0
- package/dist/analyzer/network.webp +0 -0
- package/dist/analyzer/sunburst.webp +0 -0
- package/dist/analyzer/visual.webp +0 -0
- package/dist/auth-background.json +0 -90
- package/dist/favicon-invert.svg +0 -5
- package/dist/favicon.svg +0 -5
- package/dist/features/AuthCard/AuthCard.d.ts +0 -3
- package/dist/features/AuthCard/AuthCard.d.ts.map +0 -1
- package/dist/features/AuthCard/AuthToggle.d.ts +0 -9
- package/dist/features/AuthCard/AuthToggle.d.ts.map +0 -1
- package/dist/features/AuthCard/AuthToggle.js +0 -20
- package/dist/features/AuthCard/ForgotPasswordEmailForm.d.ts +0 -11
- package/dist/features/AuthCard/ForgotPasswordEmailForm.d.ts.map +0 -1
- package/dist/features/AuthCard/ForgotPasswordEmailForm.js +0 -86
- package/dist/features/AuthCard/ForgotPasswordResetForm.d.ts +0 -11
- package/dist/features/AuthCard/ForgotPasswordResetForm.d.ts.map +0 -1
- package/dist/features/AuthCard/ForgotPasswordResetForm.js +0 -21
- package/dist/features/AuthCard/OTPInput.d.ts +0 -12
- package/dist/features/AuthCard/OTPInput.d.ts.map +0 -1
- package/dist/features/AuthCard/OTPInput.js +0 -12
- package/dist/features/AuthCard/PasswordInput.d.ts +0 -13
- package/dist/features/AuthCard/PasswordInput.d.ts.map +0 -1
- package/dist/features/AuthCard/PasswordInput.js +0 -93
- package/dist/features/AuthCard/SignInForm.d.ts +0 -9
- package/dist/features/AuthCard/SignInForm.d.ts.map +0 -1
- package/dist/features/AuthCard/SignInForm.js +0 -86
- package/dist/features/AuthCard/SignUpForm.d.ts +0 -8
- package/dist/features/AuthCard/SignUpForm.d.ts.map +0 -1
- package/dist/features/AuthCard/SignUpForm.js +0 -100
- package/dist/features/AuthCard.js +0 -202
- package/dist/features/ClearDialog/ClearDialog.d.ts +0 -2
- package/dist/features/ClearDialog/ClearDialog.d.ts.map +0 -1
- package/dist/features/ClearDialog.js +0 -31
- package/dist/features/LabelingToolbar/LabelingToolbar.d.ts +0 -8
- package/dist/features/LabelingToolbar/LabelingToolbar.d.ts.map +0 -1
- package/dist/features/LabelingToolbar.js +0 -13
- package/dist/features/LabelingTools/LabelingTools.d.ts +0 -2
- package/dist/features/LabelingTools/LabelingTools.d.ts.map +0 -1
- package/dist/features/LabelingTools.js +0 -134
- package/dist/features/SensorMetadata/SensorMetadata.d.ts +0 -2
- package/dist/features/SensorMetadata/SensorMetadata.d.ts.map +0 -1
- package/dist/features/SensorMetadata.js +0 -117
- package/dist/features/SettingsPopover/SettingsPopover.d.ts +0 -2
- package/dist/features/SettingsPopover/SettingsPopover.d.ts.map +0 -1
- package/dist/features/SettingsPopover.js +0 -204
- package/dist/index-BIpuW_o8.js +0 -146
- package/dist/linear-cursor-small.png +0 -0
- package/dist/loader-circle-CdRVlFhN.js +0 -11
- package/dist/logo/wordmark-dark-side-by-side.svg +0 -6
- package/dist/logo/wordmark-light-side-by-side.svg +0 -6
- package/dist/message-alert-matte-glass-gradient.webp +0 -0
- package/dist/proxy-C9AqCss6.js +0 -4670
- package/dist/speech-bubble-fluid-glass-gradient.webp +0 -0
- package/dist/themes/grayscale-theme.webp +0 -0
- package/dist/themes/green-black-theme.webp +0 -0
- package/dist/themes/reverse-grayscale-theme.webp +0 -0
- package/dist/themes/viridis-theme.webp +0 -0
- package/dist/utils/refs.d.ts.map +0 -1
- package/dist/x-Dl66o_vF.js +0 -14
- /package/dist/utils/{refs.js → createForwardRef.js} +0 -0
package/dist/Tabs/TabsBase.js
CHANGED
|
@@ -3,19 +3,19 @@ import "../styles/main.css";
|
|
|
3
3
|
import { jsx as x, jsxs as R } from "react/jsx-runtime";
|
|
4
4
|
import { generateId as $, prefersReducedMotion as _, debounce as L, getIndicatorPosition as S, calculateIndicatorStyle as K } from "./tabsUtils.js";
|
|
5
5
|
import { cn as y } from "../utils/twUtils.js";
|
|
6
|
-
import { createContext as M, forwardRef as z, useState as D, useId as N, useCallback as
|
|
6
|
+
import { createContext as M, forwardRef as z, useState as D, useId as N, useCallback as w, useRef as k, useEffect as O, useContext as P } from "react";
|
|
7
7
|
const E = M(null), C = (I = "Tabs") => {
|
|
8
8
|
const u = P(E);
|
|
9
9
|
if (u === null)
|
|
10
10
|
throw new Error(`${I} components must be used within a Tabs.Root`);
|
|
11
11
|
return u;
|
|
12
12
|
}, B = z(function({ activationMode: u = "automatic", children: e, defaultValue: h, dir: b = "ltr", disabled: l = !1, onValueChange: f, orientation: o = "horizontal", value: v, ...s }, c) {
|
|
13
|
-
const [m, g] = D(h ?? ""), d = N() ?? $("tabs"),
|
|
14
|
-
(
|
|
15
|
-
l || (
|
|
13
|
+
const [m, g] = D(h ?? ""), d = N() ?? $("tabs"), a = v !== void 0, t = a ? v : m, n = w(
|
|
14
|
+
(p) => {
|
|
15
|
+
l || (a || g(p), f?.(p));
|
|
16
16
|
},
|
|
17
|
-
[
|
|
18
|
-
),
|
|
17
|
+
[a, f, l]
|
|
18
|
+
), r = {
|
|
19
19
|
value: t,
|
|
20
20
|
onValueChange: n,
|
|
21
21
|
orientation: o,
|
|
@@ -24,7 +24,7 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
24
24
|
disabled: l,
|
|
25
25
|
baseId: d
|
|
26
26
|
};
|
|
27
|
-
return /* @__PURE__ */ x(E.Provider, { value:
|
|
27
|
+
return /* @__PURE__ */ x(E.Provider, { value: r, children: /* @__PURE__ */ x("div", { ref: c, "data-testid": "spectral-tabs-root", "data-orientation": o, "data-disabled": l ? "" : void 0, dir: b, ...s, children: e }) });
|
|
28
28
|
}), H = z(function({ className: u, loop: e = !0, ...h }, b) {
|
|
29
29
|
const { orientation: l, disabled: f } = C("TabsList"), [o, v] = D(() => ({
|
|
30
30
|
left: 0,
|
|
@@ -33,7 +33,7 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
33
33
|
height: 0,
|
|
34
34
|
orientation: "horizontal",
|
|
35
35
|
isEnclosed: !1
|
|
36
|
-
})), s = k(null), c = _(), m =
|
|
36
|
+
})), s = k(null), c = _(), m = w(
|
|
37
37
|
L(() => {
|
|
38
38
|
const d = K(s);
|
|
39
39
|
v(d);
|
|
@@ -43,30 +43,30 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
43
43
|
);
|
|
44
44
|
O(() => {
|
|
45
45
|
m();
|
|
46
|
-
const d = new ResizeObserver(m),
|
|
47
|
-
return t && (d.observe(t),
|
|
46
|
+
const d = new ResizeObserver(m), a = new MutationObserver(m), t = s.current;
|
|
47
|
+
return t && (d.observe(t), a.observe(t, {
|
|
48
48
|
attributes: !0,
|
|
49
49
|
childList: !0,
|
|
50
50
|
subtree: !0
|
|
51
51
|
})), () => {
|
|
52
|
-
d.disconnect(),
|
|
52
|
+
d.disconnect(), a.disconnect();
|
|
53
53
|
};
|
|
54
54
|
}, [m]);
|
|
55
|
-
const g =
|
|
55
|
+
const g = w(
|
|
56
56
|
(d) => {
|
|
57
57
|
if (f) return;
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
const t =
|
|
58
|
+
const a = Array.from(s.current?.querySelectorAll("[role='tab']:not([disabled]):not([aria-disabled='true'])") ?? []);
|
|
59
|
+
if (a.length === 0) return;
|
|
60
|
+
const t = a.findIndex((T) => T === document.activeElement);
|
|
61
61
|
if (t === -1) return;
|
|
62
62
|
let n = null;
|
|
63
|
-
const { key:
|
|
64
|
-
l === "horizontal" ?
|
|
63
|
+
const { key: r, ctrlKey: p, metaKey: A } = d, i = p || A;
|
|
64
|
+
l === "horizontal" ? r === "ArrowLeft" || r === "ArrowUp" && i ? n = t > 0 ? t - 1 : e ? a.length - 1 : t : (r === "ArrowRight" || r === "ArrowDown" && i) && (n = t < a.length - 1 ? t + 1 : e ? 0 : t) : r === "ArrowUp" || r === "ArrowLeft" && i ? n = t > 0 ? t - 1 : e ? a.length - 1 : t : (r === "ArrowDown" || r === "ArrowRight" && i) && (n = t < a.length - 1 ? t + 1 : e ? 0 : t), r === "Home" ? n = 0 : r === "End" && (n = a.length - 1), n !== null && n !== t && (d.preventDefault(), d.stopPropagation(), a[n]?.focus());
|
|
65
65
|
},
|
|
66
66
|
[f, l, e]
|
|
67
67
|
);
|
|
68
68
|
return /* @__PURE__ */ R("div", { className: "relative", ref: s, children: [
|
|
69
|
-
/* @__PURE__ */ x("div", { ref: b, role: "tablist", "aria-orientation": l, "aria-disabled": f, className: y("tabs-list", u), onKeyDown: g, ...h }),
|
|
69
|
+
/* @__PURE__ */ x("div", { ref: b, role: "tablist", "data-testid": "spectral-tabs-list", "aria-orientation": l, "aria-disabled": f, className: y("tabs-list", u), onKeyDown: g, ...h }),
|
|
70
70
|
/* @__PURE__ */ x(
|
|
71
71
|
"div",
|
|
72
72
|
{
|
|
@@ -92,7 +92,7 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
92
92
|
)
|
|
93
93
|
] });
|
|
94
94
|
}), G = z(function({ className: u, value: e, onClick: h, onKeyDown: b, disabled: l = !1, ...f }, o) {
|
|
95
|
-
const { value: v, onValueChange: s, activationMode: c, disabled: m, baseId: g } = C("TabsTrigger"), d = `${g}-trigger-${e}`,
|
|
95
|
+
const { value: v, onValueChange: s, activationMode: c, disabled: m, baseId: g } = C("TabsTrigger"), d = `${g}-trigger-${e}`, a = `${g}-content-${e}`, t = v === e, n = m || l, r = w(
|
|
96
96
|
(i) => {
|
|
97
97
|
if (n) {
|
|
98
98
|
i.preventDefault();
|
|
@@ -101,7 +101,7 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
101
101
|
s(e), h?.(i);
|
|
102
102
|
},
|
|
103
103
|
[e, s, h, n]
|
|
104
|
-
),
|
|
104
|
+
), p = w(
|
|
105
105
|
(i) => {
|
|
106
106
|
if (n) {
|
|
107
107
|
i.preventDefault();
|
|
@@ -111,7 +111,7 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
111
111
|
(T === "Enter" || T === " ") && (i.preventDefault(), i.stopPropagation(), s(e)), b?.(i);
|
|
112
112
|
},
|
|
113
113
|
[e, s, b, n]
|
|
114
|
-
), A =
|
|
114
|
+
), A = w(() => {
|
|
115
115
|
n || c === "automatic" && s(e);
|
|
116
116
|
}, [c, s, e, n]);
|
|
117
117
|
return /* @__PURE__ */ x(
|
|
@@ -120,8 +120,9 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
120
120
|
ref: o,
|
|
121
121
|
role: "tab",
|
|
122
122
|
type: "button",
|
|
123
|
+
"data-testid": "spectral-tabs-trigger",
|
|
123
124
|
id: d,
|
|
124
|
-
"aria-controls":
|
|
125
|
+
"aria-controls": a,
|
|
125
126
|
"aria-selected": t,
|
|
126
127
|
"aria-disabled": n,
|
|
127
128
|
disabled: n,
|
|
@@ -129,15 +130,29 @@ const E = M(null), C = (I = "Tabs") => {
|
|
|
129
130
|
"data-disabled": n ? "" : void 0,
|
|
130
131
|
tabIndex: t ? 0 : -1,
|
|
131
132
|
className: y("tabs-trigger z-10 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600", u),
|
|
132
|
-
onClick:
|
|
133
|
-
onKeyDown:
|
|
133
|
+
onClick: r,
|
|
134
|
+
onKeyDown: p,
|
|
134
135
|
onFocus: A,
|
|
135
136
|
...f
|
|
136
137
|
}
|
|
137
138
|
);
|
|
138
139
|
}), J = z(function({ className: u, value: e, forceMount: h = !1, ...b }, l) {
|
|
139
140
|
const { value: f, baseId: o } = C("TabsContent"), v = `${o}-content-${e}`, s = `${o}-trigger-${e}`, c = f === e;
|
|
140
|
-
return !h && !c ? null : /* @__PURE__ */ x(
|
|
141
|
+
return !h && !c ? null : /* @__PURE__ */ x(
|
|
142
|
+
"div",
|
|
143
|
+
{
|
|
144
|
+
ref: l,
|
|
145
|
+
role: "tabpanel",
|
|
146
|
+
"data-testid": "spectral-tabs-content",
|
|
147
|
+
id: v,
|
|
148
|
+
"aria-labelledby": s,
|
|
149
|
+
"data-state": c ? "active" : "inactive",
|
|
150
|
+
tabIndex: 0,
|
|
151
|
+
className: y("tabs-content focus:outline-none focus-visible:outline-none", u),
|
|
152
|
+
hidden: !c,
|
|
153
|
+
...b
|
|
154
|
+
}
|
|
155
|
+
);
|
|
141
156
|
});
|
|
142
157
|
export {
|
|
143
158
|
B as TabsBase,
|
package/dist/Tabs.js
CHANGED
|
@@ -1,43 +1,40 @@
|
|
|
1
1
|
import "./styles/main.css";
|
|
2
|
-
import {
|
|
2
|
+
import { jsx as a, jsxs as x } from "react/jsx-runtime";
|
|
3
3
|
import { TabsBase as N, TabsList as T, TabsTrigger as z, TabsContent as k } from "./Tabs/TabsBase.js";
|
|
4
|
-
import { validateTabValues as
|
|
4
|
+
import { validateTabValues as j, getTabKeys as C } from "./Tabs/tabsUtils.js";
|
|
5
5
|
import { cn as r } from "./utils/twUtils.js";
|
|
6
6
|
import "react";
|
|
7
|
-
const
|
|
7
|
+
const V = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ x("div", { className: "flex flex-col relative w-full", role: "status", children: [
|
|
8
8
|
/* @__PURE__ */ a("div", { className: r("inline-flex items-center justify-start w-full", s === "horizontal" && "border-b border-neutral-600", s === "vertical" && "flex-col items-stretch border-r border-neutral-600"), children: Array.from({ length: Math.min(d, 5) }, (i, t) => /* @__PURE__ */ a("div", { className: r("animate-pulse bg-neutral-600 rounded", s === "horizontal" ? "h-6 w-16 mx-2 my-2" : "h-6 w-full mx-2 my-1"), "aria-hidden": "true" }, t)) }),
|
|
9
9
|
/* @__PURE__ */ a("div", { className: "animate-pulse bg-neutral-600 h-32 w-full mt-4 rounded", "aria-hidden": "true" }),
|
|
10
10
|
/* @__PURE__ */ a("span", { className: "sr-only", children: "Loading tabs…" })
|
|
11
|
-
] }),
|
|
12
|
-
const o =
|
|
13
|
-
if (!
|
|
11
|
+
] }), L = ({ ariaLabel: d, className: s, openOnLoad: i, orientation: t = "horizontal", tabValues: f = [], variant: l = "default", activationMode: m = "automatic", loading: p = !1, onError: n, onBeforeChange: h, onValueChange: v, ...y }) => {
|
|
12
|
+
const o = f.filter((e) => e.key !== void 0);
|
|
13
|
+
if (!j(o)) {
|
|
14
14
|
const e = new Error("Invalid tabValues provided to Tabs component");
|
|
15
|
-
return n?.(e), /* @__PURE__ */
|
|
16
|
-
/* @__PURE__ */ a("p", { children: "No valid tabs provided" }),
|
|
17
|
-
process.env.NODE_ENV !== "production" && /* @__PURE__ */ a("p", { className: "text-xs mt-2 text-gray-400", children: "Check console for detailed validation errors" })
|
|
18
|
-
] });
|
|
15
|
+
return n?.(e), /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full p-4 text-center text-gray-500", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ a("p", { children: "No valid tabs provided" }) });
|
|
19
16
|
}
|
|
20
17
|
if (p)
|
|
21
|
-
return /* @__PURE__ */ a(
|
|
22
|
-
const
|
|
23
|
-
let c = i ??
|
|
24
|
-
if (i && !
|
|
18
|
+
return /* @__PURE__ */ a(V, { tabCount: f.length || 3, orientation: t });
|
|
19
|
+
const b = C(o);
|
|
20
|
+
let c = i ?? b[0];
|
|
21
|
+
if (i && !b.includes(i) && (console.warn(`Tabs: openOnLoad value '${i}' is not a valid tab key`), c = b[0]), !c) {
|
|
25
22
|
const e = new Error("No valid default tab available");
|
|
26
23
|
return n?.(e), /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full p-4 text-center text-text-secondary", role: "alert", "aria-live": "polite", children: /* @__PURE__ */ a("p", { children: "Unable to render tabs" }) });
|
|
27
24
|
}
|
|
28
25
|
const g = async (e) => {
|
|
29
|
-
if (
|
|
26
|
+
if (h && v) {
|
|
30
27
|
const w = c;
|
|
31
28
|
try {
|
|
32
|
-
if (await
|
|
33
|
-
} catch (
|
|
34
|
-
n?.(
|
|
29
|
+
if (await h(e, w) === !1) return;
|
|
30
|
+
} catch (u) {
|
|
31
|
+
n?.(u instanceof Error ? u : new Error("Before change callback failed"));
|
|
35
32
|
return;
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
|
|
35
|
+
v?.(e);
|
|
39
36
|
};
|
|
40
|
-
return /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full", children: /* @__PURE__ */
|
|
37
|
+
return /* @__PURE__ */ a("div", { className: "flex flex-col relative w-full", children: /* @__PURE__ */ x(N, { "aria-label": d, className: r("relative w-full data-[orientation=vertical]:flex", l, s), defaultValue: c, orientation: t, activationMode: m, onValueChange: g, ...y, children: [
|
|
41
38
|
/* @__PURE__ */ a(
|
|
42
39
|
T,
|
|
43
40
|
{
|
|
@@ -86,7 +83,7 @@ const j = ({ tabCount: d, orientation: s }) => /* @__PURE__ */ f("div", { classN
|
|
|
86
83
|
] }) });
|
|
87
84
|
};
|
|
88
85
|
export {
|
|
89
|
-
|
|
86
|
+
L as Tabs,
|
|
90
87
|
k as TabsContent,
|
|
91
88
|
T as TabsList,
|
|
92
89
|
N as TabsRoot,
|
package/dist/Textarea.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type TextareaProps = Omit<ComponentProps<'textarea'>, 'onChange'> & {
|
|
|
13
13
|
onChange?: (value: string) => void;
|
|
14
14
|
onFocus?: (e: FocusEvent<HTMLTextAreaElement>) => void;
|
|
15
15
|
placeholder?: string | undefined;
|
|
16
|
+
required?: boolean;
|
|
16
17
|
state?: TextareaState;
|
|
17
18
|
value?: string | undefined;
|
|
18
19
|
};
|
package/dist/Textarea.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./styles/main.css";
|
|
3
3
|
import { jsxs as n, jsx as e } from "react/jsx-runtime";
|
|
4
|
-
import { useTextarea as
|
|
4
|
+
import { useTextarea as z } from "./Textarea/TextareaUtils.js";
|
|
5
5
|
import "./Icons/AnalyzeIcon.js";
|
|
6
6
|
import "./Icons/AnnotationsIcon.js";
|
|
7
7
|
import "./Icons/ApprovedIcon.js";
|
|
@@ -33,7 +33,7 @@ import "./Icons/LassoIcon.js";
|
|
|
33
33
|
import "./Icons/LineToolIcon.js";
|
|
34
34
|
import "./Icons/LineToolIcon2.js";
|
|
35
35
|
import "./Icons/LiveViewIcon.js";
|
|
36
|
-
import { LoaderIcon as
|
|
36
|
+
import { LoaderIcon as B } from "./Icons/LoaderIcon.js";
|
|
37
37
|
import "./Icons/LocationIcon.js";
|
|
38
38
|
import "./Icons/LogoutIcon.js";
|
|
39
39
|
import "./Icons/MessagesIcon.js";
|
|
@@ -59,67 +59,67 @@ import "./Icons/WarningIcon.js";
|
|
|
59
59
|
import "./Icons/ZoomAllIcon.js";
|
|
60
60
|
import "./Icons/ZoomXIcon.js";
|
|
61
61
|
import "./Icons/ZoomYIcon.js";
|
|
62
|
-
import { Label as
|
|
63
|
-
import { useFormFieldId as
|
|
62
|
+
import { Label as D } from "./Label.js";
|
|
63
|
+
import { useFormFieldId as M, getAriaProps as O, getErrorMessageId as _, getTextareaClasses as $, useFormFieldState as G, ErrorMessage as V } from "./utils/formFieldUtils.js";
|
|
64
64
|
import { cn as g } from "./utils/twUtils.js";
|
|
65
|
-
import { forwardRef as
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
return g(
|
|
69
|
-
},
|
|
70
|
-
({ autoComplete: t, className: a, disabled:
|
|
71
|
-
const p =
|
|
65
|
+
import { forwardRef as H, useRef as J } from "react";
|
|
66
|
+
const K = "absolute right-4 top-4", Q = (t) => t || "off", U = (t, a) => {
|
|
67
|
+
const s = "absolute bottom-2 right-3 text-xs pointer-events-none z-10 tabular-nums", o = t >= a ? "text-danger-400" : "text-text-secondary";
|
|
68
|
+
return g(s, o);
|
|
69
|
+
}, W = H(
|
|
70
|
+
({ autoComplete: t, className: a, disabled: s, errorMessage: o, id: C, label: c, labelClassName: b, maxLength: i = 280, name: d, onBlur: N, onChange: I, onFocus: F, placeholder: S, required: u, state: r = "default", value: m = "", ...x }, v) => {
|
|
71
|
+
const p = M(C, d), h = _(p), y = J(null), P = v || y, { handleFocus: T, handleBlur: A, handleChange: R, handlePaste: w } = z({
|
|
72
72
|
maxLength: i,
|
|
73
|
-
value:
|
|
74
|
-
onChange:
|
|
73
|
+
value: m,
|
|
74
|
+
onChange: I || (() => {
|
|
75
75
|
}),
|
|
76
|
-
onFocus:
|
|
76
|
+
onFocus: F,
|
|
77
77
|
onBlur: N
|
|
78
|
-
}), { isDisabled: f, isLoading:
|
|
78
|
+
}), { isDisabled: f, isLoading: E } = G(s, r), L = O(r, h, u, x["aria-describedby"]), l = m?.length || 0, j = $(r, a), k = () => ({
|
|
79
79
|
"--textarea-min-height": "6rem",
|
|
80
80
|
"--textarea-max-height": "12rem",
|
|
81
81
|
"--textarea-border-radius": "0.5rem"
|
|
82
82
|
});
|
|
83
|
-
return /* @__PURE__ */ n("div", { className: "w-full",
|
|
84
|
-
|
|
85
|
-
/* @__PURE__ */ n("div", { className: "relative", "data-testid": "textarea-
|
|
83
|
+
return /* @__PURE__ */ n("div", { className: "w-full", children: [
|
|
84
|
+
c && /* @__PURE__ */ e(D, { "data-testid": "spectral-textarea-label", htmlFor: p, className: g("block mb-2", f && "opacity-50 cursor-not-allowed", b), children: c }),
|
|
85
|
+
/* @__PURE__ */ n("div", { className: "relative", "data-testid": "spectral-textarea-container", children: [
|
|
86
86
|
/* @__PURE__ */ e(
|
|
87
87
|
"textarea",
|
|
88
88
|
{
|
|
89
89
|
"aria-multiline": "true",
|
|
90
|
-
autoComplete:
|
|
91
|
-
className:
|
|
90
|
+
autoComplete: Q(t),
|
|
91
|
+
className: j,
|
|
92
92
|
"data-state": r,
|
|
93
|
-
"data-testid": "
|
|
93
|
+
"data-testid": "spectral-textarea",
|
|
94
94
|
disabled: f,
|
|
95
95
|
id: p,
|
|
96
|
-
name:
|
|
96
|
+
name: d,
|
|
97
97
|
onBlur: A,
|
|
98
98
|
onChange: R,
|
|
99
|
-
onFocus:
|
|
100
|
-
onPaste:
|
|
101
|
-
placeholder:
|
|
99
|
+
onFocus: T,
|
|
100
|
+
onPaste: w,
|
|
101
|
+
placeholder: S,
|
|
102
102
|
ref: P,
|
|
103
103
|
required: u,
|
|
104
104
|
spellCheck: "true",
|
|
105
|
-
style:
|
|
106
|
-
value:
|
|
107
|
-
...
|
|
105
|
+
style: k(),
|
|
106
|
+
value: m,
|
|
107
|
+
...L,
|
|
108
108
|
...x
|
|
109
109
|
}
|
|
110
110
|
),
|
|
111
|
-
|
|
112
|
-
/* @__PURE__ */ n("div", { className:
|
|
111
|
+
E && /* @__PURE__ */ e("div", { className: K, "data-testid": "spectral-textarea-loading-icon", children: /* @__PURE__ */ e(B, { size: 24 }) }),
|
|
112
|
+
/* @__PURE__ */ n("div", { className: U(l, i), role: "status", "aria-live": "polite", "aria-label": `${l} of ${i} characters used`, children: [
|
|
113
113
|
l,
|
|
114
114
|
"/",
|
|
115
115
|
i
|
|
116
116
|
] })
|
|
117
117
|
] }),
|
|
118
|
-
r === "error" && o && /* @__PURE__ */ e(
|
|
118
|
+
r === "error" && o && /* @__PURE__ */ e(V, { dataTestId: "spectral-textarea-error-message", id: h, message: o })
|
|
119
119
|
] });
|
|
120
120
|
}
|
|
121
121
|
);
|
|
122
|
-
|
|
122
|
+
W.displayName = "Textarea";
|
|
123
123
|
export {
|
|
124
|
-
|
|
124
|
+
W as Textarea
|
|
125
125
|
};
|
package/dist/Toggle.js
CHANGED
|
@@ -20,9 +20,9 @@ const v = d(
|
|
|
20
20
|
outline: "border-toggle-outline-border hover:bg-toggle-bg--hover"
|
|
21
21
|
},
|
|
22
22
|
size: {
|
|
23
|
-
default:
|
|
24
|
-
sm:
|
|
25
|
-
lg:
|
|
23
|
+
default: "h-9 px-3 min-w-9 [&_svg:not([class*='size-']:not([width]):not([height])]:size-4",
|
|
24
|
+
sm: "h-8 px-1.5 min-w-8 [&_svg:not([class*='size-']:not([width]):not([height])]:size-3",
|
|
25
|
+
lg: "h-10 px-2.5 min-w-10 [&_svg:not([class*='size-']:not([width]):not([height])]:size-5"
|
|
26
26
|
},
|
|
27
27
|
layout: {
|
|
28
28
|
default: "w-fit",
|
|
@@ -35,7 +35,7 @@ const v = d(
|
|
|
35
35
|
layout: "default"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
), m = l(({ className: e, variant: t, size: o, layout: r, ...a }, i) => /* @__PURE__ */ g(n, { ref: i, "data-slot": "toggle", className: s(v({ variant: t, size: o, layout: r }), e), ...a }));
|
|
38
|
+
), m = l(({ className: e, variant: t, size: o, layout: r, ...a }, i) => /* @__PURE__ */ g(n, { ref: i, "data-slot": "toggle", "data-testid": "spectral-toggle", className: s(v({ variant: t, size: o, layout: r }), e), ...a }));
|
|
39
39
|
export {
|
|
40
40
|
m as Toggle,
|
|
41
41
|
v as toggleVariants
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
2
2
|
type Orientation = 'horizontal' | 'vertical';
|
|
3
3
|
export type CommonGroupProps = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
className?: string;
|
|
5
|
+
defaultValue?: string | string[];
|
|
6
6
|
disabled?: boolean;
|
|
7
|
+
loop?: boolean;
|
|
7
8
|
name?: string;
|
|
8
|
-
value?: string | string[];
|
|
9
|
-
defaultValue?: string | string[];
|
|
10
9
|
onValueChange?: (v: string | string[]) => void;
|
|
11
|
-
|
|
10
|
+
orientation?: Orientation;
|
|
11
|
+
value?: string | string[];
|
|
12
12
|
};
|
|
13
13
|
export type SingleProps = CommonGroupProps & {
|
|
14
14
|
type?: 'single';
|
|
@@ -18,10 +18,10 @@ export type MultipleProps = CommonGroupProps & {
|
|
|
18
18
|
};
|
|
19
19
|
export type ToggleGroupProps = (SingleProps | MultipleProps) & Omit<HTMLAttributes<HTMLDivElement>, 'onChange'>;
|
|
20
20
|
export type ItemRenderProps = {
|
|
21
|
-
value: string;
|
|
22
|
-
disabled?: boolean;
|
|
23
21
|
children?: ReactNode;
|
|
24
22
|
className?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
value: string;
|
|
25
25
|
};
|
|
26
26
|
export declare const ToggleGroupBase: (props: ToggleGroupProps & Record<`data-${string}`, any>) => import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
export type ToggleGroupItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange' | 'onPressedChange' | 'pressed' | 'defaultPressed'> & ItemRenderProps;
|
|
@@ -1,96 +1,96 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import { jsx as
|
|
3
|
+
import { jsx as C, jsxs as E } from "react/jsx-runtime";
|
|
4
4
|
import { useControllableState as R } from "../hooks/useControllableState.js";
|
|
5
5
|
import { clamp as M } from "../utils/sharedUtils.js";
|
|
6
|
-
import { createContext as j, forwardRef as H, useContext as K, useRef as S, useImperativeHandle as L, useEffect as N, useCallback as
|
|
7
|
-
const T = j(null), W = (
|
|
6
|
+
import { createContext as j, forwardRef as H, useContext as K, useRef as S, useImperativeHandle as L, useEffect as N, useCallback as l, useMemo as U } from "react";
|
|
7
|
+
const T = j(null), W = (z) => {
|
|
8
8
|
const {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
className: o,
|
|
10
|
+
defaultValue: i,
|
|
11
|
+
disabled: x = !1,
|
|
12
|
+
loop: c = !0,
|
|
13
13
|
name: u,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"data-variant":
|
|
19
|
-
"data-size":
|
|
20
|
-
"data-slot":
|
|
21
|
-
"data-layout":
|
|
14
|
+
onValueChange: v,
|
|
15
|
+
orientation: b = "horizontal",
|
|
16
|
+
type: d = "single",
|
|
17
|
+
value: a,
|
|
18
|
+
"data-variant": V,
|
|
19
|
+
"data-size": w,
|
|
20
|
+
"data-slot": f,
|
|
21
|
+
"data-layout": A,
|
|
22
22
|
...G
|
|
23
|
-
} =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}),
|
|
23
|
+
} = z, p = d === "multiple", [n, m] = R({
|
|
24
|
+
defaultValue: typeof i < "u" ? i : p ? [] : "",
|
|
25
|
+
onChange: v,
|
|
26
|
+
value: a
|
|
27
|
+
}), r = S([]), g = l((t, s) => {
|
|
28
28
|
const P = { val: t, el: s, disabled: !!s?.disabled };
|
|
29
|
-
return
|
|
30
|
-
|
|
29
|
+
return r.current = [...r.current.filter((D) => D.val !== t), P], () => {
|
|
30
|
+
r.current = r.current.filter((D) => D.val !== t);
|
|
31
31
|
};
|
|
32
|
-
}, []),
|
|
33
|
-
(t) =>
|
|
34
|
-
[
|
|
35
|
-
), e =
|
|
32
|
+
}, []), k = l(() => r.current.slice(), []), B = l(
|
|
33
|
+
(t) => p ? Array.isArray(n) && n.includes(t) : n === t,
|
|
34
|
+
[p, n]
|
|
35
|
+
), e = l((t) => m(t), [m]), y = l(
|
|
36
36
|
(t) => {
|
|
37
|
-
const s =
|
|
37
|
+
const s = r.current;
|
|
38
38
|
if (s.length === 0) return;
|
|
39
|
-
const P = s.length - 1,
|
|
40
|
-
s[
|
|
39
|
+
const P = s.length - 1, D = c ? (t % s.length + s.length) % s.length : M(t, 0, P);
|
|
40
|
+
s[D]?.el?.focus();
|
|
41
41
|
},
|
|
42
|
-
[
|
|
43
|
-
),
|
|
42
|
+
[c]
|
|
43
|
+
), h = U(
|
|
44
44
|
() => ({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
loop:
|
|
50
|
-
groupDisabled: I,
|
|
45
|
+
focusItemByIndex: y,
|
|
46
|
+
groupDisabled: x,
|
|
47
|
+
isItemPressed: B,
|
|
48
|
+
itemsSnapshot: k,
|
|
49
|
+
loop: c,
|
|
51
50
|
name: u,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
orientation: b,
|
|
52
|
+
register: g,
|
|
53
|
+
setValue: e,
|
|
54
|
+
type: d,
|
|
55
|
+
value: n
|
|
56
56
|
}),
|
|
57
|
-
[
|
|
58
|
-
),
|
|
59
|
-
return /* @__PURE__ */ E("div", {
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
[x, B, k, c, u, b, e, d, n]
|
|
58
|
+
), I = u;
|
|
59
|
+
return /* @__PURE__ */ E("div", { className: o, "data-disabled": x ? "" : void 0, "data-layout": A, "data-orientation": b, "data-size": w, "data-slot": f, "data-variant": V, role: "group", ...G, children: [
|
|
60
|
+
/* @__PURE__ */ C(T.Provider, { value: h, children: z.children }),
|
|
61
|
+
I && d === "single" && typeof n == "string" ? /* @__PURE__ */ C("input", { type: "hidden", name: I, value: n }) : null,
|
|
62
|
+
I && d === "multiple" && Array.isArray(n) ? n.map((t) => /* @__PURE__ */ C("input", { type: "hidden", name: I + "[]", value: t }, t)) : null
|
|
63
63
|
] });
|
|
64
|
-
}, X = H(function({ value:
|
|
64
|
+
}, X = H(function({ value: o, disabled: i, className: x, children: c, onKeyDown: u, onClick: v, ...b }, d) {
|
|
65
65
|
const a = K(T);
|
|
66
66
|
if (!a) throw new Error("ToggleGroupItem must be used within ToggleGroup");
|
|
67
|
-
const { type:
|
|
68
|
-
L(
|
|
69
|
-
const
|
|
70
|
-
if (!(
|
|
71
|
-
if (
|
|
67
|
+
const { type: V, orientation: w, groupDisabled: f, setValue: A, isItemPressed: G, itemsSnapshot: p, register: n } = a, m = S(null);
|
|
68
|
+
L(d, () => m.current), N(() => n(o, m.current), [n, o]);
|
|
69
|
+
const r = G(o), g = l(() => {
|
|
70
|
+
if (!(f || i))
|
|
71
|
+
if (V === "single") A(r ? "" : o);
|
|
72
72
|
else {
|
|
73
|
-
const e = a.value,
|
|
74
|
-
|
|
73
|
+
const e = a.value, y = r ? e.filter((h) => h !== o) : [...e, o];
|
|
74
|
+
A(y);
|
|
75
75
|
}
|
|
76
|
-
}, [a.value,
|
|
76
|
+
}, [a.value, i, f, r, A, V, o]), k = l(
|
|
77
77
|
(e) => {
|
|
78
78
|
if (u && u(e), e.defaultPrevented) return;
|
|
79
79
|
if (e.key === " " || e.key === "Enter") {
|
|
80
|
-
e.preventDefault(),
|
|
80
|
+
e.preventDefault(), g();
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
const
|
|
84
|
-
e.key ===
|
|
83
|
+
const y = p(), h = y.findIndex((s) => s.val === o), I = w === "horizontal" ? "ArrowLeft" : "ArrowUp", t = w === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
84
|
+
e.key === I ? (e.preventDefault(), a.focusItemByIndex(h - 1)) : e.key === t ? (e.preventDefault(), a.focusItemByIndex(h + 1)) : e.key === "Home" ? (e.preventDefault(), a.focusItemByIndex(0)) : e.key === "End" && (e.preventDefault(), a.focusItemByIndex(y.length - 1));
|
|
85
85
|
},
|
|
86
|
-
[a,
|
|
87
|
-
),
|
|
86
|
+
[a, p, u, w, g, o]
|
|
87
|
+
), B = l(
|
|
88
88
|
(e) => {
|
|
89
|
-
|
|
89
|
+
v && v(e), !e.defaultPrevented && g();
|
|
90
90
|
},
|
|
91
|
-
[
|
|
91
|
+
[v, g]
|
|
92
92
|
);
|
|
93
|
-
return /* @__PURE__ */
|
|
93
|
+
return /* @__PURE__ */ C("button", { "aria-pressed": r, className: x, "data-disabled": f || i ? "" : void 0, "data-state": r ? "on" : "off", disabled: f || i, onClick: B, onKeyDown: k, ref: m, type: "button", ...b, children: c });
|
|
94
94
|
});
|
|
95
95
|
export {
|
|
96
96
|
W as ToggleGroupBase,
|