@snap-rail/ui 0.2.0 → 0.3.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.
@@ -11,12 +11,12 @@ import { cn, part } from "../utils.js";
11
11
  * `style`/`className` dress the wrapper — the visible control; the native
12
12
  * field already stretches inside it. */
13
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 })] }));
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", { className: cn('snap-input-field', fieldClassName), disabled: disabled, "aria-invalid": invalid || undefined, ...props, ...part(componentName, 'field') }), 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 })] }));
15
15
  }
16
16
  /** A multi-line text field. Like {@link Input}, layout `style`/`className`
17
17
  * dress the wrapper; the field stretches inside it. */
18
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 }) }));
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", { className: cn('snap-textarea-field', fieldClassName), disabled: disabled, "aria-invalid": invalid || undefined, ...props, ...part('textarea', 'field') }) }));
20
20
  }
21
21
  /** A numeric field with touch steppers: `step-up`/`step-down` commit through
22
22
  * the normal `onChange` (a native input event on the field), clamped to
@@ -40,6 +40,6 @@ export function NumberInput({ min, max, step = 1, size = 'md', invalid = false,
40
40
  setter?.call(field, String(next));
41
41
  field.dispatchEvent(new Event('input', { bubbles: true }));
42
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" })] })] }));
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, 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, ...part('number-input', 'field') }), _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" })] })] }));
44
44
  }
45
45
  //# sourceMappingURL=input.js.map
@@ -39,9 +39,24 @@ export interface PopoverContentProps extends ComponentPropsWithoutRef<typeof Pop
39
39
  side?: 'top' | 'right' | 'bottom' | 'left';
40
40
  align?: 'start' | 'center' | 'end';
41
41
  sideOffset?: number;
42
+ /** Overrides the open-focus heuristic. Default: a panel opened from an
43
+ * editable element (anchored combobox typing into a field) keeps the focus
44
+ * in it; otherwise the panel takes focus as Radix does. `false` never
45
+ * moves focus into the panel, `true` always lets the FocusScope run. */
46
+ autoFocusOnOpen?: boolean;
42
47
  }
43
- /** The portalled popover panel. */
44
- export declare function PopoverContent({ side, align, sideOffset, className, children, ...props }: PopoverContentProps): ReactNode;
48
+ /**
49
+ * The portalled popover panel, with the two focus dead ends Radix leaves
50
+ * open in anchored mode: on open, the FocusScope default steals the focus
51
+ * from the field a combobox is typing into; on close, the default handler
52
+ * focuses the trigger ref — which is `null` without a `PopoverTrigger`, so
53
+ * focus strands on `body` and every keystroke dies. The wrapper remembers
54
+ * the element that opened the panel and returns focus there; when that
55
+ * element is editable it also keeps the focus in it while the panel is
56
+ * open. Trigger-mode popovers behave exactly as Radix does (the opener IS
57
+ * the trigger).
58
+ */
59
+ export declare function PopoverContent({ side, align, sideOffset, autoFocusOnOpen, className, children, onOpenAutoFocus, onCloseAutoFocus, onInteractOutside, ...props }: PopoverContentProps): ReactNode;
45
60
  /** The dropdown menu root. */
46
61
  export declare const Menu: import("react").FC<DropdownMenuPrimitive.DropdownMenuProps>;
47
62
  /** The menu trigger; wraps its child and toggles the dropdown. */
@@ -12,7 +12,7 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
12
12
  import * as PopoverPrimitive from '@radix-ui/react-popover';
13
13
  import * as ToastPrimitive from '@radix-ui/react-toast';
14
14
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
15
- import { useSyncExternalStore, } from 'react';
15
+ import { useRef, useSyncExternalStore, } from 'react';
16
16
  import { cn, part } from "../utils.js";
17
17
  /* ------------------------------------------------------------------ Tooltip */
18
18
  /** The tooltip root; wraps `TooltipTrigger`/`TooltipContent` and owns delay. */
@@ -25,18 +25,18 @@ export function TooltipProvider(props) {
25
25
  }
26
26
  /** The tooltip trigger; wraps its child and anchors the bubble. */
27
27
  export function TooltipTrigger(props) {
28
- return _jsx(TooltipPrimitive.Trigger, { ...part('tooltip', 'trigger'), ...props });
28
+ return _jsx(TooltipPrimitive.Trigger, { ...props, ...part('tooltip', 'trigger') });
29
29
  }
