@cognitap/radiant 0.0.11 → 0.0.13

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 (46) hide show
  1. package/CHANGELOG.md +11 -3
  2. package/RELEASE_POLICY.md +5 -4
  3. package/dist/library/Combobox.d.ts +88 -0
  4. package/dist/library/Combobox.d.ts.map +1 -0
  5. package/dist/library/Combobox.js +365 -0
  6. package/dist/library/Combobox.js.map +1 -0
  7. package/dist/library/Select.js +1 -1
  8. package/dist/library/Select.js.map +1 -1
  9. package/dist/library/Tabs.d.ts +52 -0
  10. package/dist/library/Tabs.d.ts.map +1 -0
  11. package/dist/library/Tabs.js +234 -0
  12. package/dist/library/Tabs.js.map +1 -0
  13. package/dist/library/cn.d.ts.map +1 -1
  14. package/dist/library/cn.js +51 -14
  15. package/dist/library/cn.js.map +1 -1
  16. package/dist/library/comboboxStyles.d.ts +6 -0
  17. package/dist/library/comboboxStyles.d.ts.map +1 -0
  18. package/dist/library/comboboxStyles.js +38 -0
  19. package/dist/library/comboboxStyles.js.map +1 -0
  20. package/dist/library/index.d.ts +4 -0
  21. package/dist/library/index.d.ts.map +1 -1
  22. package/dist/library/index.js +2 -0
  23. package/dist/library/index.js.map +1 -1
  24. package/dist/library/motion/popup.js +5 -5
  25. package/dist/library/motion/popup.js.map +1 -1
  26. package/dist/library/react/useComboboxPopup.d.ts +4 -0
  27. package/dist/library/react/useComboboxPopup.d.ts.map +1 -0
  28. package/dist/library/react/useComboboxPopup.js +118 -0
  29. package/dist/library/react/useComboboxPopup.js.map +1 -0
  30. package/dist/library/styles.css +1 -1
  31. package/dist/library/themes/components.d.ts +55 -0
  32. package/dist/library/themes/components.d.ts.map +1 -1
  33. package/dist/library/themes/components.js +55 -0
  34. package/dist/library/themes/components.js.map +1 -1
  35. package/docs/architecture.md +27 -18
  36. package/docs/theming.md +1 -1
  37. package/package.json +1 -1
  38. package/src/Combobox.tsx +752 -0
  39. package/src/Select.tsx +1 -1
  40. package/src/Tabs.tsx +437 -0
  41. package/src/cn.ts +51 -14
  42. package/src/comboboxStyles.ts +41 -0
  43. package/src/index.ts +30 -0
  44. package/src/motion/popup.ts +5 -5
  45. package/src/react/useComboboxPopup.ts +130 -0
  46. package/src/themes/components.ts +55 -0
package/CHANGELOG.md CHANGED
@@ -4,17 +4,25 @@
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 0.0.13
8
+
9
+ - Add Combobox.
10
+
11
+ ## 0.0.12
12
+
13
+ - Add Tabs.
14
+
7
15
  ## 0.0.11
8
16
 
9
17
  - Add native Slider.
10
18
 
11
19
  ## 0.0.10
12
20
 
13
- - Add draggable Switch with Field, forms, shared sizing and theme overrides.
21
+ - Add draggable Switch with Field, forms, sizing and theme overrides.
14
22
 
15
23
  ## 0.0.9
16
24
 
17
- - Add Textarea with Field, forms, themes and native resizing.
25
+ - Add Textarea with Field, forms, themes and resizing.
18
26
 
19
27
  ## 0.0.8
20
28
 
@@ -24,7 +32,7 @@
24
32
 
25
33
  - Breaking: the example themes moved out of the core entry. Before, `import { jelly, themes } from '@cognitap/radiant'`. After, `import { jelly, themes } from '@cognitap/radiant/examples'`. `defaultTheme` stays in core, and `themeDefinitions` exposes each example's definition.
26
34
 
27
- - Reconcile native disclosure changes made before hydration: local Collapsible state adopts once, while controlled disclosures and Accordion items restore their owner's value without a change request.
35
+ - Reconcile pre-hydration disclosure changes: local Collapsible state adopts once; controlled disclosures and Accordion items restore their owner's value without a request.
28
36
 
29
37
  - Align Card root minimum-width styling with its compound parts in narrow layouts.
30
38
 
package/RELEASE_POLICY.md CHANGED
@@ -68,10 +68,11 @@ stored token; the first authenticated local publication has no CI provenance.
68
68
 
69
69
  ### Failed publication and fixes
70
70
 
71
- Fix the cause, such as scope access or trusted-publisher configuration, and
72
- rerun the failed publish job; it reuses the original candidate. Never change
73
- source or regenerate a candidate to retry. After a timeout, check whether npm
74
- accepted the upload before retrying:
71
+ Fix the cause and rerun the failed publish job; it reuses the original
72
+ candidate. The job checks npm before uploading, skips an existing version
73
+ only when its integrity matches, and retries verification while npm propagates
74
+ the release. A different integrity fails immediately. Never change source or
75
+ regenerate a candidate to retry. To verify manually:
75
76
 
