@snap-rail/ui 0.1.1 → 0.2.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/lib/charts.js +5 -4
- package/lib/contract.js +118 -61
- package/lib/fallback.js +11 -0
- package/lib/index.js +3948 -154
- package/lib/runtime.js +151 -28
- package/lib/settings.js +67 -23
- package/lib/types/charts.d.ts +1 -1
- package/lib/types/charts.js +5 -5
- package/lib/types/components/alert.d.ts +57 -0
- package/lib/types/components/alert.js +46 -0
- package/lib/types/components/controls.d.ts +74 -11
- package/lib/types/components/controls.js +60 -17
- package/lib/types/components/form-rhf.d.ts +56 -0
- package/lib/types/components/form-rhf.js +74 -0
- package/lib/types/components/form.d.ts +33 -5
- package/lib/types/components/form.js +22 -6
- package/lib/types/components/index.d.ts +7 -0
- package/lib/types/components/index.js +7 -0
- package/lib/types/components/input.d.ts +11 -5
- package/lib/types/components/input.js +34 -7
- package/lib/types/components/layout.d.ts +28 -6
- package/lib/types/components/layout.js +86 -13
- package/lib/types/components/overlay.d.ts +95 -0
- package/lib/types/components/overlay.js +138 -0
- package/lib/types/components/schema-form.d.ts +3 -1
- package/lib/types/components/schema-form.js +46 -40
- package/lib/types/components/slider.d.ts +18 -0
- package/lib/types/components/slider.js +15 -0
- package/lib/types/contract.d.ts +49 -29
- package/lib/types/contract.js +49 -29
- package/lib/types/runtime.js +3 -2
- package/lib/types/settings-pages/appearance.js +2 -2
- package/lib/types/settings-pages/plugins.js +2 -2
- package/package.json +13 -6
- package/src/styles/base.css +243 -5
- package/src/styles/default.css +184 -6
|
@@ -1,18 +1,45 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Text-entry semantics: the wrapper owns the anatomy (prefix/suffix/clear),
|
|
4
|
+
* the native field keeps keyboard and IME behaviour. Skins style the parts.
|
|
5
|
+
*
|
|
6
|
+
* @module @snap-rail/ui/components/input
|
|
7
|
+
*/
|
|
8
|
+
import { useRef } from 'react';
|
|
2
9
|
import { cn, part } from "../utils.js";
|
|
3
10
|
/** A single-line text field with semantic prefix/suffix slots. Layout
|
|
4
11
|
* `style`/`className` dress the wrapper — the visible control; the native
|
|
5
12
|
* field already stretches inside it. */
|
|
6
|
-
export function Input({ size = 'md', invalid = false, prefix, suffix, onClear, componentName = 'input', className, style, disabled, ...props }) {
|
|
7
|
-
return (_jsxs("div", { ...part(componentName, 'root'), className: cn('snap-input', className), style: style, "data-size": size, "data-invalid": invalid || undefined, "data-disabled": disabled === true || undefined, children: [prefix !== undefined && _jsx("span", { ...part(componentName, 'prefix'), children: prefix }), _jsx("input", { ...part(componentName, 'field'), className:
|
|
13
|
+
export function Input({ size = 'md', invalid = false, prefix, suffix, onClear, fieldClassName, componentName = 'input', className, style, disabled, ...props }) {
|
|
14
|
+
return (_jsxs("div", { ...part(componentName, 'root'), className: cn('snap-input', className), style: style, "data-size": size, "data-invalid": invalid || undefined, "data-disabled": disabled === true || undefined, children: [prefix !== undefined && _jsx("span", { ...part(componentName, 'prefix'), children: prefix }), _jsx("input", { ...part(componentName, 'field'), className: cn('snap-input-field', fieldClassName), disabled: disabled, "aria-invalid": invalid || undefined, ...props }), onClear !== undefined && typeof props.value === 'string' && props.value !== '' && (_jsx("button", { ...part(componentName, 'clear'), type: "button", className: "snap-input-clear", "aria-label": "\u6E05\u9664", onClick: onClear, children: "\u00D7" })), suffix !== undefined && _jsx("span", { ...part(componentName, 'suffix'), children: suffix })] }));
|
|
8
15
|
}
|
|
9
16
|
/** A multi-line text field. Like {@link Input}, layout `style`/`className`
|
|
10
17
|
* dress the wrapper; the field stretches inside it. */
|
|
11
|
-
export function Textarea({ size = 'md', invalid = false, className, style, disabled, ...props }) {
|
|
12
|
-
return (_jsx("div", { ...part('textarea', 'root'), className: cn('snap-textarea', className), style: style, "data-size": size, "data-invalid": invalid || undefined, "data-disabled": disabled === true || undefined, children: _jsx("textarea", { ...part('textarea', 'field'), className:
|
|
18
|
+
export function Textarea({ size = 'md', invalid = false, fieldClassName, className, style, disabled, ...props }) {
|
|
19
|
+
return (_jsx("div", { ...part('textarea', 'root'), className: cn('snap-textarea', className), style: style, "data-size": size, "data-invalid": invalid || undefined, "data-disabled": disabled === true || undefined, children: _jsx("textarea", { ...part('textarea', 'field'), className: cn('snap-textarea-field', fieldClassName), disabled: disabled, "aria-invalid": invalid || undefined, ...props }) }));
|
|
13
20
|
}
|
|
14
|
-
/** A numeric field with
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
/** A numeric field with touch steppers: `step-up`/`step-down` commit through
|
|
22
|
+
* the normal `onChange` (a native input event on the field), clamped to
|
|
23
|
+
* `min`/`max`. */
|
|
24
|
+
export function NumberInput({ min, max, step = 1, size = 'md', invalid = false, fieldClassName, className, style, disabled, value, onChange, ...props }) {
|
|
25
|
+
const fieldRef = useRef(null);
|
|
26
|
+
const current = typeof value === 'number' ? value : undefined;
|
|
27
|
+
const stepBy = (delta) => {
|
|
28
|
+
const field = fieldRef.current;
|
|
29
|
+
if (field === null || disabled === true)
|
|
30
|
+
return;
|
|
31
|
+
const parsed = typeof value === 'number' ? value : Number(field.value);
|
|
32
|
+
let next = (Number.isFinite(parsed) ? parsed : (min ?? 0)) + delta * step;
|
|
33
|
+
if (min !== undefined && next < min)
|
|
34
|
+
next = min;
|
|
35
|
+
if (max !== undefined && next > max)
|
|
36
|
+
next = max;
|
|
37
|
+
// Commit through the native setter + input event so controlled consumers
|
|
38
|
+
// observe a regular change event on the field itself.
|
|
39
|
+
const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set;
|
|
40
|
+
setter?.call(field, String(next));
|
|
41
|
+
field.dispatchEvent(new Event('input', { bubbles: true }));
|
|
42
|
+
};
|
|
43
|
+
return (_jsxs("div", { ...part('number-input', 'root'), className: cn('snap-input', 'snap-number-input', className), style: style, "data-size": size, "data-invalid": invalid || undefined, "data-disabled": disabled === true || undefined, children: [_jsx("input", { ref: fieldRef, ...part('number-input', 'field'), className: cn('snap-input-field', fieldClassName), type: "number", inputMode: "decimal", disabled: disabled, "aria-invalid": invalid || undefined, value: value, onChange: onChange, ...min !== undefined ? { min } : {}, ...max !== undefined ? { max } : {}, ...step !== undefined ? { step } : {}, ...props }), _jsxs("span", { className: "snap-number-input-steps", children: [_jsx("button", { ...part('number-input', 'step-up'), type: "button", tabIndex: -1, className: "snap-number-input-step", "aria-label": "\u589E\u5927", disabled: disabled === true || (current !== undefined && max !== undefined && current >= max), onClick: () => stepBy(1), children: "\uFF0B" }), _jsx("button", { ...part('number-input', 'step-down'), type: "button", tabIndex: -1, className: "snap-number-input-step", "aria-label": "\u51CF\u5C0F", disabled: disabled === true || (current !== undefined && min !== undefined && current <= min), onClick: () => stepBy(-1), children: "\uFF0D" })] })] }));
|
|
17
44
|
}
|
|
18
45
|
//# sourceMappingURL=input.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module @snap-rail/ui/components/layout
|
|
7
7
|
*/
|
|
8
|
-
import type
|
|
8
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
|
9
9
|
/** A spacing token. */
|
|
10
10
|
export type SpaceToken = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
11
11
|
/** Shared layout props. */
|
|
@@ -85,19 +85,41 @@ export interface ToolbarProps extends LayoutProps {
|
|
|
85
85
|
start?: ReactNode;
|
|
86
86
|
end?: ReactNode;
|
|
87
87
|
}
|
|
88
|
-
/** A compact action bar. */
|
|
89
|
-
export declare function Toolbar({ start, end, className, style }: ToolbarProps): ReactNode;
|
|
88
|
+
/** A compact action bar; `children` renders between the start and end groups. */
|
|
89
|
+
export declare function Toolbar({ start, end, children, className, style }: ToolbarProps): ReactNode;
|
|
90
90
|
/** Props of {@link ScrollArea}. */
|
|
91
91
|
export interface ScrollAreaProps extends LayoutProps {
|
|
92
92
|
/** `vertical`, `horizontal`, or `both`. */
|
|
93
93
|
direction?: 'vertical' | 'horizontal' | 'both';
|
|
94
|
+
/** When the themed scrollbar shows: on hover (default), only while
|
|
95
|
+
* scrolling, or always (a good fit for gloved/touch terminals). */
|
|
96
|
+
scrollbarType?: 'hover' | 'scroll' | 'always';
|
|
94
97
|
}
|
|
95
|
-
/** A
|
|
96
|
-
|
|
98
|
+
/** A scroll container with themed, overlay-style scrollbars over the Radix
|
|
99
|
+
* viewport. The anatomy stays `scroll-area.root/viewport` plus the
|
|
100
|
+
* `scroll-area.scrollbar/thumb` parts the skin styles. */
|
|
101
|
+
export declare function ScrollArea({ direction, scrollbarType, className, style, children }: ScrollAreaProps): ReactNode;
|
|
102
|
+
/** Options for {@link attachDragPan}. */
|
|
103
|
+
export interface DragPanOptions {
|
|
104
|
+
/** Which axes the pan may move (default `vertical`). */
|
|
105
|
+
direction?: 'vertical' | 'horizontal' | 'both';
|
|
106
|
+
/** Pointer travel in px beyond which a press becomes a pan (default 4). */
|
|
107
|
+
threshold?: number;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Wire an element as a drag-pan surface over its own scroll viewport. Touch
|
|
111
|
+
* pointers keep native scrolling; mouse/stylus presses pan `scrollLeft`/
|
|
112
|
+
* `scrollTop` directly once the pointer travels past `threshold`, so child
|
|
113
|
+
* clicks survive a press-release. While panning the element carries
|
|
114
|
+
* `data-dragging="true"`. Returns the disposer removing every listener.
|
|
115
|
+
*/
|
|
116
|
+
export declare function attachDragPan(element: HTMLElement, options?: DragPanOptions): () => void;
|
|
97
117
|
/** Props of {@link DragScroll}. */
|
|
98
118
|
export interface DragScrollProps extends LayoutProps {
|
|
99
119
|
direction?: 'vertical' | 'horizontal' | 'both';
|
|
100
120
|
}
|
|
101
|
-
/** A
|
|
121
|
+
/** A scroll container any pointer can pan by dragging; touch keeps native
|
|
122
|
+
* scrolling, mouse/stylus drags pan the viewport past a small travel
|
|
123
|
+
* threshold, and child clicks survive a press-release. */
|
|
102
124
|
export declare function DragScroll({ direction, className, style, children }: DragScrollProps): ReactNode;
|
|
103
125
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Semantic layout primitives. Pages compose these instead of raw flex/grid
|
|
4
|
+
* utility classes; the structural rules are inline (so layout survives
|
|
5
|
+
* without a skin) while spacing/density values ride skin tokens.
|
|
6
|
+
*
|
|
7
|
+
* @module @snap-rail/ui/components/layout
|
|
8
|
+
*/
|
|
9
|
+
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
10
|
+
import { useEffect, useRef } from 'react';
|
|
2
11
|
import { cn, part, space } from "../utils.js";
|
|
3
12
|
/** A vertical flow. */
|
|
4
13
|
export function Stack({ gap = 'md', padding, align, className, style, children }) {
|
|
@@ -55,22 +64,86 @@ export function Page({ header, actions, title, titleExtra, description, classNam
|
|
|
55
64
|
export function Section({ title, description, actions, className, style, children }) {
|
|
56
65
|
return (_jsxs("section", { ...part('section', 'root'), className: cn('snap-section', className), style: { display: 'flex', flexDirection: 'column', gap: space('sm'), ...style }, children: [(title !== undefined || actions !== undefined) && (_jsxs("div", { ...part('section', 'header'), style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: space('md') }, children: [_jsxs("div", { children: [title !== undefined && _jsx("div", { ...part('section', 'title'), children: title }), description !== undefined && _jsx("div", { children: description })] }), actions !== undefined && _jsx("div", { ...part('section', 'actions'), children: actions })] })), _jsx("div", { ...part('section', 'body'), children: children })] }));
|
|
57
66
|
}
|
|
58
|
-
/** A compact action bar. */
|
|
59
|
-
export function Toolbar({ start, end, className, style }) {
|
|
60
|
-
return (_jsxs("div", { ...part('toolbar', 'root'), className: cn('snap-toolbar', className), style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: space('sm'), ...style }, children: [_jsx("div", { ...part('toolbar', 'start'), style: { display: 'flex', alignItems: 'center', gap: space('sm'), minWidth: 0 }, children: start }), _jsx("div", { ...part('toolbar', 'end'), style: { display: 'flex', alignItems: 'center', gap: space('sm'), flexShrink: 0 }, children: end })] }));
|
|
67
|
+
/** A compact action bar; `children` renders between the start and end groups. */
|
|
68
|
+
export function Toolbar({ start, end, children, className, style }) {
|
|
69
|
+
return (_jsxs("div", { ...part('toolbar', 'root'), className: cn('snap-toolbar', className), style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: space('sm'), ...style }, children: [_jsx("div", { ...part('toolbar', 'start'), style: { display: 'flex', alignItems: 'center', gap: space('sm'), minWidth: 0 }, children: start }), children !== undefined && (_jsx("div", { ...part('toolbar', 'center'), style: { display: 'flex', alignItems: 'center', gap: space('sm'), minWidth: 0 }, children: children })), _jsx("div", { ...part('toolbar', 'end'), style: { display: 'flex', alignItems: 'center', gap: space('sm'), flexShrink: 0 }, children: end })] }));
|
|
61
70
|
}
|
|
62
|
-
/** A
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
/** A scroll container with themed, overlay-style scrollbars over the Radix
|
|
72
|
+
* viewport. The anatomy stays `scroll-area.root/viewport` plus the
|
|
73
|
+
* `scroll-area.scrollbar/thumb` parts the skin styles. */
|
|
74
|
+
export function ScrollArea({ direction = 'vertical', scrollbarType = 'hover', className, style, children }) {
|
|
75
|
+
return (_jsxs(ScrollAreaPrimitive.Root, { ...part('scroll-area', 'root'), className: cn('snap-scroll-area', className), type: scrollbarType, style: { minHeight: 0, ...direction === 'horizontal' ? { height: '100%' } : {}, ...style }, children: [_jsx(ScrollAreaPrimitive.Viewport, { ...part('scroll-area', 'viewport'), className: "snap-scroll-area-viewport", children: children }), direction !== 'horizontal' && (_jsx(ScrollAreaPrimitive.Scrollbar, { ...part('scroll-area', 'scrollbar'), className: "snap-scroll-area-scrollbar", orientation: "vertical", children: _jsx(ScrollAreaPrimitive.Thumb, { ...part('scroll-area', 'thumb'), className: "snap-scroll-area-thumb" }) })), direction !== 'vertical' && (_jsx(ScrollAreaPrimitive.Scrollbar, { ...part('scroll-area', 'scrollbar'), className: "snap-scroll-area-scrollbar", orientation: "horizontal", children: _jsx(ScrollAreaPrimitive.Thumb, { ...part('scroll-area', 'thumb'), className: "snap-scroll-area-thumb" }) }))] }));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Wire an element as a drag-pan surface over its own scroll viewport. Touch
|
|
79
|
+
* pointers keep native scrolling; mouse/stylus presses pan `scrollLeft`/
|
|
80
|
+
* `scrollTop` directly once the pointer travels past `threshold`, so child
|
|
81
|
+
* clicks survive a press-release. While panning the element carries
|
|
82
|
+
* `data-dragging="true"`. Returns the disposer removing every listener.
|
|
83
|
+
*/
|
|
84
|
+
export function attachDragPan(element, options = {}) {
|
|
85
|
+
const direction = options.direction ?? 'vertical';
|
|
86
|
+
const threshold = options.threshold ?? 4;
|
|
87
|
+
let anchor = null;
|
|
88
|
+
let panned = false;
|
|
89
|
+
const onPointerDown = (event) => {
|
|
90
|
+
if (event.pointerType === 'touch' || event.button !== 0)
|
|
91
|
+
return;
|
|
92
|
+
anchor = { x: event.clientX, y: event.clientY, left: element.scrollLeft, top: element.scrollTop };
|
|
93
|
+
panned = false;
|
|
94
|
+
};
|
|
95
|
+
const onPointerMove = (event) => {
|
|
96
|
+
if (anchor === null)
|
|
97
|
+
return;
|
|
98
|
+
const dx = event.clientX - anchor.x;
|
|
99
|
+
const dy = event.clientY - anchor.y;
|
|
100
|
+
if (!panned && Math.hypot(dx, dy) < threshold)
|
|
101
|
+
return;
|
|
102
|
+
panned = true;
|
|
103
|
+
element.setAttribute('data-dragging', 'true');
|
|
104
|
+
if (direction !== 'vertical')
|
|
105
|
+
element.scrollLeft = anchor.left - dx;
|
|
106
|
+
if (direction !== 'horizontal')
|
|
107
|
+
element.scrollTop = anchor.top - dy;
|
|
108
|
+
};
|
|
109
|
+
const endPan = () => {
|
|
110
|
+
anchor = null;
|
|
111
|
+
element.removeAttribute('data-dragging');
|
|
112
|
+
};
|
|
113
|
+
const onClickCapture = (event) => {
|
|
114
|
+
if (!panned)
|
|
115
|
+
return;
|
|
116
|
+
panned = false;
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
event.stopPropagation();
|
|
119
|
+
};
|
|
120
|
+
element.addEventListener('pointerdown', onPointerDown);
|
|
121
|
+
element.addEventListener('pointermove', onPointerMove);
|
|
122
|
+
element.addEventListener('pointerup', endPan);
|
|
123
|
+
element.addEventListener('pointercancel', endPan);
|
|
124
|
+
element.addEventListener('pointerleave', endPan);
|
|
125
|
+
element.addEventListener('click', onClickCapture, true);
|
|
126
|
+
return () => {
|
|
127
|
+
element.removeEventListener('pointerdown', onPointerDown);
|
|
128
|
+
element.removeEventListener('pointermove', onPointerMove);
|
|
129
|
+
element.removeEventListener('pointerup', endPan);
|
|
130
|
+
element.removeEventListener('pointercancel', endPan);
|
|
131
|
+
element.removeEventListener('pointerleave', endPan);
|
|
132
|
+
element.removeEventListener('click', onClickCapture, true);
|
|
133
|
+
};
|
|
70
134
|
}
|
|
71
|
-
/** A
|
|
135
|
+
/** A scroll container any pointer can pan by dragging; touch keeps native
|
|
136
|
+
* scrolling, mouse/stylus drags pan the viewport past a small travel
|
|
137
|
+
* threshold, and child clicks survive a press-release. */
|
|
72
138
|
export function DragScroll({ direction = 'vertical', className, style, children }) {
|
|
73
|
-
|
|
139
|
+
const rootRef = useRef(null);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
const root = rootRef.current;
|
|
142
|
+
if (root === null)
|
|
143
|
+
return;
|
|
144
|
+
return attachDragPan(root, { direction });
|
|
145
|
+
}, [direction]);
|
|
146
|
+
return (_jsx("div", { ref: rootRef, ...part('drag-scroll', 'root'), className: cn('snap-drag-scroll', className), style: {
|
|
74
147
|
overflowY: direction === 'horizontal' ? 'hidden' : 'auto',
|
|
75
148
|
overflowX: direction === 'vertical' ? 'hidden' : 'auto',
|
|
76
149
|
minHeight: 0,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Overlay semantics over Radix: tooltips, popovers, dropdown menus, and
|
|
3
|
+
* toasts. Behaviour/keyboard/focus handling stays here; skins target the
|
|
4
|
+
* stable parts (`tooltip.*`, `popover.*`, `menu.*`, `toast.*`) and state
|
|
5
|
+
* attributes. The imperative toast() helper pairs with the <Toaster/> the
|
|
6
|
+
* runtime mounts in every surface root.
|
|
7
|
+
*
|
|
8
|
+
* @module @snap-rail/ui/components/overlay
|
|
9
|
+
*/
|
|
10
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
11
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
12
|
+
import * as ToastPrimitive from '@radix-ui/react-toast';
|
|
13
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
14
|
+
import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
15
|
+
/** The tooltip root; wraps `TooltipTrigger`/`TooltipContent` and owns delay. */
|
|
16
|
+
export declare function Tooltip({ delayDuration, ...props }: ComponentPropsWithoutRef<typeof TooltipPrimitive.Root>): ReactNode;
|
|
17
|
+
/** The tooltip provider; the runtime mounts one, pages only need it standalone. */
|
|
18
|
+
export declare function TooltipProvider(props: ComponentPropsWithoutRef<typeof TooltipPrimitive.Provider>): ReactNode;
|
|
19
|
+
/** The tooltip trigger; wraps its child and anchors the bubble. */
|
|
20
|
+
export declare function TooltipTrigger(props: ComponentPropsWithoutRef<typeof TooltipPrimitive.Trigger>): ReactNode;
|
|
21
|
+
/** Props of {@link TooltipContent}. */
|
|
22
|
+
export interface TooltipContentProps extends ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> {
|
|
23
|
+
/** Bubble side (default `top`). */
|
|
24
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
25
|
+
sideOffset?: number;
|
|
26
|
+
}
|
|
27
|
+
/** The portalled tooltip bubble. */
|
|
28
|
+
export declare function TooltipContent({ side, sideOffset, className, children, ...props }: TooltipContentProps): ReactNode;
|
|
29
|
+
/** The popover root. */
|
|
30
|
+
export declare const Popover: import("react").FC<PopoverPrimitive.PopoverProps>;
|
|
31
|
+
/** The popover trigger; wraps its child and toggles the panel. */
|
|
32
|
+
export declare function PopoverTrigger(props: ComponentPropsWithoutRef<typeof PopoverPrimitive.Trigger>): ReactNode;
|
|
33
|
+
/** An element the panel positions against without toggling it. */
|
|
34
|
+
export declare const PopoverAnchor: import("react").ForwardRefExoticComponent<PopoverPrimitive.PopoverAnchorProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
+
/** Closes the popover from inside the panel. */
|
|
36
|
+
export declare function PopoverClose(props: ComponentPropsWithoutRef<typeof PopoverPrimitive.Close>): ReactNode;
|
|
37
|
+
/** Props of {@link PopoverContent}. */
|
|
38
|
+
export interface PopoverContentProps extends ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> {
|
|
39
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
40
|
+
align?: 'start' | 'center' | 'end';
|
|
41
|
+
sideOffset?: number;
|
|
42
|
+
}
|
|
43
|
+
/** The portalled popover panel. */
|
|
44
|
+
export declare function PopoverContent({ side, align, sideOffset, className, children, ...props }: PopoverContentProps): ReactNode;
|
|
45
|
+
/** The dropdown menu root. */
|
|
46
|
+
export declare const Menu: import("react").FC<DropdownMenuPrimitive.DropdownMenuProps>;
|
|
47
|
+
/** The menu trigger; wraps its child and toggles the dropdown. */
|
|
48
|
+
export declare function MenuTrigger(props: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Trigger>): ReactNode;
|
|
49
|
+
/** Props of {@link MenuContent}. */
|
|
50
|
+
export interface MenuContentProps extends ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> {
|
|
51
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
52
|
+
align?: 'start' | 'center' | 'end';
|
|
53
|
+
sideOffset?: number;
|
|
54
|
+
}
|
|
55
|
+
/** The portalled dropdown list. */
|
|
56
|
+
export declare function MenuContent({ side, align, sideOffset, className, children, ...props }: MenuContentProps): ReactNode;
|
|
57
|
+
/** One menu action. */
|
|
58
|
+
export declare function MenuItem({ className, children, ...props }: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item>): ReactNode;
|
|
59
|
+
/** A checkable menu action with an indicator slot. */
|
|
60
|
+
export declare function MenuCheckboxItem({ className, children, ...props }: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>): ReactNode;
|
|
61
|
+
/** A non-interactive group heading. */
|
|
62
|
+
export declare function MenuLabel({ className, children, ...props }: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label>): ReactNode;
|
|
63
|
+
/** A group container for items. */
|
|
64
|
+
export declare function MenuGroup(props: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Group>): ReactNode;
|
|
65
|
+
/** A horizontal rule between menu sections. */
|
|
66
|
+
export declare function MenuSeparator({ className, ...props }: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>): ReactNode;
|
|
67
|
+
/** One queued toast. */
|
|
68
|
+
export interface ToastEntry {
|
|
69
|
+
title: ReactNode;
|
|
70
|
+
description?: ReactNode;
|
|
71
|
+
intent?: 'neutral' | 'primary' | 'danger' | 'success' | 'warning';
|
|
72
|
+
/** Auto-dismiss after this many ms; 0 keeps the toast until dismissed
|
|
73
|
+
* (default 5000). */
|
|
74
|
+
duration?: number;
|
|
75
|
+
}
|
|
76
|
+
/** Enqueue a toast on the runtime-mounted {@link Toaster}s. */
|
|
77
|
+
export declare function toast(entry: ToastEntry): number;
|
|
78
|
+
/** Dismiss a queued toast by id. */
|
|
79
|
+
export declare function dismissToast(id: number): void;
|
|
80
|
+
/** The runtime-mounted viewport: renders the shared toast queue. Pages never
|
|
81
|
+
* mount this themselves — the runtime provides one per surface root. */
|
|
82
|
+
export declare function Toaster(props: Omit<ComponentPropsWithoutRef<typeof ToastPrimitive.Provider>, 'duration'>): ReactNode;
|
|
83
|
+
/** The raw toast root for pages that manage their own open state. */
|
|
84
|
+
export declare const Toast: import("react").ForwardRefExoticComponent<ToastPrimitive.ToastProps & import("react").RefAttributes<HTMLLIElement>>;
|
|
85
|
+
/** A toast title with its part tag. */
|
|
86
|
+
export declare function ToastTitle({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Title>): ReactNode;
|
|
87
|
+
/** A toast description with its part tag. */
|
|
88
|
+
export declare function ToastDescription({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Description>): ReactNode;
|
|
89
|
+
/** An interactive toast action (confirm/retry affordances). */
|
|
90
|
+
export declare function ToastAction({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Action>): ReactNode;
|
|
91
|
+
/** A toast dismissal button. */
|
|
92
|
+
export declare function ToastClose({ className, children, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Close>): ReactNode;
|
|
93
|
+
/** The toast viewport; only the runtime's {@link Toaster} mounts one. */
|
|
94
|
+
export declare function ToastViewport({ className, ...props }: ComponentPropsWithoutRef<typeof ToastPrimitive.Viewport>): ReactNode;
|
|
95
|
+
//# sourceMappingURL=overlay.d.ts.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Overlay semantics over Radix: tooltips, popovers, dropdown menus, and
|
|
4
|
+
* toasts. Behaviour/keyboard/focus handling stays here; skins target the
|
|
5
|
+
* stable parts (`tooltip.*`, `popover.*`, `menu.*`, `toast.*`) and state
|
|
6
|
+
* attributes. The imperative toast() helper pairs with the <Toaster/> the
|
|
7
|
+
* runtime mounts in every surface root.
|
|
8
|
+
*
|
|
9
|
+
* @module @snap-rail/ui/components/overlay
|
|
10
|
+
*/
|
|
11
|
+
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
12
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
13
|
+
import * as ToastPrimitive from '@radix-ui/react-toast';
|
|
14
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
15
|
+
import { useSyncExternalStore, } from 'react';
|
|
16
|
+
import { cn, part } from "../utils.js";
|
|
17
|
+
/* ------------------------------------------------------------------ Tooltip */
|
|
18
|
+
/** The tooltip root; wraps `TooltipTrigger`/`TooltipContent` and owns delay. */
|
|
19
|
+
export function Tooltip({ delayDuration, ...props }) {
|
|
20
|
+
return _jsx(TooltipPrimitive.Root, { ...props, delayDuration: delayDuration ?? 300 });
|
|
21
|
+
}
|
|
22
|
+
/** The tooltip provider; the runtime mounts one, pages only need it standalone. */
|
|
23
|
+
export function TooltipProvider(props) {
|
|
24
|
+
return _jsx(TooltipPrimitive.Provider, { ...props });
|
|
25
|
+
}
|
|
26
|
+
/** The tooltip trigger; wraps its child and anchors the bubble. */
|
|
27
|
+
export function TooltipTrigger(props) {
|
|
28
|
+
return _jsx(TooltipPrimitive.Trigger, { ...part('tooltip', 'trigger'), ...props });
|
|
29
|
+
}
|
|
30
|
+
/** The portalled tooltip bubble. */
|
|
31
|
+
export function TooltipContent({ side = 'top', sideOffset = 6, className, children, ...props }) {
|
|
32
|
+
return (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Content, { ...part('tooltip', 'content'), className: cn('snap-tooltip', className), side: side, sideOffset: sideOffset, ...props, children: children }) }));
|
|
33
|
+
}
|
|
34
|
+
/* ------------------------------------------------------------------ Popover */
|
|
35
|
+
/** The popover root. */
|
|
36
|
+
export const Popover = PopoverPrimitive.Root;
|
|
37
|
+
/** The popover trigger; wraps its child and toggles the panel. */
|
|
38
|
+
export function PopoverTrigger(props) {
|
|
39
|
+
return _jsx(PopoverPrimitive.Trigger, { ...part('popover', 'trigger'), ...props });
|
|
40
|
+
}
|
|
41
|
+
/** An element the panel positions against without toggling it. */
|
|
42
|
+
export const PopoverAnchor = PopoverPrimitive.Anchor;
|
|
43
|
+
/** Closes the popover from inside the panel. */
|
|
44
|
+
export function PopoverClose(props) {
|
|
45
|
+
return _jsx(PopoverPrimitive.Close, { ...props });
|
|
46
|
+
}
|
|
47
|
+
/** The portalled popover panel. */
|
|
48
|
+
export function PopoverContent({ side = 'bottom', align = 'center', sideOffset = 6, className, children, ...props }) {
|
|
49
|
+
return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { ...part('popover', 'content'), className: cn('snap-popover', className), side: side, align: align, sideOffset: sideOffset, ...props, children: children }) }));
|
|
50
|
+
}
|
|
51
|
+
/* -------------------------------------------------------------------- Menu */
|
|
52
|
+
/** The dropdown menu root. */
|
|
53
|
+
export const Menu = DropdownMenuPrimitive.Root;
|
|
54
|
+
/** The menu trigger; wraps its child and toggles the dropdown. */
|
|
55
|
+
export function MenuTrigger(props) {
|
|
56
|
+
return _jsx(DropdownMenuPrimitive.Trigger, { ...part('menu', 'trigger'), ...props });
|
|
57
|
+
}
|
|
58
|
+
/** The portalled dropdown list. */
|
|
59
|
+
export function MenuContent({ side = 'bottom', align = 'start', sideOffset = 4, className, children, ...props }) {
|
|
60
|
+
return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { ...part('menu', 'content'), className: cn('snap-menu', className), side: side, align: align, sideOffset: sideOffset, ...props, children: children }) }));
|
|
61
|
+
}
|
|
62
|
+
/** One menu action. */
|
|
63
|
+
export function MenuItem({ className, children, ...props }) {
|
|
64
|
+
return (_jsx(DropdownMenuPrimitive.Item, { ...part('menu', 'item'), className: cn('snap-menu-item', className), ...props, children: children }));
|
|
65
|
+
}
|
|
66
|
+
/** A checkable menu action with an indicator slot. */
|
|
67
|
+
export function MenuCheckboxItem({ className, children, ...props }) {
|
|
68
|
+
return (_jsxs(DropdownMenuPrimitive.CheckboxItem, { ...part('menu', 'checkbox-item'), className: cn('snap-menu-item', className), ...props, children: [_jsx(DropdownMenuPrimitive.ItemIndicator, { ...part('menu', 'item-indicator'), className: "snap-menu-indicator", children: "\u2713" }), children] }));
|
|
69
|
+
}
|
|
70
|
+
/** A non-interactive group heading. */
|
|
71
|
+
export function MenuLabel({ className, children, ...props }) {
|
|
72
|
+
return _jsx(DropdownMenuPrimitive.Label, { className: cn('snap-menu-label', className), ...props, children: children });
|
|
73
|
+
}
|
|
74
|
+
/** A group container for items. */
|
|
75
|
+
export function MenuGroup(props) {
|
|
76
|
+
return _jsx(DropdownMenuPrimitive.Group, { ...props });
|
|
77
|
+
}
|
|
78
|
+
/** A horizontal rule between menu sections. */
|
|
79
|
+
export function MenuSeparator({ className, ...props }) {
|
|
80
|
+
return _jsx(DropdownMenuPrimitive.Separator, { ...part('menu', 'separator'), className: cn('snap-menu-separator', className), ...props });
|
|
81
|
+
}
|
|
82
|
+
let toastNextId = 1;
|
|
83
|
+
let toastRecords = [];
|
|
84
|
+
const toastListeners = new Set();
|
|
85
|
+
function toastEmit() {
|
|
86
|
+
for (const listener of toastListeners)
|
|
87
|
+
listener();
|
|
88
|
+
}
|
|
89
|
+
function toastDismiss(id) {
|
|
90
|
+
toastRecords = toastRecords.filter(record => record.id !== id);
|
|
91
|
+
toastEmit();
|
|
92
|
+
}
|
|
93
|
+
/** Enqueue a toast on the runtime-mounted {@link Toaster}s. */
|
|
94
|
+
export function toast(entry) {
|
|
95
|
+
const id = toastNextId++;
|
|
96
|
+
toastRecords = [...toastRecords, { ...entry, id }];
|
|
97
|
+
toastEmit();
|
|
98
|
+
return id;
|
|
99
|
+
}
|
|
100
|
+
/** Dismiss a queued toast by id. */
|
|
101
|
+
export function dismissToast(id) {
|
|
102
|
+
toastDismiss(id);
|
|
103
|
+
}
|
|
104
|
+
/** The runtime-mounted viewport: renders the shared toast queue. Pages never
|
|
105
|
+
* mount this themselves — the runtime provides one per surface root. */
|
|
106
|
+
export function Toaster(props) {
|
|
107
|
+
const records = useSyncExternalStore((onStoreChange) => {
|
|
108
|
+
toastListeners.add(onStoreChange);
|
|
109
|
+
return () => toastListeners.delete(onStoreChange);
|
|
110
|
+
}, () => toastRecords, () => toastRecords);
|
|
111
|
+
return (_jsxs(ToastPrimitive.Provider, { ...props, children: [records.map(record => (_jsxs(ToastPrimitive.Root, { ...part('toast', 'root'), className: "snap-toast", "data-intent": record.intent ?? 'neutral', duration: record.duration ?? 5000, onOpenChange: (open) => {
|
|
112
|
+
if (!open)
|
|
113
|
+
toastDismiss(record.id);
|
|
114
|
+
}, children: [_jsx(ToastTitle, { children: record.title }), record.description !== undefined && _jsx(ToastDescription, { children: record.description }), _jsx(ToastClose, { "aria-label": "\u5173\u95ED" })] }, record.id))), _jsx(ToastViewport, {})] }));
|
|
115
|
+
}
|
|
116
|
+
/** The raw toast root for pages that manage their own open state. */
|
|
117
|
+
export const Toast = ToastPrimitive.Root;
|
|
118
|
+
/** A toast title with its part tag. */
|
|
119
|
+
export function ToastTitle({ className, children, ...props }) {
|
|
120
|
+
return _jsx(ToastPrimitive.Title, { ...part('toast', 'title'), className: cn('snap-toast-title', className), ...props, children: children });
|
|
121
|
+
}
|
|
122
|
+
/** A toast description with its part tag. */
|
|
123
|
+
export function ToastDescription({ className, children, ...props }) {
|
|
124
|
+
return _jsx(ToastPrimitive.Description, { ...part('toast', 'description'), className: cn('snap-toast-description', className), ...props, children: children });
|
|
125
|
+
}
|
|
126
|
+
/** An interactive toast action (confirm/retry affordances). */
|
|
127
|
+
export function ToastAction({ className, children, ...props }) {
|
|
128
|
+
return _jsx(ToastPrimitive.Action, { ...part('toast', 'action'), className: cn('snap-toast-action', className), ...props, children: children });
|
|
129
|
+
}
|
|
130
|
+
/** A toast dismissal button. */
|
|
131
|
+
export function ToastClose({ className, children, ...props }) {
|
|
132
|
+
return _jsx(ToastPrimitive.Close, { ...part('toast', 'close'), className: cn('snap-toast-close', className), ...props, children: children ?? _jsx("span", { "aria-hidden": "true", children: "\u00D7" }) });
|
|
133
|
+
}
|
|
134
|
+
/** The toast viewport; only the runtime's {@link Toaster} mounts one. */
|
|
135
|
+
export function ToastViewport({ className, ...props }) {
|
|
136
|
+
return _jsx(ToastPrimitive.Viewport, { ...part('toast', 'viewport'), className: cn('snap-toast-viewport', className), ...props });
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=overlay.js.map
|
|
@@ -36,9 +36,11 @@ export interface SchemaFormProps {
|
|
|
36
36
|
value: Readonly<Record<string, unknown>>;
|
|
37
37
|
onChange: (value: Record<string, unknown>) => void;
|
|
38
38
|
idPrefix?: string;
|
|
39
|
+
/** Arrange the fields in a grid with this many columns (default stacked). */
|
|
40
|
+
columns?: number;
|
|
39
41
|
}
|
|
40
42
|
/** Render a flat JSON-Schema object as semantic fields. */
|
|
41
|
-
export declare function SchemaForm({ schema, value, onChange, idPrefix }: SchemaFormProps): ReactNode;
|
|
43
|
+
export declare function SchemaForm({ schema, value, onChange, idPrefix, columns }: SchemaFormProps): ReactNode;
|
|
42
44
|
/** Normalize a driver's JSON Schema (which may carry `$schema`). */
|
|
43
45
|
export declare function schemaNodeOf(value: unknown): JsonSchemaNode;
|
|
44
46
|
//# sourceMappingURL=schema-form.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { part } from "../utils.js";
|
|
2
3
|
import { Field } from "./form.js";
|
|
3
4
|
import { Input, NumberInput, Textarea } from "./input.js";
|
|
4
5
|
import { Switch, TouchSelect } from "./controls.js";
|
|
@@ -31,51 +32,56 @@ function asRecord(value) {
|
|
|
31
32
|
: {};
|
|
32
33
|
}
|
|
33
34
|
/** Render a flat JSON-Schema object as semantic fields. */
|
|
34
|
-
export function SchemaForm({ schema, value, onChange, idPrefix = 'schema' }) {
|
|
35
|
+
export function SchemaForm({ schema, value, onChange, idPrefix = 'schema', columns }) {
|
|
35
36
|
const properties = schema.properties ?? {};
|
|
36
37
|
const required = new Set(schema.required ?? []);
|
|
37
38
|
const update = (key, next) => {
|
|
38
39
|
onChange({ ...value, [key]: next });
|
|
39
40
|
};
|
|
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
|
-
|
|
41
|
+
const renderField = (key, property) => {
|
|
42
|
+
const id = `${idPrefix}-${key}`;
|
|
43
|
+
const current = value[key] ?? property.default;
|
|
44
|
+
const label = property.title ?? key;
|
|
45
|
+
const common = {
|
|
46
|
+
label,
|
|
47
|
+
htmlFor: id,
|
|
48
|
+
...(property.description !== undefined ? { help: property.description } : {}),
|
|
49
|
+
...(required.has(key) ? { required: true } : {}),
|
|
50
|
+
};
|
|
51
|
+
const values = literalValuesOf(property);
|
|
52
|
+
if (values !== undefined) {
|
|
53
|
+
const options = values.map(item => ({ value: String(item), label: String(item) }));
|
|
54
|
+
return (_jsx(Field, { ...common, children: _jsx(TouchSelect, { ...current !== undefined ? { value: String(current) } : {}, options: options, onValueChange: next => {
|
|
55
|
+
update(key, values.find(item => String(item) === next) ?? next);
|
|
56
|
+
}, "aria-label": String(label) }) }));
|
|
57
|
+
}
|
|
58
|
+
if (property.type === 'boolean') {
|
|
59
|
+
// The field title is the label; the switch itself stays unlabeled so
|
|
60
|
+
// the row does not repeat a hardcoded on/off caption.
|
|
61
|
+
return (_jsx(Field, { ...common, children: _jsx(Switch, { checked: current === true, onCheckedChange: next => update(key, next), "aria-label": String(label) }) }));
|
|
62
|
+
}
|
|
63
|
+
if (property.type === 'number' || property.type === 'integer') {
|
|
64
|
+
return (_jsx(Field, { ...common, children: _jsx(NumberInput, { id: id, value: typeof current === 'number' ? current : '', ...property.minimum !== undefined ? { min: property.minimum } : {}, ...property.maximum !== undefined ? { max: property.maximum } : {}, onChange: event => {
|
|
65
|
+
const raw = event.target.value;
|
|
66
|
+
update(key, raw === '' ? undefined : Number(raw));
|
|
67
|
+
} }) }));
|
|
68
|
+
}
|
|
69
|
+
if (property.type === 'object' || property.type === 'array') {
|
|
70
|
+
return (_jsx(Field, { ...common, help: property.description ?? 'JSON 值', children: _jsx(Textarea, { id: id, rows: 4, defaultValue: JSON.stringify(current ?? (property.type === 'array' ? [] : {}), null, 2), onBlur: event => {
|
|
71
|
+
try {
|
|
72
|
+
update(key, JSON.parse(event.target.value));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Keep the invalid draft in the textarea; the driver's
|
|
76
|
+
// schema rejects it on submit with a readable error.
|
|
77
|
+
}
|
|
78
|
+
} }) }));
|
|
79
|
+
}
|
|
80
|
+
return (_jsx(Field, { ...common, children: _jsx(Input, { id: id, value: typeof current === 'string' || typeof current === 'number' ? String(current) : '', onChange: event => update(key, event.target.value) }) }));
|
|
81
|
+
};
|
|
82
|
+
return (_jsxs("div", { ...part('schema-form', 'root'), className: "snap-schema-form", style: columns !== undefined
|
|
83
|
+
? { display: 'grid', gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, gap: 'var(--snap-space-md)' }
|
|
84
|
+
: { display: 'flex', flexDirection: 'column', gap: 'var(--snap-space-md)' }, children: [Object.entries(properties).map(([key, property]) => (_jsx("div", { ...part('schema-form', 'field'), children: renderField(key, property) }, key))), Object.keys(properties).length === 0 && (_jsx("span", { style: { color: 'var(--snap-color-muted)' }, children: "\u8BE5\u9A71\u52A8\u6CA1\u6709\u989D\u5916\u914D\u7F6E\u9879\u3002" }))] }));
|
|
79
85
|
}
|
|
80
86
|
/** Normalize a driver's JSON Schema (which may carry `$schema`). */
|
|
81
87
|
export function schemaNodeOf(value) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coarse value adjustment for touch operation: a Radix slider with the
|
|
3
|
+
* semantic anatomy (`slider.root/track/range/thumb`). Thumb size rides the
|
|
4
|
+
* skin's control tokens so gloved operation keeps a real target.
|
|
5
|
+
*
|
|
6
|
+
* @module @snap-rail/ui/components/slider
|
|
7
|
+
*/
|
|
8
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
9
|
+
import type { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
10
|
+
/** Props of {@link Slider}. */
|
|
11
|
+
export interface SliderProps extends ComponentPropsWithoutRef<typeof SliderPrimitive.Root> {
|
|
12
|
+
/** The track label announced to assistive tech. */
|
|
13
|
+
label?: string;
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/** A ranged control with a large touch target and keyboard stepping. */
|
|
17
|
+
export declare function Slider({ label, className, children, ...props }: SliderProps): ReactNode;
|
|
18
|
+
//# sourceMappingURL=slider.d.ts.map
|