@vokality/design-system 5.1.1 → 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 +13 -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 +274 -130
- 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 +276 -130
- 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
|
@@ -8,14 +8,9 @@ import { normalizeOptions } from "../../internal/options.js";
|
|
|
8
8
|
import { useUid } from "../../internal/useUid.js";
|
|
9
9
|
import { cx } from "../../lib/cx.js";
|
|
10
10
|
/** Styled Radix Select. Radix owns state, form participation, focus, keys and dismissal. */
|
|
11
|
-
export const Select = forwardRef(function Select({ options: optionValues, placeholder,
|
|
11
|
+
export const Select = forwardRef(function Select({ options: optionValues, placeholder, size, id, className, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, ...rootProps }, ref) {
|
|
12
12
|
const { messages } = useLocale();
|
|
13
13
|
const options = normalizeOptions(optionValues);
|
|
14
14
|
const baseId = useUid("vk-select");
|
|
15
|
-
|
|
16
|
-
const option = options.find((candidate) => candidate.value === nextValue);
|
|
17
|
-
if (option)
|
|
18
|
-
onChange?.(option.value, option);
|
|
19
|
-
};
|
|
20
|
-
return (_jsx("div", { className: cx("vk-select", size === "xs" && "vk-select-xs", className), children: _jsxs(Primitive.Root, { ...rootProps, value: value === null ? "" : value, defaultValue: defaultValue, onValueChange: onValueChange, children: [_jsxs(Primitive.Trigger, { ref: ref, id: id, className: "vk-input vk-select-trigger", "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, children: [_jsx("span", { className: "vk-select-value", children: _jsx(Primitive.Value, { placeholder: placeholder ?? messages.selectOne }) }), _jsx(Primitive.Icon, { asChild: true, children: _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" }) })] }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { position: "popper", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, className: "vk-select-menu vk-select-content", "aria-label": ariaLabel, "aria-labelledby": labelledBy, children: _jsx(Primitive.Viewport, { className: "vk-select-viewport", children: options.map((option, index) => (_jsxs(Primitive.Item, { value: option.value, textValue: option.label, disabled: option.disabled, "data-index": index, "aria-describedby": option.description ? baseId + "-" + String(index) + "-desc" : undefined, className: "vk-select-option", children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx(Primitive.ItemText, { children: option.label }), option.description ? _jsx("span", { id: baseId + "-" + String(index) + "-desc", className: "vk-select-option-description", children: option.description }) : null] }), _jsx(Primitive.ItemIndicator, { asChild: true, children: _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) })] }, option.value))) }) }) })] }) }));
|
|
15
|
+
return (_jsx("div", { className: cx("vk-select", className), "data-vk-size": size, children: _jsxs(Primitive.Root, { ...rootProps, children: [_jsxs(Primitive.Trigger, { ref: ref, id: id, className: "vk-input vk-select-trigger", "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-invalid": invalid, children: [_jsx("span", { className: "vk-select-value", children: _jsx(Primitive.Value, { placeholder: placeholder ?? messages.selectOne }) }), _jsx(Primitive.Icon, { asChild: true, children: _jsx(Icon, { name: "chevron-down", className: "vk-select-icon" }) })] }), _jsx(Primitive.Portal, { children: _jsx(Primitive.Content, { position: "popper", side: "bottom", align: "start", sideOffset: 4, collisionPadding: 8, className: "vk-select-menu vk-select-content", "data-vk-size": size, "aria-label": ariaLabel, "aria-labelledby": labelledBy, children: _jsx(Primitive.Viewport, { className: "vk-select-viewport", children: options.map((option, index) => (_jsxs(Primitive.Item, { value: option.value, textValue: option.label, disabled: option.disabled, "data-index": index, "aria-describedby": option.description ? baseId + "-" + String(index) + "-desc" : undefined, className: "vk-select-option", children: [_jsxs("span", { className: "vk-select-option-text", children: [_jsx(Primitive.ItemText, { children: option.label }), option.description ? _jsx("span", { id: baseId + "-" + String(index) + "-desc", className: "vk-select-option-description", children: option.description }) : null] }), _jsx(Primitive.ItemIndicator, { asChild: true, children: _jsx(Icon, { name: "check", size: 16, className: "vk-select-check" }) })] }, option.value))) }) }) })] }) }));
|
|
21
16
|
});
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
step?: number;
|
|
8
|
-
format?: (value: number) => string;
|
|
9
|
-
valueText?: (value: number) => string;
|
|
10
|
-
showValue?: boolean;
|
|
1
|
+
import { type ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { Slider as Primitive } from "radix-ui";
|
|
3
|
+
type RootProps = Omit<ComponentPropsWithoutRef<typeof Primitive.Root>, "children" | "asChild" | "value">;
|
|
4
|
+
type ThumbProps = Omit<ComponentPropsWithoutRef<typeof Primitive.Thumb>, "children" | "asChild">;
|
|
5
|
+
interface SliderPresentationProps {
|
|
6
|
+
/** Show the native minimum and maximum below the track. */
|
|
11
7
|
showLimits?: boolean;
|
|
12
|
-
name
|
|
13
|
-
|
|
14
|
-
id?: string;
|
|
15
|
-
className?: string;
|
|
16
|
-
'aria-label'?: string;
|
|
17
|
-
'aria-labelledby'?: string;
|
|
18
|
-
'aria-describedby'?: string;
|
|
8
|
+
/** Native props for each generated thumb, including its accessible name and value text. */
|
|
9
|
+
thumbProps?: (index: number) => ThumbProps;
|
|
19
10
|
}
|
|
20
|
-
/**
|
|
21
|
-
export
|
|
11
|
+
/** Dynamic formatted output uses caller-controlled native values; Radix owns all interaction. */
|
|
12
|
+
export type SliderProps = RootProps & SliderPresentationProps & ({
|
|
13
|
+
value: number[];
|
|
14
|
+
/** Format each controlled value for the optional visual output. */
|
|
15
|
+
format?: (value: number, index: number) => string;
|
|
16
|
+
/** Accessible value text for each controlled thumb. */
|
|
17
|
+
valueText?: (value: number, index: number) => string;
|
|
18
|
+
/** Display the controlled values next to the track. */
|
|
19
|
+
showValue?: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
value?: undefined;
|
|
22
|
+
format?: never;
|
|
23
|
+
valueText?: never;
|
|
24
|
+
showValue?: false;
|
|
25
|
+
});
|
|
26
|
+
/** Styled Radix Slider with its native number-array value and commit callbacks. */
|
|
27
|
+
export declare const Slider: import("react").ForwardRefExoticComponent<SliderProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
28
|
+
export {};
|
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { forwardRef, useState } from "react";
|
|
4
4
|
import { Slider as Primitive } from "radix-ui";
|
|
5
5
|
import { useUid } from "../../internal/useUid.js";
|
|
6
6
|
import { cx } from "../../lib/cx.js";
|
|
7
|
-
/**
|
|
8
|
-
export function Slider(
|
|
9
|
-
const min = props.min ?? 0, max = props.max ?? 100, step = props.step ?? 1;
|
|
10
|
-
// Radix owns the value; this mirror supplies only the optional output and formatted value text.
|
|
11
|
-
const [displayValue, setDisplayValue] = useState(props.defaultValue ?? min);
|
|
12
|
-
const value = props.value ?? displayValue;
|
|
7
|
+
/** Styled Radix Slider with its native number-array value and commit callbacks. */
|
|
8
|
+
export const Slider = forwardRef(function Slider({ value, defaultValue, min = 0, max = 100, format, valueText, showValue, showLimits, thumbProps, id: idProp, className, orientation, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, ...rootProps }, ref) {
|
|
13
9
|
const uid = useUid("vk-slider");
|
|
14
|
-
const id =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// The ends of the range under the track; visual only, the thumb announces its range.
|
|
10
|
+
const id = idProp || uid;
|
|
11
|
+
// Radix ignores later defaultValue changes; preserve the original uncontrolled anatomy too.
|
|
12
|
+
const [uncontrolledThumbCount] = useState(() => defaultValue?.length ?? 1);
|
|
13
|
+
const thumbCount = value?.length ?? uncontrolledThumbCount;
|
|
14
|
+
const thumbs = Array.from({ length: thumbCount }, (_, index) => {
|
|
15
|
+
const props = thumbProps?.(index);
|
|
16
|
+
const current = value?.[index];
|
|
17
|
+
return {
|
|
18
|
+
id: props?.id ?? id + "-thumb-" + String(index),
|
|
19
|
+
props,
|
|
20
|
+
text: current === undefined ? undefined : valueText ? valueText(current, index) : format?.(current, index),
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
return (_jsxs("div", { className: "vk-slider", "data-orientation": orientation, children: [showValue ? _jsx("output", { className: "vk-slider-value", htmlFor: thumbs.map((thumb) => thumb.id).join(" "), children: value.map((current, index) => format ? format(current, index) : String(current)).join(" – ") }) : null, _jsxs(Primitive.Root, { ...rootProps, ref: ref, id: id, className: cx("vk-slider-track", className), min: min, max: max, value: value, defaultValue: defaultValue, orientation: orientation, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, children: [_jsx(Primitive.Range, { className: "vk-slider-fill" }), thumbs.map((thumb) => (_jsx(Primitive.Thumb, { id: thumb.id, "aria-label": ariaLabel, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-valuetext": thumb.text, ...thumb.props, className: cx("vk-slider-thumb", thumb.props?.className) }, thumb.id)))] }), showLimits ? _jsx(SliderLimits, { min: min, max: max, format: format }) : null] }));
|
|
24
|
+
});
|
|
25
|
+
/** The limits are visual; Radix announces each thumb's native range. */
|
|
31
26
|
function SliderLimits({ min, max, format }) {
|
|
32
|
-
return (_jsxs("div", { className: "vk-slider-limits", "aria-hidden": "true", children: [_jsx("span", { children: format ? format(min) : min }), _jsx("span", { children: format ? format(max) : max })] }));
|
|
27
|
+
return (_jsxs("div", { className: "vk-slider-limits", "aria-hidden": "true", children: [_jsx("span", { children: format ? format(min, 0) : min }), _jsx("span", { children: format ? format(max, 1) : max })] }));
|
|
33
28
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SemanticColor } from "../../appearance.js";
|
|
2
2
|
export interface SparklineProps {
|
|
3
3
|
values: number[];
|
|
4
4
|
width?: number;
|
|
5
5
|
height?: number;
|
|
6
|
-
|
|
6
|
+
color?: SemanticColor;
|
|
7
7
|
label?: string;
|
|
8
8
|
className?: string;
|
|
9
9
|
}
|
|
@@ -6,7 +6,7 @@ import { cx } from "../../lib/cx.js";
|
|
|
6
6
|
/** A word-sized trend line beside a number, in a table cell or a Stat. */
|
|
7
7
|
export function Sparkline(props) {
|
|
8
8
|
const { locale, messages } = useLocale();
|
|
9
|
-
const { width, height,
|
|
9
|
+
const { width, height, color, label, className } = props;
|
|
10
10
|
const values = props.values;
|
|
11
11
|
const w = width || 96, hgt = height || 28, p = 3;
|
|
12
12
|
const min = Math.min(...values), max = Math.max(...values);
|
|
@@ -15,6 +15,6 @@ export function Sparkline(props) {
|
|
|
15
15
|
const pts = values.map((v, i) => pt(v, i).join(",")).join(" ");
|
|
16
16
|
const last = values.at(-1);
|
|
17
17
|
const end = last === undefined ? null : pt(last, values.length - 1);
|
|
18
|
-
const
|
|
19
|
-
return (_jsxs("svg", { className: cx("vk-sparkline", className), width: w, height: hgt, viewBox: `0 0 ${String(w)} ${String(hgt)}`, role: "img", "aria-label": label || messages.trend(values.map((value) => formatNumber(value, { locale })).join(", ")), children: [_jsx("polyline", { points: pts, fill: "none", stroke:
|
|
18
|
+
const stroke = color ? "var(--vk-color-fg)" : "var(--chart-1)";
|
|
19
|
+
return (_jsxs("svg", { "data-vk-color": color, className: cx("vk-sparkline", className), width: w, height: hgt, viewBox: `0 0 ${String(w)} ${String(hgt)}`, role: "img", "aria-label": label || messages.trend(values.map((value) => formatNumber(value, { locale })).join(", ")), children: [_jsx("polyline", { points: pts, fill: "none", stroke: stroke, strokeWidth: 1.5, strokeLinejoin: "round", strokeLinecap: "round" }), end ? _jsx("circle", { cx: end[0], cy: end[1], r: 2.5, fill: stroke }) : null] }));
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
-
import type { ElementTag, PolymorphicProps } from "../../types.js";
|
|
2
|
+
import type { ElementTag, PolymorphicProps, SpaceStep } from "../../types.js";
|
|
3
3
|
export interface StackOwnProps {
|
|
4
|
-
gap?:
|
|
4
|
+
gap?: SpaceStep;
|
|
5
5
|
align?: CSSProperties['alignItems'];
|
|
6
6
|
children?: ReactNode;
|
|
7
7
|
className?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ComponentPropsWithoutRef } from "react";
|
|
2
2
|
import { Switch as Primitive } from "radix-ui";
|
|
3
3
|
import { type ChoiceTextProps } from "../../internal/choice.js";
|
|
4
|
-
export interface SwitchProps extends Omit<ComponentPropsWithoutRef<typeof Primitive.Root>, "asChild" | "children" | "onChange">, ChoiceTextProps {
|
|
4
|
+
export interface SwitchProps extends Omit<ComponentPropsWithoutRef<typeof Primitive.Root>, "asChild" | "children" | "onChange" | "color">, ChoiceTextProps {
|
|
5
5
|
}
|
|
6
6
|
/** Styled Radix Switch; onCheckedChange receives the boolean state and DOM events target its button. */
|
|
7
7
|
export declare const Switch: import("react").ForwardRefExoticComponent<SwitchProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -5,6 +5,6 @@ import { Switch as Primitive } from "radix-ui";
|
|
|
5
5
|
import { ChoiceLabel, hiddenLabel } from "../../internal/choice.js";
|
|
6
6
|
import { omit } from "../../lib/omit.js";
|
|
7
7
|
/** Styled Radix Switch; onCheckedChange receives the boolean state and DOM events target its button. */
|
|
8
|
-
export const Switch = forwardRef(function Switch({ label, description, hideLabel, className, ...props }, ref) {
|
|
9
|
-
return (_jsx(ChoiceLabel, { kind: "vk-switch", label: label, description: description, hideLabel: hideLabel, disabled: props.disabled, className: className, children: _jsx(Primitive.Root, { ...omit(props, ["data-state"]), ref: ref, "aria-label": props["aria-label"] || hiddenLabel({ label, hideLabel }), className: "vk-switch-track", children: _jsx(Primitive.Thumb, { className: "vk-switch-thumb" }) }) }));
|
|
8
|
+
export const Switch = forwardRef(function Switch({ label, description, hideLabel, className, size, color, ...props }, ref) {
|
|
9
|
+
return (_jsx(ChoiceLabel, { size: size, color: color, kind: "vk-switch", label: label, description: description, hideLabel: hideLabel, disabled: props.disabled, className: className, children: _jsx(Primitive.Root, { ...omit(props, ["data-state"]), ref: ref, "aria-label": props["aria-label"] || hiddenLabel({ label, hideLabel }), className: "vk-switch-track", children: _jsx(Primitive.Thumb, { className: "vk-switch-thumb" }) }) }));
|
|
10
10
|
});
|
|
@@ -87,7 +87,7 @@ function TableCells({ row: r, columns, rowHeader }) {
|
|
|
87
87
|
/** The cell with the button that shows or hides a row's details. */
|
|
88
88
|
function RowToggleCell({ rowKey: k, name, isOpen, onToggle }) {
|
|
89
89
|
const { messages } = useLocale();
|
|
90
|
-
return (_jsx("td", { className: "vk-td-select", children: _jsx("button", { type: "button",
|
|
90
|
+
return (_jsx("td", { className: "vk-td-select", children: _jsx("button", { type: "button", "data-vk-color": "primary", "data-vk-variant": "ghost", className: "vk-icon-btn vk-row-toggle", "aria-expanded": isOpen ? "true" : "false", "aria-controls": "vk-row-" + String(k), "aria-label": isOpen ? messages.hideDetails(name) : messages.showDetails(name), onClick: onToggle, children: _jsx(Icon, { name: "chevron-right", size: 14, className: cx("vk-tree-caret", isOpen && "vk-tree-caret-open") }) }) }));
|
|
91
91
|
}
|
|
92
92
|
/** One record: its details toggle and checkbox, its cells, and its details row when open. */
|
|
93
93
|
function TableRow({ row: r, index: i, rowKey: k, columns, colCount, selectable, isSel, isOpen, rowLabel, rowHeader, renderExpanded, onToggleSelect, onToggleOpen }) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactNode } from "react";
|
|
2
|
+
import { Tabs as Primitive } from "radix-ui";
|
|
3
|
+
/** Styled Radix tabs with typed content and count composition. */
|
|
4
|
+
export interface TabsProps extends Omit<ComponentPropsWithoutRef<typeof Primitive.Root>, "children" | "asChild"> {
|
|
5
|
+
/** Labels and panel content, keyed by each native tab value. */
|
|
4
6
|
tabs: {
|
|
5
7
|
id: string;
|
|
6
8
|
label: ReactNode;
|
|
@@ -8,12 +10,12 @@ export interface TabsProps {
|
|
|
8
10
|
count?: number | string;
|
|
9
11
|
disabled?: boolean;
|
|
10
12
|
}[];
|
|
11
|
-
|
|
12
|
-
defaultValue?: string;
|
|
13
|
-
onChange?: (id: string) => void;
|
|
13
|
+
/** Accessible name for the tab list. */
|
|
14
14
|
label?: string;
|
|
15
|
+
/** Preserve inactive panels using Radix Content.forceMount. */
|
|
15
16
|
keepMounted?: boolean;
|
|
16
|
-
|
|
17
|
+
/** Native Radix list attributes, including loop and its accessible name. */
|
|
18
|
+
listProps?: Omit<ComponentPropsWithoutRef<typeof Primitive.List>, "children" | "asChild">;
|
|
17
19
|
}
|
|
18
|
-
/**
|
|
19
|
-
export declare
|
|
20
|
+
/** Radix owns selection, activation, directional navigation and panel presence. */
|
|
21
|
+
export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,9 +1,9 @@
|
|
|
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 { Tabs as Primitive } from "radix-ui";
|
|
4
5
|
import { cx } from "../../lib/cx.js";
|
|
5
|
-
/**
|
|
6
|
-
export function Tabs({ tabs
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
6
|
+
/** Radix owns selection, activation, directional navigation and panel presence. */
|
|
7
|
+
export const Tabs = forwardRef(function Tabs({ tabs, label, keepMounted, listProps, className, ...rootProps }, ref) {
|
|
8
|
+
return (_jsxs(Primitive.Root, { ...rootProps, ref: ref, className: cx("vk-tabs", className), children: [_jsx(Primitive.List, { loop: true, "aria-label": label, ...listProps, className: cx("vk-tablist", listProps?.className), children: tabs.map((t) => (_jsxs(Primitive.Trigger, { value: t.id, disabled: t.disabled, className: "vk-tab", "data-tab": t.id, children: [t.label, t.count != null ? _jsx("span", { className: "vk-tab-count", children: t.count }) : null] }, t.id))) }), tabs.map((t) => (_jsx(Primitive.Content, { value: t.id, forceMount: keepMounted ? true : undefined, className: "vk-tabpanel", children: t.content }, t.id)))] }));
|
|
9
|
+
});
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { ElementTag, PolymorphicProps } from "../../types.js";
|
|
3
|
+
import type { SemanticColor } from "../../appearance.js";
|
|
4
|
+
import type { TextEmphasis, TextStyle } from "../../typography.js";
|
|
3
5
|
export interface TextOwnProps {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
/** A named typography recipe from the design tokens. */
|
|
7
|
+
size?: TextStyle;
|
|
8
|
+
/** Semantic foreground palette. */
|
|
9
|
+
color?: SemanticColor;
|
|
10
|
+
/** Neutral foreground hierarchy; semantic colors keep their named foreground. */
|
|
11
|
+
emphasis?: TextEmphasis;
|
|
6
12
|
children?: ReactNode;
|
|
7
13
|
className?: string;
|
|
8
14
|
/** Space Grotesk with tabular figures for numbers, codes and identifiers. */
|
|
@@ -15,7 +21,8 @@ export interface TextOwnProps {
|
|
|
15
21
|
weight?: "regular" | "medium" | "semibold" | "bold";
|
|
16
22
|
}
|
|
17
23
|
export type TextProps<T extends ElementTag = "p"> = PolymorphicProps<T, TextOwnProps>;
|
|
18
|
-
/** Running text in
|
|
19
|
-
export declare function Text<T extends ElementTag = "p">({ as, size,
|
|
24
|
+
/** Running text in a named typography recipe and semantic foreground. */
|
|
25
|
+
export declare function Text<T extends ElementTag = "p">({ as, size, color, emphasis, numeric, overflowWrap, truncate, weight, children, className, ...rest }: TextProps<T>): import("react").ReactElement<Omit<TextProps<T>, "numeric" | "size" | "truncate" | "color" | "overflowWrap" | "className" | "children" | "weight" | "as" | "emphasis"> & {
|
|
26
|
+
"data-vk-color": SemanticColor | undefined;
|
|
20
27
|
className: string;
|
|
21
|
-
}
|
|
28
|
+
}, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
2
|
import { cx } from "../../lib/cx.js";
|
|
3
|
-
/** Running text in
|
|
4
|
-
export function Text({ as, size,
|
|
5
|
-
return createElement(as || "p", { className: cx("vk-text", "vk-text-" + (size || "body"),
|
|
3
|
+
/** Running text in a named typography recipe and semantic foreground. */
|
|
4
|
+
export function Text({ as, size, color, emphasis, numeric, overflowWrap, truncate, weight, children, className, ...rest }) {
|
|
5
|
+
return createElement(as || "p", { ...rest, "data-vk-color": color, className: cx("vk-text", "vk-text-" + (size || "body"), emphasis && "vk-emphasis-" + emphasis, numeric && "vk-text-numeric", overflowWrap === "anywhere" && "vk-text-wrap-anywhere", truncate && "vk-text-truncate", weight && "vk-weight-" + weight, className) }, children);
|
|
6
6
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type TextareaHTMLAttributes } from "react";
|
|
2
|
+
import type { ControlSize } from "../../appearance.js";
|
|
2
3
|
export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
|
4
|
+
size?: ControlSize;
|
|
3
5
|
showCount?: boolean;
|
|
4
6
|
}
|
|
5
7
|
/** Multi-line text control (5 rows, vertical resize). The ref is the <textarea>. */
|
|
@@ -9,9 +9,9 @@ export const Textarea = forwardRef(function Textarea(props, ref) {
|
|
|
9
9
|
const txt = useControlledText(props);
|
|
10
10
|
// The counter's limit; 0 when there is no counter (the native maxLength applies instead).
|
|
11
11
|
const countMax = props.showCount && props.maxLength ? props.maxLength : 0;
|
|
12
|
-
const rest = omit(props, ["className", "showCount", "value", "defaultValue", "onChange"]);
|
|
13
|
-
const area = (_jsx("textarea", { rows: 5, ref: ref, ...rest, value: txt.value, onChange: txt.onChange, maxLength: countMax ? undefined : props.maxLength, className: cx("vk-input", "vk-textarea", countMax ? null : props.className) }));
|
|
12
|
+
const rest = omit(props, ["size", "className", "showCount", "value", "defaultValue", "onChange"]);
|
|
13
|
+
const area = (_jsx("textarea", { rows: 5, ref: ref, ...rest, "data-vk-size": props.size, value: txt.value, onChange: txt.onChange, maxLength: countMax ? undefined : props.maxLength, className: cx("vk-input", "vk-textarea", countMax ? null : props.className) }));
|
|
14
14
|
if (!countMax)
|
|
15
15
|
return area;
|
|
16
|
-
return (_jsxs("span", { className: cx("vk-affix", props.className), children: [area, _jsx(CharCount, { value: txt.value, max: countMax })] }));
|
|
16
|
+
return (_jsxs("span", { className: cx("vk-affix", props.className), "data-vk-size": props.size, children: [area, _jsx(CharCount, { value: txt.value, max: countMax })] }));
|
|
17
17
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { ControlSize } from "../../appearance.js";
|
|
1
2
|
/** "HH:MM", 24-hour. */
|
|
2
3
|
export type TimeValue = string;
|
|
3
4
|
export interface TimePickerProps {
|
|
5
|
+
size?: ControlSize;
|
|
4
6
|
value?: TimeValue | null;
|
|
5
7
|
defaultValue?: TimeValue;
|
|
6
8
|
onChange?: (value: TimeValue | null) => void;
|
|
@@ -69,7 +69,7 @@ function InvalidTime({ id, message, locale }) {
|
|
|
69
69
|
return _jsx("span", { id: id, className: "vk-field-error vk-inline-error", children: message || messages.invalidTime(formatTime("14:30", locale)) });
|
|
70
70
|
}
|
|
71
71
|
/** The portalled list of times. */
|
|
72
|
-
function TimeList({ listId, label, times, value, open, active, setActive, onPick, rootRef, escapedRef }) {
|
|
72
|
+
function TimeList({ size, listId, label, times, value, open, active, setActive, onPick, rootRef, escapedRef }) {
|
|
73
73
|
// The list mounts a render after `open` turns true (it is portalled): keep it in state so scrolling waits for it.
|
|
74
74
|
const listRef = useRef(null);
|
|
75
75
|
const [shown, setShown] = useState(false);
|
|
@@ -96,7 +96,7 @@ function TimeList({ listId, label, times, value, open, active, setActive, onPick
|
|
|
96
96
|
// Pressing the field keeps the list open.
|
|
97
97
|
if (e.target instanceof Node && rootRef.current && rootRef.current.contains(e.target))
|
|
98
98
|
e.preventDefault();
|
|
99
|
-
}, children: _jsx("ul", { ref: setList, id: listId, role: "listbox", "aria-label": label, className: "vk-select-menu vk-time-menu",
|
|
99
|
+
}, children: _jsx("ul", { ref: setList, id: listId, role: "listbox", "aria-label": label, className: "vk-select-menu vk-time-menu", "data-vk-size": size,
|
|
100
100
|
// Keep focus (and the typed text) in the input when pressing the list.
|
|
101
101
|
onMouseDown: (e) => { e.preventDefault(); }, children: times.map((t, i) => (_jsxs("li", { id: listId + "-" + String(i), "data-index": i, role: "option", "aria-selected": t.value === value ? "true" : "false", className: cx("vk-select-option", i === active && "vk-select-option-active"), onMouseMove: () => {
|
|
102
102
|
if (i !== active)
|
|
@@ -181,8 +181,8 @@ export const TimePicker = forwardRef(function TimePicker(props, ref) {
|
|
|
181
181
|
escapedRef.current = false;
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
const a11y = omit(props, ["value", "defaultValue", "onChange", "step", "min", "max", "locale", "id", "name", "placeholder", "defaultOpen", "className", "disabled", "invalidMessage"]);
|
|
185
|
-
return (_jsx(Primitive.Root, { open: open, onOpenChange: setOpen, children: _jsxs("div", { ref: rootRef, className: cx("vk-select", "vk-timepicker", props.className), "data-state": open ? "open" : "closed", children: [_jsx(Primitive.Anchor, { asChild: true, children: _jsxs("div", { className: "vk-combobox-field", children: [_jsx("input", { ref: setInputRef, id: props.id || uid, type: "text", role: "combobox", autoComplete: "off", className: "vk-input vk-combobox-input", placeholder: props.placeholder || formatTime("09:30", locale), disabled: props.disabled, value: text, "aria-autocomplete": "none", "aria-expanded": open ? "true" : "false", "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? listId + "-" + String(active) : undefined,
|
|
184
|
+
const a11y = omit(props, ["size", "value", "defaultValue", "onChange", "step", "min", "max", "locale", "id", "name", "placeholder", "defaultOpen", "className", "disabled", "invalidMessage"]);
|
|
185
|
+
return (_jsx(Primitive.Root, { open: open, onOpenChange: setOpen, children: _jsxs("div", { ref: rootRef, "data-vk-size": props.size, className: cx("vk-select", "vk-timepicker", props.className), "data-state": open ? "open" : "closed", children: [_jsx(Primitive.Anchor, { asChild: true, children: _jsxs("div", { className: "vk-combobox-field", children: [_jsx("input", { ref: setInputRef, id: props.id || uid, type: "text", role: "combobox", autoComplete: "off", className: "vk-input vk-combobox-input", placeholder: props.placeholder || formatTime("09:30", locale), disabled: props.disabled, value: text, "aria-autocomplete": "none", "aria-expanded": open ? "true" : "false", "aria-controls": listId, "aria-activedescendant": open && active >= 0 ? listId + "-" + String(active) : undefined,
|
|
186
186
|
// Typing drops the highlighted option, so Enter keeps the typed time rather than the list's.
|
|
187
187
|
onChange: (e) => { type(e.target.value); setActive(-1); }, onClick: () => {
|
|
188
188
|
if (!open)
|
|
@@ -192,5 +192,5 @@ export const TimePicker = forwardRef(function TimePicker(props, ref) {
|
|
|
192
192
|
setOpen(false);
|
|
193
193
|
commitText();
|
|
194
194
|
}
|
|
195
|
-
}, ...a11y, ...invalidAria(invalid, props, uid + "-err") }), _jsx(Icon, { name: "clock", size: 16, className: "vk-select-icon" })] }) }), _jsx(TimeList, { listId: listId, label: props["aria-label"] || messages.times, times: times, value: value, open: open, active: active, setActive: setActive, onPick: pick, rootRef: rootRef, escapedRef: escapedRef }), invalid ? _jsx(InvalidTime, { id: uid + "-err", message: props.invalidMessage, locale: locale }) : null, props.name ? _jsx("input", { type: "hidden", name: props.name, value: value || "" }) : null] }) }));
|
|
195
|
+
}, ...a11y, ...invalidAria(invalid, props, uid + "-err") }), _jsx(Icon, { name: "clock", size: 16, className: "vk-select-icon" })] }) }), _jsx(TimeList, { size: props.size, listId: listId, label: props["aria-label"] || messages.times, times: times, value: value, open: open, active: active, setActive: setActive, onPick: pick, rootRef: rootRef, escapedRef: escapedRef }), invalid ? _jsx(InvalidTime, { id: uid + "-err", message: props.invalidMessage, locale: locale }) : null, props.name ? _jsx("input", { type: "hidden", name: props.name, value: value || "" }) : null] }) }));
|
|
196
196
|
});
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ComponentPropsWithoutRef, type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import { Tooltip as Primitive } from "radix-ui";
|
|
3
|
-
export interface TooltipProps extends
|
|
3
|
+
export interface TooltipProps extends Omit<Primitive.TooltipProps, "children"> {
|
|
4
|
+
/** Short description rendered in the native tooltip content. */
|
|
4
5
|
content: ReactNode;
|
|
6
|
+
/** Focusable trigger element; custom components forward their native ref. */
|
|
5
7
|
children: ReactElement;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
/** Preferred native Radix content side. */
|
|
9
|
+
side?: Primitive.TooltipContentProps["side"];
|
|
10
|
+
/** Native Radix content alignment. */
|
|
11
|
+
align?: Primitive.TooltipContentProps["align"];
|
|
12
|
+
/** Native content attributes, positioning and dismissal callbacks. */
|
|
13
|
+
contentProps?: Omit<ComponentPropsWithoutRef<typeof Primitive.Content>, "children" | "asChild" | "side" | "align">;
|
|
9
14
|
}
|
|
10
15
|
/** Text label with Radix Tooltip's native hover, focus and dismissal behavior. */
|
|
11
|
-
export declare
|
|
16
|
+
export declare const Tooltip: import("react").ForwardRefExoticComponent<TooltipProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1,7 +1,9 @@
|
|
|
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 { Tooltip as Primitive } from "radix-ui";
|
|
5
|
+
import { cx } from "../../lib/cx.js";
|
|
4
6
|
/** Text label with Radix Tooltip's native hover, focus and dismissal behavior. */
|
|
5
|
-
export function Tooltip({ content, children,
|
|
6
|
-
return (_jsx(Primitive.Provider, {
|
|
7
|
-
}
|
|
7
|
+
export const Tooltip = forwardRef(function Tooltip({ content, children, side = "top", align = "center", delayDuration = 400, contentProps, ...rootProps }, ref) {
|
|
8
|
+
return (_jsx(Primitive.Provider, { children: _jsxs(Primitive.Root, { ...rootProps, delayDuration: delayDuration, children: [_jsx(Primitive.Trigger, { asChild: true, children: children }), _jsx(Primitive.Portal, { forceMount: contentProps?.forceMount, children: _jsx(Primitive.Content, { sideOffset: 6, collisionPadding: 8, ...contentProps, ref: ref, className: cx("vk-tooltip", contentProps?.className), side: side, align: align, children: content }) })] }) }));
|
|
9
|
+
});
|