76
77
  ```sh
77
78
  pnpm view @cognitap/radiant@<version> dist.integrity
@@ -0,0 +1,88 @@
1
+ import type { ComponentProps, ReactNode } from 'react';
2
+ import { type ButtonProps } from './Button.js';
3
+ import type { ValueOwner } from './react/useNativeOwner.js';
4
+ import type { ControlSize } from './presentation.js';
5
+ import type { ThemeStyle } from './themes/defineTheme.js';
6
+ export type ComboboxOption = {
7
+ value: string;
8
+ disabled?: boolean;
9
+ } & ({
10
+ label: string;
11
+ textValue?: string;
12
+ } | {
13
+ label: ReactNode;
14
+ textValue: string;
15
+ });
16
+ export type ComboboxProps = ValueOwner<string | null> & {
17
+ items: readonly ComboboxOption[];
18
+ onValueChange?: (value: string | null) => void;
19
+ /** Application-owned selected option when it is absent from asynchronous results. */
20
+ selectedItem?: ComboboxOption;
21
+ /** Local text matching by default. Pass null for application-filtered results. */
22
+ filter?: ((item: ComboboxOption, query: string) => boolean) | null;
23
+ onQueryChange?: (query: string) => void;
24
+ loading?: boolean;
25
+ error?: ReactNode;
26
+ loadingText?: string;
27
+ emptyText?: string;
28
+ name?: string;
29
+ form?: string;
30
+ disabled?: boolean;
31
+ required?: boolean;
32
+ controlSize?: ControlSize;
33
+ children?: ReactNode;
34
+ } & ({
35
+ query: string;
36
+ defaultQuery?: never;
37
+ } | {
38
+ query?: undefined;
39
+ defaultQuery?: string;
40
+ }) & ({
41
+ open: boolean;
42
+ defaultOpen?: never;
43
+ } | {
44
+ open?: undefined;
45
+ defaultOpen?: boolean;
46
+ }) & {
47
+ onOpenChange?: (open: boolean) => void;
48
+ };
49
+ export type ComboboxState = {
50
+ value: string | null;
51
+ query: string;
52
+ open: boolean;
53
+ disabled: boolean;
54
+ setValue(value: string | null): void;
55
+ setQuery(query: string): void;
56
+ setOpen(open: boolean): void;
57
+ };
58
+ export declare function useCombobox(): ComboboxState | null;
59
+ /** Editable search with explicit single selection. Fetching and validation messages belong to the application. */
60
+ export declare function Combobox({ items, value, defaultValue, onValueChange, selectedItem, filter, query, defaultQuery, onQueryChange, open, defaultOpen, onOpenChange, loading, error, loadingText, emptyText, name, form, disabled: disabledProp, required: requiredProp, controlSize, children }: ComboboxProps): import("react").JSX.Element;
61
+ export type ComboboxInputProps = Omit<ComponentProps<'input'>, 'value' | 'defaultValue' | 'name' | 'form' | 'type' | 'role' | 'disabled' | 'required' | 'style' | 'aria-controls' | 'aria-expanded' | 'aria-autocomplete' | 'aria-activedescendant'> & {
62
+ style?: ThemeStyle;
63
+ };
64
+ export declare function ComboboxInput({ className, ref, onChange, onClick, onKeyDown, onBlur, ...props }: ComboboxInputProps): import("react").JSX.Element;
65
+ export type ComboboxTriggerProps = Omit<ButtonProps, 'type' | 'disabled' | 'pending' | 'variant' | 'tone' | 'controlSize' | 'iconOnly' | 'fullWidth' | 'motion' | 'tabIndex' | 'aria-controls' | 'aria-expanded'>;
66
+ export declare function ComboboxTrigger({ children, className, render, onClick, onPointerDown, ...props }: ComboboxTriggerProps): import("react").JSX.Element;
67
+ export type ComboboxClearProps = ComboboxTriggerProps;
68
+ export declare function ComboboxClear({ children, className, render, onClick, onPointerDown, ...props }: ComboboxClearProps): import("react").JSX.Element | null;
69
+ export declare function ComboboxPortal({ children }: {
70
+ children?: ReactNode;
71
+ }): import("react").ReactPortal | null;
72
+ export type ComboboxContentProps = Omit<ComponentProps<'div'>, 'style' | 'popover' | 'role' | 'id'> & {
73
+ style?: ThemeStyle;
74
+ sideOffset?: number;
75
+ collisionPadding?: number;
76
+ motion?: 'inherit' | 'off';
77
+ };
78
+ export declare function ComboboxContent({ children, className, ref, sideOffset, collisionPadding, motion, ...props }: ComboboxContentProps): import("react").JSX.Element;
79
+ export type ComboboxItemProps = Omit<ComponentProps<'div'>, 'style' | 'id' | 'role' | 'tabIndex'> & {
80
+ value: string;
81
+ style?: ThemeStyle;
82
+ };
83
+ export declare function ComboboxItem({ value, children, className, onPointerDown, onPointerMove, onClick, ...props }: ComboboxItemProps): import("react").JSX.Element | null;
84
+ export type ComboboxStatusProps = Omit<ComponentProps<'div'>, 'style' | 'role'> & {
85
+ style?: ThemeStyle;
86
+ };
87
+ export declare function ComboboxStatus({ children, className, ...props }: ComboboxStatusProps): import("react").JSX.Element;
88
+ //# sourceMappingURL=Combobox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../src/Combobox.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAEjE,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AActD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEzD,MAAM,MAAM,cAAc,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,CACjE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAC1C,CAAA;AACD,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG;IACtD,KAAK,EAAE,SAAS,cAAc,EAAE,CAAA;IAChC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAA;IAC9C,qFAAqF;IACrF,YAAY,CAAC,EAAE,cAAc,CAAA;IAC7B,kFAAkF;IAClF,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,c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AE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,mBAAmB,+BAcpF"}
@@ -0,0 +1,365 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ /* oxlint-disable jsx-a11y/prefer-tag-over-role -- An editable combobox uses a native text input and an ARIA listbox; its submitted value has a separate native form bridge. */
4
+ import { createContext, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
5
+ import { createPortal } from 'react-dom';
6
+ import { Button } from './Button.js';
7
+ import { useField, useFieldControl } from './Field.js';
8
+ import { cn } from './cn.js';
9
+ import { controlMetrics } from './controlStyles.js';
10
+ import { comboboxInputClass, comboboxContentClass, comboboxItemClass, comboboxActionClass } from './comboboxStyles.js';
11
+ import { useControllableState } from './react/useControllableState.js';
12
+ import { useComposedRefs } from './react/useComposedRefs.js';
13
+ import { useTransitionHost } from './motion/host.js';
14
+ import { useComboboxPopup } from './react/useComboboxPopup.js';
15
+ const ComboboxContext = createContext(null);
16
+ export function useCombobox() {
17
+ return useContext(ComboboxContext);
18
+ }
19
+ function useComboboxContext() {
20
+ const context = useContext(ComboboxContext);
21
+ if (!context)
22
+ throw new Error('Combobox parts must render inside Combobox.');
23
+ return context;
24
+ }
25
+ const textOf = (item) => item?.textValue ?? (typeof item?.label === 'string' ? item.label : '');
26
+ const localFilter = (item, query) => textOf(item).toLocaleLowerCase().includes(query.trim().toLocaleLowerCase());
27
+ /** Editable search with explicit single selection. Fetching and validation messages belong to the application. */
28
+ export function Combobox({ items, value, defaultValue, onValueChange, selectedItem, filter = localFilter, query, defaultQuery, onQueryChange, open, defaultOpen, onOpenChange, loading = false, error, loadingText = 'Loading results…', emptyText = 'No results found.', name, form, disabled: disabledProp, required: requiredProp, controlSize = 'medium', children }) {
29
+ const ids = useId();
30
+ const field = useField();
31
+ const disabled = !!(disabledProp || field?.disabled);
32
+ const required = !!(requiredProp || field?.required);
33
+ if (new Set(items.map(item => item.value)).size !== items.length)
34
+ throw new TypeError('Combobox item values must be distinct.');
35
+ if ([...items, ...(selectedItem ? [selectedItem] : [])].some(item => typeof item.value !== 'string' || !textOf(item).trim()))
36
+ throw new TypeError('Combobox items need a string value and readable textValue.');
37
+ const selection = useControllableState({
38
+ name: 'Combobox',
39
+ value,
40
+ defaultValue,
41
+ initialValue: null,
42
+ onChange: onValueChange
43
+ });
44
+ const search = useControllableState({
45
+ name: 'Combobox query',
46
+ value: query,
47
+ defaultValue: defaultQuery,
48
+ initialValue: '',
49
+ onChange: onQueryChange
50
+ });
51
+ const expansion = useControllableState({
52
+ name: 'Combobox open',
53
+ value: open,
54
+ defaultValue: defaultOpen,
55
+ initialValue: false,
56
+ onChange: onOpenChange
57
+ });
58
+ const [input, setInput] = useState(null);
59
+ const content = useRef(null);
60
+ const bridge = useRef(null);
61
+ const [active, highlight] = useState(null);
62
+ const [searching, setSearching] = useState(!!search.value);
63
+ const [retained, setRetained] = useState(() => new Map());
64
+ const currentItem = items.find(item => item.value === selection.value) ??
65
+ (selectedItem?.value === selection.value ? selectedItem : undefined);
66
+ if (currentItem && retained.get(currentItem.value) !== currentItem)
67
+ setRetained(new Map(retained).set(currentItem.value, currentItem));
68
+ const selected = currentItem ?? (selection.value === null ? undefined : retained.get(selection.value));
69
+ const unavailable = () => disabled || !!input?.matches(':disabled');
70
+ const isOpen = expansion.value && !disabled;
71
+ const visible = loading || error ? [] : filter ? items.filter(item => filter(item, search.value)) : items;
72
+ const enabled = visible.filter(item => !item.disabled);
73
+ const activeValue = enabled.some(item => item.value === active) ? active : null;
74
+ if (active !== null && activeValue === null)
75
+ highlight(null);
76
+ const text = isOpen && (searching || search.value !== '')
77
+ ? search.value
78
+ : selected
79
+ ? textOf(selected)
80
+ : (selection.value ?? '');
81
+ const setOpen = (next) => {
82
+ if (next && unavailable())
83
+ return;
84
+ expansion.request(next);
85
+ if (!next)
86
+ highlight(null);
87
+ };
88
+ const dismiss = () => {
89
+ expansion.request(false);
90
+ highlight(null);
91
+ setSearching(false);
92
+ search.request('');
93
+ };
94
+ const setQuery = (next) => {
95
+ if (unavailable())
96
+ return;
97
+ setSearching(true);
98
+ highlight(null);
99
+ search.request(next);
100
+ setOpen(true);
101
+ };
102
+ const pending = useRef(null);
103
+ const requestValue = (next) => {
104
+ if (unavailable())
105
+ return;
106
+ if (next !== selection.value)
107
+ pending.current = { value: next };
108
+ selection.request(next);
109
+ queueMicrotask(() => {
110
+ pending.current = null;
111
+ });
112
+ };
113
+ const commit = (next) => {
114
+ if (unavailable() || (next !== null && !enabled.some(item => item.value === next)))
115
+ return;
116
+ const item = enabled.find(item => item.value === next);
117
+ if (item)
118
+ setRetained(previous => new Map(previous).set(item.value, item));
119
+ requestValue(next);
120
+ dismiss();
121
+ input?.focus({ preventScroll: true });
122
+ };
123
+ const nativeValue = selection.value ?? '';
124
+ const latest = useRef({ selection, search, nativeValue, expansion });
125
+ useLayoutEffect(() => {
126
+ latest.current = { selection, search, nativeValue, expansion };
127
+ });
128
+ useLayoutEffect(() => {
129
+ const node = bridge.current;
130
+ if (!node)
131
+ return;
132
+ const changedByUser = pending.current && Object.is(pending.current.value, selection.value);
133
+ if (changedByUser) {
134
+ // Bypass React's value tracker so form onChange observes this accepted selection.
135
+ const setter = Object.getOwnPropertyDescriptor(node.ownerDocument.defaultView.HTMLInputElement.prototype, 'value').set;
136
+ setter.call(node, nativeValue);
137
+ }
138
+ else
139
+ node.value = nativeValue;
140
+ if (selection.controlled)
141
+ node.defaultValue = nativeValue;
142
+ node.setCustomValidity(required && selection.value === null ? 'Please select an option.' : '');
143
+ if (pending.current && Object.is(pending.current.value, selection.value)) {
144
+ pending.current = null;
145
+ const EventType = node.ownerDocument.defaultView.Event;
146
+ node.dispatchEvent(new EventType('input', { bubbles: true }));
147
+ node.dispatchEvent(new EventType('change', { bubbles: true }));
148
+ }
149
+ });
150
+ useEffect(() => {
151
+ const node = bridge.current;
152
+ const owner = node?.form;
153
+ if (!node || !owner)
154
+ return;
155
+ const win = node.ownerDocument.defaultView;
156
+ let timer;
157
+ const reset = (event) => {
158
+ win.clearTimeout(timer);
159
+ timer = win.setTimeout(() => {
160
+ if (event.defaultPrevented || !node.isConnected)
161
+ return;
162
+ latest.current.selection.reset();
163
+ latest.current.search.reset();
164
+ setSearching(false);
165
+ highlight(null);
166
+ latest.current.expansion.request(false);
167
+ node.value = latest.current.nativeValue;
168
+ }, 0);
169
+ };
170
+ owner.addEventListener('reset', reset);
171
+ return () => {
172
+ owner.removeEventListener('reset', reset);
173
+ win.clearTimeout(timer);
174
+ };
175
+ }, [input, form]);
176
+ useLayoutEffect(() => {
177
+ if (!isOpen || activeValue === null)
178
+ return;
179
+ const option = content.current?.ownerDocument.getElementById(`${ids}-option-${encodeURIComponent(activeValue)}`);
180
+ option?.scrollIntoView({ block: 'nearest' });
181
+ }, [activeValue, isOpen, ids]);
182
+ const context = {
183
+ value: selection.value,
184
+ query: search.value,
185
+ open: isOpen,
186
+ disabled,
187
+ setValue: next => {
188
+ if (next === null || items.some(item => item.value === next && !item.disabled))
189
+ requestValue(next);
190
+ },
191
+ setQuery,
192
+ setOpen,
193
+ items,
194
+ visible,
195
+ active: activeValue,
196
+ highlight,
197
+ text,
198
+ input,
199
+ setInput,
200
+ content,
201
+ inputId: field?.controlProps?.id ?? `${ids}-input`,
202
+ listId: `${ids}-listbox`,
203
+ optionId: next => `${ids}-option-${encodeURIComponent(next)}`,
204
+ required,
205
+ controlSize,
206
+ loading,
207
+ error,
208
+ status: loading ? loadingText : error || (visible.length === 0 ? emptyText : ''),
209
+ dismiss,
210
+ commit
211
+ };
212
+ return (_jsxs(ComboboxContext.Provider, { value: context, children: [children ?? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "relative w-full min-w-0", "data-slot": "combobox-control", children: [_jsx(ComboboxInput, {}), _jsx(ComboboxTrigger, { className: "absolute inset-y-0 end-0 w-12" })] }), _jsx(ComboboxPortal, { children: _jsx(ComboboxContent, {}) })] })), _jsx("input", { ref: bridge, className: "sr-only", "data-slot": "combobox-native", type: "text", name: name, form: form, disabled: disabled, "aria-hidden": "true", tabIndex: -1, autoComplete: "off", defaultValue: nativeValue, onFocus: () => input?.focus(), onInvalid: event => {
213
+ event.preventDefault();
214
+ input?.focus();
215
+ } })] }));
216
+ }
217
+ export function ComboboxInput({ className, ref, onChange, onClick, onKeyDown, onBlur, ...props }) {
218
+ const box = useComboboxContext();
219
+ const control = useFieldControl({
220
+ id: props.id ?? box.inputId,
221
+ disabled: box.disabled,
222
+ required: box.required,
223
+ 'aria-describedby': props['aria-describedby'],
224
+ 'aria-invalid': props['aria-invalid']
225
+ });
226
+ const inputRef = useComposedRefs(box.setInput, ref);
227
+ return (_jsx("input", { ...props, ...control, ref: inputRef, type: "text", role: "combobox", required: false, autoComplete: props.autoComplete ?? 'off', value: box.text, className: cn(comboboxInputClass, controlMetrics({ controlSize: box.controlSize }), className), "data-slot": "combobox-input", "data-control-size": box.controlSize, "aria-autocomplete": "list", "aria-expanded": box.open, "aria-controls": box.open ? box.listId : undefined, "aria-activedescendant": box.open && box.active !== null ? box.optionId(box.active) : undefined, onChange: event => {
228
+ onChange?.(event);
229
+ box.setQuery(event.currentTarget.value);
230
+ }, onClick: event => {
231
+ onClick?.(event);
232
+ if (!event.defaultPrevented)
233
+ box.setOpen(true);
234
+ }, onBlur: event => {
235
+ onBlur?.(event);
236
+ if (!box.content.current?.contains(event.relatedTarget) &&
237
+ !event.currentTarget.parentElement?.contains(event.relatedTarget))
238
+ box.dismiss();
239
+ }, onKeyDown: event => {
240
+ onKeyDown?.(event);
241
+ if (event.defaultPrevented ||
242
+ event.nativeEvent.isComposing ||
243
+ event.keyCode === 229 ||
244
+ event.ctrlKey ||
245
+ event.metaKey)
246
+ return;
247
+ if (event.key === 'Escape' && !box.open && box.value !== null) {
248
+ event.preventDefault();
249
+ box.commit(null);
250
+ return;
251
+ }
252
+ if (event.key === 'Escape' && box.open) {
253
+ event.preventDefault();
254
+ event.stopPropagation();
255
+ box.dismiss();
256
+ return;
257
+ }
258
+ if (event.key === 'Tab') {
259
+ box.dismiss();
260
+ return;
261
+ }
262
+ if (event.altKey) {
263
+ if (event.key === 'ArrowDown') {
264
+ event.preventDefault();
265
+ box.setOpen(true);
266
+ }
267
+ else if (event.key === 'ArrowUp') {
268
+ event.preventDefault();
269
+ box.dismiss();
270
+ }
271
+ return;
272
+ }
273
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
274
+ event.preventDefault();
275
+ box.setOpen(true);
276
+ const options = box.visible.filter(item => !item.disabled);
277
+ const index = options.findIndex(item => item.value === box.active);
278
+ const next = index < 0
279
+ ? event.key === 'ArrowUp'
280
+ ? options.at(-1)
281
+ : options[0]
282
+ : options[Math.max(0, Math.min(options.length - 1, index + (event.key === 'ArrowUp' ? -1 : 1)))];
283
+ box.highlight(next?.value ?? null);
284
+ }
285
+ else if (event.key === 'Enter' && box.open && box.active !== null) {
286
+ event.preventDefault();
287
+ box.commit(box.active);
288
+ }
289
+ } }));
290
+ }
291
+ export function ComboboxTrigger({ children, className, render, onClick, onPointerDown, ...props }) {
292
+ const box = useComboboxContext();
293
+ return (_jsx(Button, { variant: "ghost", tone: "neutral", ...props, type: "button", disabled: box.disabled, pending: false, motion: "off", controlSize: box.controlSize, render: resolved => {
294
+ const native = { ...resolved, className: cn(comboboxActionClass, className) };
295
+ return render ? render(native) : _jsx("button", { ...native });
296
+ }, tabIndex: -1, "aria-label": props['aria-label'] ?? 'Show options', "aria-controls": box.open ? box.listId : undefined, "aria-expanded": box.open, "data-slot": "button combobox-trigger", onPointerDown: event => {
297
+ onPointerDown?.(event);
298
+ if (!event.defaultPrevented)
299
+ event.preventDefault();
300
+ }, onClick: event => {
301
+ onClick?.(event);
302
+ if (!event.defaultPrevented) {
303
+ box.input?.focus({ preventScroll: true });
304
+ if (box.open)
305
+ box.dismiss();
306
+ else
307
+ box.setOpen(true);
308
+ }
309
+ }, children: children ?? (_jsx("svg", { "aria-hidden": "true", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: _jsx("path", { d: "m4 6 4 4 4-4", stroke: "currentColor", strokeWidth: "1.5" }) })) }));
310
+ }
311
+ export function ComboboxClear({ children, className, render, onClick, onPointerDown, ...props }) {
312
+ const box = useComboboxContext();
313
+ if (box.value === null)
314
+ return null;
315
+ return (_jsx(Button, { variant: "ghost", tone: "neutral", ...props, type: "button", disabled: box.disabled, pending: false, motion: "off", controlSize: box.controlSize, render: resolved => {
316
+ const native = { ...resolved, className: cn(comboboxActionClass, className) };
317
+ return render ? render(native) : _jsx("button", { ...native });
318
+ }, tabIndex: -1, "aria-label": props['aria-label'] ?? 'Clear selection', "data-slot": "button combobox-clear", onPointerDown: event => {
319
+ onPointerDown?.(event);
320
+ if (!event.defaultPrevented)
321
+ event.preventDefault();
322
+ }, onClick: event => {
323
+ onClick?.(event);
324
+ if (!event.defaultPrevented)
325
+ box.commit(null);
326
+ }, children: children ?? (_jsx("svg", { "aria-hidden": "true", width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", children: _jsx("path", { d: "m5 5 6 6m0-6-6 6", stroke: "currentColor", strokeWidth: "1.5" }) })) }));
327
+ }
328
+ export function ComboboxPortal({ children }) {
329
+ const box = useComboboxContext();
330
+ return box.input?.parentElement ? createPortal(children, box.input.parentElement) : null;
331
+ }
332
+ export function ComboboxContent({ children, className, ref, sideOffset = 4, collisionPadding = 8, motion = 'inherit', ...props }) {
333
+ const box = useComboboxContext();
334
+ const contentRef = useComposedRefs(box.content, ref);
335
+ const { ref: transitionRef, active: motionActive, off: motionOff } = useTransitionHost('popup', contentRef, motion === 'off');
336
+ useComboboxPopup(box.content, box.input, box.open, box.dismiss, sideOffset, collisionPadding);
337
+ return (_jsxs("div", { ...props, ref: transitionRef, popover: "manual", "data-slot": "combobox-content", "data-motion": motion, "data-state": box.open ? 'open' : 'closed', className: cn(comboboxContentClass, controlMetrics({ controlSize: box.controlSize }), motionActive &&
338
+ !motionOff &&
339
+ 'opacity-[var(--_rad-popup-enter,0)] motion-reduce:opacity-100', className), children: [_jsx("div", { id: box.listId, role: "listbox", "aria-label": props['aria-label'] ?? box.input?.getAttribute('aria-label') ?? 'Suggestions', "aria-labelledby": props['aria-label'] ? undefined : box.input?.labels?.[0]?.id, "aria-busy": box.loading || undefined, "data-slot": "combobox-listbox", className: "max-h-[calc(var(--_rad-combobox-max-height,100dvh)-0.5rem)] overflow-y-auto overscroll-contain", children: children ??
340
+ box.visible.map(item => (_jsx(ComboboxItem, { value: item.value }, item.value))) }), _jsx(ComboboxStatus, {})] }));
341
+ }
342
+ export function ComboboxItem({ value, children, className, onPointerDown, onPointerMove, onClick, ...props }) {
343
+ const box = useComboboxContext();
344
+ const item = box.visible.find(item => item.value === value);
345
+ if (!item)
346
+ return null;
347
+ return (_jsx("div", { ...props, id: box.optionId(value), role: "option", tabIndex: -1, onKeyDown: props.onKeyDown, "aria-selected": box.active === value, "aria-disabled": item.disabled || undefined, "data-slot": "combobox-item", "data-value": value, "data-highlighted": box.active === value ? '' : undefined, "data-selected": box.value === value ? '' : undefined, "data-disabled": item.disabled ? '' : undefined, className: cn(comboboxItemClass, className), onPointerDown: event => {
348
+ onPointerDown?.(event);
349
+ if (!event.defaultPrevented)
350
+ event.preventDefault();
351
+ }, onPointerMove: event => {
352
+ onPointerMove?.(event);
353
+ if (!event.defaultPrevented && event.pointerType === 'mouse' && !item.disabled)
354
+ box.highlight(value);
355
+ }, onClick: event => {
356
+ onClick?.(event);
357
+ if (!event.defaultPrevented && !item.disabled)
358
+ box.commit(value);
359
+ }, children: children ?? (_jsxs(_Fragment, { children: [_jsx("span", { className: "min-w-0 flex-1", children: item.label }), _jsx("span", { "aria-hidden": "true", className: cn(box.value !== value && 'invisible'), children: "\u2713" })] })) }));
360
+ }
361
+ export function ComboboxStatus({ children, className, ...props }) {
362
+ const box = useComboboxContext();
363
+ return (_jsx("div", { ...props, role: "status", "aria-live": "polite", "aria-atomic": "true", "data-slot": "combobox-status", className: cn('px-3 py-2 empty:hidden', className), children: box.open ? (children ?? box.status) : null }));
364
+ }
365
+ //# sourceMappingURL=Combobox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Combobox.js","sourceRoot":"","sources":["../../src/Combobox.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,+KAA+K;AAE/K,OAAO,EACL,aAAa,EACb,UAAU,EACV,SAAS,EACT,KAAK,EACL,eAAe,EACf,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAA;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AA4D9D,MAAM,eAAe,GAAG,aAAa,CAAiB,IAAI,CAAC,CAAA;AAC3D,MAAM,UAAU,WAAW;IACzB,OAAO,UAAU,CAAC,eAAe,CAAC,CAAA;AACpC,CAAC;AACD,SAAS,kBAAkB;IACzB,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAC5E,OAAO,OAAO,CAAA;AAChB,CAAC;AACD,MAAM,MAAM,GAAG,CAAC,IAAqB,EAAE,EAAE,CACvC,IAAI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I,KAAK,CAAC,WAAW,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAC5E,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QACxB,CAAC,EACD,OAAO,EAAE,KAAK,CAAC,EAAE;YACf,OAAO,EAAE,CAAC,KAAK,CAAC,CAAA;YAChB,IAAI,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,IAAI,CAAC,QAAQ;gBAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAClE,CAAC,YAEA,QAAQ,IAAI,CACX,8BACE,eAAM,SAAS,EAAC,gBAAgB,YAAE,IAAI,CAAC,KAAK,GAAQ,EACpD,8BACc,MAAM,EAClB,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,KAAK,IAAI,WAAW,CAAC,uBAG5C,IACN,CACJ,GACG,CACP,CAAA;AACH,CAAC;AAID,MAAM,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,KAAK,EAAuB;IACnF,MAAM,GAAG,GAAG,kBAAkB,EAAE,CAAA;IAChC,OAAO,CACL,iBACM,KAAK,EACT,IAAI,EAAC,QAAQ,eACH,QAAQ,iBACN,MAAM,eACR,iBAAiB,EAC3B,SAAS,EAAE,EAAE,CAAC,wBAAwB,EAAE,SAAS,CAAC,YAEjD,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,GACvC,CACP,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\n/* oxlint-disable jsx-a11y/prefer-tag-over-role -- An editable combobox uses a native text input and an ARIA listbox; its submitted value has a separate native form bridge. */\n\nimport {\n createContext,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState\n} from 'react'\nimport type { ComponentProps, ReactNode, RefObject } from 'react'\nimport { createPortal } from 'react-dom'\nimport { Button, type ButtonProps } from './Button.js'\nimport { useField, useFieldControl } from './Field.js'\nimport { cn } from './cn.js'\nimport { controlMetrics } from './controlStyles.js'\nimport {\n comboboxInputClass,\n comboboxContentClass,\n comboboxItemClass,\n comboboxActionClass\n} from './comboboxStyles.js'\nimport { useControllableState } from './react/useControllableState.js'\nimport { useComposedRefs } from './react/useComposedRefs.js'\nimport { useTransitionHost } from './motion/host.js'\nimport { useComboboxPopup } from './react/useComboboxPopup.js'\nimport type { ValueOwner } from './react/useNativeOwner.js'\nimport type { ControlSize } from './presentation.js'\nimport type { ThemeStyle } from './themes/defineTheme.js'\n\nexport type ComboboxOption = { value: string; disabled?: boolean } & (\n | { label: string; textValue?: string }\n | { label: ReactNode; textValue: string }\n)\nexport type ComboboxProps = ValueOwner<string | null> & {\n items: readonly ComboboxOption[]\n onValueChange?: (value: string | null) => void\n /** Application-owned selected option when it is absent from asynchronous results. */\n selectedItem?: ComboboxOption\n /** Local text matching by default. Pass null for application-filtered results. */\n filter?: ((item: ComboboxOption, query: string) => boolean) | null\n onQueryChange?: (query: string) => void\n loading?: boolean\n error?: ReactNode\n loadingText?: string\n emptyText?: string\n name?: string\n form?: string\n disabled?: boolean\n required?: boolean\n controlSize?: ControlSize\n children?: ReactNode\n} & ({ query: string; defaultQuery?: never } | { query?: undefined; defaultQuery?: string }) &\n ({ open: boolean; defaultOpen?: never } | { open?: undefined; defaultOpen?: boolean }) & {\n onOpenChange?: (open: boolean) => void\n }\nexport type ComboboxState = {\n value: string | null\n query: string\n open: boolean\n disabled: boolean\n setValue(value: string | null): void\n setQuery(query: string): void\n setOpen(open: boolean): void\n}\ntype Context = ComboboxState & {\n items: readonly ComboboxOption[]\n visible: readonly ComboboxOption[]\n active: string | null\n highlight(value: string | null): void\n text: string\n input: HTMLInputElement | null\n setInput(node: HTMLInputElement | null): void\n content: RefObject<HTMLDivElement | null>\n inputId: string\n listId: string\n optionId(value: string): string\n required: boolean\n controlSize: ControlSize\n loading: boolean\n error?: ReactNode\n status: ReactNode\n dismiss(): void\n commit(value: string | null): void\n}\nconst ComboboxContext = createContext<Context | null>(null)\nexport function useCombobox(): ComboboxState | null {\n return useContext(ComboboxContext)\n}\nfunction useComboboxContext() {\n const context = useContext(ComboboxContext)\n if (!context) throw new Error('Combobox parts must render inside Combobox.')\n return context\n}\nconst textOf = (item?: ComboboxOption) =>\n item?.textValue ?? (typeof item?.label === 'string' ? item.label : '')\nconst localFilter = (item: ComboboxOption, query: string) =>\n textOf(item).toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())\n\n/** Editable search with explicit single selection. Fetching and validation messages belong to the application. */\nexport function Combobox({\n items,\n value,\n defaultValue,\n onValueChange,\n selectedItem,\n filter = localFilter,\n query,\n defaultQuery,\n onQueryChange,\n open,\n defaultOpen,\n onOpenChange,\n loading = false,\n error,\n loadingText = 'Loading results…',\n emptyText = 'No results found.',\n name,\n form,\n disabled: disabledProp,\n required: requiredProp,\n controlSize = 'medium',\n children\n}: ComboboxProps) {\n const ids = useId()\n const field = useField()\n const disabled = !!(disabledProp || field?.disabled)\n const required = !!(requiredProp || field?.required)\n if (new Set(items.map(item => item.value)).size !== items.length)\n throw new TypeError('Combobox item values must be distinct.')\n if (\n [...items, ...(selectedItem ? [selectedItem] : [])].some(\n item => typeof item.value !== 'string' || !textOf(item).trim()\n )\n )\n throw new TypeError('Combobox items need a string value and readable textValue.')\n const selection = useControllableState({\n name: 'Combobox',\n value,\n defaultValue,\n initialValue: null,\n onChange: onValueChange\n })\n const search = useControllableState({\n name: 'Combobox query',\n value: query,\n defaultValue: defaultQuery,\n initialValue: '',\n onChange: onQueryChange\n })\n const expansion = useControllableState({\n name: 'Combobox open',\n value: open,\n defaultValue: defaultOpen,\n initialValue: false,\n onChange: onOpenChange\n })\n const [input, setInput] = useState<HTMLInputElement | null>(null)\n const content = useRef<HTMLDivElement>(null)\n const bridge = useRef<HTMLInputElement>(null)\n const [active, highlight] = useState<string | null>(null)\n const [searching, setSearching] = useState(!!search.value)\n const [retained, setRetained] = useState(() => new Map<string, ComboboxOption>())\n const currentItem =\n items.find(item => item.value === selection.value) ??\n (selectedItem?.value === selection.value ? selectedItem : undefined)\n if (currentItem && retained.get(currentItem.value) !== currentItem)\n setRetained(new Map(retained).set(currentItem.value, currentItem))\n const selected =\n currentItem ?? (selection.value === null ? undefined : retained.get(selection.value))\n const unavailable = () => disabled || !!input?.matches(':disabled')\n const isOpen = expansion.value && !disabled\n const visible =\n loading || error ? [] : filter ? items.filter(item => filter(item, search.value)) : items\n const enabled = visible.filter(item => !item.disabled)\n const activeValue = enabled.some(item => item.value === active) ? active : null\n if (active !== null && activeValue === null) highlight(null)\n const text =\n isOpen && (searching || search.value !== '')\n ? search.value\n : selected\n ? textOf(selected)\n : (selection.value ?? '')\n const setOpen = (next: boolean) => {\n if (next && unavailable()) return\n expansion.request(next)\n if (!next) highlight(null)\n }\n const dismiss = () => {\n expansion.request(false)\n highlight(null)\n setSearching(false)\n search.request('')\n }\n const setQuery = (next: string) => {\n if (unavailable()) return\n setSearching(true)\n highlight(null)\n search.request(next)\n setOpen(true)\n }\n const pending = useRef<{ value: string | null } | null>(null)\n const requestValue = (next: string | null) => {\n if (unavailable()) return\n if (next !== selection.value) pending.current = { value: next }\n selection.request(next)\n queueMicrotask(() => {\n pending.current = null\n })\n }\n const commit = (next: string | null) => {\n if (unavailable() || (next !== null && !enabled.some(item => item.value === next))) return\n const item = enabled.find(item => item.value === next)\n if (item) setRetained(previous => new Map(previous).set(item.value, item))\n requestValue(next)\n dismiss()\n input?.focus({ preventScroll: true })\n }\n const nativeValue = selection.value ?? ''\n const latest = useRef({ selection, search, nativeValue, expansion })\n useLayoutEffect(() => {\n latest.current = { selection, search, nativeValue, expansion }\n })\n useLayoutEffect(() => {\n const node = bridge.current\n if (!node) return\n const changedByUser = pending.current && Object.is(pending.current.value, selection.value)\n if (changedByUser) {\n // Bypass React's value tracker so form onChange observes this accepted selection.\n const setter = Object.getOwnPropertyDescriptor(\n node.ownerDocument.defaultView!.HTMLInputElement.prototype,\n 'value'\n )!.set!\n setter.call(node, nativeValue)\n } else node.value = nativeValue\n if (selection.controlled) node.defaultValue = nativeValue\n node.setCustomValidity(required && selection.value === null ? 'Please select an option.' : '')\n if (pending.current && Object.is(pending.current.value, selection.value)) {\n pending.current = null\n const EventType = node.ownerDocument.defaultView!.Event\n node.dispatchEvent(new EventType('input', { bubbles: true }))\n node.dispatchEvent(new EventType('change', { bubbles: true }))\n }\n })\n useEffect(() => {\n const node = bridge.current\n const owner = node?.form\n if (!node || !owner) return\n const win = node.ownerDocument.defaultView!\n let timer: number | undefined\n const reset = (event: Event) => {\n win.clearTimeout(timer)\n timer = win.setTimeout(() => {\n if (event.defaultPrevented || !node.isConnected) return\n latest.current.selection.reset()\n latest.current.search.reset()\n setSearching(false)\n highlight(null)\n latest.current.expansion.request(false)\n node.value = latest.current.nativeValue\n }, 0)\n }\n owner.addEventListener('reset', reset)\n return () => {\n owner.removeEventListener('reset', reset)\n win.clearTimeout(timer)\n }\n }, [input, form])\n useLayoutEffect(() => {\n if (!isOpen || activeValue === null) return\n const option = content.current?.ownerDocument.getElementById(\n `${ids}-option-${encodeURIComponent(activeValue)}`\n )\n option?.scrollIntoView({ block: 'nearest' })\n }, [activeValue, isOpen, ids])\n const context: Context = {\n value: selection.value,\n query: search.value,\n open: isOpen,\n disabled,\n setValue: next => {\n if (next === null || items.some(item => item.value === next && !item.disabled))\n requestValue(next)\n },\n setQuery,\n setOpen,\n items,\n visible,\n active: activeValue,\n highlight,\n text,\n input,\n setInput,\n content,\n inputId: field?.controlProps?.id ?? `${ids}-input`,\n listId: `${ids}-listbox`,\n optionId: next => `${ids}-option-${encodeURIComponent(next)}`,\n required,\n controlSize,\n loading,\n error,\n status: loading ? loadingText : error || (visible.length === 0 ? emptyText : ''),\n dismiss,\n commit\n }\n return (\n <ComboboxContext.Provider value={context}>\n {children ?? (\n <>\n <div\n className=\"relative w-full min-w-0\"\n data-slot=\"combobox-control\"\n >\n <ComboboxInput />\n <ComboboxTrigger className=\"absolute inset-y-0 end-0 w-12\" />\n </div>\n <ComboboxPortal>\n <ComboboxContent />\n </ComboboxPortal>\n </>\n )}\n <input\n ref={bridge}\n className=\"sr-only\"\n data-slot=\"combobox-native\"\n type=\"text\"\n name={name}\n form={form}\n disabled={disabled}\n aria-hidden=\"true\"\n tabIndex={-1}\n autoComplete=\"off\"\n defaultValue={nativeValue}\n onFocus={() => input?.focus()}\n onInvalid={event => {\n event.preventDefault()\n input?.focus()\n }}\n />\n </ComboboxContext.Provider>\n )\n}\n\nexport type ComboboxInputProps = Omit<\n ComponentProps<'input'>,\n | 'value'\n | 'defaultValue'\n | 'name'\n | 'form'\n | 'type'\n | 'role'\n | 'disabled'\n | 'required'\n | 'style'\n | 'aria-controls'\n | 'aria-expanded'\n | 'aria-autocomplete'\n | 'aria-activedescendant'\n> & { style?: ThemeStyle }\nexport function ComboboxInput({\n className,\n ref,\n onChange,\n onClick,\n onKeyDown,\n onBlur,\n ...props\n}: ComboboxInputProps) {\n const box = useComboboxContext()\n const control = useFieldControl({\n id: props.id ?? box.inputId,\n disabled: box.disabled,\n required: box.required,\n 'aria-describedby': props['aria-describedby'],\n 'aria-invalid': props['aria-invalid']\n })\n const inputRef = useComposedRefs(box.setInput, ref)\n return (\n <input\n {...props}\n {...control}\n ref={inputRef}\n type=\"text\"\n role=\"combobox\"\n required={false}\n autoComplete={props.autoComplete ?? 'off'}\n value={box.text}\n className={cn(\n comboboxInputClass,\n controlMetrics({ controlSize: box.controlSize }),\n className\n )}\n data-slot=\"combobox-input\"\n data-control-size={box.controlSize}\n aria-autocomplete=\"list\"\n aria-expanded={box.open}\n aria-controls={box.open ? box.listId : undefined}\n aria-activedescendant={box.open && box.active !== null ? box.optionId(box.active) : undefined}\n onChange={event => {\n onChange?.(event)\n box.setQuery(event.currentTarget.value)\n }}\n onClick={event => {\n onClick?.(event)\n if (!event.defaultPrevented) box.setOpen(true)\n }}\n onBlur={event => {\n onBlur?.(event)\n if (\n !box.content.current?.contains(event.relatedTarget) &&\n !event.currentTarget.parentElement?.contains(event.relatedTarget)\n )\n box.dismiss()\n }}\n onKeyDown={event => {\n onKeyDown?.(event)\n if (\n event.defaultPrevented ||\n event.nativeEvent.isComposing ||\n event.keyCode === 229 ||\n event.ctrlKey ||\n event.metaKey\n )\n return\n if (event.key === 'Escape' && !box.open && box.value !== null) {\n event.preventDefault()\n box.commit(null)\n return\n }\n if (event.key === 'Escape' && box.open) {\n event.preventDefault()\n event.stopPropagation()\n box.dismiss()\n return\n }\n if (event.key === 'Tab') {\n box.dismiss()\n return\n }\n if (event.altKey) {\n if (event.key === 'ArrowDown') {\n event.preventDefault()\n box.setOpen(true)\n } else if (event.key === 'ArrowUp') {\n event.preventDefault()\n box.dismiss()\n }\n return\n }\n if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n box.setOpen(true)\n const options = box.visible.filter(item => !item.disabled)\n const index = options.findIndex(item => item.value === box.active)\n const next =\n index < 0\n ? event.key === 'ArrowUp'\n ? options.at(-1)\n : options[0]\n : options[\n Math.max(\n 0,\n Math.min(options.length - 1, index + (event.key === 'ArrowUp' ? -1 : 1))\n )\n ]\n box.highlight(next?.value ?? null)\n } else if (event.key === 'Enter' && box.open && box.active !== null) {\n event.preventDefault()\n box.commit(box.active)\n }\n }}\n />\n )\n}\n\nexport type ComboboxTriggerProps = Omit<\n ButtonProps,\n | 'type'\n | 'disabled'\n | 'pending'\n | 'variant'\n | 'tone'\n | 'controlSize'\n | 'iconOnly'\n | 'fullWidth'\n | 'motion'\n | 'tabIndex'\n | 'aria-controls'\n | 'aria-expanded'\n>\nexport function ComboboxTrigger({\n children,\n className,\n render,\n onClick,\n onPointerDown,\n ...props\n}: ComboboxTriggerProps) {\n const box = useComboboxContext()\n return (\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n {...props}\n type=\"button\"\n disabled={box.disabled}\n pending={false}\n motion=\"off\"\n controlSize={box.controlSize}\n render={resolved => {\n const native = { ...resolved, className: cn(comboboxActionClass, className) }\n return render ? render(native) : <button {...native} />\n }}\n tabIndex={-1}\n aria-label={props['aria-label'] ?? 'Show options'}\n aria-controls={box.open ? box.listId : undefined}\n aria-expanded={box.open}\n data-slot=\"button combobox-trigger\"\n onPointerDown={event => {\n onPointerDown?.(event)\n if (!event.defaultPrevented) event.preventDefault()\n }}\n onClick={event => {\n onClick?.(event)\n if (!event.defaultPrevented) {\n box.input?.focus({ preventScroll: true })\n if (box.open) box.dismiss()\n else box.setOpen(true)\n }\n }}\n >\n {children ?? (\n <svg\n aria-hidden=\"true\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path\n d=\"m4 6 4 4 4-4\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n />\n </svg>\n )}\n </Button>\n )\n}\nexport type ComboboxClearProps = ComboboxTriggerProps\nexport function ComboboxClear({\n children,\n className,\n render,\n onClick,\n onPointerDown,\n ...props\n}: ComboboxClearProps) {\n const box = useComboboxContext()\n if (box.value === null) return null\n return (\n <Button\n variant=\"ghost\"\n tone=\"neutral\"\n {...props}\n type=\"button\"\n disabled={box.disabled}\n pending={false}\n motion=\"off\"\n controlSize={box.controlSize}\n render={resolved => {\n const native = { ...resolved, className: cn(comboboxActionClass, className) }\n return render ? render(native) : <button {...native} />\n }}\n tabIndex={-1}\n aria-label={props['aria-label'] ?? 'Clear selection'}\n data-slot=\"button combobox-clear\"\n onPointerDown={event => {\n onPointerDown?.(event)\n if (!event.defaultPrevented) event.preventDefault()\n }}\n onClick={event => {\n onClick?.(event)\n if (!event.defaultPrevented) box.commit(null)\n }}\n >\n {children ?? (\n <svg\n aria-hidden=\"true\"\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n >\n <path\n d=\"m5 5 6 6m0-6-6 6\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n />\n </svg>\n )}\n </Button>\n )\n}\nexport function ComboboxPortal({ children }: { children?: ReactNode }) {\n const box = useComboboxContext()\n return box.input?.parentElement ? createPortal(children, box.input.parentElement) : null\n}\nexport type ComboboxContentProps = Omit<\n ComponentProps<'div'>,\n 'style' | 'popover' | 'role' | 'id'\n> & {\n style?: ThemeStyle\n sideOffset?: number\n collisionPadding?: number\n motion?: 'inherit' | 'off'\n}\nexport function ComboboxContent({\n children,\n className,\n ref,\n sideOffset = 4,\n collisionPadding = 8,\n motion = 'inherit',\n ...props\n}: ComboboxContentProps) {\n const box = useComboboxContext()\n const contentRef = useComposedRefs(box.content, ref)\n const {\n ref: transitionRef,\n active: motionActive,\n off: motionOff\n } = useTransitionHost('popup', contentRef, motion === 'off')\n useComboboxPopup(box.content, box.input, box.open, box.dismiss, sideOffset, collisionPadding)\n return (\n <div\n {...props}\n ref={transitionRef}\n popover=\"manual\"\n data-slot=\"combobox-content\"\n data-motion={motion}\n data-state={box.open ? 'open' : 'closed'}\n className={cn(\n comboboxContentClass,\n controlMetrics({ controlSize: box.controlSize }),\n motionActive &&\n !motionOff &&\n 'opacity-[var(--_rad-popup-enter,0)] motion-reduce:opacity-100',\n className\n )}\n >\n <div\n id={box.listId}\n role=\"listbox\"\n aria-label={props['aria-label'] ?? box.input?.getAttribute('aria-label') ?? 'Suggestions'}\n aria-labelledby={props['aria-label'] ? undefined : box.input?.labels?.[0]?.id}\n aria-busy={box.loading || undefined}\n data-slot=\"combobox-listbox\"\n className=\"max-h-[calc(var(--_rad-combobox-max-height,100dvh)-0.5rem)] overflow-y-auto overscroll-contain\"\n >\n {children ??\n box.visible.map(item => (\n <ComboboxItem\n key={item.value}\n value={item.value}\n />\n ))}\n </div>\n <ComboboxStatus />\n </div>\n )\n}\nexport type ComboboxItemProps = Omit<\n ComponentProps<'div'>,\n 'style' | 'id' | 'role' | 'tabIndex'\n> & { value: string; style?: ThemeStyle }\nexport function ComboboxItem({\n value,\n children,\n className,\n onPointerDown,\n onPointerMove,\n onClick,\n ...props\n}: ComboboxItemProps) {\n const box = useComboboxContext()\n const item = box.visible.find(item => item.value === value)\n if (!item) return null\n return (\n <div\n {...props}\n id={box.optionId(value)}\n role=\"option\"\n tabIndex={-1}\n onKeyDown={props.onKeyDown}\n aria-selected={box.active === value}\n aria-disabled={item.disabled || undefined}\n data-slot=\"combobox-item\"\n data-value={value}\n data-highlighted={box.active === value ? '' : undefined}\n data-selected={box.value === value ? '' : undefined}\n data-disabled={item.disabled ? '' : undefined}\n className={cn(comboboxItemClass, className)}\n onPointerDown={event => {\n onPointerDown?.(event)\n if (!event.defaultPrevented) event.preventDefault()\n }}\n onPointerMove={event => {\n onPointerMove?.(event)\n if (!event.defaultPrevented && event.pointerType === 'mouse' && !item.disabled)\n box.highlight(value)\n }}\n onClick={event => {\n onClick?.(event)\n if (!event.defaultPrevented && !item.disabled) box.commit(value)\n }}\n >\n {children ?? (\n <>\n <span className=\"min-w-0 flex-1\">{item.label}</span>\n <span\n aria-hidden=\"true\"\n className={cn(box.value !== value && 'invisible')}\n >\n ✓\n </span>\n </>\n )}\n </div>\n )\n}\nexport type ComboboxStatusProps = Omit<ComponentProps<'div'>, 'style' | 'role'> & {\n style?: ThemeStyle\n}\nexport function ComboboxStatus({ children, className, ...props }: ComboboxStatusProps) {\n const box = useComboboxContext()\n return (\n <div\n {...props}\n role=\"status\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-slot=\"combobox-status\"\n className={cn('px-3 py-2 empty:hidden', className)}\n >\n {box.open ? (children ?? box.status) : null}\n </div>\n )\n}\n"]}
@@ -381,7 +381,7 @@ export function SelectContent({ children, position = 'item-aligned', sideOffset
381
381
  }, [select.content, select.trigger]);
382
382
  return (_jsx("div", { ...props, ref: transitionRef, id: select.contentId, popover: "manual", role: "listbox", tabIndex: -1, "aria-labelledby": props['aria-label'] ? undefined : (select.labelId ?? select.trigger?.id ?? select.triggerId), className: cn(selectContentClass, controlMetrics({ controlSize: select.controlSize }), motionActive &&
383
383
  !motionOff &&
384
- 'opacity-[var(--_rad-select-enter,0)] motion-reduce:opacity-100', className), "data-slot": "select-content", "data-state": select.open ? 'open' : 'closed', "data-motion": motion, "data-position": position, onKeyDown: event => {
384
+ 'opacity-[var(--_rad-popup-enter,0)] motion-reduce:opacity-100', className), "data-slot": "select-content", "data-state": select.open ? 'open' : 'closed', "data-motion": motion, "data-position": position, onKeyDown: event => {
385
385
  onKeyDown?.(event);
386
386
  if (event.defaultPrevented)
387
387
  return;