2 lines
3.1 KiB
JavaScript
2 lines
3.1 KiB
JavaScript
|
"use strict";var e=Object.defineProperty,t=Object.defineProperties,n=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,a=(t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i;const r=require("../../../../common/vendor.js");if(!Array){r.resolveComponent("wd-icon")()}Math;const s=r.defineComponent((l=((e,t)=>{for(var n in t||(t={}))u.call(t,n)&&a(e,n,t[n]);if(i)for(var n of i(t))o.call(t,n)&&a(e,n,t[n]);return e})({},{name:"wd-input-number",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"}}),c={props:r.inputNumberProps,emits:["focus","blur","change","update:modelValue"],setup(e,{emit:t}){const n=e,i=t,u=r.ref(!1),o=r.ref(!1),a=r.ref("");function s(e){const{disabled:t,min:i,max:a,step:r}=n;u.value=t||Number(e)<=i||p(e,-r)<i,o.value=t||Number(e)>=a||p(e,r)>a}function l(e){return Number(parseFloat(""+Math.round(e*Math.pow(10,n.precision))/Math.pow(10,n.precision)).toFixed(n.precision))}function c(e){const t=function(e){if(void 0===e)return 0;const t=e.toString(),n=t.indexOf(".");let i=0;return-1!==n&&(i=t.length-n-1),i}(n.step),i=Math.pow(10,t);return Math.round(Number(e)/n.step)*i*n.step/i}function d(e,t=!0){!n.allowNull||r.isDef(e)&&""!==e?(n.stepStrictly&&(e=c(e)),!e&&0!==e||void 0===n.precision||(e=l(Number(e))),Number(e)>n.max&&(e=l(n.max)),Number(e)<n.min&&(e=l(n.min)),h(e,t)):h(e,t)}function p(e,t){if(e=Number(e),isNaN(e))return n.min;const i=Math.pow(10,n.precision);return l((e*i+t*i)/i)}function m(){u.value||n.disableMinus||h(p(a.value,-n.step))}function b(){o.value||n.disablePlus||h(p(a.value,n.step))}function v(e){h(e.detail.value||"")}function f(e){i("focus",e.detail)}function w(){const e=N(a.value);r.isEqual(a.value,e)||d(e),i("blur",{value:e})}function h(e,t=!0){r.isEqual(a.value,e)||(a.value=e,t&&i("update:modelValue",a.value),t&&i("change",{value:e}))}function N(e){return!n.allowNull||r.isDef(e)&&""!==e?(e=Number(e),isNaN(e)&&(e=n.min),n.stepStrictly&&(e=c(e)),void 0!==n.precision&&(e=e.toFixed(n.precision)),Number(e)):""}return r.watch((()=>n.modelValue),(e=>{a.value=e,s(e)}),{immediate:!0,deep:!0}),r.watch([()=>n.max,()=>n.min],(()=>{r.debounce((()=>{const e=N(a.value);r.isEqual(a.value,e)||d(e),s(e)}),30)()}),{immediate:!0,deep:!0}),r.watch((()=>n.disabled),(e=>{u.value=e,o.value=e}),{immediate:!0,deep:!0}),(e,t)=>r.e({a:r.p({name:"decrease","custom-class":"wd-input-number__action-icon"}),b:r.n("wd-input-number__action "+(u.value||e.disableMinus?"is-disabled":"")),c:r.o(m),d:!e.withoutInput},e.withoutInput?{}:{e:r.s(e.inputWidth?"width: "+e.inputWidth:""),f:e.disabled||e.disableInput,g:e.placeholder,h:r.o([e=>a.value=e.detail.value,v]),i:r.o(f),j:r.o(w),k:a.value,l:r.o((()=>{}))},{m:r.p({name:"add","custom-class":"wd-input-number__action-icon"}),n:r.n("wd-input-number__action "+(o.value||e.disablePlus?"is-disabled":"")),o:r.o(b),p:r.n(`wd-input-number ${e.customClass} ${e.disabled?"is-disabled":""} ${e.withoutInput?"is-without-input":""}`),q:r.s(e.customStyle)})}},t(l,n(c))));var l,c;const d=r._export_sfc(s,[["__scopeId","data-v-e3f783e6"]]);wx.createComponent(d);
|