@womp/kookie-ui 0.29.1 → 0.29.2
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/components.css +8 -2
- package/dist/cjs/components/index.js +2 -2
- package/dist/cjs/components/index.js.map +3 -3
- package/dist/cjs/components/select.d.ts.map +1 -1
- package/dist/cjs/components/select.js +1 -1
- package/dist/cjs/components/select.js.map +3 -3
- package/dist/cjs/components/text-field.d.ts.map +1 -1
- package/dist/cjs/components/text-field.js +2 -2
- package/dist/cjs/components/text-field.js.map +3 -3
- package/dist/cjs/components/text-field.props.d.ts +4 -1
- package/dist/cjs/components/text-field.props.d.ts.map +1 -1
- package/dist/cjs/components/text-field.props.js.map +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/props/index.js.map +1 -1
- package/dist/esm/chunk-676Y7ZUT.js +3 -0
- package/dist/esm/chunk-676Y7ZUT.js.map +7 -0
- package/dist/esm/{chunk-FIMFM25N.js → chunk-EXF5SF27.js} +1 -1
- package/dist/esm/{chunk-FIMFM25N.js.map → chunk-EXF5SF27.js.map} +1 -1
- package/dist/esm/chunk-K5V53KTJ.js +6 -0
- package/dist/esm/chunk-K5V53KTJ.js.map +7 -0
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/select.d.ts.map +1 -1
- package/dist/esm/components/select.js +1 -1
- package/dist/esm/components/text-field.d.ts.map +1 -1
- package/dist/esm/components/text-field.js +1 -1
- package/dist/esm/components/text-field.props.d.ts +4 -1
- package/dist/esm/components/text-field.props.d.ts.map +1 -1
- package/dist/esm/components/text-field.props.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/props/index.js +1 -1
- package/package.json +1 -1
- package/src/components/select.css +2 -2
- package/src/components/select.tsx +15 -1
- package/src/components/text-field.css +8 -1
- package/src/components/text-field.props.tsx +4 -1
- package/src/components/text-field.tsx +66 -86
- package/styles.css +8 -2
- package/dist/esm/chunk-GPZHRZBE.js +0 -6
- package/dist/esm/chunk-GPZHRZBE.js.map +0 -7
- package/dist/esm/chunk-VQDCHBZR.js +0 -3
- package/dist/esm/chunk-VQDCHBZR.js.map +0 -7
|
@@ -23,8 +23,14 @@ type TextFieldRootOwnProps = GetPropDefTypes<typeof textFieldRootPropDefs> & {
|
|
|
23
23
|
type TextFieldInputProps = ComponentPropsWithout<'input', NotInputTextualAttributes | 'color' | 'defaultValue' | 'size' | 'type' | 'value'>;
|
|
24
24
|
interface TextFieldRootProps extends TextFieldInputProps, TextFieldRootOwnProps {}
|
|
25
25
|
|
|
26
|
-
// Each Slot registers its id here, so the input can list slot content in aria-describedby.
|
|
27
|
-
|
|
26
|
+
// Each Slot registers its id here, so the input can list slot content in aria-describedby. A scrub
|
|
27
|
+
// slot also registers its arrow-key step, and reads whether the field takes input at all.
|
|
28
|
+
type ScrubKeyHandler = (direction: 1 | -1, shiftKey: boolean, altKey: boolean) => void;
|
|
29
|
+
type TextFieldContextValue = {
|
|
30
|
+
registerSlot: (id: string) => () => void;
|
|
31
|
+
registerScrub: (handler: ScrubKeyHandler) => () => void;
|
|
32
|
+
inert: boolean;
|
|
33
|
+
};
|
|
28
34
|
const TextFieldContext = React.createContext<TextFieldContextValue | null>(null);
|
|
29
35
|
|
|
30
36
|
// Clicking anything a person could mean to press keeps its own press: the guard is a focusability
|
|
@@ -64,7 +70,16 @@ const TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>
|
|
|
64
70
|
setSlotIds((prev) => (prev.includes(id) ? prev : [...prev, id]));
|
|
65
71
|
return () => setSlotIds((prev) => prev.filter((slotId) => slotId !== id));
|
|
66
72
|
}, []);
|
|
67
|
-
const
|
|
73
|
+
const scrubKeyRef = React.useRef<ScrubKeyHandler | null>(null);
|
|
74
|
+
const registerScrub = React.useCallback((handler: ScrubKeyHandler) => {
|
|
75
|
+
scrubKeyRef.current = handler;
|
|
76
|
+
return () => {
|
|
77
|
+
if (scrubKeyRef.current === handler) scrubKeyRef.current = null;
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
// A disabled or read-only field takes no input, so its slot does not scrub or step either.
|
|
81
|
+
const inert = Boolean(inputProps.disabled || inputProps.readOnly);
|
|
82
|
+
const contextValue = React.useMemo(() => ({ registerSlot, registerScrub, inert }), [registerSlot, registerScrub, inert]);
|
|
68
83
|
|
|
69
84
|
const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby, 'aria-invalid': ariaInvalid } = inputProps;
|
|
70
85
|
|
|
@@ -91,7 +106,16 @@ const TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>
|
|
|
91
106
|
);
|
|
92
107
|
|
|
93
108
|
// Filter out our custom props to avoid DOM warnings
|
|
94
|
-
const { error, errorMessage, required, 'aria-describedby': _ariaDescribedby, 'aria-labelledby': _ariaLabelledby, ...nativeInputProps } = inputProps;
|
|
109
|
+
const { error, errorMessage, required, 'aria-describedby': _ariaDescribedby, 'aria-labelledby': _ariaLabelledby, onKeyDown, ...nativeInputProps } = inputProps;
|
|
110
|
+
|
|
111
|
+
// With a scrub slot, Up and Down step the value at once, by the slot's step, with the same Shift
|
|
112
|
+
// and Option multipliers as a drag. The caller's handler runs first and can prevent it.
|
|
113
|
+
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
114
|
+
const step = scrubKeyRef.current;
|
|
115
|
+
if (!step || inert || (event.key !== 'ArrowUp' && event.key !== 'ArrowDown')) return;
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
step(event.key === 'ArrowUp' ? 1 : -1, event.shiftKey, event.altKey);
|
|
118
|
+
};
|
|
95
119
|
|
|
96
120
|
// Clicking the padding or a passive slot focuses the input. preventDefault stops the browser
|
|
97
121
|
// from moving focus to the root first, so the input is focused once, synchronously.
|
|
@@ -132,7 +156,14 @@ const TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>
|
|
|
132
156
|
})}
|
|
133
157
|
onMouseDown={handleMouseDown}
|
|
134
158
|
>
|
|
135
|
-
<input
|
|
159
|
+
<input
|
|
160
|
+
{...nativeInputProps}
|
|
161
|
+
required={required || undefined}
|
|
162
|
+
{...ariaProps}
|
|
163
|
+
onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}
|
|
164
|
+
ref={composeRefs(inputRef, forwardedRef)}
|
|
165
|
+
className="kui-reset kui-TextFieldInput"
|
|
166
|
+
/>
|
|
136
167
|
<TextFieldContext.Provider value={contextValue}>{children}</TextFieldContext.Provider>
|
|
137
168
|
</div>
|
|
138
169
|
);
|
|
@@ -185,19 +216,9 @@ type TextFieldSlotElement = React.ElementRef<'div'>;
|
|
|
185
216
|
type TextFieldSlotOwnProps = GetPropDefTypes<typeof textFieldSlotPropDefs> & TextFieldSlotScrubProps;
|
|
186
217
|
interface TextFieldSlotProps extends ComponentPropsWithout<'div', RemovedProps>, TextFieldSlotOwnProps {}
|
|
187
218
|
|
|
188
|
-
// Detect if we should use pointer capture instead of pointer lock
|
|
189
|
-
// Safari and Firefox show intrusive browser warnings with pointer lock
|
|
190
|
-
const usePointerCapture = (() => {
|
|
191
|
-
if (typeof navigator === 'undefined') return false;
|
|
192
|
-
const ua = navigator.userAgent;
|
|
193
|
-
const isSafari = /^((?!chrome|android).)*safari/i.test(ua);
|
|
194
|
-
const isFirefox = /firefox/i.test(ua);
|
|
195
|
-
return isSafari || isFirefox;
|
|
196
|
-
})();
|
|
197
|
-
|
|
198
219
|
const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>((props, forwardedRef) => {
|
|
199
220
|
// Extract scrub props first (not part of PropDef system)
|
|
200
|
-
const { scrub, scrubValue, scrubStep = 1, scrubSensitivity = 1, scrubMin, scrubMax, scrubShiftMultiplier = 10, scrubAltMultiplier = 0.1, onScrub, ...restProps } = props;
|
|
221
|
+
const { scrub: scrubProp, scrubValue, scrubStep = 1, scrubSensitivity = 1, scrubMin, scrubMax, scrubShiftMultiplier = 10, scrubAltMultiplier = 0.1, onScrub, ...restProps } = props;
|
|
201
222
|
|
|
202
223
|
// Then extract styling props
|
|
203
224
|
const { className, color, side, onPointerDown, onPointerMove, onPointerUp, onLostPointerCapture, ...slotProps } = extractProps(
|
|
@@ -210,7 +231,10 @@ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>
|
|
|
210
231
|
// by the button's name.
|
|
211
232
|
const generatedId = React.useId();
|
|
212
233
|
const slotId = slotProps.id ?? generatedId;
|
|
213
|
-
const
|
|
234
|
+
const fieldContext = React.useContext(TextFieldContext);
|
|
235
|
+
const registerSlot = fieldContext?.registerSlot;
|
|
236
|
+
const registerScrub = fieldContext?.registerScrub;
|
|
237
|
+
const scrub = Boolean(scrubProp) && !fieldContext?.inert;
|
|
214
238
|
const slotRef = React.useRef<HTMLDivElement>(null);
|
|
215
239
|
// Unknown until the slot has rendered; it registers once it is known to hold only text.
|
|
216
240
|
const [holdsControl, setHoldsControl] = React.useState<boolean | null>(null);
|
|
@@ -227,8 +251,6 @@ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>
|
|
|
227
251
|
const cursorRef = React.useRef<HTMLImageElement>(null);
|
|
228
252
|
// Virtual cursor Y, tracked beside virtualX
|
|
229
253
|
const virtualY = React.useRef(0);
|
|
230
|
-
// Whether this slot asked for the pointer lock, so a lock change elsewhere is not ours
|
|
231
|
-
const lockedByMe = React.useRef(false);
|
|
232
254
|
|
|
233
255
|
// Track accumulated sub-step movement for precision
|
|
234
256
|
const accumulatedMovement = React.useRef(0);
|
|
@@ -284,45 +306,18 @@ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>
|
|
|
284
306
|
const slot = slotRef.current;
|
|
285
307
|
if (!slot) return;
|
|
286
308
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
lockedByMe.current = true;
|
|
296
|
-
slot.requestPointerLock();
|
|
297
|
-
}
|
|
309
|
+
// Pointer capture in every browser. Pointer lock gave endless travel in Chrome, but Chrome
|
|
310
|
+
// shows its "Press Esc to show your cursor" banner on every drag, which is noise for a
|
|
311
|
+
// gesture repeated all day. Captured, the drag keeps going past the window, up to the edge
|
|
312
|
+
// of the screen.
|
|
313
|
+
pointerIdRef.current = event.pointerId;
|
|
314
|
+
lastXRef.current = event.clientX;
|
|
315
|
+
slot.setPointerCapture(event.pointerId);
|
|
316
|
+
setIsScrubbing(true);
|
|
298
317
|
},
|
|
299
318
|
[scrub, scrubValue],
|
|
300
319
|
);
|
|
301
320
|
|
|
302
|
-
// Handle pointer lock state changes (Chrome only). Only a scrub slot listens, and only a lock
|
|
303
|
-
// this slot asked for starts or ends its scrub.
|
|
304
|
-
React.useEffect(() => {
|
|
305
|
-
if (usePointerCapture || !scrub) return;
|
|
306
|
-
|
|
307
|
-
const handlePointerLockChange = () => {
|
|
308
|
-
if (!lockedByMe.current) return;
|
|
309
|
-
const isLocked = document.pointerLockElement === slotRef.current;
|
|
310
|
-
setIsScrubbing(isLocked);
|
|
311
|
-
if (!isLocked) {
|
|
312
|
-
lockedByMe.current = false;
|
|
313
|
-
// Fire callback with isChanging = false when scrubbing ends
|
|
314
|
-
scrubConfigRef.current.onScrub?.(0, false);
|
|
315
|
-
accumulatedMovement.current = 0;
|
|
316
|
-
currentValue.current = 0;
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
document.addEventListener('pointerlockchange', handlePointerLockChange);
|
|
321
|
-
return () => {
|
|
322
|
-
document.removeEventListener('pointerlockchange', handlePointerLockChange);
|
|
323
|
-
};
|
|
324
|
-
}, [scrub]);
|
|
325
|
-
|
|
326
321
|
// Shared scrub calculation logic
|
|
327
322
|
const processScrubMovement = React.useCallback((movementX: number, movementY: number, shiftKey: boolean, altKey: boolean) => {
|
|
328
323
|
const config = scrubConfigRef.current;
|
|
@@ -401,10 +396,9 @@ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>
|
|
|
401
396
|
setIsScrubbing(false);
|
|
402
397
|
}, []);
|
|
403
398
|
|
|
404
|
-
// Handle pointer capture mode events (Safari/Firefox)
|
|
405
399
|
const handlePointerMove = React.useCallback(
|
|
406
400
|
(event: React.PointerEvent) => {
|
|
407
|
-
if (!isScrubbing
|
|
401
|
+
if (!isScrubbing) return;
|
|
408
402
|
|
|
409
403
|
const movementX = event.clientX - lastXRef.current;
|
|
410
404
|
lastXRef.current = event.clientX;
|
|
@@ -416,7 +410,7 @@ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>
|
|
|
416
410
|
|
|
417
411
|
const handlePointerUp = React.useCallback(
|
|
418
412
|
(event: React.PointerEvent) => {
|
|
419
|
-
if (
|
|
413
|
+
if (pointerIdRef.current !== event.pointerId) return;
|
|
420
414
|
|
|
421
415
|
const slot = slotRef.current;
|
|
422
416
|
if (slot && pointerIdRef.current !== null) {
|
|
@@ -428,41 +422,14 @@ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>
|
|
|
428
422
|
);
|
|
429
423
|
|
|
430
424
|
const handleLostPointerCapture = React.useCallback(() => {
|
|
431
|
-
if (
|
|
425
|
+
if (isScrubbing) {
|
|
432
426
|
endScrubbing();
|
|
433
427
|
}
|
|
434
428
|
}, [isScrubbing, endScrubbing]);
|
|
435
429
|
|
|
436
|
-
// Attach document-level listeners for pointer lock mode (Chrome)
|
|
437
|
-
React.useEffect(() => {
|
|
438
|
-
if (!isScrubbing || usePointerCapture) return;
|
|
439
|
-
|
|
440
|
-
const handleMouseMove = (event: MouseEvent) => {
|
|
441
|
-
processScrubMovement(event.movementX, event.movementY, event.shiftKey, event.altKey);
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
const handleMouseUp = () => {
|
|
445
|
-
// Exit pointer lock to end scrubbing
|
|
446
|
-
document.exitPointerLock();
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
// Use mousemove for pointer lock (pointermove doesn't work well with pointer lock)
|
|
450
|
-
document.addEventListener('mousemove', handleMouseMove);
|
|
451
|
-
document.addEventListener('mouseup', handleMouseUp);
|
|
452
|
-
|
|
453
|
-
// Disable text selection during scrubbing
|
|
454
|
-
document.body.style.userSelect = 'none';
|
|
455
|
-
|
|
456
|
-
return () => {
|
|
457
|
-
document.removeEventListener('mousemove', handleMouseMove);
|
|
458
|
-
document.removeEventListener('mouseup', handleMouseUp);
|
|
459
|
-
document.body.style.userSelect = '';
|
|
460
|
-
};
|
|
461
|
-
}, [isScrubbing, processScrubMovement]);
|
|
462
|
-
|
|
463
430
|
// Hide native cursor and disable text selection during pointer capture scrubbing
|
|
464
431
|
React.useEffect(() => {
|
|
465
|
-
if (!isScrubbing
|
|
432
|
+
if (!isScrubbing) return;
|
|
466
433
|
|
|
467
434
|
// Create a style element to hide cursor globally during scrub
|
|
468
435
|
const style = document.createElement('style');
|
|
@@ -474,6 +441,19 @@ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>
|
|
|
474
441
|
};
|
|
475
442
|
}, [isScrubbing]);
|
|
476
443
|
|
|
444
|
+
// Up and Down on the input step once. The step is a whole change, so it reports isChanging
|
|
445
|
+
// false at once: one undo step per press, as a drag is one per release.
|
|
446
|
+
React.useEffect(() => {
|
|
447
|
+
if (!scrub || !registerScrub) return;
|
|
448
|
+
return registerScrub((direction, shiftKey, altKey) => {
|
|
449
|
+
const config = scrubConfigRef.current;
|
|
450
|
+
const multiplier = shiftKey ? config.scrubShiftMultiplier : altKey ? config.scrubAltMultiplier : 1;
|
|
451
|
+
const start = config.scrubValue ?? 0;
|
|
452
|
+
const next = Math.max(config.scrubMin ?? -Infinity, Math.min(config.scrubMax ?? Infinity, start + direction * config.scrubStep * multiplier));
|
|
453
|
+
if (next !== start) config.onScrub?.(next - start, false);
|
|
454
|
+
});
|
|
455
|
+
}, [scrub, registerScrub]);
|
|
456
|
+
|
|
477
457
|
// Render virtual cursor via portal to body so it's not clipped
|
|
478
458
|
// Using a data URI of ew-resize cursor for a native look
|
|
479
459
|
const virtualCursor = isScrubbing
|
package/styles.css
CHANGED
|
@@ -11399,6 +11399,12 @@
|
|
|
11399
11399
|
-ms-user-select: none;
|
|
11400
11400
|
user-select: none;
|
|
11401
11401
|
position: relative;
|
|
11402
|
+
border-radius: calc(var(--text-field-border-radius, var(--radius-2)) - 2px);
|
|
11403
|
+
}
|
|
11404
|
+
@media (hover: hover) {
|
|
11405
|
+
.kui-TextFieldSlot:where([data-scrub]):where(:hover:not([data-scrubbing])) {
|
|
11406
|
+
background-color: var(--neutral-a3);
|
|
11407
|
+
}
|
|
11402
11408
|
}
|
|
11403
11409
|
.kui-TextFieldSlot:where([data-scrub]) * {
|
|
11404
11410
|
cursor: ew-resize !important;
|
|
@@ -14759,12 +14765,12 @@
|
|
|
14759
14765
|
-webkit-padding-end: var(--space-4);
|
|
14760
14766
|
padding-inline-end: var(--space-4);
|
|
14761
14767
|
}
|
|
14762
|
-
.kui-SelectItem:where(.kui-SelectItemRich) {
|
|
14768
|
+
.kui-SelectItem:where(.kui-SelectItemRich[data-multiline]) {
|
|
14763
14769
|
-webkit-box-align: start;
|
|
14764
14770
|
-ms-flex-align: start;
|
|
14765
14771
|
align-items: flex-start;
|
|
14766
14772
|
}
|
|
14767
|
-
.kui-SelectItem:where(.kui-SelectItemRich) :where(.kui-SelectItemIndicator) {
|
|
14773
|
+
.kui-SelectItem:where(.kui-SelectItemRich[data-multiline]) :where(.kui-SelectItemIndicator) {
|
|
14768
14774
|
bottom: auto;
|
|
14769
14775
|
height: var(--base-menu-item-height);
|
|
14770
14776
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{a as me}from"./chunk-YCLPURTD.js";import{a as K}from"./chunk-OAJ5DARR.js";import{b as fe,c as U}from"./chunk-OKQAVYW4.js";import{c as ie}from"./chunk-5ON3XLRD.js";import{c as j}from"./chunk-HBWBPBSA.js";import{b as ne}from"./chunk-XU74PNM2.js";import{a as Ee}from"./chunk-VQPANPMI.js";var ze={};Ee(ze,{Group:()=>he,Root:()=>ge,Slot:()=>Se});import*as e from"react";import*as Pe from"react-dom";import Z from"classnames";import{composeEventHandlers as $,composeRefs as ye,useLayoutEffect as Ge}from"radix-ui/internal";var be=["1","2","3","4"],Le=["raised","surface","soft","ghost","outline"],ae={size:{type:"enum",className:"kui-r-size",values:be,default:"2",responsive:!0},variant:{type:"enum",className:"kui-variant",values:Le,default:"raised"},error:{type:"boolean",default:!1},errorMessage:{type:"string",default:void 0},required:{type:"boolean",default:!1},"aria-describedby":{type:"string",default:void 0},"aria-labelledby":{type:"string",default:void 0},...j,...ne},Ie=["raised","surface","soft","outline","ghost"],le={size:{type:"enum",className:"kui-r-size",values:be,default:"2",responsive:!0},variant:{type:"enum",className:"kui-variant",values:Ie,default:"raised"},disabled:{type:"boolean",default:!1},...j,...ne},Ne=["left","right"],xe={side:{type:"enum",values:Ne},...j,gap:me.gap,px:K.px,pl:K.pl,pr:K.pr};var Re=e.createContext(null),ue="button, a, input, select, textarea, label, [tabindex], [contenteditable]",ve=e.createContext(null),ge=e.forwardRef((a,g)=>{let r=e.useContext(ve),f=r?{...a,size:r.size,variant:r.variant,radius:r.radius,color:a.color??r.color,disabled:!!(r.disabled||a.disabled)}:a,{className:P,style:m,...y}=ie(f,ae.size),b=e.useRef(null),{children:F,className:M,color:w,radius:H,style:k,...l}=U(y,ae),c=!!l.errorMessage,D=e.useId(),[E,L]=e.useState([]),I=e.useCallback(o=>(L(s=>s.includes(o)?s:[...s,o]),()=>L(s=>s.filter(i=>i!==o))),[]),N=e.useMemo(()=>({registerSlot:I}),[I]),{"aria-describedby":G,"aria-labelledby":C,"aria-invalid":h}=l,x=!!l.error||h===!0||h==="true",z=e.useMemo(()=>{let o=[];return l.errorMessage&&o.push(D),G&&o.push(G),o.push(...E),o.length>0?o.join(" "):void 0},[l.errorMessage,G,D,E]),J=e.useMemo(()=>({"aria-invalid":x?!0:h,"aria-describedby":z,"aria-labelledby":C}),[x,h,z,C]),{error:u,errorMessage:B,required:X,"aria-describedby":ce,"aria-labelledby":Q,...V}=l,O=e.useCallback(o=>{let s=o.target;if(s.closest(ue))return;let i=b.current;if(!i)return;let S=s.closest(`
|
|
3
|
-
.kui-TextFieldSlot[data-side='right'],
|
|
4
|
-
.kui-TextFieldSlot:not([data-side='right']) ~ .kui-TextFieldSlot:not([data-side='left'])
|
|
5
|
-
`)?i.value.length:0;o.preventDefault(),i.focus();try{i.setSelectionRange(S,S)}catch{}},[]),R=e.createElement("div",{"data-accent-color":w,"data-radius":H,style:c?k:fe(k,m),className:Z("kui-TextFieldRoot",M,!c&&P,{"kui-error":x}),onMouseDown:O},e.createElement("input",{...V,required:X||void 0,...J,ref:ye(b,g),className:"kui-reset kui-TextFieldInput"}),e.createElement(Re.Provider,{value:N},F));return e.createElement("div",{className:Z("kui-TextFieldWrapper",c&&P),style:c?m:void 0,"data-message":c||void 0},R,c?e.createElement("div",{id:D,className:"kui-TextFieldErrorMessage",role:"alert"},l.errorMessage):null)});ge.displayName="TextField.Root";var he=e.forwardRef((a,g)=>{let r=ie(a,le.size),{size:f,variant:P,radius:m,color:y,disabled:b}=r,{className:F,children:M,radius:w,color:H,disabled:k,...l}=U(r,le),c=e.useMemo(()=>({size:f,variant:P,radius:m,color:y,disabled:b}),[f,P,m,y,b]);return e.createElement("div",{role:"group","data-accent-color":y,"data-radius":m,"data-disabled":b||void 0,...l,ref:g,className:Z("kui-TextFieldGroup",F)},e.createElement(ve.Provider,{value:c},M))});he.displayName="TextField.Group";var T=(()=>{if(typeof navigator>"u")return!1;let a=navigator.userAgent,g=/^((?!chrome|android).)*safari/i.test(a),r=/firefox/i.test(a);return g||r})(),Se=e.forwardRef((a,g)=>{let{scrub:r,scrubValue:f,scrubStep:P=1,scrubSensitivity:m=1,scrubMin:y,scrubMax:b,scrubShiftMultiplier:F=10,scrubAltMultiplier:M=.1,onScrub:w,...H}=a,{className:k,color:l,side:c,onPointerDown:D,onPointerMove:E,onPointerUp:L,onLostPointerCapture:I,...N}=U(H,xe),G=e.useId(),C=N.id??G,h=e.useContext(Re)?.registerSlot,x=e.useRef(null),[z,J]=e.useState(null);Ge(()=>{let t=!!x.current?.querySelector(ue);J(n=>n===t?n:t)}),e.useEffect(()=>z===!1?h?.(C):void 0,[h,C,z]);let[u,B]=e.useState(!1),[X,ce]=e.useState({x:0,y:0}),Q=e.useRef(null),V=e.useRef(0),O=e.useRef(!1),R=e.useRef(0),o=e.useRef(0),s=e.useRef(0),i=e.useRef(null),A=e.useRef(0),S=e.useRef({scrubValue:f,scrubStep:P,scrubSensitivity:m,scrubMin:y,scrubMax:b,scrubShiftMultiplier:F,scrubAltMultiplier:M,onScrub:w});S.current={scrubValue:f,scrubStep:P,scrubSensitivity:m,scrubMin:y,scrubMax:b,scrubShiftMultiplier:F,scrubAltMultiplier:M,onScrub:w};let Te=e.useCallback(t=>{if(!r||t.target.closest(ue))return;t.preventDefault(),R.current=0,o.current=f??0,s.current=t.clientX,V.current=t.clientY,ce({x:t.clientX,y:t.clientY});let d=x.current;d&&(T?(i.current=t.pointerId,A.current=t.clientX,d.setPointerCapture(t.pointerId),B(!0)):(O.current=!0,d.requestPointerLock()))},[r,f]);e.useEffect(()=>{if(T||!r)return;let t=()=>{if(!O.current)return;let n=document.pointerLockElement===x.current;B(n),n||(O.current=!1,S.current.onScrub?.(0,!1),R.current=0,o.current=0)};return document.addEventListener("pointerlockchange",t),()=>{document.removeEventListener("pointerlockchange",t)}},[r]);let W=e.useCallback((t,n,d,we)=>{let p=S.current,q=window.innerWidth,Y=window.innerHeight;s.current+=t,s.current>q?s.current=s.current%q:s.current<0&&(s.current=q+s.current%q);let v=V.current+n;v>Y?v=v%Y:v<0&&(v=Y+v%Y),V.current=v;let ee=Q.current;ee&&(ee.style.left=`${s.current}px`,ee.style.top=`${v}px`),R.current+=t;let te=R.current/p.scrubSensitivity;if(Math.abs(te)>=1){let re=1;d?re=p.scrubShiftMultiplier:we&&(re=p.scrubAltMultiplier);let de=Math.trunc(te),oe=de*p.scrubStep*re,se=oe;if(p.scrubMin!==void 0||p.scrubMax!==void 0){let ke=o.current+oe,pe=Math.max(p.scrubMin??-1/0,Math.min(p.scrubMax??1/0,ke));se=pe-o.current,o.current=pe}else o.current+=oe;se!==0&&p.onScrub?.(se,!0),R.current=(te-de)*p.scrubSensitivity}},[]),_=e.useCallback(()=>{S.current.onScrub?.(0,!1),R.current=0,o.current=0,i.current=null,B(!1)},[]),Fe=e.useCallback(t=>{if(!u||!T)return;let n=t.clientX-A.current;A.current=t.clientX,W(n,t.movementY,t.shiftKey,t.altKey)},[u,W]),Me=e.useCallback(t=>{if(!T||i.current!==t.pointerId)return;let n=x.current;n&&i.current!==null&&n.releasePointerCapture(i.current),_()},[_]),De=e.useCallback(()=>{T&&u&&_()},[u,_]);e.useEffect(()=>{if(!u||T)return;let t=d=>{W(d.movementX,d.movementY,d.shiftKey,d.altKey)},n=()=>{document.exitPointerLock()};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",n),document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",n),document.body.style.userSelect=""}},[u,W]),e.useEffect(()=>{if(!u||!T)return;let t=document.createElement("style");return t.textContent="* { cursor: none !important; user-select: none !important; }",document.head.appendChild(t),()=>{document.head.removeChild(t)}},[u]);let Ce=u?Pe.createPortal(e.createElement("img",{ref:Q,className:"kui-TextFieldSlotScrubCursor",src:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='black' stroke='white' stroke-width='1' d='M0 12 L5 7 L5 10 L19 10 L19 7 L24 12 L19 17 L19 14 L5 14 L5 17 Z'/%3E%3C/svg%3E",alt:"",style:{position:"fixed",left:X.x,top:X.y,transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:99999,width:24,height:24},"aria-hidden":"true"}),document.body):null;return e.createElement("div",{"data-accent-color":l,"data-side":c,"data-scrub":r||void 0,"data-scrubbing":u||void 0,...N,id:C,ref:ye(x,g),className:Z("kui-TextFieldSlot",k),onPointerDown:r?$(D,Te):D,onPointerMove:r?$(E,Fe):E,onPointerUp:r?$(L,Me):L,onLostPointerCapture:r?$(I,De):I},N.children,Ce)});Se.displayName="TextField.Slot";export{ge as a,he as b,Se as c,ze as d};
|
|
6
|
-
//# sourceMappingURL=chunk-GPZHRZBE.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/components/text-field.tsx", "../../src/components/text-field.props.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport classNames from 'classnames';\nimport { composeEventHandlers, composeRefs, useLayoutEffect } from 'radix-ui/internal';\n\nimport { textFieldRootPropDefs, textFieldGroupPropDefs, textFieldSlotPropDefs, type TextFieldSlotScrubProps } from './text-field.props.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { mergeStyles } from '../helpers/merge-styles.js';\nimport { useThemeSizeProps } from '../hooks/theme-size.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { NotInputTextualAttributes } from '../helpers/input-attributes.js';\nimport type { GetPropDefTypes } from '../props/prop-def.js';\n\ntype TextFieldRootElement = React.ElementRef<'input'>;\ntype TextFieldRootOwnProps = GetPropDefTypes<typeof textFieldRootPropDefs> & {\n defaultValue?: string | number;\n value?: string | number;\n type?: 'date' | 'datetime-local' | 'email' | 'hidden' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';\n};\ntype TextFieldInputProps = ComponentPropsWithout<'input', NotInputTextualAttributes | 'color' | 'defaultValue' | 'size' | 'type' | 'value'>;\ninterface TextFieldRootProps extends TextFieldInputProps, TextFieldRootOwnProps {}\n\n// Each Slot registers its id here, so the input can list slot content in aria-describedby.\ntype TextFieldContextValue = { registerSlot: (id: string) => () => void };\nconst TextFieldContext = React.createContext<TextFieldContextValue | null>(null);\n\n// Clicking anything a person could mean to press keeps its own press: the guard is a focusability\n// list, not a tag list. `[tabindex]` catches role-based widgets; `label` already redirects a click.\nconst FOCUSABLE_IN_SLOT = 'button, a, input, select, textarea, label, [tabindex], [contenteditable]';\n\n// A Group decides the look of its fields: their size, variant and radius come from it. A field\n// can still take its own color, and is disabled when either it or the group is.\ntype TextFieldGroupContextValue = Pick<TextFieldGroupOwnProps, 'size' | 'variant' | 'radius' | 'color' | 'disabled'>;\nconst TextFieldGroupContext = React.createContext<TextFieldGroupContextValue | null>(null);\n\nconst TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>((fieldProps, forwardedRef) => {\n const group = React.useContext(TextFieldGroupContext);\n const ownProps = group\n ? {\n ...fieldProps,\n size: group.size,\n variant: group.variant,\n radius: group.radius,\n color: fieldProps.color ?? group.color,\n disabled: Boolean(group.disabled || fieldProps.disabled),\n }\n : fieldProps;\n // The caller's className and style are kept apart from the size and variant classes: with an\n // error message they go on the wrapper, which is then the one box the parent lays out.\n const { className: ownClassName, style: ownStyle, ...themedProps } = useThemeSizeProps(ownProps, textFieldRootPropDefs.size);\n const inputRef = React.useRef<HTMLInputElement>(null);\n const { children, className, color, radius, style, ...inputProps } = extractProps(themedProps, textFieldRootPropDefs);\n const wrapped = Boolean(inputProps.errorMessage);\n\n // Generate unique IDs for accessibility\n const errorId = React.useId();\n\n // Slot content qualifies the value, so it describes the input (as in v2), in mount order.\n const [slotIds, setSlotIds] = React.useState<string[]>([]);\n const registerSlot = React.useCallback((id: string) => {\n setSlotIds((prev) => (prev.includes(id) ? prev : [...prev, id]));\n return () => setSlotIds((prev) => prev.filter((slotId) => slotId !== id));\n }, []);\n const contextValue = React.useMemo(() => ({ registerSlot }), [registerSlot]);\n\n const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby, 'aria-invalid': ariaInvalid } = inputProps;\n\n // Invalid when `error` is set or the caller passes aria-invalid; the CSS keys on aria-invalid only.\n const isInvalid = Boolean(inputProps.error) || ariaInvalid === true || ariaInvalid === 'true';\n\n // Build aria-describedby string. The caller's ids stay; ours are appended.\n const describedBy = React.useMemo(() => {\n const parts = [];\n if (inputProps.errorMessage) parts.push(errorId);\n if (ariaDescribedby) parts.push(ariaDescribedby);\n parts.push(...slotIds);\n return parts.length > 0 ? parts.join(' ') : undefined;\n }, [inputProps.errorMessage, ariaDescribedby, errorId, slotIds]);\n\n // Build aria attributes\n const ariaProps = React.useMemo(\n () => ({\n 'aria-invalid': isInvalid ? true : ariaInvalid,\n 'aria-describedby': describedBy,\n 'aria-labelledby': ariaLabelledby,\n }),\n [isInvalid, ariaInvalid, describedBy, ariaLabelledby],\n );\n\n // Filter out our custom props to avoid DOM warnings\n const { error, errorMessage, required, 'aria-describedby': _ariaDescribedby, 'aria-labelledby': _ariaLabelledby, ...nativeInputProps } = inputProps;\n\n // Clicking the padding or a passive slot focuses the input. preventDefault stops the browser\n // from moving focus to the root first, so the input is focused once, synchronously.\n const handleMouseDown = React.useCallback((event: React.MouseEvent) => {\n const target = event.target as HTMLElement;\n if (target.closest(FOCUSABLE_IN_SLOT)) return;\n\n const input = inputRef.current;\n if (!input) return;\n\n // Same selector as in the CSS to find the right slot\n const isRightSlot = target.closest(`\n .kui-TextFieldSlot[data-side='right'],\n .kui-TextFieldSlot:not([data-side='right']) ~ .kui-TextFieldSlot:not([data-side='left'])\n `);\n\n const cursorPosition = isRightSlot ? input.value.length : 0;\n\n event.preventDefault();\n input.focus();\n // Only some input types support this, browsers will throw an error if not supported\n // See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange#:~:text=Note%20that%20according,not%20support%20selection%22.\n try {\n input.setSelectionRange(cursorPosition, cursorPosition);\n } catch {}\n }, []);\n\n // A pointer-only hit-target redirect to the input; keyboard users reach the input directly.\n const field = (\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n <div\n data-accent-color={color}\n data-radius={radius}\n style={wrapped ? style : mergeStyles(style, ownStyle)}\n className={classNames('kui-TextFieldRoot', className, !wrapped && ownClassName, {\n // Not used by the library's CSS (invalid styling keys on aria-invalid); kept as a hook for app styles.\n 'kui-error': isInvalid,\n })}\n onMouseDown={handleMouseDown}\n >\n <input {...nativeInputProps} required={required || undefined} {...ariaProps} ref={composeRefs(inputRef, forwardedRef)} className=\"kui-reset kui-TextFieldInput\" />\n <TextFieldContext.Provider value={contextValue}>{children}</TextFieldContext.Provider>\n </div>\n );\n // The wrapper is always there, so a message coming or going never moves the field in the tree:\n // moving it would remount the input, dropping focus, the caret and an uncontrolled value. With\n // no message it is `display: contents` and the field is the box the parent lays out; with one\n // it holds the field and the message below it, and the caller's className and style size the pair.\n return (\n <div className={classNames('kui-TextFieldWrapper', wrapped && ownClassName)} style={wrapped ? ownStyle : undefined} data-message={wrapped || undefined}>\n {field}\n {wrapped ? (\n <div id={errorId} className=\"kui-TextFieldErrorMessage\" role=\"alert\">\n {inputProps.errorMessage}\n </div>\n ) : null}\n </div>\n );\n});\nTextFieldRoot.displayName = 'TextField.Root';\n\ntype TextFieldGroupOwnProps = GetPropDefTypes<typeof textFieldGroupPropDefs>;\ninterface TextFieldGroupProps extends ComponentPropsWithout<'div', RemovedProps>, TextFieldGroupOwnProps {}\n\n/**\n * Joins two or more fields into one, such as X, Y and Z: one edge, square inner corners and a\n * hairline between the fields. The group draws the edge, so each field keeps only its fill.\n */\nconst TextFieldGroup = React.forwardRef<HTMLDivElement, TextFieldGroupProps>((ownProps, forwardedRef) => {\n const props = useThemeSizeProps(ownProps, textFieldGroupPropDefs.size);\n const { size, variant, radius, color, disabled } = props;\n const { className, children, radius: _radius, color: _color, disabled: _disabled, ...domProps } = extractProps(props, textFieldGroupPropDefs);\n const contextValue = React.useMemo(() => ({ size, variant, radius, color, disabled }), [size, variant, radius, color, disabled]);\n return (\n <div\n role=\"group\"\n data-accent-color={color}\n data-radius={radius}\n data-disabled={disabled || undefined}\n {...domProps}\n ref={forwardedRef}\n className={classNames('kui-TextFieldGroup', className)}\n >\n <TextFieldGroupContext.Provider value={contextValue}>{children}</TextFieldGroupContext.Provider>\n </div>\n );\n});\nTextFieldGroup.displayName = 'TextField.Group';\n\ntype TextFieldSlotElement = React.ElementRef<'div'>;\ntype TextFieldSlotOwnProps = GetPropDefTypes<typeof textFieldSlotPropDefs> & TextFieldSlotScrubProps;\ninterface TextFieldSlotProps extends ComponentPropsWithout<'div', RemovedProps>, TextFieldSlotOwnProps {}\n\n// Detect if we should use pointer capture instead of pointer lock\n// Safari and Firefox show intrusive browser warnings with pointer lock\nconst usePointerCapture = (() => {\n if (typeof navigator === 'undefined') return false;\n const ua = navigator.userAgent;\n const isSafari = /^((?!chrome|android).)*safari/i.test(ua);\n const isFirefox = /firefox/i.test(ua);\n return isSafari || isFirefox;\n})();\n\nconst TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>((props, forwardedRef) => {\n // Extract scrub props first (not part of PropDef system)\n const { scrub, scrubValue, scrubStep = 1, scrubSensitivity = 1, scrubMin, scrubMax, scrubShiftMultiplier = 10, scrubAltMultiplier = 0.1, onScrub, ...restProps } = props;\n\n // Then extract styling props\n const { className, color, side, onPointerDown, onPointerMove, onPointerUp, onLostPointerCapture, ...slotProps } = extractProps(\n restProps,\n textFieldSlotPropDefs,\n );\n\n // A slot of text describes the input (see TextFieldRoot); a caller's own id is kept. A slot\n // holding a control, such as a show-password button, does not: the input would be described\n // by the button's name.\n const generatedId = React.useId();\n const slotId = slotProps.id ?? generatedId;\n const registerSlot = React.useContext(TextFieldContext)?.registerSlot;\n const slotRef = React.useRef<HTMLDivElement>(null);\n // Unknown until the slot has rendered; it registers once it is known to hold only text.\n const [holdsControl, setHoldsControl] = React.useState<boolean | null>(null);\n useLayoutEffect(() => {\n const next = Boolean(slotRef.current?.querySelector(FOCUSABLE_IN_SLOT));\n setHoldsControl((prev) => (prev === next ? prev : next));\n });\n React.useEffect(() => (holdsControl === false ? registerSlot?.(slotId) : undefined), [registerSlot, slotId, holdsControl]);\n\n const [isScrubbing, setIsScrubbing] = React.useState(false);\n // Where the virtual cursor starts. Movement is written straight to the cursor element, so a\n // scrub does not re-render the slot on every mouse move.\n const [cursorStart, setCursorStart] = React.useState({ x: 0, y: 0 });\n const cursorRef = React.useRef<HTMLImageElement>(null);\n // Virtual cursor Y, tracked beside virtualX\n const virtualY = React.useRef(0);\n // Whether this slot asked for the pointer lock, so a lock change elsewhere is not ours\n const lockedByMe = React.useRef(false);\n\n // Track accumulated sub-step movement for precision\n const accumulatedMovement = React.useRef(0);\n // Track current value for clamping (initialized to scrubValue when scrubbing starts)\n const currentValue = React.useRef(0);\n // Track virtual X position for wrap-around (separate from rendered position)\n const virtualX = React.useRef(0);\n // Track pointer ID for capture mode\n const pointerIdRef = React.useRef<number | null>(null);\n // Track last X position for capture mode (movementX calculation)\n const lastXRef = React.useRef(0);\n\n // Store scrub config in refs so document handlers can access latest values\n const scrubConfigRef = React.useRef({\n scrubValue,\n scrubStep,\n scrubSensitivity,\n scrubMin,\n scrubMax,\n scrubShiftMultiplier,\n scrubAltMultiplier,\n onScrub,\n });\n scrubConfigRef.current = {\n scrubValue,\n scrubStep,\n scrubSensitivity,\n scrubMin,\n scrubMax,\n scrubShiftMultiplier,\n scrubAltMultiplier,\n onScrub,\n };\n\n const handlePointerDown = React.useCallback(\n (event: React.PointerEvent) => {\n if (!scrub) return;\n\n // Don't start scrubbing if clicking on interactive elements\n const target = event.target as HTMLElement;\n if (target.closest(FOCUSABLE_IN_SLOT)) return;\n\n event.preventDefault();\n accumulatedMovement.current = 0;\n // Initialize to current value so min/max clamping works correctly\n currentValue.current = scrubValue ?? 0;\n\n // Initialize virtual cursor at actual mouse position\n virtualX.current = event.clientX;\n virtualY.current = event.clientY;\n setCursorStart({ x: event.clientX, y: event.clientY });\n\n const slot = slotRef.current;\n if (!slot) return;\n\n if (usePointerCapture) {\n // Safari/Firefox: Use pointer capture (no browser warning)\n pointerIdRef.current = event.pointerId;\n lastXRef.current = event.clientX;\n slot.setPointerCapture(event.pointerId);\n setIsScrubbing(true);\n } else {\n // Chrome: Use pointer lock for infinite movement\n lockedByMe.current = true;\n slot.requestPointerLock();\n }\n },\n [scrub, scrubValue],\n );\n\n // Handle pointer lock state changes (Chrome only). Only a scrub slot listens, and only a lock\n // this slot asked for starts or ends its scrub.\n React.useEffect(() => {\n if (usePointerCapture || !scrub) return;\n\n const handlePointerLockChange = () => {\n if (!lockedByMe.current) return;\n const isLocked = document.pointerLockElement === slotRef.current;\n setIsScrubbing(isLocked);\n if (!isLocked) {\n lockedByMe.current = false;\n // Fire callback with isChanging = false when scrubbing ends\n scrubConfigRef.current.onScrub?.(0, false);\n accumulatedMovement.current = 0;\n currentValue.current = 0;\n }\n };\n\n document.addEventListener('pointerlockchange', handlePointerLockChange);\n return () => {\n document.removeEventListener('pointerlockchange', handlePointerLockChange);\n };\n }, [scrub]);\n\n // Shared scrub calculation logic\n const processScrubMovement = React.useCallback((movementX: number, movementY: number, shiftKey: boolean, altKey: boolean) => {\n const config = scrubConfigRef.current;\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Update virtual position with wrap-around at viewport edges\n virtualX.current += movementX;\n if (virtualX.current > viewportWidth) {\n virtualX.current = virtualX.current % viewportWidth;\n } else if (virtualX.current < 0) {\n virtualX.current = viewportWidth + (virtualX.current % viewportWidth);\n }\n\n // Also track Y with wrap-around\n let newY = virtualY.current + movementY;\n if (newY > viewportHeight) {\n newY = newY % viewportHeight;\n } else if (newY < 0) {\n newY = viewportHeight + (newY % viewportHeight);\n }\n virtualY.current = newY;\n\n const cursor = cursorRef.current;\n if (cursor) {\n cursor.style.left = `${virtualX.current}px`;\n cursor.style.top = `${newY}px`;\n }\n\n // Accumulate movement for sensitivity calculation\n accumulatedMovement.current += movementX;\n\n // Calculate how many steps we've moved\n const stepsFromMovement = accumulatedMovement.current / config.scrubSensitivity;\n\n if (Math.abs(stepsFromMovement) >= 1) {\n // Determine modifier multiplier\n let multiplier = 1;\n if (shiftKey) {\n multiplier = config.scrubShiftMultiplier;\n } else if (altKey) {\n multiplier = config.scrubAltMultiplier;\n }\n\n // Calculate delta\n const wholeSteps = Math.trunc(stepsFromMovement);\n const delta = wholeSteps * config.scrubStep * multiplier;\n\n // Apply min/max clamping if bounds are set\n let clampedDelta = delta;\n if (config.scrubMin !== undefined || config.scrubMax !== undefined) {\n const newValue = currentValue.current + delta;\n const clampedValue = Math.max(config.scrubMin ?? -Infinity, Math.min(config.scrubMax ?? Infinity, newValue));\n clampedDelta = clampedValue - currentValue.current;\n currentValue.current = clampedValue;\n } else {\n currentValue.current += delta;\n }\n\n // Fire callback with clamped delta (isChanging = true during drag)\n if (clampedDelta !== 0) {\n config.onScrub?.(clampedDelta, true);\n }\n\n // Keep the fractional remainder for smooth sub-pixel accumulation\n accumulatedMovement.current = (stepsFromMovement - wholeSteps) * config.scrubSensitivity;\n }\n }, []);\n\n // End scrubbing helper\n const endScrubbing = React.useCallback(() => {\n scrubConfigRef.current.onScrub?.(0, false);\n accumulatedMovement.current = 0;\n currentValue.current = 0;\n pointerIdRef.current = null;\n setIsScrubbing(false);\n }, []);\n\n // Handle pointer capture mode events (Safari/Firefox)\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent) => {\n if (!isScrubbing || !usePointerCapture) return;\n\n const movementX = event.clientX - lastXRef.current;\n lastXRef.current = event.clientX;\n\n processScrubMovement(movementX, event.movementY, event.shiftKey, event.altKey);\n },\n [isScrubbing, processScrubMovement],\n );\n\n const handlePointerUp = React.useCallback(\n (event: React.PointerEvent) => {\n if (!usePointerCapture || pointerIdRef.current !== event.pointerId) return;\n\n const slot = slotRef.current;\n if (slot && pointerIdRef.current !== null) {\n slot.releasePointerCapture(pointerIdRef.current);\n }\n endScrubbing();\n },\n [endScrubbing],\n );\n\n const handleLostPointerCapture = React.useCallback(() => {\n if (usePointerCapture && isScrubbing) {\n endScrubbing();\n }\n }, [isScrubbing, endScrubbing]);\n\n // Attach document-level listeners for pointer lock mode (Chrome)\n React.useEffect(() => {\n if (!isScrubbing || usePointerCapture) return;\n\n const handleMouseMove = (event: MouseEvent) => {\n processScrubMovement(event.movementX, event.movementY, event.shiftKey, event.altKey);\n };\n\n const handleMouseUp = () => {\n // Exit pointer lock to end scrubbing\n document.exitPointerLock();\n };\n\n // Use mousemove for pointer lock (pointermove doesn't work well with pointer lock)\n document.addEventListener('mousemove', handleMouseMove);\n document.addEventListener('mouseup', handleMouseUp);\n\n // Disable text selection during scrubbing\n document.body.style.userSelect = 'none';\n\n return () => {\n document.removeEventListener('mousemove', handleMouseMove);\n document.removeEventListener('mouseup', handleMouseUp);\n document.body.style.userSelect = '';\n };\n }, [isScrubbing, processScrubMovement]);\n\n // Hide native cursor and disable text selection during pointer capture scrubbing\n React.useEffect(() => {\n if (!isScrubbing || !usePointerCapture) return;\n\n // Create a style element to hide cursor globally during scrub\n const style = document.createElement('style');\n style.textContent = '* { cursor: none !important; user-select: none !important; }';\n document.head.appendChild(style);\n\n return () => {\n document.head.removeChild(style);\n };\n }, [isScrubbing]);\n\n // Render virtual cursor via portal to body so it's not clipped\n // Using a data URI of ew-resize cursor for a native look\n const virtualCursor = isScrubbing\n ? ReactDOM.createPortal(\n <img\n ref={cursorRef}\n className=\"kui-TextFieldSlotScrubCursor\"\n src=\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='black' stroke='white' stroke-width='1' d='M0 12 L5 7 L5 10 L19 10 L19 7 L24 12 L19 17 L19 14 L5 14 L5 17 Z'/%3E%3C/svg%3E\"\n alt=\"\"\n style={{\n position: 'fixed',\n left: cursorStart.x,\n top: cursorStart.y,\n transform: 'translate(-50%, -50%)',\n pointerEvents: 'none',\n zIndex: 99999,\n width: 24,\n height: 24,\n }}\n aria-hidden=\"true\"\n />,\n document.body,\n )\n : null;\n\n return (\n <div\n data-accent-color={color}\n data-side={side}\n data-scrub={scrub || undefined}\n data-scrubbing={isScrubbing || undefined}\n {...slotProps}\n id={slotId}\n ref={composeRefs(slotRef, forwardedRef)}\n className={classNames('kui-TextFieldSlot', className)}\n // The caller's handlers run first; the scrub handlers only when `scrub` is set.\n onPointerDown={scrub ? composeEventHandlers(onPointerDown, handlePointerDown) : onPointerDown}\n onPointerMove={scrub ? composeEventHandlers(onPointerMove, handlePointerMove) : onPointerMove}\n onPointerUp={scrub ? composeEventHandlers(onPointerUp, handlePointerUp) : onPointerUp}\n onLostPointerCapture={scrub ? composeEventHandlers(onLostPointerCapture, handleLostPointerCapture) : onLostPointerCapture}\n >\n {slotProps.children}\n {virtualCursor}\n </div>\n );\n});\nTextFieldSlot.displayName = 'TextField.Slot';\n\nexport { TextFieldRoot as Root, TextFieldGroup as Group, TextFieldSlot as Slot };\nexport type { TextFieldRootProps as RootProps, TextFieldGroupProps as GroupProps, TextFieldSlotProps as SlotProps };\n", "import { colorPropDef } from '../props/color.prop.js';\nimport { paddingPropDefs } from '../props/padding.props.js';\nimport { radiusPropDef } from '../props/radius.prop.js';\nimport { flexPropDefs } from './flex.props.js';\n\nimport type { PropDef } from '../props/prop-def.js';\n\nconst sizes = ['1', '2', '3', '4'] as const;\nconst variants = ['raised', 'surface', 'soft', 'ghost', 'outline'] as const;\n\nconst textFieldRootPropDefs = {\n size: { type: 'enum', className: 'kui-r-size', values: sizes, default: '2', responsive: true },\n variant: { type: 'enum', className: 'kui-variant', values: variants, default: 'raised' },\n // Error and validation props\n error: { type: 'boolean', default: false },\n errorMessage: { type: 'string', default: undefined },\n required: { type: 'boolean', default: false },\n // Accessibility props\n 'aria-describedby': { type: 'string', default: undefined },\n 'aria-labelledby': { type: 'string', default: undefined },\n ...colorPropDef,\n ...radiusPropDef,\n} satisfies {\n size: PropDef<(typeof sizes)[number]>;\n variant: PropDef<(typeof variants)[number]>;\n error: PropDef<boolean>;\n errorMessage: PropDef<string | undefined>;\n required: PropDef<boolean>;\n 'aria-describedby': PropDef<string | undefined>;\n 'aria-labelledby': PropDef<string | undefined>;\n};\n\n// Ghost is the dividers alone: no fill, no edge.\nconst groupVariants = ['raised', 'surface', 'soft', 'outline', 'ghost'] as const;\n\nconst textFieldGroupPropDefs = {\n size: { type: 'enum', className: 'kui-r-size', values: sizes, default: '2', responsive: true },\n variant: { type: 'enum', className: 'kui-variant', values: groupVariants, default: 'raised' },\n disabled: { type: 'boolean', default: false },\n ...colorPropDef,\n ...radiusPropDef,\n} satisfies {\n size: PropDef<(typeof sizes)[number]>;\n variant: PropDef<(typeof groupVariants)[number]>;\n disabled: PropDef<boolean>;\n};\n\nconst sides = ['left', 'right'] as const;\n\nconst textFieldSlotPropDefs = {\n side: { type: 'enum', values: sides },\n ...colorPropDef,\n gap: flexPropDefs.gap,\n px: paddingPropDefs.px,\n pl: paddingPropDefs.pl,\n pr: paddingPropDefs.pr,\n} satisfies {\n side: PropDef<(typeof sides)[number]>;\n gap: typeof flexPropDefs.gap;\n px: typeof paddingPropDefs.px;\n pl: typeof paddingPropDefs.pl;\n pr: typeof paddingPropDefs.pr;\n};\n\n/** Scrubbing props for TextField.Slot - handled separately from PropDef system */\ninterface TextFieldSlotScrubProps {\n /** Enable scrubbing behavior on this slot */\n scrub?: boolean;\n /** Current value (required for min/max clamping to work correctly) */\n scrubValue?: number;\n /** Base value change per movement unit (default: 1) */\n scrubStep?: number;\n /** Pixels of movement per step - higher = less sensitive (default: 1) */\n scrubSensitivity?: number;\n /** Minimum allowed value */\n scrubMin?: number;\n /** Maximum allowed value */\n scrubMax?: number;\n /** Step multiplier when Shift is held (default: 10) */\n scrubShiftMultiplier?: number;\n /** Step multiplier when Alt/Option is held (default: 0.1) */\n scrubAltMultiplier?: number;\n /**\n * Callback fired during scrubbing with the value delta\n * @param delta - The change in value\n * @param isChanging - true while dragging, false when released\n */\n onScrub?: (delta: number, isChanging: boolean) => void;\n}\n\nexport type { TextFieldSlotScrubProps };\n\nexport { textFieldRootPropDefs, text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,SAAU,QACV,KAAMF,EAAY,EAClB,IAAKA,EAAY,EACjB,UAAW,wBACX,cAAe,OACf,OAAQ,MACR,MAAO,GACP,OAAQ,EACV,EACA,cAAY,OACd,EACA,SAAS,IACX,EACA,KAEJ,OACE,gBAAC,OACC,oBAAmB5E,EACnB,YAAW6D,EACX,aAAYV,GAAS,OACrB,iBAAgBuB,GAAe,OAC9B,GAAGR,EACJ,GAAItD,EACJ,IAAKuB,GAAYkC,EAAShF,CAAY,EACtC,UAAW6C,EAAW,oBAAqBnC,CAAS,EAEpD,cAAeoD,EAAQgE,EAAqBrD,EAAeyB,EAAiB,EAAIzB,EAChF,cAAeX,EAAQgE,EAAqBpD,EAAe8C,EAAiB,EAAI9C,EAChF,YAAaZ,EAAQgE,EAAqBnD,EAAa8C,EAAe,EAAI9C,EAC1E,qBAAsBb,EAAQgE,EAAqBlD,EAAsB8C,EAAwB,EAAI9C,GAEpGC,EAAU,SACVgD,EACH,CAEJ,CAAC,EACDhE,GAAc,YAAc",
|
|
6
|
-
"names": ["text_field_exports", "__export", "TextFieldGroup", "TextFieldRoot", "TextFieldSlot", "React", "ReactDOM", "classNames", "composeEventHandlers", "composeRefs", "useLayoutEffect", "sizes", "variants", "textFieldRootPropDefs", "colorPropDef", "radiusPropDef", "groupVariants", "textFieldGroupPropDefs", "sides", "textFieldSlotPropDefs", "flexPropDefs", "paddingPropDefs", "TextFieldContext", "FOCUSABLE_IN_SLOT", "TextFieldGroupContext", "TextFieldRoot", "fieldProps", "forwardedRef", "group", "ownProps", "ownClassName", "ownStyle", "themedProps", "useThemeSizeProps", "textFieldRootPropDefs", "inputRef", "children", "className", "color", "radius", "style", "inputProps", "extractProps", "wrapped", "errorId", "slotIds", "setSlotIds", "registerSlot", "id", "prev", "slotId", "contextValue", "ariaDescribedby", "ariaLabelledby", "ariaInvalid", "isInvalid", "describedBy", "parts", "ariaProps", "error", "errorMessage", "required", "_ariaDescribedby", "_ariaLabelledby", "nativeInputProps", "handleMouseDown", "event", "target", "input", "cursorPosition", "field", "mergeStyles", "classNames", "composeRefs", "TextFieldGroup", "props", "textFieldGroupPropDefs", "size", "variant", "disabled", "_radius", "_color", "_disabled", "domProps", "usePointerCapture", "ua", "isSafari", "isFirefox", "TextFieldSlot", "scrub", "scrubValue", "scrubStep", "scrubSensitivity", "scrubMin", "scrubMax", "scrubShiftMultiplier", "scrubAltMultiplier", "onScrub", "restProps", "side", "onPointerDown", "onPointerMove", "onPointerUp", "onLostPointerCapture", "slotProps", "textFieldSlotPropDefs", "generatedId", "slotRef", "holdsControl", "setHoldsControl", "useLayoutEffect", "next", "isScrubbing", "setIsScrubbing", "cursorStart", "setCursorStart", "cursorRef", "virtualY", "lockedByMe", "accumulatedMovement", "currentValue", "virtualX", "pointerIdRef", "lastXRef", "scrubConfigRef", "handlePointerDown", "slot", "handlePointerLockChange", "isLocked", "processScrubMovement", "movementX", "movementY", "shiftKey", "altKey", "config", "viewportWidth", "viewportHeight", "newY", "cursor", "stepsFromMovement", "multiplier", "wholeSteps", "delta", "clampedDelta", "newValue", "clampedValue", "endScrubbing", "handlePointerMove", "handlePointerUp", "handleLostPointerCapture", "handleMouseMove", "handleMouseUp", "virtualCursor", "composeEventHandlers"]
|
|
7
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import{a as N}from"./chunk-BUXK5VGR.js";import{b as E,c as w}from"./chunk-GKDGNPBD.js";import{a as L}from"./chunk-KOAWATCI.js";import{c as g}from"./chunk-OKQAVYW4.js";import{a as z}from"./chunk-AQKSO3SW.js";import{b as O}from"./chunk-FVRVBB6O.js";import{b as x}from"./chunk-5ON3XLRD.js";import{c as C}from"./chunk-HBWBPBSA.js";import{b as D}from"./chunk-XU74PNM2.js";import{a as q}from"./chunk-VQPANPMI.js";var $={};q($,{Content:()=>W,Group:()=>H,Item:()=>K,Label:()=>j,Root:()=>A,Separator:()=>U,Trigger:()=>B});import*as e from"react";import S from"classnames";import{Select as r,ScrollArea as R}from"radix-ui";var J=["1","2","3","4"],v={size:{type:"enum",className:"kui-r-size",values:J,default:"2",responsive:!0}},Q=["raised","surface","soft","outline","ghost"],G={variant:{type:"enum",className:"kui-variant",values:Q,default:"raised"},error:{type:"boolean"},loading:{type:"boolean"},disabled:{type:"boolean"},readOnly:{type:"boolean"},...C,...D,placeholder:{type:"ReactNode"}},M={...C};var V={size:v.size},X=[" ","Enter","ArrowUp","ArrowDown"],h=e.createContext({}),A=o=>{let{children:t,size:a,open:s,defaultOpen:n,onOpenChange:c,...P}=o,p=x(a,v.size),[f,i]=e.useState(n??!1),m=s??f,u=e.useCallback(d=>{i(d),c?.(d)},[c]);return e.createElement(r.Root,{...P,open:m,onOpenChange:u},e.createElement(h.Provider,{value:e.useMemo(()=>({size:p,open:m}),[p,m])},t))};A.displayName="Select.Root";var B=e.forwardRef((o,t)=>{let a=e.useContext(h),{children:s,className:n,color:c,radius:P,placeholder:p,error:f,loading:i,disabled:m,readOnly:u,...d}=g({size:a?.size,...o},V,G),{"aria-invalid":y,"aria-busy":b,"aria-disabled":T,"aria-readonly":k}=d,I=!!f||y===!0||y==="true",Y=e.useMemo(()=>({"aria-invalid":I?!0:y,"aria-busy":i||b,"aria-disabled":m||T,"aria-readonly":u||k}),[I,y,i,b,m,T,u,k]),F=!!(u||i)?{onPointerDown:l=>l.preventDefault(),onClick:l=>{l.preventDefault(),l.currentTarget.focus()},onKeyDown:l=>{let _=l.ctrlKey||l.altKey||l.metaKey;(X.includes(l.key)||!_&&l.key.length===1)&&l.preventDefault()}}:void 0;return e.createElement(r.Trigger,{asChild:!0,disabled:m,...F},e.createElement("button",{"data-accent-color":c,"data-radius":P,"data-error":f,"data-loading":i,...d,...Y,ref:t,className:S("kui-reset","kui-SelectTrigger",n)},e.createElement("span",{className:"kui-SelectTriggerInner"},e.createElement(r.Value,{placeholder:p},s)),e.createElement(r.Icon,{asChild:!0},i?e.createElement("span",{className:"kui-SelectIcon kui-SelectLoadingIcon","aria-hidden":"true"},e.createElement(N,null)):e.createElement(w,{className:"kui-SelectIcon"}))))});B.displayName="Select.Trigger";var W=e.forwardRef((o,t)=>{let a=e.useContext(h),{className:s,children:n,color:c,container:P,...p}=g({size:a?.size,...o},V,M),f=O();if(a.open===!1&&!p.forceMount)return e.createElement(r.Portal,{container:P},e.createElement(r.Content,{...p,asChild:!1,ref:t},n));let i=c||f.accentColor;return e.createElement(r.Portal,{container:P},e.createElement(z,{asChild:!0},e.createElement(r.Content,{"data-accent-color":i,sideOffset:4,...p,asChild:!1,ref:t,className:S("kui-PopperContent","kui-BaseMenuContent","kui-variant-soft","kui-SelectContent",s)},e.createElement(Z,null,n))))});W.displayName="Select.Content";function Z({children:o}){let t=L();return e.createElement(R.Root,{type:"auto",className:"kui-ScrollAreaRoot"},e.createElement(r.Viewport,{asChild:!0,className:S("kui-BaseMenuViewport","kui-SelectViewport")},e.createElement(R.Viewport,{ref:t,className:"kui-ScrollAreaViewport",style:{overflowY:void 0}},o)),e.createElement(R.Scrollbar,{className:"kui-ScrollAreaScrollbar",orientation:"vertical"},e.createElement(R.Thumb,{className:"kui-ScrollAreaThumb"})))}var K=e.forwardRef((o,t)=>{let{className:a,children:s,...n}=o,c=typeof s!="string";return e.createElement(r.Item,{...n,asChild:!1,ref:t,className:S("kui-reset","kui-BaseMenuItem","kui-SelectItem",{"kui-SelectItemRich":c},a)},e.createElement(r.ItemIndicator,{className:"kui-SelectItemIndicator"},e.createElement(E,{className:"kui-SelectItemIndicatorIcon"})),e.createElement(r.ItemText,null,s))});K.displayName="Select.Item";var H=e.forwardRef(({className:o,...t},a)=>e.createElement(r.Group,{...t,asChild:!1,ref:a,className:S("kui-SelectGroup",o)}));H.displayName="Select.Group";var j=e.forwardRef(({className:o,...t},a)=>e.createElement(r.Label,{...t,asChild:!1,ref:a,className:S("kui-BaseMenuLabel","kui-SelectLabel",o)}));j.displayName="Select.Label";var U=e.forwardRef(({className:o,...t},a)=>e.createElement(r.Separator,{...t,asChild:!1,ref:a,className:S("kui-BaseMenuSeparator","kui-SelectSeparator",o)}));U.displayName="Select.Separator";export{A as a,B as b,W as c,K as d,H as e,j as f,U as g,$ as h};
|
|
3
|
-
//# sourceMappingURL=chunk-VQDCHBZR.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/components/select.tsx", "../../src/components/select.props.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport classNames from 'classnames';\nimport { Select as SelectPrimitive, ScrollArea as ScrollAreaPrimitive } from 'radix-ui';\n\nimport { extractProps } from '../helpers/extract-props.js';\nimport { useThemeSize } from '../hooks/theme-size.js';\nimport { ChevronDownIcon, ThickCheckIcon } from './icons.js';\nimport { Spinner } from './spinner.js';\nimport {\n selectRootPropDefs,\n selectTriggerPropDefs,\n selectContentPropDefs,\n} from './select.props.js';\nimport { useThemeContext } from './theme.js';\nimport { PortalTheme } from './_internal/portal-theme.js';\nimport { useThumbSync } from '../hooks/use-thumb-sync.js';\n\nimport type { GetPropDefTypes } from '../props/prop-def.js';\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\n\ntype SelectRootOwnProps = GetPropDefTypes<typeof selectRootPropDefs>;\n\n// Trigger and Content pass the size prop def as its own record. It is hoisted because\n// extractProps caches its compiled prop defs on the identity of each record it is given:\n// a literal written at the call site would be a new object, and a recompile, every render.\nconst selectSizePropDefs = { size: selectRootPropDefs.size };\n\n// Keys that open the list from the trigger, as in Radix.\nconst OPEN_KEYS = [' ', 'Enter', 'ArrowUp', 'ArrowDown'];\n\ninterface SelectContextValue extends SelectRootOwnProps {\n /** Whether the list is open. Undefined when Content is rendered outside a Kookie Select.Root. */\n open?: boolean;\n}\nconst SelectContext = React.createContext<SelectContextValue>({});\n\ninterface SelectRootProps extends SelectPrimitive.SelectProps, SelectRootOwnProps {}\nconst SelectRoot: React.FC<SelectRootProps> = (props) => {\n const {\n children,\n size: sizeProp,\n open: openProp,\n defaultOpen,\n onOpenChange,\n ...rootProps\n } = props;\n const size = useThemeSize(sizeProp, selectRootPropDefs.size);\n\n // Root owns the open state and hands Radix a controlled `open`, so Content learns of a\n // change in the same render Radix does. Radix's uncontrolled state reports changes from an\n // effect, a render late, which would mount the open list once without its wrappers.\n const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen ?? false);\n const open = openProp ?? uncontrolledOpen;\n const handleOpenChange = React.useCallback(\n (next: boolean) => {\n setUncontrolledOpen(next);\n onOpenChange?.(next);\n },\n [onOpenChange],\n );\n\n return (\n <SelectPrimitive.Root {...rootProps} open={open} onOpenChange={handleOpenChange}>\n <SelectContext.Provider value={React.useMemo(() => ({ size, open }), [size, open])}>\n {children}\n </SelectContext.Provider>\n </SelectPrimitive.Root>\n );\n};\nSelectRoot.displayName = 'Select.Root';\n\ntype SelectTriggerElement = React.ElementRef<typeof SelectPrimitive.Trigger>;\ntype SelectTriggerOwnProps = GetPropDefTypes<typeof selectTriggerPropDefs>;\ninterface SelectTriggerProps\n extends ComponentPropsWithout<typeof SelectPrimitive.Trigger, RemovedProps>,\n SelectTriggerOwnProps {}\nconst SelectTrigger = React.forwardRef<SelectTriggerElement, SelectTriggerProps>(\n (props, forwardedRef) => {\n const context = React.useContext(SelectContext);\n const {\n children,\n className,\n color,\n radius,\n placeholder,\n error,\n loading,\n disabled,\n readOnly,\n ...triggerProps\n } = extractProps(\n // Pass size value from the context to generate styles\n { size: context?.size, ...props },\n // Pass size prop def to allow it to be extracted\n selectSizePropDefs,\n selectTriggerPropDefs,\n );\n\n // The props win when set; otherwise a caller's own aria-* (a form library's aria-invalid)\n // stays, so both paths reach the accessibility tree and the CSS, as on TextField.\n const {\n 'aria-invalid': ariaInvalid,\n 'aria-busy': ariaBusy,\n 'aria-disabled': ariaDisabled,\n 'aria-readonly': ariaReadOnly,\n } = triggerProps;\n const isInvalid = Boolean(error) || ariaInvalid === true || ariaInvalid === 'true';\n const ariaProps = React.useMemo(\n () => ({\n 'aria-invalid': isInvalid ? true : ariaInvalid,\n 'aria-busy': loading || ariaBusy,\n 'aria-disabled': disabled || ariaDisabled,\n 'aria-readonly': readOnly || ariaReadOnly,\n }),\n [isInvalid, ariaInvalid, loading, ariaBusy, disabled, ariaDisabled, readOnly, ariaReadOnly],\n );\n\n // Read-only and loading triggers stay focusable but do not open or take typeahead,\n // as on Combobox. Radix skips its own handler when the event is default-prevented.\n const isBlocked = Boolean(readOnly || loading);\n const blockedHandlers = isBlocked\n ? {\n onPointerDown: (event: React.PointerEvent<HTMLButtonElement>) => event.preventDefault(),\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n event.currentTarget.focus();\n },\n onKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>) => {\n const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;\n if (OPEN_KEYS.includes(event.key) || (!isModifierKey && event.key.length === 1)) {\n event.preventDefault();\n }\n },\n }\n : undefined;\n\n return (\n // `disabled` goes to Radix, which merges it with Root's and sets the native attribute.\n <SelectPrimitive.Trigger asChild disabled={disabled} {...blockedHandlers}>\n <button\n data-accent-color={color}\n data-radius={radius}\n data-error={error}\n data-loading={loading}\n {...triggerProps}\n {...ariaProps}\n ref={forwardedRef}\n className={classNames('kui-reset', 'kui-SelectTrigger', className)}\n >\n <span className=\"kui-SelectTriggerInner\">\n <SelectPrimitive.Value placeholder={placeholder}>{children}</SelectPrimitive.Value>\n </span>\n <SelectPrimitive.Icon asChild>\n {loading ? (\n <span className=\"kui-SelectIcon kui-SelectLoadingIcon\" aria-hidden=\"true\">\n <Spinner />\n </span>\n ) : (\n <ChevronDownIcon className=\"kui-SelectIcon\" />\n )}\n </SelectPrimitive.Icon>\n </button>\n </SelectPrimitive.Trigger>\n );\n },\n);\nSelectTrigger.displayName = 'Select.Trigger';\n\ntype SelectContentElement = React.ElementRef<typeof SelectPrimitive.Content>;\ntype SelectContentOwnProps = GetPropDefTypes<typeof selectContentPropDefs>;\ninterface SelectContentProps\n extends ComponentPropsWithout<typeof SelectPrimitive.Content, RemovedProps>,\n SelectContentOwnProps {\n container?: React.ComponentPropsWithoutRef<typeof SelectPrimitive.Portal>['container'];\n}\nconst SelectContent = React.forwardRef<SelectContentElement, SelectContentProps>(\n (props, forwardedRef) => {\n const context = React.useContext(SelectContext);\n const { className, children, color, container, ...contentProps } = extractProps(\n // Pass size value from the context to generate styles\n { size: context?.size, ...props },\n // Pass size prop def to allow it to be extracted\n selectSizePropDefs,\n selectContentPropDefs,\n );\n const themeContext = useThemeContext();\n\n // While closed, Radix still renders Content's children, into a detached fragment: the\n // items must exist for the trigger's value label, typeahead and the native form select.\n // Nothing in that fragment is ever shown, so the theme wrapper and the scroll area, with\n // its two resize observers, are left out until the list opens.\n if (context.open === false && !contentProps.forceMount) {\n return (\n <SelectPrimitive.Portal container={container}>\n <SelectPrimitive.Content {...contentProps} asChild={false} ref={forwardedRef}>\n {children}\n </SelectPrimitive.Content>\n </SelectPrimitive.Portal>\n );\n }\n\n const resolvedColor = color || themeContext.accentColor;\n return (\n <SelectPrimitive.Portal container={container}>\n <PortalTheme asChild>\n <SelectPrimitive.Content\n data-accent-color={resolvedColor}\n sideOffset={4}\n {...contentProps}\n asChild={false}\n ref={forwardedRef}\n className={classNames(\n 'kui-PopperContent',\n 'kui-BaseMenuContent',\n 'kui-variant-soft',\n 'kui-SelectContent',\n className,\n )}\n >\n <SelectScrollArea>{children}</SelectScrollArea>\n </SelectPrimitive.Content>\n </PortalTheme>\n </SelectPrimitive.Portal>\n );\n },\n);\nSelectContent.displayName = 'Select.Content';\n\n/** The open list's scroll area. Its own component so the thumb sync hook runs only while open. */\nfunction SelectScrollArea({ children }: { children: React.ReactNode }) {\n const setThumbViewport = useThumbSync<HTMLDivElement>();\n return (\n <ScrollAreaPrimitive.Root type=\"auto\" className=\"kui-ScrollAreaRoot\">\n <SelectPrimitive.Viewport\n asChild\n className={classNames('kui-BaseMenuViewport', 'kui-SelectViewport')}\n >\n <ScrollAreaPrimitive.Viewport\n ref={setThumbViewport}\n className=\"kui-ScrollAreaViewport\"\n style={{ overflowY: undefined }}\n >\n {children}\n </ScrollAreaPrimitive.Viewport>\n </SelectPrimitive.Viewport>\n <ScrollAreaPrimitive.Scrollbar className=\"kui-ScrollAreaScrollbar\" orientation=\"vertical\">\n <ScrollAreaPrimitive.Thumb className=\"kui-ScrollAreaThumb\" />\n </ScrollAreaPrimitive.Scrollbar>\n </ScrollAreaPrimitive.Root>\n );\n}\n\ntype SelectItemElement = React.ElementRef<typeof SelectPrimitive.Item>;\ninterface SelectItemProps\n extends ComponentPropsWithout<typeof SelectPrimitive.Item, RemovedProps> {}\nconst SelectItem = React.forwardRef<SelectItemElement, SelectItemProps>((props, forwardedRef) => {\n const { className, children, ...itemProps } = props;\n\n // Detect if this is rich content (not just a string)\n const isRichContent = typeof children !== 'string';\n\n return (\n <SelectPrimitive.Item\n {...itemProps}\n asChild={false}\n ref={forwardedRef}\n className={classNames(\n 'kui-reset',\n 'kui-BaseMenuItem',\n 'kui-SelectItem',\n { 'kui-SelectItemRich': isRichContent },\n className,\n )}\n >\n <SelectPrimitive.ItemIndicator className=\"kui-SelectItemIndicator\">\n <ThickCheckIcon className=\"kui-SelectItemIndicatorIcon\" />\n </SelectPrimitive.ItemIndicator>\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\n </SelectPrimitive.Item>\n );\n});\nSelectItem.displayName = 'Select.Item';\n\ntype SelectGroupElement = React.ElementRef<typeof SelectPrimitive.Group>;\ninterface SelectGroupProps\n extends ComponentPropsWithout<typeof SelectPrimitive.Group, RemovedProps> {}\nconst SelectGroup = React.forwardRef<SelectGroupElement, SelectGroupProps>(\n ({ className, ...props }, forwardedRef) => (\n <SelectPrimitive.Group\n {...props}\n asChild={false}\n ref={forwardedRef}\n className={classNames('kui-SelectGroup', className)}\n />\n ),\n);\nSelectGroup.displayName = 'Select.Group';\n\ntype SelectLabelElement = React.ElementRef<typeof SelectPrimitive.Label>;\ninterface SelectLabelProps\n extends ComponentPropsWithout<typeof SelectPrimitive.Label, RemovedProps> {}\nconst SelectLabel = React.forwardRef<SelectLabelElement, SelectLabelProps>(\n ({ className, ...props }, forwardedRef) => (\n <SelectPrimitive.Label\n {...props}\n asChild={false}\n ref={forwardedRef}\n className={classNames('kui-BaseMenuLabel', 'kui-SelectLabel', className)}\n />\n ),\n);\nSelectLabel.displayName = 'Select.Label';\n\ntype SelectSeparatorElement = React.ElementRef<typeof SelectPrimitive.Separator>;\ninterface SelectSeparatorProps\n extends ComponentPropsWithout<typeof SelectPrimitive.Separator, RemovedProps> {}\nconst SelectSeparator = React.forwardRef<SelectSeparatorElement, SelectSeparatorProps>(\n ({ className, ...props }, forwardedRef) => (\n <SelectPrimitive.Separator\n {...props}\n asChild={false}\n ref={forwardedRef}\n className={classNames('kui-BaseMenuSeparator', 'kui-SelectSeparator', className)}\n />\n ),\n);\nSelectSeparator.displayName = 'Select.Separator';\n\nexport {\n SelectRoot as Root,\n SelectTrigger as Trigger,\n SelectContent as Content,\n SelectItem as Item,\n SelectGroup as Group,\n SelectLabel as Label,\n SelectSeparator as Separator,\n};\n\nexport type {\n SelectRootProps as RootProps,\n SelectTriggerProps as TriggerProps,\n SelectContentProps as ContentProps,\n SelectItemProps as ItemProps,\n SelectGroupProps as GroupProps,\n SelectLabelProps as LabelProps,\n SelectSeparatorProps as SeparatorProps,\n};\n", "import type React from 'react';\n\nimport { colorPropDef } from '../props/color.prop.js';\nimport { radiusPropDef } from '../props/radius.prop.js';\n\nimport type { PropDef } from '../props/prop-def.js';\n\nconst sizes = ['1', '2', '3', '4'] as const;\n\nconst selectRootPropDefs = {\n size: { type: 'enum', className: 'kui-r-size', values: sizes, default: '2', responsive: true },\n} satisfies {\n size: PropDef<(typeof sizes)[number]>;\n};\n\nconst triggerVariants = ['raised', 'surface', 'soft', 'outline', 'ghost'] as const;\n\nconst selectTriggerPropDefs = {\n variant: { type: 'enum', className: 'kui-variant', values: triggerVariants, default: 'raised' },\n error: { type: 'boolean' },\n loading: { type: 'boolean' },\n disabled: { type: 'boolean' },\n readOnly: { type: 'boolean' },\n ...colorPropDef,\n ...radiusPropDef,\n placeholder: { type: 'ReactNode' },\n} satisfies {\n variant: PropDef<(typeof triggerVariants)[number]>;\n error: PropDef<boolean>;\n loading: PropDef<boolean>;\n disabled: PropDef<boolean>;\n readOnly: PropDef<boolean>;\n placeholder: PropDef<React.ReactNode>;\n};\n\n\nconst selectContentPropDefs = {\n ...colorPropDef,\n} satisfies {\n};\n\nexport { selectRootPropDefs, selectTriggerPropDefs, selectContentPropDefs };\n"],
|
|
5
|
-
"mappings": ";uZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,UAAAC,EAAA,SAAAC,EAAA,UAAAC,EAAA,SAAAC,EAAA,cAAAC,EAAA,YAAAC,IAEA,UAAYC,MAAW,QACvB,OAAOC,MAAgB,aACvB,OAAS,UAAUC,EAAiB,cAAcC,MAA2B,WCG7E,IAAMC,EAAQ,CAAC,IAAK,IAAK,IAAK,GAAG,EAE3BC,EAAqB,CACzB,KAAM,CAAE,KAAM,OAAQ,UAAW,aAAc,OAAQD,EAAO,QAAS,IAAK,WAAY,EAAK,CAC/F,EAIME,EAAkB,CAAC,SAAU,UAAW,OAAQ,UAAW,OAAO,EAElEC,EAAwB,CAC5B,QAAS,CAAE,KAAM,OAAQ,UAAW,cAAe,OAAQD,EAAiB,QAAS,QAAS,EAC9F,MAAO,CAAE,KAAM,SAAU,EACzB,QAAS,CAAE,KAAM,SAAU,EAC3B,SAAU,CAAE,KAAM,SAAU,EAC5B,SAAU,CAAE,KAAM,SAAU,EAC5B,GAAGE,EACH,GAAGC,EACH,YAAa,CAAE,KAAM,WAAY,CACnC,EAUMC,EAAwB,CAC5B,GAAGF,CACL,EDXA,IAAMG,EAAqB,CAAE,KAAMC,EAAmB,IAAK,EAGrDC,EAAY,CAAC,IAAK,QAAS,UAAW,WAAW,EAMjDC,EAAsB,gBAAkC,CA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1C,EAAgB,SAAhB,KAA0Bb,CAAS,CACtC,CAEJ,CAAC,EACDoD,EAAW,YAAc,cAKzB,IAAMI,EAAoB,aACxB,CAAC,CAAE,UAAAvC,EAAW,GAAGlB,CAAM,EAAGgB,IACxB,gBAACF,EAAgB,MAAhB,CACE,GAAGd,EACJ,QAAS,GACT,IAAKgB,EACL,UAAWsB,EAAW,kBAAmBpB,CAAS,EACpD,CAEJ,EACAuC,EAAY,YAAc,eAK1B,IAAMC,EAAoB,aACxB,CAAC,CAAE,UAAAxC,EAAW,GAAGlB,CAAM,EAAGgB,IACxB,gBAACF,EAAgB,MAAhB,CACE,GAAGd,EACJ,QAAS,GACT,IAAKgB,EACL,UAAWsB,EAAW,oBAAqB,kBAAmBpB,CAAS,EACzE,CAEJ,EACAwC,EAAY,YAAc,eAK1B,IAAMC,EAAwB,aAC5B,CAAC,CAAE,UAAAzC,EAAW,GAAGlB,CAAM,EAAGgB,IACxB,gBAACF,EAAgB,UAAhB,CACE,GAAGd,EACJ,QAAS,GACT,IAAKgB,EACL,UAAWsB,EAAW,wBAAyB,sBAAuBpB,CAAS,EACjF,CAEJ,EACAyC,EAAgB,YAAc",
|
|
6
|
-
"names": ["select_exports", "__export", "SelectContent", "SelectGroup", "SelectItem", "SelectLabel", "SelectRoot", "SelectSeparator", "SelectTrigger", "React", "classNames", "SelectPrimitive", "ScrollAreaPrimitive", "sizes", "selectRootPropDefs", "triggerVariants", "selectTriggerPropDefs", "colorPropDef", "radiusPropDef", "selectContentPropDefs", "selectSizePropDefs", "selectRootPropDefs", "OPEN_KEYS", "SelectContext", "SelectRoot", "props", "children", "sizeProp", "openProp", "defaultOpen", "onOpenChange", "rootProps", "size", "useThemeSize", "uncontrolledOpen", "setUncontrolledOpen", "open", "handleOpenChange", "next", "SelectPrimitive", "SelectTrigger", "forwardedRef", "context", "className", "color", "radius", "placeholder", "error", "loading", "disabled", "readOnly", "triggerProps", "extractProps", "selectTriggerPropDefs", "ariaInvalid", "ariaBusy", "ariaDisabled", "ariaReadOnly", "isInvalid", "ariaProps", "blockedHandlers", "event", "isModifierKey", "classNames", "Spinner", "ChevronDownIcon", "SelectContent", "container", "contentProps", "selectContentPropDefs", "themeContext", "useThemeContext", "resolvedColor", "PortalTheme", "SelectScrollArea", "setThumbViewport", "useThumbSync", "ScrollAreaPrimitive", "SelectItem", "itemProps", "isRichContent", "ThickCheckIcon", "SelectGroup", "SelectLabel", "SelectSeparator"]
|
|
7
|
-
}
|