@vokality/design-system 5.1.2 → 6.0.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/CHANGELOG.md +7 -0
- package/README.md +22 -1
- package/dist/appearance.d.ts +6 -0
- package/dist/appearance.js +1 -0
- package/dist/chat.d.ts +3 -1
- package/dist/components/Accordion/Accordion.d.ts +9 -6
- package/dist/components/Accordion/Accordion.js +4 -8
- package/dist/components/AppShell/AppShell.js +1 -1
- package/dist/components/Badge/Badge.d.ts +5 -1
- package/dist/components/Badge/Badge.js +2 -2
- package/dist/components/Button/Button.d.ts +11 -10
- package/dist/components/Button/Button.js +6 -14
- package/dist/components/ChatPanel/transcript.js +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.js +2 -2
- package/dist/components/Combobox/Combobox.d.ts +3 -0
- package/dist/components/Combobox/Combobox.js +3 -3
- package/dist/components/Combobox/ListPanel.d.ts +3 -1
- package/dist/components/Combobox/ListPanel.js +2 -2
- package/dist/components/Container/Container.d.ts +7 -4
- package/dist/components/Container/Container.js +3 -4
- package/dist/components/DatePicker/DatePicker.d.ts +3 -0
- package/dist/components/DatePicker/DatePicker.js +3 -3
- package/dist/components/Dialog/Dialog.d.ts +2 -4
- package/dist/components/Dialog/Dialog.js +2 -3
- package/dist/components/Grid/Grid.d.ts +3 -3
- package/dist/components/Heading/Heading.d.ts +14 -9
- package/dist/components/Heading/Heading.js +6 -5
- package/dist/components/IconButton/IconButton.d.ts +7 -7
- package/dist/components/IconButton/IconButton.js +2 -10
- package/dist/components/Inline/Inline.d.ts +2 -2
- package/dist/components/Input/Input.d.ts +6 -1
- package/dist/components/Input/Input.js +3 -3
- package/dist/components/Link/Link.d.ts +18 -3
- package/dist/components/Link/Link.js +7 -7
- package/dist/components/Menu/Menu.d.ts +27 -8
- package/dist/components/Menu/Menu.js +6 -11
- package/dist/components/MultiSelect/MultiSelect.d.ts +3 -0
- package/dist/components/MultiSelect/MultiSelect.js +3 -3
- package/dist/components/OtpInput/OtpInput.d.ts +16 -15
- package/dist/components/OtpInput/OtpInput.js +10 -8
- package/dist/components/PageHeader/PageHeader.d.ts +2 -2
- package/dist/components/PageHeader/PageHeader.js +2 -2
- package/dist/components/Popover/Popover.d.ts +16 -7
- package/dist/components/Popover/Popover.js +4 -3
- package/dist/components/Progress/Progress.d.ts +10 -10
- package/dist/components/Progress/Progress.js +8 -12
- package/dist/components/Prose/Prose.d.ts +4 -3
- package/dist/components/Prose/Prose.js +2 -2
- package/dist/components/Radio/Radio.d.ts +3 -3
- package/dist/components/Radio/Radio.js +4 -3
- package/dist/components/RadioGroup/RadioGroup.d.ts +7 -2
- package/dist/components/RadioGroup/RadioGroup.js +2 -2
- package/dist/components/SearchInput/SearchInput.d.ts +6 -1
- package/dist/components/SearchInput/SearchInput.js +2 -2
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +8 -8
- package/dist/components/SegmentedControl/SegmentedControl.js +4 -3
- package/dist/components/Select/Select.d.ts +4 -9
- package/dist/components/Select/Select.js +2 -7
- package/dist/components/Slider/Slider.d.ts +26 -19
- package/dist/components/Slider/Slider.js +20 -25
- package/dist/components/Sparkline/Sparkline.d.ts +2 -2
- package/dist/components/Sparkline/Sparkline.js +3 -3
- package/dist/components/Stack/Stack.d.ts +2 -2
- package/dist/components/Switch/Switch.d.ts +1 -1
- package/dist/components/Switch/Switch.js +2 -2
- package/dist/components/Table/Table.js +1 -1
- package/dist/components/Tabs/Tabs.d.ts +11 -9
- package/dist/components/Tabs/Tabs.js +5 -5
- package/dist/components/Text/Text.d.ts +12 -5
- package/dist/components/Text/Text.js +3 -3
- package/dist/components/Textarea/Textarea.d.ts +2 -0
- package/dist/components/Textarea/Textarea.js +3 -3
- package/dist/components/TimePicker/TimePicker.d.ts +2 -0
- package/dist/components/TimePicker/TimePicker.js +5 -5
- package/dist/components/Tooltip/Tooltip.d.ts +11 -6
- package/dist/components/Tooltip/Tooltip.js +5 -3
- package/dist/components.css +273 -129
- package/dist/internal/choice.d.ts +7 -2
- package/dist/internal/choice.js +4 -4
- package/dist/lib/space.d.ts +2 -1
- package/dist/lib/space.js +2 -6
- package/dist/tokens.css +2 -0
- package/dist/tokens.dtcg.json +10 -0
- package/dist/tokens.json +10 -0
- package/dist/types.d.ts +4 -3
- package/dist/typography.d.ts +8 -0
- package/dist/typography.js +34 -0
- package/dist/vokality.css +275 -129
- package/dist/vokality.iife.js +1945 -1863
- package/docs/brand.md +6 -2
- package/docs/components/Accordion/README.md +5 -2
- package/docs/components/Badge/README.md +2 -2
- package/docs/components/Button/README.md +15 -11
- package/docs/components/Checkbox/README.md +4 -0
- package/docs/components/Combobox/README.md +6 -0
- package/docs/components/Container/README.md +2 -1
- package/docs/components/DatePicker/README.md +6 -0
- package/docs/components/Dialog/README.md +2 -2
- package/docs/components/Grid/README.md +2 -1
- package/docs/components/Heading/README.md +4 -2
- package/docs/components/IconButton/README.md +7 -3
- package/docs/components/Inline/README.md +3 -3
- package/docs/components/Input/README.md +6 -0
- package/docs/components/Link/README.md +3 -1
- package/docs/components/Menu/README.md +7 -1
- package/docs/components/MultiSelect/README.md +8 -0
- package/docs/components/NumberInput/README.md +6 -0
- package/docs/components/OtpInput/README.md +10 -2
- package/docs/components/PageHeader/README.md +1 -1
- package/docs/components/PasswordInput/README.md +6 -0
- package/docs/components/Popover/README.md +6 -2
- package/docs/components/Progress/README.md +2 -2
- package/docs/components/Prose/README.md +1 -1
- package/docs/components/Radio/README.md +4 -0
- package/docs/components/RadioGroup/README.md +4 -0
- package/docs/components/SearchInput/README.md +6 -0
- package/docs/components/SegmentedControl/README.md +4 -1
- package/docs/components/Select/README.md +8 -3
- package/docs/components/Slider/README.md +13 -3
- package/docs/components/Sparkline/README.md +1 -1
- package/docs/components/Stack/README.md +1 -1
- package/docs/components/Switch/README.md +4 -0
- package/docs/components/Tabs/README.md +3 -1
- package/docs/components/Text/README.md +6 -3
- package/docs/components/Textarea/README.md +4 -0
- package/docs/components/ThemeProvider/README.md +1 -1
- package/docs/components/TimePicker/README.md +6 -0
- package/docs/components/Tooltip/README.md +4 -3
- package/package.json +9 -1
- package/skills/vokality-design-system/SKILL.md +1 -1
|
@@ -17,9 +17,9 @@ export const Input = forwardRef(function Input(props, ref) {
|
|
|
17
17
|
const countMax = props.showCount && props.maxLength ? props.maxLength : 0;
|
|
18
18
|
// Add-ons or a counter put the field in a wrapper, which then takes className.
|
|
19
19
|
const wrapped = !!(props.prefix || props.suffix || countMax);
|
|
20
|
-
const rest = omit(props, ["className", "prefix", "suffix", "showCount", "value", "defaultValue", "onChange", "inputClassName"]);
|
|
21
|
-
const input = (_jsx("input", { type: "text", ref: ref, ...rest, value: txt.value, onChange: txt.onChange, maxLength: countMax ? undefined : props.maxLength, className: cx("vk-input", props.prefix ? "vk-input-has-prefix" : null, props.suffix ? "vk-input-has-suffix" : null, props.inputClassName, wrapped ? null : props.className) }));
|
|
20
|
+
const rest = omit(props, ["size", "htmlSize", "className", "prefix", "suffix", "showCount", "value", "defaultValue", "onChange", "inputClassName"]);
|
|
21
|
+
const input = (_jsx("input", { type: "text", ref: ref, ...rest, "data-vk-size": props.size, size: props.htmlSize, value: txt.value, onChange: txt.onChange, maxLength: countMax ? undefined : props.maxLength, className: cx("vk-input", props.prefix ? "vk-input-has-prefix" : null, props.suffix ? "vk-input-has-suffix" : null, props.inputClassName, wrapped ? null : props.className) }));
|
|
22
22
|
if (!wrapped)
|
|
23
23
|
return input;
|
|
24
|
-
return (_jsxs("span", { className: cx("vk-affix", props.className), children: [_jsxs("span", { className: "vk-affix-row", children: [_jsx(Addon, { side: "prefix", children: props.prefix }), input, _jsx(Addon, { side: "suffix", children: props.suffix })] }), countMax ? _jsx(CharCount, { value: txt.value, max: countMax }) : null] }));
|
|
24
|
+
return (_jsxs("span", { className: cx("vk-affix", props.className), "data-vk-size": props.size, children: [_jsxs("span", { className: "vk-affix-row", children: [_jsx(Addon, { side: "prefix", children: props.prefix }), input, _jsx(Addon, { side: "suffix", children: props.suffix })] }), countMax ? _jsx(CharCount, { value: txt.value, max: countMax }) : null] }));
|
|
25
25
|
});
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import { type AnchorHTMLAttributes } from "react";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { AppearanceVariant, ControlSize, SemanticColor } from "../../appearance.js";
|
|
3
|
+
import type { TextEmphasis } from "../../typography.js";
|
|
4
|
+
interface LinkBaseProps extends Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "color"> {
|
|
5
|
+
/** Theme-aware palette. Neutral for inline links, primary for action links. */
|
|
6
|
+
color?: SemanticColor;
|
|
7
|
+
/** Opens an external destination in a new tab with an accompanying glyph. */
|
|
4
8
|
external?: boolean;
|
|
5
9
|
}
|
|
6
|
-
/** Inline text
|
|
10
|
+
/** Inline text emphasis and action geometry are separate presentation contracts. */
|
|
11
|
+
export type LinkProps = LinkBaseProps & ({
|
|
12
|
+
variant?: undefined;
|
|
13
|
+
emphasis?: TextEmphasis;
|
|
14
|
+
size?: never;
|
|
15
|
+
} | {
|
|
16
|
+
variant: AppearanceVariant;
|
|
17
|
+
size?: ControlSize;
|
|
18
|
+
emphasis?: never;
|
|
19
|
+
});
|
|
20
|
+
/** A native anchor, optionally styled as an action. LinkProvider supplies router integration. */
|
|
7
21
|
export declare const Link: import("react").ForwardRefExoticComponent<LinkProps & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
22
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import { Icon } from "../Icon/Icon.js";
|
|
4
4
|
import { Anchor } from "../LinkProvider/LinkProvider.js";
|
|
5
5
|
import { cx } from "../../lib/cx.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
return (
|
|
6
|
+
/** A native anchor, optionally styled as an action. LinkProvider supplies router integration. */
|
|
7
|
+
export const Link = forwardRef(function Link({ color, emphasis, variant, size, external, className, children, ...props }, ref) {
|
|
8
|
+
const palette = color ?? (variant ? "primary" : "neutral");
|
|
9
|
+
const ext = external ? { target: "_blank", rel: "noopener noreferrer" } : {};
|
|
10
|
+
const content = _jsxs(_Fragment, { children: [children, external ? _jsx(Icon, { name: "arrow-up-right", size: 13, className: "vk-link-icon" }) : null] });
|
|
11
|
+
return (_jsx(Anchor, { ...ext, ...props, ref: ref, "data-vk-color": palette, "data-vk-variant": variant, "data-vk-size": size, className: cx("vk-link", variant && "vk-btn", emphasis && "vk-emphasis-" + emphasis, className), children: variant ? _jsx("span", { className: "vk-btn-label", children: content }) : content }));
|
|
12
12
|
});
|
|
@@ -1,13 +1,32 @@
|
|
|
1
|
+
import { DropdownMenu as Primitive } from "radix-ui";
|
|
2
|
+
import type { AppearanceVariant, ControlSize, SemanticColor } from "../../appearance.js";
|
|
1
3
|
import type { IconName, MenuEntry } from "../../types.js";
|
|
2
|
-
|
|
4
|
+
import type { IconButtonProps } from "../IconButton/IconButton.js";
|
|
5
|
+
interface MenuBaseProps extends Omit<Primitive.DropdownMenuProps, "children"> {
|
|
3
6
|
items: MenuEntry[];
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
color?: SemanticColor;
|
|
8
|
+
size?: ControlSize;
|
|
9
|
+
/** Native content placement. */
|
|
10
|
+
side?: Primitive.DropdownMenuContentProps["side"];
|
|
11
|
+
align?: Primitive.DropdownMenuContentProps["align"];
|
|
12
|
+
/** Native trigger attributes and handlers; the ref targets this button. */
|
|
13
|
+
triggerProps?: Omit<Primitive.DropdownMenuTriggerProps, "children" | "asChild" | "className" | "disabled">;
|
|
14
|
+
/** Native positioning, dismissal and content attributes. */
|
|
15
|
+
contentProps?: Omit<Primitive.DropdownMenuContentProps, "children" | "asChild" | "className" | "side" | "align">;
|
|
10
16
|
disabled?: boolean;
|
|
11
17
|
className?: string;
|
|
12
18
|
}
|
|
13
|
-
export
|
|
19
|
+
export type MenuProps = MenuBaseProps & ({
|
|
20
|
+
label: string;
|
|
21
|
+
icon?: IconName;
|
|
22
|
+
triggerLabel?: string;
|
|
23
|
+
variant?: AppearanceVariant;
|
|
24
|
+
} | {
|
|
25
|
+
label?: undefined;
|
|
26
|
+
icon: IconName;
|
|
27
|
+
triggerLabel?: string;
|
|
28
|
+
variant?: IconButtonProps["variant"];
|
|
29
|
+
});
|
|
30
|
+
/** Menu button (WAI-ARIA), built on Radix DropdownMenu. */
|
|
31
|
+
export declare const Menu: import("react").ForwardRefExoticComponent<MenuProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
export {};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
3
4
|
import { useLocale } from "../../localization.js";
|
|
4
5
|
import { DropdownMenu as Primitive } from "radix-ui";
|
|
5
6
|
import { Icon } from "../Icon/Icon.js";
|
|
6
7
|
import { cx } from "../../lib/cx.js";
|
|
7
8
|
import { MenuEntries } from "./entries.js";
|
|
8
9
|
/** Menu button (WAI-ARIA), built on Radix DropdownMenu. */
|
|
9
|
-
|
|
10
|
-
function triggerClass(iconOnly, variant, size) {
|
|
11
|
-
return iconOnly
|
|
12
|
-
? cx("vk-icon-btn", variant === "outline" ? "vk-icon-btn-outline" : "vk-icon-btn-ghost", size === "xs" && "vk-icon-btn-xs")
|
|
13
|
-
: cx("vk-btn", "vk-btn-" + (variant || "outline"), size === "sm" && "vk-btn-sm", size === "xs" && "vk-btn-xs");
|
|
14
|
-
}
|
|
15
|
-
export function Menu({ items, label, icon, triggerLabel, variant, size, align, disabled, className }) {
|
|
10
|
+
export const Menu = forwardRef(function Menu({ items, label, icon, triggerLabel, variant, color = "primary", size, side = "bottom", align = "start", triggerProps, contentProps, disabled, className, ...rootProps }, ref) {
|
|
16
11
|
const { messages } = useLocale();
|
|
17
12
|
// An icon with no label makes an icon button, named by triggerLabel.
|
|
18
|
-
const iconOnly = label
|
|
19
|
-
return (_jsx("div", { className: cx("vk-menu-root", className), children: _jsxs(Primitive.Root, { children: [_jsx(Primitive.Trigger, { disabled: disabled, className:
|
|
13
|
+
const iconOnly = label === undefined ? icon : undefined;
|
|
14
|
+
return (_jsx("div", { className: cx("vk-menu-root", className), children: _jsxs(Primitive.Root, { ...rootProps, children: [_jsx(Primitive.Trigger, { ...triggerProps, ref: ref, disabled: disabled, className: iconOnly ? "vk-icon-btn" : "vk-btn", "data-vk-size": size, "data-vk-color": color, "data-vk-variant": variant ?? (iconOnly ? "ghost" : "outline"), "aria-label": triggerProps?.["aria-label"] ?? (iconOnly ? triggerLabel || messages.moreActions : undefined), title: triggerProps?.title ?? (iconOnly ? triggerLabel || messages.moreActions : undefined), children: iconOnly
|
|
20
15
|
? _jsx(Icon, { name: iconOnly })
|
|
21
|
-
: _jsxs(_Fragment, { children: [_jsxs("span", { className: "vk-btn-label", children: [icon ? _jsx(Icon, { name: icon, size: 16, className: "vk-menu-trigger-icon" }) : null, label] }), _jsx("span", { className: "vk-btn-glyph", "aria-hidden": "true", children: _jsx(Icon, { name: "chevron-down", size: 14 }) })] }) }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, {
|
|
22
|
-
}
|
|
16
|
+
: _jsxs(_Fragment, { children: [_jsxs("span", { className: "vk-btn-label", children: [icon ? _jsx(Icon, { name: icon, size: 16, className: "vk-menu-trigger-icon" }) : null, label] }), _jsx("span", { className: "vk-btn-glyph", "aria-hidden": "true", children: _jsx(Icon, { name: "chevron-down", size: 14 }) })] }) }), _jsx(Primitive.Portal, { forceMount: contentProps?.forceMount, children: _jsx(Primitive.Content, { sideOffset: 4, collisionPadding: 8, ...contentProps, className: "vk-menu", side: side, align: align, children: _jsx(MenuEntries, { parts: Primitive, items: items }) }) })] }) }));
|
|
17
|
+
});
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { ControlSize } from "../../appearance.js";
|
|
1
2
|
import type { SelectOption } from "../../types.js";
|
|
2
3
|
export interface MultiSelectProps {
|
|
4
|
+
/** Visual size shared with actions and other fields. */
|
|
5
|
+
size?: ControlSize;
|
|
3
6
|
options: (string | SelectOption)[];
|
|
4
7
|
value?: string[];
|
|
5
8
|
defaultValue?: string[];
|
|
@@ -132,12 +132,12 @@ export function MultiSelect(props) {
|
|
|
132
132
|
close();
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
const a11y = omit(props, ["options", "placeholder", "className", "value", "defaultValue", "onChange", "disabled", "name", "id", "defaultOpen", "emptyText", "max", "required"]);
|
|
135
|
+
const a11y = omit(props, ["size", "options", "placeholder", "className", "value", "defaultValue", "onChange", "disabled", "name", "id", "defaultOpen", "emptyText", "max", "required"]);
|
|
136
136
|
return (_jsx(Popover.Root, { open: open, onOpenChange: (next) => {
|
|
137
137
|
// A press outside, or Escape from outside the field.
|
|
138
138
|
if (!next)
|
|
139
139
|
close();
|
|
140
|
-
}, children: _jsxs("div", { ref: rootRef, className: cx("vk-select", "vk-multiselect", open && "vk-select-open", props.disabled && "vk-multiselect-disabled", props.className), children: [_jsx(Popover.Anchor, { asChild: true, children: _jsxs("div", {
|
|
140
|
+
}, children: _jsxs("div", { ref: rootRef, "data-vk-size": props.size, className: cx("vk-select", "vk-multiselect", open && "vk-select-open", props.disabled && "vk-multiselect-disabled", props.className), children: [_jsx(Popover.Anchor, { asChild: true, children: _jsxs("div", {
|
|
141
141
|
// The box around the tags and the combobox input: a press anywhere in it focuses the
|
|
142
142
|
// input (which carries the role and keyboard support), so the box itself is presentational.
|
|
143
143
|
role: "presentation", className: "vk-input vk-multiselect-field", "aria-invalid": props["aria-invalid"], onMouseDown: (e) => {
|
|
@@ -159,7 +159,7 @@ export function MultiSelect(props) {
|
|
|
159
159
|
}, onKeyDown: onKeyDown, onBlur: (e) => {
|
|
160
160
|
if (rootRef.current && !rootRef.current.contains(e.relatedTarget))
|
|
161
161
|
close();
|
|
162
|
-
}, ...a11y }), _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" })] }) }), _jsx(ListPanel, { rootRef: rootRef, active: active, children: optionList({
|
|
162
|
+
}, ...a11y }), _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" })] }) }), _jsx(ListPanel, { rootRef: rootRef, active: active, size: props.size, children: optionList({
|
|
163
163
|
listId,
|
|
164
164
|
options: filtered,
|
|
165
165
|
values,
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { unstable_OneTimePasswordField as Primitive } from "radix-ui";
|
|
2
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
3
|
+
import type { ControlSize } from "../../appearance.js";
|
|
4
|
+
type RootProps = ComponentPropsWithoutRef<typeof Primitive.Root>;
|
|
5
|
+
type DigitProps = ComponentPropsWithoutRef<typeof Primitive.Input>;
|
|
6
|
+
export interface OtpInputProps extends Omit<RootProps, "children" | "asChild"> {
|
|
7
|
+
/** Visual size shared with actions and other fields. */
|
|
8
|
+
size?: ControlSize;
|
|
9
|
+
/** Number of composed input boxes. */
|
|
2
10
|
length?: number;
|
|
3
|
-
|
|
4
|
-
defaultValue?: string;
|
|
5
|
-
onChange?: (code: string) => void;
|
|
6
|
-
onComplete?: (code: string) => void;
|
|
7
|
-
numeric?: boolean;
|
|
8
|
-
name?: string;
|
|
9
|
-
disabled?: boolean;
|
|
11
|
+
/** Localized noun used in each box's accessible name. */
|
|
10
12
|
label?: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'aria-describedby'?: string;
|
|
16
|
-
'aria-invalid'?: boolean;
|
|
13
|
+
/** Called after a changed value fills every box; does not submit the form. */
|
|
14
|
+
onComplete?: (code: string) => void;
|
|
15
|
+
/** Native Radix Input props shared by each digit, including onInvalidChange. */
|
|
16
|
+
inputProps?: Omit<DigitProps, "index" | "id" | "children" | "asChild" | "className" | "aria-label" | "aria-invalid" | "aria-describedby">;
|
|
17
17
|
}
|
|
18
18
|
/** Styled Radix OTP fields; the primitive owns validation, paste, navigation, focus and form data. */
|
|
19
|
-
export declare
|
|
19
|
+
export declare const OtpInput: import("react").ForwardRefExoticComponent<OtpInputProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
20
|
+
export {};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement as _createElement } from "react";
|
|
3
4
|
import { unstable_OneTimePasswordField as Primitive } from "radix-ui";
|
|
5
|
+
import { forwardRef } from "react";
|
|
4
6
|
import { useLocale } from "../../localization.js";
|
|
5
7
|
import { useUid } from "../../internal/useUid.js";
|
|
6
8
|
import { cx } from "../../lib/cx.js";
|
|
7
9
|
/** Styled Radix OTP fields; the primitive owns validation, paste, navigation, focus and form data. */
|
|
8
|
-
export function OtpInput(
|
|
10
|
+
export const OtpInput = forwardRef(function OtpInput({ size, length = 6, label, onComplete, inputProps, onValueChange, className, style, id, ...rootProps }, ref) {
|
|
9
11
|
const { messages } = useLocale();
|
|
10
|
-
const length = props.length || 6;
|
|
11
12
|
const uid = useUid("vk-otp");
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const rootId = id || uid;
|
|
14
|
+
const otpStyle = { "--vk-otp-length": length, ...style };
|
|
15
|
+
return (_jsxs(Primitive.Root, { ...rootProps, ref: ref, id: rootId, className: cx("vk-otp", className), "data-vk-size": size, style: otpStyle, onValueChange: (code) => {
|
|
16
|
+
onValueChange?.(code);
|
|
15
17
|
if (code.length === length)
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
}
|
|
18
|
+
onComplete?.(code);
|
|
19
|
+
}, "aria-label": rootProps["aria-labelledby"] ? undefined : rootProps["aria-label"] || messages.oneTimeCode, children: [Array.from({ length }, (_, index) => (_createElement(Primitive.Input, { ...inputProps, key: index, index: index, id: rootId + "-digit-" + String(index + 1), className: "vk-input vk-otp-box", "aria-label": messages.digitPosition(label || messages.digit, index + 1, length), "aria-invalid": rootProps["aria-invalid"], "aria-describedby": index === 0 ? rootProps["aria-describedby"] : undefined }))), _jsx(Primitive.HiddenInput, { name: rootProps.disabled ? undefined : rootProps.name, form: rootProps.form })] }));
|
|
20
|
+
});
|
|
@@ -8,11 +8,11 @@ export interface PageHeaderProps {
|
|
|
8
8
|
breadcrumbs?: BreadcrumbsProps["items"];
|
|
9
9
|
actions?: ReactNode;
|
|
10
10
|
badge?: ReactNode;
|
|
11
|
-
|
|
11
|
+
badgeColor?: BadgeProps["color"];
|
|
12
12
|
divider?: boolean;
|
|
13
13
|
headingAs?: "h1" | "h2";
|
|
14
14
|
children?: ReactNode;
|
|
15
15
|
className?: string;
|
|
16
16
|
}
|
|
17
17
|
/** The top of a page inside an app: breadcrumbs, the page title, a description and the page's main actions. */
|
|
18
|
-
export declare function PageHeader({ title, description, eyebrow, breadcrumbs, actions, badge,
|
|
18
|
+
export declare function PageHeader({ title, description, eyebrow, breadcrumbs, actions, badge, badgeColor, divider, headingAs, children, className }: PageHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { Breadcrumbs } from "../Breadcrumbs/Breadcrumbs.js";
|
|
|
5
5
|
import { cx } from "../../lib/cx.js";
|
|
6
6
|
import { para } from "../../lib/text.js";
|
|
7
7
|
/** The top of a page inside an app: breadcrumbs, the page title, a description and the page's main actions. */
|
|
8
|
-
export function PageHeader({ title, description, eyebrow, breadcrumbs, actions, badge,
|
|
8
|
+
export function PageHeader({ title, description, eyebrow, breadcrumbs, actions, badge, badgeColor, divider, headingAs, children, className }) {
|
|
9
9
|
const Heading = headingAs || "h1";
|
|
10
|
-
return (_jsxs("header", { className: cx("vk-page-header", divider ? "vk-page-header-divider" : null, className), children: [breadcrumbs ? _jsx(Breadcrumbs, { items: breadcrumbs }) : null, _jsxs("div", { className: "vk-page-header-row", children: [_jsxs("div", { className: "vk-page-header-text", children: [eyebrow ? _jsx("p", { className: "vk-page-header-eyebrow", children: eyebrow }) : null, _jsxs(Heading, { className: "vk-page-header-title", children: [title, badge ? _jsx(Badge, {
|
|
10
|
+
return (_jsxs("header", { className: cx("vk-page-header", divider ? "vk-page-header-divider" : null, className), children: [breadcrumbs ? _jsx(Breadcrumbs, { items: breadcrumbs }) : null, _jsxs("div", { className: "vk-page-header-row", children: [_jsxs("div", { className: "vk-page-header-text", children: [eyebrow ? _jsx("p", { className: "vk-page-header-eyebrow", children: eyebrow }) : null, _jsxs(Heading, { className: "vk-page-header-title", children: [title, badge ? _jsx(Badge, { color: badgeColor, children: badge }) : null] }), description ? createElement(para(description), { className: "vk-page-header-description" }, description) : null] }), actions ? _jsx("div", { className: "vk-page-header-actions", children: actions }) : null] }), children] }));
|
|
11
11
|
}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import { Popover as Primitive } from "radix-ui";
|
|
3
|
+
import type { AppearanceVariant, ControlSize, SemanticColor } from "../../appearance.js";
|
|
3
4
|
import type { IconName } from "../../types.js";
|
|
4
|
-
export interface PopoverProps extends
|
|
5
|
+
export interface PopoverProps extends Omit<Primitive.PopoverProps, "children"> {
|
|
5
6
|
label: string;
|
|
6
7
|
title?: string;
|
|
7
|
-
icon?: IconName;
|
|
8
|
-
variant?:
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
icon?: IconName;
|
|
9
|
+
variant?: AppearanceVariant;
|
|
10
|
+
color?: SemanticColor;
|
|
11
|
+
size?: ControlSize;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Native content placement. */
|
|
14
|
+
side?: Primitive.PopoverContentProps["side"];
|
|
15
|
+
align?: Primitive.PopoverContentProps["align"];
|
|
16
|
+
/** Native trigger attributes and handlers; the ref targets this button. */
|
|
17
|
+
triggerProps?: Omit<Primitive.PopoverTriggerProps, "children" | "asChild" | "className" | "disabled">;
|
|
18
|
+
/** Native positioning, focus, dismissal and content attributes. */
|
|
19
|
+
contentProps?: Omit<Primitive.PopoverContentProps, "children" | "asChild" | "className" | "side" | "align">;
|
|
11
20
|
width?: string;
|
|
12
21
|
children: ReactNode;
|
|
13
22
|
close?: ReactElement;
|
|
14
23
|
className?: string;
|
|
15
24
|
}
|
|
16
25
|
/** Non-modal panel attached to a button (Radix Popover). */
|
|
17
|
-
export declare
|
|
26
|
+
export declare const Popover: import("react").ForwardRefExoticComponent<PopoverProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
3
4
|
import { Popover as Primitive } from "radix-ui";
|
|
4
5
|
import { Icon } from "../Icon/Icon.js";
|
|
5
6
|
import { cx } from "../../lib/cx.js";
|
|
6
7
|
/** Non-modal panel attached to a button (Radix Popover). */
|
|
7
|
-
export function Popover({ label, title, icon, variant, size,
|
|
8
|
-
return (_jsx("div", { className: cx("vk-menu-root", className), children: _jsxs(Primitive.Root, {
|
|
9
|
-
}
|
|
8
|
+
export const Popover = forwardRef(function Popover({ label, title, icon, variant = "outline", color = "primary", size, disabled, side = "bottom", align = "start", triggerProps, contentProps, width, children, close, className, ...rootProps }, ref) {
|
|
9
|
+
return (_jsx("div", { className: cx("vk-menu-root", className), children: _jsxs(Primitive.Root, { ...rootProps, children: [_jsxs(Primitive.Trigger, { ...triggerProps, ref: ref, className: "vk-btn", disabled: disabled, "data-vk-size": size, "data-vk-color": color, "data-vk-variant": variant, children: [_jsxs("span", { className: "vk-btn-label", children: [icon ? _jsx(Icon, { name: icon, size: 16, className: "vk-menu-trigger-icon" }) : null, label] }), _jsx("span", { className: "vk-btn-glyph", "aria-hidden": "true", children: _jsx(Icon, { name: "chevron-down", size: 14 }) })] }), _jsx(Primitive.Portal, { forceMount: contentProps?.forceMount, children: _jsxs(Primitive.Content, { "aria-label": title || label, sideOffset: 4, collisionPadding: 8, ...contentProps, className: "vk-popover vk-popover-panel", side: side, align: align, style: width ? { ...contentProps?.style, width } : contentProps?.style, children: [title ? _jsx("p", { className: "vk-popover-title", children: title }) : null, children, close ? _jsx("div", { className: "vk-popover-footer", children: _jsx(Primitive.Close, { asChild: true, children: close }) }) : null] }) })] }) }));
|
|
10
|
+
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
|
+
import { Progress as Primitive } from "radix-ui";
|
|
3
|
+
import type { SemanticColor } from "../../appearance.js";
|
|
4
|
+
export interface ProgressProps extends Omit<ComponentPropsWithoutRef<typeof Primitive.Root>, "children" | "asChild"> {
|
|
5
|
+
/** A visible label associated with the progressbar. */
|
|
5
6
|
label?: ReactNode;
|
|
7
|
+
/** Displays the percentage, or the upstream getValueLabel result. */
|
|
6
8
|
showValue?: boolean;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"aria-label"?: string;
|
|
10
|
-
className?: string;
|
|
9
|
+
/** Theme-aware fill palette. */
|
|
10
|
+
color?: SemanticColor;
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
13
|
-
export declare
|
|
12
|
+
/** Styled Radix Progress. Native props and the ref target its progressbar root. */
|
|
13
|
+
export declare const Progress: import("react").ForwardRefExoticComponent<ProgressProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
4
|
import { Progress as Primitive } from "radix-ui";
|
|
5
|
+
import { useLocale } from "../../localization.js";
|
|
5
6
|
import { useUid } from "../../internal/useUid.js";
|
|
6
7
|
import { cx } from "../../lib/cx.js";
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
return (_jsxs("div", { className: "vk-progress-row", children: [label ? _jsx("span", { id: labelId, className: "vk-progress-label", children: label }) : _jsx("span", {}), value != null ? _jsx("span", { className: "vk-progress-value", children: value }) : null] }));
|
|
10
|
-
}
|
|
11
|
-
/** A bar showing how far a task has got, or that it is still running (Radix Progress). */
|
|
12
|
-
export function Progress({ value, max: maxProp, label, showValue, valueText, tone, "aria-label": ariaLabel, className }) {
|
|
8
|
+
/** Styled Radix Progress. Native props and the ref target its progressbar root. */
|
|
9
|
+
export const Progress = forwardRef(function Progress({ value, max = 100, label, showValue, getValueLabel, color = "primary", "aria-label": ariaLabel, className, ...props }, ref) {
|
|
13
10
|
const { messages } = useLocale();
|
|
14
|
-
const
|
|
11
|
+
const labelId = useUid("vk-progress");
|
|
15
12
|
const indeterminate = value == null;
|
|
16
13
|
const pct = value == null ? 0 : (value / max) * 100;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
14
|
+
const shownValue = showValue && value != null ? getValueLabel?.(value, max) ?? String(Math.round(pct)) + "%" : null;
|
|
15
|
+
return (_jsxs("div", { className: "vk-progress", "data-vk-color": color, children: [label || showValue ? _jsxs("div", { className: "vk-progress-row", children: [label ? _jsx("span", { id: labelId, className: "vk-progress-label", children: label }) : _jsx("span", {}), shownValue != null ? _jsx("span", { className: "vk-progress-value", children: shownValue }) : null] }) : null, _jsx(Primitive.Root, { ...props, ref: ref, value: value, max: max, getValueLabel: getValueLabel, "aria-labelledby": props["aria-labelledby"] ?? (label ? labelId : undefined), "aria-label": label ? ariaLabel : ariaLabel ?? messages.progress, className: cx("vk-progress-track", className), children: indeterminate ? null : _jsx(Primitive.Indicator, { className: "vk-progress-fill", style: { width: String(pct) + "%" } }) })] }));
|
|
16
|
+
});
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { TextEmphasis } from "../../typography.js";
|
|
2
3
|
import type { AsProp } from "../../types.js";
|
|
3
4
|
export interface ProseProps extends AsProp {
|
|
4
5
|
children?: ReactNode;
|
|
5
6
|
className?: string;
|
|
6
|
-
/**
|
|
7
|
-
|
|
7
|
+
/** Muted by default for articles; default emphasis uses foreground for record descriptions and messages. */
|
|
8
|
+
emphasis?: Extract<TextEmphasis, "default" | "muted">;
|
|
8
9
|
}
|
|
9
10
|
/** Styles long-form HTML (help articles, release notes, rendered Markdown) without a class on every element. */
|
|
10
|
-
export declare function Prose({ as, children, className,
|
|
11
|
+
export declare function Prose({ as, children, className, emphasis }: ProseProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "../../lib/cx.js";
|
|
3
3
|
/** Styles long-form HTML (help articles, release notes, rendered Markdown) without a class on every element. */
|
|
4
|
-
export function Prose({ as, children, className,
|
|
4
|
+
export function Prose({ as, children, className, emphasis }) {
|
|
5
5
|
const Tag = as || "div";
|
|
6
|
-
return _jsx(Tag, { className: cx("vk-prose",
|
|
6
|
+
return _jsx(Tag, { className: cx("vk-prose", emphasis === "default" && "vk-prose-foreground", className), children: children });
|
|
7
7
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type InputHTMLAttributes } from "react";
|
|
2
2
|
import type { ChoiceTextProps } from "../../internal/choice.js";
|
|
3
|
-
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type">, ChoiceTextProps {
|
|
3
|
+
export interface RadioProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "type" | "size" | "color">, ChoiceTextProps {
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Square radio (inner square dot) with label and optional description. A native radio, since Radix radios only
|
|
7
7
|
* work inside a group; `RadioGroup` draws the same box with Radix RadioGroup.
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare const Radio: import("react").ForwardRefExoticComponent<RadioProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { nativeRadio } from "../../internal/choice.js";
|
|
3
|
+
import { forwardRef } from "react";
|
|
3
4
|
/**
|
|
4
5
|
* Square radio (inner square dot) with label and optional description. A native radio, since Radix radios only
|
|
5
6
|
* work inside a group; `RadioGroup` draws the same box with Radix RadioGroup.
|
|
6
7
|
*/
|
|
7
|
-
export function Radio(props) {
|
|
8
|
-
return nativeRadio(props);
|
|
9
|
-
}
|
|
8
|
+
export const Radio = forwardRef(function Radio(props, ref) {
|
|
9
|
+
return nativeRadio(props, ref);
|
|
10
|
+
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { ComponentPropsWithoutRef, ReactNode } from "react";
|
|
2
2
|
import { RadioGroup as Primitive } from "radix-ui";
|
|
3
|
-
|
|
3
|
+
import type { ControlSize, SemanticColor } from "../../appearance.js";
|
|
4
|
+
export interface RadioGroupProps extends Omit<ComponentPropsWithoutRef<typeof Primitive.Root>, "asChild" | "children" | "onChange" | "color"> {
|
|
5
|
+
/** Shared dimensions of each choice. */
|
|
6
|
+
size?: ControlSize;
|
|
7
|
+
/** Semantic palette of the selected option. */
|
|
8
|
+
color?: SemanticColor;
|
|
4
9
|
label: ReactNode;
|
|
5
10
|
options: (string | {
|
|
6
11
|
value: string;
|
|
@@ -11,4 +16,4 @@ export interface RadioGroupProps extends Omit<ComponentPropsWithoutRef<typeof Pr
|
|
|
11
16
|
inline?: boolean;
|
|
12
17
|
}
|
|
13
18
|
/** Styled Radix RadioGroup with a fieldset legend and direct onValueChange(value) callbacks. */
|
|
14
|
-
export declare function RadioGroup({ label, options, inline, className, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function RadioGroup({ label, options, inline, className, size, color, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,10 +5,10 @@ import { ChoiceLabel } from "../../internal/choice.js";
|
|
|
5
5
|
import { useUid } from "../../internal/useUid.js";
|
|
6
6
|
import { cx } from "../../lib/cx.js";
|
|
7
7
|
/** Styled Radix RadioGroup with a fieldset legend and direct onValueChange(value) callbacks. */
|
|
8
|
-
export function RadioGroup({ label, options, inline, className, ...props }) {
|
|
8
|
+
export function RadioGroup({ label, options, inline, className, size, color, ...props }) {
|
|
9
9
|
const legendId = useUid("vk-radio-group");
|
|
10
10
|
return (_jsx(Primitive.Root, { ...props, asChild: true, children: _jsxs("fieldset", { className: cx("vk-choice-group", inline && "vk-choice-group-inline", className), "aria-labelledby": legendId, children: [_jsx("legend", { id: legendId, className: "vk-field-label", children: label }), _jsx("div", { className: "vk-choice-list", children: options.map((option) => {
|
|
11
11
|
const item = typeof option === "string" ? { value: option, label: option } : option;
|
|
12
|
-
return (_jsx(ChoiceLabel, { label: item.label, description: item.description, disabled: props.disabled || item.disabled, children: _jsx(Primitive.Item, { className: "vk-choice-box vk-choice-box-radio", value: item.value, disabled: item.disabled, children: _jsx(Primitive.Indicator, { forceMount: true, className: "vk-choice-dot" }) }) }, item.value));
|
|
12
|
+
return (_jsx(ChoiceLabel, { size: size, color: color, label: item.label, description: item.description, disabled: props.disabled || item.disabled, children: _jsx(Primitive.Item, { className: "vk-choice-box vk-choice-box-radio", value: item.value, disabled: item.disabled, children: _jsx(Primitive.Indicator, { forceMount: true, className: "vk-choice-dot" }) }) }, item.value));
|
|
13
13
|
}) })] }) }));
|
|
14
14
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { type ChangeEvent, type InputHTMLAttributes } from "react";
|
|
2
|
-
|
|
2
|
+
import type { ControlSize } from "../../appearance.js";
|
|
3
|
+
export interface SearchInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'type' | 'size'> {
|
|
4
|
+
/** Visual size shared with actions and other fields. */
|
|
5
|
+
size?: ControlSize;
|
|
6
|
+
/** Native input width in characters. */
|
|
7
|
+
htmlSize?: number;
|
|
3
8
|
value?: string;
|
|
4
9
|
defaultValue?: string;
|
|
5
10
|
onChange?: (value: string, event?: ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -20,13 +20,13 @@ export const SearchInput = forwardRef(function SearchInput(props, ref) {
|
|
|
20
20
|
else if (ref)
|
|
21
21
|
ref.current = el;
|
|
22
22
|
}, [ref]);
|
|
23
|
-
const rest = omit(props, ["value", "defaultValue", "onChange", "onClear", "className", "clearLabel"]);
|
|
23
|
+
const rest = omit(props, ["size", "htmlSize", "value", "defaultValue", "onChange", "onClear", "className", "clearLabel"]);
|
|
24
24
|
const set = (v, e) => {
|
|
25
25
|
if (!controlled)
|
|
26
26
|
setText(v);
|
|
27
27
|
props.onChange?.(v, e);
|
|
28
28
|
};
|
|
29
|
-
return (_jsxs("span", { className: cx("vk-search", props.className), children: [_jsx(Icon, { name: "search", size: 16, className: "vk-search-icon" }), _jsx("input", { ref: setRef, type: "search", className: "vk-input vk-search-input", autoComplete: "off", ...rest, value: value, onChange: (e) => { set(e.target.value, e); }, onKeyDown: (e) => {
|
|
29
|
+
return (_jsxs("span", { className: cx("vk-search", props.className), "data-vk-size": props.size, children: [_jsx(Icon, { name: "search", size: 16, className: "vk-search-icon" }), _jsx("input", { ref: setRef, type: "search", className: "vk-input vk-search-input", autoComplete: "off", ...rest, size: props.htmlSize, value: value, onChange: (e) => { set(e.target.value, e); }, onKeyDown: (e) => {
|
|
30
30
|
if (e.key === "Escape" && value) {
|
|
31
31
|
e.preventDefault();
|
|
32
32
|
set("");
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { RadioGroup as Primitive } from "radix-ui";
|
|
2
3
|
import type { IconName } from "../../types.js";
|
|
4
|
+
import type { AppearanceVariant, ControlSize, SemanticColor } from "../../appearance.js";
|
|
3
5
|
/** Exclusive options that apply immediately (radiogroup). */
|
|
4
|
-
export interface SegmentedControlProps {
|
|
6
|
+
export interface SegmentedControlProps extends Omit<Primitive.RadioGroupProps, "children" | "color" | "asChild"> {
|
|
5
7
|
options: (string | {
|
|
6
8
|
value: string;
|
|
7
9
|
label: ReactNode;
|
|
8
10
|
icon?: IconName;
|
|
9
11
|
disabled?: boolean;
|
|
10
12
|
})[];
|
|
11
|
-
value?: string;
|
|
12
|
-
defaultValue?: string;
|
|
13
|
-
onChange?: (value: string) => void;
|
|
14
13
|
label?: string;
|
|
15
|
-
size?:
|
|
16
|
-
|
|
14
|
+
size?: ControlSize;
|
|
15
|
+
color?: SemanticColor;
|
|
16
|
+
variant?: Extract<AppearanceVariant, "solid" | "soft" | "outline">;
|
|
17
17
|
}
|
|
18
18
|
/** Exclusive options that apply immediately (Radix RadioGroup): one Tab stop, arrow keys move the selection and wrap. */
|
|
19
|
-
export declare
|
|
19
|
+
export declare const SegmentedControl: import("react").ForwardRefExoticComponent<SegmentedControlProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
3
4
|
import { RadioGroup as Primitive } from "radix-ui";
|
|
4
5
|
import { Icon } from "../Icon/Icon.js";
|
|
5
6
|
import { cx } from "../../lib/cx.js";
|
|
6
7
|
import { normalizeOptions } from "../../internal/options.js";
|
|
7
8
|
/** Exclusive options that apply immediately (Radix RadioGroup): one Tab stop, arrow keys move the selection and wrap. */
|
|
8
|
-
export function SegmentedControl({ options: optionsProp,
|
|
9
|
+
export const SegmentedControl = forwardRef(function SegmentedControl({ options: optionsProp, label, size, color = "primary", variant = "soft", className, ...rootProps }, ref) {
|
|
9
10
|
const options = normalizeOptions(optionsProp, (value) => ({ value, label: value }));
|
|
10
|
-
return (_jsx(Primitive.Root, { "aria-label": label, className: cx("vk-segmented",
|
|
11
|
-
}
|
|
11
|
+
return (_jsx(Primitive.Root, { ...rootProps, ref: ref, "aria-label": rootProps["aria-label"] ?? label, className: cx("vk-segmented", className), "data-vk-size": size, "data-vk-color": color, "data-vk-variant": variant, children: options.map((o) => (_jsxs(Primitive.Item, { value: o.value, disabled: o.disabled, className: "vk-segment", children: [o.icon ? _jsx(Icon, { name: o.icon, size: 16 }) : null, o.label] }, o.value))) }));
|
|
12
|
+
});
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef } from "react";
|
|
2
2
|
import { Select as Primitive } from "radix-ui";
|
|
3
|
+
import type { ControlSize } from "../../appearance.js";
|
|
3
4
|
import type { SelectOption } from "../../types.js";
|
|
4
5
|
type RootProps = ComponentPropsWithoutRef<typeof Primitive.Root>;
|
|
5
|
-
export interface SelectProps extends Omit<RootProps, "children"
|
|
6
|
+
export interface SelectProps extends Omit<RootProps, "children"> {
|
|
6
7
|
/** Non-empty string values, following Radix Select's item contract. */
|
|
7
8
|
options: (string | SelectOption)[];
|
|
8
9
|
/** Shown until an option is selected. */
|
|
9
10
|
placeholder?: string;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/** The initial selection for an uncontrolled select. */
|
|
13
|
-
defaultValue?: string;
|
|
14
|
-
/** Receives Radix's changed value and its matching option. */
|
|
15
|
-
onChange?: (value: string, option: SelectOption) => void;
|
|
16
|
-
/** xs for toolbars and status lines (24px with small type on fine pointers, 44px on touch); forms keep the control height. */
|
|
17
|
-
size?: 'xs';
|
|
11
|
+
/** Visual size shared with actions and other fields. */
|
|
12
|
+
size?: ControlSize;
|
|
18
13
|
id?: string;
|
|
19
14
|
className?: string;
|
|
20
15
|
"aria-label"?: string;
|