@kushagradhawan/kookie-ui 0.1.104 → 0.1.105

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.
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.d.ts","sourceRoot":"","sources":["../../../src/components/text-field.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,uBAAuB,EAC7B,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,KAAK,qBAAqB,GAAG,eAAe,CAAC,OAAO,qBAAqB,CAAC,GAAG;IAC3E,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EACD,MAAM,GACN,gBAAgB,GAChB,OAAO,GACP,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,KAAK,GACL,MAAM,GACN,MAAM,GACN,KAAK,GACL,MAAM,CAAC;CACZ,CAAC;AACF,KAAK,mBAAmB,GAAG,qBAAqB,CAC9C,OAAO,EACP,yBAAyB,GAAG,OAAO,GAAG,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CACjF,CAAC;AACF,UAAU,kBAAmB,SAAQ,mBAAmB,EAAE,WAAW,EAAE,qBAAqB;CAAG;AAC/F,QAAA,MAAM,aAAa,6FAkGlB,CAAC;AAIF,KAAK,qBAAqB,GAAG,eAAe,CAAC,OAAO,qBAAqB,CAAC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O,CAAC,CAAC;AAC5I,UAAU,kBAAmB,SAAQ,mBAAmB,EAAE,WAAW,EAAE,qBAAqB;CAAG;AAC/F,QAAA,MAAM,aAAa,6FAiFjB,CAAC;AAIH,KAAK,qBAAqB,GAAG,eAAe,CAAC,OAAO,qBAAqB,CAAC,GAAG,uBAAuB,CAAC;AACrG,UAAU,kBAAmB,SAAQ,qBAAqB,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,qBAAqB;CAAG;AAYzG,QAAA,MAAM,aAAa,2FAiSjB,CAAC;AAGH,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,aAAa,IAAI,IAAI,EAAE,CAAC;AACxD,YAAY,EAAE,kBAAkB,IAAI,SAAS,EAAE,kBAAkB,IAAI,SAAS,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
- "use strict";"use client";var $=Object.create;var k=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var se=(t,o)=>{for(var r in o)k(t,r,{get:o[r],enumerable:!0})},U=(t,o,r,d)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of te(o))!oe.call(t,a)&&a!==r&&k(t,a,{get:()=>o[a],enumerable:!(d=ee(o,a))||d.enumerable});return t};var W=(t,o,r)=>(r=t!=null?$(re(t)):{},U(o||!t||!t.__esModule?k(r,"default",{value:t,enumerable:!0}):r,t)),ne=t=>U(k({},"__esModule",{value:!0}),t);var le={};se(le,{Root:()=>B,Slot:()=>G});module.exports=ne(le);var e=W(require("react")),ie=W(require("react-dom")),X=W(require("classnames")),Y=require("radix-ui/internal"),C=require("./text-field.props.js"),q=require("../helpers/extract-props.js"),Z=require("../props/margin.props.js");const B=e.forwardRef((t,o)=>{const r=e.useRef(null),{children:d,className:a,color:M,radius:F,panelBackground:R,material:w,style:E,...i}=(0,q.extractProps)(t,C.textFieldRootPropDefs,Z.marginPropDefs),L=w||R,h=e.useId(),v=i.error||i.isInvalid,{"aria-describedby":P,"aria-labelledby":g}=i,b=e.useMemo(()=>{const p=[];return i.errorMessage&&p.push(h),P&&p.push(P),p.length>0?p.join(" "):void 0},[i.errorMessage,P,h]),x=e.useMemo(()=>({"aria-invalid":v,"aria-describedby":b,"aria-labelledby":g}),[v,b,g]),{error:_,errorMessage:N,isInvalid:H,required:y,"aria-describedby":f,"aria-labelledby":c,...S}=i,V=e.useCallback(p=>{const s=p.target;if(s.closest("input, button, a"))return;const l=r.current;if(!l)return;const n=s.closest(`
1
+ "use strict";"use client";var ie=Object.create;var j=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var ue=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var de=(r,n)=>{for(var o in n)j(r,o,{get:n[o],enumerable:!0})},$=(r,n,o,m)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of ae(n))!ce.call(r,u)&&u!==o&&j(r,u,{get:()=>n[u],enumerable:!(m=le(n,u))||m.enumerable});return r};var G=(r,n,o)=>(o=r!=null?ie(ue(r)):{},$(n||!r||!r.__esModule?j(o,"default",{value:r,enumerable:!0}):o,r)),pe=r=>$(j({},"__esModule",{value:!0}),r);var me={};de(me,{Root:()=>Z,Slot:()=>J});module.exports=pe(me);var e=G(require("react")),fe=G(require("react-dom")),U=G(require("classnames")),_=require("radix-ui/internal"),O=require("./text-field.props.js"),z=require("../helpers/extract-props.js"),ee=require("../props/margin.props.js");const Z=e.forwardRef((r,n)=>{const o=e.useRef(null),{children:m,className:u,color:w,radius:L,panelBackground:C,material:k,style:I,...l}=(0,z.extractProps)(r,O.textFieldRootPropDefs,ee.marginPropDefs),D=k||C,g=e.useId(),S=l.error||l.isInvalid,{"aria-describedby":M,"aria-labelledby":R}=l,h=e.useMemo(()=>{const a=[];return l.errorMessage&&a.push(g),M&&a.push(M),a.length>0?a.join(" "):void 0},[l.errorMessage,M,g]),i=e.useMemo(()=>({"aria-invalid":S,"aria-describedby":h,"aria-labelledby":R}),[S,h,R]),{error:N,errorMessage:W,isInvalid:K,required:x,"aria-describedby":P,"aria-labelledby":c,...y}=l,T=e.useCallback(a=>{const X=a.target;if(X.closest("input, button, a"))return;const b=o.current;if(!b)return;const A=X.closest(`
2
2
  .rt-TextFieldSlot[data-side='right'],
3
3
  .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])
4
- `)?l.value.length:0;requestAnimationFrame(()=>{try{l.setSelectionRange(n,n)}catch{}l.focus()})},[]);return e.createElement("div",{"data-accent-color":M,"data-radius":F,"data-panel-background":L,"data-material":L,style:E,className:(0,X.default)("rt-TextFieldRoot",a,{"rt-error":v}),onPointerDown:V},e.createElement("input",{spellCheck:"false",...S,...x,ref:(0,Y.composeRefs)(r,o),className:"rt-reset rt-TextFieldInput"}),d,i.errorMessage&&e.createElement("div",{id:h,className:"rt-TextFieldErrorMessage",role:"alert","aria-live":"polite"},i.errorMessage))});B.displayName="TextField.Root";const G=e.forwardRef((t,o)=>{const{scrub:r,scrubValue:d,scrubStep:a=1,scrubSensitivity:M=1,scrubMin:F,scrubMax:R,scrubShiftMultiplier:w=10,scrubAltMultiplier:E=.1,onScrub:i,...L}=t,{className:h,color:v,side:P,...g}=(0,q.extractProps)(L,C.textFieldSlotPropDefs),b=e.useRef(null),[x,_]=e.useState(!1),[N,H]=e.useState({x:0,y:0}),y=e.useRef(0),f=e.useRef(0),c=e.useRef(0),S=e.useRef({scrubValue:d,scrubStep:a,scrubSensitivity:M,scrubMin:F,scrubMax:R,scrubShiftMultiplier:w,scrubAltMultiplier:E,onScrub:i});S.current={scrubValue:d,scrubStep:a,scrubSensitivity:M,scrubMin:F,scrubMax:R,scrubShiftMultiplier:w,scrubAltMultiplier:E,onScrub:i};const V=e.useCallback(s=>{if(!r||s.target.closest("input, button, a"))return;s.preventDefault(),y.current=0,f.current=d??0,c.current=s.clientX,H({x:s.clientX,y:s.clientY});const m=b.current;m&&m.requestPointerLock()},[r,d]);e.useEffect(()=>{const s=()=>{const l=document.pointerLockElement===b.current;_(l),l||(S.current.onScrub?.(0,!1),y.current=0,f.current=0)};return document.addEventListener("pointerlockchange",s),()=>{document.removeEventListener("pointerlockchange",s)}},[]),e.useEffect(()=>{if(!x)return;const s=m=>{const n=S.current,z=m.movementX,J=m.movementY,D=window.innerWidth,I=window.innerHeight;c.current+=z,c.current>D?c.current=c.current%D:c.current<0&&(c.current=D+c.current%D),H(T=>{let u=T.y+J;return u>I?u=u%I:u<0&&(u=I+u%I),{x:c.current,y:u}}),y.current+=z;const j=y.current/n.scrubSensitivity;if(Math.abs(j)>=1){let T=1;m.shiftKey?T=n.scrubShiftMultiplier:m.altKey&&(T=n.scrubAltMultiplier);const u=Math.trunc(j),A=u*n.scrubStep*T;let O=A;if(n.scrubMin!==void 0||n.scrubMax!==void 0){const Q=f.current+A,K=Math.max(n.scrubMin??-1/0,Math.min(n.scrubMax??1/0,Q));O=K-f.current,f.current=K}else f.current+=A;O!==0&&n.onScrub?.(O,!0),y.current=(j-u)*n.scrubSensitivity}},l=()=>{document.exitPointerLock()};return document.addEventListener("mousemove",s),document.addEventListener("mouseup",l),document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",l),document.body.style.userSelect=""}},[x]);const p=x?ie.createPortal(e.createElement("img",{className:"rt-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:N.x,top:N.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":v,"data-side":P,"data-scrub":r||void 0,"data-scrubbing":x||void 0,...g,ref:(0,Y.composeRefs)(b,o),className:(0,X.default)("rt-TextFieldSlot",h),onPointerDown:r?V:void 0},g.children,p)});G.displayName="TextField.Slot";
4
+ `)?b.value.length:0;requestAnimationFrame(()=>{try{b.setSelectionRange(A,A)}catch{}b.focus()})},[]);return e.createElement("div",{"data-accent-color":w,"data-radius":L,"data-panel-background":D,"data-material":D,style:I,className:(0,U.default)("rt-TextFieldRoot",u,{"rt-error":S}),onPointerDown:T},e.createElement("input",{spellCheck:"false",...y,...i,ref:(0,_.composeRefs)(o,n),className:"rt-reset rt-TextFieldInput"}),m,l.errorMessage&&e.createElement("div",{id:g,className:"rt-TextFieldErrorMessage",role:"alert","aria-live":"polite"},l.errorMessage))});Z.displayName="TextField.Root";const v=(()=>{if(typeof navigator>"u")return!1;const r=navigator.userAgent,n=/^((?!chrome|android).)*safari/i.test(r),o=/firefox/i.test(r);return n||o})(),J=e.forwardRef((r,n)=>{const{scrub:o,scrubValue:m,scrubStep:u=1,scrubSensitivity:w=1,scrubMin:L,scrubMax:C,scrubShiftMultiplier:k=10,scrubAltMultiplier:I=.1,onScrub:l,...D}=r,{className:g,color:S,side:M,...R}=(0,z.extractProps)(D,O.textFieldSlotPropDefs),h=e.useRef(null),[i,N]=e.useState(!1),[W,K]=e.useState({x:0,y:0}),x=e.useRef(0),P=e.useRef(0),c=e.useRef(0),y=e.useRef(null),T=e.useRef(0),a=e.useRef({scrubValue:m,scrubStep:u,scrubSensitivity:w,scrubMin:L,scrubMax:C,scrubShiftMultiplier:k,scrubAltMultiplier:I,onScrub:l});a.current={scrubValue:m,scrubStep:u,scrubSensitivity:w,scrubMin:L,scrubMax:C,scrubShiftMultiplier:k,scrubAltMultiplier:I,onScrub:l};const X=e.useCallback(t=>{if(!o||t.target.closest("input, button, a"))return;t.preventDefault(),x.current=0,P.current=m??0,c.current=t.clientX,K({x:t.clientX,y:t.clientY});const d=h.current;d&&(v?(y.current=t.pointerId,T.current=t.clientX,d.setPointerCapture(t.pointerId),N(!0)):d.requestPointerLock())},[o,m]);e.useEffect(()=>{if(v)return;const t=()=>{const s=document.pointerLockElement===h.current;N(s),s||(a.current.onScrub?.(0,!1),x.current=0,P.current=0)};return document.addEventListener("pointerlockchange",t),()=>{document.removeEventListener("pointerlockchange",t)}},[]);const b=e.useCallback((t,s,d,ne)=>{const p=a.current,H=window.innerWidth,V=window.innerHeight;c.current+=t,c.current>H?c.current=c.current%H:c.current<0&&(c.current=H+c.current%H),K(E=>{let f=E.y+s;return f>V?f=f%V:f<0&&(f=V+f%V),{x:c.current,y:f}}),x.current+=t;const Y=x.current/p.scrubSensitivity;if(Math.abs(Y)>=1){let E=1;d?E=p.scrubShiftMultiplier:ne&&(E=p.scrubAltMultiplier);const f=Math.trunc(Y),q=f*p.scrubStep*E;let B=q;if(p.scrubMin!==void 0||p.scrubMax!==void 0){const se=P.current+q,Q=Math.max(p.scrubMin??-1/0,Math.min(p.scrubMax??1/0,se));B=Q-P.current,P.current=Q}else P.current+=q;B!==0&&p.onScrub?.(B,!0),x.current=(Y-f)*p.scrubSensitivity}},[]),F=e.useCallback(()=>{a.current.onScrub?.(0,!1),x.current=0,P.current=0,y.current=null,N(!1)},[]),A=e.useCallback(t=>{if(!i||!v)return;const s=t.clientX-T.current;T.current=t.clientX,b(s,t.movementY,t.shiftKey,t.altKey)},[i,b]),te=e.useCallback(t=>{if(!v||y.current!==t.pointerId)return;const s=h.current;s&&y.current!==null&&s.releasePointerCapture(y.current),F()},[F]),re=e.useCallback(()=>{v&&i&&F()},[i,F]);e.useEffect(()=>{if(!i||v)return;const t=d=>{b(d.movementX,d.movementY,d.shiftKey,d.altKey)},s=()=>{document.exitPointerLock()};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",s),document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),document.body.style.userSelect=""}},[i,b]),e.useEffect(()=>{if(!i||!v)return;const t=document.createElement("style");return t.textContent="* { cursor: none !important; user-select: none !important; }",document.head.appendChild(t),()=>{document.head.removeChild(t)}},[i]);const oe=i?fe.createPortal(e.createElement("img",{className:"rt-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:W.x,top:W.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":S,"data-side":M,"data-scrub":o||void 0,"data-scrubbing":i||void 0,...R,ref:(0,_.composeRefs)(h,n),className:(0,U.default)("rt-TextFieldSlot",g),onPointerDown:o?X:void 0,onPointerMove:o?A:void 0,onPointerUp:o?te:void 0,onLostPointerCapture:o?re:void 0},R.children,oe)});J.displayName="TextField.Slot";
5
5
  //# sourceMappingURL=text-field.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/text-field.tsx"],
4
- "sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport classNames from 'classnames';\nimport { composeRefs } from 'radix-ui/internal';\n\nimport {\n textFieldRootPropDefs,\n textFieldSlotPropDefs,\n type TextFieldSlotScrubProps,\n} from './text-field.props.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { NotInputTextualAttributes } from '../helpers/input-attributes.js';\nimport type { MarginProps } from '../props/margin.props.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?:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'hidden'\n | 'month'\n | 'number'\n | 'password'\n | 'search'\n | 'tel'\n | 'text'\n | 'time'\n | 'url'\n | 'week';\n};\ntype TextFieldInputProps = ComponentPropsWithout<\n 'input',\n NotInputTextualAttributes | 'color' | 'defaultValue' | 'size' | 'type' | 'value'\n>;\ninterface TextFieldRootProps extends TextFieldInputProps, MarginProps, TextFieldRootOwnProps {}\nconst TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>(\n (props, forwardedRef) => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const { children, className, color, radius, panelBackground, material, style, ...inputProps } =\n extractProps(props, textFieldRootPropDefs, marginPropDefs);\n const effectiveMaterial = material || panelBackground;\n\n // Generate unique IDs for accessibility\n const errorId = React.useId();\n\n // Determine invalid state\n const isInvalid = inputProps.error || inputProps.isInvalid;\n\n const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby } = inputProps;\n\n // Build aria-describedby string\n const describedBy = React.useMemo(() => {\n const parts = [];\n if (inputProps.errorMessage) parts.push(errorId);\n if (ariaDescribedby) parts.push(ariaDescribedby);\n return parts.length > 0 ? parts.join(' ') : undefined;\n }, [inputProps.errorMessage, ariaDescribedby, errorId]);\n\n // Build aria attributes\n const ariaProps = React.useMemo(\n () => ({\n 'aria-invalid': isInvalid,\n 'aria-describedby': describedBy,\n 'aria-labelledby': ariaLabelledby,\n }),\n [isInvalid, describedBy, ariaLabelledby],\n );\n\n // Filter out our custom props to avoid DOM warnings\n const {\n error,\n errorMessage,\n isInvalid: _isInvalid,\n required,\n 'aria-describedby': _ariaDescribedby,\n 'aria-labelledby': _ariaLabelledby,\n ...nativeInputProps\n } = inputProps;\n\n // Memoized pointer event handler\n const handlePointerDown = React.useCallback((event: React.PointerEvent) => {\n const target = event.target as HTMLElement;\n if (target.closest('input, button, a')) 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 .rt-TextFieldSlot[data-side='right'],\n .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])\n `);\n\n const cursorPosition = isRightSlot ? input.value.length : 0;\n\n requestAnimationFrame(() => {\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 input.focus();\n });\n }, []);\n\n return (\n <div\n data-accent-color={color}\n data-radius={radius}\n data-panel-background={effectiveMaterial}\n data-material={effectiveMaterial}\n style={style}\n className={classNames('rt-TextFieldRoot', className, {\n 'rt-error': isInvalid,\n })}\n onPointerDown={handlePointerDown}\n >\n <input\n spellCheck=\"false\"\n {...nativeInputProps}\n {...ariaProps}\n ref={composeRefs(inputRef, forwardedRef)}\n className=\"rt-reset rt-TextFieldInput\"\n />\n {children}\n {inputProps.errorMessage && (\n <div id={errorId} className=\"rt-TextFieldErrorMessage\" role=\"alert\" aria-live=\"polite\">\n {inputProps.errorMessage}\n </div>\n )}\n </div>\n );\n },\n);\nTextFieldRoot.displayName = 'TextField.Root';\n\ntype TextFieldSlotElement = React.ElementRef<'div'>;\ntype TextFieldSlotOwnProps = GetPropDefTypes<typeof textFieldSlotPropDefs> & TextFieldSlotScrubProps;\ninterface TextFieldSlotProps\n extends ComponentPropsWithout<'div', RemovedProps>,\n TextFieldSlotOwnProps {}\nconst TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>(\n (props, forwardedRef) => {\n // Extract scrub props first (not part of PropDef system)\n const {\n scrub,\n scrubValue,\n scrubStep = 1,\n scrubSensitivity = 1,\n scrubMin,\n scrubMax,\n scrubShiftMultiplier = 10,\n scrubAltMultiplier = 0.1,\n onScrub,\n ...restProps\n } = props;\n\n // Then extract styling props\n const { className, color, side, ...slotProps } = extractProps(restProps, textFieldSlotPropDefs);\n\n const slotRef = React.useRef<HTMLDivElement>(null);\n const [isScrubbing, setIsScrubbing] = React.useState(false);\n // Virtual cursor position - X wraps around viewport, Y follows mouse\n const [cursorPosition, setCursorPosition] = React.useState({ x: 0, y: 0 });\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\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('input, button, a')) 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 setCursorPosition({ x: event.clientX, y: event.clientY });\n\n // Request pointer lock for infinite movement (cursor won't hit screen edges)\n const slot = slotRef.current;\n if (slot) {\n slot.requestPointerLock();\n }\n },\n [scrub, scrubValue],\n );\n\n // Handle pointer lock state changes\n React.useEffect(() => {\n const handlePointerLockChange = () => {\n const isLocked = document.pointerLockElement === slotRef.current;\n setIsScrubbing(isLocked);\n if (!isLocked) {\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 }, []);\n\n // Attach document-level listeners when scrubbing starts\n React.useEffect(() => {\n if (!isScrubbing) return;\n\n const handleMouseMove = (event: MouseEvent) => {\n const config = scrubConfigRef.current;\n const movementX = event.movementX;\n const movementY = event.movementY;\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 setCursorPosition((prev) => {\n let newY = prev.y + movementY;\n if (newY > viewportHeight) {\n newY = newY % viewportHeight;\n } else if (newY < 0) {\n newY = viewportHeight + (newY % viewportHeight);\n }\n return { x: virtualX.current, y: newY };\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 (event.shiftKey) {\n multiplier = config.scrubShiftMultiplier;\n } else if (event.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(\n config.scrubMin ?? -Infinity,\n Math.min(config.scrubMax ?? Infinity, newValue),\n );\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 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]);\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 className=\"rt-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: cursorPosition.x,\n top: cursorPosition.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 ref={composeRefs(slotRef, forwardedRef)}\n className={classNames('rt-TextFieldSlot', className)}\n onPointerDown={scrub ? handlePointerDown : undefined}\n >\n {slotProps.children}\n {virtualCursor}\n </div>\n );\n },\n);\nTextFieldSlot.displayName = 'TextField.Slot';\n\nexport { TextFieldRoot as Root, TextFieldSlot as Slot };\nexport type { TextFieldRootProps as RootProps, TextFieldSlotProps as SlotProps };\n"],
5
- "mappings": "ilBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,UAAAE,EAAA,SAAAC,IAAA,eAAAC,GAAAJ,IAEA,IAAAK,EAAuB,oB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OACC,UAAU,8BACV,IAAI,oPACJ,IAAI,GACJ,MAAO,CACL,SAAU,QACV,KAAMqC,EAAe,EACrB,IAAKA,EAAe,EACpB,UAAW,wBACX,cAAe,OACf,OAAQ,MACR,MAAO,GACP,OAAQ,EACV,EACA,cAAY,OACd,EACA,SAAS,IACX,EACA,KAEJ,OACErC,EAAA,cAAC,OACC,oBAAmBY,EACnB,YAAWqC,EACX,aAAYV,GAAS,OACrB,iBAAgBa,GAAe,OAC9B,GAAGF,EACJ,OAAK,eAAYC,EAAS3C,CAAY,EACtC,aAAW,EAAA8B,SAAW,mBAAoB3B,CAAS,EACnD,cAAe4B,EAAQN,EAAoB,QAE1CiB,EAAU,SACV4B,CACH,CAEJ,CACF,EACAhF,EAAc,YAAc",
6
- "names": ["text_field_exports", "__export", "TextFieldRoot", "TextFieldSlot", "__toCommonJS", "React", "ReactDOM", "import_classnames", "import_internal", "import_text_field_props", "import_extract_props", "import_margin_props", "props", "forwardedRef", "inputRef", "children", "className", "color", "radius", "panelBackground", "material", "style", "inputProps", "effectiveMaterial", "errorId", "isInvalid", "ariaDescribedby", "ariaLabelledby", "describedBy", "parts", "ariaProps", "error", "errorMessage", "_isInvalid", "required", "_ariaDescribedby", "_ariaLabelledby", "nativeInputProps", "handlePointerDown", "event", "target", "input", "cursorPosition", "classNames", "scrub", "scrubValue", "scrubStep", "scrubSensitivity", "scrubMin", "scrubMax", "scrubShiftMultiplier", "scrubAltMultiplier", "onScrub", "restProps", "side", "slotProps", "slotRef", "isScrubbing", "setIsScrubbing", "setCursorPosition", "accumulatedMovement", "currentValue", "virtualX", "scrubConfigRef", "slot", "handlePointerLockChange", "isLocked", "handleMouseMove", "config", "movementX", "movementY", "viewportWidth", "viewportHeight", "prev", "newY", "stepsFromMovement", "multiplier", "wholeSteps", "delta", "clampedDelta", "newValue", "clampedValue", "handleMouseUp", "virtualCursor"]
4
+ "sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport classNames from 'classnames';\nimport { composeRefs } from 'radix-ui/internal';\n\nimport { textFieldRootPropDefs, textFieldSlotPropDefs, type TextFieldSlotScrubProps } from './text-field.props.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { NotInputTextualAttributes } from '../helpers/input-attributes.js';\nimport type { MarginProps } from '../props/margin.props.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, MarginProps, TextFieldRootOwnProps {}\nconst TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>((props, forwardedRef) => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const { children, className, color, radius, panelBackground, material, style, ...inputProps } = extractProps(props, textFieldRootPropDefs, marginPropDefs);\n const effectiveMaterial = material || panelBackground;\n\n // Generate unique IDs for accessibility\n const errorId = React.useId();\n\n // Determine invalid state\n const isInvalid = inputProps.error || inputProps.isInvalid;\n\n const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby } = inputProps;\n\n // Build aria-describedby string\n const describedBy = React.useMemo(() => {\n const parts = [];\n if (inputProps.errorMessage) parts.push(errorId);\n if (ariaDescribedby) parts.push(ariaDescribedby);\n return parts.length > 0 ? parts.join(' ') : undefined;\n }, [inputProps.errorMessage, ariaDescribedby, errorId]);\n\n // Build aria attributes\n const ariaProps = React.useMemo(\n () => ({\n 'aria-invalid': isInvalid,\n 'aria-describedby': describedBy,\n 'aria-labelledby': ariaLabelledby,\n }),\n [isInvalid, describedBy, ariaLabelledby],\n );\n\n // Filter out our custom props to avoid DOM warnings\n const { error, errorMessage, isInvalid: _isInvalid, required, 'aria-describedby': _ariaDescribedby, 'aria-labelledby': _ariaLabelledby, ...nativeInputProps } = inputProps;\n\n // Memoized pointer event handler\n const handlePointerDown = React.useCallback((event: React.PointerEvent) => {\n const target = event.target as HTMLElement;\n if (target.closest('input, button, a')) 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 .rt-TextFieldSlot[data-side='right'],\n .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])\n `);\n\n const cursorPosition = isRightSlot ? input.value.length : 0;\n\n requestAnimationFrame(() => {\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 input.focus();\n });\n }, []);\n\n return (\n <div\n data-accent-color={color}\n data-radius={radius}\n data-panel-background={effectiveMaterial}\n data-material={effectiveMaterial}\n style={style}\n className={classNames('rt-TextFieldRoot', className, {\n 'rt-error': isInvalid,\n })}\n onPointerDown={handlePointerDown}\n >\n <input spellCheck=\"false\" {...nativeInputProps} {...ariaProps} ref={composeRefs(inputRef, forwardedRef)} className=\"rt-reset rt-TextFieldInput\" />\n {children}\n {inputProps.errorMessage && (\n <div id={errorId} className=\"rt-TextFieldErrorMessage\" role=\"alert\" aria-live=\"polite\">\n {inputProps.errorMessage}\n </div>\n )}\n </div>\n );\n});\nTextFieldRoot.displayName = 'TextField.Root';\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, ...slotProps } = extractProps(restProps, textFieldSlotPropDefs);\n\n const slotRef = React.useRef<HTMLDivElement>(null);\n const [isScrubbing, setIsScrubbing] = React.useState(false);\n // Virtual cursor position - X wraps around viewport, Y follows mouse\n const [cursorPosition, setCursorPosition] = React.useState({ x: 0, y: 0 });\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('input, button, a')) 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 setCursorPosition({ 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 slot.requestPointerLock();\n }\n },\n [scrub, scrubValue],\n );\n\n // Handle pointer lock state changes (Chrome only)\n React.useEffect(() => {\n if (usePointerCapture) return;\n\n const handlePointerLockChange = () => {\n const isLocked = document.pointerLockElement === slotRef.current;\n setIsScrubbing(isLocked);\n if (!isLocked) {\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 }, []);\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 setCursorPosition((prev) => {\n let newY = prev.y + movementY;\n if (newY > viewportHeight) {\n newY = newY % viewportHeight;\n } else if (newY < 0) {\n newY = viewportHeight + (newY % viewportHeight);\n }\n return { x: virtualX.current, y: newY };\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 className=\"rt-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: cursorPosition.x,\n top: cursorPosition.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 ref={composeRefs(slotRef, forwardedRef)}\n className={classNames('rt-TextFieldSlot', className)}\n onPointerDown={scrub ? handlePointerDown : undefined}\n onPointerMove={scrub ? handlePointerMove : undefined}\n onPointerUp={scrub ? handlePointerUp : undefined}\n onLostPointerCapture={scrub ? handleLostPointerCapture : undefined}\n >\n {slotProps.children}\n {virtualCursor}\n </div>\n );\n});\nTextFieldSlot.displayName = 'TextField.Slot';\n\nexport { TextFieldRoot as Root, TextFieldSlot as Slot };\nexport type { TextFieldRootProps as RootProps, TextFieldSlotProps as SlotProps };\n"],
5
+ "mappings": "mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,UAAAE,EAAA,SAAAC,IAAA,eAAAC,GAAAJ,IAEA,IAAAK,EAAuB,oBACvBC,GAA0B,wBAC1BC,EAAuB,yBACvBC,EAA4B,6BAE5BC,EAA2F,iCAC3FC,EAA6B,uCAC7BC,GAA+B,oCAe/B,MAAMT,EAAgBG,EAAM,WAAqD,CAACO,EAAOC,IAAiB,CACxG,MAAMC,EAAWT,EAAM,OAAyB,IAAI,EAC9C,CAAE,SAAAU,EAAU,UAAAC,EAAW,MAAAC,EAAO,OAAAC,EAAQ,gBAAAC,EAAiB,SAAAC,EAAU,MAAAC,EAAO,GAAGC,CAAW,KAAI,gBAAaV,EAAO,wBAAuB,iBAAc,EACnJW,EAAoBH,GAAYD,EAGhCK,EAAUnB,EAAM,MAAM,EAGtBoB,EAAYH,EAAW,OAASA,EAAW,UAE3C,CAAE,mBAAoBI,EAAiB,kBAAmBC,CAAe,EAAIL,EAG7EM,EAAcvB,EAAM,QAAQ,IAAM,CACtC,MAAMwB,EAAQ,CAAC,EACf,OAAIP,EAAW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C,EAAA,cAAC,OACC,oBAAmBY,EACnB,YAAWyC,EACX,aAAYV,GAAS,OACrB,iBAAgBa,GAAe,OAC9B,GAAGF,EACJ,OAAK,eAAYC,EAAS/C,CAAY,EACtC,aAAW,EAAA8B,SAAW,mBAAoB3B,CAAS,EACnD,cAAegC,EAAQV,EAAoB,OAC3C,cAAeU,EAAQ2C,EAAoB,OAC3C,YAAa3C,EAAQ4C,GAAkB,OACvC,qBAAsB5C,EAAQ6C,GAA2B,QAExDlC,EAAU,SACVqC,EACH,CAEJ,CAAC,EACD7F,EAAc,YAAc",
6
+ "names": ["text_field_exports", "__export", "TextFieldRoot", "TextFieldSlot", "__toCommonJS", "React", "ReactDOM", "import_classnames", "import_internal", "import_text_field_props", "import_extract_props", "import_margin_props", "props", "forwardedRef", "inputRef", "children", "className", "color", "radius", "panelBackground", "material", "style", "inputProps", "effectiveMaterial", "errorId", "isInvalid", "ariaDescribedby", "ariaLabelledby", "describedBy", "parts", "ariaProps", "error", "errorMessage", "_isInvalid", "required", "_ariaDescribedby", "_ariaLabelledby", "nativeInputProps", "handlePointerDown", "event", "target", "input", "cursorPosition", "classNames", "usePointerCapture", "ua", "isSafari", "isFirefox", "scrub", "scrubValue", "scrubStep", "scrubSensitivity", "scrubMin", "scrubMax", "scrubShiftMultiplier", "scrubAltMultiplier", "onScrub", "restProps", "side", "slotProps", "slotRef", "isScrubbing", "setIsScrubbing", "setCursorPosition", "accumulatedMovement", "currentValue", "virtualX", "pointerIdRef", "lastXRef", "scrubConfigRef", "slot", "handlePointerLockChange", "isLocked", "processScrubMovement", "movementX", "movementY", "shiftKey", "altKey", "config", "viewportWidth", "viewportHeight", "prev", "newY", "stepsFromMovement", "multiplier", "wholeSteps", "delta", "clampedDelta", "newValue", "clampedValue", "endScrubbing", "handlePointerMove", "handlePointerUp", "handleLostPointerCapture", "handleMouseMove", "handleMouseUp", "virtualCursor"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"text-field.d.ts","sourceRoot":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,qBAAqB,CAAC,GAAG,uBAAuB,CAAC;AACrG,UAAU,kBAAmB,SAAQ,qBAAqB,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,qBAAqB;CAAG;AAYzG,QAAA,MAAM,aAAa,2FAiSjB,CAAC;AAGH,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,aAAa,IAAI,IAAI,EAAE,CAAC;AACxD,YAAY,EAAE,kBAAkB,IAAI,SAAS,EAAE,kBAAkB,IAAI,SAAS,EAAE,CAAC"}
@@ -1,5 +1,5 @@
1
- "use client";import*as e from"react";import*as K from"react-dom";import X from"classnames";import{composeRefs as Y}from"radix-ui/internal";import{textFieldRootPropDefs as U,textFieldSlotPropDefs as Z}from"./text-field.props.js";import{extractProps as q}from"../helpers/extract-props.js";import{marginPropDefs as J}from"../props/margin.props.js";const B=e.forwardRef((D,I)=>{const c=e.useRef(null),{children:d,className:g,color:S,radius:T,panelBackground:M,material:F,style:R,...o}=q(D,U,J),w=F||M,b=e.useId(),x=o.error||o.isInvalid,{"aria-describedby":y,"aria-labelledby":h}=o,p=e.useMemo(()=>{const l=[];return o.errorMessage&&l.push(b),y&&l.push(y),l.length>0?l.join(" "):void 0},[o.errorMessage,y,b]),m=e.useMemo(()=>({"aria-invalid":x,"aria-describedby":p,"aria-labelledby":h}),[x,p,h]),{error:A,errorMessage:k,isInvalid:C,required:f,"aria-describedby":u,"aria-labelledby":n,...v}=o,N=e.useCallback(l=>{const t=l.target;if(t.closest("input, button, a"))return;const s=c.current;if(!s)return;const r=t.closest(`
1
+ "use client";import*as e from"react";import*as te from"react-dom";import B from"classnames";import{composeRefs as G}from"radix-ui/internal";import{textFieldRootPropDefs as re,textFieldSlotPropDefs as oe}from"./text-field.props.js";import{extractProps as U}from"../helpers/extract-props.js";import{marginPropDefs as ne}from"../props/margin.props.js";const _=e.forwardRef((h,y)=>{const o=e.useRef(null),{children:x,className:E,color:w,radius:L,panelBackground:C,material:k,style:I,...s}=U(h,re,ne),D=k||C,v=e.useId(),g=s.error||s.isInvalid,{"aria-describedby":S,"aria-labelledby":M}=s,f=e.useMemo(()=>{const i=[];return s.errorMessage&&i.push(v),S&&i.push(S),i.length>0?i.join(" "):void 0},[s.errorMessage,S,v]),n=e.useMemo(()=>({"aria-invalid":g,"aria-describedby":f,"aria-labelledby":M}),[g,f,M]),{error:N,errorMessage:j,isInvalid:O,required:m,"aria-describedby":p,"aria-labelledby":l,...b}=s,R=e.useCallback(i=>{const X=i.target;if(X.closest("input, button, a"))return;const d=o.current;if(!d)return;const A=X.closest(`
2
2
  .rt-TextFieldSlot[data-side='right'],
3
3
  .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])
4
- `)?s.value.length:0;requestAnimationFrame(()=>{try{s.setSelectionRange(r,r)}catch{}s.focus()})},[]);return e.createElement("div",{"data-accent-color":S,"data-radius":T,"data-panel-background":w,"data-material":w,style:R,className:X("rt-TextFieldRoot",g,{"rt-error":x}),onPointerDown:N},e.createElement("input",{spellCheck:"false",...v,...m,ref:Y(c,I),className:"rt-reset rt-TextFieldInput"}),d,o.errorMessage&&e.createElement("div",{id:b,className:"rt-TextFieldErrorMessage",role:"alert","aria-live":"polite"},o.errorMessage))});B.displayName="TextField.Root";const G=e.forwardRef((D,I)=>{const{scrub:c,scrubValue:d,scrubStep:g=1,scrubSensitivity:S=1,scrubMin:T,scrubMax:M,scrubShiftMultiplier:F=10,scrubAltMultiplier:R=.1,onScrub:o,...w}=D,{className:b,color:x,side:y,...h}=q(w,Z),p=e.useRef(null),[m,A]=e.useState(!1),[k,C]=e.useState({x:0,y:0}),f=e.useRef(0),u=e.useRef(0),n=e.useRef(0),v=e.useRef({scrubValue:d,scrubStep:g,scrubSensitivity:S,scrubMin:T,scrubMax:M,scrubShiftMultiplier:F,scrubAltMultiplier:R,onScrub:o});v.current={scrubValue:d,scrubStep:g,scrubSensitivity:S,scrubMin:T,scrubMax:M,scrubShiftMultiplier:F,scrubAltMultiplier:R,onScrub:o};const N=e.useCallback(t=>{if(!c||t.target.closest("input, button, a"))return;t.preventDefault(),f.current=0,u.current=d??0,n.current=t.clientX,C({x:t.clientX,y:t.clientY});const a=p.current;a&&a.requestPointerLock()},[c,d]);e.useEffect(()=>{const t=()=>{const s=document.pointerLockElement===p.current;A(s),s||(v.current.onScrub?.(0,!1),f.current=0,u.current=0)};return document.addEventListener("pointerlockchange",t),()=>{document.removeEventListener("pointerlockchange",t)}},[]),e.useEffect(()=>{if(!m)return;const t=a=>{const r=v.current,O=a.movementX,_=a.movementY,E=window.innerWidth,L=window.innerHeight;n.current+=O,n.current>E?n.current=n.current%E:n.current<0&&(n.current=E+n.current%E),C(P=>{let i=P.y+_;return i>L?i=i%L:i<0&&(i=L+i%L),{x:n.current,y:i}}),f.current+=O;const H=f.current/r.scrubSensitivity;if(Math.abs(H)>=1){let P=1;a.shiftKey?P=r.scrubShiftMultiplier:a.altKey&&(P=r.scrubAltMultiplier);const i=Math.trunc(H),V=i*r.scrubStep*P;let j=V;if(r.scrubMin!==void 0||r.scrubMax!==void 0){const z=u.current+V,W=Math.max(r.scrubMin??-1/0,Math.min(r.scrubMax??1/0,z));j=W-u.current,u.current=W}else u.current+=V;j!==0&&r.onScrub?.(j,!0),f.current=(H-i)*r.scrubSensitivity}},s=()=>{document.exitPointerLock()};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",s),document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",s),document.body.style.userSelect=""}},[m]);const l=m?K.createPortal(e.createElement("img",{className:"rt-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:k.x,top:k.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":x,"data-side":y,"data-scrub":c||void 0,"data-scrubbing":m||void 0,...h,ref:Y(p,I),className:X("rt-TextFieldSlot",b),onPointerDown:c?N:void 0},h.children,l)});G.displayName="TextField.Slot";export{B as Root,G as Slot};
4
+ `)?d.value.length:0;requestAnimationFrame(()=>{try{d.setSelectionRange(A,A)}catch{}d.focus()})},[]);return e.createElement("div",{"data-accent-color":w,"data-radius":L,"data-panel-background":D,"data-material":D,style:I,className:B("rt-TextFieldRoot",E,{"rt-error":g}),onPointerDown:R},e.createElement("input",{spellCheck:"false",...b,...n,ref:G(o,y),className:"rt-reset rt-TextFieldInput"}),x,s.errorMessage&&e.createElement("div",{id:v,className:"rt-TextFieldErrorMessage",role:"alert","aria-live":"polite"},s.errorMessage))});_.displayName="TextField.Root";const P=(()=>{if(typeof navigator>"u")return!1;const h=navigator.userAgent,y=/^((?!chrome|android).)*safari/i.test(h),o=/firefox/i.test(h);return y||o})(),z=e.forwardRef((h,y)=>{const{scrub:o,scrubValue:x,scrubStep:E=1,scrubSensitivity:w=1,scrubMin:L,scrubMax:C,scrubShiftMultiplier:k=10,scrubAltMultiplier:I=.1,onScrub:s,...D}=h,{className:v,color:g,side:S,...M}=U(D,oe),f=e.useRef(null),[n,N]=e.useState(!1),[j,O]=e.useState({x:0,y:0}),m=e.useRef(0),p=e.useRef(0),l=e.useRef(0),b=e.useRef(null),R=e.useRef(0),i=e.useRef({scrubValue:x,scrubStep:E,scrubSensitivity:w,scrubMin:L,scrubMax:C,scrubShiftMultiplier:k,scrubAltMultiplier:I,onScrub:s});i.current={scrubValue:x,scrubStep:E,scrubSensitivity:w,scrubMin:L,scrubMax:C,scrubShiftMultiplier:k,scrubAltMultiplier:I,onScrub:s};const X=e.useCallback(t=>{if(!o||t.target.closest("input, button, a"))return;t.preventDefault(),m.current=0,p.current=x??0,l.current=t.clientX,O({x:t.clientX,y:t.clientY});const a=f.current;a&&(P?(b.current=t.pointerId,R.current=t.clientX,a.setPointerCapture(t.pointerId),N(!0)):a.requestPointerLock())},[o,x]);e.useEffect(()=>{if(P)return;const t=()=>{const r=document.pointerLockElement===f.current;N(r),r||(i.current.onScrub?.(0,!1),m.current=0,p.current=0)};return document.addEventListener("pointerlockchange",t),()=>{document.removeEventListener("pointerlockchange",t)}},[]);const d=e.useCallback((t,r,a,$)=>{const u=i.current,H=window.innerWidth,V=window.innerHeight;l.current+=t,l.current>H?l.current=l.current%H:l.current<0&&(l.current=H+l.current%H),O(F=>{let c=F.y+r;return c>V?c=c%V:c<0&&(c=V+c%V),{x:l.current,y:c}}),m.current+=t;const W=m.current/u.scrubSensitivity;if(Math.abs(W)>=1){let F=1;a?F=u.scrubShiftMultiplier:$&&(F=u.scrubAltMultiplier);const c=Math.trunc(W),K=c*u.scrubStep*F;let Y=K;if(u.scrubMin!==void 0||u.scrubMax!==void 0){const ee=p.current+K,q=Math.max(u.scrubMin??-1/0,Math.min(u.scrubMax??1/0,ee));Y=q-p.current,p.current=q}else p.current+=K;Y!==0&&u.onScrub?.(Y,!0),m.current=(W-c)*u.scrubSensitivity}},[]),T=e.useCallback(()=>{i.current.onScrub?.(0,!1),m.current=0,p.current=0,b.current=null,N(!1)},[]),A=e.useCallback(t=>{if(!n||!P)return;const r=t.clientX-R.current;R.current=t.clientX,d(r,t.movementY,t.shiftKey,t.altKey)},[n,d]),Z=e.useCallback(t=>{if(!P||b.current!==t.pointerId)return;const r=f.current;r&&b.current!==null&&r.releasePointerCapture(b.current),T()},[T]),J=e.useCallback(()=>{P&&n&&T()},[n,T]);e.useEffect(()=>{if(!n||P)return;const t=a=>{d(a.movementX,a.movementY,a.shiftKey,a.altKey)},r=()=>{document.exitPointerLock()};return document.addEventListener("mousemove",t),document.addEventListener("mouseup",r),document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",t),document.removeEventListener("mouseup",r),document.body.style.userSelect=""}},[n,d]),e.useEffect(()=>{if(!n||!P)return;const t=document.createElement("style");return t.textContent="* { cursor: none !important; user-select: none !important; }",document.head.appendChild(t),()=>{document.head.removeChild(t)}},[n]);const Q=n?te.createPortal(e.createElement("img",{className:"rt-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:j.x,top:j.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":g,"data-side":S,"data-scrub":o||void 0,"data-scrubbing":n||void 0,...M,ref:G(f,y),className:B("rt-TextFieldSlot",v),onPointerDown:o?X:void 0,onPointerMove:o?A:void 0,onPointerUp:o?Z:void 0,onLostPointerCapture:o?J:void 0},M.children,Q)});z.displayName="TextField.Slot";export{_ as Root,z as Slot};
5
5
  //# sourceMappingURL=text-field.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/text-field.tsx"],
4
- "sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport classNames from 'classnames';\nimport { composeRefs } from 'radix-ui/internal';\n\nimport {\n textFieldRootPropDefs,\n textFieldSlotPropDefs,\n type TextFieldSlotScrubProps,\n} from './text-field.props.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { NotInputTextualAttributes } from '../helpers/input-attributes.js';\nimport type { MarginProps } from '../props/margin.props.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?:\n | 'date'\n | 'datetime-local'\n | 'email'\n | 'hidden'\n | 'month'\n | 'number'\n | 'password'\n | 'search'\n | 'tel'\n | 'text'\n | 'time'\n | 'url'\n | 'week';\n};\ntype TextFieldInputProps = ComponentPropsWithout<\n 'input',\n NotInputTextualAttributes | 'color' | 'defaultValue' | 'size' | 'type' | 'value'\n>;\ninterface TextFieldRootProps extends TextFieldInputProps, MarginProps, TextFieldRootOwnProps {}\nconst TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>(\n (props, forwardedRef) => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const { children, className, color, radius, panelBackground, material, style, ...inputProps } =\n extractProps(props, textFieldRootPropDefs, marginPropDefs);\n const effectiveMaterial = material || panelBackground;\n\n // Generate unique IDs for accessibility\n const errorId = React.useId();\n\n // Determine invalid state\n const isInvalid = inputProps.error || inputProps.isInvalid;\n\n const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby } = inputProps;\n\n // Build aria-describedby string\n const describedBy = React.useMemo(() => {\n const parts = [];\n if (inputProps.errorMessage) parts.push(errorId);\n if (ariaDescribedby) parts.push(ariaDescribedby);\n return parts.length > 0 ? parts.join(' ') : undefined;\n }, [inputProps.errorMessage, ariaDescribedby, errorId]);\n\n // Build aria attributes\n const ariaProps = React.useMemo(\n () => ({\n 'aria-invalid': isInvalid,\n 'aria-describedby': describedBy,\n 'aria-labelledby': ariaLabelledby,\n }),\n [isInvalid, describedBy, ariaLabelledby],\n );\n\n // Filter out our custom props to avoid DOM warnings\n const {\n error,\n errorMessage,\n isInvalid: _isInvalid,\n required,\n 'aria-describedby': _ariaDescribedby,\n 'aria-labelledby': _ariaLabelledby,\n ...nativeInputProps\n } = inputProps;\n\n // Memoized pointer event handler\n const handlePointerDown = React.useCallback((event: React.PointerEvent) => {\n const target = event.target as HTMLElement;\n if (target.closest('input, button, a')) 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 .rt-TextFieldSlot[data-side='right'],\n .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])\n `);\n\n const cursorPosition = isRightSlot ? input.value.length : 0;\n\n requestAnimationFrame(() => {\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 input.focus();\n });\n }, []);\n\n return (\n <div\n data-accent-color={color}\n data-radius={radius}\n data-panel-background={effectiveMaterial}\n data-material={effectiveMaterial}\n style={style}\n className={classNames('rt-TextFieldRoot', className, {\n 'rt-error': isInvalid,\n })}\n onPointerDown={handlePointerDown}\n >\n <input\n spellCheck=\"false\"\n {...nativeInputProps}\n {...ariaProps}\n ref={composeRefs(inputRef, forwardedRef)}\n className=\"rt-reset rt-TextFieldInput\"\n />\n {children}\n {inputProps.errorMessage && (\n <div id={errorId} className=\"rt-TextFieldErrorMessage\" role=\"alert\" aria-live=\"polite\">\n {inputProps.errorMessage}\n </div>\n )}\n </div>\n );\n },\n);\nTextFieldRoot.displayName = 'TextField.Root';\n\ntype TextFieldSlotElement = React.ElementRef<'div'>;\ntype TextFieldSlotOwnProps = GetPropDefTypes<typeof textFieldSlotPropDefs> & TextFieldSlotScrubProps;\ninterface TextFieldSlotProps\n extends ComponentPropsWithout<'div', RemovedProps>,\n TextFieldSlotOwnProps {}\nconst TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>(\n (props, forwardedRef) => {\n // Extract scrub props first (not part of PropDef system)\n const {\n scrub,\n scrubValue,\n scrubStep = 1,\n scrubSensitivity = 1,\n scrubMin,\n scrubMax,\n scrubShiftMultiplier = 10,\n scrubAltMultiplier = 0.1,\n onScrub,\n ...restProps\n } = props;\n\n // Then extract styling props\n const { className, color, side, ...slotProps } = extractProps(restProps, textFieldSlotPropDefs);\n\n const slotRef = React.useRef<HTMLDivElement>(null);\n const [isScrubbing, setIsScrubbing] = React.useState(false);\n // Virtual cursor position - X wraps around viewport, Y follows mouse\n const [cursorPosition, setCursorPosition] = React.useState({ x: 0, y: 0 });\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\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('input, button, a')) 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 setCursorPosition({ x: event.clientX, y: event.clientY });\n\n // Request pointer lock for infinite movement (cursor won't hit screen edges)\n const slot = slotRef.current;\n if (slot) {\n slot.requestPointerLock();\n }\n },\n [scrub, scrubValue],\n );\n\n // Handle pointer lock state changes\n React.useEffect(() => {\n const handlePointerLockChange = () => {\n const isLocked = document.pointerLockElement === slotRef.current;\n setIsScrubbing(isLocked);\n if (!isLocked) {\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 }, []);\n\n // Attach document-level listeners when scrubbing starts\n React.useEffect(() => {\n if (!isScrubbing) return;\n\n const handleMouseMove = (event: MouseEvent) => {\n const config = scrubConfigRef.current;\n const movementX = event.movementX;\n const movementY = event.movementY;\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 setCursorPosition((prev) => {\n let newY = prev.y + movementY;\n if (newY > viewportHeight) {\n newY = newY % viewportHeight;\n } else if (newY < 0) {\n newY = viewportHeight + (newY % viewportHeight);\n }\n return { x: virtualX.current, y: newY };\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 (event.shiftKey) {\n multiplier = config.scrubShiftMultiplier;\n } else if (event.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(\n config.scrubMin ?? -Infinity,\n Math.min(config.scrubMax ?? Infinity, newValue),\n );\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 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]);\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 className=\"rt-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: cursorPosition.x,\n top: cursorPosition.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 ref={composeRefs(slotRef, forwardedRef)}\n className={classNames('rt-TextFieldSlot', className)}\n onPointerDown={scrub ? handlePointerDown : undefined}\n >\n {slotProps.children}\n {virtualCursor}\n </div>\n );\n },\n);\nTextFieldSlot.displayName = 'TextField.Slot';\n\nexport { TextFieldRoot as Root, TextFieldSlot as Slot };\nexport type { TextFieldRootProps as RootProps, TextFieldSlotProps as SlotProps };\n"],
5
- "mappings": "aAEA,UAAYA,MAAW,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AG,CAACzB,CAAW,CAAC,EAIhB,MAAM0B,EAAgB1B,EAClBrD,EAAS,aACPD,EAAA,cAAC,OACC,UAAU,8BACV,IAAI,oPACJ,IAAI,GACJ,MAAO,CACL,SAAU,QACV,KAAMuC,EAAe,EACrB,IAAKA,EAAe,EACpB,UAAW,wBACX,cAAe,OACf,OAAQ,MACR,MAAO,GACP,OAAQ,EACV,EACA,cAAY,OACd,EACA,SAAS,IACX,EACA,KAEJ,OACEvC,EAAA,cAAC,OACC,oBAAmBc,EACnB,YAAWqC,EACX,aAAYV,GAAS,OACrB,iBAAgBa,GAAe,OAC9B,GAAGF,EACJ,IAAKjD,EAAYkD,EAAS3C,CAAY,EACtC,UAAWR,EAAW,mBAAoBW,CAAS,EACnD,cAAe4B,EAAQN,EAAoB,QAE1CiB,EAAU,SACV4B,CACH,CAEJ,CACF,EACAxC,EAAc,YAAc",
6
- "names": ["React", "ReactDOM", "classNames", "composeRefs", "textFieldRootPropDefs", "textFieldSlotPropDefs", "extractProps", "marginPropDefs", "TextFieldRoot", "props", "forwardedRef", "inputRef", "children", "className", "color", "radius", "panelBackground", "material", "style", "inputProps", "effectiveMaterial", "errorId", "isInvalid", "ariaDescribedby", "ariaLabelledby", "describedBy", "parts", "ariaProps", "error", "errorMessage", "_isInvalid", "required", "_ariaDescribedby", "_ariaLabelledby", "nativeInputProps", "handlePointerDown", "event", "target", "input", "cursorPosition", "TextFieldSlot", "scrub", "scrubValue", "scrubStep", "scrubSensitivity", "scrubMin", "scrubMax", "scrubShiftMultiplier", "scrubAltMultiplier", "onScrub", "restProps", "side", "slotProps", "slotRef", "isScrubbing", "setIsScrubbing", "setCursorPosition", "accumulatedMovement", "currentValue", "virtualX", "scrubConfigRef", "slot", "handlePointerLockChange", "isLocked", "handleMouseMove", "config", "movementX", "movementY", "viewportWidth", "viewportHeight", "prev", "newY", "stepsFromMovement", "multiplier", "wholeSteps", "delta", "clampedDelta", "newValue", "clampedValue", "handleMouseUp", "virtualCursor"]
4
+ "sourcesContent": ["'use client';\n\nimport * as React from 'react';\nimport * as ReactDOM from 'react-dom';\nimport classNames from 'classnames';\nimport { composeRefs } from 'radix-ui/internal';\n\nimport { textFieldRootPropDefs, textFieldSlotPropDefs, type TextFieldSlotScrubProps } from './text-field.props.js';\nimport { extractProps } from '../helpers/extract-props.js';\nimport { marginPropDefs } from '../props/margin.props.js';\n\nimport type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js';\nimport type { NotInputTextualAttributes } from '../helpers/input-attributes.js';\nimport type { MarginProps } from '../props/margin.props.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, MarginProps, TextFieldRootOwnProps {}\nconst TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>((props, forwardedRef) => {\n const inputRef = React.useRef<HTMLInputElement>(null);\n const { children, className, color, radius, panelBackground, material, style, ...inputProps } = extractProps(props, textFieldRootPropDefs, marginPropDefs);\n const effectiveMaterial = material || panelBackground;\n\n // Generate unique IDs for accessibility\n const errorId = React.useId();\n\n // Determine invalid state\n const isInvalid = inputProps.error || inputProps.isInvalid;\n\n const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby } = inputProps;\n\n // Build aria-describedby string\n const describedBy = React.useMemo(() => {\n const parts = [];\n if (inputProps.errorMessage) parts.push(errorId);\n if (ariaDescribedby) parts.push(ariaDescribedby);\n return parts.length > 0 ? parts.join(' ') : undefined;\n }, [inputProps.errorMessage, ariaDescribedby, errorId]);\n\n // Build aria attributes\n const ariaProps = React.useMemo(\n () => ({\n 'aria-invalid': isInvalid,\n 'aria-describedby': describedBy,\n 'aria-labelledby': ariaLabelledby,\n }),\n [isInvalid, describedBy, ariaLabelledby],\n );\n\n // Filter out our custom props to avoid DOM warnings\n const { error, errorMessage, isInvalid: _isInvalid, required, 'aria-describedby': _ariaDescribedby, 'aria-labelledby': _ariaLabelledby, ...nativeInputProps } = inputProps;\n\n // Memoized pointer event handler\n const handlePointerDown = React.useCallback((event: React.PointerEvent) => {\n const target = event.target as HTMLElement;\n if (target.closest('input, button, a')) 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 .rt-TextFieldSlot[data-side='right'],\n .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])\n `);\n\n const cursorPosition = isRightSlot ? input.value.length : 0;\n\n requestAnimationFrame(() => {\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 input.focus();\n });\n }, []);\n\n return (\n <div\n data-accent-color={color}\n data-radius={radius}\n data-panel-background={effectiveMaterial}\n data-material={effectiveMaterial}\n style={style}\n className={classNames('rt-TextFieldRoot', className, {\n 'rt-error': isInvalid,\n })}\n onPointerDown={handlePointerDown}\n >\n <input spellCheck=\"false\" {...nativeInputProps} {...ariaProps} ref={composeRefs(inputRef, forwardedRef)} className=\"rt-reset rt-TextFieldInput\" />\n {children}\n {inputProps.errorMessage && (\n <div id={errorId} className=\"rt-TextFieldErrorMessage\" role=\"alert\" aria-live=\"polite\">\n {inputProps.errorMessage}\n </div>\n )}\n </div>\n );\n});\nTextFieldRoot.displayName = 'TextField.Root';\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, ...slotProps } = extractProps(restProps, textFieldSlotPropDefs);\n\n const slotRef = React.useRef<HTMLDivElement>(null);\n const [isScrubbing, setIsScrubbing] = React.useState(false);\n // Virtual cursor position - X wraps around viewport, Y follows mouse\n const [cursorPosition, setCursorPosition] = React.useState({ x: 0, y: 0 });\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('input, button, a')) 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 setCursorPosition({ 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 slot.requestPointerLock();\n }\n },\n [scrub, scrubValue],\n );\n\n // Handle pointer lock state changes (Chrome only)\n React.useEffect(() => {\n if (usePointerCapture) return;\n\n const handlePointerLockChange = () => {\n const isLocked = document.pointerLockElement === slotRef.current;\n setIsScrubbing(isLocked);\n if (!isLocked) {\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 }, []);\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 setCursorPosition((prev) => {\n let newY = prev.y + movementY;\n if (newY > viewportHeight) {\n newY = newY % viewportHeight;\n } else if (newY < 0) {\n newY = viewportHeight + (newY % viewportHeight);\n }\n return { x: virtualX.current, y: newY };\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 className=\"rt-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: cursorPosition.x,\n top: cursorPosition.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 ref={composeRefs(slotRef, forwardedRef)}\n className={classNames('rt-TextFieldSlot', className)}\n onPointerDown={scrub ? handlePointerDown : undefined}\n onPointerMove={scrub ? handlePointerMove : undefined}\n onPointerUp={scrub ? handlePointerUp : undefined}\n onLostPointerCapture={scrub ? handleLostPointerCapture : undefined}\n >\n {slotProps.children}\n {virtualCursor}\n </div>\n );\n});\nTextFieldSlot.displayName = 'TextField.Slot';\n\nexport { TextFieldRoot as Root, TextFieldSlot as Slot };\nexport type { TextFieldRootProps as RootProps, TextFieldSlotProps as SlotProps };\n"],
5
+ "mappings": "aAEA,UAAYA,MAAW,QACvB,UAAYC,OAAc,YAC1B,OAAOC,MAAgB,aACvB,OAAS,eAAAC,MAAmB,oBAE5B,OAAS,yBAAAC,GAAuB,yBAAAC,OAA2D,wBAC3F,OAAS,gBAAAC,MAAoB,8BAC7B,OAAS,kBAAAC,OAAsB,2BAe/B,MAAMC,EAAgBR,EAAM,WAAqD,CAACS,EAAOC,IAAiB,CACxG,MAAMC,EAAWX,EAAM,OAAyB,IAAI,EAC9C,CAAE,SAAAY,EAAU,UAAAC,EAAW,MAAAC,EAAO,OAAAC,EAAQ,gBAAAC,EAAiB,SAAAC,EAAU,MAAAC,EAAO,GAAGC,CAAW,EAAIb,EAAaG,EAAOL,GAAuBG,EAAc,EACnJa,EAAoBH,GAAYD,EAGhCK,EAAUrB,EAAM,MAAM,EAGtBsB,EAAYH,EAAW,OAASA,EAAW,UAE3C,CAAE,mBAAoBI,EAAiB,kBAAmBC,CAAe,EAAIL,EAG7EM,EAAczB,EAAM,QAAQ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Q,EACV,EACA,cAAY,OACd,EACA,SAAS,IACX,EACA,KAEJ,OACEvC,EAAA,cAAC,OACC,oBAAmBc,EACnB,YAAWyC,EACX,aAAYV,GAAS,OACrB,iBAAgBa,GAAe,OAC9B,GAAGF,EACJ,IAAKrD,EAAYsD,EAAS/C,CAAY,EACtC,UAAWR,EAAW,mBAAoBW,CAAS,EACnD,cAAegC,EAAQV,EAAoB,OAC3C,cAAeU,EAAQ2C,EAAoB,OAC3C,YAAa3C,EAAQ4C,EAAkB,OACvC,qBAAsB5C,EAAQ6C,EAA2B,QAExDlC,EAAU,SACVqC,CACH,CAEJ,CAAC,EACDjD,EAAc,YAAc",
6
+ "names": ["React", "ReactDOM", "classNames", "composeRefs", "textFieldRootPropDefs", "textFieldSlotPropDefs", "extractProps", "marginPropDefs", "TextFieldRoot", "props", "forwardedRef", "inputRef", "children", "className", "color", "radius", "panelBackground", "material", "style", "inputProps", "effectiveMaterial", "errorId", "isInvalid", "ariaDescribedby", "ariaLabelledby", "describedBy", "parts", "ariaProps", "error", "errorMessage", "_isInvalid", "required", "_ariaDescribedby", "_ariaLabelledby", "nativeInputProps", "handlePointerDown", "event", "target", "input", "cursorPosition", "usePointerCapture", "ua", "isSafari", "isFirefox", "TextFieldSlot", "scrub", "scrubValue", "scrubStep", "scrubSensitivity", "scrubMin", "scrubMax", "scrubShiftMultiplier", "scrubAltMultiplier", "onScrub", "restProps", "side", "slotProps", "slotRef", "isScrubbing", "setIsScrubbing", "setCursorPosition", "accumulatedMovement", "currentValue", "virtualX", "pointerIdRef", "lastXRef", "scrubConfigRef", "slot", "handlePointerLockChange", "isLocked", "processScrubMovement", "movementX", "movementY", "shiftKey", "altKey", "config", "viewportWidth", "viewportHeight", "prev", "newY", "stepsFromMovement", "multiplier", "wholeSteps", "delta", "clampedDelta", "newValue", "clampedValue", "endScrubbing", "handlePointerMove", "handlePointerUp", "handleLostPointerCapture", "handleMouseMove", "handleMouseUp", "virtualCursor"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kushagradhawan/kookie-ui",
3
- "version": "0.1.104",
3
+ "version": "0.1.105",
4
4
  "description": "A modern React component library with beautiful design tokens, flexible theming, and comprehensive documentation",
5
5
  "keywords": [
6
6
  "react",
@@ -279,6 +279,6 @@
279
279
  "title": "Base-button Component Props",
280
280
  "description": "Props schema for the base-button component in Kookie UI",
281
281
  "version": "1.0.0",
282
- "generatedAt": "2026-01-05T18:44:44.223Z",
282
+ "generatedAt": "2026-01-05T19:36:34.470Z",
283
283
  "source": "Zod schema"
284
284
  }
@@ -530,6 +530,6 @@
530
530
  "title": "Button Component Props",
531
531
  "description": "Props schema for the button component in Kookie UI",
532
532
  "version": "1.0.0",
533
- "generatedAt": "2026-01-05T18:44:44.229Z",
533
+ "generatedAt": "2026-01-05T19:36:34.477Z",
534
534
  "source": "Zod schema"
535
535
  }
@@ -313,6 +313,6 @@
313
313
  "title": "Icon-button Component Props",
314
314
  "description": "Props schema for the icon-button component in Kookie UI",
315
315
  "version": "1.0.0",
316
- "generatedAt": "2026-01-05T18:44:44.230Z",
316
+ "generatedAt": "2026-01-05T19:36:34.477Z",
317
317
  "source": "Zod schema"
318
318
  }
@@ -3,7 +3,7 @@
3
3
  "title": "Kookie UI Button Components",
4
4
  "description": "Complete JSON Schema collection for all button components in Kookie UI",
5
5
  "version": "1.0.0",
6
- "generatedAt": "2026-01-05T18:44:44.233Z",
6
+ "generatedAt": "2026-01-05T19:36:34.480Z",
7
7
  "source": "Zod schemas",
8
8
  "components": {
9
9
  "base-button": {
@@ -287,7 +287,7 @@
287
287
  "title": "Base-button Component Props",
288
288
  "description": "Props schema for the base-button component in Kookie UI",
289
289
  "version": "1.0.0",
290
- "generatedAt": "2026-01-05T18:44:44.223Z",
290
+ "generatedAt": "2026-01-05T19:36:34.470Z",
291
291
  "source": "Zod schema"
292
292
  },
293
293
  "button": {
@@ -822,7 +822,7 @@
822
822
  "title": "Button Component Props",
823
823
  "description": "Props schema for the button component in Kookie UI",
824
824
  "version": "1.0.0",
825
- "generatedAt": "2026-01-05T18:44:44.229Z",
825
+ "generatedAt": "2026-01-05T19:36:34.477Z",
826
826
  "source": "Zod schema"
827
827
  },
828
828
  "icon-button": {
@@ -1140,7 +1140,7 @@
1140
1140
  "title": "Icon-button Component Props",
1141
1141
  "description": "Props schema for the icon-button component in Kookie UI",
1142
1142
  "version": "1.0.0",
1143
- "generatedAt": "2026-01-05T18:44:44.230Z",
1143
+ "generatedAt": "2026-01-05T19:36:34.477Z",
1144
1144
  "source": "Zod schema"
1145
1145
  },
1146
1146
  "toggle-button": {
@@ -1683,7 +1683,7 @@
1683
1683
  "title": "Toggle-button Component Props",
1684
1684
  "description": "Props schema for the toggle-button component in Kookie UI",
1685
1685
  "version": "1.0.0",
1686
- "generatedAt": "2026-01-05T18:44:44.232Z",
1686
+ "generatedAt": "2026-01-05T19:36:34.479Z",
1687
1687
  "source": "Zod schema"
1688
1688
  },
1689
1689
  "toggle-icon-button": {
@@ -2009,7 +2009,7 @@
2009
2009
  "title": "Toggle-icon-button Component Props",
2010
2010
  "description": "Props schema for the toggle-icon-button component in Kookie UI",
2011
2011
  "version": "1.0.0",
2012
- "generatedAt": "2026-01-05T18:44:44.233Z",
2012
+ "generatedAt": "2026-01-05T19:36:34.480Z",
2013
2013
  "source": "Zod schema"
2014
2014
  }
2015
2015
  }
@@ -538,6 +538,6 @@
538
538
  "title": "Toggle-button Component Props",
539
539
  "description": "Props schema for the toggle-button component in Kookie UI",
540
540
  "version": "1.0.0",
541
- "generatedAt": "2026-01-05T18:44:44.232Z",
541
+ "generatedAt": "2026-01-05T19:36:34.479Z",
542
542
  "source": "Zod schema"
543
543
  }
@@ -321,6 +321,6 @@
321
321
  "title": "Toggle-icon-button Component Props",
322
322
  "description": "Props schema for the toggle-icon-button component in Kookie UI",
323
323
  "version": "1.0.0",
324
- "generatedAt": "2026-01-05T18:44:44.233Z",
324
+ "generatedAt": "2026-01-05T19:36:34.480Z",
325
325
  "source": "Zod schema"
326
326
  }
@@ -5,11 +5,7 @@ import * as ReactDOM from 'react-dom';
5
5
  import classNames from 'classnames';
6
6
  import { composeRefs } from 'radix-ui/internal';
7
7
 
8
- import {
9
- textFieldRootPropDefs,
10
- textFieldSlotPropDefs,
11
- type TextFieldSlotScrubProps,
12
- } from './text-field.props.js';
8
+ import { textFieldRootPropDefs, textFieldSlotPropDefs, type TextFieldSlotScrubProps } from './text-field.props.js';
13
9
  import { extractProps } from '../helpers/extract-props.js';
14
10
  import { marginPropDefs } from '../props/margin.props.js';
15
11
 
@@ -22,363 +18,398 @@ type TextFieldRootElement = React.ElementRef<'input'>;
22
18
  type TextFieldRootOwnProps = GetPropDefTypes<typeof textFieldRootPropDefs> & {
23
19
  defaultValue?: string | number;
24
20
  value?: string | number;
25
- type?:
26
- | 'date'
27
- | 'datetime-local'
28
- | 'email'
29
- | 'hidden'
30
- | 'month'
31
- | 'number'
32
- | 'password'
33
- | 'search'
34
- | 'tel'
35
- | 'text'
36
- | 'time'
37
- | 'url'
38
- | 'week';
21
+ type?: 'date' | 'datetime-local' | 'email' | 'hidden' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
39
22
  };
40
- type TextFieldInputProps = ComponentPropsWithout<
41
- 'input',
42
- NotInputTextualAttributes | 'color' | 'defaultValue' | 'size' | 'type' | 'value'
43
- >;
23
+ type TextFieldInputProps = ComponentPropsWithout<'input', NotInputTextualAttributes | 'color' | 'defaultValue' | 'size' | 'type' | 'value'>;
44
24
  interface TextFieldRootProps extends TextFieldInputProps, MarginProps, TextFieldRootOwnProps {}
45
- const TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>(
46
- (props, forwardedRef) => {
47
- const inputRef = React.useRef<HTMLInputElement>(null);
48
- const { children, className, color, radius, panelBackground, material, style, ...inputProps } =
49
- extractProps(props, textFieldRootPropDefs, marginPropDefs);
50
- const effectiveMaterial = material || panelBackground;
51
-
52
- // Generate unique IDs for accessibility
53
- const errorId = React.useId();
54
-
55
- // Determine invalid state
56
- const isInvalid = inputProps.error || inputProps.isInvalid;
57
-
58
- const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby } = inputProps;
59
-
60
- // Build aria-describedby string
61
- const describedBy = React.useMemo(() => {
62
- const parts = [];
63
- if (inputProps.errorMessage) parts.push(errorId);
64
- if (ariaDescribedby) parts.push(ariaDescribedby);
65
- return parts.length > 0 ? parts.join(' ') : undefined;
66
- }, [inputProps.errorMessage, ariaDescribedby, errorId]);
67
-
68
- // Build aria attributes
69
- const ariaProps = React.useMemo(
70
- () => ({
71
- 'aria-invalid': isInvalid,
72
- 'aria-describedby': describedBy,
73
- 'aria-labelledby': ariaLabelledby,
74
- }),
75
- [isInvalid, describedBy, ariaLabelledby],
76
- );
77
-
78
- // Filter out our custom props to avoid DOM warnings
79
- const {
80
- error,
81
- errorMessage,
82
- isInvalid: _isInvalid,
83
- required,
84
- 'aria-describedby': _ariaDescribedby,
85
- 'aria-labelledby': _ariaLabelledby,
86
- ...nativeInputProps
87
- } = inputProps;
88
-
89
- // Memoized pointer event handler
90
- const handlePointerDown = React.useCallback((event: React.PointerEvent) => {
91
- const target = event.target as HTMLElement;
92
- if (target.closest('input, button, a')) return;
93
-
94
- const input = inputRef.current;
95
- if (!input) return;
96
-
97
- // Same selector as in the CSS to find the right slot
98
- const isRightSlot = target.closest(`
25
+ const TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>((props, forwardedRef) => {
26
+ const inputRef = React.useRef<HTMLInputElement>(null);
27
+ const { children, className, color, radius, panelBackground, material, style, ...inputProps } = extractProps(props, textFieldRootPropDefs, marginPropDefs);
28
+ const effectiveMaterial = material || panelBackground;
29
+
30
+ // Generate unique IDs for accessibility
31
+ const errorId = React.useId();
32
+
33
+ // Determine invalid state
34
+ const isInvalid = inputProps.error || inputProps.isInvalid;
35
+
36
+ const { 'aria-describedby': ariaDescribedby, 'aria-labelledby': ariaLabelledby } = inputProps;
37
+
38
+ // Build aria-describedby string
39
+ const describedBy = React.useMemo(() => {
40
+ const parts = [];
41
+ if (inputProps.errorMessage) parts.push(errorId);
42
+ if (ariaDescribedby) parts.push(ariaDescribedby);
43
+ return parts.length > 0 ? parts.join(' ') : undefined;
44
+ }, [inputProps.errorMessage, ariaDescribedby, errorId]);
45
+
46
+ // Build aria attributes
47
+ const ariaProps = React.useMemo(
48
+ () => ({
49
+ 'aria-invalid': isInvalid,
50
+ 'aria-describedby': describedBy,
51
+ 'aria-labelledby': ariaLabelledby,
52
+ }),
53
+ [isInvalid, describedBy, ariaLabelledby],
54
+ );
55
+
56
+ // Filter out our custom props to avoid DOM warnings
57
+ const { error, errorMessage, isInvalid: _isInvalid, required, 'aria-describedby': _ariaDescribedby, 'aria-labelledby': _ariaLabelledby, ...nativeInputProps } = inputProps;
58
+
59
+ // Memoized pointer event handler
60
+ const handlePointerDown = React.useCallback((event: React.PointerEvent) => {
61
+ const target = event.target as HTMLElement;
62
+ if (target.closest('input, button, a')) return;
63
+
64
+ const input = inputRef.current;
65
+ if (!input) return;
66
+
67
+ // Same selector as in the CSS to find the right slot
68
+ const isRightSlot = target.closest(`
99
69
  .rt-TextFieldSlot[data-side='right'],
100
70
  .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])
101
71
  `);
102
72
 
103
- const cursorPosition = isRightSlot ? input.value.length : 0;
104
-
105
- requestAnimationFrame(() => {
106
- // Only some input types support this, browsers will throw an error if not supported
107
- // See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange#:~:text=Note%20that%20according,not%20support%20selection%22.
108
- try {
109
- input.setSelectionRange(cursorPosition, cursorPosition);
110
- } catch {}
111
- input.focus();
112
- });
113
- }, []);
114
-
115
- return (
116
- <div
117
- data-accent-color={color}
118
- data-radius={radius}
119
- data-panel-background={effectiveMaterial}
120
- data-material={effectiveMaterial}
121
- style={style}
122
- className={classNames('rt-TextFieldRoot', className, {
123
- 'rt-error': isInvalid,
124
- })}
125
- onPointerDown={handlePointerDown}
126
- >
127
- <input
128
- spellCheck="false"
129
- {...nativeInputProps}
130
- {...ariaProps}
131
- ref={composeRefs(inputRef, forwardedRef)}
132
- className="rt-reset rt-TextFieldInput"
133
- />
134
- {children}
135
- {inputProps.errorMessage && (
136
- <div id={errorId} className="rt-TextFieldErrorMessage" role="alert" aria-live="polite">
137
- {inputProps.errorMessage}
138
- </div>
139
- )}
140
- </div>
141
- );
142
- },
143
- );
73
+ const cursorPosition = isRightSlot ? input.value.length : 0;
74
+
75
+ requestAnimationFrame(() => {
76
+ // Only some input types support this, browsers will throw an error if not supported
77
+ // See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange#:~:text=Note%20that%20according,not%20support%20selection%22.
78
+ try {
79
+ input.setSelectionRange(cursorPosition, cursorPosition);
80
+ } catch {}
81
+ input.focus();
82
+ });
83
+ }, []);
84
+
85
+ return (
86
+ <div
87
+ data-accent-color={color}
88
+ data-radius={radius}
89
+ data-panel-background={effectiveMaterial}
90
+ data-material={effectiveMaterial}
91
+ style={style}
92
+ className={classNames('rt-TextFieldRoot', className, {
93
+ 'rt-error': isInvalid,
94
+ })}
95
+ onPointerDown={handlePointerDown}
96
+ >
97
+ <input spellCheck="false" {...nativeInputProps} {...ariaProps} ref={composeRefs(inputRef, forwardedRef)} className="rt-reset rt-TextFieldInput" />
98
+ {children}
99
+ {inputProps.errorMessage && (
100
+ <div id={errorId} className="rt-TextFieldErrorMessage" role="alert" aria-live="polite">
101
+ {inputProps.errorMessage}
102
+ </div>
103
+ )}
104
+ </div>
105
+ );
106
+ });
144
107
  TextFieldRoot.displayName = 'TextField.Root';
145
108
 
146
109
  type TextFieldSlotElement = React.ElementRef<'div'>;
147
110
  type TextFieldSlotOwnProps = GetPropDefTypes<typeof textFieldSlotPropDefs> & TextFieldSlotScrubProps;
148
- interface TextFieldSlotProps
149
- extends ComponentPropsWithout<'div', RemovedProps>,
150
- TextFieldSlotOwnProps {}
151
- const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>(
152
- (props, forwardedRef) => {
153
- // Extract scrub props first (not part of PropDef system)
154
- const {
155
- scrub,
156
- scrubValue,
157
- scrubStep = 1,
158
- scrubSensitivity = 1,
159
- scrubMin,
160
- scrubMax,
161
- scrubShiftMultiplier = 10,
162
- scrubAltMultiplier = 0.1,
163
- onScrub,
164
- ...restProps
165
- } = props;
166
-
167
- // Then extract styling props
168
- const { className, color, side, ...slotProps } = extractProps(restProps, textFieldSlotPropDefs);
169
-
170
- const slotRef = React.useRef<HTMLDivElement>(null);
171
- const [isScrubbing, setIsScrubbing] = React.useState(false);
172
- // Virtual cursor position - X wraps around viewport, Y follows mouse
173
- const [cursorPosition, setCursorPosition] = React.useState({ x: 0, y: 0 });
174
-
175
- // Track accumulated sub-step movement for precision
176
- const accumulatedMovement = React.useRef(0);
177
- // Track current value for clamping (initialized to scrubValue when scrubbing starts)
178
- const currentValue = React.useRef(0);
179
- // Track virtual X position for wrap-around (separate from rendered position)
180
- const virtualX = React.useRef(0);
181
-
182
- // Store scrub config in refs so document handlers can access latest values
183
- const scrubConfigRef = React.useRef({
184
- scrubValue,
185
- scrubStep,
186
- scrubSensitivity,
187
- scrubMin,
188
- scrubMax,
189
- scrubShiftMultiplier,
190
- scrubAltMultiplier,
191
- onScrub,
111
+ interface TextFieldSlotProps extends ComponentPropsWithout<'div', RemovedProps>, TextFieldSlotOwnProps {}
112
+
113
+ // Detect if we should use pointer capture instead of pointer lock
114
+ // Safari and Firefox show intrusive browser warnings with pointer lock
115
+ const usePointerCapture = (() => {
116
+ if (typeof navigator === 'undefined') return false;
117
+ const ua = navigator.userAgent;
118
+ const isSafari = /^((?!chrome|android).)*safari/i.test(ua);
119
+ const isFirefox = /firefox/i.test(ua);
120
+ return isSafari || isFirefox;
121
+ })();
122
+
123
+ const TextFieldSlot = React.forwardRef<TextFieldSlotElement, TextFieldSlotProps>((props, forwardedRef) => {
124
+ // Extract scrub props first (not part of PropDef system)
125
+ const { scrub, scrubValue, scrubStep = 1, scrubSensitivity = 1, scrubMin, scrubMax, scrubShiftMultiplier = 10, scrubAltMultiplier = 0.1, onScrub, ...restProps } = props;
126
+
127
+ // Then extract styling props
128
+ const { className, color, side, ...slotProps } = extractProps(restProps, textFieldSlotPropDefs);
129
+
130
+ const slotRef = React.useRef<HTMLDivElement>(null);
131
+ const [isScrubbing, setIsScrubbing] = React.useState(false);
132
+ // Virtual cursor position - X wraps around viewport, Y follows mouse
133
+ const [cursorPosition, setCursorPosition] = React.useState({ x: 0, y: 0 });
134
+
135
+ // Track accumulated sub-step movement for precision
136
+ const accumulatedMovement = React.useRef(0);
137
+ // Track current value for clamping (initialized to scrubValue when scrubbing starts)
138
+ const currentValue = React.useRef(0);
139
+ // Track virtual X position for wrap-around (separate from rendered position)
140
+ const virtualX = React.useRef(0);
141
+ // Track pointer ID for capture mode
142
+ const pointerIdRef = React.useRef<number | null>(null);
143
+ // Track last X position for capture mode (movementX calculation)
144
+ const lastXRef = React.useRef(0);
145
+
146
+ // Store scrub config in refs so document handlers can access latest values
147
+ const scrubConfigRef = React.useRef({
148
+ scrubValue,
149
+ scrubStep,
150
+ scrubSensitivity,
151
+ scrubMin,
152
+ scrubMax,
153
+ scrubShiftMultiplier,
154
+ scrubAltMultiplier,
155
+ onScrub,
156
+ });
157
+ scrubConfigRef.current = {
158
+ scrubValue,
159
+ scrubStep,
160
+ scrubSensitivity,
161
+ scrubMin,
162
+ scrubMax,
163
+ scrubShiftMultiplier,
164
+ scrubAltMultiplier,
165
+ onScrub,
166
+ };
167
+
168
+ const handlePointerDown = React.useCallback(
169
+ (event: React.PointerEvent) => {
170
+ if (!scrub) return;
171
+
172
+ // Don't start scrubbing if clicking on interactive elements
173
+ const target = event.target as HTMLElement;
174
+ if (target.closest('input, button, a')) return;
175
+
176
+ event.preventDefault();
177
+ accumulatedMovement.current = 0;
178
+ // Initialize to current value so min/max clamping works correctly
179
+ currentValue.current = scrubValue ?? 0;
180
+
181
+ // Initialize virtual cursor at actual mouse position
182
+ virtualX.current = event.clientX;
183
+ setCursorPosition({ x: event.clientX, y: event.clientY });
184
+
185
+ const slot = slotRef.current;
186
+ if (!slot) return;
187
+
188
+ if (usePointerCapture) {
189
+ // Safari/Firefox: Use pointer capture (no browser warning)
190
+ pointerIdRef.current = event.pointerId;
191
+ lastXRef.current = event.clientX;
192
+ slot.setPointerCapture(event.pointerId);
193
+ setIsScrubbing(true);
194
+ } else {
195
+ // Chrome: Use pointer lock for infinite movement
196
+ slot.requestPointerLock();
197
+ }
198
+ },
199
+ [scrub, scrubValue],
200
+ );
201
+
202
+ // Handle pointer lock state changes (Chrome only)
203
+ React.useEffect(() => {
204
+ if (usePointerCapture) return;
205
+
206
+ const handlePointerLockChange = () => {
207
+ const isLocked = document.pointerLockElement === slotRef.current;
208
+ setIsScrubbing(isLocked);
209
+ if (!isLocked) {
210
+ // Fire callback with isChanging = false when scrubbing ends
211
+ scrubConfigRef.current.onScrub?.(0, false);
212
+ accumulatedMovement.current = 0;
213
+ currentValue.current = 0;
214
+ }
215
+ };
216
+
217
+ document.addEventListener('pointerlockchange', handlePointerLockChange);
218
+ return () => {
219
+ document.removeEventListener('pointerlockchange', handlePointerLockChange);
220
+ };
221
+ }, []);
222
+
223
+ // Shared scrub calculation logic
224
+ const processScrubMovement = React.useCallback((movementX: number, movementY: number, shiftKey: boolean, altKey: boolean) => {
225
+ const config = scrubConfigRef.current;
226
+ const viewportWidth = window.innerWidth;
227
+ const viewportHeight = window.innerHeight;
228
+
229
+ // Update virtual position with wrap-around at viewport edges
230
+ virtualX.current += movementX;
231
+ if (virtualX.current > viewportWidth) {
232
+ virtualX.current = virtualX.current % viewportWidth;
233
+ } else if (virtualX.current < 0) {
234
+ virtualX.current = viewportWidth + (virtualX.current % viewportWidth);
235
+ }
236
+
237
+ // Also track Y with wrap-around
238
+ setCursorPosition((prev) => {
239
+ let newY = prev.y + movementY;
240
+ if (newY > viewportHeight) {
241
+ newY = newY % viewportHeight;
242
+ } else if (newY < 0) {
243
+ newY = viewportHeight + (newY % viewportHeight);
244
+ }
245
+ return { x: virtualX.current, y: newY };
192
246
  });
193
- scrubConfigRef.current = {
194
- scrubValue,
195
- scrubStep,
196
- scrubSensitivity,
197
- scrubMin,
198
- scrubMax,
199
- scrubShiftMultiplier,
200
- scrubAltMultiplier,
201
- onScrub,
247
+
248
+ // Accumulate movement for sensitivity calculation
249
+ accumulatedMovement.current += movementX;
250
+
251
+ // Calculate how many steps we've moved
252
+ const stepsFromMovement = accumulatedMovement.current / config.scrubSensitivity;
253
+
254
+ if (Math.abs(stepsFromMovement) >= 1) {
255
+ // Determine modifier multiplier
256
+ let multiplier = 1;
257
+ if (shiftKey) {
258
+ multiplier = config.scrubShiftMultiplier;
259
+ } else if (altKey) {
260
+ multiplier = config.scrubAltMultiplier;
261
+ }
262
+
263
+ // Calculate delta
264
+ const wholeSteps = Math.trunc(stepsFromMovement);
265
+ const delta = wholeSteps * config.scrubStep * multiplier;
266
+
267
+ // Apply min/max clamping if bounds are set
268
+ let clampedDelta = delta;
269
+ if (config.scrubMin !== undefined || config.scrubMax !== undefined) {
270
+ const newValue = currentValue.current + delta;
271
+ const clampedValue = Math.max(config.scrubMin ?? -Infinity, Math.min(config.scrubMax ?? Infinity, newValue));
272
+ clampedDelta = clampedValue - currentValue.current;
273
+ currentValue.current = clampedValue;
274
+ } else {
275
+ currentValue.current += delta;
276
+ }
277
+
278
+ // Fire callback with clamped delta (isChanging = true during drag)
279
+ if (clampedDelta !== 0) {
280
+ config.onScrub?.(clampedDelta, true);
281
+ }
282
+
283
+ // Keep the fractional remainder for smooth sub-pixel accumulation
284
+ accumulatedMovement.current = (stepsFromMovement - wholeSteps) * config.scrubSensitivity;
285
+ }
286
+ }, []);
287
+
288
+ // End scrubbing helper
289
+ const endScrubbing = React.useCallback(() => {
290
+ scrubConfigRef.current.onScrub?.(0, false);
291
+ accumulatedMovement.current = 0;
292
+ currentValue.current = 0;
293
+ pointerIdRef.current = null;
294
+ setIsScrubbing(false);
295
+ }, []);
296
+
297
+ // Handle pointer capture mode events (Safari/Firefox)
298
+ const handlePointerMove = React.useCallback(
299
+ (event: React.PointerEvent) => {
300
+ if (!isScrubbing || !usePointerCapture) return;
301
+
302
+ const movementX = event.clientX - lastXRef.current;
303
+ lastXRef.current = event.clientX;
304
+
305
+ processScrubMovement(movementX, event.movementY, event.shiftKey, event.altKey);
306
+ },
307
+ [isScrubbing, processScrubMovement],
308
+ );
309
+
310
+ const handlePointerUp = React.useCallback(
311
+ (event: React.PointerEvent) => {
312
+ if (!usePointerCapture || pointerIdRef.current !== event.pointerId) return;
313
+
314
+ const slot = slotRef.current;
315
+ if (slot && pointerIdRef.current !== null) {
316
+ slot.releasePointerCapture(pointerIdRef.current);
317
+ }
318
+ endScrubbing();
319
+ },
320
+ [endScrubbing],
321
+ );
322
+
323
+ const handleLostPointerCapture = React.useCallback(() => {
324
+ if (usePointerCapture && isScrubbing) {
325
+ endScrubbing();
326
+ }
327
+ }, [isScrubbing, endScrubbing]);
328
+
329
+ // Attach document-level listeners for pointer lock mode (Chrome)
330
+ React.useEffect(() => {
331
+ if (!isScrubbing || usePointerCapture) return;
332
+
333
+ const handleMouseMove = (event: MouseEvent) => {
334
+ processScrubMovement(event.movementX, event.movementY, event.shiftKey, event.altKey);
202
335
  };
203
336
 
204
- const handlePointerDown = React.useCallback(
205
- (event: React.PointerEvent) => {
206
- if (!scrub) return;
337
+ const handleMouseUp = () => {
338
+ // Exit pointer lock to end scrubbing
339
+ document.exitPointerLock();
340
+ };
207
341
 
208
- // Don't start scrubbing if clicking on interactive elements
209
- const target = event.target as HTMLElement;
210
- if (target.closest('input, button, a')) return;
342
+ // Use mousemove for pointer lock (pointermove doesn't work well with pointer lock)
343
+ document.addEventListener('mousemove', handleMouseMove);
344
+ document.addEventListener('mouseup', handleMouseUp);
211
345
 
212
- event.preventDefault();
213
- accumulatedMovement.current = 0;
214
- // Initialize to current value so min/max clamping works correctly
215
- currentValue.current = scrubValue ?? 0;
216
-
217
- // Initialize virtual cursor at actual mouse position
218
- virtualX.current = event.clientX;
219
- setCursorPosition({ x: event.clientX, y: event.clientY });
220
-
221
- // Request pointer lock for infinite movement (cursor won't hit screen edges)
222
- const slot = slotRef.current;
223
- if (slot) {
224
- slot.requestPointerLock();
225
- }
226
- },
227
- [scrub, scrubValue],
228
- );
229
-
230
- // Handle pointer lock state changes
231
- React.useEffect(() => {
232
- const handlePointerLockChange = () => {
233
- const isLocked = document.pointerLockElement === slotRef.current;
234
- setIsScrubbing(isLocked);
235
- if (!isLocked) {
236
- // Fire callback with isChanging = false when scrubbing ends
237
- scrubConfigRef.current.onScrub?.(0, false);
238
- accumulatedMovement.current = 0;
239
- currentValue.current = 0;
240
- }
241
- };
242
-
243
- document.addEventListener('pointerlockchange', handlePointerLockChange);
244
- return () => {
245
- document.removeEventListener('pointerlockchange', handlePointerLockChange);
246
- };
247
- }, []);
248
-
249
- // Attach document-level listeners when scrubbing starts
250
- React.useEffect(() => {
251
- if (!isScrubbing) return;
252
-
253
- const handleMouseMove = (event: MouseEvent) => {
254
- const config = scrubConfigRef.current;
255
- const movementX = event.movementX;
256
- const movementY = event.movementY;
257
- const viewportWidth = window.innerWidth;
258
- const viewportHeight = window.innerHeight;
259
-
260
- // Update virtual position with wrap-around at viewport edges
261
- virtualX.current += movementX;
262
- if (virtualX.current > viewportWidth) {
263
- virtualX.current = virtualX.current % viewportWidth;
264
- } else if (virtualX.current < 0) {
265
- virtualX.current = viewportWidth + (virtualX.current % viewportWidth);
266
- }
267
-
268
- // Also track Y with wrap-around
269
- setCursorPosition((prev) => {
270
- let newY = prev.y + movementY;
271
- if (newY > viewportHeight) {
272
- newY = newY % viewportHeight;
273
- } else if (newY < 0) {
274
- newY = viewportHeight + (newY % viewportHeight);
275
- }
276
- return { x: virtualX.current, y: newY };
277
- });
278
-
279
- // Accumulate movement for sensitivity calculation
280
- accumulatedMovement.current += movementX;
281
-
282
- // Calculate how many steps we've moved
283
- const stepsFromMovement = accumulatedMovement.current / config.scrubSensitivity;
284
-
285
- if (Math.abs(stepsFromMovement) >= 1) {
286
- // Determine modifier multiplier
287
- let multiplier = 1;
288
- if (event.shiftKey) {
289
- multiplier = config.scrubShiftMultiplier;
290
- } else if (event.altKey) {
291
- multiplier = config.scrubAltMultiplier;
292
- }
293
-
294
- // Calculate delta
295
- const wholeSteps = Math.trunc(stepsFromMovement);
296
- const delta = wholeSteps * config.scrubStep * multiplier;
297
-
298
- // Apply min/max clamping if bounds are set
299
- let clampedDelta = delta;
300
- if (config.scrubMin !== undefined || config.scrubMax !== undefined) {
301
- const newValue = currentValue.current + delta;
302
- const clampedValue = Math.max(
303
- config.scrubMin ?? -Infinity,
304
- Math.min(config.scrubMax ?? Infinity, newValue),
305
- );
306
- clampedDelta = clampedValue - currentValue.current;
307
- currentValue.current = clampedValue;
308
- } else {
309
- currentValue.current += delta;
310
- }
311
-
312
- // Fire callback with clamped delta (isChanging = true during drag)
313
- if (clampedDelta !== 0) {
314
- config.onScrub?.(clampedDelta, true);
315
- }
316
-
317
- // Keep the fractional remainder for smooth sub-pixel accumulation
318
- accumulatedMovement.current = (stepsFromMovement - wholeSteps) * config.scrubSensitivity;
319
- }
320
- };
321
-
322
- const handleMouseUp = () => {
323
- // Exit pointer lock to end scrubbing
324
- document.exitPointerLock();
325
- };
326
-
327
- // Use mousemove for pointer lock (pointermove doesn't work well with pointer lock)
328
- document.addEventListener('mousemove', handleMouseMove);
329
- document.addEventListener('mouseup', handleMouseUp);
330
-
331
- // Disable text selection during scrubbing
332
- document.body.style.userSelect = 'none';
333
-
334
- return () => {
335
- document.removeEventListener('mousemove', handleMouseMove);
336
- document.removeEventListener('mouseup', handleMouseUp);
337
- document.body.style.userSelect = '';
338
- };
339
- }, [isScrubbing]);
340
-
341
- // Render virtual cursor via portal to body so it's not clipped
342
- // Using a data URI of ew-resize cursor for a native look
343
- const virtualCursor = isScrubbing
344
- ? ReactDOM.createPortal(
345
- <img
346
- className="rt-TextFieldSlotScrubCursor"
347
- 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"
348
- alt=""
349
- style={{
350
- position: 'fixed',
351
- left: cursorPosition.x,
352
- top: cursorPosition.y,
353
- transform: 'translate(-50%, -50%)',
354
- pointerEvents: 'none',
355
- zIndex: 99999,
356
- width: 24,
357
- height: 24,
358
- }}
359
- aria-hidden="true"
360
- />,
361
- document.body,
362
- )
363
- : null;
364
-
365
- return (
366
- <div
367
- data-accent-color={color}
368
- data-side={side}
369
- data-scrub={scrub || undefined}
370
- data-scrubbing={isScrubbing || undefined}
371
- {...slotProps}
372
- ref={composeRefs(slotRef, forwardedRef)}
373
- className={classNames('rt-TextFieldSlot', className)}
374
- onPointerDown={scrub ? handlePointerDown : undefined}
375
- >
376
- {slotProps.children}
377
- {virtualCursor}
378
- </div>
379
- );
380
- },
381
- );
346
+ // Disable text selection during scrubbing
347
+ document.body.style.userSelect = 'none';
348
+
349
+ return () => {
350
+ document.removeEventListener('mousemove', handleMouseMove);
351
+ document.removeEventListener('mouseup', handleMouseUp);
352
+ document.body.style.userSelect = '';
353
+ };
354
+ }, [isScrubbing, processScrubMovement]);
355
+
356
+ // Hide native cursor and disable text selection during pointer capture scrubbing
357
+ React.useEffect(() => {
358
+ if (!isScrubbing || !usePointerCapture) return;
359
+
360
+ // Create a style element to hide cursor globally during scrub
361
+ const style = document.createElement('style');
362
+ style.textContent = '* { cursor: none !important; user-select: none !important; }';
363
+ document.head.appendChild(style);
364
+
365
+ return () => {
366
+ document.head.removeChild(style);
367
+ };
368
+ }, [isScrubbing]);
369
+
370
+ // Render virtual cursor via portal to body so it's not clipped
371
+ // Using a data URI of ew-resize cursor for a native look
372
+ const virtualCursor = isScrubbing
373
+ ? ReactDOM.createPortal(
374
+ <img
375
+ className="rt-TextFieldSlotScrubCursor"
376
+ 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"
377
+ alt=""
378
+ style={{
379
+ position: 'fixed',
380
+ left: cursorPosition.x,
381
+ top: cursorPosition.y,
382
+ transform: 'translate(-50%, -50%)',
383
+ pointerEvents: 'none',
384
+ zIndex: 99999,
385
+ width: 24,
386
+ height: 24,
387
+ }}
388
+ aria-hidden="true"
389
+ />,
390
+ document.body,
391
+ )
392
+ : null;
393
+
394
+ return (
395
+ <div
396
+ data-accent-color={color}
397
+ data-side={side}
398
+ data-scrub={scrub || undefined}
399
+ data-scrubbing={isScrubbing || undefined}
400
+ {...slotProps}
401
+ ref={composeRefs(slotRef, forwardedRef)}
402
+ className={classNames('rt-TextFieldSlot', className)}
403
+ onPointerDown={scrub ? handlePointerDown : undefined}
404
+ onPointerMove={scrub ? handlePointerMove : undefined}
405
+ onPointerUp={scrub ? handlePointerUp : undefined}
406
+ onLostPointerCapture={scrub ? handleLostPointerCapture : undefined}
407
+ >
408
+ {slotProps.children}
409
+ {virtualCursor}
410
+ </div>
411
+ );
412
+ });
382
413
  TextFieldSlot.displayName = 'TextField.Slot';
383
414
 
384
415
  export { TextFieldRoot as Root, TextFieldSlot as Slot };