Files
aiops/backend/static/assets/checkbox-Bu55mX0G.js
T

2 lines
4.2 KiB
JavaScript

import{r as i,j as o}from"./vendor-codemirror-B1SGo4xl.js";import{w as L,P as O,x as _,y as H,z as w,A as j,C as G,m as K}from"./index-Dungj95X.js";import{u as U}from"./index-5FEebgvX.js";import{w as X}from"./vendor-icons-DmqcWdzX.js";var y="Checkbox",[$]=L(y),[J,P]=$(y);function Q(t){const{__scopeCheckbox:n,checked:a,children:l,defaultChecked:s,disabled:e,form:h,name:b,onCheckedChange:d,required:k,value:x="on",internal_do_not_use_render:u}=t,[p,v]=H({prop:a,defaultProp:s??!1,onChange:d,caller:y}),[m,C]=i.useState(null),[g,r]=i.useState(null),c=i.useRef(!1),E=m?!!h||!!m.closest("form"):!0,R={checked:p,disabled:e,setChecked:v,control:m,setControl:C,name:b,form:h,value:x,hasConsumerStoppedPropagationRef:c,required:k,defaultChecked:f(s)?!1:s,isFormControl:E,bubbleInput:g,setBubbleInput:r};return o.jsx(J,{scope:n,...R,children:V(u)?u(R):l})}var N="CheckboxTrigger",S=i.forwardRef(({__scopeCheckbox:t,onKeyDown:n,onClick:a,...l},s)=>{const{control:e,value:h,disabled:b,checked:d,required:k,setControl:x,setChecked:u,hasConsumerStoppedPropagationRef:p,isFormControl:v,bubbleInput:m}=P(N,t),C=w(s,x),g=i.useRef(d);return i.useEffect(()=>{const r=e?.form;if(r){const c=()=>u(g.current);return r.addEventListener("reset",c),()=>r.removeEventListener("reset",c)}},[e,u]),o.jsx(_.button,{type:"button",role:"checkbox","aria-checked":f(d)?"mixed":d,"aria-required":k,"data-state":z(d),"data-disabled":b?"":void 0,disabled:b,value:h,...l,ref:C,onKeyDown:j(n,r=>{r.key==="Enter"&&r.preventDefault()}),onClick:j(a,r=>{u(c=>f(c)?!0:!c),m&&v&&(p.current=r.isPropagationStopped(),p.current||r.stopPropagation())})})});S.displayName=N;var B=i.forwardRef((t,n)=>{const{__scopeCheckbox:a,name:l,checked:s,defaultChecked:e,required:h,disabled:b,value:d,onCheckedChange:k,form:x,...u}=t;return o.jsx(Q,{__scopeCheckbox:a,checked:s,defaultChecked:e,disabled:b,required:h,onCheckedChange:k,name:l,form:x,value:d,internal_do_not_use_render:({isFormControl:p})=>o.jsxs(o.Fragment,{children:[o.jsx(S,{...u,ref:n,__scopeCheckbox:a}),p&&o.jsx(q,{__scopeCheckbox:a})]})})});B.displayName=y;var A="CheckboxIndicator",M=i.forwardRef((t,n)=>{const{__scopeCheckbox:a,forceMount:l,...s}=t,e=P(A,a);return o.jsx(O,{present:l||f(e.checked)||e.checked===!0,children:o.jsx(_.span,{"data-state":z(e.checked),"data-disabled":e.disabled?"":void 0,...s,ref:n,style:{pointerEvents:"none",...t.style}})})});M.displayName=A;var T="CheckboxBubbleInput",q=i.forwardRef(({__scopeCheckbox:t,...n},a)=>{const{control:l,hasConsumerStoppedPropagationRef:s,checked:e,defaultChecked:h,required:b,disabled:d,name:k,value:x,form:u,bubbleInput:p,setBubbleInput:v}=P(T,t),m=w(a,v),C=U(e),g=G(l);i.useEffect(()=>{const c=p;if(!c)return;const E=window.HTMLInputElement.prototype,I=Object.getOwnPropertyDescriptor(E,"checked").set,D=!s.current;if(C!==e&&I){const F=new Event("click",{bubbles:D});c.indeterminate=f(e),I.call(c,f(e)?!1:e),c.dispatchEvent(F)}},[p,C,e,s]);const r=i.useRef(f(e)?!1:e);return o.jsx(_.input,{type:"checkbox","aria-hidden":!0,defaultChecked:h??r.current,required:b,disabled:d,name:k,value:x,form:u,...n,tabIndex:-1,ref:m,style:{...n.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});q.displayName=T;function V(t){return typeof t=="function"}function f(t){return t==="indeterminate"}function z(t){return f(t)?"indeterminate":t?"checked":"unchecked"}function te({className:t,...n}){return o.jsx(B,{"code-path":"src/components/ui/checkbox.tsx:14:5","data-slot":"checkbox",className:K("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...n,children:o.jsx(M,{"code-path":"src/components/ui/checkbox.tsx:22:7","data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none",children:o.jsx(X,{"code-path":"src/components/ui/checkbox.tsx:26:9",className:"size-3.5"})})})}export{te as C};