Files
mai-bot/dashboard/dist/assets/radio-group-BBkaGEpR.js

2 lines
3.9 KiB
JavaScript

import{r as n,j as a}from"./router-zNjPR4CY.js";import{aq as U,a2 as K,ay as T,P as x,ap as C,az as V,U as w,aA as E,aB as z,a1 as N,aC as H,aD as $}from"./radix-C-ZuImoP.js";import{g as I}from"./index-CuOHsLf7.js";import{z as W}from"./icons-DTcdLw9j.js";var g="Radio",[X,P]=N(g),[Y,J]=X(g),_=n.forwardRef((r,t)=>{const{__scopeRadio:e,name:d,checked:o=!1,required:s,disabled:i,value:p="on",onCheck:f,form:R,...m}=r,[l,v]=n.useState(null),c=C(t,h=>v(h)),u=n.useRef(!1),y=l?R||!!l.closest("form"):!0;return a.jsxs(Y,{scope:e,checked:o,disabled:i,children:[a.jsx(x.button,{type:"button",role:"radio","aria-checked":o,"data-state":A(o),"data-disabled":i?"":void 0,disabled:i,value:p,...m,ref:c,onClick:w(r.onClick,h=>{o||f?.(),y&&(u.current=h.isPropagationStopped(),u.current||h.stopPropagation())})}),y&&a.jsx(G,{control:l,bubbles:!u.current,name:d,value:p,checked:o,required:s,disabled:i,form:R,style:{transform:"translateX(-100%)"}})]})});_.displayName=g;var j="RadioIndicator",k=n.forwardRef((r,t)=>{const{__scopeRadio:e,forceMount:d,...o}=r,s=J(j,e);return a.jsx(z,{present:d||s.checked,children:a.jsx(x.span,{"data-state":A(s.checked),"data-disabled":s.disabled?"":void 0,...o,ref:t})})});k.displayName=j;var Q="RadioBubbleInput",G=n.forwardRef(({__scopeRadio:r,control:t,checked:e,bubbles:d=!0,...o},s)=>{const i=n.useRef(null),p=C(i,s),f=H(e),R=$(t);return n.useEffect(()=>{const m=i.current;if(!m)return;const l=window.HTMLInputElement.prototype,c=Object.getOwnPropertyDescriptor(l,"checked").set;if(f!==e&&c){const u=new Event("click",{bubbles:d});c.call(m,e),m.dispatchEvent(u)}},[f,e,d]),a.jsx(x.input,{type:"radio","aria-hidden":!0,defaultChecked:e,...o,tabIndex:-1,ref:p,style:{...o.style,...R,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});G.displayName=Q;function A(r){return r?"checked":"unchecked"}var Z=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],b="RadioGroup",[ee]=N(b,[E,P]),S=E(),D=P(),[oe,re]=ee(b),M=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,name:d,defaultValue:o,value:s,required:i=!1,disabled:p=!1,orientation:f,dir:R,loop:m=!0,onValueChange:l,...v}=r,c=S(e),u=U(R),[y,h]=K({prop:s,defaultProp:o??null,onChange:l,caller:b});return a.jsx(oe,{scope:e,name:d,required:i,disabled:p,value:y,onValueChange:h,children:a.jsx(T,{asChild:!0,...c,orientation:f,dir:u,loop:m,children:a.jsx(x.div,{role:"radiogroup","aria-required":i,"aria-orientation":f,"data-disabled":p?"":void 0,dir:u,...v,ref:t})})})});M.displayName=b;var O="RadioGroupItem",q=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,disabled:d,...o}=r,s=re(O,e),i=s.disabled||d,p=S(e),f=D(e),R=n.useRef(null),m=C(t,R),l=s.value===o.value,v=n.useRef(!1);return n.useEffect(()=>{const c=y=>{Z.includes(y.key)&&(v.current=!0)},u=()=>v.current=!1;return document.addEventListener("keydown",c),document.addEventListener("keyup",u),()=>{document.removeEventListener("keydown",c),document.removeEventListener("keyup",u)}},[]),a.jsx(V,{asChild:!0,...p,focusable:!i,active:l,children:a.jsx(_,{disabled:i,required:s.required,checked:l,...f,...o,name:s.name,ref:m,onCheck:()=>s.onValueChange(o.value),onKeyDown:w(c=>{c.key==="Enter"&&c.preventDefault()}),onFocus:w(o.onFocus,()=>{v.current&&R.current?.click()})})})});q.displayName=O;var ae="RadioGroupIndicator",B=n.forwardRef((r,t)=>{const{__scopeRadioGroup:e,...d}=r,o=D(e);return a.jsx(k,{...o,...d,ref:t})});B.displayName=ae;var F=M,L=q,te=B;const se=n.forwardRef(({className:r,...t},e)=>a.jsx(F,{className:I("grid gap-2",r),...t,ref:e}));se.displayName=F.displayName;const ne=n.forwardRef(({className:r,...t},e)=>a.jsx(L,{ref:e,className:I("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",r),...t,children:a.jsx(te,{className:"flex items-center justify-center",children:a.jsx(W,{className:"h-2.5 w-2.5 fill-current text-current"})})}));ne.displayName=L.displayName;export{se as R,ne as a};