@spear-ai/spectral 1.4.25 → 1.4.27
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 +28 -9
- package/dist/Accordion.js +203 -183
- package/dist/Alert/AlertBase.d.ts +24 -16
- package/dist/Alert/AlertBase.js +33 -18
- package/dist/Alert.js +1 -1
- package/dist/Avatar.js +11 -11
- package/dist/Button.d.ts +7 -2
- package/dist/Button.js +25 -12
- package/dist/ButtonIcon.d.ts +7 -2
- package/dist/ButtonIcon.js +25 -16
- package/dist/Card.js +1 -1
- package/dist/Checkbox/CheckboxBase.d.ts +13 -13
- package/dist/Checkbox/CheckboxBase.js +128 -125
- package/dist/Checkbox.d.ts +7 -2
- package/dist/Checkbox.js +29 -22
- package/dist/DataCard.js +3 -3
- package/dist/Dialog.js +2 -2
- package/dist/Drawer.js +2 -2
- package/dist/HoverCard.js +1 -1
- package/dist/Icons/AnalyzeIcon.d.ts +3 -1
- package/dist/Icons/AnalyzeIcon.js +3 -6
- package/dist/Icons/AnnotationsIcon.d.ts +3 -1
- package/dist/Icons/AnnotationsIcon.js +3 -6
- package/dist/Icons/ApprovedIcon.d.ts +3 -1
- package/dist/Icons/ApprovedIcon.js +3 -6
- package/dist/Icons/ArrowDownIcon.d.ts +3 -1
- package/dist/Icons/ArrowDownIcon.js +3 -6
- package/dist/Icons/ArrowUpIcon.d.ts +3 -1
- package/dist/Icons/ArrowUpIcon.js +4 -7
- package/dist/Icons/CalendarIcon.d.ts +3 -1
- package/dist/Icons/CalendarIcon.js +9 -12
- package/dist/Icons/CheckCircleIcon.d.ts +3 -1
- package/dist/Icons/CheckCircleIcon.js +2 -5
- package/dist/Icons/CheckSquareIcon.d.ts +3 -1
- package/dist/Icons/CheckSquareIcon.js +4 -7
- package/dist/Icons/CheckmarkIcon.d.ts +3 -1
- package/dist/Icons/CheckmarkIcon.js +5 -8
- package/dist/Icons/ChevronDownIcon.d.ts +3 -1
- package/dist/Icons/ChevronDownIcon.js +5 -8
- package/dist/Icons/ChevronUpIcon.d.ts +3 -1
- package/dist/Icons/ChevronUpIcon.js +5 -8
- package/dist/Icons/ClockIcon.d.ts +3 -1
- package/dist/Icons/ClockIcon.js +5 -8
- package/dist/Icons/CloseCircleIcon.d.ts +3 -1
- package/dist/Icons/CloseCircleIcon.js +4 -7
- package/dist/Icons/CloseIcon.d.ts +3 -1
- package/dist/Icons/CloseIcon.js +5 -8
- package/dist/Icons/DashboardIcon.d.ts +3 -1
- package/dist/Icons/DashboardIcon.js +3 -6
- package/dist/Icons/DatabaseIcon.d.ts +3 -1
- package/dist/Icons/DatabaseIcon.js +4 -7
- package/dist/Icons/DeleteIcon.d.ts +3 -1
- package/dist/Icons/DeleteIcon.js +4 -7
- package/dist/Icons/DurationIcon.d.ts +3 -1
- package/dist/Icons/DurationIcon.js +3 -6
- package/dist/Icons/EditIcon.d.ts +3 -1
- package/dist/Icons/EditIcon.js +3 -6
- package/dist/Icons/EmailIcon.d.ts +3 -1
- package/dist/Icons/EmailIcon.js +4 -7
- package/dist/Icons/EraserIcon.d.ts +3 -1
- package/dist/Icons/EraserIcon.js +9 -10
- package/dist/Icons/ErrorIcon.d.ts +3 -1
- package/dist/Icons/ErrorIcon.js +4 -7
- package/dist/Icons/EyeClosedIcon.d.ts +3 -1
- package/dist/Icons/EyeClosedIcon.js +4 -7
- package/dist/Icons/EyeClosedIcon2.d.ts +3 -1
- package/dist/Icons/EyeClosedIcon2.js +3 -6
- package/dist/Icons/EyeOpenIcon.d.ts +3 -1
- package/dist/Icons/EyeOpenIcon.js +6 -9
- package/dist/Icons/GoToFirstIcon.d.ts +3 -1
- package/dist/Icons/GoToFirstIcon.js +4 -7
- package/dist/Icons/GoToLastIcon.d.ts +3 -1
- package/dist/Icons/GoToLastIcon.js +4 -7
- package/dist/Icons/HarmonicCursorsIcon.d.ts +3 -1
- package/dist/Icons/HarmonicCursorsIcon.js +4 -7
- package/dist/Icons/IconBase.d.ts +4 -2
- package/dist/Icons/IconBase.js +17 -8
- package/dist/Icons/InfoIcon.d.ts +3 -1
- package/dist/Icons/InfoIcon.js +4 -7
- package/dist/Icons/LabelIcon.d.ts +3 -1
- package/dist/Icons/LabelIcon.js +3 -6
- package/dist/Icons/LassoIcon.d.ts +3 -1
- package/dist/Icons/LassoIcon.js +5 -8
- package/dist/Icons/LineToolIcon.d.ts +3 -1
- package/dist/Icons/LineToolIcon.js +3 -6
- package/dist/Icons/LineToolIcon2.d.ts +3 -1
- package/dist/Icons/LineToolIcon2.js +3 -6
- package/dist/Icons/LiveViewIcon.d.ts +3 -1
- package/dist/Icons/LiveViewIcon.js +2 -5
- package/dist/Icons/LoaderIcon.d.ts +3 -1
- package/dist/Icons/LoaderIcon.js +6 -7
- package/dist/Icons/LocationIcon.d.ts +3 -1
- package/dist/Icons/LocationIcon.js +3 -6
- package/dist/Icons/LogoutIcon.d.ts +3 -1
- package/dist/Icons/LogoutIcon.js +4 -7
- package/dist/Icons/MessagesIcon.d.ts +3 -1
- package/dist/Icons/MessagesIcon.js +5 -8
- package/dist/Icons/MetadataIcon.d.ts +3 -1
- package/dist/Icons/MetadataIcon.js +4 -7
- package/dist/Icons/MinusIcon.d.ts +3 -1
- package/dist/Icons/MinusIcon.js +3 -6
- package/dist/Icons/OntologyIcon.d.ts +3 -1
- package/dist/Icons/OntologyIcon.js +2 -5
- package/dist/Icons/PanelIconClose.d.ts +3 -1
- package/dist/Icons/PanelIconClose.js +4 -7
- package/dist/Icons/PanelIconOpen.d.ts +3 -1
- package/dist/Icons/PanelIconOpen.js +8 -11
- package/dist/Icons/PlayIcon.d.ts +3 -1
- package/dist/Icons/PlayIcon.js +3 -6
- package/dist/Icons/PlusIcon.d.ts +3 -1
- package/dist/Icons/PlusIcon.js +4 -7
- package/dist/Icons/ResetIcon.d.ts +3 -1
- package/dist/Icons/ResetIcon.js +4 -7
- package/dist/Icons/ReviewedIcon.d.ts +3 -1
- package/dist/Icons/ReviewedIcon.js +3 -6
- package/dist/Icons/ScissorsIcon.d.ts +3 -1
- package/dist/Icons/ScissorsIcon.js +6 -9
- package/dist/Icons/SettingsIcon.d.ts +3 -1
- package/dist/Icons/SettingsIcon.js +3 -6
- package/dist/Icons/SortAscendingIcon.d.ts +3 -1
- package/dist/Icons/SortAscendingIcon.js +3 -6
- package/dist/Icons/SortAtoZIcon.d.ts +3 -1
- package/dist/Icons/SortAtoZIcon.js +3 -6
- package/dist/Icons/SortDescendingIcon.d.ts +3 -1
- package/dist/Icons/SortDescendingIcon.js +3 -6
- package/dist/Icons/SortZtoAIcon.d.ts +3 -1
- package/dist/Icons/SortZtoAIcon.js +3 -6
- package/dist/Icons/StackIcon.d.ts +3 -1
- package/dist/Icons/StackIcon.js +4 -7
- package/dist/Icons/StarIcon.d.ts +3 -1
- package/dist/Icons/StarIcon.js +3 -6
- package/dist/Icons/TrashIcon.d.ts +3 -1
- package/dist/Icons/TrashIcon.js +3 -6
- package/dist/Icons/UndoIcon.d.ts +3 -1
- package/dist/Icons/UndoIcon.js +4 -7
- package/dist/Icons/UserIcon.d.ts +3 -1
- package/dist/Icons/UserIcon.js +3 -6
- package/dist/Icons/WarningIcon.d.ts +3 -1
- package/dist/Icons/WarningIcon.js +5 -8
- package/dist/Icons/ZoomAllIcon.d.ts +3 -1
- package/dist/Icons/ZoomAllIcon.js +3 -6
- package/dist/Icons/ZoomXIcon.d.ts +3 -1
- package/dist/Icons/ZoomXIcon.js +4 -7
- package/dist/Icons/ZoomYIcon.d.ts +3 -1
- package/dist/Icons/ZoomYIcon.js +4 -7
- package/dist/Input/InputUtils.d.ts +4 -4
- package/dist/Input/InputUtils.js +1 -1
- package/dist/Input.d.ts +7 -17
- package/dist/Input.js +105 -101
- package/dist/InputOTP.d.ts +27 -7
- package/dist/InputOTP.js +171 -146
- package/dist/Label.d.ts +7 -2
- package/dist/Label.js +12 -9
- package/dist/MultiSelect/MultiSelectBase.d.ts +7 -2
- package/dist/MultiSelect/MultiSelectBase.js +212 -213
- package/dist/{MultiSelect/MutiSelect.d.ts → MultiSelect.d.ts} +8 -2
- package/dist/MultiSelect.js +27 -0
- package/dist/Popover.js +1 -1
- package/dist/RadioButtonGroup.js +1 -1
- package/dist/RadioGroup.d.ts +20 -14
- package/dist/RadioGroup.js +177 -148
- package/dist/Select.d.ts +7 -2
- package/dist/Select.js +108 -109
- package/dist/Separator.d.ts +8 -8
- package/dist/Separator.js +14 -15
- package/dist/Switch/SwitchBase.d.ts +13 -11
- package/dist/Switch/SwitchBase.js +84 -61
- package/dist/Switch.d.ts +11 -4
- package/dist/Switch.js +19 -20
- package/dist/Tabs/TabsBase.d.ts +16 -6
- package/dist/Tabs/TabsBase.js +133 -96
- package/dist/Tabs/tabsUtils.d.ts +6 -2
- package/dist/Tabs/tabsUtils.js +5 -2
- package/dist/Tabs.js +18 -18
- package/dist/Textarea.d.ts +7 -2
- package/dist/Textarea.js +78 -61
- package/dist/Toggle/ToggleBase.d.ts +4 -8
- package/dist/Toggle/ToggleBase.js +29 -16
- package/dist/Toggle.d.ts +4 -2
- package/dist/Toggle.js +23 -13
- package/dist/ToggleGroup/ToggleGroupBase.d.ts +4 -7
- package/dist/ToggleGroup/ToggleGroupBase.js +82 -73
- package/dist/ToggleGroup.d.ts +7 -2
- package/dist/ToggleGroup.js +31 -19
- package/dist/Tray.d.ts +47 -15
- package/dist/Tray.js +98 -60
- package/dist/hooks/useAccordionAutoScroll.d.ts +1 -1
- package/dist/hooks/useAccordionAutoScroll.d.ts.map +1 -1
- package/dist/hooks/useAccordionAutoScroll.js +35 -34
- package/dist/{index-BSCg4Mei.js → index-B0Kp8R0j.js} +3 -3
- package/dist/{index-jgQ7sgLl.js → index-D4jMMaAi.js} +5 -5
- package/dist/primitives/input.d.ts.map +1 -1
- package/dist/primitives/input.js +1 -4
- package/dist/primitives/select.d.ts.map +1 -1
- package/dist/primitives/select.js +4 -11
- package/dist/primitives/slot.d.ts +11 -4
- package/dist/primitives/slot.d.ts.map +1 -1
- package/dist/primitives/slot.js +32 -28
- package/dist/primitives/textarea.d.ts.map +1 -1
- package/dist/primitives/textarea.js +1 -3
- package/dist/utils/formFieldUtils.js +2 -2
- package/package.json +1 -1
- package/dist/MultiSelect/MutiSelect.js +0 -19
package/dist/Textarea.js
CHANGED
|
@@ -65,66 +65,83 @@ import "./Icons/ZoomAllIcon.js";
|
|
|
65
65
|
import "./Icons/ZoomXIcon.js";
|
|
66
66
|
import "./Icons/ZoomYIcon.js";
|
|
67
67
|
import { Label as D } from "./Label.js";
|
|
68
|
-
import { useFormFieldId as M,
|
|
69
|
-
import { cn as
|
|
70
|
-
import {
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
68
|
+
import { useFormFieldId as M, useFormFieldState as O, getAriaProps as _, getTextareaClasses as $, ErrorMessage as G, getErrorMessageId as V } from "./utils/formFieldUtils.js";
|
|
69
|
+
import { cn as C } from "./utils/twUtils.js";
|
|
70
|
+
import { useRef as H } from "react";
|
|
71
|
+
const J = "absolute right-4 top-4", K = (t) => t || "off", Q = (t, i) => {
|
|
72
|
+
const a = "absolute bottom-2 right-3 text-xs pointer-events-none z-10 tabular-nums", m = t >= i ? "text-danger-400" : "text-text-secondary";
|
|
73
|
+
return C(a, m);
|
|
74
|
+
}, U = ({
|
|
75
|
+
ref: t,
|
|
76
|
+
autoComplete: i,
|
|
77
|
+
className: a,
|
|
78
|
+
disabled: m,
|
|
79
|
+
errorMessage: c,
|
|
80
|
+
id: b,
|
|
81
|
+
label: d,
|
|
82
|
+
labelClassName: N,
|
|
83
|
+
maxLength: o = 280,
|
|
84
|
+
name: u,
|
|
85
|
+
onBlur: I,
|
|
86
|
+
onChange: F,
|
|
87
|
+
onFocus: S,
|
|
88
|
+
placeholder: v,
|
|
89
|
+
required: x,
|
|
90
|
+
state: r = "default",
|
|
91
|
+
value: s = "",
|
|
92
|
+
...h
|
|
93
|
+
}) => {
|
|
94
|
+
const p = M(b, u), g = V(p), y = H(null), P = t || y, { handleFocus: T, handleBlur: A, handleChange: E, handlePaste: L } = z({
|
|
95
|
+
maxLength: o,
|
|
96
|
+
value: s,
|
|
97
|
+
onChange: F || (() => {
|
|
98
|
+
}),
|
|
99
|
+
onFocus: S,
|
|
100
|
+
onBlur: I
|
|
101
|
+
}), { isDisabled: f, isLoading: R } = O(m, r), j = _(r, g, x, h["aria-describedby"]), l = s?.length || 0, k = $(r, a), w = () => ({
|
|
102
|
+
"--textarea-min-height": "6rem",
|
|
103
|
+
"--textarea-max-height": "12rem",
|
|
104
|
+
"--textarea-border-radius": "0.5rem"
|
|
105
|
+
});
|
|
106
|
+
return /* @__PURE__ */ n("div", { className: "w-full", children: [
|
|
107
|
+
d && /* @__PURE__ */ e(D, { "data-testid": "spectral-textarea-label", htmlFor: p, className: C("mb-2 block", f && "cursor-not-allowed opacity-50", N), children: d }),
|
|
108
|
+
/* @__PURE__ */ n("div", { className: "relative", children: [
|
|
109
|
+
/* @__PURE__ */ e(
|
|
110
|
+
"textarea",
|
|
111
|
+
{
|
|
112
|
+
"aria-multiline": "true",
|
|
113
|
+
autoComplete: K(i),
|
|
114
|
+
className: k,
|
|
115
|
+
"data-state": r,
|
|
116
|
+
"data-testid": "spectral-textarea",
|
|
117
|
+
disabled: f,
|
|
118
|
+
id: p,
|
|
119
|
+
name: u,
|
|
120
|
+
onBlur: A,
|
|
121
|
+
onChange: E,
|
|
122
|
+
onFocus: T,
|
|
123
|
+
onPaste: L,
|
|
124
|
+
placeholder: v,
|
|
125
|
+
ref: P,
|
|
126
|
+
required: x,
|
|
127
|
+
spellCheck: "true",
|
|
128
|
+
style: w(),
|
|
129
|
+
value: s,
|
|
130
|
+
...j,
|
|
131
|
+
...h
|
|
132
|
+
}
|
|
133
|
+
),
|
|
134
|
+
R && /* @__PURE__ */ e("div", { className: J, "data-testid": "spectral-textarea-loading-icon", children: /* @__PURE__ */ e(B, { size: 24 }) }),
|
|
135
|
+
/* @__PURE__ */ n("div", { "aria-label": `${l} of ${o} characters used`, "aria-live": "polite", className: Q(l, o), "data-testid": "spectral-textarea-counter", role: "status", children: [
|
|
136
|
+
l,
|
|
137
|
+
"/",
|
|
138
|
+
o
|
|
139
|
+
] })
|
|
140
|
+
] }),
|
|
141
|
+
r === "error" && c && /* @__PURE__ */ e(G, { dataTestId: "spectral-textarea-error-message", id: g, message: c })
|
|
142
|
+
] });
|
|
143
|
+
};
|
|
144
|
+
U.displayName = "Textarea";
|
|
128
145
|
export {
|
|
129
|
-
|
|
146
|
+
U as Textarea
|
|
130
147
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsChildProp } from '../primitives/slot';
|
|
2
|
-
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, Ref } from 'react';
|
|
3
3
|
export type ToggleProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChange'> & Omit<AsChildProp, 'asChild'> & {
|
|
4
4
|
pressed?: boolean;
|
|
5
5
|
defaultPressed?: boolean;
|
|
@@ -7,11 +7,7 @@ export type ToggleProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onChang
|
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
asChild?: boolean;
|
|
9
9
|
};
|
|
10
|
-
export declare const ToggleBase:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
onPressedChange?: (pressed: boolean) => void;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
asChild?: boolean;
|
|
16
|
-
} & import('react').RefAttributes<HTMLButtonElement | HTMLDivElement>>;
|
|
10
|
+
export declare const ToggleBase: ({ ref, pressed: pressedProp, defaultPressed, onPressedChange, disabled, className, onKeyDown, onClick, type, asChild, children, ...rest }: ToggleProps & {
|
|
11
|
+
ref?: Ref<HTMLButtonElement>;
|
|
12
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
17
13
|
//# sourceMappingURL=ToggleBase.d.ts.map
|
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import { jsx as
|
|
3
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
4
4
|
import { useControllableState as k } from "../hooks/useControllableState.js";
|
|
5
5
|
import { Slot as C } from "../primitives/slot.js";
|
|
6
|
-
import {
|
|
7
|
-
const B =
|
|
6
|
+
import { useCallback as f } from "react";
|
|
7
|
+
const B = function({
|
|
8
|
+
ref: l,
|
|
9
|
+
pressed: c,
|
|
10
|
+
defaultPressed: m = !1,
|
|
11
|
+
onPressedChange: g,
|
|
12
|
+
disabled: t,
|
|
13
|
+
className: v,
|
|
14
|
+
onKeyDown: n,
|
|
15
|
+
onClick: a,
|
|
16
|
+
type: h = "button",
|
|
17
|
+
asChild: b = !1,
|
|
18
|
+
children: u,
|
|
19
|
+
...d
|
|
20
|
+
}) {
|
|
8
21
|
const [r, i] = k({
|
|
9
22
|
defaultValue: m,
|
|
10
23
|
onChange: g,
|
|
11
24
|
value: c
|
|
12
|
-
}), o =
|
|
25
|
+
}), o = f(() => {
|
|
13
26
|
t || i(!r);
|
|
14
|
-
}, [t, r, i]), x =
|
|
27
|
+
}, [t, r, i]), x = f(
|
|
15
28
|
(e) => {
|
|
16
|
-
|
|
29
|
+
n && n(e), !e.defaultPrevented && (e.key === " " || e.key === "Enter") && (e.preventDefault(), o());
|
|
17
30
|
},
|
|
18
|
-
[o,
|
|
19
|
-
), P =
|
|
31
|
+
[o, n]
|
|
32
|
+
), P = f(
|
|
20
33
|
(e) => {
|
|
21
|
-
|
|
34
|
+
a && a(e), !e.defaultPrevented && o();
|
|
22
35
|
},
|
|
23
|
-
[o,
|
|
36
|
+
[o, a]
|
|
24
37
|
), p = {
|
|
25
38
|
"aria-disabled": t || void 0,
|
|
26
39
|
"aria-pressed": r,
|
|
@@ -30,18 +43,18 @@ const B = T(function({ pressed: c, defaultPressed: m = !1, onPressedChange: g, d
|
|
|
30
43
|
onClick: P,
|
|
31
44
|
onKeyDown: x
|
|
32
45
|
};
|
|
33
|
-
return b ? /* @__PURE__ */
|
|
46
|
+
return b ? /* @__PURE__ */ s(
|
|
34
47
|
"div",
|
|
35
48
|
{
|
|
36
|
-
ref:
|
|
49
|
+
ref: l,
|
|
37
50
|
role: "button",
|
|
38
51
|
tabIndex: t ? -1 : 0,
|
|
39
|
-
...
|
|
52
|
+
...d,
|
|
40
53
|
...p,
|
|
41
|
-
children: /* @__PURE__ */
|
|
54
|
+
children: /* @__PURE__ */ s(C, { children: u })
|
|
42
55
|
}
|
|
43
|
-
) : /* @__PURE__ */
|
|
44
|
-
}
|
|
56
|
+
) : /* @__PURE__ */ s("button", { ref: l, tabIndex: t ? -1 : 0, type: h, ...d, ...p, children: u });
|
|
57
|
+
};
|
|
45
58
|
export {
|
|
46
59
|
B as ToggleBase
|
|
47
60
|
};
|
package/dist/Toggle.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToggleBase } from './ToggleBase';
|
|
2
2
|
import { VariantProps } from 'class-variance-authority';
|
|
3
|
-
import { ComponentProps, CSSProperties } from 'react';
|
|
3
|
+
import { ComponentProps, CSSProperties, Ref } from 'react';
|
|
4
4
|
export type ActiveColor = string;
|
|
5
5
|
export declare function getActiveColorStyle(activeColor: ActiveColor | undefined, activeTextColor?: ActiveColor): CSSProperties | undefined;
|
|
6
6
|
export type ToggleProps = ComponentProps<typeof ToggleBase> & VariantProps<typeof toggleVariants> & {
|
|
@@ -12,5 +12,7 @@ export declare const toggleVariants: (props?: ({
|
|
|
12
12
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
13
13
|
layout?: "default" | "expanded" | null | undefined;
|
|
14
14
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
15
|
-
export declare const Toggle:
|
|
15
|
+
export declare const Toggle: ({ ref, className, variant, size, layout, disabled, activeColor, activeTextColor, style, ...props }: ToggleProps & {
|
|
16
|
+
ref?: Ref<HTMLButtonElement>;
|
|
17
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
16
18
|
//# sourceMappingURL=Toggle.d.ts.map
|
package/dist/Toggle.js
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
"use client";
|
|
2
1
|
import "./styles/main.css";
|
|
3
2
|
import { jsx as c } from "react/jsx-runtime";
|
|
4
3
|
import { ToggleBase as v } from "./Toggle/ToggleBase.js";
|
|
5
4
|
import { cn as b } from "./utils/twUtils.js";
|
|
6
5
|
import { c as u } from "./index-D29mdTf5.js";
|
|
7
|
-
import
|
|
8
|
-
const
|
|
9
|
-
function
|
|
10
|
-
return
|
|
6
|
+
import "react";
|
|
7
|
+
const h = /^(#|rgb|hsl|oklch|oklab|lab|lch|color|var\(|transparent|currentcolor)/i, f = /^(success|warning|danger|primary|neutral|secondary)-\d+$/;
|
|
8
|
+
function o(e) {
|
|
9
|
+
return h.test(e) ? e : f.test(e) ? `var(--horizon-color-${e})` : `var(--color-${e})`;
|
|
11
10
|
}
|
|
12
|
-
function
|
|
11
|
+
function p(e, t) {
|
|
13
12
|
if (!(!e && !t))
|
|
14
13
|
return {
|
|
15
14
|
...e && {
|
|
16
|
-
"--color-toggle-bg--active":
|
|
17
|
-
"--color-toggle-border--active":
|
|
15
|
+
"--color-toggle-bg--active": o(e),
|
|
16
|
+
"--color-toggle-border--active": o(e)
|
|
18
17
|
},
|
|
19
18
|
...t && {
|
|
20
|
-
"--color-toggle-text--active":
|
|
19
|
+
"--color-toggle-text--active": o(t)
|
|
21
20
|
}
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
const
|
|
23
|
+
const m = u(
|
|
25
24
|
`
|
|
26
25
|
bg-toggle-bg inline-flex items-center justify-center gap-2 border rounded-md text-sm shadow-sm font-medium w-fit text-toggle-text whitespace-nowrap outline-none transition-[colors]
|
|
27
26
|
[&_svg]:pointer-events-none [&_svg]:shrink-0 active:bg-toggle-bg--active hover:cursor-pointer hover:bg-toggle-bg--hover hover:border-toggle-border--hover hover:text-toggle-text--hover
|
|
@@ -51,9 +50,20 @@ const x = u(
|
|
|
51
50
|
layout: "default"
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
|
-
), A =
|
|
53
|
+
), A = ({
|
|
54
|
+
ref: e,
|
|
55
|
+
className: t,
|
|
56
|
+
variant: r,
|
|
57
|
+
size: a,
|
|
58
|
+
layout: i,
|
|
59
|
+
disabled: g,
|
|
60
|
+
activeColor: n,
|
|
61
|
+
activeTextColor: s,
|
|
62
|
+
style: l,
|
|
63
|
+
...d
|
|
64
|
+
}) => /* @__PURE__ */ c(v, { ref: e, disabled: g, "data-slot": "toggle", "data-testid": "spectral-toggle", className: b(m({ variant: r, size: a, layout: i }), t), style: { ...p(n, s), ...l }, ...d });
|
|
55
65
|
export {
|
|
56
66
|
A as Toggle,
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
p as getActiveColorStyle,
|
|
68
|
+
m as toggleVariants
|
|
59
69
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react';
|
|
1
|
+
import { ButtonHTMLAttributes, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
2
|
type Orientation = 'horizontal' | 'vertical';
|
|
3
3
|
export type CommonGroupProps = {
|
|
4
4
|
className?: string;
|
|
@@ -30,11 +30,8 @@ export type ToggleGroupItemProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>,
|
|
|
30
30
|
/** @deprecated This prop is ignored - pressed state is managed by ToggleGroup */
|
|
31
31
|
defaultPressed?: boolean;
|
|
32
32
|
};
|
|
33
|
-
export declare const ToggleGroupItemBase:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** @deprecated This prop is ignored - pressed state is managed by ToggleGroup */
|
|
37
|
-
defaultPressed?: boolean;
|
|
38
|
-
} & import('react').RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
export declare const ToggleGroupItemBase: ({ ref, value, disabled, className, children, onKeyDown, onClick, ...rest }: ToggleGroupItemProps & {
|
|
34
|
+
ref?: Ref<HTMLButtonElement>;
|
|
35
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
39
36
|
export {};
|
|
40
37
|
//# sourceMappingURL=ToggleGroupBase.d.ts.map
|
|
@@ -1,97 +1,106 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import {
|
|
4
|
-
import { useControllableState as
|
|
5
|
-
import { clamp as
|
|
6
|
-
import { createContext as j,
|
|
7
|
-
const T = j(null), Q = (
|
|
3
|
+
import { jsxs as E, jsx as B } from "react/jsx-runtime";
|
|
4
|
+
import { useControllableState as M } from "../hooks/useControllableState.js";
|
|
5
|
+
import { clamp as R } from "../utils/sharedUtils.js";
|
|
6
|
+
import { createContext as j, useRef as S, useCallback as i, useMemo as H, useContext as K, useImperativeHandle as L, useEffect as N } from "react";
|
|
7
|
+
const T = j(null), Q = (C) => {
|
|
8
8
|
const {
|
|
9
|
-
className:
|
|
10
|
-
defaultValue:
|
|
11
|
-
disabled:
|
|
12
|
-
loop:
|
|
13
|
-
name:
|
|
14
|
-
onValueChange:
|
|
15
|
-
orientation:
|
|
16
|
-
type:
|
|
17
|
-
value:
|
|
18
|
-
"data-variant":
|
|
19
|
-
"data-size":
|
|
20
|
-
"data-slot":
|
|
21
|
-
"data-layout":
|
|
22
|
-
...
|
|
23
|
-
} =
|
|
24
|
-
defaultValue: typeof
|
|
25
|
-
onChange:
|
|
26
|
-
value:
|
|
27
|
-
}),
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
|
|
9
|
+
className: z,
|
|
10
|
+
defaultValue: r,
|
|
11
|
+
disabled: l = !1,
|
|
12
|
+
loop: c = !0,
|
|
13
|
+
name: x,
|
|
14
|
+
onValueChange: v,
|
|
15
|
+
orientation: u = "horizontal",
|
|
16
|
+
type: d = "single",
|
|
17
|
+
value: a,
|
|
18
|
+
"data-variant": D,
|
|
19
|
+
"data-size": b,
|
|
20
|
+
"data-slot": f,
|
|
21
|
+
"data-layout": w,
|
|
22
|
+
...G
|
|
23
|
+
} = C, p = d === "multiple", [n, m] = M({
|
|
24
|
+
defaultValue: typeof r < "u" ? r : p ? [] : "",
|
|
25
|
+
onChange: v,
|
|
26
|
+
value: a
|
|
27
|
+
}), o = S([]), g = i((t, s) => {
|
|
28
|
+
const P = { val: t, el: s, disabled: !!s?.disabled };
|
|
29
|
+
return o.current = [...o.current.filter((A) => A.val !== t), P], () => {
|
|
30
|
+
o.current = o.current.filter((A) => A.val !== t);
|
|
31
31
|
};
|
|
32
|
-
}, []),
|
|
33
|
-
(t) =>
|
|
34
|
-
[
|
|
35
|
-
),
|
|
32
|
+
}, []), V = i(() => o.current.slice(), []), k = i(
|
|
33
|
+
(t) => p ? Array.isArray(n) && n.includes(t) : n === t,
|
|
34
|
+
[p, n]
|
|
35
|
+
), e = i((t) => m(t), [m]), y = i(
|
|
36
36
|
(t) => {
|
|
37
|
-
const s =
|
|
37
|
+
const s = o.current;
|
|
38
38
|
if (s.length === 0) return;
|
|
39
|
-
const
|
|
40
|
-
s[
|
|
39
|
+
const P = s.length - 1, A = c ? (t % s.length + s.length) % s.length : R(t, 0, P);
|
|
40
|
+
s[A]?.el?.focus();
|
|
41
41
|
},
|
|
42
|
-
[
|
|
43
|
-
),
|
|
42
|
+
[c]
|
|
43
|
+
), h = H(
|
|
44
44
|
() => ({
|
|
45
|
-
focusItemByIndex:
|
|
46
|
-
groupDisabled:
|
|
47
|
-
isItemPressed:
|
|
48
|
-
itemsSnapshot:
|
|
49
|
-
loop:
|
|
50
|
-
name:
|
|
51
|
-
orientation:
|
|
52
|
-
register:
|
|
53
|
-
setValue:
|
|
54
|
-
type:
|
|
45
|
+
focusItemByIndex: y,
|
|
46
|
+
groupDisabled: l,
|
|
47
|
+
isItemPressed: k,
|
|
48
|
+
itemsSnapshot: V,
|
|
49
|
+
loop: c,
|
|
50
|
+
name: x,
|
|
51
|
+
orientation: u,
|
|
52
|
+
register: g,
|
|
53
|
+
setValue: e,
|
|
54
|
+
type: d,
|
|
55
55
|
value: n
|
|
56
56
|
}),
|
|
57
|
-
[
|
|
58
|
-
),
|
|
59
|
-
return /* @__PURE__ */ E("div", { className:
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
[l, k, V, c, x, u, e, d, n]
|
|
58
|
+
), I = x;
|
|
59
|
+
return /* @__PURE__ */ E("div", { className: z, "data-disabled": l ? "" : void 0, "data-layout": w, "data-orientation": u, "data-size": b, "data-slot": f, "data-variant": D, role: "group", ...G, children: [
|
|
60
|
+
/* @__PURE__ */ B(T.Provider, { value: h, children: C.children }),
|
|
61
|
+
I && d === "single" && typeof n == "string" ? /* @__PURE__ */ B("input", { type: "hidden", name: I, value: n }) : null,
|
|
62
|
+
I && d === "multiple" && Array.isArray(n) ? n.map((t) => /* @__PURE__ */ B("input", { type: "hidden", name: I + "[]", value: t }, t)) : null
|
|
63
63
|
] });
|
|
64
|
-
}, W =
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
}, W = function({
|
|
65
|
+
ref: z,
|
|
66
|
+
value: r,
|
|
67
|
+
disabled: l,
|
|
68
|
+
className: c,
|
|
69
|
+
children: x,
|
|
70
|
+
onKeyDown: v,
|
|
71
|
+
onClick: u,
|
|
72
|
+
...d
|
|
73
|
+
}) {
|
|
74
|
+
const a = K(T);
|
|
75
|
+
if (!a) throw new Error("ToggleGroupItem must be used within ToggleGroup");
|
|
76
|
+
const { type: D, orientation: b, groupDisabled: f, setValue: w, isItemPressed: G, itemsSnapshot: p, register: n } = a, m = S(null);
|
|
77
|
+
L(z, () => m.current), N(() => n(r, m.current), [n, r]);
|
|
78
|
+
const o = G(r), g = i(() => {
|
|
79
|
+
if (!(f || l))
|
|
80
|
+
if (D === "single") w(o ? "" : r);
|
|
72
81
|
else {
|
|
73
|
-
const e =
|
|
74
|
-
|
|
82
|
+
const e = a.value, y = o ? e.filter((h) => h !== r) : [...e, r];
|
|
83
|
+
w(y);
|
|
75
84
|
}
|
|
76
|
-
}, [
|
|
85
|
+
}, [a.value, l, f, o, w, D, r]), V = i(
|
|
77
86
|
(e) => {
|
|
78
|
-
if (
|
|
87
|
+
if (v && v(e), e.defaultPrevented) return;
|
|
79
88
|
if (e.key === " " || e.key === "Enter") {
|
|
80
|
-
e.preventDefault(),
|
|
89
|
+
e.preventDefault(), g();
|
|
81
90
|
return;
|
|
82
91
|
}
|
|
83
|
-
const
|
|
84
|
-
e.key ===
|
|
92
|
+
const y = p(), h = y.findIndex((s) => s.val === r), I = b === "horizontal" ? "ArrowLeft" : "ArrowUp", t = b === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
93
|
+
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
94
|
},
|
|
86
|
-
[
|
|
87
|
-
),
|
|
95
|
+
[a, p, v, b, g, r]
|
|
96
|
+
), k = i(
|
|
88
97
|
(e) => {
|
|
89
|
-
|
|
98
|
+
u && u(e), !e.defaultPrevented && g();
|
|
90
99
|
},
|
|
91
|
-
[
|
|
100
|
+
[u, g]
|
|
92
101
|
);
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
}
|
|
102
|
+
return /* @__PURE__ */ B("button", { "aria-pressed": o, className: c, "data-disabled": f || l ? "" : void 0, "data-state": o ? "on" : "off", disabled: f || l, onClick: k, onKeyDown: V, ref: m, type: "button", ...d, children: x });
|
|
103
|
+
};
|
|
95
104
|
export {
|
|
96
105
|
Q as ToggleGroupBase,
|
|
97
106
|
W as ToggleGroupItemBase
|
package/dist/ToggleGroup.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ToggleGroupBase, ToggleGroupItemBase } from './ToggleGroupBase';
|
|
2
2
|
import { toggleVariants, ActiveColor } from '../Toggle/Toggle';
|
|
3
3
|
import { VariantProps } from 'class-variance-authority';
|
|
4
|
-
import { ComponentProps } from 'react';
|
|
4
|
+
import { ComponentProps, Ref } from 'react';
|
|
5
5
|
export type ToggleGroupItemProps = ComponentProps<typeof ToggleGroupItemBase> & VariantProps<typeof toggleVariants> & {
|
|
6
6
|
activeColor?: ActiveColor;
|
|
7
7
|
activeTextColor?: ActiveColor;
|
|
@@ -11,5 +11,10 @@ export type ToggleGroupProps = ComponentProps<typeof ToggleGroupBase> & VariantP
|
|
|
11
11
|
activeTextColor?: ActiveColor;
|
|
12
12
|
};
|
|
13
13
|
export declare const ToggleGroup: ({ className, variant, size, layout, activeColor, activeTextColor, children, ...props }: ToggleGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export declare const ToggleGroupItem:
|
|
14
|
+
export declare const ToggleGroupItem: {
|
|
15
|
+
({ ref, className, children, variant, size, value, layout, activeColor, activeTextColor, style, ...props }: ToggleGroupItemProps & {
|
|
16
|
+
ref?: Ref<HTMLButtonElement>;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
displayName: string;
|
|
19
|
+
};
|
|
15
20
|
//# sourceMappingURL=ToggleGroup.d.ts.map
|
package/dist/ToggleGroup.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./styles/main.css";
|
|
3
3
|
import { jsx as s } from "react/jsx-runtime";
|
|
4
|
-
import {
|
|
4
|
+
import { ToggleGroupBase as C, ToggleGroupItemBase as T } from "./ToggleGroup/ToggleGroupBase.js";
|
|
5
5
|
import { getActiveColorStyle as z, toggleVariants as G } from "./Toggle.js";
|
|
6
6
|
import { cn as c } from "./utils/twUtils.js";
|
|
7
|
-
import { createContext as
|
|
8
|
-
const m =
|
|
7
|
+
import { createContext as h, useContext as w } from "react";
|
|
8
|
+
const m = h({
|
|
9
9
|
size: "default",
|
|
10
10
|
variant: "default",
|
|
11
11
|
layout: "default"
|
|
12
|
-
}),
|
|
13
|
-
|
|
12
|
+
}), _ = ({ className: r, variant: o, size: e, layout: a, activeColor: l, activeTextColor: d, children: n, ...i }) => /* @__PURE__ */ s(
|
|
13
|
+
C,
|
|
14
14
|
{
|
|
15
15
|
"data-slot": "toggle-group",
|
|
16
16
|
"data-testid": "spectral-toggle-group",
|
|
@@ -18,24 +18,36 @@ const m = w({
|
|
|
18
18
|
"data-size": e,
|
|
19
19
|
"data-layout": a,
|
|
20
20
|
className: c(
|
|
21
|
-
"group/toggle-group [&[data-variant='outline']]:bg-toggle-group-bg flex h-fit w-fit
|
|
21
|
+
"group/toggle-group [&[data-variant='outline']]:bg-toggle-group-bg flex h-fit w-fit items-center rounded-md [&_button:first-of-type]:rounded-l-md [&_button:last-of-type]:rounded-r-md [&[data-layout='expanded']]:w-full [&[data-variant='outline']]:gap-0.25",
|
|
22
22
|
r
|
|
23
23
|
),
|
|
24
24
|
...i,
|
|
25
25
|
children: /* @__PURE__ */ s(m.Provider, { value: { variant: o, size: e, layout: a, activeColor: l, activeTextColor: d }, children: n })
|
|
26
26
|
}
|
|
27
|
-
),
|
|
28
|
-
|
|
27
|
+
), A = ({
|
|
28
|
+
ref: r,
|
|
29
|
+
className: o,
|
|
30
|
+
children: e,
|
|
31
|
+
variant: a,
|
|
32
|
+
size: l,
|
|
33
|
+
value: d,
|
|
34
|
+
layout: n,
|
|
35
|
+
activeColor: i,
|
|
36
|
+
activeTextColor: v,
|
|
37
|
+
style: f,
|
|
38
|
+
...y
|
|
39
|
+
}) => {
|
|
40
|
+
const t = w(m), g = t.variant ?? a, u = t.size ?? l, p = t.layout ?? n, x = i ?? t.activeColor, b = v ?? t.activeTextColor;
|
|
29
41
|
return /* @__PURE__ */ s(
|
|
30
|
-
|
|
42
|
+
T,
|
|
31
43
|
{
|
|
32
|
-
ref:
|
|
44
|
+
ref: r,
|
|
33
45
|
"data-slot": "toggle-group-item",
|
|
34
46
|
"data-testid": "spectral-toggle-group-item",
|
|
35
47
|
"data-variant": g,
|
|
36
48
|
"data-size": u,
|
|
37
49
|
"data-layout": p,
|
|
38
|
-
value:
|
|
50
|
+
value: d,
|
|
39
51
|
className: c(
|
|
40
52
|
G({
|
|
41
53
|
variant: g,
|
|
@@ -43,16 +55,16 @@ const m = w({
|
|
|
43
55
|
layout: p
|
|
44
56
|
}),
|
|
45
57
|
"group data-[variant=outline]:border-togglegroup-border rounded-none shadow-none focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0",
|
|
46
|
-
|
|
58
|
+
o
|
|
47
59
|
),
|
|
48
|
-
style: { ...z(
|
|
49
|
-
...
|
|
50
|
-
children:
|
|
60
|
+
style: { ...z(x, b), ...f },
|
|
61
|
+
...y,
|
|
62
|
+
children: e
|
|
51
63
|
}
|
|
52
64
|
);
|
|
53
|
-
}
|
|
54
|
-
|
|
65
|
+
};
|
|
66
|
+
A.displayName = "ToggleGroupItem";
|
|
55
67
|
export {
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
_ as ToggleGroup,
|
|
69
|
+
A as ToggleGroupItem
|
|
58
70
|
};
|