UNPKG

decocms

Version:

Deco CMS — Self-hostable MCP Gateway for managing AI connections and tools

2 lines (1 loc) • 2.68 kB
import{r as c,j as i,c9 as C,c7 as _,c4 as T,ca as I,cg as M,cr as H,cn as z,c as A,m as g}from"./index-DoEtSiIe.js";var b="Switch",[U]=z(b),[q,L]=U(b),y=c.forwardRef((o,e)=>{const{__scopeSwitch:t,name:s,checked:r,defaultChecked:n,required:a,disabled:d,value:u="on",onCheckedChange:w,form:l,...k}=o,[p,h]=c.useState(null),S=_(e,m=>h(m)),v=c.useRef(!1),x=p?l||!!p.closest("form"):!0,[f,N]=T({prop:r,defaultProp:n??!1,onChange:w,caller:b});return i.jsxs(q,{scope:t,checked:f,disabled:d,children:[i.jsx(C.button,{type:"button",role:"switch","aria-checked":f,"aria-required":a,"data-state":j(f),"data-disabled":d?"":void 0,disabled:d,value:u,...k,ref:S,onClick:I(o.onClick,m=>{N(B=>!B),x&&(v.current=m.isPropagationStopped(),v.current||m.stopPropagation())})}),x&&i.jsx(R,{control:p,bubbles:!v.current,name:s,value:u,checked:f,required:a,disabled:d,form:l,style:{transform:"translateX(-100%)"}})]})});y.displayName=b;var E="SwitchThumb",P=c.forwardRef((o,e)=>{const{__scopeSwitch:t,...s}=o,r=L(E,t);return i.jsx(C.span,{"data-state":j(r.checked),"data-disabled":r.disabled?"":void 0,...s,ref:e})});P.displayName=E;var O="SwitchBubbleInput",R=c.forwardRef(({__scopeSwitch:o,control:e,checked:t,bubbles:s=!0,...r},n)=>{const a=c.useRef(null),d=_(a,n),u=M(t),w=H(e);return c.useEffect(()=>{const l=a.current;if(!l)return;const k=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(k,"checked").set;if(u!==t&&h){const S=new Event("click",{bubbles:s});h.call(l,t),l.dispatchEvent(S)}},[u,t,s]),i.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:t,...r,tabIndex:-1,ref:d,style:{...r.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});R.displayName=O;function j(o){return o?"checked":"unchecked"}var $=y,D=P;function W(o){const e=A.c(9);let t,s;e[0]!==o?({className:t,...s}=o,e[0]=o,e[1]=t,e[2]=s):(t=e[1],s=e[2]);let r;e[3]!==t?(r=g("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-foreground/15 inline-flex h-[1.125rem] w-8 shrink-0 items-center rounded-full border-2 border-transparent transition-colors outline-none focus-ring disabled:opacity-50",t),e[3]=t,e[4]=r):r=e[4];let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=i.jsx(D,{"data-slot":"switch-thumb",className:g("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-3.5 rounded-full shadow-[0_0_0_1px_#0000000f] ring-0 transition-transform data-[state=checked]:translate-x-3.5 data-[state=unchecked]:translate-x-0")}),e[5]=n):n=e[5];let a;return e[6]!==s||e[7]!==r?(a=i.jsx($,{"data-slot":"switch",className:r,...s,children:n}),e[6]=s,e[7]=r,e[8]=a):a=e[8],a}export{W as S};