PageSourceSearch

https://delivr.to/assets/checkbox-CLrZ-oDk.js

js delivr.to collected 2026-10-03 22:10:43 UTC 3,867 bytes, 1 lines download raw bytes

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

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.