@spear-ai/spectral 1.9.0 → 1.10.0
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/README.md +6 -5
- package/dist/.js +112 -239
- package/dist/Accordion-CDXdSAST.js +363 -0
- package/dist/Accordion.js +3 -498
- package/dist/Alert/AlertBase.js +69 -152
- package/dist/Alert.js +58 -106
- package/dist/AnimatePresence-D-9jXfgI.js +178 -0
- package/dist/App.js +6 -6
- package/dist/Avatar.js +83 -65
- package/dist/Badge.d.ts +1 -3
- package/dist/Badge.js +21 -25
- package/dist/Button.js +102 -178
- package/dist/ButtonGroup/ButtonGroupButton.js +38 -40
- package/dist/ButtonGroup.js +55 -59
- package/dist/ButtonIcon.js +58 -134
- package/dist/Calendar-s4lyijkn.js +3109 -0
- package/dist/Checkbox/CheckboxBase.js +94 -126
- package/dist/Checkbox.d.ts +1 -1
- package/dist/Checkbox.js +40 -105
- package/dist/Combobox/ComboboxBase.js +2 -79
- package/dist/Combobox.js +106 -172
- package/dist/ComboboxBase-D8Nf4xC-.js +491 -0
- package/dist/ControlGroup/ControlGroupSelect.d.ts +1 -1
- package/dist/ControlGroup/ControlGroupSelect.js +85 -101
- package/dist/ControlGroup.js +45 -48
- package/dist/DataCard/Card.js +37 -12
- package/dist/DataCard.d.ts +1 -1
- package/dist/DataCard.js +36 -16
- package/dist/DateTimePicker/Calendar.js +2 -2967
- package/dist/DateTimePicker/DateTimeDisplayInput.d.ts +1 -1
- package/dist/DateTimePicker/DateTimeDisplayInput.js +379 -274
- package/dist/DateTimePicker/DateTimeInput.d.ts +5 -3
- package/dist/DateTimePicker/DateTimeInput.js +133 -88
- package/dist/DateTimePicker/DateTimeUtils.js +2 -2193
- package/dist/DateTimePicker/TimePeriodSelect.d.ts +1 -1
- package/dist/DateTimePicker/TimePeriodSelect.js +45 -20
- package/dist/DateTimePicker/TimePicker.d.ts +1 -1
- package/dist/DateTimePicker/TimePicker.js +76 -60
- package/dist/DateTimePicker.d.ts +2 -2
- package/dist/DateTimePicker.js +87 -205
- package/dist/DateTimeUtils-DVvG6H-p.js +2098 -0
- package/dist/Dialog.js +74 -74
- package/dist/Drawer.js +67 -37
- package/dist/HoverCard-CYDsIiVK.js +201 -0
- package/dist/HoverCard.d.ts +1 -1
- package/dist/HoverCard.js +2 -218
- package/dist/Icons/AnalyzeIcon.js +50 -57
- package/dist/Icons/AnnotationsIcon.js +20 -15
- package/dist/Icons/ApprovedIcon.js +26 -18
- package/dist/Icons/ArrowDownIcon.js +20 -6
- package/dist/Icons/ArrowUpIcon.js +20 -6
- package/dist/Icons/BoxToolIcon.js +17 -12
- package/dist/Icons/CalendarIcon.js +43 -20
- package/dist/Icons/CheckCircleIcon.js +26 -10
- package/dist/Icons/CheckSquareIcon.js +26 -10
- package/dist/Icons/CheckmarkIcon.js +22 -9
- package/dist/Icons/ChevronDownIcon.js +22 -9
- package/dist/Icons/ChevronUpIcon.js +22 -9
- package/dist/Icons/ClockIcon.js +26 -18
- package/dist/Icons/CloseCircleIcon.js +26 -10
- package/dist/Icons/CloseIcon.js +18 -9
- package/dist/Icons/DashboardIcon.js +36 -10
- package/dist/Icons/DatabaseIcon.js +36 -19
- package/dist/Icons/DeleteIcon.js +36 -19
- package/dist/Icons/DurationIcon.js +57 -22
- package/dist/Icons/EditIcon.js +26 -27
- package/dist/Icons/EmailIcon.js +26 -10
- package/dist/Icons/EraserIcon.js +41 -25
- package/dist/Icons/ErrorIcon.js +27 -11
- package/dist/Icons/EyeClosedIcon.js +29 -13
- package/dist/Icons/EyeClosedIcon2.js +27 -11
- package/dist/Icons/EyeOpenIcon.js +22 -9
- package/dist/Icons/FileDownloadIcon.js +43 -20
- package/dist/Icons/GoToFirstIcon.js +26 -9
- package/dist/Icons/GoToLastIcon.js +26 -9
- package/dist/Icons/HarmonicCursorsIcon.js +23 -9
- package/dist/Icons/IconBase.d.ts +3 -3
- package/dist/Icons/IconBase.js +49 -23
- package/dist/Icons/InfoIcon.js +36 -10
- package/dist/Icons/KeyboardIcon.js +26 -27
- package/dist/Icons/LabelIcon.js +19 -14
- package/dist/Icons/LassoIcon.js +36 -28
- package/dist/Icons/LineToolIcon.js +48 -39
- package/dist/Icons/LiveViewIcon.js +50 -12
- package/dist/Icons/LoaderIcon.js +67 -27
- package/dist/Icons/LocationIcon.js +26 -27
- package/dist/Icons/LogoutIcon.js +20 -15
- package/dist/Icons/MeasureIcon.js +78 -25
- package/dist/Icons/MessagesIcon.js +33 -18
- package/dist/Icons/MetadataIcon.js +20 -15
- package/dist/Icons/MinusIcon.d.ts +1 -1
- package/dist/Icons/MinusIcon.js +18 -6
- package/dist/Icons/OntologyIcon.js +87 -71
- package/dist/Icons/PanelIconClose.js +28 -10
- package/dist/Icons/PanelIconOpen.js +28 -10
- package/dist/Icons/PlayIcon.js +20 -6
- package/dist/Icons/PlusIcon.js +20 -14
- package/dist/Icons/PolygonIcon.js +50 -39
- package/dist/Icons/ProgressCheckIcon.d.ts +5 -0
- package/dist/Icons/ProgressCheckIcon.js +58 -0
- package/dist/Icons/ResetIcon.js +17 -12
- package/dist/Icons/ReviewedIcon.js +36 -19
- package/dist/Icons/ScissorsIcon.js +22 -17
- package/dist/Icons/SearchIcon.js +26 -9
- package/dist/Icons/SettingsIcon.js +26 -27
- package/dist/Icons/SortAscendingIcon.js +50 -12
- package/dist/Icons/SortAtoZIcon.js +50 -12
- package/dist/Icons/SortDescendingIcon.js +50 -12
- package/dist/Icons/SortZtoAIcon.js +50 -12
- package/dist/Icons/StackIcon.js +26 -9
- package/dist/Icons/StarIcon.js +20 -6
- package/dist/Icons/TrashIcon.js +17 -12
- package/dist/Icons/UndoIcon.js +20 -15
- package/dist/Icons/User2Icon.js +26 -10
- package/dist/Icons/UserIcon.js +19 -14
- package/dist/Icons/WarningIcon.js +19 -14
- package/dist/Icons/ZoomAllIcon.js +71 -15
- package/dist/Icons/ZoomXIcon.js +36 -10
- package/dist/Icons/ZoomYIcon.js +36 -10
- package/dist/Icons/index.d.ts +1 -0
- package/dist/Icons.js +68 -136
- package/dist/IconsAnimated/PanelLeftCloseIcon.js +66 -36
- package/dist/IconsAnimated/PanelLeftOpenIcon.js +66 -36
- package/dist/IconsAnimated.js +3 -6
- package/dist/Input/InputUtils.js +51 -52
- package/dist/Input.js +132 -185
- package/dist/InputOTP-XUWW9xcI.js +461 -0
- package/dist/InputOTP.js +2 -382
- package/dist/Kbd.d.ts +1 -1
- package/dist/Kbd.js +182 -86
- package/dist/Label.js +12 -14
- package/dist/MultiSelect/MultiSelectBase.js +331 -403
- package/dist/MultiSelect.d.ts +1 -1
- package/dist/MultiSelect.js +23 -23
- package/dist/Popover.js +28 -32
- package/dist/RadioButton.d.ts +17 -0
- package/dist/RadioButton.js +33 -0
- package/dist/RadioButtonGroup/RadioButtonGroupBase.d.ts +3 -1
- package/dist/RadioButtonGroup/RadioButtonGroupBase.js +49 -46
- package/dist/RadioButtonGroup.d.ts +1 -1
- package/dist/RadioButtonGroup.js +11 -8
- package/dist/RadioGroup-w_q6RGEK.js +447 -0
- package/dist/RadioGroup.js +2 -505
- package/dist/Select.js +163 -186
- package/dist/Separator.js +16 -19
- package/dist/Skeleton.js +10 -6
- package/dist/Slider-BzzZT3Zm.js +490 -0
- package/dist/Slider.js +2 -562
- package/dist/SpectralProvider.js +8 -5
- package/dist/Switch/SwitchBase.js +91 -95
- package/dist/Switch-CVzRJ-0n.js +126 -0
- package/dist/Switch.d.ts +1 -1
- package/dist/Switch.js +2 -134
- package/dist/Tabs/TabsBase.js +242 -250
- package/dist/Tabs/tabsUtils.js +65 -73
- package/dist/Tabs.d.ts +1 -1
- package/dist/Tabs.js +73 -103
- package/dist/Textarea/TextareaUtils.js +35 -46
- package/dist/Textarea.js +83 -160
- package/dist/Toast-9zqXxKKO.js +711 -0
- package/dist/Toast.js +2 -885
- package/dist/Toggle/ToggleBase.js +46 -56
- package/dist/Toggle.d.ts +1 -1
- package/dist/Toggle.js +52 -62
- package/dist/ToggleGroup/ToggleGroupBase.js +128 -104
- package/dist/ToggleGroup.d.ts +1 -1
- package/dist/ToggleGroup.js +52 -63
- package/dist/Tooltip-D1K8kY1y.js +389 -0
- package/dist/Tooltip.js +2 -365
- package/dist/Tray.js +174 -217
- package/dist/chunk-h9knIhTc.js +20 -0
- package/dist/clsx-jM1GlMvB.js +16 -0
- package/dist/dist-3Af8168y.js +913 -0
- package/dist/dist-7HRQ5IKN.js +249 -0
- package/dist/dist-B2k1iWFp.js +129 -0
- package/dist/dist-B4FgboI8.js +122 -0
- package/dist/dist-B4g6zpUF.js +33 -0
- package/dist/dist-B9tup-4O.js +216 -0
- package/dist/dist-BK1K0g9W.js +29 -0
- package/dist/dist-Bfjk-jx9.js +28 -0
- package/dist/dist-Bft31cJh.js +65 -0
- package/dist/dist-BtdmHAzK.js +190 -0
- package/dist/dist-C0Hifjgh.js +1287 -0
- package/dist/dist-CGzgmYB9.js +68 -0
- package/dist/dist-ClmepHp4.js +10 -0
- package/dist/dist-D8Wb_MX9.js +6 -0
- package/dist/dist-Dtvmk11N.js +12 -0
- package/dist/dist-fW81qjVl.js +677 -0
- package/dist/dist-s1uWaZYZ.js +11 -0
- package/dist/es2015-YHaMV-St.js +701 -0
- package/dist/hooks/useAccordionAutoScroll.js +66 -67
- package/dist/hooks/useControllableState.js +14 -13
- package/dist/hooks/useTheme.js +21 -17
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/main.js +18954 -27224
- package/dist/primitives/button.js +39 -41
- package/dist/primitives/input-group.js +57 -73
- package/dist/primitives/input.js +11 -20
- package/dist/primitives/popover.d.ts.map +1 -1
- package/dist/primitives/popover.js +34 -25
- package/dist/primitives/select.js +70 -138
- package/dist/primitives/slot.js +32 -31
- package/dist/primitives/textarea.js +10 -16
- package/dist/proxy-Dn10Pl_g.js +4920 -0
- package/dist/styles/main.css +2 -1
- package/dist/styles/spectral.css +1 -1
- package/dist/twUtils-VNWgstKL.js +1673 -0
- package/dist/use-animation-CBUDycyW.js +57 -0
- package/dist/utils/constants.js +4 -4
- package/dist/utils/formFieldUtils.js +136 -148
- package/dist/utils/sharedUtils.js +26 -7
- package/dist/utils/twUtils.js +2 -2919
- package/package.json +24 -28
- package/dist/ComboboxBase-CxNxYtdT.js +0 -408
- package/dist/clsx-OuTLNxxd.js +0 -16
- package/dist/index-0ioNhtNM.js +0 -10
- package/dist/index-6oYKCvIn.js +0 -677
- package/dist/index-BFOf48AQ.js +0 -69
- package/dist/index-BZPx6jYI.js +0 -8
- package/dist/index-BlHU_t18.js +0 -142
- package/dist/index-Bm1RbF6w.js +0 -1037
- package/dist/index-Bv2OIg5P.js +0 -225
- package/dist/index-CKEI0pDv.js +0 -56
- package/dist/index-CM_hWgfC.js +0 -32
- package/dist/index-C_YVr64u.js +0 -1538
- package/dist/index-Cl8VeY0o.js +0 -149
- package/dist/index-CwSyIPrv.js +0 -13
- package/dist/index-D29mdTf5.js +0 -34
- package/dist/index-DEYs15GP.js +0 -66
- package/dist/index-Dc0No4pV.js +0 -233
- package/dist/index-T6XEa11q.js +0 -822
- package/dist/index-pBCLb6Gr.js +0 -240
- package/dist/index-psiVrsnE.js +0 -27
- package/dist/index-rKs9bXHr.js +0 -6
- package/dist/proxy-CO_-Vget.js +0 -4975
- package/dist/use-animation-DhEPRwZ3.js +0 -62
|
@@ -1,59 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import {
|
|
4
|
-
import { useControllableState as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
ref: l,
|
|
49
|
-
role: "button",
|
|
50
|
-
tabIndex: t ? -1 : 0,
|
|
51
|
-
...i,
|
|
52
|
-
...p,
|
|
53
|
-
children: /* @__PURE__ */ s(x, { children: u })
|
|
54
|
-
}
|
|
55
|
-
) : /* @__PURE__ */ s("button", { ...i, ...p, disabled: t, ref: l, type: "button", children: u });
|
|
56
|
-
};
|
|
57
|
-
export {
|
|
58
|
-
B as ToggleBase
|
|
3
|
+
import { Slot as e } from "../primitives/slot.js";
|
|
4
|
+
import { useControllableState as t } from "../hooks/useControllableState.js";
|
|
5
|
+
import { useCallback as n } from "react";
|
|
6
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/Toggle/ToggleBase.tsx
|
|
8
|
+
var i = function({ asChild: i = !1, children: a, className: o, defaultPressed: s = !1, disabled: c, onClick: l, onKeyDown: u, onPressedChange: d, pressed: f, ref: p, ...m }) {
|
|
9
|
+
let [h, g] = t({
|
|
10
|
+
defaultValue: s,
|
|
11
|
+
onChange: d,
|
|
12
|
+
value: f
|
|
13
|
+
}), _ = n(() => {
|
|
14
|
+
c || g(!h);
|
|
15
|
+
}, [
|
|
16
|
+
c,
|
|
17
|
+
h,
|
|
18
|
+
g
|
|
19
|
+
]), v = n((e) => {
|
|
20
|
+
u && u(e), !e.defaultPrevented && (e.key === " " || e.key === "Enter") && (e.preventDefault(), _());
|
|
21
|
+
}, [_, u]), y = {
|
|
22
|
+
className: o,
|
|
23
|
+
onClick: n((e) => {
|
|
24
|
+
l && l(e), !e.defaultPrevented && _();
|
|
25
|
+
}, [_, l]),
|
|
26
|
+
onKeyDown: v,
|
|
27
|
+
"aria-disabled": c ? !0 : void 0,
|
|
28
|
+
"aria-pressed": h,
|
|
29
|
+
"data-state": h ? "on" : "off",
|
|
30
|
+
"data-disabled": c ? !0 : void 0
|
|
31
|
+
};
|
|
32
|
+
return i ? /* @__PURE__ */ r("div", {
|
|
33
|
+
ref: p,
|
|
34
|
+
role: "button",
|
|
35
|
+
tabIndex: c ? -1 : 0,
|
|
36
|
+
...m,
|
|
37
|
+
...y,
|
|
38
|
+
children: /* @__PURE__ */ r(e, { children: a })
|
|
39
|
+
}) : /* @__PURE__ */ r("button", {
|
|
40
|
+
...m,
|
|
41
|
+
...y,
|
|
42
|
+
disabled: c,
|
|
43
|
+
ref: p,
|
|
44
|
+
type: "button",
|
|
45
|
+
children: a
|
|
46
|
+
});
|
|
59
47
|
};
|
|
48
|
+
//#endregion
|
|
49
|
+
export { i as ToggleBase };
|
package/dist/Toggle.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ToggleBase } from './ToggleBase';
|
|
2
1
|
import { VariantProps } from 'class-variance-authority';
|
|
3
2
|
import { ComponentProps, CSSProperties, Ref } from 'react';
|
|
3
|
+
import { ToggleBase } from './ToggleBase';
|
|
4
4
|
export type ActiveColor = string;
|
|
5
5
|
export declare const getActiveColorStyle: (activeColor: ActiveColor | undefined, activeTextColor?: ActiveColor) => CSSProperties | undefined;
|
|
6
6
|
export type ToggleProps = ComponentProps<typeof ToggleBase> & VariantProps<typeof toggleVariants> & {
|
package/dist/Toggle.js
CHANGED
|
@@ -1,64 +1,54 @@
|
|
|
1
1
|
import "./styles/main.css";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { c as u } from "./index-D29mdTf5.js";
|
|
2
|
+
import { t as e } from "./twUtils-VNWgstKL.js";
|
|
3
|
+
import { t } from "./dist-B4g6zpUF.js";
|
|
4
|
+
import { ToggleBase as n } from "./Toggle/ToggleBase.js";
|
|
6
5
|
import "react";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
activeTextColor: s,
|
|
57
|
-
style: l,
|
|
58
|
-
...d
|
|
59
|
-
}) => /* @__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 });
|
|
60
|
-
export {
|
|
61
|
-
A as Toggle,
|
|
62
|
-
p as getActiveColorStyle,
|
|
63
|
-
m as toggleVariants
|
|
64
|
-
};
|
|
6
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/Toggle/Toggle.tsx
|
|
8
|
+
var i = /^(#|rgb|hsl|oklch|oklab|lab|lch|color|var\(|transparent|currentcolor)/i, a = /^(success|warning|danger|primary|neutral|secondary)-\d+$/, o = (e) => i.test(e) ? e : a.test(e) ? `var(--horizon-color-${e})` : `var(--color-${e})`, s = (e, t) => {
|
|
9
|
+
if (!(!e && !t)) return {
|
|
10
|
+
...e && {
|
|
11
|
+
"--color-toggle-bg--active": o(e),
|
|
12
|
+
"--color-toggle-border--active": o(e)
|
|
13
|
+
},
|
|
14
|
+
...t && { "--color-toggle-text--active": o(t) }
|
|
15
|
+
};
|
|
16
|
+
}, c = t("gap-2 rounded-md text-sm shadow-sm font-medium focus-visible:border-ring focus-visible:ring-ring/50 inline-flex w-fit items-center justify-center border bg-toggle-bg whitespace-nowrap text-toggle-text transition-colors outline-none hover:cursor-pointer hover:border-toggle-border--hover hover:bg-toggle-bg--hover hover:text-toggle-text--hover focus:outline-none focus-visible:ring-[3px] active:bg-toggle-bg--active aria-invalid:border-danger-200 aria-invalid:ring-danger-200/20 aria-pressed:border-toggle-border--active aria-pressed:bg-toggle-bg--active aria-pressed:text-toggle-text--active data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[state=on]:border-toggle-border--active data-[state=on]:bg-toggle-bg--active data-[state=on]:text-toggle-text--active [&_svg]:pointer-events-none [&_svg]:shrink-0", {
|
|
17
|
+
variants: {
|
|
18
|
+
variant: {
|
|
19
|
+
default: "border-toggle-border hover:border-toggle-border--hover",
|
|
20
|
+
outline: "border-toggle-outline-border hover:border-toggle-outline-border--hover hover:bg-toggle-bg--hover"
|
|
21
|
+
},
|
|
22
|
+
size: {
|
|
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
|
+
},
|
|
27
|
+
layout: {
|
|
28
|
+
default: "w-fit",
|
|
29
|
+
expanded: "w-full"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: "default",
|
|
34
|
+
size: "default",
|
|
35
|
+
layout: "default"
|
|
36
|
+
}
|
|
37
|
+
}), l = ({ ref: t, className: i, variant: a, size: o, layout: l, disabled: u, activeColor: d, activeTextColor: f, style: p, ...m }) => /* @__PURE__ */ r(n, {
|
|
38
|
+
ref: t,
|
|
39
|
+
disabled: u,
|
|
40
|
+
"data-slot": "toggle",
|
|
41
|
+
"data-testid": "spectral-toggle",
|
|
42
|
+
className: e(c({
|
|
43
|
+
variant: a,
|
|
44
|
+
size: o,
|
|
45
|
+
layout: l
|
|
46
|
+
}), i),
|
|
47
|
+
style: {
|
|
48
|
+
...s(d, f),
|
|
49
|
+
...p
|
|
50
|
+
},
|
|
51
|
+
...m
|
|
52
|
+
});
|
|
53
|
+
//#endregion
|
|
54
|
+
export { l as Toggle, s as getActiveColorStyle, c as toggleVariants };
|
|
@@ -1,107 +1,131 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
3
|
+
import { useControllableState as e } from "../hooks/useControllableState.js";
|
|
4
|
+
import { clamp as t } from "../utils/sharedUtils.js";
|
|
5
|
+
import { createContext as n, useCallback as r, useContext as i, useEffect as a, useImperativeHandle as o, useMemo as s, useRef as c } from "react";
|
|
6
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/ToggleGroup/ToggleGroupBase.tsx
|
|
8
|
+
var d = n(null), f = (n) => {
|
|
9
|
+
let { className: i, defaultValue: a, disabled: o = !1, loop: f = !0, name: p, onValueChange: m, orientation: h = "horizontal", type: g = "single", value: _, "data-variant": v, "data-size": y, "data-slot": b, "data-layout": x, ...S } = n, C = g === "multiple", [w, T] = e({
|
|
10
|
+
defaultValue: a === void 0 ? C ? [] : "" : a,
|
|
11
|
+
onChange: m,
|
|
12
|
+
value: _
|
|
13
|
+
}), E = c([]), D = r((e, t) => {
|
|
14
|
+
let n = {
|
|
15
|
+
val: e,
|
|
16
|
+
el: t,
|
|
17
|
+
disabled: !!t?.disabled
|
|
18
|
+
};
|
|
19
|
+
return E.current = [...E.current.filter((t) => t.val !== e), n], () => {
|
|
20
|
+
E.current = E.current.filter((t) => t.val !== e);
|
|
21
|
+
};
|
|
22
|
+
}, []), O = r(() => E.current.slice(), []), k = r((e) => C ? Array.isArray(w) && w.includes(e) : w === e, [C, w]), A = r((e) => T(e), [T]), j = r((e) => {
|
|
23
|
+
let n = E.current;
|
|
24
|
+
if (n.length === 0) return;
|
|
25
|
+
let r = n.length - 1;
|
|
26
|
+
n[f ? (e % n.length + n.length) % n.length : t(e, 0, r)]?.el?.focus();
|
|
27
|
+
}, [f]), M = s(() => ({
|
|
28
|
+
focusItemByIndex: j,
|
|
29
|
+
groupDisabled: o,
|
|
30
|
+
isItemPressed: k,
|
|
31
|
+
itemsSnapshot: O,
|
|
32
|
+
loop: f,
|
|
33
|
+
name: p,
|
|
34
|
+
orientation: h,
|
|
35
|
+
register: D,
|
|
36
|
+
setValue: A,
|
|
37
|
+
type: g,
|
|
38
|
+
value: w
|
|
39
|
+
}), [
|
|
40
|
+
j,
|
|
41
|
+
o,
|
|
42
|
+
k,
|
|
43
|
+
O,
|
|
44
|
+
f,
|
|
45
|
+
p,
|
|
46
|
+
h,
|
|
47
|
+
D,
|
|
48
|
+
A,
|
|
49
|
+
g,
|
|
50
|
+
w
|
|
51
|
+
]), N = p;
|
|
52
|
+
return /* @__PURE__ */ u("div", {
|
|
53
|
+
className: i,
|
|
54
|
+
"data-disabled": o ? "" : void 0,
|
|
55
|
+
"data-layout": x,
|
|
56
|
+
"data-orientation": h,
|
|
57
|
+
"data-size": y,
|
|
58
|
+
"data-slot": b,
|
|
59
|
+
"data-variant": v,
|
|
60
|
+
role: "group",
|
|
61
|
+
...S,
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ l(d.Provider, {
|
|
64
|
+
value: M,
|
|
65
|
+
children: n.children
|
|
66
|
+
}),
|
|
67
|
+
N && g === "single" && typeof w == "string" ? /* @__PURE__ */ l("input", {
|
|
68
|
+
type: "hidden",
|
|
69
|
+
name: N,
|
|
70
|
+
value: w
|
|
71
|
+
}) : null,
|
|
72
|
+
N && g === "multiple" && Array.isArray(w) ? w.map((e) => /* @__PURE__ */ l("input", {
|
|
73
|
+
type: "hidden",
|
|
74
|
+
name: N + "[]",
|
|
75
|
+
value: e
|
|
76
|
+
}, e)) : null
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
}, p = function({ ref: e, value: t, disabled: n, className: s, children: u, onKeyDown: f, onClick: p, ...m }) {
|
|
80
|
+
let h = i(d);
|
|
81
|
+
if (!h) throw Error("ToggleGroupItem must be used within ToggleGroup");
|
|
82
|
+
let { type: g, orientation: _, groupDisabled: v, setValue: y, isItemPressed: b, itemsSnapshot: x, register: S } = h, C = c(null);
|
|
83
|
+
o(e, () => C.current), a(() => S(t, C.current), [S, t]);
|
|
84
|
+
let w = b(t), T = r(() => {
|
|
85
|
+
if (!(v || n)) if (g === "single") y(w ? "" : t);
|
|
86
|
+
else {
|
|
87
|
+
let e = h.value;
|
|
88
|
+
y(w ? e.filter((e) => e !== t) : [...e, t]);
|
|
89
|
+
}
|
|
90
|
+
}, [
|
|
91
|
+
h.value,
|
|
92
|
+
n,
|
|
93
|
+
v,
|
|
94
|
+
w,
|
|
95
|
+
y,
|
|
96
|
+
g,
|
|
97
|
+
t
|
|
98
|
+
]), E = r((e) => {
|
|
99
|
+
if (f && f(e), e.defaultPrevented) return;
|
|
100
|
+
if (e.key === " " || e.key === "Enter") {
|
|
101
|
+
e.preventDefault(), T();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
let n = x(), r = n.findIndex((e) => e.val === t), i = _ === "horizontal" ? "ArrowLeft" : "ArrowUp", a = _ === "horizontal" ? "ArrowRight" : "ArrowDown";
|
|
105
|
+
e.key === i ? (e.preventDefault(), h.focusItemByIndex(r - 1)) : e.key === a ? (e.preventDefault(), h.focusItemByIndex(r + 1)) : e.key === "Home" ? (e.preventDefault(), h.focusItemByIndex(0)) : e.key === "End" && (e.preventDefault(), h.focusItemByIndex(n.length - 1));
|
|
106
|
+
}, [
|
|
107
|
+
h,
|
|
108
|
+
x,
|
|
109
|
+
f,
|
|
110
|
+
_,
|
|
111
|
+
T,
|
|
112
|
+
t
|
|
113
|
+
]), D = r((e) => {
|
|
114
|
+
p && p(e), !e.defaultPrevented && T();
|
|
115
|
+
}, [p, T]);
|
|
116
|
+
return /* @__PURE__ */ l("button", {
|
|
117
|
+
"aria-pressed": w,
|
|
118
|
+
className: s,
|
|
119
|
+
"data-disabled": v || n ? "" : void 0,
|
|
120
|
+
"data-state": w ? "on" : "off",
|
|
121
|
+
disabled: v || n,
|
|
122
|
+
onClick: D,
|
|
123
|
+
onKeyDown: E,
|
|
124
|
+
ref: C,
|
|
125
|
+
type: "button",
|
|
126
|
+
...m,
|
|
127
|
+
children: u
|
|
128
|
+
});
|
|
107
129
|
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { f as ToggleGroupBase, p as ToggleGroupItemBase };
|
package/dist/ToggleGroup.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ToggleGroupBase, ToggleGroupItemBase } from './ToggleGroupBase';
|
|
2
1
|
import { toggleVariants, ActiveColor } from '../Toggle/Toggle';
|
|
3
2
|
import { VariantProps } from 'class-variance-authority';
|
|
4
3
|
import { ComponentProps, Ref } from 'react';
|
|
4
|
+
import { ToggleGroupBase, ToggleGroupItemBase } from './ToggleGroupBase';
|
|
5
5
|
export type ToggleGroupItemProps = ComponentProps<typeof ToggleGroupItemBase> & VariantProps<typeof toggleVariants> & {
|
|
6
6
|
activeColor?: ActiveColor;
|
|
7
7
|
activeTextColor?: ActiveColor;
|
package/dist/ToggleGroup.js
CHANGED
|
@@ -1,67 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "./styles/main.css";
|
|
3
|
+
import { t as e } from "./twUtils-VNWgstKL.js";
|
|
4
|
+
import { getActiveColorStyle as t, toggleVariants as n } from "./Toggle.js";
|
|
5
|
+
import { ToggleGroupBase as r, ToggleGroupItemBase as i } from "./ToggleGroup/ToggleGroupBase.js";
|
|
6
|
+
import { createContext as a, useContext as o } from "react";
|
|
3
7
|
import { jsx as s } from "react/jsx-runtime";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
),
|
|
50
|
-
"data-layout": p,
|
|
51
|
-
"data-size": g,
|
|
52
|
-
"data-slot": "toggle-group-item",
|
|
53
|
-
"data-testid": "spectral-toggle-group-item",
|
|
54
|
-
"data-variant": u,
|
|
55
|
-
ref: d,
|
|
56
|
-
style: { ...z(x, b), ...i },
|
|
57
|
-
value: v,
|
|
58
|
-
...y,
|
|
59
|
-
children: e
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
A.displayName = "ToggleGroupItem";
|
|
64
|
-
export {
|
|
65
|
-
_ as ToggleGroup,
|
|
66
|
-
A as ToggleGroupItem
|
|
8
|
+
//#region src/components/ToggleGroup/ToggleGroup.tsx
|
|
9
|
+
var c = a({
|
|
10
|
+
layout: "default",
|
|
11
|
+
size: "default",
|
|
12
|
+
variant: "default"
|
|
13
|
+
}), l = ({ className: t, variant: n, size: i, layout: a, activeColor: o, activeTextColor: l, children: u, ...d }) => /* @__PURE__ */ s(r, {
|
|
14
|
+
className: e("group/toggle-group rounded-md [&_button:first-of-type]:rounded-l-md [&_button:last-of-type]:rounded-r-md data-[variant='outline']:gap-0.5 flex h-fit w-fit items-center data-[layout='expanded']:w-full", t),
|
|
15
|
+
"data-layout": a,
|
|
16
|
+
"data-size": i,
|
|
17
|
+
"data-slot": "toggle-group",
|
|
18
|
+
"data-testid": "spectral-toggle-group",
|
|
19
|
+
"data-variant": n,
|
|
20
|
+
...d,
|
|
21
|
+
children: /* @__PURE__ */ s(c.Provider, {
|
|
22
|
+
value: {
|
|
23
|
+
variant: n,
|
|
24
|
+
size: i,
|
|
25
|
+
layout: a,
|
|
26
|
+
activeColor: o,
|
|
27
|
+
activeTextColor: l
|
|
28
|
+
},
|
|
29
|
+
children: u
|
|
30
|
+
})
|
|
31
|
+
}), u = ({ activeColor: r, activeTextColor: a, children: l, className: u, layout: d, ref: f, size: p, style: m, value: h, variant: g, ..._ }) => {
|
|
32
|
+
let v = o(c), y = v.variant ?? g, b = v.size ?? p, x = v.layout ?? d, S = r ?? v.activeColor, C = a ?? v.activeTextColor;
|
|
33
|
+
return /* @__PURE__ */ s(i, {
|
|
34
|
+
className: e(n({
|
|
35
|
+
variant: y,
|
|
36
|
+
size: b,
|
|
37
|
+
layout: x
|
|
38
|
+
}), "group data-[variant=outline]:hover:border-togglegroup-border rounded-none shadow-none focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:border-toggle-outline-border", u),
|
|
39
|
+
"data-layout": x,
|
|
40
|
+
"data-size": b,
|
|
41
|
+
"data-slot": "toggle-group-item",
|
|
42
|
+
"data-testid": "spectral-toggle-group-item",
|
|
43
|
+
"data-variant": y,
|
|
44
|
+
ref: f,
|
|
45
|
+
style: {
|
|
46
|
+
...t(S, C),
|
|
47
|
+
...m
|
|
48
|
+
},
|
|
49
|
+
value: h,
|
|
50
|
+
..._,
|
|
51
|
+
children: l
|
|
52
|
+
});
|
|
67
53
|
};
|
|
54
|
+
u.displayName = "ToggleGroupItem";
|
|
55
|
+
//#endregion
|
|
56
|
+
export { l as ToggleGroup, u as ToggleGroupItem };
|