30
30
  /** The portalled tooltip bubble. */
31
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 }) }));
32
+ return (_jsx(TooltipPrimitive.Portal, { children: _jsx(TooltipPrimitive.Content, { className: cn('snap-tooltip', className), side: side, sideOffset: sideOffset, ...props, ...part('tooltip', 'content'), children: children }) }));
33
33
  }
34
34
  /* ------------------------------------------------------------------ Popover */
35
35
  /** The popover root. */
36
36
  export const Popover = PopoverPrimitive.Root;
37
37
  /** The popover trigger; wraps its child and toggles the panel. */
38
38
  export function PopoverTrigger(props) {
39
- return _jsx(PopoverPrimitive.Trigger, { ...part('popover', 'trigger'), ...props });
39
+ return _jsx(PopoverPrimitive.Trigger, { ...props, ...part('popover', 'trigger') });
40
40
  }
41
41
  /** An element the panel positions against without toggling it. */
42
42
  export const PopoverAnchor = PopoverPrimitive.Anchor;
@@ -44,32 +44,79 @@ export const PopoverAnchor = PopoverPrimitive.Anchor;
44
44
  export function PopoverClose(props) {
45
45
  return _jsx(PopoverPrimitive.Close, { ...props });
46
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 }) }));
47
+ /** Whether the element can hold a text caret (the anchored-combobox opener). */
48
+ function isEditableElement(element) {
49
+ if (element === null || !(element instanceof HTMLElement))
50
+ return false;
51
+ return element.tagName === 'INPUT' || element.tagName === 'TEXTAREA' || element.isContentEditable;
52
+ }
53
+ /**
54
+ * The portalled popover panel, with the two focus dead ends Radix leaves
55
+ * open in anchored mode: on open, the FocusScope default steals the focus
56
+ * from the field a combobox is typing into; on close, the default handler
57
+ * focuses the trigger ref — which is `null` without a `PopoverTrigger`, so
58
+ * focus strands on `body` and every keystroke dies. The wrapper remembers
59
+ * the element that opened the panel and returns focus there; when that
60
+ * element is editable it also keeps the focus in it while the panel is
61
+ * open. Trigger-mode popovers behave exactly as Radix does (the opener IS
62
+ * the trigger).
63
+ */
64
+ export function PopoverContent({ side = 'bottom', align = 'center', sideOffset = 6, autoFocusOnOpen, className, children, onOpenAutoFocus, onCloseAutoFocus, onInteractOutside, ...props }) {
65
+ const openerRef = useRef(null);
66
+ const interactedOutsideRef = useRef(false);
67
+ const handleOpenAutoFocus = (event) => {
68
+ // Radix dispatches this while the opener still holds focus; record it
69
+ // before anything can move focus — the close path returns to it.
70
+ openerRef.current = document.activeElement;
71
+ interactedOutsideRef.current = false;
72
+ onOpenAutoFocus?.(event);
73
+ if (event.defaultPrevented)
74
+ return;
75
+ const exempt = autoFocusOnOpen === false
76
+ || (autoFocusOnOpen === undefined && isEditableElement(openerRef.current));
77
+ if (exempt)
78
+ event.preventDefault();
79
+ };
80
+ const handleCloseAutoFocus = (event) => {
81
+ onCloseAutoFocus?.(event);
82
+ if (event.defaultPrevented)
83
+ return;
84
+ if (interactedOutsideRef.current)
85
+ return;
86
+ const opener = openerRef.current;
87
+ if (opener !== null && opener !== document.body && opener.isConnected) {
88
+ event.preventDefault();
89
+ opener.focus({ preventScroll: true });
90
+ }
91
+ };
92
+ const handleInteractOutside = (event) => {
93
+ interactedOutsideRef.current = true;
94
+ onInteractOutside?.(event);
95
+ };
96
+ return (_jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { className: cn('snap-popover', className), side: side, align: align, sideOffset: sideOffset, onOpenAutoFocus: handleOpenAutoFocus, onCloseAutoFocus: handleCloseAutoFocus, onInteractOutside: handleInteractOutside, ...props, ...part('popover', 'content'), children: children }) }));
50
97
  }
51
98
  /* -------------------------------------------------------------------- Menu */
52
99
  /** The dropdown menu root. */
53
100
  export const Menu = DropdownMenuPrimitive.Root;
