@robin-rossow/vue-input-number 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2,4 +2,4 @@
2
2
  object-assign
3
3
  (c) Sindre Sorhus
4
4
  @license MIT
5
- */var O=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;function A(t){if(t==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function T(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de",Object.getOwnPropertyNames(t)[0]==="5")return!1;for(var r={},e=0;e<10;e++)r["_"+String.fromCharCode(e)]=e;var n=Object.getOwnPropertyNames(r).map(function(u){return r[u]});if(n.join("")!=="0123456789")return!1;var a={};return"abcdefghijklmnopqrst".split("").forEach(function(u){a[u]=u}),Object.keys(Object.assign({},a)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}var F=T()?Object.assign:function(t,r){for(var e,n=A(t),a,u=1;u<arguments.length;u++){e=Object(arguments[u]);for(var c in e)I.call(e,c)&&(n[c]=e[c]);if(O){a=O(e);for(var s=0;s<a.length;s++)M.call(e,a[s])&&(n[a[s]]=e[a[s]])}}return n};const S=j(F);var k=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var r={},e=Symbol("test"),n=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var a=42;r[e]=a;for(e in r)return!1;if(typeof Object.keys=="function"&&Object.keys(r).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(r).length!==0)return!1;var u=Object.getOwnPropertySymbols(r);if(u.length!==1||u[0]!==e||!Object.prototype.propertyIsEnumerable.call(r,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var c=Object.getOwnPropertyDescriptor(r,e);if(c.value!==a||c.enumerable!==!0)return!1}return!0},x=k,$=function(){return x()&&!!Symbol.toStringTag},C=String.prototype.valueOf,D=function(r){try{return C.call(r),!0}catch{return!1}},B=Object.prototype.toString,U="[object String]",q=$(),H=function(r){return typeof r=="string"?!0:typeof r!="object"?!1:q?D(r):B.call(r)===U};const R=j(H);function Z(t){return R(t)&&t.match("%v")?{pos:t,neg:t.replace("-","").replace("%v","-%v"),zero:t}:t}const f={symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3,stripZeros:!1,fallback:0};function z(t,r){const e=t.split(r),n=e[0],a=e[1].replace(/0+$/,"");return a.length>0?n+r+a:n}function G(t,r){return t=Math.round(Math.abs(t)),isNaN(t)?r:t}function d(t,r){r=G(r,f.precision);const e=Math.pow(10,r);return(Math.round((t+1e-8)*e)/e).toFixed(r)}function N(t,r={}){if(Array.isArray(t))return t.map(c=>N(c,r));r=S({},f,r);const e=t<0?"-":"",n=parseInt(d(Math.abs(t),r.precision),10)+"",a=n.length>3?n.length%3:0,u=e+(a?n.substr(0,a)+r.thousand:"")+n.substr(a).replace(/(\d{3})(?=\d)/g,"$1"+r.thousand)+(r.precision>0?r.decimal+d(Math.abs(t),r.precision).split(".")[1]:"");return r.stripZeros?z(u,r.decimal):u}function h(t,r={}){if(Array.isArray(t))return t.map(a=>h(a,r));r=S({},f,r);const e=Z(r.format);let n;return t>0?n=e.pos:t<0?n=e.neg:n=e.zero,n.replace("%s",r.symbol).replace("%v",N(Math.abs(t),r))}function w(t,r=f.decimal,e=f.fallback){if(Array.isArray(t))return t.map(p=>w(p,r,e));if(typeof t=="number")return t;const n=new RegExp("[^0-9-(-)-"+r+"]",["g"]),a=(""+t).replace(n,"").replace(r,".").replace(/\(([-]*\d*[^)]?\d+)\)/g,"-$1").replace(/\((.*)\)/,""),u=(a.match(/-/g)||2).length%2,c=parseFloat(a.replace(/-/g,"")),s=c*(u?-1:1);return isNaN(s)?e:s}const L=["value"],P=i.defineComponent({__name:"VueInputNumber",props:{modelValue:{},outputType:{default:"Number"},min:{default:Number.MIN_SAFE_INTEGER},max:{default:Number.MAX_SAFE_INTEGER},precision:{default:0},thousandSeparator:{default:","},decimalSeparator:{default:"."},currency:{default:""},currencySymbolPosition:{default:"prefix"},emptyValue:{default:""}},emits:["update:modelValue","blur","focus"],setup(t,{emit:r}){const e=t,n=i.ref(""),a=i.ref(!1),u=i.ref(),c=i.computed(()=>v(n.value)),s=i.computed(()=>v(e.modelValue)),p=i.computed(()=>e.currency?e.currencySymbolPosition==="suffix"?"%v %s":"%s %v":"%v");m(s.value),n.value=b(s.value),i.watch(e,()=>{a.value||(m(s.value),n.value=b(s.value))});function _(o){a.value=!1,r("blur",o),n.value=b(s.value)}function V(o){if(a.value=!0,r("focus",o),typeof s.value=="string"&&s.value==="")return"";n.value=h(s.value,{symbol:"",format:"%v",thousand:"",decimal:e.decimalSeparator,precision:Number(e.precision)})}function E(){m(c.value)}function m(o){if(typeof o=="string"&&o==="")r("update:modelValue",o);else{if(o=Number(o),o>=e.max){y(e.max);return}if(o<=e.min){y(e.min);return}if(o>e.min&&o<e.max){y(o);return}}}function y(o){const l=d(o,e.precision),g=e.outputType.toLowerCase()==="string"?l:Number(l);r("update:modelValue",g)}function b(o){return typeof o=="string"&&o===""?"":h(o,{symbol:e.currency,format:p.value,precision:Number(e.precision),decimal:e.decimalSeparator,thousand:e.thousandSeparator})}function v(o){if(o===void 0)return o;const l=typeof o=="string"&&o===""?e.emptyValue:o;return typeof l=="string"&&l===""?"":w(l,e.decimalSeparator)}return(o,l)=>i.withDirectives((i.openBlock(),i.createElementBlock("input",i.mergeProps(o.$attrs,{ref_key:"inputElement",ref:u,"onUpdate:modelValue":l[0]||(l[0]=g=>n.value=g),value:n.value,onBlur:_,onInput:E,onFocus:V}),null,16,L)),[[i.vModelDynamic,n.value]])}}),X={install:t=>{t.component("VueInputNumber",P)}};exports.VueInputNumber=P;exports.default=X;
5
+ */var O=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;function A(t){if(t==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}function T(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de",Object.getOwnPropertyNames(t)[0]==="5")return!1;for(var r={},e=0;e<10;e++)r["_"+String.fromCharCode(e)]=e;var n=Object.getOwnPropertyNames(r).map(function(u){return r[u]});if(n.join("")!=="0123456789")return!1;var a={};return"abcdefghijklmnopqrst".split("").forEach(function(u){a[u]=u}),Object.keys(Object.assign({},a)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}var F=T()?Object.assign:function(t,r){for(var e,n=A(t),a,u=1;u<arguments.length;u++){e=Object(arguments[u]);for(var c in e)I.call(e,c)&&(n[c]=e[c]);if(O){a=O(e);for(var s=0;s<a.length;s++)M.call(e,a[s])&&(n[a[s]]=e[a[s]])}}return n};const S=j(F);var k=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var r={},e=Symbol("test"),n=Object(e);if(typeof e=="string"||Object.prototype.toString.call(e)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var a=42;r[e]=a;for(e in r)return!1;if(typeof Object.keys=="function"&&Object.keys(r).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(r).length!==0)return!1;var u=Object.getOwnPropertySymbols(r);if(u.length!==1||u[0]!==e||!Object.prototype.propertyIsEnumerable.call(r,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var c=Object.getOwnPropertyDescriptor(r,e);if(c.value!==a||c.enumerable!==!0)return!1}return!0},x=k,$=function(){return x()&&!!Symbol.toStringTag},C=String.prototype.valueOf,D=function(r){try{return C.call(r),!0}catch{return!1}},B=Object.prototype.toString,U="[object String]",q=$(),H=function(r){return typeof r=="string"?!0:typeof r!="object"?!1:q?D(r):B.call(r)===U};const R=j(H);function Z(t){return R(t)&&t.match("%v")?{pos:t,neg:t.replace("-","").replace("%v","-%v"),zero:t}:t}const f={symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3,stripZeros:!1,fallback:0};function z(t,r){const e=t.split(r),n=e[0],a=e[1].replace(/0+$/,"");return a.length>0?n+r+a:n}function G(t,r){return t=Math.round(Math.abs(t)),isNaN(t)?r:t}function d(t,r){r=G(r,f.precision);const e=Math.pow(10,r);return(Math.round((t+1e-8)*e)/e).toFixed(r)}function N(t,r={}){if(Array.isArray(t))return t.map(c=>N(c,r));r=S({},f,r);const e=t<0?"-":"",n=parseInt(d(Math.abs(t),r.precision),10)+"",a=n.length>3?n.length%3:0,u=e+(a?n.substr(0,a)+r.thousand:"")+n.substr(a).replace(/(\d{3})(?=\d)/g,"$1"+r.thousand)+(r.precision>0?r.decimal+d(Math.abs(t),r.precision).split(".")[1]:"");return r.stripZeros?z(u,r.decimal):u}function h(t,r={}){if(Array.isArray(t))return t.map(a=>h(a,r));r=S({},f,r);const e=Z(r.format);let n;return t>0?n=e.pos:t<0?n=e.neg:n=e.zero,n.replace("%s",r.symbol).replace("%v",N(Math.abs(t),r))}function w(t,r=f.decimal,e=f.fallback){if(Array.isArray(t))return t.map(p=>w(p,r,e));if(typeof t=="number")return t;const n=new RegExp("[^0-9-(-)-"+r+"]",["g"]),a=(""+t).replace(n,"").replace(r,".").replace(/\(([-]*\d*[^)]?\d+)\)/g,"-$1").replace(/\((.*)\)/,""),u=(a.match(/-/g)||2).length%2,c=parseFloat(a.replace(/-/g,"")),s=c*(u?-1:1);return isNaN(s)?e:s}const L=["value"],P=i.defineComponent({__name:"VueInputNumber",props:{modelValue:{},outputType:{default:"Number"},min:{default:Number.MIN_SAFE_INTEGER},max:{default:Number.MAX_SAFE_INTEGER},precision:{default:0},thousandSeparator:{default:","},decimalSeparator:{default:"."},currency:{default:""},currencySymbolPosition:{default:"prefix"},emptyValue:{default:""}},emits:["update:modelValue","blur","focus"],setup(t,{emit:r}){const e=t,n=i.ref(""),a=i.ref(!1),u=i.ref(),c=i.computed(()=>v(n.value)),s=i.computed(()=>v(e.modelValue)),p=i.computed(()=>e.currency?e.currencySymbolPosition==="suffix"?"%v %s":"%s %v":"%v");m(s.value),n.value=b(s.value),i.watch(e,()=>{a.value||(m(s.value),n.value=b(s.value))});function _(o){a.value=!1,r("blur",o),n.value=b(s.value)}function V(o){if(a.value=!0,r("focus",o),typeof s.value=="string"&&s.value==="")return"";n.value=h(s.value,{symbol:"",format:"%v",thousand:"",decimal:e.decimalSeparator,precision:Number(e.precision)})}function E(){m(c.value)}function m(o){if(o!==void 0)if(typeof o=="string"&&o==="")r("update:modelValue",o);else{if(o=Number(o),o>=e.max){y(e.max);return}if(o<=e.min){y(e.min);return}if(o>e.min&&o<e.max){y(o);return}}}function y(o){const l=d(o,e.precision),g=e.outputType.toLowerCase()==="string"?l:Number(l);r("update:modelValue",g)}function b(o){return typeof o=="string"&&o===""?"":h(o,{symbol:e.currency,format:p.value,precision:Number(e.precision),decimal:e.decimalSeparator,thousand:e.thousandSeparator})}function v(o){if(o===void 0)return o;const l=typeof o=="string"&&o===""?e.emptyValue:o;return typeof l=="string"&&l===""?"":w(l,e.decimalSeparator)}return(o,l)=>i.withDirectives((i.openBlock(),i.createElementBlock("input",i.mergeProps(o.$attrs,{ref_key:"inputElement",ref:u,"onUpdate:modelValue":l[0]||(l[0]=g=>n.value=g),value:n.value,onBlur:_,onInput:E,onFocus:V}),null,16,L)),[[i.vModelDynamic,n.value]])}}),X={install:t=>{t.component("VueInputNumber",P)}};exports.VueInputNumber=P;exports.default=X;
package/dist/index.js CHANGED
@@ -190,22 +190,23 @@ const ee = ["value"], re = /* @__PURE__ */ I({
190
190
  p(i.value);
191
191
  }
192
192
  function p(o) {
193
- if (typeof o == "string" && o === "")
194
- r("update:modelValue", o);
195
- else {
196
- if (o = Number(o), o >= e.max) {
197
- m(e.max);
198
- return;
193
+ if (o !== void 0)
194
+ if (typeof o == "string" && o === "")
195
+ r("update:modelValue", o);
196
+ else {
197
+ if (o = Number(o), o >= e.max) {
198
+ m(e.max);
199
+ return;
200
+ }
201
+ if (o <= e.min) {
202
+ m(e.min);
203
+ return;
204
+ }
205
+ if (o > e.min && o < e.max) {
206
+ m(o);
207
+ return;
208
+ }
199
209
  }
200
- if (o <= e.min) {
201
- m(e.min);
202
- return;
203
- }
204
- if (o > e.min && o < e.max) {
205
- m(o);
206
- return;
207
- }
208
- }
209
210
  }
210
211
  function m(o) {
211
212
  const c = h(o, e.precision), b = e.outputType.toLowerCase() === "string" ? c : Number(c);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@robin-rossow/vue-input-number",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "keywords": [
5
5
  "component",
6
6
  "currency",