@robin-rossow/vue-input-number 1.0.9 → 2.0.0
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 +0 -15
- package/dist/components/VueInputNumber.vue.d.ts +12 -108
- package/dist/index.d.ts +2 -0
- package/dist/vue-input-number.js +113 -0
- package/dist/vue-input-number.umd.cjs +1 -0
- package/package.json +23 -38
- package/dist/VueInputNumberPlugin.d.ts +0 -7
- package/dist/index.cjs +0 -5
- package/dist/index.js +0 -247
package/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Vue Input Number
|
|
2
2
|
Input field component to display a formatted number value. It is meant to be used with Vue 3.
|
|
3
3
|
|
|
4
|
-
This is rewrite based on [vue-numeric](https://github.com/kevinongko/vue-numeric) written in TypeScript.
|
|
5
|
-
|
|
6
4
|
## Installation
|
|
7
5
|
|
|
8
6
|
### Install via NPM
|
|
@@ -10,19 +8,6 @@ This is rewrite based on [vue-numeric](https://github.com/kevinongko/vue-numeric
|
|
|
10
8
|
$ npm install @robin-rossow/vue-input-number --save
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
#### Use globally
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import VueInputNumberPlugin from '@robin-rossow/vue-input-number'
|
|
17
|
-
|
|
18
|
-
import { createApp } from 'vue'
|
|
19
|
-
import App from './App.vue'
|
|
20
|
-
|
|
21
|
-
createApp(App)
|
|
22
|
-
.use(VueInputNumberPlugin)
|
|
23
|
-
.mount('#app')
|
|
24
|
-
```
|
|
25
|
-
|
|
26
11
|
#### Load in component
|
|
27
12
|
```ts
|
|
28
13
|
import { VueInputNumber } from '@robin-rossow/vue-input-number'
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { PropType as __PropType } from 'vue';
|
|
2
1
|
export interface Props {
|
|
3
2
|
modelValue: string | number | undefined;
|
|
4
3
|
outputType?: 'Number' | 'String';
|
|
@@ -11,111 +10,15 @@ export interface Props {
|
|
|
11
10
|
currencySymbolPosition?: 'prefix' | 'suffix';
|
|
12
11
|
emptyValue?: number | '';
|
|
13
12
|
}
|
|
14
|
-
declare const
|
|
15
|
-
modelValue:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
min: {
|
|
25
|
-
type: __PropType<number>;
|
|
26
|
-
required: false;
|
|
27
|
-
default: number;
|
|
28
|
-
};
|
|
29
|
-
max: {
|
|
30
|
-
type: __PropType<number>;
|
|
31
|
-
required: false;
|
|
32
|
-
default: number;
|
|
33
|
-
};
|
|
34
|
-
precision: {
|
|
35
|
-
type: __PropType<number>;
|
|
36
|
-
required: false;
|
|
37
|
-
default: number;
|
|
38
|
-
};
|
|
39
|
-
thousandSeparator: {
|
|
40
|
-
type: __PropType<string>;
|
|
41
|
-
required: false;
|
|
42
|
-
default: string;
|
|
43
|
-
};
|
|
44
|
-
decimalSeparator: {
|
|
45
|
-
type: __PropType<string>;
|
|
46
|
-
required: false;
|
|
47
|
-
default: string;
|
|
48
|
-
};
|
|
49
|
-
currency: {
|
|
50
|
-
type: __PropType<string>;
|
|
51
|
-
required: false;
|
|
52
|
-
default: string;
|
|
53
|
-
};
|
|
54
|
-
currencySymbolPosition: {
|
|
55
|
-
type: __PropType<"prefix" | "suffix">;
|
|
56
|
-
required: false;
|
|
57
|
-
default: string;
|
|
58
|
-
};
|
|
59
|
-
emptyValue: {
|
|
60
|
-
type: __PropType<number | "">;
|
|
61
|
-
required: false;
|
|
62
|
-
default: string;
|
|
63
|
-
};
|
|
64
|
-
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:modelValue" | "blur" | "focus")[], "update:modelValue" | "blur" | "focus", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
65
|
-
modelValue: {
|
|
66
|
-
type: __PropType<string | number>;
|
|
67
|
-
required: true;
|
|
68
|
-
};
|
|
69
|
-
outputType: {
|
|
70
|
-
type: __PropType<"Number" | "String">;
|
|
71
|
-
required: false;
|
|
72
|
-
default: string;
|
|
73
|
-
};
|
|
74
|
-
min: {
|
|
75
|
-
type: __PropType<number>;
|
|
76
|
-
required: false;
|
|
77
|
-
default: number;
|
|
78
|
-
};
|
|
79
|
-
max: {
|
|
80
|
-
type: __PropType<number>;
|
|
81
|
-
required: false;
|
|
82
|
-
default: number;
|
|
83
|
-
};
|
|
84
|
-
precision: {
|
|
85
|
-
type: __PropType<number>;
|
|
86
|
-
required: false;
|
|
87
|
-
default: number;
|
|
88
|
-
};
|
|
89
|
-
thousandSeparator: {
|
|
90
|
-
type: __PropType<string>;
|
|
91
|
-
required: false;
|
|
92
|
-
default: string;
|
|
93
|
-
};
|
|
94
|
-
decimalSeparator: {
|
|
95
|
-
type: __PropType<string>;
|
|
96
|
-
required: false;
|
|
97
|
-
default: string;
|
|
98
|
-
};
|
|
99
|
-
currency: {
|
|
100
|
-
type: __PropType<string>;
|
|
101
|
-
required: false;
|
|
102
|
-
default: string;
|
|
103
|
-
};
|
|
104
|
-
currencySymbolPosition: {
|
|
105
|
-
type: __PropType<"prefix" | "suffix">;
|
|
106
|
-
required: false;
|
|
107
|
-
default: string;
|
|
108
|
-
};
|
|
109
|
-
emptyValue: {
|
|
110
|
-
type: __PropType<number | "">;
|
|
111
|
-
required: false;
|
|
112
|
-
default: string;
|
|
113
|
-
};
|
|
114
|
-
}>> & {
|
|
115
|
-
"onUpdate:modelValue"?: (...args: any[]) => any;
|
|
116
|
-
onBlur?: (...args: any[]) => any;
|
|
117
|
-
onFocus?: (...args: any[]) => any;
|
|
118
|
-
}, {
|
|
13
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
+
"update:modelValue": (...args: any[]) => void;
|
|
15
|
+
blur: (...args: any[]) => void;
|
|
16
|
+
focus: (...args: any[]) => void;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
18
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
19
|
+
onBlur?: ((...args: any[]) => any) | undefined;
|
|
20
|
+
onFocus?: ((...args: any[]) => any) | undefined;
|
|
21
|
+
}>, {
|
|
119
22
|
outputType: "Number" | "String";
|
|
120
23
|
min: number;
|
|
121
24
|
max: number;
|
|
@@ -125,5 +28,6 @@ declare const _sfc_main: import("vue").DefineComponent<{
|
|
|
125
28
|
currency: string;
|
|
126
29
|
currencySymbolPosition: "prefix" | "suffix";
|
|
127
30
|
emptyValue: number | "";
|
|
128
|
-
}, {}>;
|
|
129
|
-
|
|
31
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
32
|
+
declare const _default: typeof __VLS_export;
|
|
33
|
+
export default _default;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { defineComponent as I, ref as y, computed as m, onMounted as _, watch as F, withDirectives as $, openBlock as w, createElementBlock as k, mergeProps as B, vModelDynamic as P } from "vue";
|
|
2
|
+
var l = { symbol: "$", format: "%s%v", decimal: ".", thousand: ",", precision: 2, grouping: 3, stripZeros: !1, fallback: 0, round: 0 };
|
|
3
|
+
function g(u, t = l.decimal, e = l.fallback) {
|
|
4
|
+
let n = new RegExp(`[^0-9-(-)-${t}]`, "g"), a = ("" + u).replace(n, "").replace(t, ".").replace(/\(([-]*\d*[^)]?\d+)\)/g, "-$1").replace(/\((.*)\)/, ""), r = (a.match(/-/g) || "").length % 2, i = parseFloat(a.replace(/-/g, "")) * (r ? -1 : 1);
|
|
5
|
+
return isNaN(i) ? e : i;
|
|
6
|
+
}
|
|
7
|
+
function h(u, t, e) {
|
|
8
|
+
t ??= l.precision, e ??= l.round;
|
|
9
|
+
let n = Math.pow(10, t), a;
|
|
10
|
+
return e > 0 ? a = Math.ceil : e < 0 ? a = Math.floor : a = Math.round, (a((u + 1e-8) * n) / n).toFixed(t);
|
|
11
|
+
}
|
|
12
|
+
function T(u, t) {
|
|
13
|
+
let e = u.split(t), n = "";
|
|
14
|
+
if (e[0] !== void 0 && (n = e[0]), e[1] !== void 0) {
|
|
15
|
+
let a = e[1].replace(/0+$/, "");
|
|
16
|
+
a.length > 0 && (n = n + t + a);
|
|
17
|
+
}
|
|
18
|
+
return n;
|
|
19
|
+
}
|
|
20
|
+
function A(u, t = {}) {
|
|
21
|
+
t = Object.assign({}, l, t);
|
|
22
|
+
let e = u < 0 ? "-" : "", n = parseInt(h(Math.abs(u), t.precision, t.round), 10) + "", a = n.length > 3 ? n.length % 3 : 0, r = e + (a ? n.substr(0, a) + t.thousand : "") + n.substr(a).replace(/(\d{3})(?=\d)/g, "$1" + t.thousand) + (t.precision > 0 ? t.decimal + h(Math.abs(u), t.precision).split(".")[1] : "");
|
|
23
|
+
return t.stripZeros ? T(r, t.decimal) : r;
|
|
24
|
+
}
|
|
25
|
+
function D(u) {
|
|
26
|
+
return typeof u == "string" && u.match("%v") ? { pos: u, neg: u.replace("-", "").replace("%v", "-%v"), zero: u } : u;
|
|
27
|
+
}
|
|
28
|
+
function N(u, t = {}) {
|
|
29
|
+
t = Object.assign({}, l, t);
|
|
30
|
+
let e = D(t.format), n;
|
|
31
|
+
return u > 0 ? n = e.pos : u < 0 ? n = e.neg : n = e.zero, n.replace("%s", t.symbol).replace("%v", A(Math.abs(u), t));
|
|
32
|
+
}
|
|
33
|
+
const R = /* @__PURE__ */ I({
|
|
34
|
+
__name: "VueInputNumber",
|
|
35
|
+
props: {
|
|
36
|
+
modelValue: {},
|
|
37
|
+
outputType: { default: "Number" },
|
|
38
|
+
min: { default: Number.MIN_SAFE_INTEGER },
|
|
39
|
+
max: { default: Number.MAX_SAFE_INTEGER },
|
|
40
|
+
precision: { default: 0 },
|
|
41
|
+
thousandSeparator: { default: "," },
|
|
42
|
+
decimalSeparator: { default: "." },
|
|
43
|
+
currency: { default: "" },
|
|
44
|
+
currencySymbolPosition: { default: "prefix" },
|
|
45
|
+
emptyValue: { default: "" }
|
|
46
|
+
},
|
|
47
|
+
emits: ["update:modelValue", "blur", "focus"],
|
|
48
|
+
setup(u, { emit: t }) {
|
|
49
|
+
const e = u, n = t, a = y(""), r = y(!1), i = m(() => e.currency ? e.currencySymbolPosition === "suffix" ? "%v %s" : "%s %v" : "%v"), s = m(() => c(g(a.value, e.decimalSeparator)) || 0);
|
|
50
|
+
function d(o) {
|
|
51
|
+
return N(o, {
|
|
52
|
+
symbol: e.currency,
|
|
53
|
+
format: i.value,
|
|
54
|
+
thousand: e.thousandSeparator,
|
|
55
|
+
decimal: e.decimalSeparator,
|
|
56
|
+
precision: Number(e.precision)
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const M = m(() => d(s.value)), f = m(() => N(s.value, {
|
|
60
|
+
symbol: "",
|
|
61
|
+
format: "%v",
|
|
62
|
+
thousand: e.thousandSeparator,
|
|
63
|
+
decimal: e.decimalSeparator,
|
|
64
|
+
precision: Number(e.precision)
|
|
65
|
+
}));
|
|
66
|
+
function S(o) {
|
|
67
|
+
r.value = !1, a.value = M.value, p(), n("blur", o);
|
|
68
|
+
}
|
|
69
|
+
function V(o) {
|
|
70
|
+
r.value = !0, a.value = f.value, n("focus", o);
|
|
71
|
+
}
|
|
72
|
+
function x() {
|
|
73
|
+
r.value || p();
|
|
74
|
+
}
|
|
75
|
+
function c(o) {
|
|
76
|
+
return o < e.min ? e.min : o > e.max ? e.max : o;
|
|
77
|
+
}
|
|
78
|
+
function b(o) {
|
|
79
|
+
if (!o) {
|
|
80
|
+
a.value = e.emptyValue === "" ? "" : String(c(e.emptyValue));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (typeof o == "string") {
|
|
84
|
+
a.value = d(c(g(o, e.decimalSeparator)));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
a.value = d(c(o));
|
|
88
|
+
}
|
|
89
|
+
function p() {
|
|
90
|
+
if (!s.value) {
|
|
91
|
+
n("update:modelValue", e.emptyValue);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const o = e.outputType.toLowerCase() === "string" ? f.value : s.value;
|
|
95
|
+
n("update:modelValue", o);
|
|
96
|
+
}
|
|
97
|
+
return _(() => {
|
|
98
|
+
b(e.modelValue), p();
|
|
99
|
+
}), F(e, () => {
|
|
100
|
+
r.value || (b(e.modelValue), p());
|
|
101
|
+
}), (o, v) => $((w(), k("input", B(o.$attrs, {
|
|
102
|
+
"onUpdate:modelValue": v[0] || (v[0] = (E) => a.value = E),
|
|
103
|
+
onBlur: S,
|
|
104
|
+
onInput: x,
|
|
105
|
+
onFocus: V
|
|
106
|
+
}), null, 16)), [
|
|
107
|
+
[P, a.value]
|
|
108
|
+
]);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
export {
|
|
112
|
+
R as VueInputNumber
|
|
113
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(i,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],r):(i=typeof globalThis<"u"?globalThis:i||self,r(i.VueInputNumber={},i.Vue))})(this,(function(i,r){"use strict";var s={symbol:"$",format:"%s%v",decimal:".",thousand:",",precision:2,grouping:3,stripZeros:!1,fallback:0,round:0};function b(u,t=s.decimal,e=s.fallback){let n=new RegExp(`[^0-9-(-)-${t}]`,"g"),o=(""+u).replace(n,"").replace(t,".").replace(/\(([-]*\d*[^)]?\d+)\)/g,"-$1").replace(/\((.*)\)/,""),l=(o.match(/-/g)||"").length%2,c=parseFloat(o.replace(/-/g,""))*(l?-1:1);return isNaN(c)?e:c}function y(u,t,e){t??=s.precision,e??=s.round;let n=Math.pow(10,t),o;return e>0?o=Math.ceil:e<0?o=Math.floor:o=Math.round,(o((u+1e-8)*n)/n).toFixed(t)}function S(u,t){let e=u.split(t),n="";if(e[0]!==void 0&&(n=e[0]),e[1]!==void 0){let o=e[1].replace(/0+$/,"");o.length>0&&(n=n+t+o)}return n}function V(u,t={}){t=Object.assign({},s,t);let e=u<0?"-":"",n=parseInt(y(Math.abs(u),t.precision,t.round),10)+"",o=n.length>3?n.length%3:0,l=e+(o?n.substr(0,o)+t.thousand:"")+n.substr(o).replace(/(\d{3})(?=\d)/g,"$1"+t.thousand)+(t.precision>0?t.decimal+y(Math.abs(u),t.precision).split(".")[1]:"");return t.stripZeros?S(l,t.decimal):l}function M(u){return typeof u=="string"&&u.match("%v")?{pos:u,neg:u.replace("-","").replace("%v","-%v"),zero:u}:u}function h(u,t={}){t=Object.assign({},s,t);let e=M(t.format),n;return u>0?n=e.pos:u<0?n=e.neg:n=e.zero,n.replace("%s",t.symbol).replace("%v",V(Math.abs(u),t))}const x=r.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(u,{emit:t}){const e=u,n=t,o=r.ref(""),l=r.ref(!1),c=r.computed(()=>e.currency?e.currencySymbolPosition==="suffix"?"%v %s":"%s %v":"%v"),p=r.computed(()=>d(b(o.value,e.decimalSeparator))||0);function f(a){return h(a,{symbol:e.currency,format:c.value,thousand:e.thousandSeparator,decimal:e.decimalSeparator,precision:Number(e.precision)})}const I=r.computed(()=>f(p.value)),g=r.computed(()=>h(p.value,{symbol:"",format:"%v",thousand:e.thousandSeparator,decimal:e.decimalSeparator,precision:Number(e.precision)}));function E(a){l.value=!1,o.value=I.value,m(),n("blur",a)}function T(a){l.value=!0,o.value=g.value,n("focus",a)}function _(){l.value||m()}function d(a){return a<e.min?e.min:a>e.max?e.max:a}function v(a){if(!a){o.value=e.emptyValue===""?"":String(d(e.emptyValue));return}if(typeof a=="string"){o.value=f(d(b(a,e.decimalSeparator)));return}o.value=f(d(a))}function m(){if(!p.value){n("update:modelValue",e.emptyValue);return}const a=e.outputType.toLowerCase()==="string"?g.value:p.value;n("update:modelValue",a)}return r.onMounted(()=>{v(e.modelValue),m()}),r.watch(e,()=>{l.value||(v(e.modelValue),m())}),(a,N)=>r.withDirectives((r.openBlock(),r.createElementBlock("input",r.mergeProps(a.$attrs,{"onUpdate:modelValue":N[0]||(N[0]=F=>o.value=F),onBlur:E,onInput:_,onFocus:T}),null,16)),[[r.vModelDynamic,o.value]])}});i.VueInputNumber=x,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@robin-rossow/vue-input-number",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"component",
|
|
6
6
|
"currency",
|
|
@@ -14,50 +14,35 @@
|
|
|
14
14
|
],
|
|
15
15
|
"type": "module",
|
|
16
16
|
"private": false,
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"main": "./dist/vue-input-number.umd.cjs",
|
|
19
|
+
"module": "./dist/vue-input-number.js",
|
|
17
20
|
"exports": {
|
|
18
|
-
".":
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/vue-input-number.js",
|
|
23
|
+
"require": "./dist/vue-input-number.umd.cjs"
|
|
24
|
+
}
|
|
19
25
|
},
|
|
20
|
-
"types": "./dist/
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "https://github.com/robinrossow/vue-input-number"
|
|
25
|
-
},
|
|
26
|
-
"files": [
|
|
27
|
-
"dist"
|
|
28
|
-
],
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
29
27
|
"scripts": {
|
|
30
28
|
"dev": "vite",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"coverage": "vitest run --coverage",
|
|
35
|
-
"build-only": "vite build",
|
|
36
|
-
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
|
|
37
|
-
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
|
|
29
|
+
"test": "vitest",
|
|
30
|
+
"build": "vite build && vue-tsc --emitDeclarationOnly",
|
|
31
|
+
"preview": "vite preview"
|
|
38
32
|
},
|
|
39
33
|
"dependencies": {
|
|
40
|
-
"accounting-js": "^
|
|
41
|
-
"vue": "^3.
|
|
34
|
+
"accounting-js": "^2.0.3",
|
|
35
|
+
"vue": "^3.5.25"
|
|
42
36
|
},
|
|
43
37
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"eslint": "^8.39.0",
|
|
54
|
-
"eslint-plugin-vue": "^9.11.0",
|
|
55
|
-
"jsdom": "^22.0.0",
|
|
56
|
-
"npm-run-all": "^4.1.5",
|
|
57
|
-
"typescript": "~5.0.4",
|
|
58
|
-
"vite": "^4.3.5",
|
|
59
|
-
"vite-plugin-dts": "^2.3.0",
|
|
60
|
-
"vitest": "^0.31.0",
|
|
61
|
-
"vue-tsc": "^1.6.4"
|
|
38
|
+
"@types/node": "^24.10.1",
|
|
39
|
+
"@vitejs/plugin-vue": "^6.0.2",
|
|
40
|
+
"@vue/test-utils": "^2.4.6",
|
|
41
|
+
"@vue/tsconfig": "^0.8.1",
|
|
42
|
+
"happy-dom": "^20.6.1",
|
|
43
|
+
"typescript": "~5.9.3",
|
|
44
|
+
"vite": "^7.3.1",
|
|
45
|
+
"vitest": "^4.0.18",
|
|
46
|
+
"vue-tsc": "^3.2.4"
|
|
62
47
|
}
|
|
63
48
|
}
|
package/dist/index.cjs
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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
|
-
object-assign
|
|
3
|
-
(c) Sindre Sorhus
|
|
4
|
-
@license MIT
|
|
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
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { defineComponent as I, ref as g, computed as d, watch as M, withDirectives as A, openBlock as F, createElementBlock as T, mergeProps as k, vModelDynamic as x } from "vue";
|
|
2
|
-
function S(t) {
|
|
3
|
-
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
4
|
-
}
|
|
5
|
-
/*
|
|
6
|
-
object-assign
|
|
7
|
-
(c) Sindre Sorhus
|
|
8
|
-
@license MIT
|
|
9
|
-
*/
|
|
10
|
-
var j = Object.getOwnPropertySymbols, $ = Object.prototype.hasOwnProperty, C = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
function D(t) {
|
|
12
|
-
if (t == null)
|
|
13
|
-
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
14
|
-
return Object(t);
|
|
15
|
-
}
|
|
16
|
-
function B() {
|
|
17
|
-
try {
|
|
18
|
-
if (!Object.assign)
|
|
19
|
-
return !1;
|
|
20
|
-
var t = new String("abc");
|
|
21
|
-
if (t[5] = "de", Object.getOwnPropertyNames(t)[0] === "5")
|
|
22
|
-
return !1;
|
|
23
|
-
for (var r = {}, e = 0; e < 10; e++)
|
|
24
|
-
r["_" + String.fromCharCode(e)] = e;
|
|
25
|
-
var n = Object.getOwnPropertyNames(r).map(function(u) {
|
|
26
|
-
return r[u];
|
|
27
|
-
});
|
|
28
|
-
if (n.join("") !== "0123456789")
|
|
29
|
-
return !1;
|
|
30
|
-
var o = {};
|
|
31
|
-
return "abcdefghijklmnopqrst".split("").forEach(function(u) {
|
|
32
|
-
o[u] = u;
|
|
33
|
-
}), Object.keys(Object.assign({}, o)).join("") === "abcdefghijklmnopqrst";
|
|
34
|
-
} catch {
|
|
35
|
-
return !1;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
var U = B() ? Object.assign : function(t, r) {
|
|
39
|
-
for (var e, n = D(t), o, u = 1; u < arguments.length; u++) {
|
|
40
|
-
e = Object(arguments[u]);
|
|
41
|
-
for (var i in e)
|
|
42
|
-
$.call(e, i) && (n[i] = e[i]);
|
|
43
|
-
if (j) {
|
|
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
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return n;
|
|
50
|
-
};
|
|
51
|
-
const N = /* @__PURE__ */ S(U);
|
|
52
|
-
var H = function() {
|
|
53
|
-
if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function")
|
|
54
|
-
return !1;
|
|
55
|
-
if (typeof Symbol.iterator == "symbol")
|
|
56
|
-
return !0;
|
|
57
|
-
var r = {}, e = Symbol("test"), n = Object(e);
|
|
58
|
-
if (typeof e == "string" || Object.prototype.toString.call(e) !== "[object Symbol]" || Object.prototype.toString.call(n) !== "[object Symbol]")
|
|
59
|
-
return !1;
|
|
60
|
-
var o = 42;
|
|
61
|
-
r[e] = o;
|
|
62
|
-
for (e in r)
|
|
63
|
-
return !1;
|
|
64
|
-
if (typeof Object.keys == "function" && Object.keys(r).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(r).length !== 0)
|
|
65
|
-
return !1;
|
|
66
|
-
var u = Object.getOwnPropertySymbols(r);
|
|
67
|
-
if (u.length !== 1 || u[0] !== e || !Object.prototype.propertyIsEnumerable.call(r, e))
|
|
68
|
-
return !1;
|
|
69
|
-
if (typeof Object.getOwnPropertyDescriptor == "function") {
|
|
70
|
-
var i = Object.getOwnPropertyDescriptor(r, e);
|
|
71
|
-
if (i.value !== o || i.enumerable !== !0)
|
|
72
|
-
return !1;
|
|
73
|
-
}
|
|
74
|
-
return !0;
|
|
75
|
-
}, R = H, Z = function() {
|
|
76
|
-
return R() && !!Symbol.toStringTag;
|
|
77
|
-
}, q = String.prototype.valueOf, z = function(r) {
|
|
78
|
-
try {
|
|
79
|
-
return q.call(r), !0;
|
|
80
|
-
} catch {
|
|
81
|
-
return !1;
|
|
82
|
-
}
|
|
83
|
-
}, G = Object.prototype.toString, L = "[object String]", X = Z(), J = function(r) {
|
|
84
|
-
return typeof r == "string" ? !0 : typeof r != "object" ? !1 : X ? z(r) : G.call(r) === L;
|
|
85
|
-
};
|
|
86
|
-
const K = /* @__PURE__ */ S(J);
|
|
87
|
-
function Q(t) {
|
|
88
|
-
return K(t) && t.match("%v") ? {
|
|
89
|
-
pos: t,
|
|
90
|
-
neg: t.replace("-", "").replace("%v", "-%v"),
|
|
91
|
-
zero: t
|
|
92
|
-
} : t;
|
|
93
|
-
}
|
|
94
|
-
const l = {
|
|
95
|
-
symbol: "$",
|
|
96
|
-
// default currency symbol is '$'
|
|
97
|
-
format: "%s%v",
|
|
98
|
-
// controls output: %s = symbol, %v = value (can be object, see docs)
|
|
99
|
-
decimal: ".",
|
|
100
|
-
// decimal point separator
|
|
101
|
-
thousand: ",",
|
|
102
|
-
// thousands separator
|
|
103
|
-
precision: 2,
|
|
104
|
-
// decimal places
|
|
105
|
-
grouping: 3,
|
|
106
|
-
// digit grouping (not implemented yet)
|
|
107
|
-
stripZeros: !1,
|
|
108
|
-
// strip insignificant zeros from decimal part
|
|
109
|
-
fallback: 0
|
|
110
|
-
// value returned on unformat() failure
|
|
111
|
-
};
|
|
112
|
-
function W(t, r) {
|
|
113
|
-
const e = t.split(r), n = e[0], o = e[1].replace(/0+$/, "");
|
|
114
|
-
return o.length > 0 ? n + r + o : n;
|
|
115
|
-
}
|
|
116
|
-
function Y(t, r) {
|
|
117
|
-
return t = Math.round(Math.abs(t)), isNaN(t) ? r : t;
|
|
118
|
-
}
|
|
119
|
-
function h(t, r) {
|
|
120
|
-
r = Y(r, l.precision);
|
|
121
|
-
const e = Math.pow(10, r);
|
|
122
|
-
return (Math.round((t + 1e-8) * e) / e).toFixed(r);
|
|
123
|
-
}
|
|
124
|
-
function w(t, r = {}) {
|
|
125
|
-
if (Array.isArray(t))
|
|
126
|
-
return t.map((i) => w(i, r));
|
|
127
|
-
r = N(
|
|
128
|
-
{},
|
|
129
|
-
l,
|
|
130
|
-
r
|
|
131
|
-
);
|
|
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
|
-
return r.stripZeros ? W(u, r.decimal) : u;
|
|
134
|
-
}
|
|
135
|
-
function v(t, r = {}) {
|
|
136
|
-
if (Array.isArray(t))
|
|
137
|
-
return t.map((o) => v(o, r));
|
|
138
|
-
r = N(
|
|
139
|
-
{},
|
|
140
|
-
l,
|
|
141
|
-
r
|
|
142
|
-
);
|
|
143
|
-
const e = Q(r.format);
|
|
144
|
-
let n;
|
|
145
|
-
return t > 0 ? n = e.pos : t < 0 ? n = e.neg : n = e.zero, n.replace("%s", r.symbol).replace("%v", w(Math.abs(t), r));
|
|
146
|
-
}
|
|
147
|
-
function P(t, r = l.decimal, e = l.fallback) {
|
|
148
|
-
if (Array.isArray(t))
|
|
149
|
-
return t.map((f) => P(f, r, e));
|
|
150
|
-
if (typeof t == "number")
|
|
151
|
-
return t;
|
|
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
|
-
return isNaN(s) ? e : s;
|
|
154
|
-
}
|
|
155
|
-
const ee = ["value"], re = /* @__PURE__ */ I({
|
|
156
|
-
__name: "VueInputNumber",
|
|
157
|
-
props: {
|
|
158
|
-
modelValue: {},
|
|
159
|
-
outputType: { default: "Number" },
|
|
160
|
-
min: { default: Number.MIN_SAFE_INTEGER },
|
|
161
|
-
max: { default: Number.MAX_SAFE_INTEGER },
|
|
162
|
-
precision: { default: 0 },
|
|
163
|
-
thousandSeparator: { default: "," },
|
|
164
|
-
decimalSeparator: { default: "." },
|
|
165
|
-
currency: { default: "" },
|
|
166
|
-
currencySymbolPosition: { default: "prefix" },
|
|
167
|
-
emptyValue: { default: "" }
|
|
168
|
-
},
|
|
169
|
-
emits: ["update:modelValue", "blur", "focus"],
|
|
170
|
-
setup(t, { emit: r }) {
|
|
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 || (p(s.value), n.value = y(s.value));
|
|
174
|
-
});
|
|
175
|
-
function V(a) {
|
|
176
|
-
o.value = !1, r("blur", a), n.value = y(s.value);
|
|
177
|
-
}
|
|
178
|
-
function E(a) {
|
|
179
|
-
if (o.value = !0, r("focus", a), typeof s.value == "string" && s.value === "")
|
|
180
|
-
return "";
|
|
181
|
-
n.value = v(s.value, {
|
|
182
|
-
symbol: "",
|
|
183
|
-
format: "%v",
|
|
184
|
-
thousand: "",
|
|
185
|
-
decimal: e.decimalSeparator,
|
|
186
|
-
precision: Number(e.precision)
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
function _() {
|
|
190
|
-
p(i.value);
|
|
191
|
-
}
|
|
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;
|
|
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
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function m(a) {
|
|
211
|
-
const c = h(a, e.precision), b = e.outputType.toLowerCase() === "string" ? c : Number(c);
|
|
212
|
-
r("update:modelValue", b);
|
|
213
|
-
}
|
|
214
|
-
function y(a) {
|
|
215
|
-
return typeof a == "string" && a === "" ? "" : v(a, {
|
|
216
|
-
symbol: e.currency,
|
|
217
|
-
format: f.value,
|
|
218
|
-
precision: Number(e.precision),
|
|
219
|
-
decimal: e.decimalSeparator,
|
|
220
|
-
thousand: e.thousandSeparator
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
function O(a) {
|
|
224
|
-
const c = typeof a == "string" && a === "" || a === void 0 ? e.emptyValue : a;
|
|
225
|
-
return typeof c == "string" && c === "" ? "" : P(c, e.decimalSeparator);
|
|
226
|
-
}
|
|
227
|
-
return (a, c) => A((F(), T("input", k(a.$attrs, {
|
|
228
|
-
ref_key: "inputElement",
|
|
229
|
-
ref: u,
|
|
230
|
-
"onUpdate:modelValue": c[0] || (c[0] = (b) => n.value = b),
|
|
231
|
-
value: n.value,
|
|
232
|
-
onBlur: V,
|
|
233
|
-
onInput: _,
|
|
234
|
-
onFocus: E
|
|
235
|
-
}), null, 16, ee)), [
|
|
236
|
-
[x, n.value]
|
|
237
|
-
]);
|
|
238
|
-
}
|
|
239
|
-
}), ne = {
|
|
240
|
-
install: (t) => {
|
|
241
|
-
t.component("VueInputNumber", re);
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
export {
|
|
245
|
-
re as VueInputNumber,
|
|
246
|
-
ne as default
|
|
247
|
-
};
|