54
101
  /** The menu trigger; wraps its child and toggles the dropdown. */
55
102
  export function MenuTrigger(props) {
56
- return _jsx(DropdownMenuPrimitive.Trigger, { ...part('menu', 'trigger'), ...props });
103
+ return _jsx(DropdownMenuPrimitive.Trigger, { ...props, ...part('menu', 'trigger') });
57
104
  }
58
105
  /** The portalled dropdown list. */
59
106
  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 }) }));
107
+ return (_jsx(DropdownMenuPrimitive.Portal, { children: _jsx(DropdownMenuPrimitive.Content, { className: cn('snap-menu', className), side: side, align: align, sideOffset: sideOffset, ...props, ...part('menu', 'content'), children: children }) }));
61
108
  }
62
109
  /** One menu action. */
63
110
  export function MenuItem({ className, children, ...props }) {
64
- return (_jsx(DropdownMenuPrimitive.Item, { ...part('menu', 'item'), className: cn('snap-menu-item', className), ...props, children: children }));
111
+ return (_jsx(DropdownMenuPrimitive.Item, { className: cn('snap-menu-item', className), ...props, ...part('menu', 'item'), children: children }));
65
112
  }
66
113
  /** A checkable menu action with an indicator slot. */
67
114
  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] }));
115
+ return (_jsxs(DropdownMenuPrimitive.CheckboxItem, { className: cn('snap-menu-item', className), ...props, ...part('menu', 'checkbox-item'), children: [_jsx(DropdownMenuPrimitive.ItemIndicator, { ...part('menu', 'item-indicator'), className: "snap-menu-indicator", children: "\u2713" }), children] }));
69
116
  }
70
117
  /** A non-interactive group heading. */
71
118
  export function MenuLabel({ className, children, ...props }) {
72
- return _jsx(DropdownMenuPrimitive.Label, { className: cn('snap-menu-label', className), ...props, children: children });
119
+ return _jsx(DropdownMenuPrimitive.Label, { className: cn('snap-menu-label', className), ...props, ...part('menu', 'label'), children: children });
73
120
  }
74
121
  /** A group container for items. */
75
122
  export function MenuGroup(props) {
@@ -77,7 +124,7 @@ export function MenuGroup(props) {
77
124
  }
78
125
  /** A horizontal rule between menu sections. */
79
126
  export function MenuSeparator({ className, ...props }) {
80
- return _jsx(DropdownMenuPrimitive.Separator, { ...part('menu', 'separator'), className: cn('snap-menu-separator', className), ...props });
127
+ return _jsx(DropdownMenuPrimitive.Separator, { className: cn('snap-menu-separator', className), ...props, ...part('menu', 'separator') });
81
128
  }
82
129
  let toastNextId = 1;
83
130
  let toastRecords = [];
@@ -117,22 +164,22 @@ export function Toaster(props) {
117
164
  export const Toast = ToastPrimitive.Root;
118
165
  /** A toast title with its part tag. */
119
166
  export function ToastTitle({ className, children, ...props }) {
120
- return _jsx(ToastPrimitive.Title, { ...part('toast', 'title'), className: cn('snap-toast-title', className), ...props, children: children });
167
+ return _jsx(ToastPrimitive.Title, { className: cn('snap-toast-title', className), ...props, ...part('toast', 'title'), children: children });
121
168
  }
122
169
  /** A toast description with its part tag. */
123
170
  export function ToastDescription({ className, children, ...props }) {
124
- return _jsx(ToastPrimitive.Description, { ...part('toast', 'description'), className: cn('snap-toast-description', className), ...props, children: children });
171
+ return _jsx(ToastPrimitive.Description, { className: cn('snap-toast-description', className), ...props, ...part('toast', 'description'), children: children });
125
172
  }
126
173
  /** An interactive toast action (confirm/retry affordances). */
127
174
  export function ToastAction({ className, children, ...props }) {
128
- return _jsx(ToastPrimitive.Action, { ...part('toast', 'action'), className: cn('snap-toast-action', className), ...props, children: children });
175
+ return _jsx(ToastPrimitive.Action, { className: cn('snap-toast-action', className), ...props, ...part('toast', 'action'), children: children });
129
176
  }
130
177
  /** A toast dismissal button. */
131
178
  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" }) });
179
+ return _jsx(ToastPrimitive.Close, { className: cn('snap-toast-close', className), ...props, ...part('toast', 'close'), children: children ?? _jsx("span", { "aria-hidden": "true", children: "\u00D7" }) });
133
180
  }
134
181
  /** The toast viewport; only the runtime's {@link Toaster} mounts one. */
135
182
  export function ToastViewport({ className, ...props }) {
136
- return _jsx(ToastPrimitive.Viewport, { ...part('toast', 'viewport'), className: cn('snap-toast-viewport', className), ...props });
183
+ return _jsx(ToastPrimitive.Viewport, { className: cn('snap-toast-viewport', className), ...props, ...part('toast', 'viewport') });
137
184
  }
138
185
  //# sourceMappingURL=overlay.js.map
@@ -10,6 +10,6 @@ import * as SliderPrimitive from '@radix-ui/react-slider';
10
10
  import { cn, part } from "../utils.js";
11
11
  /** A ranged control with a large touch target and keyboard stepping. */
12
12
  export function Slider({ label, className, children, ...props }) {
13
- return (_jsxs(SliderPrimitive.Root, { ...part('slider', 'root'), className: cn('snap-slider', className), "aria-label": label, ...props, children: [_jsx(SliderPrimitive.Track, { ...part('slider', 'track'), className: "snap-slider-track", children: _jsx(SliderPrimitive.Range, { ...part('slider', 'range'), className: "snap-slider-range" }) }), _jsx(SliderPrimitive.Thumb, { ...part('slider', 'thumb'), className: "snap-slider-thumb", "aria-label": label }), children] }));
13
+ return (_jsxs(SliderPrimitive.Root, { className: cn('snap-slider', className), "aria-label": label, ...props, ...part('slider', 'root'), children: [_jsx(SliderPrimitive.Track, { ...part('slider', 'track'), className: "snap-slider-track", children: _jsx(SliderPrimitive.Range, { ...part('slider', 'range'), className: "snap-slider-range" }) }), _jsx(SliderPrimitive.Thumb, { ...part('slider', 'thumb'), className: "snap-slider-thumb", "aria-label": label }), children] }));
14
14
  }
15
15
  //# sourceMappingURL=slider.js.map
@@ -2,31 +2,31 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn, part } from "../utils.js";
3
3
  /** A content card. */
