Files
nademitex_admin/dist/assets/BaseSwitch-gjOaAbzm.js
T

1 line
1.4 KiB
JavaScript

import{At as e,N as t,Nt as n,f as r,g as i,h as a,o,p as s,x as c}from"./http-WTIyGIuL.js";var l=[`title`],u={key:0,class:`base-switch__label`},d={class:`base-switch__control`},f=[`id`,`checked`,`disabled`,`aria-checked`,`aria-label`],p={class:`base-switch__track`,"aria-hidden":`true`},m={class:`base-switch__thumb`},h={key:0,class:`base-switch__spinner`},g=o(c({__name:`BaseSwitch`,props:{modelValue:{type:Boolean},disabled:{type:Boolean},loading:{type:Boolean},error:{type:Boolean},label:{},activeText:{default:`فعال`},inactiveText:{default:`غیرفعال`},id:{}},emits:[`update:modelValue`],setup(o,{emit:c}){let g=o,_=c,v=r(()=>g.id??`switch-${crypto.randomUUID().slice(0,8)}`),y=r(()=>g.modelValue?g.activeText:g.inactiveText);function b(e){let t=e.target,n=t.checked;t.checked=g.modelValue,!(g.disabled||g.loading)&&_(`update:modelValue`,n)}return(r,c)=>(t(),i(`label`,{class:e([`base-switch`,{"base-switch--disabled":o.disabled||o.loading,"base-switch--error":o.error}]),title:y.value},[o.label?(t(),i(`span`,u,n(o.label),1)):a(``,!0),s(`span`,d,[s(`input`,{id:v.value,class:`base-switch__input`,type:`checkbox`,role:`switch`,checked:o.modelValue,disabled:o.disabled||o.loading,"aria-checked":o.modelValue,"aria-label":o.label||y.value,onChange:b},null,40,f),s(`span`,p,[s(`span`,m,[o.loading?(t(),i(`span`,h)):a(``,!0)])])])],10,l))}}),[[`__scopeId`,`data-v-0410eed4`]]);export{g as t};