2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
import{a as m,c as N,g as H,h as d,U as re,p as se,q as oe,u as ce,Y as O,y as X,v as de,l as fe,r as K,A as w,x as ve,b as me,a3 as ge,m as be}from"./index-BFHpqQMc.js";import{h as ye,b as L,i as he,d as ke}from"./use-router-link-niyq3CDa.js";const A={xs:18,sm:24,md:32,lg:38,xl:46},Y={size:String};function G(e,t=A){return m(()=>e.size!==void 0?{fontSize:e.size in t?`${t[e.size]}px`:e.size}:null)}const Q="0 0 24 24",z=e=>e,j=e=>`ionicons ${e}`,J={"mdi-":e=>`mdi ${e}`,"icon-":z,"bt-":e=>`bt ${e}`,"eva-":e=>`eva ${e}`,"ion-md":j,"ion-ios":j,"ion-logo":j,"iconfont ":z,"ti-":e=>`themify-icon ${e}`,"bi-":e=>`bootstrap-icons ${e}`,"i-":z},Z={o_:"-outlined",r_:"-round",s_:"-sharp"},ee={sym_o_:"-outlined",sym_r_:"-rounded",sym_s_:"-sharp"},xe=new RegExp("^("+Object.keys(J).join("|")+")"),qe=new RegExp("^("+Object.keys(Z).join("|")+")"),D=new RegExp("^("+Object.keys(ee).join("|")+")"),pe=/^[Mm]\s?[-+]?\.?\d/,Ee=/^img:/,we=/^svguse:/,$e=/^ion-/,Se=/^(fa-(classic|sharp|solid|regular|light|brands|duotone|thin)|[lf]a[srlbdk]?) /,I=N({name:"QIcon",props:{...Y,tag:{type:String,default:"i"},name:String,color:String,left:Boolean,right:Boolean},setup(e,{slots:t}){const{proxy:{$q:a}}=H(),u=G(e),o=m(()=>"q-icon"+(e.left===!0?" on-left":"")+(e.right===!0?" on-right":"")+(e.color!==void 0?` text-${e.color}`:"")),f=m(()=>{let r,i=e.name;if(i==="none"||!i)return{none:!0};if(a.iconMapFn!==null){const c=a.iconMapFn(i);if(c!==void 0)if(c.icon!==void 0){if(i=c.icon,i==="none"||!i)return{none:!0}}else return{cls:c.cls,content:c.content!==void 0?c.content:" "}}if(pe.test(i)===!0){const[c,b=Q]=i.split("|");return{svg:!0,viewBox:b,nodes:c.split("&&").map(l=>{const[y,g,q]=l.split("@@");return d("path",{style:g,d:y,transform:q})})}}if(Ee.test(i)===!0)return{img:!0,src:i.substring(4)};if(we.test(i)===!0){const[c,b=Q]=i.split("|");return{svguse:!0,src:c.substring(7),viewBox:b}}let x=" ";const E=i.match(xe);if(E!==null)r=J[E[1]](i);else if(Se.test(i)===!0)r=i;else if($e.test(i)===!0)r=`ionicons ion-${a.platform.is.ios===!0?"ios":"md"}${i.substring(3)}`;else if(D.test(i)===!0){r="notranslate material-symbols";const c=i.match(D);c!==null&&(i=i.substring(6),r+=ee[c[1]]),x=i}else{r="notranslate material-icons";const c=i.match(qe);c!==null&&(i=i.substring(2),r+=Z[c[1]]),x=i}return{cls:r,content:x}});return()=>{const r={class:o.value,style:u.value,"aria-hidden":"true"};return f.value.none===!0?d(e.tag,r,ye(t.default)):f.value.img===!0?d(e.tag,r,L(t.default,[d("img",{src:f.value.src})])):f.value.svg===!0?d(e.tag,r,L(t.default,[d("svg",{viewBox:f.value.viewBox||"0 0 24 24"},f.value.nodes)])):f.value.svguse===!0?d(e.tag,r,L(t.default,[d("svg",{viewBox:f.value.viewBox},[d("use",{"xlink:href":f.value.src})])])):(f.value.cls!==void 0&&(r.class+=" "+f.value.cls),d(e.tag,r,L(t.default,[f.value.content])))}}}),Be={size:{type:[String,Number],default:"1em"},color:String};function _e(e){return{cSize:m(()=>e.size in A?`${A[e.size]}px`:e.size),classes:m(()=>"q-spinner"+(e.color?` text-${e.color}`:""))}}const Re=N({name:"QSpinner",props:{...Be,thickness:{type:Number,default:5}},setup(e){const{cSize:t,classes:a}=_e(e);return()=>d("svg",{class:a.value+" q-spinner-mat",width:t.value,height:t.value,viewBox:"25 25 50 50"},[d("circle",{class:"path",cx:"50",cy:"50",r:"20",fill:"none",stroke:"currentColor","stroke-width":e.thickness,"stroke-miterlimit":"10"})])}});function Ce(e,t){const a=e.style;for(const u in t)a[u]=t[u]}function Ve(e){if(e==null)return;if(typeof e=="string")try{return document.querySelector(e)||void 0}catch{return}const t=re(e);if(t)return t.$el||t}function We(e,t){if(e==null||e.contains(t)===!0)return!0;for(let a=e.nextElementSibling;a!==null;a=a.nextElementSibling)if(a.contains(t))return!0;return!1}function Le(e,t=250){let a=!1,u;return function(){return a===!1&&(a=!0,setTimeout(()=>{a=!1},t),u=e.apply(this,arguments)),u}}function U(e,t,a,u){a.modifiers.stop===!0&&X(e);const o=a.modifiers.color;let f=a.modifiers.center;f=f===!0||u===!0;const r=document.createElement("span"),i=document.createElement("span"),x=de(e),{left:E,top:c,width:b,height:l}=t.getBoundingClientRect(),y=Math.sqrt(b*b+l*l),g=y/2,q=`${(b-y)/2}px`,s=f?q:`${x.left-E-g}px`,h=`${(l-y)/2}px`,P=f?h:`${x.top-c-g}px`;i.className="q-ripple__inner",Ce(i,{height:`${y}px`,width:`${y}px`,transform:`translate3d(${s},${P},0) scale3d(.2,.2,1)`,opacity:0}),r.className=`q-ripple${o?" text-"+o:""}`,r.setAttribute("dir","ltr"),r.appendChild(i),t.appendChild(r);const T=()=>{r.remove(),clearTimeout(_)};a.abort.push(T);let _=setTimeout(()=>{i.classList.add("q-ripple__inner--enter"),i.style.transform=`translate3d(${q},${h},0) scale3d(1,1,1)`,i.style.opacity=.2,_=setTimeout(()=>{i.classList.remove("q-ripple__inner--enter"),i.classList.add("q-ripple__inner--leave"),i.style.opacity=0,_=setTimeout(()=>{r.remove(),a.abort.splice(a.abort.indexOf(T),1)},275)},250)},50)}function V(e,{modifiers:t,value:a,arg:u}){const o=Object.assign({},e.cfg.ripple,t,a);e.modifiers={early:o.early===!0,stop:o.stop===!0,center:o.center===!0,color:o.color||u,keyCodes:[].concat(o.keyCodes||13)}}const Te=se({name:"ripple",beforeMount(e,t){const a=t.instance.$.appContext.config.globalProperties.$q.config||{};if(a.ripple===!1)return;const u={cfg:a,enabled:t.value!==!1,modifiers:{},abort:[],start(o){u.enabled===!0&&o.qSkipRipple!==!0&&o.type===(u.modifiers.early===!0?"pointerdown":"click")&&U(o,e,u,o.qKeyEvent===!0)},keystart:Le(o=>{u.enabled===!0&&o.qSkipRipple!==!0&&O(o,u.modifiers.keyCodes)===!0&&o.type===`key${u.modifiers.early===!0?"down":"up"}`&&U(o,e,u,!0)},300)};V(u,t),e.__qripple=u,ce(u,"main",[[e,"pointerdown","start","passive"],[e,"click","start","passive"],[e,"keydown","keystart","passive"],[e,"keyup","keystart","passive"]])},updated(e,t){if(t.oldValue!==t.value){const a=e.__qripple;a!==void 0&&(a.enabled=t.value!==!1,a.enabled===!0&&Object(t.value)===t.value&&V(a,t))}},beforeUnmount(e){const t=e.__qripple;t!==void 0&&(t.abort.forEach(a=>{a()}),oe(t,"main"),delete e._qripple)}}),te={left:"start",center:"center",right:"end",between:"between",around:"around",evenly:"evenly",stretch:"stretch"},Me=Object.keys(te),Pe={align:{type:String,validator:e=>Me.includes(e)}};function ze(e){return m(()=>{const t=e.align===void 0?e.vertical===!0?"stretch":"left":e.align;return`${e.vertical===!0?"items":"justify"}-${te[t]}`})}const W={none:0,xs:4,sm:8,md:16,lg:24,xl:32},je={xs:8,sm:10,md:14,lg:20,xl:24},Oe=["button","submit","reset"],Ae=/[^\s]\/[^\s]/,Ne=["flat","outline","push","unelevated"];function Fe(e,t){return e.flat===!0?"flat":e.outline===!0?"outline":e.push===!0?"push":e.unelevated===!0?"unelevated":t}const Ke={...Y,...he,type:{type:String,default:"button"},label:[Number,String],icon:String,iconRight:String,...Ne.reduce((e,t)=>(e[t]=Boolean)&&e,{}),square:Boolean,rounded:Boolean,glossy:Boolean,size:String,fab:Boolean,fabMini:Boolean,padding:String,color:String,textColor:String,noCaps:Boolean,noWrap:Boolean,dense:Boolean,tabindex:[Number,String],ripple:{type:[Boolean,Object],default:!0},align:{...Pe.align,default:"center"},stack:Boolean,stretch:Boolean,loading:{type:Boolean,default:null},disable:Boolean},Qe={...Ke,round:Boolean};function De(e){const t=G(e,je),a=ze(e),{hasRouterLink:u,hasLink:o,linkTag:f,linkAttrs:r,navigateOnClick:i}=ke({fallbackTag:"button"}),x=m(()=>{const s=e.fab===!1&&e.fabMini===!1?t.value:{};return e.padding!==void 0?Object.assign({},s,{padding:e.padding.split(/\s+/).map(h=>h in W?W[h]+"px":h).join(" "),minWidth:"0",minHeight:"0"}):s}),E=m(()=>e.rounded===!0||e.fab===!0||e.fabMini===!0),c=m(()=>e.disable!==!0&&e.loading!==!0),b=m(()=>c.value===!0?e.tabindex||0:-1),l=m(()=>Fe(e,"standard")),y=m(()=>{const s={tabindex:b.value};return o.value===!0?Object.assign(s,r.value):Oe.includes(e.type)===!0&&(s.type=e.type),f.value==="a"?(e.disable===!0?s["aria-disabled"]="true":s.href===void 0&&(s.role="button"),u.value!==!0&&Ae.test(e.type)===!0&&(s.type=e.type)):e.disable===!0&&(s.disabled="",s["aria-disabled"]="true"),e.loading===!0&&e.percentage!==void 0&&Object.assign(s,{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e.percentage}),s}),g=m(()=>{let s;e.color!==void 0?e.flat===!0||e.outline===!0?s=`text-${e.textColor||e.color}`:s=`bg-${e.color} text-${e.textColor||"white"}`:e.textColor&&(s=`text-${e.textColor}`);const h=e.round===!0?"round":`rectangle${E.value===!0?" q-btn--rounded":e.square===!0?" q-btn--square":""}`;return`q-btn--${l.value} q-btn--${h}`+(s!==void 0?" "+s:"")+(c.value===!0?" q-btn--actionable q-focusable q-hoverable":e.disable===!0?" disabled":"")+(e.fab===!0?" q-btn--fab":e.fabMini===!0?" q-btn--fab-mini":"")+(e.noCaps===!0?" q-btn--no-uppercase":"")+(e.dense===!0?" q-btn--dense":"")+(e.stretch===!0?" no-border-radius self-stretch":"")+(e.glossy===!0?" glossy":"")+(e.square?" q-btn--square":"")}),q=m(()=>a.value+(e.stack===!0?" column":" row")+(e.noWrap===!0?" no-wrap text-no-wrap":"")+(e.loading===!0?" q-btn__content--hidden":""));return{classes:g,style:x,innerClasses:q,attributes:y,hasLink:o,linkTag:f,navigateOnClick:i,isActionable:c}}const{passiveCapture:k}=fe;let $=null,S=null,B=null;const He=N({name:"QBtn",props:{...Qe,percentage:Number,darkPercentage:Boolean,onTouchstart:[Function,Array]},emits:["click","keydown","mousedown","keyup"],setup(e,{slots:t,emit:a}){const{proxy:u}=H(),{classes:o,style:f,innerClasses:r,attributes:i,hasLink:x,linkTag:E,navigateOnClick:c,isActionable:b}=De(e),l=K(null),y=K(null);let g=null,q,s=null;const h=m(()=>e.label!==void 0&&e.label!==null&&e.label!==""),P=m(()=>e.disable===!0||e.ripple===!1?!1:{keyCodes:x.value===!0?[13,32]:[13],...e.ripple===!0?{}:e.ripple}),T=m(()=>({center:e.round})),_=m(()=>{const n=Math.max(0,Math.min(100,e.percentage));return n>0?{transition:"transform 0.6s",transform:`translateX(${n-100}%)`}:{}}),ne=m(()=>{if(e.loading===!0)return{onMousedown:C,onTouchstart:C,onClick:C,onKeydown:C,onKeyup:C};if(b.value===!0){const n={onClick:F,onKeydown:ie,onMousedown:ue};if(u.$q.platform.has.touch===!0){const v=e.onTouchstart!==void 0?"":"Passive";n[`onTouchstart${v}`]=le}return n}return{onClick:w}}),ae=m(()=>({ref:l,class:"q-btn q-btn-item non-selectable no-outline "+o.value,style:f.value,...i.value,...ne.value}));function F(n){if(l.value!==null){if(n!==void 0){if(n.defaultPrevented===!0)return;const v=document.activeElement;if(e.type==="submit"&&v!==document.body&&l.value.contains(v)===!1&&v.contains(l.value)===!1){n.qAvoidFocus!==!0&&l.value.focus();const M=()=>{document.removeEventListener("keydown",w,!0),document.removeEventListener("keyup",M,k),l.value?.removeEventListener("blur",M,k)};document.addEventListener("keydown",w,!0),document.addEventListener("keyup",M,k),l.value.addEventListener("blur",M,k)}}c(n)}}function ie(n){l.value!==null&&(a("keydown",n),O(n,[13,32])===!0&&S!==l.value&&(S!==null&&R(),n.defaultPrevented!==!0&&(n.qAvoidFocus!==!0&&l.value.focus(),S=l.value,l.value.classList.add("q-btn--active"),document.addEventListener("keyup",p,!0),l.value.addEventListener("blur",p,k)),w(n)))}function le(n){l.value!==null&&(a("touchstart",n),n.defaultPrevented!==!0&&($!==l.value&&($!==null&&R(),$=l.value,g=n.target,g.addEventListener("touchcancel",p,k),g.addEventListener("touchend",p,k)),q=!0,s!==null&&clearTimeout(s),s=setTimeout(()=>{s=null,q=!1},200)))}function ue(n){l.value!==null&&(n.qSkipRipple=q===!0,a("mousedown",n),n.defaultPrevented!==!0&&B!==l.value&&(B!==null&&R(),B=l.value,l.value.classList.add("q-btn--active"),document.addEventListener("mouseup",p,k)))}function p(n){if(l.value!==null&&!(n?.type==="blur"&&document.activeElement===l.value)){if(n?.type==="keyup"){if(S===l.value&&O(n,[13,32])===!0){const v=new MouseEvent("click",n);v.qKeyEvent=!0,n.defaultPrevented===!0&&ve(v),n.cancelBubble===!0&&X(v),l.value.dispatchEvent(v),w(n),n.qKeyEvent=!0}a("keyup",n)}R()}}function R(n){const v=y.value;n!==!0&&($===l.value||B===l.value)&&v!==null&&v!==document.activeElement&&(v.setAttribute("tabindex",-1),v.focus()),$===l.value&&(g!==null&&(g.removeEventListener("touchcancel",p,k),g.removeEventListener("touchend",p,k)),$=g=null),B===l.value&&(document.removeEventListener("mouseup",p,k),B=null),S===l.value&&(document.removeEventListener("keyup",p,!0),l.value?.removeEventListener("blur",p,k),S=null),l.value?.classList.remove("q-btn--active")}function C(n){w(n),n.qSkipRipple=!0}return me(()=>{R(!0)}),Object.assign(u,{click:n=>{b.value===!0&&F(n)}}),()=>{let n=[];e.icon!==void 0&&n.push(d(I,{name:e.icon,left:e.stack!==!0&&h.value===!0,role:"img"})),h.value===!0&&n.push(d("span",{class:"block"},[e.label])),n=L(t.default,n),e.iconRight!==void 0&&e.round===!1&&n.push(d(I,{name:e.iconRight,right:e.stack!==!0&&h.value===!0,role:"img"}));const v=[d("span",{class:"q-focus-helper",ref:y})];return e.loading===!0&&e.percentage!==void 0&&v.push(d("span",{class:"q-btn__progress absolute-full overflow-hidden"+(e.darkPercentage===!0?" q-btn__progress--dark":"")},[d("span",{class:"q-btn__progress-indicator fit block",style:_.value})])),v.push(d("span",{class:"q-btn__content text-center col items-center q-anchor--skip "+r.value},n)),e.loading!==null&&v.push(d(ge,{name:"q-transition--fade"},()=>e.loading===!0?[d("span",{key:"loading",class:"absolute-full flex flex-center"},t.loading!==void 0?t.loading():[d(Re)])]:null)),be(d(E.value,ae.value,v),[[Te,P.value,void 0,T.value]])}}});export{He as Q,Te as R,G as a,I as b,Re as c,We as d,Pe as e,ze as f,Ve as g,Ce as h,Y as u};
|