@radix-ui/themes
Version:
[](https://radix-ui.com/themes)
6 lines (5 loc) • 1.35 kB
JavaScript
"use client";import*as t from"react";import d from"classnames";import{textFieldRootPropDefs as F,textFieldSlotPropDefs as R}from"./text-field.props.js";import{extractProps as m}from"../helpers/index.js";import{marginPropDefs as y}from"../props/index.js";import{composeRefs as S}from"@radix-ui/react-compose-refs";const u=t.forwardRef((r,s)=>{const e=t.useRef(null),{children:l,className:i,color:p,radius:x,style:f,...P}=m(r,F,y);return t.createElement("div",{"data-accent-color":p,"data-radius":x,style:f,className:d("rt-TextFieldRoot",i),onPointerDown:T=>{const n=T.target;if(n.closest("input, button, a"))return;const o=e.current;if(!o)return;const a=n.closest(`
.rt-TextFieldSlot[data-side='right'],
.rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])
`)?o.value.length:0;requestAnimationFrame(()=>{try{o.setSelectionRange(a,a)}catch{}o.focus()})}},t.createElement("input",{spellCheck:"false",...P,ref:S(e,s),className:"rt-reset rt-TextFieldInput"}),l)});u.displayName="TextField.Root";const c=t.forwardRef((r,s)=>{const{className:e,color:l,side:i,...p}=m(r,R);return t.createElement("div",{"data-accent-color":l,"data-side":i,...p,ref:s,className:d("rt-TextFieldSlot",e)})});c.displayName="TextField.Slot";export{u as Root,c as Slot};
//# sourceMappingURL=text-field.js.map