@cognitap/radiant 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/README.md +2 -2
- package/dist/library/Dialog.js +1 -1
- package/dist/library/Dialog.js.map +1 -1
- package/dist/library/Select.d.ts +87 -0
- package/dist/library/Select.d.ts.map +1 -0
- package/dist/library/Select.js +454 -0
- package/dist/library/Select.js.map +1 -0
- package/dist/library/Textarea.d.ts +15 -0
- package/dist/library/Textarea.d.ts.map +1 -0
- package/dist/library/Textarea.js +54 -0
- package/dist/library/Textarea.js.map +1 -0
- package/dist/library/cn.d.ts.map +1 -1
- package/dist/library/cn.js +45 -3
- package/dist/library/cn.js.map +1 -1
- package/dist/library/examples/glass.d.ts.map +1 -1
- package/dist/library/examples/glass.js +5 -0
- package/dist/library/examples/glass.js.map +1 -1
- package/dist/library/index.d.ts +4 -0
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js +2 -0
- package/dist/library/index.js.map +1 -1
- package/dist/library/internal/select.d.ts +37 -0
- package/dist/library/internal/select.d.ts.map +1 -0
- package/dist/library/internal/select.js +42 -0
- package/dist/library/internal/select.js.map +1 -0
- package/dist/library/motion/host.d.ts +2 -1
- package/dist/library/motion/host.d.ts.map +1 -1
- package/dist/library/motion/host.js.map +1 -1
- package/dist/library/motion/popup.d.ts +5 -0
- package/dist/library/motion/popup.d.ts.map +1 -0
- package/dist/library/motion/popup.js +60 -0
- package/dist/library/motion/popup.js.map +1 -0
- package/dist/library/motion/react.d.ts.map +1 -1
- package/dist/library/motion/react.js +3 -1
- package/dist/library/motion/react.js.map +1 -1
- package/dist/library/react/useControllableState.d.ts +1 -0
- package/dist/library/react/useControllableState.d.ts.map +1 -1
- package/dist/library/react/useControllableState.js +8 -1
- package/dist/library/react/useControllableState.js.map +1 -1
- package/dist/library/selectStyles.d.ts +4 -0
- package/dist/library/selectStyles.d.ts.map +1 -0
- package/dist/library/selectStyles.js +32 -0
- package/dist/library/selectStyles.js.map +1 -0
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/components.d.ts +47 -0
- package/dist/library/themes/components.d.ts.map +1 -1
- package/dist/library/themes/components.js +47 -0
- package/dist/library/themes/components.js.map +1 -1
- package/docs/architecture.md +17 -5
- package/docs/motion.md +4 -4
- package/docs/theming.md +2 -2
- package/package.json +6 -8
- package/src/Dialog.tsx +1 -1
- package/src/Select.tsx +781 -0
- package/src/Textarea.tsx +92 -0
- package/src/cn.ts +45 -3
- package/src/examples/glass.ts +5 -0
- package/src/index.ts +29 -0
- package/src/internal/select.ts +80 -0
- package/src/motion/host.ts +2 -1
- package/src/motion/popup.ts +55 -0
- package/src/motion/react.ts +3 -1
- package/src/react/useControllableState.ts +7 -1
- package/src/selectStyles.ts +34 -0
- package/src/themes/components.ts +47 -0
|
@@ -0,0 +1,454 @@
|
|
|
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 -- A custom select needs ARIA on its trigger/listbox/options; the native select is a separate 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 { matchSelectText, moveSelectFocus, positionSelect } from './internal/select.js';
|
|
11
|
+
import { useComposedRefs } from './react/useComposedRefs.js';
|
|
12
|
+
import { useControllableState } from './react/useControllableState.js';
|
|
13
|
+
import { useTransitionHost } from './motion/host.js';
|
|
14
|
+
import { selectContentClass, selectItemClass, selectTriggerClass } from './selectStyles.js';
|
|
15
|
+
const SelectContext = createContext(null);
|
|
16
|
+
const SelectItemContext = createContext(null);
|
|
17
|
+
export function useSelect() {
|
|
18
|
+
return useContext(SelectContext);
|
|
19
|
+
}
|
|
20
|
+
function useSelectContext() {
|
|
21
|
+
const select = useContext(SelectContext);
|
|
22
|
+
if (!select)
|
|
23
|
+
throw new Error('Select parts must render inside Select.');
|
|
24
|
+
return select;
|
|
25
|
+
}
|
|
26
|
+
/** Custom selection presentation with a real native form control. */
|
|
27
|
+
export function Select({ items, value, defaultValue, onValueChange, open, defaultOpen, onOpenChange, name, form, autoComplete, disabled: disabledProp, required: requiredProp, controlSize = 'medium', children }) {
|
|
28
|
+
const ids = useId();
|
|
29
|
+
const field = useField();
|
|
30
|
+
const disabled = !!(disabledProp || field?.disabled);
|
|
31
|
+
const required = !!(requiredProp || field?.required);
|
|
32
|
+
const entries = items.map(item => ({
|
|
33
|
+
value: item.value,
|
|
34
|
+
disabled: item.disabled,
|
|
35
|
+
textValue: item.textValue ?? (typeof item.label === 'string' ? item.label : '')
|
|
36
|
+
}));
|
|
37
|
+
if (new Set(entries.map(item => item.value)).size !== items.length)
|
|
38
|
+
throw new TypeError('Select item values must be distinct.');
|
|
39
|
+
if (entries.some(item => typeof item.value !== 'string' || !item.textValue.trim()))
|
|
40
|
+
throw new TypeError('Select items need a string value and readable textValue.');
|
|
41
|
+
const selection = useControllableState({
|
|
42
|
+
name: 'Select',
|
|
43
|
+
value,
|
|
44
|
+
defaultValue,
|
|
45
|
+
initialValue: null,
|
|
46
|
+
onChange: onValueChange
|
|
47
|
+
});
|
|
48
|
+
const expansion = useControllableState({
|
|
49
|
+
name: 'Select open',
|
|
50
|
+
value: open,
|
|
51
|
+
defaultValue: defaultOpen,
|
|
52
|
+
initialValue: false,
|
|
53
|
+
onChange: onOpenChange
|
|
54
|
+
});
|
|
55
|
+
const [trigger, setTrigger] = useState(null);
|
|
56
|
+
const bridge = useRef(null);
|
|
57
|
+
const content = useRef(null);
|
|
58
|
+
const restoreFocus = useRef(true);
|
|
59
|
+
const pendingUser = useRef(null);
|
|
60
|
+
const dispatching = useRef(false);
|
|
61
|
+
const searchBuffer = useRef({ text: '', at: 0 });
|
|
62
|
+
const selected = items.find(item => item.value === selection.value);
|
|
63
|
+
const nativeValue = selected?.value ?? '';
|
|
64
|
+
const [initialNativeValue] = useState(nativeValue);
|
|
65
|
+
const isOpen = expansion.value && !disabled;
|
|
66
|
+
const unavailable = () => disabled || !!trigger?.matches(':disabled');
|
|
67
|
+
const setOpen = (next) => {
|
|
68
|
+
if (next && unavailable())
|
|
69
|
+
return;
|
|
70
|
+
searchBuffer.current = { text: '', at: 0 };
|
|
71
|
+
restoreFocus.current = true;
|
|
72
|
+
expansion.request(next);
|
|
73
|
+
};
|
|
74
|
+
const close = (restore = true) => {
|
|
75
|
+
restoreFocus.current = restore;
|
|
76
|
+
expansion.request(false);
|
|
77
|
+
};
|
|
78
|
+
const focus = (itemValue) => {
|
|
79
|
+
const nodes = content.current?.querySelectorAll('[data-slot~="select-item"]');
|
|
80
|
+
const option = Array.from(nodes ?? []).find(node => node.dataset.value === itemValue && node.getAttribute('aria-disabled') !== 'true');
|
|
81
|
+
option?.focus({ preventScroll: true });
|
|
82
|
+
option?.scrollIntoView({ block: 'nearest' });
|
|
83
|
+
};
|
|
84
|
+
const commit = (next) => {
|
|
85
|
+
if (unavailable() || !items.some(item => item.value === next && !item.disabled))
|
|
86
|
+
return;
|
|
87
|
+
if (next !== selection.value)
|
|
88
|
+
pendingUser.current = next;
|
|
89
|
+
selection.request(next);
|
|
90
|
+
close();
|
|
91
|
+
// A declined controlled request must not become a later programmatic change event.
|
|
92
|
+
queueMicrotask(() => {
|
|
93
|
+
pendingUser.current = null;
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
const latest = useRef({ selection, close, nativeValue });
|
|
97
|
+
useLayoutEffect(() => {
|
|
98
|
+
latest.current = { selection, close, nativeValue };
|
|
99
|
+
});
|
|
100
|
+
useLayoutEffect(() => {
|
|
101
|
+
const node = bridge.current;
|
|
102
|
+
if (!node)
|
|
103
|
+
return;
|
|
104
|
+
node.value = nativeValue;
|
|
105
|
+
if (selection.controlled)
|
|
106
|
+
for (const option of node.options)
|
|
107
|
+
option.defaultSelected = option.value === nativeValue;
|
|
108
|
+
if (pendingUser.current !== null && pendingUser.current === nativeValue) {
|
|
109
|
+
pendingUser.current = null;
|
|
110
|
+
dispatching.current = true;
|
|
111
|
+
try {
|
|
112
|
+
node.dispatchEvent(new Event('change', { bubbles: true }));
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
dispatching.current = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const node = bridge.current;
|
|
121
|
+
const owner = node?.form;
|
|
122
|
+
if (!owner)
|
|
123
|
+
return;
|
|
124
|
+
const win = node.ownerDocument.defaultView;
|
|
125
|
+
let resetTimer;
|
|
126
|
+
const reset = (event) => {
|
|
127
|
+
win.clearTimeout(resetTimer);
|
|
128
|
+
resetTimer = win.setTimeout(() => {
|
|
129
|
+
if (event.defaultPrevented || !node.isConnected)
|
|
130
|
+
return;
|
|
131
|
+
latest.current.selection.reset();
|
|
132
|
+
if (latest.current.selection.controlled)
|
|
133
|
+
node.value = latest.current.nativeValue;
|
|
134
|
+
latest.current.close(false);
|
|
135
|
+
}, 0);
|
|
136
|
+
};
|
|
137
|
+
owner.addEventListener('reset', reset);
|
|
138
|
+
return () => {
|
|
139
|
+
owner.removeEventListener('reset', reset);
|
|
140
|
+
win.clearTimeout(resetTimer);
|
|
141
|
+
};
|
|
142
|
+
}, [form, trigger]);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (!isOpen &&
|
|
145
|
+
restoreFocus.current &&
|
|
146
|
+
content.current?.contains(content.current.ownerDocument.activeElement))
|
|
147
|
+
trigger?.focus({ preventScroll: true });
|
|
148
|
+
}, [isOpen, trigger]);
|
|
149
|
+
const context = {
|
|
150
|
+
value: selection.value,
|
|
151
|
+
setValue: selection.request,
|
|
152
|
+
open: isOpen,
|
|
153
|
+
setOpen,
|
|
154
|
+
disabled,
|
|
155
|
+
items,
|
|
156
|
+
entries,
|
|
157
|
+
controlSize,
|
|
158
|
+
required,
|
|
159
|
+
triggerId: field?.controlProps?.id ?? `${ids}-trigger`,
|
|
160
|
+
contentId: `${ids}-content`,
|
|
161
|
+
labelId: field?.layout === 'control' ? field.labelId : undefined,
|
|
162
|
+
trigger,
|
|
163
|
+
setTrigger,
|
|
164
|
+
content,
|
|
165
|
+
focus,
|
|
166
|
+
commit,
|
|
167
|
+
close,
|
|
168
|
+
restoreFocus,
|
|
169
|
+
search(key, current) {
|
|
170
|
+
const now = Date.now();
|
|
171
|
+
const text = (now - searchBuffer.current.at < 1000 ? searchBuffer.current.text : '') + key;
|
|
172
|
+
searchBuffer.current = { text, at: now };
|
|
173
|
+
return matchSelectText(entries, text, current);
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
return (_jsxs(SelectContext.Provider, { value: context, children: [children ?? (_jsxs(_Fragment, { children: [_jsxs(SelectTrigger, { children: [_jsx(SelectValue, {}), _jsx(SelectIcon, {})] }), _jsx(SelectPortal, { children: _jsx(SelectContent, {}) })] })), _jsxs("select", { ref: bridge, name: name, form: form, autoComplete: autoComplete, required: required, disabled: disabled, "aria-hidden": "true", tabIndex: -1, className: "sr-only", "data-slot": "select-native", defaultValue: initialNativeValue, onFocus: () => trigger?.focus(), onInvalid: event => {
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
trigger?.focus();
|
|
179
|
+
}, onChange: event => {
|
|
180
|
+
if (dispatching.current)
|
|
181
|
+
return;
|
|
182
|
+
const next = event.currentTarget.value;
|
|
183
|
+
if (unavailable()) {
|
|
184
|
+
event.currentTarget.value = latest.current.nativeValue;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (items.some(item => item.value === next && !item.disabled))
|
|
188
|
+
selection.request(next);
|
|
189
|
+
if (selection.controlled)
|
|
190
|
+
event.currentTarget.value = nativeValue;
|
|
191
|
+
}, children: [!items.some(item => item.value === '') && _jsx("option", { value: "", children: "No selection" }), items.map(item => (_jsx("option", { value: item.value, disabled: item.disabled, children: item.textValue ?? item.label }, item.value)))] })] }));
|
|
192
|
+
}
|
|
193
|
+
export function SelectTrigger({ className, onClick, onKeyDown, ref, children, ...props }) {
|
|
194
|
+
const select = useSelectContext();
|
|
195
|
+
const control = useFieldControl({
|
|
196
|
+
id: props.id ?? select.triggerId,
|
|
197
|
+
disabled: select.disabled,
|
|
198
|
+
required: select.required,
|
|
199
|
+
'aria-describedby': props['aria-describedby'],
|
|
200
|
+
'aria-invalid': props['aria-invalid']
|
|
201
|
+
});
|
|
202
|
+
const hostRef = useComposedRefs(select.setTrigger, ref);
|
|
203
|
+
return (_jsx(Button, { ...props, ...control, ref: hostRef, variant: "outline", tone: "neutral", type: "button", controlSize: select.controlSize, className: cn(selectTriggerClass, controlMetrics({ controlSize: select.controlSize }), className), role: "combobox", "aria-haspopup": "listbox", "aria-controls": select.contentId, "aria-expanded": select.open, "aria-required": select.required || undefined, "data-slot": "button select-trigger", "data-state": select.open ? 'open' : 'closed', "data-placeholder": select.value === null ? '' : undefined, onClick: event => {
|
|
204
|
+
onClick?.(event);
|
|
205
|
+
if (!event.defaultPrevented)
|
|
206
|
+
select.setOpen(!select.open);
|
|
207
|
+
}, onKeyDown: event => {
|
|
208
|
+
onKeyDown?.(event);
|
|
209
|
+
if (event.defaultPrevented || event.ctrlKey || event.altKey || event.metaKey)
|
|
210
|
+
return;
|
|
211
|
+
if (['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(event.key)) {
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
select.setOpen(true);
|
|
214
|
+
}
|
|
215
|
+
else if (event.key.length === 1) {
|
|
216
|
+
const next = select.search(event.key, select.value);
|
|
217
|
+
if (next !== undefined) {
|
|
218
|
+
event.preventDefault();
|
|
219
|
+
select.commit(next);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}, children: children ?? (_jsxs(_Fragment, { children: [_jsx(SelectValue, {}), _jsx(SelectIcon, {})] })) }));
|
|
223
|
+
}
|
|
224
|
+
export function SelectValue({ placeholder = 'Select an option', children, className, ...props }) {
|
|
225
|
+
const select = useSelectContext();
|
|
226
|
+
return (_jsx("span", { ...props, className: cn('min-w-0 truncate', className), "data-slot": "select-value", children: children ?? select.items.find(item => item.value === select.value)?.label ?? placeholder }));
|
|
227
|
+
}
|
|
228
|
+
export function SelectIcon({ children, className, ...props }) {
|
|
229
|
+
return (_jsx("span", { ...props, "aria-hidden": "true", "data-slot": "select-icon", className: cn('shrink-0', className), children: children ?? (_jsx("svg", { 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" }) })) }));
|
|
230
|
+
}
|
|
231
|
+
/** Portal into the trigger's local scope; the top layer escapes clipping and modal bounds. */
|
|
232
|
+
export function SelectPortal({ children }) {
|
|
233
|
+
const select = useSelectContext();
|
|
234
|
+
return select.trigger?.parentElement ? createPortal(children, select.trigger.parentElement) : null;
|
|
235
|
+
}
|
|
236
|
+
export function SelectContent({ children, position = 'item-aligned', sideOffset = 4, collisionPadding = 8, motion = 'inherit', className, onKeyDown, ref, ...props }) {
|
|
237
|
+
const select = useSelectContext();
|
|
238
|
+
const mergedRef = useComposedRefs(select.content, ref);
|
|
239
|
+
const { ref: transitionRef, active: motionActive, off: motionOff } = useTransitionHost('popup', mergedRef, motion === 'off');
|
|
240
|
+
const latest = useRef(select);
|
|
241
|
+
useLayoutEffect(() => {
|
|
242
|
+
latest.current = select;
|
|
243
|
+
});
|
|
244
|
+
const wasOpen = useRef(false);
|
|
245
|
+
useLayoutEffect(() => {
|
|
246
|
+
const state = latest.current;
|
|
247
|
+
const node = state.content.current;
|
|
248
|
+
const trigger = state.trigger;
|
|
249
|
+
if (!node || !trigger)
|
|
250
|
+
return;
|
|
251
|
+
const doc = trigger.ownerDocument;
|
|
252
|
+
const win = doc.defaultView;
|
|
253
|
+
if (!state.open) {
|
|
254
|
+
if (wasOpen.current &&
|
|
255
|
+
latest.current.restoreFocus.current &&
|
|
256
|
+
node.contains(doc.activeElement))
|
|
257
|
+
trigger.focus({ preventScroll: true });
|
|
258
|
+
if (node.matches(':popover-open'))
|
|
259
|
+
node.hidePopover();
|
|
260
|
+
wasOpen.current = false;
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const seedWidth = () => {
|
|
264
|
+
const available = (win.visualViewport?.width ?? win.innerWidth) - 2 * Math.max(0, collisionPadding);
|
|
265
|
+
const width = `${Math.min(trigger.getBoundingClientRect().width, Math.max(0, available))}px`;
|
|
266
|
+
if (node.style.getPropertyValue('--_rad-select-width') !== width)
|
|
267
|
+
node.style.setProperty('--_rad-select-width', width);
|
|
268
|
+
};
|
|
269
|
+
// Top-layer auto layout is viewport-sized. Establish the anchor width before it can paint.
|
|
270
|
+
seedWidth();
|
|
271
|
+
node.showPopover();
|
|
272
|
+
const place = () => {
|
|
273
|
+
if (!node.isConnected || !node.matches(':popover-open'))
|
|
274
|
+
return;
|
|
275
|
+
seedWidth();
|
|
276
|
+
const viewport = win.visualViewport;
|
|
277
|
+
const selected = Array.from(node.querySelectorAll('[data-slot~="select-item"]')).find(item => item.dataset.value === latest.current.value);
|
|
278
|
+
const rect = trigger.getBoundingClientRect();
|
|
279
|
+
const computed = win.getComputedStyle(node);
|
|
280
|
+
const viewportNode = node.querySelector('[data-slot="select-viewport"]');
|
|
281
|
+
const naturalHeight = viewportNode
|
|
282
|
+
? viewportNode.scrollHeight +
|
|
283
|
+
parseFloat(computed.paddingTop) +
|
|
284
|
+
parseFloat(computed.paddingBottom)
|
|
285
|
+
: node.scrollHeight;
|
|
286
|
+
const next = positionSelect({
|
|
287
|
+
trigger: rect,
|
|
288
|
+
width: node.getBoundingClientRect().width,
|
|
289
|
+
height: naturalHeight +
|
|
290
|
+
parseFloat(computed.borderTopWidth) +
|
|
291
|
+
parseFloat(computed.borderBottomWidth),
|
|
292
|
+
selectedOffset: selected ? selected.offsetTop + selected.offsetHeight / 2 : 24,
|
|
293
|
+
viewport: {
|
|
294
|
+
top: viewport?.offsetTop ?? 0,
|
|
295
|
+
left: viewport?.offsetLeft ?? 0,
|
|
296
|
+
width: viewport?.width ?? win.innerWidth,
|
|
297
|
+
height: viewport?.height ?? win.innerHeight
|
|
298
|
+
},
|
|
299
|
+
padding: Math.max(0, collisionPadding),
|
|
300
|
+
offset: sideOffset,
|
|
301
|
+
aligned: position === 'item-aligned',
|
|
302
|
+
rtl: win.getComputedStyle(trigger).direction === 'rtl'
|
|
303
|
+
});
|
|
304
|
+
for (const [key, value] of Object.entries({
|
|
305
|
+
top: next.top,
|
|
306
|
+
left: next.left,
|
|
307
|
+
width: next.width,
|
|
308
|
+
'max-height': next.maxHeight
|
|
309
|
+
}))
|
|
310
|
+
if (node.style.getPropertyValue(`--_rad-select-${key}`) !== `${value}px`)
|
|
311
|
+
node.style.setProperty(`--_rad-select-${key}`, `${value}px`);
|
|
312
|
+
};
|
|
313
|
+
place();
|
|
314
|
+
const active = doc.activeElement;
|
|
315
|
+
if (!wasOpen.current ||
|
|
316
|
+
active === doc.body ||
|
|
317
|
+
active?.getAttribute('aria-disabled') === 'true') {
|
|
318
|
+
const first = state.items.find(item => item.value === state.value && !item.disabled) ??
|
|
319
|
+
state.items.find(item => !item.disabled);
|
|
320
|
+
if (first)
|
|
321
|
+
state.focus(first.value);
|
|
322
|
+
else
|
|
323
|
+
node.focus();
|
|
324
|
+
}
|
|
325
|
+
wasOpen.current = true;
|
|
326
|
+
const outside = (event) => {
|
|
327
|
+
const target = event.target;
|
|
328
|
+
if (!(target instanceof win.Node) || node.contains(target) || trigger.contains(target))
|
|
329
|
+
return;
|
|
330
|
+
latest.current.close(false);
|
|
331
|
+
};
|
|
332
|
+
const focusOut = (event) => {
|
|
333
|
+
const target = event.target;
|
|
334
|
+
if (target === doc.body || target === doc.documentElement)
|
|
335
|
+
return;
|
|
336
|
+
if (target instanceof win.Node && !node.contains(target) && !trigger.contains(target))
|
|
337
|
+
latest.current.close(false);
|
|
338
|
+
};
|
|
339
|
+
const scroll = (event) => {
|
|
340
|
+
if (!(event.target instanceof win.Node) || !node.contains(event.target))
|
|
341
|
+
place();
|
|
342
|
+
};
|
|
343
|
+
let frame = 0;
|
|
344
|
+
const schedule = () => {
|
|
345
|
+
if (!frame)
|
|
346
|
+
frame = win.requestAnimationFrame(() => {
|
|
347
|
+
frame = 0;
|
|
348
|
+
place();
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
const observer = new win.ResizeObserver(schedule);
|
|
352
|
+
const mutations = new win.MutationObserver(schedule);
|
|
353
|
+
mutations.observe(node, { childList: true, subtree: true, characterData: true });
|
|
354
|
+
observer.observe(trigger);
|
|
355
|
+
observer.observe(node);
|
|
356
|
+
doc.addEventListener('pointerdown', outside, true);
|
|
357
|
+
doc.addEventListener('focusin', focusOut);
|
|
358
|
+
doc.addEventListener('scroll', scroll, true);
|
|
359
|
+
win.addEventListener('resize', place);
|
|
360
|
+
win.visualViewport?.addEventListener('resize', place);
|
|
361
|
+
win.visualViewport?.addEventListener('scroll', place);
|
|
362
|
+
return () => {
|
|
363
|
+
observer.disconnect();
|
|
364
|
+
mutations.disconnect();
|
|
365
|
+
win.cancelAnimationFrame(frame);
|
|
366
|
+
doc.removeEventListener('pointerdown', outside, true);
|
|
367
|
+
doc.removeEventListener('focusin', focusOut);
|
|
368
|
+
doc.removeEventListener('scroll', scroll, true);
|
|
369
|
+
win.removeEventListener('resize', place);
|
|
370
|
+
win.visualViewport?.removeEventListener('resize', place);
|
|
371
|
+
win.visualViewport?.removeEventListener('scroll', place);
|
|
372
|
+
};
|
|
373
|
+
}, [select.open, select.trigger, select.items, position, sideOffset, collisionPadding]);
|
|
374
|
+
useLayoutEffect(() => {
|
|
375
|
+
const node = select.content.current;
|
|
376
|
+
const trigger = select.trigger;
|
|
377
|
+
return () => {
|
|
378
|
+
if (node?.contains(node.ownerDocument.activeElement) && trigger?.isConnected)
|
|
379
|
+
trigger.focus({ preventScroll: true });
|
|
380
|
+
};
|
|
381
|
+
}, [select.content, select.trigger]);
|
|
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
|
+
!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 => {
|
|
385
|
+
onKeyDown?.(event);
|
|
386
|
+
if (event.defaultPrevented)
|
|
387
|
+
return;
|
|
388
|
+
if (event.key === 'Escape') {
|
|
389
|
+
event.preventDefault();
|
|
390
|
+
event.stopPropagation();
|
|
391
|
+
select.close();
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
if (event.key === 'Tab') {
|
|
395
|
+
event.preventDefault();
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
if (event.ctrlKey || event.altKey || event.metaKey)
|
|
399
|
+
return;
|
|
400
|
+
const target = event.target;
|
|
401
|
+
const current = target.closest('[data-slot~="select-item"]')?.dataset.value ?? null;
|
|
402
|
+
if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {
|
|
403
|
+
event.preventDefault();
|
|
404
|
+
select.focus(moveSelectFocus(select.entries, current, event.key));
|
|
405
|
+
}
|
|
406
|
+
else if (event.key.length === 1 && event.key !== ' ') {
|
|
407
|
+
event.preventDefault();
|
|
408
|
+
select.focus(select.search(event.key, current));
|
|
409
|
+
}
|
|
410
|
+
}, children: children ?? (_jsx(SelectViewport, { children: select.items.map(item => (_jsxs(SelectItem, { value: item.value, children: [_jsx(SelectItemText, {}), _jsx(SelectItemIndicator, {})] }, item.value))) })) }));
|
|
411
|
+
}
|
|
412
|
+
export function SelectViewport({ className, ...props }) {
|
|
413
|
+
return (_jsx("div", { ...props, "data-slot": "select-viewport", className: cn('max-h-[calc(var(--_rad-select-max-height,100dvh)-0.5rem)] overflow-y-auto overscroll-contain', className) }));
|
|
414
|
+
}
|
|
415
|
+
export function SelectItem({ value, children, className, onKeyDown, onClick, onPointerMove, ...props }) {
|
|
416
|
+
const select = useSelectContext();
|
|
417
|
+
const item = select.items.find(item => item.value === value);
|
|
418
|
+
if (!item)
|
|
419
|
+
throw new Error('SelectItem value must exist in Select items.');
|
|
420
|
+
return (_jsx(SelectItemContext.Provider, { value: item, children: _jsx("div", { ...props, role: "option", tabIndex: -1, "aria-selected": select.value === value, "aria-disabled": item.disabled || undefined, "data-slot": "select-item", "data-value": value, "data-disabled": item.disabled ? '' : undefined, "data-state": select.value === value ? 'checked' : 'unchecked', className: cn(selectItemClass, className), onClick: event => {
|
|
421
|
+
onClick?.(event);
|
|
422
|
+
if (!event.defaultPrevented && !item.disabled)
|
|
423
|
+
select.commit(value);
|
|
424
|
+
}, onPointerMove: event => {
|
|
425
|
+
onPointerMove?.(event);
|
|
426
|
+
if (!event.defaultPrevented && event.pointerType === 'mouse' && !item.disabled)
|
|
427
|
+
event.currentTarget.focus({ preventScroll: true });
|
|
428
|
+
}, onKeyDown: event => {
|
|
429
|
+
onKeyDown?.(event);
|
|
430
|
+
if (!event.defaultPrevented && ['Enter', ' '].includes(event.key)) {
|
|
431
|
+
event.preventDefault();
|
|
432
|
+
if (!item.disabled)
|
|
433
|
+
select.commit(value);
|
|
434
|
+
}
|
|
435
|
+
}, children: children ?? (_jsxs(_Fragment, { children: [_jsx(SelectItemText, {}), _jsx(SelectItemIndicator, {})] })) }) }));
|
|
436
|
+
}
|
|
437
|
+
export function SelectItemText({ children, className, ...props }) {
|
|
438
|
+
const item = useContext(SelectItemContext);
|
|
439
|
+
if (!item)
|
|
440
|
+
throw new Error('SelectItemText must render inside SelectItem.');
|
|
441
|
+
return (_jsx("span", { ...props, "data-slot": "select-item-text", className: cn('min-w-0 flex-1', className), children: children ?? item.label }));
|
|
442
|
+
}
|
|
443
|
+
export function SelectItemIndicator({ children, className, ...props }) {
|
|
444
|
+
const select = useSelectContext();
|
|
445
|
+
const item = useContext(SelectItemContext);
|
|
446
|
+
if (!item)
|
|
447
|
+
throw new Error('SelectItemIndicator must render inside SelectItem.');
|
|
448
|
+
return (_jsx("span", { ...props, "data-slot": "select-item-indicator", "aria-hidden": "true", className: cn('shrink-0', select.value !== item.value && 'invisible', className), children: children ?? '✓' }));
|
|
449
|
+
}
|
|
450
|
+
export function SelectGroup({ label, children, className, ...props }) {
|
|
451
|
+
const id = useId();
|
|
452
|
+
return (_jsxs("div", { ...props, role: "group", "aria-labelledby": id, "data-slot": "select-group", className: className, children: [_jsx("div", { id: id, "data-slot": "select-label", className: "px-3 py-2 text-sm font-semibold", children: label }), children] }));
|
|
453
|
+
}
|
|
454
|
+
//# sourceMappingURL=Select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../src/Select.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,6JAA6J;AAE7J,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,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AA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S,EAAE,SAAS,aAEpB,cACE,EAAE,EAAE,EAAE,eACI,cAAc,EACxB,SAAS,EAAC,iCAAiC,YAE1C,KAAK,GACF,EACL,QAAQ,IACL,CACP,CAAA;AACH,CAAC","sourcesContent":["'use client'\n\n/* oxlint-disable jsx-a11y/prefer-tag-over-role -- A custom select needs ARIA on its trigger/listbox/options; the native select is a separate 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 { matchSelectText, moveSelectFocus, positionSelect } from './internal/select.js'\nimport { useComposedRefs } from './react/useComposedRefs.js'\nimport { useControllableState } from './react/useControllableState.js'\nimport { useTransitionHost } from './motion/host.js'\nimport type { ValueOwner } from './react/useNativeOwner.js'\nimport type { ControlSize } from './presentation.js'\nimport type { ThemeStyle } from './themes/defineTheme.js'\nimport { selectContentClass, selectItemClass, selectTriggerClass } from './selectStyles.js'\n\nexport type SelectOption = { value: string; disabled?: boolean } & (\n | { label: string; textValue?: string }\n | { label: ReactNode; textValue: string }\n)\nexport type SelectProps = ValueOwner<string | null> &\n ({ open: boolean; defaultOpen?: never } | { open?: undefined; defaultOpen?: boolean }) & {\n /** One registry for native options, SSR value text and keyboard matching. Values must be unique. */\n items: readonly SelectOption[]\n onValueChange?: (value: string | null) => void\n onOpenChange?: (open: boolean) => void\n name?: string\n form?: string\n autoComplete?: string\n disabled?: boolean\n required?: boolean\n controlSize?: ControlSize\n children?: ReactNode\n }\n\nexport type SelectState = {\n value: string | null\n open: boolean\n disabled: boolean\n setValue(value: string | null): void\n setOpen(open: boolean): void\n}\ntype Context = SelectState & {\n items: readonly SelectOption[]\n entries: { value: string; textValue: string; disabled?: boolean }[]\n controlSize: ControlSize\n required: boolean\n triggerId: string\n contentId: string\n labelId?: string\n trigger: HTMLButtonElement | null\n setTrigger(node: HTMLButtonElement | null): void\n content: RefObject<HTMLDivElement | null>\n focus(value?: string): void\n commit(value: string): void\n close(restore?: boolean): void\n search(key: string, current: string | null): string | undefined\n restoreFocus: RefObject<boolean>\n}\nconst SelectContext = createContext<Context | null>(null)\nconst SelectItemContext = createContext<SelectOption | null>(null)\nexport function useSelect(): SelectState | null {\n return useContext(SelectContext)\n}\nfunction useSelectContext() {\n const select = useContext(SelectContext)\n if (!select) throw new Error('Select parts must render inside Select.')\n return select\n}\n\n/** Custom selection presentation with a real native form control. */\nexport function Select({\n items,\n value,\n defaultValue,\n onValueChange,\n open,\n defaultOpen,\n onOpenChange,\n name,\n form,\n autoComplete,\n disabled: disabledProp,\n required: requiredProp,\n controlSize = 'medium',\n children\n}: SelectProps) {\n const ids = useId()\n const field = useField()\n const disabled = !!(disabledProp || field?.disabled)\n const required = !!(requiredProp || field?.required)\n const entries = items.map(item => ({\n value: item.value,\n disabled: item.disabled,\n textValue: item.textValue ?? (typeof item.label === 'string' ? item.label : '')\n }))\n if (new Set(entries.map(item => item.value)).size !== items.length)\n throw new TypeError('Select item values must be distinct.')\n if (entries.some(item => typeof item.value !== 'string' || !item.textValue.trim()))\n throw new TypeError('Select items need a string value and readable textValue.')\n const selection = useControllableState({\n name: 'Select',\n value,\n defaultValue,\n initialValue: null,\n onChange: onValueChange\n })\n const expansion = useControllableState({\n name: 'Select open',\n value: open,\n defaultValue: defaultOpen,\n initialValue: false,\n onChange: onOpenChange\n })\n const [trigger, setTrigger] = useState<HTMLButtonElement | null>(null)\n const bridge = useRef<HTMLSelectElement>(null)\n const content = useRef<HTMLDivElement>(null)\n const restoreFocus = useRef(true)\n const pendingUser = useRef<string | null>(null)\n const dispatching = useRef(false)\n const searchBuffer = useRef({ text: '', at: 0 })\n const selected = items.find(item => item.value === selection.value)\n const nativeValue = selected?.value ?? ''\n const [initialNativeValue] = useState(nativeValue)\n const isOpen = expansion.value && !disabled\n const unavailable = () => disabled || !!trigger?.matches(':disabled')\n const setOpen = (next: boolean) => {\n if (next && unavailable()) return\n searchBuffer.current = { text: '', at: 0 }\n restoreFocus.current = true\n expansion.request(next)\n }\n const close = (restore = true) => {\n restoreFocus.current = restore\n expansion.request(false)\n }\n const focus = (itemValue?: string) => {\n const nodes = content.current?.querySelectorAll<HTMLElement>('[data-slot~=\"select-item\"]')\n const option = Array.from(nodes ?? []).find(\n node => node.dataset.value === itemValue && node.getAttribute('aria-disabled') !== 'true'\n )\n option?.focus({ preventScroll: true })\n option?.scrollIntoView({ block: 'nearest' })\n }\n const commit = (next: string) => {\n if (unavailable() || !items.some(item => item.value === next && !item.disabled)) return\n if (next !== selection.value) pendingUser.current = next\n selection.request(next)\n close()\n // A declined controlled request must not become a later programmatic change event.\n queueMicrotask(() => {\n pendingUser.current = null\n })\n }\n const latest = useRef({ selection, close, nativeValue })\n useLayoutEffect(() => {\n latest.current = { selection, close, nativeValue }\n })\n useLayoutEffect(() => {\n const node = bridge.current\n if (!node) return\n node.value = nativeValue\n if (selection.controlled)\n for (const option of node.options) option.defaultSelected = option.value === nativeValue\n if (pendingUser.current !== null && pendingUser.current === nativeValue) {\n pendingUser.current = null\n dispatching.current = true\n try {\n node.dispatchEvent(new Event('change', { bubbles: true }))\n } finally {\n dispatching.current = false\n }\n }\n })\n useEffect(() => {\n const node = bridge.current\n const owner = node?.form\n if (!owner) return\n const win = node.ownerDocument.defaultView!\n let resetTimer: number | undefined\n const reset = (event: Event) => {\n win.clearTimeout(resetTimer)\n resetTimer = win.setTimeout(() => {\n if (event.defaultPrevented || !node.isConnected) return\n latest.current.selection.reset()\n if (latest.current.selection.controlled) node.value = latest.current.nativeValue\n latest.current.close(false)\n }, 0)\n }\n owner.addEventListener('reset', reset)\n return () => {\n owner.removeEventListener('reset', reset)\n win.clearTimeout(resetTimer)\n }\n }, [form, trigger])\n useEffect(() => {\n if (\n !isOpen &&\n restoreFocus.current &&\n content.current?.contains(content.current.ownerDocument.activeElement)\n )\n trigger?.focus({ preventScroll: true })\n }, [isOpen, trigger])\n const context: Context = {\n value: selection.value,\n setValue: selection.request,\n open: isOpen,\n setOpen,\n disabled,\n items,\n entries,\n controlSize,\n required,\n triggerId: field?.controlProps?.id ?? `${ids}-trigger`,\n contentId: `${ids}-content`,\n labelId: field?.layout === 'control' ? field.labelId : undefined,\n trigger,\n setTrigger,\n content,\n focus,\n commit,\n close,\n restoreFocus,\n search(key, current) {\n const now = Date.now()\n const text = (now - searchBuffer.current.at < 1000 ? searchBuffer.current.text : '') + key\n searchBuffer.current = { text, at: now }\n return matchSelectText(entries, text, current)\n }\n }\n return (\n <SelectContext.Provider value={context}>\n {children ?? (\n <>\n <SelectTrigger>\n <SelectValue />\n <SelectIcon />\n </SelectTrigger>\n <SelectPortal>\n <SelectContent />\n </SelectPortal>\n </>\n )}\n <select\n ref={bridge}\n name={name}\n form={form}\n autoComplete={autoComplete}\n required={required}\n disabled={disabled}\n aria-hidden=\"true\"\n tabIndex={-1}\n className=\"sr-only\"\n data-slot=\"select-native\"\n defaultValue={initialNativeValue}\n onFocus={() => trigger?.focus()}\n onInvalid={event => {\n event.preventDefault()\n trigger?.focus()\n }}\n onChange={event => {\n if (dispatching.current) return\n const next = event.currentTarget.value\n if (unavailable()) {\n event.currentTarget.value = latest.current.nativeValue\n return\n }\n if (items.some(item => item.value === next && !item.disabled)) selection.request(next)\n if (selection.controlled) event.currentTarget.value = nativeValue\n }}\n >\n {!items.some(item => item.value === '') && <option value=\"\">No selection</option>}\n {items.map(item => (\n <option\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n >\n {item.textValue ?? item.label}\n </option>\n ))}\n </select>\n </SelectContext.Provider>\n )\n}\n\nexport type SelectTriggerProps = Omit<\n ButtonProps,\n 'variant' | 'tone' | 'type' | 'pending' | 'controlSize' | 'disabled'\n>\nexport function SelectTrigger({\n className,\n onClick,\n onKeyDown,\n ref,\n children,\n ...props\n}: SelectTriggerProps) {\n const select = useSelectContext()\n const control = useFieldControl({\n id: props.id ?? select.triggerId,\n disabled: select.disabled,\n required: select.required,\n 'aria-describedby': props['aria-describedby'],\n 'aria-invalid': props['aria-invalid']\n })\n const hostRef = useComposedRefs(select.setTrigger, ref)\n return (\n <Button\n {...props}\n {...control}\n ref={hostRef}\n variant=\"outline\"\n tone=\"neutral\"\n type=\"button\"\n controlSize={select.controlSize}\n className={cn(\n selectTriggerClass,\n controlMetrics({ controlSize: select.controlSize }),\n className\n )}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-controls={select.contentId}\n aria-expanded={select.open}\n aria-required={select.required || undefined}\n data-slot=\"button select-trigger\"\n data-state={select.open ? 'open' : 'closed'}\n data-placeholder={select.value === null ? '' : undefined}\n onClick={event => {\n onClick?.(event)\n if (!event.defaultPrevented) select.setOpen(!select.open)\n }}\n onKeyDown={event => {\n onKeyDown?.(event)\n if (event.defaultPrevented || event.ctrlKey || event.altKey || event.metaKey) return\n if (['Enter', ' ', 'ArrowDown', 'ArrowUp'].includes(event.key)) {\n event.preventDefault()\n select.setOpen(true)\n } else if (event.key.length === 1) {\n const next = select.search(event.key, select.value)\n if (next !== undefined) {\n event.preventDefault()\n select.commit(next)\n }\n }\n }}\n >\n {children ?? (\n <>\n <SelectValue />\n <SelectIcon />\n </>\n )}\n </Button>\n )\n}\n\nexport type SelectValueProps = Omit<ComponentProps<'span'>, 'style'> & {\n placeholder?: ReactNode\n style?: ThemeStyle\n}\nexport function SelectValue({\n placeholder = 'Select an option',\n children,\n className,\n ...props\n}: SelectValueProps) {\n const select = useSelectContext()\n return (\n <span\n {...props}\n className={cn('min-w-0 truncate', className)}\n data-slot=\"select-value\"\n >\n {children ?? select.items.find(item => item.value === select.value)?.label ?? placeholder}\n </span>\n )\n}\nexport type SelectIconProps = Omit<ComponentProps<'span'>, 'style'> & { style?: ThemeStyle }\nexport function SelectIcon({ children, className, ...props }: SelectIconProps) {\n return (\n <span\n {...props}\n aria-hidden=\"true\"\n data-slot=\"select-icon\"\n className={cn('shrink-0', className)}\n >\n {children ?? (\n <svg\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 </span>\n )\n}\n\n/** Portal into the trigger's local scope; the top layer escapes clipping and modal bounds. */\nexport function SelectPortal({ children }: { children?: ReactNode }) {\n const select = useSelectContext()\n return select.trigger?.parentElement ? createPortal(children, select.trigger.parentElement) : null\n}\n\nexport type SelectContentProps = Omit<ComponentProps<'div'>, 'style' | 'popover'> & {\n style?: ThemeStyle\n position?: 'item-aligned' | 'popper'\n sideOffset?: number\n collisionPadding?: number\n motion?: 'inherit' | 'off'\n}\nexport function SelectContent({\n children,\n position = 'item-aligned',\n sideOffset = 4,\n collisionPadding = 8,\n motion = 'inherit',\n className,\n onKeyDown,\n ref,\n ...props\n}: SelectContentProps) {\n const select = useSelectContext()\n const mergedRef = useComposedRefs(select.content, ref)\n const {\n ref: transitionRef,\n active: motionActive,\n off: motionOff\n } = useTransitionHost('popup', mergedRef, motion === 'off')\n const latest = useRef(select)\n useLayoutEffect(() => {\n latest.current = select\n })\n const wasOpen = useRef(false)\n useLayoutEffect(() => {\n const state = latest.current\n const node = state.content.current\n const trigger = state.trigger\n if (!node || !trigger) return\n const doc = trigger.ownerDocument\n const win = doc.defaultView!\n if (!state.open) {\n if (\n wasOpen.current &&\n latest.current.restoreFocus.current &&\n node.contains(doc.activeElement)\n )\n trigger.focus({ preventScroll: true })\n if (node.matches(':popover-open')) node.hidePopover()\n wasOpen.current = false\n return\n }\n const seedWidth = () => {\n const available =\n (win.visualViewport?.width ?? win.innerWidth) - 2 * Math.max(0, collisionPadding)\n const width = `${Math.min(trigger.getBoundingClientRect().width, Math.max(0, available))}px`\n if (node.style.getPropertyValue('--_rad-select-width') !== width)\n node.style.setProperty('--_rad-select-width', width)\n }\n // Top-layer auto layout is viewport-sized. Establish the anchor width before it can paint.\n seedWidth()\n node.showPopover()\n const place = () => {\n if (!node.isConnected || !node.matches(':popover-open')) return\n seedWidth()\n const viewport = win.visualViewport\n const selected = Array.from(\n node.querySelectorAll<HTMLElement>('[data-slot~=\"select-item\"]')\n ).find(item => item.dataset.value === latest.current.value)\n const rect = trigger.getBoundingClientRect()\n const computed = win.getComputedStyle(node)\n const viewportNode = node.querySelector<HTMLElement>('[data-slot=\"select-viewport\"]')\n const naturalHeight = viewportNode\n ? viewportNode.scrollHeight +\n parseFloat(computed.paddingTop) +\n parseFloat(computed.paddingBottom)\n : node.scrollHeight\n const next = positionSelect({\n trigger: rect,\n width: node.getBoundingClientRect().width,\n height:\n naturalHeight +\n parseFloat(computed.borderTopWidth) +\n parseFloat(computed.borderBottomWidth),\n selectedOffset: selected ? selected.offsetTop + selected.offsetHeight / 2 : 24,\n viewport: {\n top: viewport?.offsetTop ?? 0,\n left: viewport?.offsetLeft ?? 0,\n width: viewport?.width ?? win.innerWidth,\n height: viewport?.height ?? win.innerHeight\n },\n padding: Math.max(0, collisionPadding),\n offset: sideOffset,\n aligned: position === 'item-aligned',\n rtl: win.getComputedStyle(trigger).direction === 'rtl'\n })\n for (const [key, value] of Object.entries({\n top: next.top,\n left: next.left,\n width: next.width,\n 'max-height': next.maxHeight\n }))\n if (node.style.getPropertyValue(`--_rad-select-${key}`) !== `${value}px`)\n node.style.setProperty(`--_rad-select-${key}`, `${value}px`)\n }\n place()\n const active = doc.activeElement as HTMLElement | null\n if (\n !wasOpen.current ||\n active === doc.body ||\n active?.getAttribute('aria-disabled') === 'true'\n ) {\n const first =\n state.items.find(item => item.value === state.value && !item.disabled) ??\n state.items.find(item => !item.disabled)\n if (first) state.focus(first.value)\n else node.focus()\n }\n wasOpen.current = true\n const outside = (event: PointerEvent) => {\n const target = event.target\n if (!(target instanceof win.Node) || node.contains(target) || trigger.contains(target)) return\n latest.current.close(false)\n }\n const focusOut = (event: FocusEvent) => {\n const target = event.target\n if (target === doc.body || target === doc.documentElement) return\n if (target instanceof win.Node && !node.contains(target) && !trigger.contains(target))\n latest.current.close(false)\n }\n const scroll = (event: Event) => {\n if (!(event.target instanceof win.Node) || !node.contains(event.target)) place()\n }\n let frame = 0\n const schedule = () => {\n if (!frame)\n frame = win.requestAnimationFrame(() => {\n frame = 0\n place()\n })\n }\n const observer = new win.ResizeObserver(schedule)\n const mutations = new win.MutationObserver(schedule)\n mutations.observe(node, { childList: true, subtree: true, characterData: true })\n observer.observe(trigger)\n observer.observe(node)\n doc.addEventListener('pointerdown', outside, true)\n doc.addEventListener('focusin', focusOut)\n doc.addEventListener('scroll', scroll, true)\n win.addEventListener('resize', place)\n win.visualViewport?.addEventListener('resize', place)\n win.visualViewport?.addEventListener('scroll', place)\n return () => {\n observer.disconnect()\n mutations.disconnect()\n win.cancelAnimationFrame(frame)\n doc.removeEventListener('pointerdown', outside, true)\n doc.removeEventListener('focusin', focusOut)\n doc.removeEventListener('scroll', scroll, true)\n win.removeEventListener('resize', place)\n win.visualViewport?.removeEventListener('resize', place)\n win.visualViewport?.removeEventListener('scroll', place)\n }\n }, [select.open, select.trigger, select.items, position, sideOffset, collisionPadding])\n useLayoutEffect(() => {\n const node = select.content.current\n const trigger = select.trigger\n return () => {\n if (node?.contains(node.ownerDocument.activeElement) && trigger?.isConnected)\n trigger.focus({ preventScroll: true })\n }\n }, [select.content, select.trigger])\n return (\n <div\n {...props}\n ref={transitionRef}\n id={select.contentId}\n popover=\"manual\"\n role=\"listbox\"\n tabIndex={-1}\n aria-labelledby={\n props['aria-label'] ? undefined : (select.labelId ?? select.trigger?.id ?? select.triggerId)\n }\n className={cn(\n selectContentClass,\n controlMetrics({ controlSize: select.controlSize }),\n motionActive &&\n !motionOff &&\n 'opacity-[var(--_rad-select-enter,0)] motion-reduce:opacity-100',\n className\n )}\n data-slot=\"select-content\"\n data-state={select.open ? 'open' : 'closed'}\n data-motion={motion}\n data-position={position}\n onKeyDown={event => {\n onKeyDown?.(event)\n if (event.defaultPrevented) return\n if (event.key === 'Escape') {\n event.preventDefault()\n event.stopPropagation()\n select.close()\n return\n }\n if (event.key === 'Tab') {\n event.preventDefault()\n return\n }\n if (event.ctrlKey || event.altKey || event.metaKey) return\n const target = event.target as HTMLElement\n const current =\n target.closest<HTMLElement>('[data-slot~=\"select-item\"]')?.dataset.value ?? null\n if (['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) {\n event.preventDefault()\n select.focus(moveSelectFocus(select.entries, current, event.key))\n } else if (event.key.length === 1 && event.key !== ' ') {\n event.preventDefault()\n select.focus(select.search(event.key, current))\n }\n }}\n >\n {children ?? (\n <SelectViewport>\n {select.items.map(item => (\n <SelectItem\n key={item.value}\n value={item.value}\n >\n <SelectItemText />\n <SelectItemIndicator />\n </SelectItem>\n ))}\n </SelectViewport>\n )}\n </div>\n )\n}\n\nexport type SelectViewportProps = Omit<ComponentProps<'div'>, 'style'> & { style?: ThemeStyle }\nexport function SelectViewport({ className, ...props }: SelectViewportProps) {\n return (\n <div\n {...props}\n data-slot=\"select-viewport\"\n className={cn(\n 'max-h-[calc(var(--_rad-select-max-height,100dvh)-0.5rem)] overflow-y-auto overscroll-contain',\n className\n )}\n />\n )\n}\nexport type SelectItemProps = Omit<ComponentProps<'div'>, 'style'> & {\n value: string\n style?: ThemeStyle\n}\nexport function SelectItem({\n value,\n children,\n className,\n onKeyDown,\n onClick,\n onPointerMove,\n ...props\n}: SelectItemProps) {\n const select = useSelectContext()\n const item = select.items.find(item => item.value === value)\n if (!item) throw new Error('SelectItem value must exist in Select items.')\n return (\n <SelectItemContext.Provider value={item}>\n <div\n {...props}\n role=\"option\"\n tabIndex={-1}\n aria-selected={select.value === value}\n aria-disabled={item.disabled || undefined}\n data-slot=\"select-item\"\n data-value={value}\n data-disabled={item.disabled ? '' : undefined}\n data-state={select.value === value ? 'checked' : 'unchecked'}\n className={cn(selectItemClass, className)}\n onClick={event => {\n onClick?.(event)\n if (!event.defaultPrevented && !item.disabled) select.commit(value)\n }}\n onPointerMove={event => {\n onPointerMove?.(event)\n if (!event.defaultPrevented && event.pointerType === 'mouse' && !item.disabled)\n event.currentTarget.focus({ preventScroll: true })\n }}\n onKeyDown={event => {\n onKeyDown?.(event)\n if (!event.defaultPrevented && ['Enter', ' '].includes(event.key)) {\n event.preventDefault()\n if (!item.disabled) select.commit(value)\n }\n }}\n >\n {children ?? (\n <>\n <SelectItemText />\n <SelectItemIndicator />\n </>\n )}\n </div>\n </SelectItemContext.Provider>\n )\n}\nexport type SelectItemTextProps = Omit<ComponentProps<'span'>, 'style'> & { style?: ThemeStyle }\nexport function SelectItemText({ children, className, ...props }: SelectItemTextProps) {\n const item = useContext(SelectItemContext)\n if (!item) throw new Error('SelectItemText must render inside SelectItem.')\n return (\n <span\n {...props}\n data-slot=\"select-item-text\"\n className={cn('min-w-0 flex-1', className)}\n >\n {children ?? item.label}\n </span>\n )\n}\nexport function SelectItemIndicator({ children, className, ...props }: SelectIconProps) {\n const select = useSelectContext()\n const item = useContext(SelectItemContext)\n if (!item) throw new Error('SelectItemIndicator must render inside SelectItem.')\n return (\n <span\n {...props}\n data-slot=\"select-item-indicator\"\n aria-hidden=\"true\"\n className={cn('shrink-0', select.value !== item.value && 'invisible', className)}\n >\n {children ?? '✓'}\n </span>\n )\n}\nexport type SelectGroupProps = Omit<ComponentProps<'div'>, 'style'> & {\n label: ReactNode\n style?: ThemeStyle\n}\nexport function SelectGroup({ label, children, className, ...props }: SelectGroupProps) {\n const id = useId()\n return (\n <div\n {...props}\n role=\"group\"\n aria-labelledby={id}\n data-slot=\"select-group\"\n className={className}\n >\n <div\n id={id}\n data-slot=\"select-label\"\n className=\"px-3 py-2 text-sm font-semibold\"\n >\n {label}\n </div>\n {children}\n </div>\n )\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { type ValueOwner } from './react/useNativeOwner.js';
|
|
3
|
+
import type { ThemeStyle } from './themes/defineTheme.js';
|
|
4
|
+
import type { ControlSize } from './presentation.js';
|
|
5
|
+
export type TextareaProps = Omit<ComponentProps<'textarea'>, 'value' | 'defaultValue' | 'style' | 'children'> & ValueOwner<Exclude<ComponentProps<'textarea'>['value'], undefined>> & {
|
|
6
|
+
/** Set initial text with defaultValue. */
|
|
7
|
+
children?: never;
|
|
8
|
+
/** Shared visual metrics. Native rows and cols keep their browser meanings. */
|
|
9
|
+
controlSize?: ControlSize;
|
|
10
|
+
/** Applied to the native textarea, including caller-owned motion styles. */
|
|
11
|
+
style?: ThemeStyle;
|
|
12
|
+
};
|
|
13
|
+
/** Native editing, selection, events and ref; Field supplies owned form relationships. */
|
|
14
|
+
export declare function Textarea({ className, controlSize, rows, id, disabled, required, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, ...props }: TextareaProps): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=Textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Textarea.d.ts","sourceRoot":"","sources":["../../src/Textarea.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAI3C,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAmCpD,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,cAAc,CAAC,UAAU,CAAC,EAC1B,OAAO,GAAG,cAAc,GAAG,OAAO,GAAG,UAAU,CAChD,GACC,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC,GAAG;IACpE,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB,CAAA;AAEH,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,EACvB,SAAS,EACT,WAAsB,EACtB,IAAQ,EACR,EAAE,EACF,QAAQ,EACR,QAAQ,EACR,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,YAAY,EAC7B,GAAG,KAAK,EACT,EAAE,aAAa,+BAuBf"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { cn } from './cn.js';
|
|
5
|
+
import { controlBorderClass, controlMetrics } from './controlStyles.js';
|
|
6
|
+
import { useNativeOwner } from './react/useNativeOwner.js';
|
|
7
|
+
import { useFieldControl } from './Field.js';
|
|
8
|
+
const textareaVariants = cva([
|
|
9
|
+
controlBorderClass,
|
|
10
|
+
'box-border w-full min-w-0',
|
|
11
|
+
'min-h-[var(--rad-textarea-min-height,var(--_rad-control-height))]',
|
|
12
|
+
'resize-y overflow-auto',
|
|
13
|
+
'py-[var(--rad-textarea-padding-block,calc((var(--_rad-control-height)_-_1lh)/2_-_var(--rad-textarea-border-width,var(--rad-control-border-width,1px))))]',
|
|
14
|
+
'px-[var(--rad-textarea-padding,var(--_rad-control-padding))]',
|
|
15
|
+
'font-[family-name:var(--rad-textarea-font-family,var(--rad-typography-roles-ui-body-family,system-ui,sans-serif))] tracking-[var(--rad-typography-roles-ui-body-letter-spacing,-0.011em)]',
|
|
16
|
+
'text-[length:var(--rad-textarea-font-size,var(--_rad-control-font-size))]',
|
|
17
|
+
'leading-[var(--rad-typography-roles-ui-body-line-height,1.5)]',
|
|
18
|
+
'font-[number:var(--rad-textarea-font-weight,var(--rad-typography-roles-ui-body-weight,400))]',
|
|
19
|
+
'[color:var(--rad-textarea-color,var(--rad-color-foreground,oklch(0.21_0.006_286)))]',
|
|
20
|
+
'bg-[var(--rad-textarea-background,var(--rad-color-surface,oklch(1_0_0)))]',
|
|
21
|
+
'[border-width:var(--rad-textarea-border-width,var(--rad-control-border-width,1px))]',
|
|
22
|
+
'[border-style:var(--rad-textarea-border-style,var(--rad-control-border-style,solid))]',
|
|
23
|
+
'[border-color:var(--rad-textarea-border-color,var(--_rad-control-border))]',
|
|
24
|
+
'rounded-[var(--rad-textarea-radius,var(--rad-control-radius,0.5rem))]',
|
|
25
|
+
'[corner-shape:var(--rad-textarea-corner-shape,var(--rad-control-corner-shape,round))]',
|
|
26
|
+
'[box-shadow:var(--rad-textarea-shadow,none)]',
|
|
27
|
+
'placeholder:[color:var(--rad-textarea-placeholder,var(--rad-color-placeholder,oklch(0.5_0.01_286)))]',
|
|
28
|
+
'focus-visible:outline-solid',
|
|
29
|
+
'focus-visible:[outline-color:var(--rad-textarea-focus-color,var(--rad-color-focus,oklch(0.55_0.13_255)))]',
|
|
30
|
+
'focus-visible:[outline-width:var(--rad-textarea-focus-width,var(--rad-focus-width,2px))]',
|
|
31
|
+
'focus-visible:[outline-offset:var(--rad-textarea-focus-offset,var(--rad-focus-offset,2px))]',
|
|
32
|
+
'focus-visible:[outline-style:var(--rad-textarea-focus-style,var(--rad-focus-style,solid))]',
|
|
33
|
+
'data-invalid:[border-color:var(--rad-textarea-invalid-border,var(--rad-color-invalid,oklch(0.56_0.19_25)))]',
|
|
34
|
+
'disabled:cursor-not-allowed',
|
|
35
|
+
'disabled:[background:var(--rad-textarea-disabled-background,var(--rad-color-disabled-background,oklch(0.96_0.005_286)))]',
|
|
36
|
+
'forced-colors:border-[CanvasText] forced-colors:text-[CanvasText]',
|
|
37
|
+
'forced-colors:disabled:bg-[Canvas] forced-colors:disabled:text-[GrayText]'
|
|
38
|
+
]);
|
|
39
|
+
/** Native editing, selection, events and ref; Field supplies owned form relationships. */
|
|
40
|
+
export function Textarea({ className, controlSize = 'medium', rows = 3, id, disabled, required, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-required': ariaRequired, ...props }) {
|
|
41
|
+
useNativeOwner('Textarea', props.value, props.defaultValue);
|
|
42
|
+
if (props.value === null)
|
|
43
|
+
throw new TypeError('Textarea value cannot be null. Use an empty string.');
|
|
44
|
+
const control = useFieldControl({
|
|
45
|
+
id,
|
|
46
|
+
disabled,
|
|
47
|
+
required,
|
|
48
|
+
'aria-invalid': ariaInvalid,
|
|
49
|
+
'aria-required': ariaRequired,
|
|
50
|
+
'aria-describedby': ariaDescribedBy
|
|
51
|
+
});
|
|
52
|
+
return (_jsx("textarea", { ...props, ...control, className: cn(textareaVariants(), controlMetrics({ controlSize }), className), "data-control-size": controlSize, "data-slot": "textarea", rows: rows }));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=Textarea.js.map
|