4
4
  export function Card({ className, children, ...props }) {
5
- return _jsx("div", { ...part('card', 'root'), className: cn('snap-card', className), ...props, children: children });
5
+ return _jsx("div", { className: cn('snap-card', className), ...props, ...part('card', 'root'), children: children });
6
6
  }
7
7
  /** The card header region. */
8
8
  export function CardHeader({ className, children, ...props }) {
9
- return _jsx("div", { ...part('card', 'header'), className: cn('snap-card-header', className), ...props, children: children });
9
+ return _jsx("div", { className: cn('snap-card-header', className), ...props, ...part('card', 'header'), children: children });
10
10
  }
11
11
  /** The card title. */
12
12
  export function CardTitle({ className, children, ...props }) {
13
- return _jsx("div", { ...part('card', 'title'), className: cn('snap-card-title', className), ...props, children: children });
13
+ return _jsx("div", { className: cn('snap-card-title', className), ...props, ...part('card', 'title'), children: children });
14
14
  }
15
15
  /** The card description. */
16
16
  export function CardDescription({ className, children, ...props }) {
17
- return _jsx("div", { ...part('card', 'description'), className: cn('snap-card-description', className), ...props, children: children });
17
+ return _jsx("div", { className: cn('snap-card-description', className), ...props, ...part('card', 'description'), children: children });
18
18
  }
19
19
  /** The card body. */
20
20
  export function CardContent({ className, children, ...props }) {
21
- return _jsx("div", { ...part('card', 'body'), className: cn('snap-card-content', className), ...props, children: children });
21
+ return _jsx("div", { className: cn('snap-card-content', className), ...props, ...part('card', 'body'), children: children });
22
22
  }
23
23
  /** The card footer. */
24
24
  export function CardFooter({ className, children, ...props }) {
25
- return _jsx("div", { ...part('card', 'footer'), className: cn('snap-card-footer', className), ...props, children: children });
25
+ return _jsx("div", { className: cn('snap-card-footer', className), ...props, ...part('card', 'footer'), children: children });
26
26
  }
27
27
  /** A bounded panel with optional header/footer. */
