@snap-rail/ui 0.0.0-stage → 0.1.1

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.
Files changed (62) hide show
  1. package/LICENSE +202 -0
  2. package/lib/charts.js +118 -0
  3. package/lib/contract.js +527 -0
  4. package/lib/fallback.js +399 -0
  5. package/lib/index.js +1282 -0
  6. package/lib/pages.js +68 -0
  7. package/lib/runtime.js +3003 -0
  8. package/lib/settings.js +2069 -0
  9. package/lib/skins.js +258 -0
  10. package/lib/slots.js +267 -0
  11. package/lib/types/charts.d.ts +62 -0
  12. package/lib/types/charts.js +41 -0
  13. package/lib/types/components/button.d.ts +39 -0
  14. package/lib/types/components/button.js +27 -0
  15. package/lib/types/components/controls.d.ts +66 -0
  16. package/lib/types/components/controls.js +66 -0
  17. package/lib/types/components/dialog.d.ts +58 -0
  18. package/lib/types/components/dialog.js +46 -0
  19. package/lib/types/components/feedback.d.ts +46 -0
  20. package/lib/types/components/feedback.js +20 -0
  21. package/lib/types/components/form.d.ts +31 -0
  22. package/lib/types/components/form.js +13 -0
  23. package/lib/types/components/index.d.ts +15 -0
  24. package/lib/types/components/index.js +15 -0
  25. package/lib/types/components/input.d.ts +40 -0
  26. package/lib/types/components/input.js +18 -0
  27. package/lib/types/components/layout.d.ts +103 -0
  28. package/lib/types/components/layout.js +80 -0
  29. package/lib/types/components/schema-form.d.ts +44 -0
  30. package/lib/types/components/schema-form.js +84 -0
  31. package/lib/types/components/surface.d.ts +49 -0
  32. package/lib/types/components/surface.js +59 -0
  33. package/lib/types/contract.d.ts +350 -0
  34. package/lib/types/contract.js +231 -0
  35. package/lib/types/fallback.d.ts +14 -0
  36. package/lib/types/fallback.js +50 -0
  37. package/lib/types/index.d.ts +19 -0
  38. package/lib/types/index.js +19 -0
  39. package/lib/types/pages.d.ts +40 -0
  40. package/lib/types/pages.js +69 -0
  41. package/lib/types/runtime.d.ts +93 -0
  42. package/lib/types/runtime.js +233 -0
  43. package/lib/types/settings-pages/appearance.d.ts +15 -0
  44. package/lib/types/settings-pages/appearance.js +128 -0
  45. package/lib/types/settings-pages/index.d.ts +3 -0
  46. package/lib/types/settings-pages/index.js +3 -0
  47. package/lib/types/settings-pages/plugin-feed.d.ts +17 -0
  48. package/lib/types/settings-pages/plugin-feed.js +66 -0
  49. package/lib/types/settings-pages/plugins.d.ts +21 -0
  50. package/lib/types/settings-pages/plugins.js +372 -0
  51. package/lib/types/settings.d.ts +59 -0
  52. package/lib/types/settings.js +176 -0
  53. package/lib/types/skins.d.ts +137 -0
  54. package/lib/types/skins.js +271 -0
  55. package/lib/types/slots.d.ts +69 -0
  56. package/lib/types/slots.js +210 -0
  57. package/lib/types/utils.d.ts +15 -0
  58. package/lib/types/utils.js +26 -0
  59. package/package.json +105 -3
  60. package/src/styles/base.css +329 -0
  61. package/src/styles/default.css +735 -0
  62. package/README.md +0 -3
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * Semantic buttons: one behaviour, skin-owned visuals. The DOM exposes
4
+ * `button.root`, `button.label`, `button.icon`, and `button.spinner` parts;
5
+ * intent/emphasis/size are data attributes a skin styles.
6
+ *
7
+ * @module @snap-rail/ui/components/button
8
+ */
9
+ import { Slot as RadixSlot } from '@radix-ui/react-slot';
10
+ import { cn, part } from "../utils.js";
11
+ /** A spinner that inherits the current text colour. */
12
+ export function Spinner(props) {
13
+ return (_jsxs("svg", { ...part('button', 'spinner'), className: cn('snap-spinner', props.className), viewBox: "0 0 24 24", "aria-hidden": "true", children: [_jsx("circle", { cx: "12", cy: "12", r: "9", fill: "none", stroke: "currentColor", strokeWidth: "3", opacity: "0.25" }), _jsx("path", { d: "M21 12a9 9 0 0 0-9-9", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round" })] }));
14
+ }
15
+ /** A themed button; `asChild` composes the behaviour onto a child element. */
16
+ export function Button({ intent = 'neutral', emphasis = 'solid', size = 'md', loading = false, icon, iconPosition = 'start', asChild = false, disabled, className, children, type, ...props }) {
17
+ const Component = asChild ? RadixSlot : 'button';
18
+ const content = asChild
19
+ ? children
20
+ : (_jsxs(_Fragment, { children: [icon !== undefined && iconPosition === 'start' && _jsx("span", { ...part('button', 'icon'), children: icon }), children !== undefined && _jsx("span", { ...part('button', 'label'), children: children }), icon !== undefined && iconPosition === 'end' && _jsx("span", { ...part('button', 'icon'), children: icon }), loading && _jsx(Spinner, {})] }));
21
+ return (_jsx(Component, { ...part('button', 'root'), ...type !== undefined ? { type } : !asChild ? { type: 'button' } : {}, className: cn('snap-button', className), "data-intent": intent, "data-emphasis": emphasis, "data-size": size, "data-loading": loading || undefined, "data-disabled": disabled === true || undefined, "aria-busy": loading || undefined, disabled: !asChild ? disabled === true || loading : undefined, ...props, children: content }));
22
+ }
23
+ /** A square glyph button with a mandatory accessible label. */
24
+ export function IconButton({ icon, label, active = false, intent = 'neutral', emphasis = 'ghost', size = 'md', className, ...props }) {
25
+ return (_jsx("button", { ...part('icon-button', 'root'), type: "button", className: cn('snap-icon-button', className), "data-intent": intent, "data-emphasis": emphasis, "data-size": size, "data-active": active || undefined, "aria-label": label, "aria-pressed": active || undefined, ...props, children: _jsx("span", { ...part('icon-button', 'icon'), "aria-hidden": "true", children: icon }) }));
26
+ }
27
+ //# sourceMappingURL=button.js.map
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Selection and toggle semantics over Radix: tabs, select, switch, checkbox,
3
+ * and radio groups. All behaviour/keyboard handling stays here; skins target
4
+ * the stable parts and state attributes.
5
+ *
6
+ * @module @snap-rail/ui/components/controls
7
+ */
8
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
9
+ import * as LabelPrimitive from '@radix-ui/react-label';
10
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
11
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
12
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
13
+ import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
14
+ /** A form label. */
15
+ export declare function Label({ className, children, ...props }: ComponentPropsWithoutRef<typeof LabelPrimitive.Root>): ReactNode;
16
+ /** The tabs root. */
17
+ export declare const Tabs: import("react").ForwardRefExoticComponent<TabsPrimitive.TabsProps & import("react").RefAttributes<HTMLDivElement>>;
18
+ /** The tabs list. */
19
+ export declare function TabsList({ className, children, ...props }: ComponentPropsWithoutRef<typeof TabsPrimitive.List>): ReactNode;
20
+ /** A tab trigger. */
21
+ export declare function TabsTrigger({ className, children, ...props }: ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>): ReactNode;
22
+ /** A tab panel. */
23
+ export declare function TabsContent({ className, children, ...props }: ComponentPropsWithoutRef<typeof TabsPrimitive.Content>): ReactNode;
24
+ /** Props of {@link Switch}. */
25
+ export interface SwitchProps extends Omit<ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>, 'children'> {
26
+ label?: ReactNode;
27
+ }
28
+ /** A boolean switch. */
29
+ export declare function Switch({ className, label, ...props }: SwitchProps): ReactNode;
30
+ /** Props of {@link Checkbox}. */
31
+ export interface CheckboxProps extends Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, 'children'> {
32
+ label?: ReactNode;
33
+ }
34
+ /** A tri-state checkbox with an inline indicator. */
35
+ export declare function Checkbox({ className, label, ...props }: CheckboxProps): ReactNode;
36
+ /** The radio group root. */
37
+ export declare function RadioGroup({ className, children, ...props }: ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>): ReactNode;
38
+ /** One radio item. */
39
+ export declare function RadioGroupItem({ className, ...props }: ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>): ReactNode;
40
+ /** One option in a {@link Select} or {@link TouchSelect}. */
41
+ export interface SelectOption {
42
+ value: string;
43
+ label: ReactNode;
44
+ disabled?: boolean;
45
+ }
46
+ /** Props of {@link Select}. */
47
+ export interface SelectProps {
48
+ value?: string;
49
+ onValueChange?: (value: string) => void;
50
+ options: readonly SelectOption[];
51
+ placeholder?: string;
52
+ disabled?: boolean;
53
+ invalid?: boolean;
54
+ size?: 'sm' | 'md' | 'lg';
55
+ className?: string;
56
+ 'aria-label'?: string;
57
+ }
58
+ /** Props of {@link TouchSelect}: a modal list for gloved/touch operation. */
59
+ export interface TouchSelectProps extends SelectProps {
60
+ title?: ReactNode;
61
+ }
62
+ /** A modal option list; use on touch terminals in place of the popover select. */
63
+ export declare function TouchSelect({ value, onValueChange, options, placeholder, disabled, invalid, size, className, 'aria-label': ariaLabel, title, }: TouchSelectProps): ReactNode;
64
+ /** A popover select. */
65
+ export declare function Select({ value, onValueChange, options, placeholder, disabled, invalid, size, className, 'aria-label': ariaLabel, }: SelectProps): ReactNode;
66
+ //# sourceMappingURL=controls.d.ts.map
@@ -0,0 +1,66 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /**
3
+ * Selection and toggle semantics over Radix: tabs, select, switch, checkbox,
4
+ * and radio groups. All behaviour/keyboard handling stays here; skins target
5
+ * the stable parts and state attributes.
6
+ *
7
+ * @module @snap-rail/ui/components/controls
8
+ */
9
+ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
10
+ import * as LabelPrimitive from '@radix-ui/react-label';
11
+ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
12
+ import * as SelectPrimitive from '@radix-ui/react-select';
13
+ import * as SwitchPrimitive from '@radix-ui/react-switch';
14
+ import * as TabsPrimitive from '@radix-ui/react-tabs';
15
+ import { useState } from 'react';
16
+ import { cn, part } from "../utils.js";
17
+ import { Button } from "./button.js";
18
+ import { Dialog, DialogContent, DialogHeader, DialogTitle } from "./dialog.js";
19
+ /** A form label. */
20
+ export function Label({ className, children, ...props }) {
21
+ return _jsx(LabelPrimitive.Root, { className: cn('snap-label', className), ...props, children: children });
22
+ }
23
+ /** The tabs root. */
24
+ export const Tabs = TabsPrimitive.Root;
25
+ /** The tabs list. */
26
+ export function TabsList({ className, children, ...props }) {
27
+ return _jsx(TabsPrimitive.List, { ...part('tabs', 'list'), className: cn('snap-tabs-list', className), ...props, children: children });
28
+ }
29
+ /** A tab trigger. */
30
+ export function TabsTrigger({ className, children, ...props }) {
31
+ return _jsx(TabsPrimitive.Trigger, { ...part('tabs', 'trigger'), className: cn('snap-tabs-trigger', className), ...props, children: children });
32
+ }
33
+ /** A tab panel. */
34
+ export function TabsContent({ className, children, ...props }) {
35
+ return _jsx(TabsPrimitive.Content, { ...part('tabs', 'content'), className: cn('snap-tabs-content', className), ...props, children: children });
36
+ }
37
+ /** A boolean switch. */
38
+ export function Switch({ className, label, ...props }) {
39
+ return (_jsxs("label", { className: "snap-switch-label", children: [_jsx(SwitchPrimitive.Root, { ...part('switch', 'root'), className: cn('snap-switch', className), ...props, children: _jsx(SwitchPrimitive.Thumb, { ...part('switch', 'thumb'), className: "snap-switch-thumb" }) }), label !== undefined && _jsx("span", { ...part('switch', 'label'), children: label })] }));
40
+ }
41
+ /** A tri-state checkbox with an inline indicator. */
42
+ export function Checkbox({ className, label, ...props }) {
43
+ return (_jsxs("label", { className: "snap-checkbox-label", children: [_jsx(CheckboxPrimitive.Root, { ...part('checkbox', 'root'), className: cn('snap-checkbox', className), ...props, children: _jsx(CheckboxPrimitive.Indicator, { ...part('checkbox', 'indicator'), className: "snap-checkbox-indicator", children: "\u2713" }) }), label !== undefined && _jsx("span", { ...part('checkbox', 'label'), children: label })] }));
44
+ }
45
+ /** The radio group root. */
46
+ export function RadioGroup({ className, children, ...props }) {
47
+ return _jsx(RadioGroupPrimitive.Root, { ...part('radio-group', 'root'), className: cn('snap-radio-group', className), ...props, children: children });
48
+ }
49
+ /** One radio item. */
50
+ export function RadioGroupItem({ className, ...props }) {
51
+ return (_jsx(RadioGroupPrimitive.Item, { ...part('radio-group', 'item'), className: cn('snap-radio-item', className), ...props, children: _jsx(RadioGroupPrimitive.Indicator, { ...part('radio-group', 'indicator'), className: "snap-radio-indicator" }) }));
52
+ }
53
+ /** A modal option list; use on touch terminals in place of the popover select. */
54
+ export function TouchSelect({ value, onValueChange, options, placeholder = '请选择', disabled = false, invalid = false, size = 'md', className, 'aria-label': ariaLabel, title, }) {
55
+ const [open, setOpen] = useState(false);
56
+ const selected = options.find(option => option.value === value);
57
+ return (_jsxs(_Fragment, { children: [_jsxs(Button, { type: "button", size: size, emphasis: "outline", className: className, disabled: disabled, "aria-label": ariaLabel, "aria-invalid": invalid || undefined, "aria-haspopup": "dialog", onClick: () => setOpen(true), children: [_jsx("span", { style: { flex: 1, textAlign: 'left' }, children: selected?.label ?? placeholder }), _jsx("span", { "aria-hidden": "true", children: "\u25BE" })] }), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: _jsxs(DialogContent, { presentation: "modal", size: "sm", children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: title ?? ariaLabel ?? '请选择' }) }), _jsxs("div", { ...part('touch-select', 'options'), style: { display: 'flex', flexDirection: 'column', gap: 'var(--snap-space-sm)' }, children: [options.map(option => (_jsx(Button, { type: "button", size: "lg", emphasis: option.value === value ? 'solid' : 'outline', intent: option.value === value ? 'primary' : 'neutral', disabled: option.disabled === true, onClick: () => {
58
+ onValueChange?.(option.value);
59
+ setOpen(false);
60
+ }, children: option.label }, option.value))), options.length === 0 && _jsx("span", { style: { color: 'var(--snap-color-muted)' }, children: "\u65E0\u53EF\u9009\u9879" })] })] }) })] }));
61
+ }
62
+ /** A popover select. */
63
+ export function Select({ value, onValueChange, options, placeholder = '请选择', disabled = false, invalid = false, size = 'md', className, 'aria-label': ariaLabel, }) {
64
+ return (_jsxs(SelectPrimitive.Root, { ...value !== undefined ? { value } : {}, ...onValueChange !== undefined ? { onValueChange } : {}, disabled: disabled, children: [_jsxs(SelectPrimitive.Trigger, { ...part('select', 'trigger'), className: cn('snap-select-trigger', className), "data-size": size, "data-invalid": invalid || undefined, "data-disabled": disabled || undefined, "aria-label": ariaLabel, "aria-invalid": invalid || undefined, children: [_jsx(SelectPrimitive.Value, { ...part('select', 'value'), placeholder: placeholder }), _jsx(SelectPrimitive.Icon, { ...part('select', 'chevron'), className: "snap-select-chevron", children: "\u25BE" })] }), _jsx(SelectPrimitive.Portal, { children: _jsx(SelectPrimitive.Content, { ...part('select', 'content'), className: "snap-select-content", position: "popper", sideOffset: 4, children: _jsxs(SelectPrimitive.Viewport, { children: [options.map(option => (_jsxs(SelectPrimitive.Item, { ...part('select', 'item'), className: "snap-select-item", value: option.value, disabled: option.disabled === true, children: [_jsx(SelectPrimitive.ItemText, { children: option.label }), _jsx(SelectPrimitive.ItemIndicator, { ...part('select', 'item-indicator'), className: "snap-select-item-indicator", children: "\u2713" })] }, option.value))), options.length === 0 && _jsx("div", { ...part('select', 'empty'), className: "snap-select-empty", children: "\u65E0\u53EF\u9009\u9879" })] }) }) })] }));
65
+ }
66
+ //# sourceMappingURL=controls.js.map
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Dialog/sheet semantics over Radix's focus trap and portal. The skin chooses
3
+ * the presentation (modal, sheet, fullscreen) through the `presentation`
4
+ * attribute; the core owns dismissal and focus behaviour.
5
+ *
6
+ * @module @snap-rail/ui/components/dialog
7
+ */
8
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
9
+ import type { HTMLAttributes, ReactNode } from 'react';
10
+ /** The presentation variants the core implements for overlays. */
11
+ export type DialogPresentation = 'modal' | 'sheet' | 'fullscreen';
12
+ /** Props of {@link DialogContent}. Panel-level attributes (drag handlers,
13
+ * `aria-describedby`, tests hooks) ride through to the dialog panel. */
14
+ export interface DialogContentProps extends HTMLAttributes<HTMLDivElement> {
15
+ className?: string;
16
+ /** `auto` currently resolves to the skin default; explicit values win. */
17
+ presentation?: DialogPresentation | 'auto';
18
+ size?: 'sm' | 'md' | 'lg';
19
+ showClose?: boolean;
20
+ }
21
+ /** The dialog root. */
22
+ export declare const Dialog: import("react").FC<DialogPrimitive.DialogProps>;
23
+ /** The dialog trigger. */
24
+ export declare const DialogTrigger: import("react").ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
25
+ /** The dialog close. */
26
+ export declare const DialogClose: import("react").ForwardRefExoticComponent<DialogPrimitive.DialogCloseProps & import("react").RefAttributes<HTMLButtonElement>>;
27
+ /** The portalled dialog content. */
28
+ export declare function DialogContent({ children, className, presentation, size, showClose, ...rest }: DialogContentProps): ReactNode;
29
+ /** The dialog header. */
30
+ export declare function DialogHeader({ children, className }: {
31
+ children?: ReactNode;
32
+ className?: string;
33
+ }): ReactNode;
34
+ /** The dialog title. */
35
+ export declare function DialogTitle({ children, className }: {
36
+ children?: ReactNode;
37
+ className?: string;
38
+ }): ReactNode;
39
+ /** The dialog description. */
40
+ export declare function DialogDescription({ children, className }: {
41
+ children?: ReactNode;
42
+ className?: string;
43
+ }): ReactNode;
44
+ /** The dialog body. */
45
+ export declare function DialogBody({ children, className }: {
46
+ children?: ReactNode;
47
+ className?: string;
48
+ }): ReactNode;
49
+ /** The dialog footer. */
50
+ export declare function DialogFooter({ children, className }: {
51
+ children?: ReactNode;
52
+ className?: string;
53
+ }): ReactNode;
54
+ /** A sheet is a dialog with the `sheet` presentation by default. */
55
+ export declare function Sheet(props: Omit<DialogContentProps, 'presentation'> & {
56
+ presentation?: DialogPresentation;
57
+ }): ReactNode;
58
+ //# sourceMappingURL=dialog.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Dialog/sheet semantics over Radix's focus trap and portal. The skin chooses
4
+ * the presentation (modal, sheet, fullscreen) through the `presentation`
5
+ * attribute; the core owns dismissal and focus behaviour.
6
+ *
7
+ * @module @snap-rail/ui/components/dialog
8
+ */
9
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
10
+ import { cn, part } from "../utils.js";
11
+ /** The dialog root. */
12
+ export const Dialog = DialogPrimitive.Root;
13
+ /** The dialog trigger. */
14
+ export const DialogTrigger = DialogPrimitive.Trigger;
15
+ /** The dialog close. */
16
+ export const DialogClose = DialogPrimitive.Close;
17
+ /** The portalled dialog content. */
18
+ export function DialogContent({ children, className, presentation = 'auto', size = 'md', showClose = true, ...rest }) {
19
+ const resolved = presentation === 'auto' ? 'modal' : presentation;
20
+ return (_jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Overlay, { ...part('dialog', 'overlay'), className: "snap-dialog-overlay" }), _jsxs(DialogPrimitive.Content, { ...part('dialog', 'panel'), className: cn('snap-dialog-panel', className), "data-presentation": resolved, "data-size": size, ...rest, children: [children, showClose && (_jsx(DialogPrimitive.Close, { ...part('dialog', 'close'), className: "snap-dialog-close", "aria-label": "\u5173\u95ED", children: "\u00D7" }))] })] }));
21
+ }
22
+ /** The dialog header. */
23
+ export function DialogHeader({ children, className }) {
24
+ return _jsx("div", { ...part('dialog', 'header'), className: cn('snap-dialog-header', className), children: children });
25
+ }
26
+ /** The dialog title. */
27
+ export function DialogTitle({ children, className }) {
28
+ return (_jsx(DialogPrimitive.Title, { ...part('dialog', 'title'), className: cn('snap-dialog-title', className), children: children }));
29
+ }
30
+ /** The dialog description. */
31
+ export function DialogDescription({ children, className }) {
32
+ return (_jsx(DialogPrimitive.Description, { ...part('dialog', 'description'), className: cn('snap-dialog-description', className), children: children }));
33
+ }
34
+ /** The dialog body. */
35
+ export function DialogBody({ children, className }) {
36
+ return _jsx("div", { ...part('dialog', 'body'), className: cn('snap-dialog-body', className), children: children });
37
+ }
38
+ /** The dialog footer. */
39
+ export function DialogFooter({ children, className }) {
40
+ return _jsx("div", { ...part('dialog', 'footer'), className: cn('snap-dialog-footer', className), children: children });
41
+ }
42
+ /** A sheet is a dialog with the `sheet` presentation by default. */
43
+ export function Sheet(props) {
44
+ return _jsx(DialogContent, { ...props, presentation: props.presentation ?? 'sheet' });
45
+ }
46
+ //# sourceMappingURL=dialog.js.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Feedback primitives: badges, status LEDs, progress, and empty states. These
3
+ * are read-only surfaces; their parts are skin-owned.
4
+ *
5
+ * @module @snap-rail/ui/components/feedback
6
+ */
7
+ import type { ReactNode } from 'react';
8
+ import type { ButtonIntent } from './button.tsx';
9
+ /** Props of {@link Badge}. */
10
+ export interface BadgeProps {
11
+ children?: ReactNode;
12
+ intent?: ButtonIntent;
13
+ className?: string;
14
+ }
15
+ /** A compact status/count label. */
16
+ export declare function Badge({ children, intent, className }: BadgeProps): ReactNode;
17
+ /** The semantic LED tones. */
18
+ export type LedTone = 'neutral' | 'accent' | 'success' | 'warning' | 'danger';
19
+ /** Props of {@link Led}. */
20
+ export interface LedProps {
21
+ tone?: LedTone;
22
+ label?: string;
23
+ className?: string;
24
+ }
25
+ /** A status light with a separate halo part for breathing/glow skins. */
26
+ export declare function Led({ tone, label, className }: LedProps): ReactNode;
27
+ /** Props of {@link Progress}. */
28
+ export interface ProgressProps {
29
+ /** Completion in `0..1`; `null` renders an indeterminate track. */
30
+ value: number | null;
31
+ label?: string;
32
+ className?: string;
33
+ }
34
+ /** A linear progress indicator. */
35
+ export declare function Progress({ value, label, className }: ProgressProps): ReactNode;
36
+ /** Props of {@link EmptyState}. */
37
+ export interface EmptyStateProps {
38
+ title: ReactNode;
39
+ description?: ReactNode;
40
+ icon?: ReactNode;
41
+ action?: ReactNode;
42
+ className?: string;
43
+ }
44
+ /** A centered empty/zero-state block. */
45
+ export declare function EmptyState({ title, description, icon, action, className }: EmptyStateProps): ReactNode;
46
+ //# sourceMappingURL=feedback.d.ts.map
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn, part } from "../utils.js";
3
+ /** A compact status/count label. */
4
+ export function Badge({ children, intent = 'neutral', className }) {
5
+ return (_jsx("span", { ...part('badge', 'root'), className: cn('snap-badge', className), "data-intent": intent, children: children }));
6
+ }
7
+ /** A status light with a separate halo part for breathing/glow skins. */
8
+ export function Led({ tone = 'neutral', label, className }) {
9
+ return (_jsx("span", { ...part('led', 'root'), className: cn('snap-led', className), "data-tone": tone, "aria-label": label, role: label !== undefined ? 'img' : undefined, children: _jsx("span", { ...part('led', 'halo'), "aria-hidden": "true" }) }));
10
+ }
11
+ /** A linear progress indicator. */
12
+ export function Progress({ value, label, className }) {
13
+ const clamped = value === null ? null : Math.min(1, Math.max(0, value));
14
+ return (_jsx("div", { ...part('progress', 'root'), className: cn('snap-progress', className), role: "progressbar", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": 100, ...clamped !== null ? { 'aria-valuenow': Math.round(clamped * 100) } : {}, "data-indeterminate": clamped === null || undefined, children: _jsx("div", { ...part('progress', 'track'), className: "snap-progress-track", children: _jsx("div", { ...part('progress', 'indicator'), className: "snap-progress-indicator", style: clamped === null ? undefined : { width: `${Math.round(clamped * 100)}%` } }) }) }));
15
+ }
16
+ /** A centered empty/zero-state block. */
17
+ export function EmptyState({ title, description, icon, action, className }) {
18
+ return (_jsxs("div", { ...part('empty-state', 'root'), className: cn('snap-empty-state', className), children: [icon !== undefined && _jsx("div", { ...part('empty-state', 'icon'), children: icon }), _jsx("div", { ...part('empty-state', 'title'), children: title }), description !== undefined && _jsx("div", { ...part('empty-state', 'description'), children: description }), action !== undefined && _jsx("div", { ...part('empty-state', 'action'), children: action })] }));
19
+ }
20
+ //# sourceMappingURL=feedback.js.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Form semantics: a field owns its label/control/help/error anatomy; a form
3
+ * owns its fields/actions regions. Validation stays with the page (or a
4
+ * schema renderer); the parts carry `data-invalid` for the skin.
5
+ *
6
+ * @module @snap-rail/ui/components/form
7
+ */
8
+ import type { FormEvent, ReactNode } from 'react';
9
+ /** Props of {@link Field}. */
10
+ export interface FieldProps {
11
+ label?: ReactNode;
12
+ htmlFor?: string;
13
+ help?: ReactNode;
14
+ error?: ReactNode;
15
+ invalid?: boolean;
16
+ required?: boolean;
17
+ children: ReactNode;
18
+ className?: string;
19
+ }
20
+ /** A labelled form row. */
21
+ export declare function Field({ label, htmlFor, help, error, invalid, required, children, className, }: FieldProps): ReactNode;
22
+ /** Props of {@link Form}. */
23
+ export interface FormProps {
24
+ children?: ReactNode;
25
+ actions?: ReactNode;
26
+ onSubmit?: (event: FormEvent<HTMLFormElement>) => void;
27
+ className?: string;
28
+ }
29
+ /** A form with a fields region and an actions region. */
30
+ export declare function Form({ children, actions, onSubmit, className }: FormProps): ReactNode;
31
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn, part } from "../utils.js";
3
+ import { Label } from "./controls.js";
4
+ /** A labelled form row. */
5
+ export function Field({ label, htmlFor, help, error, invalid = false, required = false, children, className, }) {
6
+ const bad = invalid || error !== undefined;
7
+ return (_jsxs("div", { ...part('field', 'root'), className: cn('snap-field', className), "data-invalid": bad || undefined, "data-required": required || undefined, children: [label !== undefined && (_jsxs(Label, { ...htmlFor !== undefined ? { htmlFor } : {}, ...part('field', 'label'), children: [label, required && _jsx("span", { "aria-hidden": "true", children: " *" })] })), _jsx("div", { ...part('field', 'control'), children: children }), help !== undefined && error === undefined && _jsx("div", { ...part('field', 'help'), className: "snap-field-help", children: help }), error !== undefined && _jsx("div", { ...part('field', 'error'), className: "snap-field-error", role: "alert", children: error })] }));
8
+ }
9
+ /** A form with a fields region and an actions region. */
10
+ export function Form({ children, actions, onSubmit, className }) {
11
+ return (_jsxs("form", { ...part('form', 'root'), className: cn('snap-form', className), onSubmit: onSubmit, children: [_jsx("div", { ...part('form', 'fields'), className: "snap-form-fields", children: children }), actions !== undefined && _jsx("div", { ...part('form', 'actions'), className: "snap-form-actions", children: actions })] }));
12
+ }
13
+ //# sourceMappingURL=form.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The semantic component set. Pages import from here; skins style the parts.
3
+ *
4
+ * @module @snap-rail/ui/components
5
+ */
6
+ export * from './button.tsx';
7
+ export * from './controls.tsx';
8
+ export * from './dialog.tsx';
9
+ export * from './feedback.tsx';
10
+ export * from './form.tsx';
11
+ export * from './input.tsx';
12
+ export * from './layout.tsx';
13
+ export * from './schema-form.tsx';
14
+ export * from './surface.tsx';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The semantic component set. Pages import from here; skins style the parts.
3
+ *
4
+ * @module @snap-rail/ui/components
5
+ */
6
+ export * from "./button.js";
7
+ export * from "./controls.js";
8
+ export * from "./dialog.js";
9
+ export * from "./feedback.js";
10
+ export * from "./form.js";
11
+ export * from "./input.js";
12
+ export * from "./layout.js";
13
+ export * from "./schema-form.js";
14
+ export * from "./surface.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Text-entry semantics: the wrapper owns the anatomy (prefix/suffix/clear),
3
+ * the native field keeps keyboard and IME behaviour. Skins style the parts.
4
+ *
5
+ * @module @snap-rail/ui/components/input
6
+ */
7
+ import type { ComponentPropsWithoutRef, ReactNode } from 'react';
8
+ /** The control size shared by single-line inputs. */
9
+ export type InputSize = 'sm' | 'md' | 'lg';
10
+ /** Props of {@link Input}. */
11
+ export interface InputProps extends Omit<ComponentPropsWithoutRef<'input'>, 'size' | 'prefix'> {
12
+ size?: InputSize;
13
+ invalid?: boolean;
14
+ prefix?: ReactNode;
15
+ suffix?: ReactNode;
16
+ onClear?: (() => void) | undefined;
17
+ /** Internal anatomy name so NumberInput can reuse the field. */
18
+ componentName?: 'input' | 'number-input';
19
+ }
20
+ /** A single-line text field with semantic prefix/suffix slots. Layout
21
+ * `style`/`className` dress the wrapper — the visible control; the native
22
+ * field already stretches inside it. */
23
+ export declare function Input({ size, invalid, prefix, suffix, onClear, componentName, className, style, disabled, ...props }: InputProps): ReactNode;
24
+ /** Props of {@link Textarea}. */
25
+ export interface TextareaProps extends Omit<ComponentPropsWithoutRef<'textarea'>, 'size'> {
26
+ size?: InputSize;
27
+ invalid?: boolean;
28
+ }
29
+ /** A multi-line text field. Like {@link Input}, layout `style`/`className`
30
+ * dress the wrapper; the field stretches inside it. */
31
+ export declare function Textarea({ size, invalid, className, style, disabled, ...props }: TextareaProps): ReactNode;
32
+ /** Props of {@link NumberInput}. */
33
+ export interface NumberInputProps extends Omit<InputProps, 'type' | 'prefix' | 'suffix' | 'onClear'> {
34
+ min?: number;
35
+ max?: number;
36
+ step?: number;
37
+ }
38
+ /** A numeric field with the numeric keyboard hint and native stepping. */
39
+ export declare function NumberInput({ min, max, step, ...props }: NumberInputProps): ReactNode;
40
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn, part } from "../utils.js";
3
+ /** A single-line text field with semantic prefix/suffix slots. Layout
4
+ * `style`/`className` dress the wrapper — the visible control; the native
5
+ * 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: "snap-input-field", 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
+ }
9
+ /** A multi-line text field. Like {@link Input}, layout `style`/`className`
10
+ * 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: "snap-textarea-field", disabled: disabled, "aria-invalid": invalid || undefined, ...props }) }));
13
+ }
14
+ /** A numeric field with the numeric keyboard hint and native stepping. */
15
+ export function NumberInput({ min, max, step, ...props }) {
16
+ return (_jsx(Input, { ...props, componentName: "number-input", type: "number", inputMode: "decimal", ...min !== undefined ? { min } : {}, ...max !== undefined ? { max } : {}, ...step !== undefined ? { step } : {} }));
17
+ }
18
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Semantic layout primitives. Pages compose these instead of raw flex/grid
3
+ * utility classes; the structural rules are inline (so layout survives
4
+ * without a skin) while spacing/density values ride skin tokens.
5
+ *
6
+ * @module @snap-rail/ui/components/layout
7
+ */
8
+ import type { CSSProperties, ReactNode } from 'react';
9
+ /** A spacing token. */
10
+ export type SpaceToken = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
11
+ /** Shared layout props. */
12
+ export interface LayoutProps {
13
+ children?: ReactNode;
14
+ className?: string;
15
+ style?: CSSProperties;
16
+ }
17
+ /** Props of {@link Stack}. */
18
+ export interface StackProps extends LayoutProps {
19
+ gap?: SpaceToken;
20
+ padding?: SpaceToken;
21
+ align?: CSSProperties['alignItems'];
22
+ }
23
+ /** A vertical flow. */
24
+ export declare function Stack({ gap, padding, align, className, style, children }: StackProps): ReactNode;
25
+ /** Props of {@link Row}. */
26
+ export interface RowProps extends LayoutProps {
27
+ gap?: SpaceToken;
28
+ padding?: SpaceToken;
29
+ align?: CSSProperties['alignItems'];
30
+ justify?: CSSProperties['justifyContent'];
31
+ wrap?: boolean;
32
+ }
33
+ /** A horizontal flow. */
34
+ export declare function Row({ gap, padding, align, justify, wrap, className, style, children }: RowProps): ReactNode;
35
+ /** Props of {@link Grid}. */
36
+ export interface GridProps extends LayoutProps {
37
+ gap?: SpaceToken;
38
+ padding?: SpaceToken;
39
+ /** A fixed column count or any CSS grid-template-columns value. */
40
+ columns?: number | string;
41
+ minColumnWidth?: string;
42
+ }
43
+ /** A responsive grid. */
44
+ export declare function Grid({ gap, padding, columns, minColumnWidth, className, style, children }: GridProps): ReactNode;
45
+ /** Props of {@link Split}. */
46
+ export interface SplitProps extends LayoutProps {
47
+ start: ReactNode;
48
+ end: ReactNode;
49
+ gap?: SpaceToken;
50
+ /** The start column's share; defaults to a stable 2:3 split. */
51
+ ratio?: string;
52
+ }
53
+ /** A two-pane split (sidebar + content, list + detail). */
54
+ export declare function Split({ start, end, gap, ratio, className, style }: SplitProps): ReactNode;
55
+ /** Props of {@link AppShell}. */
56
+ export interface AppShellProps extends LayoutProps {
57
+ header?: ReactNode;
58
+ sidebar?: ReactNode;
59
+ footer?: ReactNode;
60
+ }
61
+ /** The operator-window shell frame. */
62
+ export declare function AppShell({ header, sidebar, footer, className, style, children }: AppShellProps): ReactNode;
63
+ /** Props of {@link Page}. */
64
+ export interface PageProps extends LayoutProps {
65
+ header?: ReactNode;
66
+ actions?: ReactNode;
67
+ title?: ReactNode;
68
+ /** Controls that belong to the title itself; rendered right beside it,
69
+ * before the far-aligned `actions`. */
70
+ titleExtra?: ReactNode;
71
+ description?: ReactNode;
72
+ }
73
+ /** A page body with its own header/actions anatomy. */
74
+ export declare function Page({ header, actions, title, titleExtra, description, className, style, children }: PageProps): ReactNode;
75
+ /** Props of {@link Section}. */
76
+ export interface SectionProps extends LayoutProps {
77
+ title?: ReactNode;
78
+ description?: ReactNode;
79
+ actions?: ReactNode;
80
+ }
81
+ /** A titled content section. */
82
+ export declare function Section({ title, description, actions, className, style, children }: SectionProps): ReactNode;
83
+ /** Props of {@link Toolbar}. */
84
+ export interface ToolbarProps extends LayoutProps {
85
+ start?: ReactNode;
86
+ end?: ReactNode;
87
+ }
88
+ /** A compact action bar. */
89
+ export declare function Toolbar({ start, end, className, style }: ToolbarProps): ReactNode;
90
+ /** Props of {@link ScrollArea}. */
91
+ export interface ScrollAreaProps extends LayoutProps {
92
+ /** `vertical`, `horizontal`, or `both`. */
93
+ direction?: 'vertical' | 'horizontal' | 'both';
94
+ }
95
+ /** A native scroll container with a stable anatomy. */
96
+ export declare function ScrollArea({ direction, className, style, children }: ScrollAreaProps): ReactNode;
97
+ /** Props of {@link DragScroll}. */
98
+ export interface DragScrollProps extends LayoutProps {
99
+ direction?: 'vertical' | 'horizontal' | 'both';
100
+ }
101
+ /** A touch-friendly scroll container; pointer dragging pans the viewport. */
102
+ export declare function DragScroll({ direction, className, style, children }: DragScrollProps): ReactNode;
103
+ //# sourceMappingURL=layout.d.ts.map