PageSourceSearch

https://delivr.to/assets/switch-Toae-IaB.js

js delivr.to collected 2026-09-25 19:12:07 UTC 2,759 bytes, 1 lines download raw bytes

1import{c as I,b as x}from"./index-CT7kTiav.js";import{j as a}from"./query-DmstuUoN.js";import{a as o}from"./vendor-CHI41uxr.js";import{u as C,e as T,c as L,g as y,h as q,M as H,N as A}from"./ui-WgsiDFN4.js";const K=I("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);var m="Switch",[U]=L(m),[z,O]=U(m),P=o.forwardRef((t,s)=>{const{__scopeSwitch:e,name:n,checked:r,defaultChecked:b,required:d,disabled:c,value:l="on",onCheckedChange:w,form:i,...v}=t,[u,p]=o.useState(null),k=C(s,h=>p(h)),S=o.useRef(!1),g=u?i||!!u.closest("form"):!0,[f,M]=T({prop:r,defaultProp:b??!1,onChange:w,caller:m});return a.jsxs(z,{scope:e,checked:f,disabled:c,children:[a.jsx(y.button,{type:"button",role:"switch","aria-checked":f,"aria-required":d,"data-state":j(f),"data-disabled":c?"":void 0,disabled:c,value:l,...v,ref:k,onClick:q(t.onClick,h=>{M(B=>!B),g&&(S.current=h.isPropagationStopped(),S.current||h.stopPropagation())})}),g&&a.jsx(R,{control:u,bubbles:!S.current,name:n,value:l,checked:f,required:d,disabled:c,form:i,style:{transform:"translateX(-100%)"}})]})});P.displayName=m;var E="SwitchThumb",N=o.forwardRef((t,s)=>{const{__scopeSwitch:e,...n}=t,r=O(E,e);return a.jsx(y.span,{"data-state":j(r.checked),"data-disabled":r.disabled?"":void 0,...n,ref:s})});N.displayName=E;var D="SwitchBubbleInput",R=o.forwardRef(({__scopeSwitch:t,control:s,checked:e,bubbles:n=!0,...r},b)=>{const d=o.useRef(null),c=C(d,b),l=H(e),w=A(s);return o.useEffect(()=>{const i=d.current;if(!i)return;const v=window.HTMLInputElement.prototype,p=Object.getOwnPropertyDescriptor(v,"checked").set;if(l!==e&&p){const k=new Event("click",{bubbles:n});p.call(i,e),i.dispatchEvent(k)}},[l,e,n]),a.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:e,...r,tabIndex:-1,ref:c,style:{...r.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});R.displayName=D;function j(t){return t?"checked":"unchecked"}var _=P,F=N;const W=o.forwardRef(({className:t,...s},e)=>a.jsx(_,{className:x("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...s,ref:e,children:a.jsx(F,{className:x("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));W.displayName=_.displayName;export{K as L,W as S};

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.