28
28
  export function Panel({ title, actions, footer, className, children, ...props }) {
29
- return (_jsxs("div", { ...part('panel', 'root'), className: cn('snap-panel', className), ...props, children: [(title !== undefined || actions !== undefined) && (_jsxs("div", { ...part('panel', 'header'), className: "snap-panel-header", children: [_jsx("div", { ...part('panel', 'title'), children: title }), actions !== undefined && _jsx("div", { children: actions })] })), _jsx("div", { ...part('panel', 'body'), className: "snap-panel-body", children: children }), footer !== undefined && _jsx("div", { ...part('panel', 'footer'), className: "snap-panel-footer", children: footer })] }));
29
+ return (_jsxs("div", { className: cn('snap-panel', className), ...props, ...part('panel', 'root'), children: [(title !== undefined || actions !== undefined) && (_jsxs("div", { ...part('panel', 'header'), className: "snap-panel-header", children: [_jsx("div", { ...part('panel', 'title'), children: title }), actions !== undefined && _jsx("div", { children: actions })] })), _jsx("div", { ...part('panel', 'body'), className: "snap-panel-body", children: children }), footer !== undefined && _jsx("div", { ...part('panel', 'footer'), className: "snap-panel-footer", children: footer })] }));
30
30
  }
31
31
  /** A semantic table. */
