2 lines
4.4 KiB
JavaScript
Vendored
2 lines
4.4 KiB
JavaScript
Vendored
import{Q as _,P as h,a4 as k,a6 as f,Z as U,R as E,S as I,a3 as C,r as b,o as M,q as N,w as v,g as $,i as m,J as y,l as L,M as j,t as V}from"./vendor.7e4e5e39.js";import{_ as W}from"./plugin-vue_export-helper.21dcd24c.js";import{_ as q,a as x,r as w,c as K,u as z,K as B}from"./dom.esm.2d7131b5.js";import{u as J}from"./use-resolve-button-type.esm.e228f45b.js";var D=Symbol("LabelContext");function G(){var n=C(D,null);if(n===null){var t=new Error("You used a <Label /> component, but it is not inside a parent.");throw Error.captureStackTrace&&Error.captureStackTrace(t,G),t}return n}function Q(n){var t=n===void 0?{}:n,e=t.slot,d=e===void 0?{}:e,i=t.name,s=i===void 0?"Label":i,o=t.props,l=o===void 0?{}:o,a=h([]);function u(c){return a.value.push(c),function(){var r=a.value.indexOf(c);r!==-1&&a.value.splice(r,1)}}return k(D,{register:u,slot:d,name:s,props:l}),_(function(){return a.value.length>0?a.value.join(" "):void 0})}var Y=f({name:"Label",props:{as:{type:[Object,String],default:"label"},passive:{type:[Boolean],default:!1}},render:function(){var t=this.context,e=t.name,d=e===void 0?"Label":e,i=t.slot,s=i===void 0?{}:i,o=t.props,l=o===void 0?{}:o,a=this.$props,u=a.passive,c=q(a,["passive"]),r=x({},Object.entries(l).reduce(function(P,g){var p,R=g[0],T=g[1];return Object.assign(P,(p={},p[R]=U(T),p))},{}),{id:this.id}),S=x({},c,r);return u&&delete S.onClick,w({props:S,slot:s,attrs:this.$attrs,slots:this.$slots,name:d})},setup:function(){var t=G(),e="headlessui-label-"+K();return E(function(){return I(t.register(e))}),{id:e,context:t}}}),O=Symbol("GroupContext"),Z=f({name:"SwitchGroup",props:{as:{type:[Object,String],default:"template"}},setup:function(t,e){var d=e.slots,i=e.attrs,s=h(null),o=Q({name:"SwitchLabel",props:{onClick:function(){!s.value||(s.value.click(),s.value.focus({preventScroll:!0}))}}}),l=z({name:"SwitchDescription"}),a={switchRef:s,labelledby:o,describedby:l};return k(O,a),function(){return w({props:t,slot:{},slots:d,attrs:i,name:"SwitchGroup"})}}}),A=f({name:"Switch",emits:{"update:modelValue":function(t){return!0}},props:{as:{type:[Object,String],default:"button"},modelValue:{type:Boolean,default:!1}},render:function(){var t={checked:this.$props.modelValue},e={id:this.id,ref:"el",role:"switch",type:this.type,tabIndex:0,"aria-checked":this.$props.modelValue,"aria-labelledby":this.labelledby,"aria-describedby":this.describedby,onClick:this.handleClick,onKeyup:this.handleKeyUp,onKeypress:this.handleKeyPress};return w({props:x({},this.$props,e),slot:t,attrs:this.$attrs,slots:this.$slots,name:"Switch"})},setup:function(t,e){var d=e.emit,i=e.attrs,s=C(O,null),o="headlessui-switch-"+K();function l(){d("update:modelValue",!t.modelValue)}var a=h(null),u=s===null?a:s.switchRef;return{id:o,el:u,type:J(_(function(){return{as:t.as,type:i.type}}),u),labelledby:s==null?void 0:s.labelledby,describedby:s==null?void 0:s.describedby,handleClick:function(r){r.preventDefault(),l()},handleKeyUp:function(r){r.key!==B.Tab&&r.preventDefault(),r.key===B.Space&&l()},handleKeyPress:function(r){r.preventDefault()}}}}),F=Y;const H={components:{Switch:A,SwitchGroup:Z,SwitchLabel:F},props:{textin:String,textout:String,user_id:Number,enabled:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["clicked","prohibited"],methods:{clicked(){this.disabled===!1?this.$emit("clicked",this.user_id):this.$emit("prohibited")}}};function X(n,t,e,d,i,s){const o=b("Switch"),l=b("SwitchLabel"),a=b("SwitchGroup");return M(),N(a,{as:"div",class:y([{"pointer-events-none":e.disabled},"flex items-center"]),onClick:s.clicked},{default:v(()=>[$(o,{modelValue:e.enabled,"onUpdate:modelValue":t[0]||(t[0]=u=>e.enabled=u),class:y([e.enabled?"bg-orange":"bg-indigo-200","relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"])},{default:v(()=>[m("span",{"aria-hidden":"true",class:y([e.enabled?"translate-x-5":"translate-x-0","pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow transform ring-0 transition ease-in-out duration-200"])},null,2)]),_:1},8,["modelValue","class"]),$(l,{as:"span",class:"ml-3"},{default:v(()=>[L(m("span",{class:"text-sm text-white"},V(e.textin),513),[[j,!e.enabled]]),L(m("span",{class:"text-sm text-white"},V(e.textout),513),[[j,e.enabled]])]),_:1})]),_:1},8,["class","onClick"])}var ne=W(H,[["render",X]]);export{ne as T};
|