@robin-rossow/vue-input-number 1.0.4 → 1.0.6
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 +1 -1
- package/dist/index.js +45 -48
- package/package.json +1 -1
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
|
|
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 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(t,r){for(var e,n=A(t),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 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 o=42;r[e]=o;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!==o||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],o=e[1].replace(/0+$/,"");return o.length>0?n+r+o:n}function G(t,r){return t=Math.round(Math.abs(t)),isNaN(t)?r:t}function g(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(g(Math.abs(t),r.precision),10)+"",o=n.length>3?n.length%3:0,u=e+(o?n.substr(0,o)+r.thousand:"")+n.substr(o).replace(/(\d{3})(?=\d)/g,"$1"+r.thousand)+(r.precision>0?r.decimal+g(Math.abs(t),r.precision).split(".")[1]:"");return r.stripZeros?z(u,r.decimal):u}function v(t,r={}){if(Array.isArray(t))return t.map(o=>v(o,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"]),o=(""+t).replace(n,"").replace(r,".").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(t,{emit:r}){const e=t,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||e.modelValue!=null&&(m(s.value),n.value=b(s.value))});function V(a){o.value=!1,r("blur",a),n.value=b(s.value)}function _(a){if(o.value=!0,r("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==="")r("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);r("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===""?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:t=>{t.component("VueInputNumber",P)}};exports.VueInputNumber=P;exports.default=X;
|
package/dist/index.js
CHANGED
|
@@ -27,23 +27,23 @@ function B() {
|
|
|
27
27
|
});
|
|
28
28
|
if (n.join("") !== "0123456789")
|
|
29
29
|
return !1;
|
|
30
|
-
var
|
|
30
|
+
var o = {};
|
|
31
31
|
return "abcdefghijklmnopqrst".split("").forEach(function(u) {
|
|
32
|
-
|
|
33
|
-
}), Object.keys(Object.assign({},
|
|
32
|
+
o[u] = u;
|
|
33
|
+
}), Object.keys(Object.assign({}, o)).join("") === "abcdefghijklmnopqrst";
|
|
34
34
|
} catch {
|
|
35
35
|
return !1;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
var U = B() ? Object.assign : function(t, r) {
|
|
39
|
-
for (var e, n = D(t),
|
|
39
|
+
for (var e, n = D(t), o, u = 1; u < arguments.length; u++) {
|
|
40
40
|
e = Object(arguments[u]);
|
|
41
41
|
for (var i in e)
|
|
42
42
|
$.call(e, i) && (n[i] = e[i]);
|
|
43
43
|
if (j) {
|
|
44
|
-
|
|
45
|
-
for (var s = 0; s <
|
|
46
|
-
C.call(e,
|
|
44
|
+
o = j(e);
|
|
45
|
+
for (var s = 0; s < o.length; s++)
|
|
46
|
+
C.call(e, o[s]) && (n[o[s]] = e[o[s]]);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return n;
|
|
@@ -57,8 +57,8 @@ var H = function() {
|
|
|
57
57
|
var r = {}, e = Symbol("test"), n = Object(e);
|
|
58
58
|
if (typeof e == "string" || Object.prototype.toString.call(e) !== "[object Symbol]" || Object.prototype.toString.call(n) !== "[object Symbol]")
|
|
59
59
|
return !1;
|
|
60
|
-
var
|
|
61
|
-
r[e] =
|
|
60
|
+
var o = 42;
|
|
61
|
+
r[e] = o;
|
|
62
62
|
for (e in r)
|
|
63
63
|
return !1;
|
|
64
64
|
if (typeof Object.keys == "function" && Object.keys(r).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(r).length !== 0)
|
|
@@ -68,7 +68,7 @@ var H = function() {
|
|
|
68
68
|
return !1;
|
|
69
69
|
if (typeof Object.getOwnPropertyDescriptor == "function") {
|
|
70
70
|
var i = Object.getOwnPropertyDescriptor(r, e);
|
|
71
|
-
if (i.value !==
|
|
71
|
+
if (i.value !== o || i.enumerable !== !0)
|
|
72
72
|
return !1;
|
|
73
73
|
}
|
|
74
74
|
return !0;
|
|
@@ -110,8 +110,8 @@ const l = {
|
|
|
110
110
|
// value returned on unformat() failure
|
|
111
111
|
};
|
|
112
112
|
function W(t, r) {
|
|
113
|
-
const e = t.split(r), n = e[0],
|
|
114
|
-
return
|
|
113
|
+
const e = t.split(r), n = e[0], o = e[1].replace(/0+$/, "");
|
|
114
|
+
return o.length > 0 ? n + r + o : n;
|
|
115
115
|
}
|
|
116
116
|
function Y(t, r) {
|
|
117
117
|
return t = Math.round(Math.abs(t)), isNaN(t) ? r : t;
|
|
@@ -129,12 +129,12 @@ function w(t, r = {}) {
|
|
|
129
129
|
l,
|
|
130
130
|
r
|
|
131
131
|
);
|
|
132
|
-
const e = t < 0 ? "-" : "", n = parseInt(h(Math.abs(t), r.precision), 10) + "",
|
|
132
|
+
const e = t < 0 ? "-" : "", n = parseInt(h(Math.abs(t), r.precision), 10) + "", o = n.length > 3 ? n.length % 3 : 0, u = e + (o ? n.substr(0, o) + r.thousand : "") + n.substr(o).replace(/(\d{3})(?=\d)/g, "$1" + r.thousand) + (r.precision > 0 ? r.decimal + h(Math.abs(t), r.precision).split(".")[1] : "");
|
|
133
133
|
return r.stripZeros ? W(u, r.decimal) : u;
|
|
134
134
|
}
|
|
135
135
|
function v(t, r = {}) {
|
|
136
136
|
if (Array.isArray(t))
|
|
137
|
-
return t.map((
|
|
137
|
+
return t.map((o) => v(o, r));
|
|
138
138
|
r = N(
|
|
139
139
|
{},
|
|
140
140
|
l,
|
|
@@ -149,7 +149,7 @@ function P(t, r = l.decimal, e = l.fallback) {
|
|
|
149
149
|
return t.map((f) => P(f, r, e));
|
|
150
150
|
if (typeof t == "number")
|
|
151
151
|
return t;
|
|
152
|
-
const n = new RegExp("[^0-9-(-)-" + r + "]", ["g"]),
|
|
152
|
+
const n = new RegExp("[^0-9-(-)-" + r + "]", ["g"]), o = ("" + t).replace(n, "").replace(r, ".").replace(/\(([-]*\d*[^)]?\d+)\)/g, "-$1").replace(/\((.*)\)/, ""), u = (o.match(/-/g) || 2).length % 2, i = parseFloat(o.replace(/-/g, "")), s = i * (u ? -1 : 1);
|
|
153
153
|
return isNaN(s) ? e : s;
|
|
154
154
|
}
|
|
155
155
|
const ee = ["value"], re = /* @__PURE__ */ I({
|
|
@@ -168,15 +168,15 @@ const ee = ["value"], re = /* @__PURE__ */ I({
|
|
|
168
168
|
},
|
|
169
169
|
emits: ["update:modelValue", "blur", "focus"],
|
|
170
170
|
setup(t, { emit: r }) {
|
|
171
|
-
const e = t, n = g(""),
|
|
172
|
-
p(s.value), n.value = y(s.value), M(e, () => {
|
|
173
|
-
|
|
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
|
+
e.modelValue !== void 0 && (p(s.value), n.value = y(s.value)), M(e, () => {
|
|
173
|
+
o.value || e.modelValue != null && (p(s.value), n.value = y(s.value));
|
|
174
174
|
});
|
|
175
|
-
function V(
|
|
176
|
-
|
|
175
|
+
function V(a) {
|
|
176
|
+
o.value = !1, r("blur", a), n.value = y(s.value);
|
|
177
177
|
}
|
|
178
|
-
function E(
|
|
179
|
-
if (
|
|
178
|
+
function E(a) {
|
|
179
|
+
if (o.value = !0, r("focus", a), typeof s.value == "string" && s.value === "")
|
|
180
180
|
return "";
|
|
181
181
|
n.value = v(s.value, {
|
|
182
182
|
symbol: "",
|
|
@@ -189,31 +189,30 @@ const ee = ["value"], re = /* @__PURE__ */ I({
|
|
|
189
189
|
function _() {
|
|
190
190
|
p(i.value);
|
|
191
191
|
}
|
|
192
|
-
function p(
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
-
}
|
|
192
|
+
function p(a) {
|
|
193
|
+
if (typeof a == "string" && a === "")
|
|
194
|
+
r("update:modelValue", a);
|
|
195
|
+
else {
|
|
196
|
+
if (a = Number(a), a >= e.max) {
|
|
197
|
+
m(e.max);
|
|
198
|
+
return;
|
|
209
199
|
}
|
|
200
|
+
if (a <= e.min) {
|
|
201
|
+
m(e.min);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (a > e.min && a < e.max) {
|
|
205
|
+
m(a);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
210
209
|
}
|
|
211
|
-
function m(
|
|
212
|
-
const c = h(
|
|
210
|
+
function m(a) {
|
|
211
|
+
const c = h(a, e.precision), b = e.outputType.toLowerCase() === "string" ? c : Number(c);
|
|
213
212
|
r("update:modelValue", b);
|
|
214
213
|
}
|
|
215
|
-
function y(
|
|
216
|
-
return typeof
|
|
214
|
+
function y(a) {
|
|
215
|
+
return typeof a == "string" && a === "" ? "" : v(a, {
|
|
217
216
|
symbol: e.currency,
|
|
218
217
|
format: f.value,
|
|
219
218
|
precision: Number(e.precision),
|
|
@@ -221,13 +220,11 @@ const ee = ["value"], re = /* @__PURE__ */ I({
|
|
|
221
220
|
thousand: e.thousandSeparator
|
|
222
221
|
});
|
|
223
222
|
}
|
|
224
|
-
function O(
|
|
225
|
-
|
|
226
|
-
return o;
|
|
227
|
-
const c = typeof o == "string" && o === "" ? e.emptyValue : o;
|
|
223
|
+
function O(a) {
|
|
224
|
+
const c = typeof a == "string" && a === "" ? e.emptyValue : a;
|
|
228
225
|
return typeof c == "string" && c === "" ? "" : P(c, e.decimalSeparator);
|
|
229
226
|
}
|
|
230
|
-
return (
|
|
227
|
+
return (a, c) => A((F(), T("input", k(a.$attrs, {
|
|
231
228
|
ref_key: "inputElement",
|
|
232
229
|
ref: u,
|
|
233
230
|
"onUpdate:modelValue": c[0] || (c[0] = (b) => n.value = b),
|