index-legacy-369babc4.js 3.3 KB

1
  1. System.register(["./index-legacy-e1ea41b7.js"],(function(e,l){"use strict";var a,t,u,n,i,o,s,r,d,m,c,v,p,b,g,h,S,f,x,w,y,V,P,T,B;return{setters:[e=>{a=e.c,t=e.b,u=e.t,n=e.n,i=e.d,o=e.r,s=e.e,r=e.o,d=e.aU,m=e.w,c=e.a3,v=e.a,p=e.g,b=e.v,g=e.h,h=e.H,S=e.bg,f=e.X,x=e.z,w=e.bh,y=e.p,V=e.a0,P=e.aT,T=e.b8,B=e.k}],execute:function(){const[l,I]=a("stepper"),M=(e,l)=>String(e)===String(l),C={min:t(1),max:t(1/0),name:t(""),step:t(1),theme:String,integer:Boolean,disabled:Boolean,showPlus:u,showMinus:u,showInput:u,longPress:u,autoFixed:u,allowEmpty:Boolean,modelValue:n,inputWidth:n,buttonSize:n,placeholder:String,disablePlus:Boolean,disableMinus:Boolean,disableInput:Boolean,beforeChange:Function,defaultValue:t(1),decimalLength:n};var F=i({name:l,props:C,emits:["plus","blur","minus","focus","change","overlimit","update:modelValue"],setup(e,{emit:l}){const a=(l,a=!0)=>{const{min:t,max:u,allowEmpty:n,decimalLength:i}=e;return n&&""===l||(l=""===(l=S(String(l),!e.integer))?0:+l,l=Number.isNaN(l)?+t:l,l=a?Math.max(Math.min(+u,l),+t):l,f(i)&&(l=l.toFixed(+i))),l};let t;const u=o(),n=o((()=>{var t;const u=null!=(t=e.modelValue)?t:e.defaultValue,n=a(u);return M(n,e.modelValue)||l("update:modelValue",n),n})()),i=s((()=>e.disabled||e.disableMinus||+n.value<=+e.min)),B=s((()=>e.disabled||e.disablePlus||+n.value>=+e.max)),C=s((()=>({width:r(e.inputWidth),height:r(e.buttonSize)}))),F=s((()=>d(e.buttonSize))),z=l=>{e.beforeChange?V(e.beforeChange,{args:[l],done(){n.value=l}}):n.value=l},L=()=>{if("plus"===t&&B.value||"minus"===t&&i.value)return void l("overlimit",t);const u="minus"===t?-e.step:+e.step,o=a(P(+n.value,u));z(o),l(t)},N=l=>{const a=l.target,{value:t}=a,{decimalLength:u}=e;let i=S(String(t),!e.integer);if(f(u)&&i.includes(".")){const e=i.split(".");i=`${e[0]}.${e[1].slice(0,+u)}`}e.beforeChange?a.value=String(n.value):M(t,i)||(a.value=i);const o=i===String(+i);z(o?+i:i)},k=a=>{var t;e.disableInput?null==(t=u.value)||t.blur():l("focus",a)},E=t=>{const u=t.target,i=a(u.value,e.autoFixed);u.value=String(i),n.value=i,x((()=>{l("blur",t),w()}))};let W,$;const j=()=>{$=setTimeout((()=>{L(),j()}),200)},H=l=>{e.longPress&&(clearTimeout($),W&&y(l))},U=l=>{e.disableInput&&y(l)},X=l=>({onClick:e=>{y(e),t=l,L()},onTouchstartPassive:()=>{t=l,e.longPress&&(W=!1,clearTimeout($),$=setTimeout((()=>{W=!0,L(),j()}),T))},onTouchend:H,onTouchcancel:H});return m((()=>[e.max,e.min,e.integer,e.decimalLength]),(()=>{const e=a(n.value);M(e,n.value)||(n.value=e)})),m((()=>e.modelValue),(e=>{M(e,n.value)||(n.value=a(e))})),m(n,(a=>{l("update:modelValue",a),l("change",a,{name:e.name})})),c((()=>e.modelValue)),()=>v("div",{role:"group",class:I([e.theme])},[p(v("button",g({type:"button",style:F.value,class:[I("minus",{disabled:i.value}),{[h]:!i.value}],"aria-disabled":i.value||void 0},X("minus")),null),[[b,e.showMinus]]),p(v("input",{ref:u,type:e.integer?"tel":"text",role:"spinbutton",class:I("input"),value:n.value,style:C.value,disabled:e.disabled,readonly:e.disableInput,inputmode:e.integer?"numeric":"decimal",placeholder:e.placeholder,"aria-valuemax":e.max,"aria-valuemin":e.min,"aria-valuenow":n.value,onBlur:E,onInput:N,onFocus:k,onMousedown:U},null),[[b,e.showInput]]),p(v("button",g({type:"button",style:F.value,class:[I("plus",{disabled:B.value}),{[h]:!B.value}],"aria-disabled":B.value||void 0},X("plus")),null),[[b,e.showPlus]])])}});e("S",B(F))}}}));