@spear-ai/spectral 1.4.46 → 1.4.47
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsChildProp } from '../primitives/slot';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
|
|
3
3
|
export type RadioButtonGroupProps = {
|
|
4
4
|
value?: string;
|
|
5
5
|
onValueChange?: (value: string) => void;
|
|
@@ -9,19 +9,16 @@ export type RadioButtonGroupProps = {
|
|
|
9
9
|
expanded?: boolean;
|
|
10
10
|
asChild?: boolean;
|
|
11
11
|
};
|
|
12
|
-
export type RadioButtonGroupItemProps = AsChildProp & {
|
|
12
|
+
export type RadioButtonGroupItemProps = AsChildProp & Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'onSelect' | 'type'> & {
|
|
13
13
|
value: string;
|
|
14
14
|
children: ReactNode;
|
|
15
|
-
className?: string;
|
|
16
|
-
disabled?: boolean;
|
|
17
15
|
onSelect?: (value: string) => void;
|
|
18
16
|
};
|
|
19
17
|
export declare const RadioButtonGroupBase: ({ value, onValueChange, children, className, isKeptActive, expanded }: RadioButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
export declare const RadioButtonGroupItem:
|
|
21
|
-
value:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} & import('react').RefAttributes<HTMLButtonElement>>;
|
|
18
|
+
export declare const RadioButtonGroupItem: {
|
|
19
|
+
({ ref, value, children, className, disabled, asChild, onSelect, onClick, ...rest }: RadioButtonGroupItemProps & {
|
|
20
|
+
ref?: Ref<HTMLButtonElement>;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
displayName: string;
|
|
23
|
+
};
|
|
27
24
|
//# sourceMappingURL=RadioButtonGroupBase.d.ts.map
|
|
@@ -1,38 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import "../styles/main.css";
|
|
3
|
-
import { jsx as
|
|
4
|
-
import { Slot as
|
|
5
|
-
import { cn as
|
|
6
|
-
import { createContext as
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
import { Slot as w } from "../primitives/slot.js";
|
|
5
|
+
import { cn as b } from "../utils/twUtils.js";
|
|
6
|
+
import { createContext as B, useContext as y } from "react";
|
|
7
|
+
const p = B(null), I = ({ value: e, onValueChange: t, children: o, className: a, isKeptActive: r = !1, expanded: i = !1 }) => /* @__PURE__ */ n(p.Provider, { value: { value: e, onValueChange: t, isKeptActive: r, expanded: i }, children: /* @__PURE__ */ n("div", { role: "radiogroup", "data-testid": "spectral-radio-button-group", "data-expanded": i, className: b("flex h-fit w-fit items-center rounded-md [&_button:first-of-type]:rounded-l-md [&_button:last-of-type]:rounded-r-md", "data-[expanded=true]:w-full", a), children: o }) }), C = ({
|
|
8
|
+
ref: e,
|
|
9
|
+
value: t,
|
|
10
|
+
children: o,
|
|
11
|
+
className: a,
|
|
12
|
+
disabled: r = !1,
|
|
13
|
+
asChild: i = !1,
|
|
14
|
+
onSelect: s,
|
|
15
|
+
onClick: d,
|
|
16
|
+
...v
|
|
17
|
+
}) => {
|
|
18
|
+
const l = y(p);
|
|
19
|
+
if (!l)
|
|
10
20
|
throw new Error("RadioButtonGroupItem must be used within a RadioButtonGroup");
|
|
11
|
-
const { value:
|
|
12
|
-
|
|
13
|
-
}, m = r ? h : "button", x = {
|
|
21
|
+
const { value: m, onValueChange: u, isKeptActive: h, expanded: x } = l, c = m === t, g = {
|
|
22
|
+
...v,
|
|
14
23
|
role: "radio",
|
|
15
|
-
"aria-checked":
|
|
16
|
-
"data-state":
|
|
24
|
+
"aria-checked": c,
|
|
25
|
+
"data-state": c ? "on" : "off",
|
|
17
26
|
"data-testid": "spectral-radio-button-group-item",
|
|
18
|
-
disabled:
|
|
19
|
-
onClick:
|
|
20
|
-
|
|
27
|
+
disabled: r,
|
|
28
|
+
onClick: (f) => {
|
|
29
|
+
d && d(f), !f.defaultPrevented && (r || (u && u(t), s && s(t)));
|
|
30
|
+
},
|
|
31
|
+
className: b(
|
|
21
32
|
`bg-toggle-bg inline-flex items-center justify-center gap-2 border text-sm font-medium disabled:pointer-events-none disabled:opacity-50
|
|
22
33
|
disabled:cursor-not-allowed hover:cursor-pointer text-toggle-text hover:bg-toggle-bg--hover hover:text-toggle-text--hover transition-[colors]
|
|
23
34
|
[&_svg]:pointer-events-none [&_svg]:shrink-0 focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] focus:outline-none
|
|
24
35
|
outline-none border-toggle-border hover:border-toggle-border--hover h-9 px-3 min-w-9 [&_svg:not([class*='size-']):not([width]):not([height])]:size-4
|
|
25
36
|
rounded-none shadow-none focus:z-10 focus-visible:z-10 [&:not(:first-child)]:border-l-0 active:bg-toggle-bg--active active:text-toggle-text--active
|
|
26
37
|
active:border-toggle-border--active`,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
x && "w-full",
|
|
39
|
+
h && "data-[state=on]:bg-toggle-bg--active data-[state=on]:text-toggle-text--active data-[state=on]:border-toggle-border--active",
|
|
40
|
+
a
|
|
30
41
|
)
|
|
31
42
|
};
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
}
|
|
34
|
-
|
|
43
|
+
return i ? /* @__PURE__ */ n(w, { ref: e, ...g, children: o }) : /* @__PURE__ */ n("button", { ref: e, ...g, type: "button", children: o });
|
|
44
|
+
};
|
|
45
|
+
C.displayName = "RadioButtonGroupItem";
|
|
35
46
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
I as RadioButtonGroupBase,
|
|
48
|
+
C as RadioButtonGroupItem
|
|
38
49
|
};
|
|
@@ -3,11 +3,10 @@ import { ComponentProps } from 'react';
|
|
|
3
3
|
export type RadioButtonGroupProps = ComponentProps<typeof RadioButtonGroupBase>;
|
|
4
4
|
export type RadioButtonGroupItemProps = RadioButtonGroupItemPropsBase;
|
|
5
5
|
export declare const RadioButtonGroup: ({ className, children, ...props }: RadioButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
export declare const RadioButtonGroupItem:
|
|
7
|
-
value:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} & import('react').RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
export declare const RadioButtonGroupItem: {
|
|
7
|
+
({ ref, value, children, className, disabled, asChild, onSelect, onClick, ...rest }: RadioButtonGroupItemPropsBase & {
|
|
8
|
+
ref?: import('react').Ref<HTMLButtonElement>;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
displayName: string;
|
|
11
|
+
};
|
|
13
12
|
//# sourceMappingURL=RadioButtonGroup.d.ts.map
|