@robin-rossow/vue-input-number 1.0.7 → 1.0.9
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/README.md +12 -12
- package/dist/index.cjs +2 -2
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,18 +36,18 @@ import { VueInputNumber } from '@robin-rossow/vue-input-number'
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
### Props
|
|
39
|
-
| Props | Required | Type
|
|
40
|
-
|
|
41
|
-
| v-model | ✅ | string | number
|
|
42
|
-
| outputType | ❌ | 'Number' | 'String'
|
|
43
|
-
| min | ❌ | number
|
|
44
|
-
| max | ❌ | number
|
|
45
|
-
| precision | ❌ | number
|
|
46
|
-
| thousandSeparator | ❌ | string | undefined
|
|
47
|
-
| decimalSeparator | ❌ | string | undefined
|
|
48
|
-
| currency | ❌ | string
|
|
49
|
-
| currencySymbolPosition | ❌ | 'prefix' |' suffix'
|
|
50
|
-
| emptyValue | ❌ | number | ''
|
|
39
|
+
| Props | Required | Type | Default |
|
|
40
|
+
|------------------------|----------|---------------------------------------|-------------------------|
|
|
41
|
+
| v-model | ✅ | string | number | undefined | - |
|
|
42
|
+
| outputType | ❌ | 'Number' | 'String' | 'Number' |
|
|
43
|
+
| min | ❌ | number | Number.MIN_SAFE_INTEGER |
|
|
44
|
+
| max | ❌ | number | Number.MAX_SAFE_INTEGER |
|
|
45
|
+
| precision | ❌ | number | 0 |
|
|
46
|
+
| thousandSeparator | ❌ | string | undefined | ',' |
|
|
47
|
+
| decimalSeparator | ❌ | string | undefined | ',' |
|
|
48
|
+
| currency | ❌ | string | '' |
|
|
49
|
+
| currencySymbolPosition | ❌ | 'prefix' |' suffix' | 'prefix' |
|
|
50
|
+
| emptyValue | ❌ | number | '' | '' |
|
|
51
51
|
|
|
52
52
|
## License
|
|
53
53
|
vue-number-input is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue");function j(
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("vue");function j(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}/*
|
|
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(
|
|
5
|
+
*/var O=Object.getOwnPropertySymbols,I=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;function A(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function T(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var t={},e=0;e<10;e++)t["_"+String.fromCharCode(e)]=e;var n=Object.getOwnPropertyNames(t).map(function(u){return t[u]});if(n.join("")!=="0123456789")return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(u){o[u]=u}),Object.keys(Object.assign({},o)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}var F=T()?Object.assign:function(r,t){for(var e,n=A(r),o,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){o=O(e);for(var s=0;s<o.length;s++)M.call(e,o[s])&&(n[o[s]]=e[o[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 t={},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 o=42;t[e]=o;for(e in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var u=Object.getOwnPropertySymbols(t);if(u.length!==1||u[0]!==e||!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var c=Object.getOwnPropertyDescriptor(t,e);if(c.value!==o||c.enumerable!==!0)return!1}return!0},x=k,$=function(){return x()&&!!Symbol.toStringTag},C=String.prototype.valueOf,D=function(t){try{return C.call(t),!0}catch{return!1}},B=Object.prototype.toString,U="[object String]",q=$(),H=function(t){return typeof t=="string"?!0:typeof t!="object"?!1:q?D(t):B.call(t)===U};const R=j(H);function Z(r){return R(r)&&r.match("%v")?{pos:r,neg:r.replace("-","").replace("%v","-%v"),zero:r}:r}const f={symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3,stripZeros:!1,fallback:0};function z(r,t){const e=r.split(t),n=e[0],o=e[1].replace(/0+$/,"");return o.length>0?n+t+o:n}function G(r,t){return r=Math.round(Math.abs(r)),isNaN(r)?t:r}function g(r,t){t=G(t,f.precision);const e=Math.pow(10,t);return(Math.round((r+1e-8)*e)/e).toFixed(t)}function N(r,t={}){if(Array.isArray(r))return r.map(c=>N(c,t));t=S({},f,t);const e=r<0?"-":"",n=parseInt(g(Math.abs(r),t.precision),10)+"",o=n.length>3?n.length%3:0,u=e+(o?n.substr(0,o)+t.thousand:"")+n.substr(o).replace(/(\d{3})(?=\d)/g,"$1"+t.thousand)+(t.precision>0?t.decimal+g(Math.abs(r),t.precision).split(".")[1]:"");return t.stripZeros?z(u,t.decimal):u}function v(r,t={}){if(Array.isArray(r))return r.map(o=>v(o,t));t=S({},f,t);const e=Z(t.format);let n;return r>0?n=e.pos:r<0?n=e.neg:n=e.zero,n.replace("%s",t.symbol).replace("%v",N(Math.abs(r),t))}function w(r,t=f.decimal,e=f.fallback){if(Array.isArray(r))return r.map(p=>w(p,t,e));if(typeof r=="number")return r;const n=new RegExp("[^0-9-(-)-"+t+"]",["g"]),o=(""+r).replace(n,"").replace(t,".").replace(/\(([-]*\d*[^)]?\d+)\)/g,"-$1").replace(/\((.*)\)/,""),u=(o.match(/-/g)||2).length%2,c=parseFloat(o.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(r,{emit:t}){const e=r,n=i.ref(""),o=i.ref(!1),u=i.ref(),c=i.computed(()=>h(n.value)),s=i.computed(()=>h(e.modelValue)),p=i.computed(()=>e.currency?e.currencySymbolPosition==="suffix"?"%v %s":"%s %v":"%v");e.modelValue!==void 0&&(m(s.value),n.value=b(s.value)),i.watch(e,()=>{o.value||(m(s.value),n.value=b(s.value))});function V(a){o.value=!1,t("blur",a),n.value=b(s.value)}function _(a){if(o.value=!0,t("focus",a),typeof s.value=="string"&&s.value==="")return"";n.value=v(s.value,{symbol:"",format:"%v",thousand:"",decimal:e.decimalSeparator,precision:Number(e.precision)})}function E(){m(c.value)}function m(a){if(typeof a=="string"&&a==="")t("update:modelValue",a);else{if(a=Number(a),a>=e.max){y(e.max);return}if(a<=e.min){y(e.min);return}if(a>e.min&&a<e.max){y(a);return}}}function y(a){const l=g(a,e.precision),d=e.outputType.toLowerCase()==="string"?l:Number(l);t("update:modelValue",d)}function b(a){return typeof a=="string"&&a===""?"":v(a,{symbol:e.currency,format:p.value,precision:Number(e.precision),decimal:e.decimalSeparator,thousand:e.thousandSeparator})}function h(a){const l=typeof a=="string"&&a===""||a===void 0?e.emptyValue:a;return typeof l=="string"&&l===""?"":w(l,e.decimalSeparator)}return(a,l)=>i.withDirectives((i.openBlock(),i.createElementBlock("input",i.mergeProps(a.$attrs,{ref_key:"inputElement",ref:u,"onUpdate:modelValue":l[0]||(l[0]=d=>n.value=d),value:n.value,onBlur:V,onInput:E,onFocus:_}),null,16,L)),[[i.vModelDynamic,n.value]])}}),X={install:r=>{r.component("VueInputNumber",P)}};exports.VueInputNumber=P;exports.default=X;
|
package/dist/index.js
CHANGED
|
@@ -169,8 +169,8 @@ const ee = ["value"], re = /* @__PURE__ */ I({
|
|
|
169
169
|
emits: ["update:modelValue", "blur", "focus"],
|
|
170
170
|
setup(t, { emit: r }) {
|
|
171
171
|
const e = t, n = g(""), o = g(!1), u = g(), i = d(() => O(n.value)), s = d(() => O(e.modelValue)), f = d(() => e.currency ? e.currencySymbolPosition === "suffix" ? "%v %s" : "%s %v" : "%v");
|
|
172
|
-
|
|
173
|
-
o.value ||
|
|
172
|
+
e.modelValue !== void 0 && (p(s.value), n.value = y(s.value)), M(e, () => {
|
|
173
|
+
o.value || (p(s.value), n.value = y(s.value));
|
|
174
174
|
});
|
|
175
175
|
function V(a) {
|
|
176
176
|
o.value = !1, r("blur", a), n.value = y(s.value);
|
|
@@ -221,7 +221,7 @@ const ee = ["value"], re = /* @__PURE__ */ I({
|
|
|
221
221
|
});
|
|
222
222
|
}
|
|
223
223
|
function O(a) {
|
|
224
|
-
const c = typeof a == "string" && a === "" ? e.emptyValue : a;
|
|
224
|
+
const c = typeof a == "string" && a === "" || a === void 0 ? e.emptyValue : a;
|
|
225
225
|
return typeof c == "string" && c === "" ? "" : P(c, e.decimalSeparator);
|
|
226
226
|
}
|
|
227
227
|
return (a, c) => A((F(), T("input", k(a.$attrs, {
|