32
32
  export function Table({ className, children, ...props }) {
@@ -34,23 +34,23 @@ export function Table({ className, children, ...props }) {
34
34
  }
35
35
  /** The table head. */
36
36
  export function TableHeader({ className, children, ...props }) {
37
- return _jsx("thead", { ...part('table', 'header'), className: cn('snap-table-header', className), ...props, children: children });
37
+ return _jsx("thead", { className: cn('snap-table-header', className), ...props, ...part('table', 'header'), children: children });
38
38
  }
39
39
  /** The table body. */
40
40
  export function TableBody({ className, children, ...props }) {
41
- return _jsx("tbody", { ...part('table', 'body'), className: cn('snap-table-body', className), ...props, children: children });
41
+ return _jsx("tbody", { className: cn('snap-table-body', className), ...props, ...part('table', 'body'), children: children });
42
42
  }
43
43
  /** A table row. */
44
44
  export function TableRow({ className, children, ...props }) {
45
- return _jsx("tr", { ...part('table', 'row'), className: cn('snap-table-row', className), ...props, children: children });
45
+ return _jsx("tr", { className: cn('snap-table-row', className), ...props, ...part('table', 'row'), children: children });
46
46
  }
47
47
  /** A table header cell. */
48
48
  export function TableHead({ className, children, ...props }) {
49
- return _jsx("th", { ...part('table', 'head'), className: cn('snap-table-head', className), ...props, children: children });
49
+ return _jsx("th", { className: cn('snap-table-head', className), ...props, ...part('table', 'head'), children: children });
50
50
  }
51
51
  /** A table body cell. */
52
52
  export function TableCell({ className, children, ...props }) {
53
- return _jsx("td", { ...part('table', 'cell'), className: cn('snap-table-cell', className), ...props, children: children });
53
+ return _jsx("td", { className: cn('snap-table-cell', className), ...props, ...part('table', 'cell'), children: children });
54
54
  }
55
55
  /** A full-width empty row. */
56
56
  export function TableEmpty({ colSpan, children }) {
@@ -204,9 +204,14 @@ export declare const UI_COMPONENTS: {
204
204
  readonly props: readonly ["size", "invalid", "disabled", "defaultValue", "side", "align"];
205
205
  };
206
206
  readonly 'touch-select': {
207
- readonly parts: readonly ["touch-select.root", "touch-select.trigger", "touch-select.sheet", "touch-select.option"];
207
+ readonly parts: readonly ["touch-select.root", "touch-select.trigger", "touch-select.sheet", "touch-select.options"];
208
208
  readonly props: readonly ["invalid", "disabled"];
209
209
  };
210
+ readonly combobox: {
211
+ readonly parts: readonly ["combobox.root", "combobox.anchor", "combobox.list", "combobox.option", "combobox.empty"];
212
+ readonly slots: readonly ["empty"];
213
+ readonly props: readonly ["value", "options", "size", "invalid", "disabled", "loading", "onInputValueChange"];
214
+ };
210
215
  readonly checkbox: {
211
216
  readonly parts: readonly ["checkbox.root", "checkbox.indicator", "checkbox.label", "checkbox.field", "checkbox.description"];
212
217
  readonly slots: readonly ["label", "description"];
@@ -92,9 +92,14 @@ export const UI_COMPONENTS = {
92
92
  props: ['size', 'invalid', 'disabled', 'defaultValue', 'side', 'align'],
93
93
  },
94
94
  'touch-select': {
95
- parts: ['touch-select.root', 'touch-select.trigger', 'touch-select.sheet', 'touch-select.option'],
95
+ parts: ['touch-select.root', 'touch-select.trigger', 'touch-select.sheet', 'touch-select.options'],
96
96
  props: ['invalid', 'disabled'],
97
97
  },
98
+ combobox: {
99
+ parts: ['combobox.root', 'combobox.anchor', 'combobox.list', 'combobox.option', 'combobox.empty'],
100
+ slots: ['empty'],
101
+ props: ['value', 'options', 'size', 'invalid', 'disabled', 'loading', 'onInputValueChange'],
102
+ },
98
103
  checkbox: {
99
104
  parts: ['checkbox.root', 'checkbox.indicator', 'checkbox.label', 'checkbox.field', 'checkbox.description'],
100
105
  slots: ['label', 'description'],
@@ -6,7 +6,13 @@
6
6
  */
7
7
  /** Join truthy class names. */
8
8
  export declare function cn(...values: ReadonlyArray<string | false | null | undefined>): string;
9
- /** The anatomy attributes every semantic component renders. */
9
+ /**
10
+ * The anatomy attributes every semantic component renders. The identity is
11
+ * component-owned: components spread these AFTER caller props so a composite
12
+ * can never mask a host part (a masked `button.root` loses every skin rule
13
+ * and falls back to the UA default look). Composites tag their own wrappers
14
+ * instead of pushing `part()` into a child component's props.
15
+ */
10
16
  export declare function part(component: string, name: string): Record<string, string>;
11
17
  /** Map a semantic size token to a control-height CSS variable. */
12
18
  export declare function controlHeight(size: 'sm' | 'md' | 'lg'): string;
@@ -8,7 +8,13 @@
8
8
  export function cn(...values) {
9
9
  return values.filter((value) => typeof value === 'string' && value.length > 0).join(' ');
10
10
  }
11
- /** The anatomy attributes every semantic component renders. */
11
+ /**
12
+ * The anatomy attributes every semantic component renders. The identity is
13
+ * component-owned: components spread these AFTER caller props so a composite
14
+ * can never mask a host part (a masked `button.root` loses every skin rule
15
+ * and falls back to the UA default look). Composites tag their own wrappers
16
+ * instead of pushing `part()` into a child component's props.
17
+ */
12
18
  export function part(component, name) {
13
19
  return {
14
20
  'data-snap-component': component,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snap-rail/ui",
3
3
  "description": "The built-in UI substrate: semantic components, typed region slots, skins, settings and renderer runtime",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -86,8 +86,8 @@
86
86
  "zod": "^4.4.3",
87
87
  "@snap-rail/connection": "^0.1.0",
88
88
  "@snap-rail/cordis": "^4.0.3",
89
- "@snap-rail/protocol": "^0.1.3",
90
- "@snap-rail/shell": "^0.2.3"
89
+ "@snap-rail/shell": "^0.2.4",
90
+ "@snap-rail/protocol": "^0.1.3"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@types/react": "^19.2.14",
@@ -99,14 +99,14 @@
99
99
  "typescript": "^6.0.3",
100
100
  "vitest": "^4.1.8",
101
101
  "zod": "^4.4.3",
102
+ "@snap-rail/client-kernel": "^0.1.2",
102
103
  "@snap-rail/connection": "^0.1.0",
103
104
  "@snap-rail/cordis": "^4.0.3",
104
- "@snap-rail/app-boot": "^0.1.3",
105
105
  "@snap-rail/cordis-plugin-timer": "^1.1.3",
106
- "@snap-rail/client-kernel": "^0.1.2",
106
+ "@snap-rail/app-boot": "^0.1.3",
107
107
  "@snap-rail/protocol": "^0.1.3",
108
- "@snap-rail/station-rpc": "^0.1.0",
109
- "@snap-rail/shell": "^0.2.3"
108
+ "@snap-rail/shell": "^0.2.4",
109
+ "@snap-rail/station-rpc": "^0.1.0"
110
110
  },
111
111
  "snapRail": {
112
112
  "layer": "base",
@@ -178,6 +178,12 @@
178
178
  text-align: left;
179
179
  }
180
180
 
181
+ /* Headers never wrap: narrow panes get a wider scrollable table instead of
182
+ * vertically stacked glyphs. */
183
+ [data-snap-part='table.head'] {
184
+ white-space: nowrap;
185
+ }
186
+
181
187
  [data-snap-part='card.root'],
182
188
  [data-snap-part='panel.root'] {
183
189
  display: flex;
@@ -352,9 +358,31 @@
352
358
  min-height: 0;
353
359
  }
354
360
 
355
- [data-snap-component='touch-select'] {
356
- display: inline-flex;
357
- max-width: 100%;
361
+ /* TouchSelect fills its container like every other form control (the
362
+ * Input family defaults to width:100%); parts anchor the layout because
363
+ * the trigger/sheet wrappers also carry the component tag. */
364
+ [data-snap-part='touch-select.root'] {
365
+ display: flex;
366
+ width: 100%;
367
+ min-width: 0;
368
+ }
369
+
370
+ [data-snap-part='touch-select.trigger'] {
371
+ display: flex;
372
+ flex: 1;
373
+ min-width: 0;
374
+ }
375
+
376
+ [data-snap-part='touch-select.trigger'] > [data-snap-component='button'] {
377
+ width: 100%;
378
+ }
379
+
380
+ [data-snap-part='touch-select.sheet'] {
381
+ display: flex;
382
+ flex: 1;
383
+ flex-direction: column;
384
+ gap: var(--snap-space-sm);
385
+ min-height: 0;
358
386
  }
359
387
 
360
388
  [data-snap-part='radio-group.block'] {
@@ -401,6 +429,49 @@
401
429
  z-index: var(--snap-z-overlay);
402
430
  }
403
431
 
432
+ /* A popover tracks its anchor: at least as wide, wider when content asks
433
+ * (the popper exposes the anchor width as a CSS variable). */
434
+ [data-snap-part='popover.content'] {
435
+ min-width: var(--radix-popper-anchor-width);
436
+ }
437
+
438
+ [data-snap-part='combobox.root'] {
439
+ display: flex;
440
+ width: 100%;
441
+ min-width: 0;
442
+ }
443
+
444
+ [data-snap-part='combobox.anchor'] {
445
+ display: block;
446
+ flex: 1;
447
+ min-width: 0;
448
+ }
449
+
450
+ [data-snap-part='combobox.list'] {
451
+ display: flex;
452
+ flex-direction: column;
453
+ max-height: 320px;
454
+ overflow: auto;
455
+ }
456
+
457
+ [data-snap-part='combobox.option'] {
458
+ display: flex;
459
+ align-items: center;
460
+ min-height: var(--snap-control-height-md);
461
+ padding-inline: var(--snap-space-md);
462
+ cursor: pointer;
463
+ }
464
+
465
+ [data-snap-part='combobox.option'][data-disabled] {
466
+ color: var(--snap-color-muted);
467
+ cursor: default;
468
+ }
469
+
470
+ [data-snap-part='combobox.empty'] {
471
+ padding: var(--snap-space-sm) var(--snap-space-md);
472
+ color: var(--snap-color-muted);
473
+ }
474
+
404
475
  [data-snap-part='menu.item'],
405
476
  [data-snap-part='menu.checkbox-item'] {
406
477
  display: flex;
@@ -478,6 +549,7 @@
478
549
  display: flex;
479
550
  align-items: center;
480
551
  gap: var(--snap-space-sm);
552
+ padding-inline: var(--snap-space-md);
481
553
  min-height: var(--snap-control-height-md);
482
554
  min-width: 0;
483
555
  }
@@ -654,6 +654,16 @@
654
654
  background: var(--snap-color-surface-raised);
655
655
  }
656
656
 
657
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='combobox.option']:hover,
658
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='combobox.option'][data-active] {
659
+ background: var(--snap-color-surface);
660
+ }
661
+
662
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='combobox.option'][aria-selected='true'] {
663
+ background: var(--snap-color-surface-raised);
664
+ font-weight: 600;
665
+ }
666
+
657
667
  :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='list.leading'],
658
668
  :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='list.trailing'] {
659
669
  color: var(--snap-color-muted);