mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
2 lines
2.8 KiB
JavaScript
2 lines
2.8 KiB
JavaScript
import{r as R,K as L,N as T,j as s,ae as W,V as X,au as Z,a8 as ee,Q as N,W as te,aa as se,_ as h,Y as ae}from"./index-Db-xuq0b.js";import{I as oe,a as ce,b as re}from"./InputsGroupFieldset-COkNgcEo.js";import{u as A}from"./use-uncontrolled-C3HRHW6t.js";const B=R.createContext(null),le=B.Provider,ne=()=>R.useContext(B),ie={},x=L((l,o)=>{const{value:t,defaultValue:e,onChange:b,size:d,wrapperProps:u,children:p,readOnly:f,...y}=T("SwitchGroup",ie,l),[c,m]=A({value:t,defaultValue:e,finalValue:[],onChange:b}),w=v=>{const n=v.currentTarget.value;!f&&m(c.includes(n)?c.filter(C=>C!==n):[...c,n])};return s.jsx(le,{value:{value:c,onChange:w,size:d},children:s.jsx(W.Wrapper,{size:d,ref:o,...u,...y,labelElement:"div",__staticSelector:"SwitchGroup",children:s.jsx(oe,{role:"group",children:p})})})});x.classes=W.Wrapper.classes;x.displayName="@mantine/core/SwitchGroup";var F={root:"m_5f93f3bb",input:"m_926b4011",track:"m_9307d992",thumb:"m_93039a1d",trackLabel:"m_8277e082"};const he={labelPosition:"right"},de=te((l,{radius:o,color:t,size:e})=>({root:{"--switch-radius":o===void 0?void 0:ae(o),"--switch-height":h(e,"switch-height"),"--switch-width":h(e,"switch-width"),"--switch-thumb-size":h(e,"switch-thumb-size"),"--switch-label-font-size":h(e,"switch-label-font-size"),"--switch-track-label-padding":h(e,"switch-track-label-padding"),"--switch-color":t?se(t,l):void 0}})),_=L((l,o)=>{const t=T("Switch",he,l),{classNames:e,className:b,style:d,styles:u,unstyled:p,vars:f,color:y,label:c,offLabel:m,onLabel:w,id:v,size:n,radius:C,wrapperProps:K,thumbIcon:O,checked:g,defaultChecked:Q,onChange:S,labelPosition:P,description:U,error:j,disabled:G,variant:Y,rootRef:$,mod:q,...D}=t,a=ne(),H=n||(a==null?void 0:a.size),i=X({name:"Switch",props:t,classes:F,className:b,style:d,classNames:e,styles:u,unstyled:p,vars:f,varsResolver:de}),{styleProps:J,rest:I}=Z(D),V=ee(v),r=a?{checked:a.value.includes(I.value),onChange:a.onChange}:{},[z,M]=A({value:r.checked??g,defaultValue:Q,finalValue:!1});return s.jsxs(ce,{...i("root"),__staticSelector:"Switch",__stylesApiProps:t,id:V,size:H,labelPosition:P,label:c,description:U,error:j,disabled:G,bodyElement:"label",labelElement:"span",classNames:e,styles:u,unstyled:p,"data-checked":r.checked||g||void 0,variant:Y,ref:$,mod:q,...J,...K,children:[s.jsx("input",{...I,disabled:G,checked:z,"data-checked":r.checked||g||void 0,onChange:k=>{var E;a?(E=r.onChange)==null||E.call(r,k):S==null||S(k),M(k.currentTarget.checked)},id:V,ref:o,type:"checkbox",role:"switch",...i("input")}),s.jsxs(N,{"aria-hidden":"true",component:"span",mod:{error:j,"label-position":P,"without-labels":!w&&!m},...i("track"),children:[s.jsx(N,{component:"span",mod:"reduce-motion",...i("thumb"),children:O}),s.jsx("span",{...i("trackLabel"),children:z?w:m})]})]})});_.classes={...F,...re};_.displayName="@mantine/core/Switch";_.Group=x;export{_ as S};
|