v-money3 3.20.1 → 3.21.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 +1 -1
- package/dist/BigNumber.d.ts +17 -0
- package/dist/Utils.d.ts +20 -0
- package/dist/component.vue.d.ts +179 -0
- package/dist/directive.d.ts +7 -0
- package/dist/format.d.ts +2 -0
- package/dist/index.d.ts +13 -0
- package/dist/options.d.ts +20 -0
- package/dist/unformat.d.ts +2 -0
- package/dist/v-money3.es.js +581 -1
- package/dist/v-money3.umd.js +1 -1
- package/package.json +13 -10
package/README.md
CHANGED
|
@@ -261,7 +261,7 @@ A console warn with more information will be shown!
|
|
|
261
261
|
Use it directly in the browser!
|
|
262
262
|
|
|
263
263
|
```html
|
|
264
|
-
<script src="https://unpkg.com/v-money3@3.
|
|
264
|
+
<script src="https://unpkg.com/v-money3@3.21.0/dist/v-money3.umd.js"></script>
|
|
265
265
|
```
|
|
266
266
|
|
|
267
267
|
Take a look at issue [#15](https://github.com/jonathanpmartins/v-money3/issues/15#issuecomment-830988807) and also this [codesandbox](https://codesandbox.io/s/mystifying-paper-bpfyn?file=/index.html) working example.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare type NumberParam = bigint | number | string;
|
|
2
|
+
export default class BigNumber {
|
|
3
|
+
private number;
|
|
4
|
+
private decimal;
|
|
5
|
+
constructor(number: NumberParam);
|
|
6
|
+
getNumber(): bigint;
|
|
7
|
+
getDecimalPrecision(): number;
|
|
8
|
+
setNumber(number: NumberParam): void;
|
|
9
|
+
toFixed(precision?: number, shouldRound?: boolean): string;
|
|
10
|
+
toString(): string;
|
|
11
|
+
lessThan(thatBigNumber: NumberParam | BigNumber): boolean;
|
|
12
|
+
biggerThan(thatBigNumber: NumberParam | BigNumber): boolean;
|
|
13
|
+
isEqual(thatBigNumber: NumberParam | BigNumber): boolean;
|
|
14
|
+
setupString(number: string): void;
|
|
15
|
+
adjustComparisonNumbers(thatNumberParam: NumberParam | BigNumber): BigInt[];
|
|
16
|
+
}
|
|
17
|
+
export {};
|
package/dist/Utils.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { VMoneyOptions } from './options';
|
|
2
|
+
export declare const RESTRICTED_CHARACTERS: string[];
|
|
3
|
+
export declare const RESTRICTED_OPTIONS: string[];
|
|
4
|
+
export declare function fixed(precision: number): number;
|
|
5
|
+
export declare function numbersToCurrency(numbers: string, precision: number): string;
|
|
6
|
+
export declare function onlyNumbers(input: number | string): string;
|
|
7
|
+
export declare function addThousandSeparator(integer: string, separator: string): string;
|
|
8
|
+
export declare function joinIntegerAndDecimal(integer: string, decimal: string, separator: string): string;
|
|
9
|
+
export declare function validateRestrictedInput(value: string, caller: string): boolean;
|
|
10
|
+
export declare function validateRestrictedOptions(opt: VMoneyOptions): boolean;
|
|
11
|
+
export declare function filterOptRestrictions(opt: VMoneyOptions): VMoneyOptions;
|
|
12
|
+
export declare function guessFloatPrecision(string: string): number;
|
|
13
|
+
export declare function removeLeadingZeros(string: string): string;
|
|
14
|
+
export declare function isValidInteger(str: string): boolean;
|
|
15
|
+
export declare function isValidFloat(str: string): boolean;
|
|
16
|
+
export declare function replaceAt(str: string, index: number, chr: string | number): string;
|
|
17
|
+
export declare function round(string: string, precision: number): string;
|
|
18
|
+
export declare function setCursor(el: HTMLInputElement, position: number): void;
|
|
19
|
+
export declare function event(name: string): Event;
|
|
20
|
+
export declare function debug({ debug }: VMoneyOptions, ...args: any): void;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
debug: {
|
|
3
|
+
required: false;
|
|
4
|
+
type: BooleanConstructor;
|
|
5
|
+
default: boolean;
|
|
6
|
+
};
|
|
7
|
+
id: {
|
|
8
|
+
required: false;
|
|
9
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
10
|
+
default: () => number | null;
|
|
11
|
+
};
|
|
12
|
+
modelValue: {
|
|
13
|
+
required: true;
|
|
14
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
15
|
+
};
|
|
16
|
+
modelModifiers: {
|
|
17
|
+
required: false;
|
|
18
|
+
type: ObjectConstructor;
|
|
19
|
+
default: () => {
|
|
20
|
+
number: boolean;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
masked: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
default: boolean;
|
|
26
|
+
};
|
|
27
|
+
precision: {
|
|
28
|
+
type: NumberConstructor;
|
|
29
|
+
default: () => number;
|
|
30
|
+
};
|
|
31
|
+
decimal: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: () => string;
|
|
34
|
+
validator(value: string): boolean;
|
|
35
|
+
};
|
|
36
|
+
thousands: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: () => string;
|
|
39
|
+
validator(value: string): boolean;
|
|
40
|
+
};
|
|
41
|
+
prefix: {
|
|
42
|
+
type: StringConstructor;
|
|
43
|
+
default: () => string;
|
|
44
|
+
validator(value: string): boolean;
|
|
45
|
+
};
|
|
46
|
+
suffix: {
|
|
47
|
+
type: StringConstructor;
|
|
48
|
+
default: () => string;
|
|
49
|
+
validator(value: string): boolean;
|
|
50
|
+
};
|
|
51
|
+
disableNegative: {
|
|
52
|
+
type: BooleanConstructor;
|
|
53
|
+
default: boolean;
|
|
54
|
+
};
|
|
55
|
+
disabled: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
max: {
|
|
60
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
61
|
+
default: () => string | number | null;
|
|
62
|
+
};
|
|
63
|
+
min: {
|
|
64
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
65
|
+
default: () => string | number | null;
|
|
66
|
+
};
|
|
67
|
+
allowBlank: {
|
|
68
|
+
type: BooleanConstructor;
|
|
69
|
+
default: () => boolean;
|
|
70
|
+
};
|
|
71
|
+
minimumNumberOfCharacters: {
|
|
72
|
+
type: NumberConstructor;
|
|
73
|
+
default: () => number;
|
|
74
|
+
};
|
|
75
|
+
shouldRound: {
|
|
76
|
+
type: BooleanConstructor;
|
|
77
|
+
default: () => boolean;
|
|
78
|
+
};
|
|
79
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
80
|
+
"update:model-value": (value: string | number) => void;
|
|
81
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
82
|
+
debug: {
|
|
83
|
+
required: false;
|
|
84
|
+
type: BooleanConstructor;
|
|
85
|
+
default: boolean;
|
|
86
|
+
};
|
|
87
|
+
id: {
|
|
88
|
+
required: false;
|
|
89
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
90
|
+
default: () => number | null;
|
|
91
|
+
};
|
|
92
|
+
modelValue: {
|
|
93
|
+
required: true;
|
|
94
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
95
|
+
};
|
|
96
|
+
modelModifiers: {
|
|
97
|
+
required: false;
|
|
98
|
+
type: ObjectConstructor;
|
|
99
|
+
default: () => {
|
|
100
|
+
number: boolean;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
masked: {
|
|
104
|
+
type: BooleanConstructor;
|
|
105
|
+
default: boolean;
|
|
106
|
+
};
|
|
107
|
+
precision: {
|
|
108
|
+
type: NumberConstructor;
|
|
109
|
+
default: () => number;
|
|
110
|
+
};
|
|
111
|
+
decimal: {
|
|
112
|
+
type: StringConstructor;
|
|
113
|
+
default: () => string;
|
|
114
|
+
validator(value: string): boolean;
|
|
115
|
+
};
|
|
116
|
+
thousands: {
|
|
117
|
+
type: StringConstructor;
|
|
118
|
+
default: () => string;
|
|
119
|
+
validator(value: string): boolean;
|
|
120
|
+
};
|
|
121
|
+
prefix: {
|
|
122
|
+
type: StringConstructor;
|
|
123
|
+
default: () => string;
|
|
124
|
+
validator(value: string): boolean;
|
|
125
|
+
};
|
|
126
|
+
suffix: {
|
|
127
|
+
type: StringConstructor;
|
|
128
|
+
default: () => string;
|
|
129
|
+
validator(value: string): boolean;
|
|
130
|
+
};
|
|
131
|
+
disableNegative: {
|
|
132
|
+
type: BooleanConstructor;
|
|
133
|
+
default: boolean;
|
|
134
|
+
};
|
|
135
|
+
disabled: {
|
|
136
|
+
type: BooleanConstructor;
|
|
137
|
+
default: boolean;
|
|
138
|
+
};
|
|
139
|
+
max: {
|
|
140
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
141
|
+
default: () => string | number | null;
|
|
142
|
+
};
|
|
143
|
+
min: {
|
|
144
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
145
|
+
default: () => string | number | null;
|
|
146
|
+
};
|
|
147
|
+
allowBlank: {
|
|
148
|
+
type: BooleanConstructor;
|
|
149
|
+
default: () => boolean;
|
|
150
|
+
};
|
|
151
|
+
minimumNumberOfCharacters: {
|
|
152
|
+
type: NumberConstructor;
|
|
153
|
+
default: () => number;
|
|
154
|
+
};
|
|
155
|
+
shouldRound: {
|
|
156
|
+
type: BooleanConstructor;
|
|
157
|
+
default: () => boolean;
|
|
158
|
+
};
|
|
159
|
+
}>> & {
|
|
160
|
+
"onUpdate:model-value"?: ((value: string | number) => any) | undefined;
|
|
161
|
+
}, {
|
|
162
|
+
debug: boolean;
|
|
163
|
+
masked: boolean;
|
|
164
|
+
prefix: string;
|
|
165
|
+
suffix: string;
|
|
166
|
+
thousands: string;
|
|
167
|
+
decimal: string;
|
|
168
|
+
precision: number;
|
|
169
|
+
disableNegative: boolean;
|
|
170
|
+
disabled: boolean;
|
|
171
|
+
min: string | number;
|
|
172
|
+
max: string | number;
|
|
173
|
+
allowBlank: boolean;
|
|
174
|
+
minimumNumberOfCharacters: number;
|
|
175
|
+
modelModifiers: Record<string, any>;
|
|
176
|
+
shouldRound: boolean;
|
|
177
|
+
id: string | number;
|
|
178
|
+
}>;
|
|
179
|
+
export default _default;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DirectiveBinding } from 'vue';
|
|
2
|
+
declare const _default: {
|
|
3
|
+
mounted(el: HTMLInputElement, binding: DirectiveBinding): void;
|
|
4
|
+
updated(el: HTMLInputElement, binding: DirectiveBinding): void;
|
|
5
|
+
beforeUnmount(el: HTMLInputElement): void;
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
package/dist/format.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import Money3Component from './component.vue';
|
|
3
|
+
import Money3Directive from './directive';
|
|
4
|
+
import format from './format';
|
|
5
|
+
import { VMoneyOptions } from './options';
|
|
6
|
+
import unformat from './unformat';
|
|
7
|
+
import BigNumber from './BigNumber';
|
|
8
|
+
declare const _default: {
|
|
9
|
+
install(app: App): void;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
12
|
+
export type { VMoneyOptions, };
|
|
13
|
+
export { Money3Component, Money3Directive, format, unformat, BigNumber, Money3Component as Money3, Money3Directive as VMoney3, Money3Component as Money, Money3Directive as VMoney, };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface VMoneyOptions {
|
|
2
|
+
debug: boolean;
|
|
3
|
+
masked: boolean;
|
|
4
|
+
prefix: string;
|
|
5
|
+
suffix: string;
|
|
6
|
+
thousands: string;
|
|
7
|
+
decimal: string;
|
|
8
|
+
precision: number;
|
|
9
|
+
disableNegative: boolean;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
min: number | string | null;
|
|
12
|
+
max: number | string | null;
|
|
13
|
+
allowBlank: boolean;
|
|
14
|
+
minimumNumberOfCharacters: number;
|
|
15
|
+
modelModifiers: any;
|
|
16
|
+
shouldRound: boolean;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
declare const _default: VMoneyOptions;
|
|
20
|
+
export default _default;
|
package/dist/v-money3.es.js
CHANGED
|
@@ -1 +1,581 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { defineComponent, getCurrentInstance, toRefs, ref, watch, useAttrs, computed, resolveDirective, withDirectives, openBlock, createElementBlock, mergeProps, unref } from "vue";
|
|
8
|
+
const RESTRICTED_CHARACTERS = ["+", "-"];
|
|
9
|
+
const RESTRICTED_OPTIONS = ["decimal", "thousands", "prefix", "suffix"];
|
|
10
|
+
function fixed(precision) {
|
|
11
|
+
return Math.max(0, Math.min(precision, 1e3));
|
|
12
|
+
}
|
|
13
|
+
function numbersToCurrency(numbers, precision) {
|
|
14
|
+
numbers = numbers.padStart(precision + 1, "0");
|
|
15
|
+
return precision === 0 ? numbers : `${numbers.slice(0, -precision)}.${numbers.slice(-precision)}`;
|
|
16
|
+
}
|
|
17
|
+
function onlyNumbers(input) {
|
|
18
|
+
input = input ? input.toString() : "";
|
|
19
|
+
return input.replace(/\D+/g, "") || "0";
|
|
20
|
+
}
|
|
21
|
+
function addThousandSeparator(integer, separator) {
|
|
22
|
+
return integer.replace(/(\d)(?=(?:\d{3})+\b)/gm, `$1${separator}`);
|
|
23
|
+
}
|
|
24
|
+
function joinIntegerAndDecimal(integer, decimal, separator) {
|
|
25
|
+
return decimal ? integer + separator + decimal : integer;
|
|
26
|
+
}
|
|
27
|
+
function validateRestrictedInput(value, caller) {
|
|
28
|
+
if (RESTRICTED_CHARACTERS.includes(value)) {
|
|
29
|
+
console.warn(`v-money3 "${caller}" property don't accept "${value}" as a value.`);
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (/\d/g.test(value)) {
|
|
33
|
+
console.warn(`v-money3 "${caller}" property don't accept "${value}" (any number) as a value.`);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
function validateRestrictedOptions(opt) {
|
|
39
|
+
for (const target of RESTRICTED_OPTIONS) {
|
|
40
|
+
const isValid = validateRestrictedInput(opt[target], target);
|
|
41
|
+
if (!isValid) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
function filterOptRestrictions(opt) {
|
|
48
|
+
for (const option of RESTRICTED_OPTIONS) {
|
|
49
|
+
opt[option] = opt[option].replace(/\d+/g, "");
|
|
50
|
+
for (const character of RESTRICTED_CHARACTERS) {
|
|
51
|
+
opt[option] = opt[option].replaceAll(character, "");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return opt;
|
|
55
|
+
}
|
|
56
|
+
function guessFloatPrecision(string) {
|
|
57
|
+
const total = string.length;
|
|
58
|
+
const index2 = string.indexOf(".");
|
|
59
|
+
return total - (index2 + 1);
|
|
60
|
+
}
|
|
61
|
+
function removeLeadingZeros(string) {
|
|
62
|
+
return string.replace(/^(-?)0+(?!\.)(.+)/, "$1$2");
|
|
63
|
+
}
|
|
64
|
+
function isValidInteger(str) {
|
|
65
|
+
return /^-?[\d]+$/g.test(str);
|
|
66
|
+
}
|
|
67
|
+
function isValidFloat(str) {
|
|
68
|
+
return /^-?[\d]+(\.[\d]+)$/g.test(str);
|
|
69
|
+
}
|
|
70
|
+
function replaceAt(str, index2, chr) {
|
|
71
|
+
if (index2 > str.length - 1)
|
|
72
|
+
return str;
|
|
73
|
+
return str.substring(0, index2) + chr + str.substring(index2 + 1);
|
|
74
|
+
}
|
|
75
|
+
function round(string, precision) {
|
|
76
|
+
const diff = precision - guessFloatPrecision(string);
|
|
77
|
+
if (diff >= 0) {
|
|
78
|
+
return string;
|
|
79
|
+
}
|
|
80
|
+
let firstPiece = string.slice(0, diff);
|
|
81
|
+
const lastPiece = string.slice(diff);
|
|
82
|
+
if (firstPiece.charAt(firstPiece.length - 1) === ".") {
|
|
83
|
+
firstPiece = firstPiece.slice(0, -1);
|
|
84
|
+
}
|
|
85
|
+
if (parseInt(lastPiece.charAt(0), 10) >= 5) {
|
|
86
|
+
for (let i = firstPiece.length - 1; i >= 0; i -= 1) {
|
|
87
|
+
const char = firstPiece.charAt(i);
|
|
88
|
+
if (char !== "." && char !== "-") {
|
|
89
|
+
const newValue = parseInt(char, 10) + 1;
|
|
90
|
+
if (newValue < 10) {
|
|
91
|
+
return replaceAt(firstPiece, i, newValue);
|
|
92
|
+
}
|
|
93
|
+
firstPiece = replaceAt(firstPiece, i, "0");
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return `1${firstPiece}`;
|
|
97
|
+
}
|
|
98
|
+
return firstPiece;
|
|
99
|
+
}
|
|
100
|
+
function setCursor(el, position) {
|
|
101
|
+
const setSelectionRange = () => {
|
|
102
|
+
el.setSelectionRange(position, position);
|
|
103
|
+
};
|
|
104
|
+
if (el === document.activeElement) {
|
|
105
|
+
setSelectionRange();
|
|
106
|
+
setTimeout(setSelectionRange, 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function event(name) {
|
|
110
|
+
return new Event(name, { bubbles: true, cancelable: false });
|
|
111
|
+
}
|
|
112
|
+
function debug({ debug: debug2 = false }, ...args) {
|
|
113
|
+
if (debug2)
|
|
114
|
+
console.log(...args);
|
|
115
|
+
}
|
|
116
|
+
var defaults = {
|
|
117
|
+
debug: false,
|
|
118
|
+
masked: false,
|
|
119
|
+
prefix: "",
|
|
120
|
+
suffix: "",
|
|
121
|
+
thousands: ",",
|
|
122
|
+
decimal: ".",
|
|
123
|
+
precision: 2,
|
|
124
|
+
disableNegative: false,
|
|
125
|
+
disabled: false,
|
|
126
|
+
min: null,
|
|
127
|
+
max: null,
|
|
128
|
+
allowBlank: false,
|
|
129
|
+
minimumNumberOfCharacters: 0,
|
|
130
|
+
modelModifiers: {
|
|
131
|
+
number: false
|
|
132
|
+
},
|
|
133
|
+
shouldRound: true
|
|
134
|
+
};
|
|
135
|
+
class BigNumber {
|
|
136
|
+
constructor(number) {
|
|
137
|
+
__publicField(this, "number", 0n);
|
|
138
|
+
__publicField(this, "decimal", 0);
|
|
139
|
+
this.setNumber(number);
|
|
140
|
+
}
|
|
141
|
+
getNumber() {
|
|
142
|
+
return this.number;
|
|
143
|
+
}
|
|
144
|
+
getDecimalPrecision() {
|
|
145
|
+
return this.decimal;
|
|
146
|
+
}
|
|
147
|
+
setNumber(number) {
|
|
148
|
+
this.decimal = 0;
|
|
149
|
+
if (typeof number === "bigint") {
|
|
150
|
+
this.number = number;
|
|
151
|
+
} else if (typeof number === "number") {
|
|
152
|
+
this.setupString(number.toString());
|
|
153
|
+
} else {
|
|
154
|
+
this.setupString(number);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
toFixed(precision = 0, shouldRound = true) {
|
|
158
|
+
let string = this.toString();
|
|
159
|
+
const diff = precision - this.getDecimalPrecision();
|
|
160
|
+
if (diff > 0) {
|
|
161
|
+
if (!string.includes(".")) {
|
|
162
|
+
string += ".";
|
|
163
|
+
}
|
|
164
|
+
return string.padEnd(string.length + diff, "0");
|
|
165
|
+
}
|
|
166
|
+
if (diff < 0) {
|
|
167
|
+
if (shouldRound) {
|
|
168
|
+
return round(string, precision);
|
|
169
|
+
}
|
|
170
|
+
return string.slice(0, diff);
|
|
171
|
+
}
|
|
172
|
+
return string;
|
|
173
|
+
}
|
|
174
|
+
toString() {
|
|
175
|
+
let string = this.number.toString();
|
|
176
|
+
if (this.decimal) {
|
|
177
|
+
let isNegative = false;
|
|
178
|
+
if (string.charAt(0) === "-") {
|
|
179
|
+
string = string.substring(1);
|
|
180
|
+
isNegative = true;
|
|
181
|
+
}
|
|
182
|
+
string = string.padStart(string.length + this.decimal, "0");
|
|
183
|
+
string = `${string.slice(0, -this.decimal)}.${string.slice(-this.decimal)}`;
|
|
184
|
+
string = removeLeadingZeros(string);
|
|
185
|
+
return (isNegative ? "-" : "") + string;
|
|
186
|
+
}
|
|
187
|
+
return string;
|
|
188
|
+
}
|
|
189
|
+
lessThan(thatBigNumber) {
|
|
190
|
+
const [thisNumber, thatNumber] = this.adjustComparisonNumbers(thatBigNumber);
|
|
191
|
+
return thisNumber < thatNumber;
|
|
192
|
+
}
|
|
193
|
+
biggerThan(thatBigNumber) {
|
|
194
|
+
const [thisNumber, thatNumber] = this.adjustComparisonNumbers(thatBigNumber);
|
|
195
|
+
return thisNumber > thatNumber;
|
|
196
|
+
}
|
|
197
|
+
isEqual(thatBigNumber) {
|
|
198
|
+
const [thisNumber, thatNumber] = this.adjustComparisonNumbers(thatBigNumber);
|
|
199
|
+
return thisNumber === thatNumber;
|
|
200
|
+
}
|
|
201
|
+
setupString(number) {
|
|
202
|
+
number = removeLeadingZeros(number);
|
|
203
|
+
if (isValidInteger(number)) {
|
|
204
|
+
this.number = BigInt(number);
|
|
205
|
+
} else if (isValidFloat(number)) {
|
|
206
|
+
this.decimal = guessFloatPrecision(number);
|
|
207
|
+
this.number = BigInt(number.replace(".", ""));
|
|
208
|
+
} else {
|
|
209
|
+
throw new Error(`BigNumber has received and invalid format for the constructor: ${number}`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
adjustComparisonNumbers(thatNumberParam) {
|
|
213
|
+
let thatNumber;
|
|
214
|
+
if (thatNumberParam.constructor.name !== "BigNumber") {
|
|
215
|
+
thatNumber = new BigNumber(thatNumberParam);
|
|
216
|
+
} else {
|
|
217
|
+
thatNumber = thatNumberParam;
|
|
218
|
+
}
|
|
219
|
+
const diff = this.getDecimalPrecision() - thatNumber.getDecimalPrecision();
|
|
220
|
+
let thisNum = this.getNumber();
|
|
221
|
+
let thatNum = thatNumber.getNumber();
|
|
222
|
+
if (diff > 0) {
|
|
223
|
+
thatNum = thatNumber.getNumber() * 10n ** BigInt(diff);
|
|
224
|
+
} else if (diff < 0) {
|
|
225
|
+
thisNum = this.getNumber() * 10n ** BigInt(diff * -1);
|
|
226
|
+
}
|
|
227
|
+
return [thisNum, thatNum];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
function format(input, opt = defaults, caller = "") {
|
|
231
|
+
debug(opt, "utils format() - caller", caller);
|
|
232
|
+
debug(opt, "utils format() - input1", input);
|
|
233
|
+
if (input === null || input === void 0) {
|
|
234
|
+
input = "";
|
|
235
|
+
} else if (typeof input === "number") {
|
|
236
|
+
if (opt.shouldRound) {
|
|
237
|
+
input = input.toFixed(fixed(opt.precision));
|
|
238
|
+
} else {
|
|
239
|
+
input = input.toFixed(fixed(opt.precision) + 1).slice(0, -1);
|
|
240
|
+
}
|
|
241
|
+
} else if (opt.modelModifiers && opt.modelModifiers.number && isValidInteger(input)) {
|
|
242
|
+
input = Number(input).toFixed(fixed(opt.precision));
|
|
243
|
+
}
|
|
244
|
+
debug(opt, "utils format() - input2", input);
|
|
245
|
+
const negative = opt.disableNegative ? "" : input.indexOf("-") >= 0 ? "-" : "";
|
|
246
|
+
let filtered = input.replace(opt.prefix, "").replace(opt.suffix, "");
|
|
247
|
+
debug(opt, "utils format() - filtered", filtered);
|
|
248
|
+
if (!opt.precision && opt.thousands !== "." && isValidFloat(filtered)) {
|
|
249
|
+
filtered = round(filtered, 0);
|
|
250
|
+
debug(opt, "utils format() - !opt.precision && isValidFloat()", filtered);
|
|
251
|
+
}
|
|
252
|
+
const numbers = onlyNumbers(filtered);
|
|
253
|
+
debug(opt, "utils format() - numbers", numbers);
|
|
254
|
+
debug(opt, "utils format() - numbersToCurrency", negative + numbersToCurrency(numbers, opt.precision));
|
|
255
|
+
const bigNumber = new BigNumber(negative + numbersToCurrency(numbers, opt.precision));
|
|
256
|
+
debug(opt, "utils format() - bigNumber1", bigNumber.toString());
|
|
257
|
+
if (opt.max) {
|
|
258
|
+
if (bigNumber.biggerThan(opt.max)) {
|
|
259
|
+
bigNumber.setNumber(opt.max);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (opt.min) {
|
|
263
|
+
if (bigNumber.lessThan(opt.min)) {
|
|
264
|
+
bigNumber.setNumber(opt.min);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const currency = bigNumber.toFixed(fixed(opt.precision), opt.shouldRound);
|
|
268
|
+
debug(opt, "utils format() - bigNumber2", bigNumber.toFixed(fixed(opt.precision)));
|
|
269
|
+
if (/^0(\.0+)?$/g.test(currency) && opt.allowBlank) {
|
|
270
|
+
return "";
|
|
271
|
+
}
|
|
272
|
+
let [integer, decimal] = currency.split(".");
|
|
273
|
+
const decimalLength = decimal !== void 0 ? decimal.length : 0;
|
|
274
|
+
integer = integer.padStart(opt.minimumNumberOfCharacters - decimalLength, "0");
|
|
275
|
+
integer = addThousandSeparator(integer, opt.thousands);
|
|
276
|
+
const output = opt.prefix + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.suffix;
|
|
277
|
+
debug(opt, "utils format() - output", output);
|
|
278
|
+
return output;
|
|
279
|
+
}
|
|
280
|
+
function unformat(input, opt = defaults, caller = "") {
|
|
281
|
+
debug(opt, "utils unformat() - caller", caller);
|
|
282
|
+
debug(opt, "utils unformat() - input", input);
|
|
283
|
+
const negative = opt.disableNegative ? "" : input.indexOf("-") >= 0 ? "-" : "";
|
|
284
|
+
const filtered = input.replace(opt.prefix, "").replace(opt.suffix, "");
|
|
285
|
+
debug(opt, "utils unformat() - filtered", filtered);
|
|
286
|
+
const numbers = onlyNumbers(filtered);
|
|
287
|
+
debug(opt, "utils unformat() - numbers", numbers);
|
|
288
|
+
const bigNumber = new BigNumber(negative + numbersToCurrency(numbers, opt.precision));
|
|
289
|
+
debug(opt, "utils unformat() - bigNumber1", numbers.toString());
|
|
290
|
+
if (opt.max) {
|
|
291
|
+
if (bigNumber.biggerThan(opt.max)) {
|
|
292
|
+
bigNumber.setNumber(opt.max);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (opt.min) {
|
|
296
|
+
if (bigNumber.lessThan(opt.min)) {
|
|
297
|
+
bigNumber.setNumber(opt.min);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
let output = bigNumber.toFixed(fixed(opt.precision), opt.shouldRound);
|
|
301
|
+
if (opt.modelModifiers && opt.modelModifiers.number) {
|
|
302
|
+
output = parseFloat(output);
|
|
303
|
+
}
|
|
304
|
+
debug(opt, "utils unformat() - output", output);
|
|
305
|
+
return output;
|
|
306
|
+
}
|
|
307
|
+
const setValue = (el, opt, caller) => {
|
|
308
|
+
debug(opt, "directive setValue() - caller", caller);
|
|
309
|
+
if (!validateRestrictedOptions(opt)) {
|
|
310
|
+
debug(opt, "directive setValue() - validateRestrictedOptions() return false. Stopping here...", el.value);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
let positionFromEnd = el.value.length - (el.selectionEnd || 0);
|
|
314
|
+
el.value = format(el.value, opt, caller);
|
|
315
|
+
positionFromEnd = Math.max(positionFromEnd, opt.suffix.length);
|
|
316
|
+
positionFromEnd = el.value.length - positionFromEnd;
|
|
317
|
+
positionFromEnd = Math.max(positionFromEnd, opt.prefix.length);
|
|
318
|
+
setCursor(el, positionFromEnd);
|
|
319
|
+
el.dispatchEvent(event("change"));
|
|
320
|
+
};
|
|
321
|
+
const onKeyDown = (e, opt) => {
|
|
322
|
+
const el = e.currentTarget;
|
|
323
|
+
const backspacePressed = e.code === "Backspace" || e.code === "Delete";
|
|
324
|
+
const isAtEndPosition = el.value.length - (el.selectionEnd || 0) === 0;
|
|
325
|
+
debug(opt, "directive onkeydown() - el.value", el.value);
|
|
326
|
+
debug(opt, "directive onkeydown() - backspacePressed", backspacePressed);
|
|
327
|
+
debug(opt, "directive onkeydown() - isAtEndPosition", isAtEndPosition);
|
|
328
|
+
if (opt.allowBlank && backspacePressed && isAtEndPosition && unformat(el.value, opt, "directive onkeydown allowBlank") === 0) {
|
|
329
|
+
debug(opt, 'directive onkeydown() - set el.value = ""', el.value);
|
|
330
|
+
el.value = "";
|
|
331
|
+
el.dispatchEvent(event("change"));
|
|
332
|
+
}
|
|
333
|
+
debug(opt, "directive onkeydown() - e.key", e.key);
|
|
334
|
+
if (e.key === "+") {
|
|
335
|
+
debug(opt, "directive onkeydown() - unformat el.value", el.value);
|
|
336
|
+
let number = unformat(el.value, opt, "directive onkeydown +");
|
|
337
|
+
if (typeof number === "string") {
|
|
338
|
+
number = parseFloat(number);
|
|
339
|
+
}
|
|
340
|
+
if (number < 0) {
|
|
341
|
+
el.value = String(number * -1);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
const onInput = (e, opt) => {
|
|
346
|
+
const el = e.currentTarget;
|
|
347
|
+
debug(opt, "directive oninput()", el.value);
|
|
348
|
+
if (/^[1-9]$/.test(el.value)) {
|
|
349
|
+
el.value = numbersToCurrency(el.value, fixed(opt.precision));
|
|
350
|
+
debug(opt, "directive oninput() - is 1-9", el.value);
|
|
351
|
+
}
|
|
352
|
+
setValue(el, opt, "directive oninput");
|
|
353
|
+
};
|
|
354
|
+
var Money3Directive = {
|
|
355
|
+
mounted(el, binding) {
|
|
356
|
+
if (!binding.value) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const opt = filterOptRestrictions({ ...defaults, ...binding.value });
|
|
360
|
+
debug(opt, "directive mounted() - opt", opt);
|
|
361
|
+
if (el.tagName.toLocaleUpperCase() !== "INPUT") {
|
|
362
|
+
const els = el.getElementsByTagName("input");
|
|
363
|
+
if (els.length !== 1)
|
|
364
|
+
;
|
|
365
|
+
else {
|
|
366
|
+
el = els[0];
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
el.onkeydown = (e) => {
|
|
370
|
+
onKeyDown(e, opt);
|
|
371
|
+
};
|
|
372
|
+
el.oninput = (e) => {
|
|
373
|
+
onInput(e, opt);
|
|
374
|
+
};
|
|
375
|
+
debug(opt, "directive mounted() - el.value", el.value);
|
|
376
|
+
setValue(el, opt, "directive mounted");
|
|
377
|
+
},
|
|
378
|
+
updated(el, binding) {
|
|
379
|
+
if (!binding.value) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const opt = filterOptRestrictions({ ...defaults, ...binding.value });
|
|
383
|
+
el.onkeydown = (e) => {
|
|
384
|
+
onKeyDown(e, opt);
|
|
385
|
+
};
|
|
386
|
+
el.oninput = (e) => {
|
|
387
|
+
onInput(e, opt);
|
|
388
|
+
};
|
|
389
|
+
debug(opt, "directive updated() - el.value", el.value);
|
|
390
|
+
debug(opt, "directive updated() - opt", opt);
|
|
391
|
+
setValue(el, opt, "directive updated");
|
|
392
|
+
},
|
|
393
|
+
beforeUnmount(el) {
|
|
394
|
+
el.onkeydown = null;
|
|
395
|
+
el.oninput = null;
|
|
396
|
+
el.onfocus = null;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const _hoisted_1 = ["id", "value", "disabled"];
|
|
400
|
+
const __default__ = {
|
|
401
|
+
inheritAttrs: false,
|
|
402
|
+
name: "Money3",
|
|
403
|
+
directives: {
|
|
404
|
+
money3: Money3Directive
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
408
|
+
...__default__,
|
|
409
|
+
props: {
|
|
410
|
+
debug: {
|
|
411
|
+
required: false,
|
|
412
|
+
type: Boolean,
|
|
413
|
+
default: false
|
|
414
|
+
},
|
|
415
|
+
id: {
|
|
416
|
+
required: false,
|
|
417
|
+
type: [Number, String],
|
|
418
|
+
default: () => {
|
|
419
|
+
const instante = getCurrentInstance();
|
|
420
|
+
if (instante) {
|
|
421
|
+
return instante.uid;
|
|
422
|
+
}
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
modelValue: {
|
|
427
|
+
required: true,
|
|
428
|
+
type: [Number, String]
|
|
429
|
+
},
|
|
430
|
+
modelModifiers: {
|
|
431
|
+
required: false,
|
|
432
|
+
type: Object,
|
|
433
|
+
default: () => ({ number: false })
|
|
434
|
+
},
|
|
435
|
+
masked: {
|
|
436
|
+
type: Boolean,
|
|
437
|
+
default: false
|
|
438
|
+
},
|
|
439
|
+
precision: {
|
|
440
|
+
type: Number,
|
|
441
|
+
default: () => defaults.precision
|
|
442
|
+
},
|
|
443
|
+
decimal: {
|
|
444
|
+
type: String,
|
|
445
|
+
default: () => defaults.decimal,
|
|
446
|
+
validator(value) {
|
|
447
|
+
return validateRestrictedInput(value, "decimal");
|
|
448
|
+
}
|
|
449
|
+
},
|
|
450
|
+
thousands: {
|
|
451
|
+
type: String,
|
|
452
|
+
default: () => defaults.thousands,
|
|
453
|
+
validator(value) {
|
|
454
|
+
return validateRestrictedInput(value, "thousands");
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
prefix: {
|
|
458
|
+
type: String,
|
|
459
|
+
default: () => defaults.prefix,
|
|
460
|
+
validator(value) {
|
|
461
|
+
return validateRestrictedInput(value, "prefix");
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
suffix: {
|
|
465
|
+
type: String,
|
|
466
|
+
default: () => defaults.suffix,
|
|
467
|
+
validator(value) {
|
|
468
|
+
return validateRestrictedInput(value, "suffix");
|
|
469
|
+
}
|
|
470
|
+
},
|
|
471
|
+
disableNegative: {
|
|
472
|
+
type: Boolean,
|
|
473
|
+
default: false
|
|
474
|
+
},
|
|
475
|
+
disabled: {
|
|
476
|
+
type: Boolean,
|
|
477
|
+
default: false
|
|
478
|
+
},
|
|
479
|
+
max: {
|
|
480
|
+
type: [Number, String],
|
|
481
|
+
default: () => defaults.max
|
|
482
|
+
},
|
|
483
|
+
min: {
|
|
484
|
+
type: [Number, String],
|
|
485
|
+
default: () => defaults.min
|
|
486
|
+
},
|
|
487
|
+
allowBlank: {
|
|
488
|
+
type: Boolean,
|
|
489
|
+
default: () => defaults.allowBlank
|
|
490
|
+
},
|
|
491
|
+
minimumNumberOfCharacters: {
|
|
492
|
+
type: Number,
|
|
493
|
+
default: () => defaults.minimumNumberOfCharacters
|
|
494
|
+
},
|
|
495
|
+
shouldRound: {
|
|
496
|
+
type: Boolean,
|
|
497
|
+
default: () => defaults.shouldRound
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
emits: ["update:model-value"],
|
|
501
|
+
setup(__props, { emit }) {
|
|
502
|
+
const props = __props;
|
|
503
|
+
const { modelValue, modelModifiers, masked, precision, shouldRound } = toRefs(props);
|
|
504
|
+
debug(props, "component setup()", props);
|
|
505
|
+
let value = modelValue.value;
|
|
506
|
+
if (modelModifiers.value && modelModifiers.value.number) {
|
|
507
|
+
if (shouldRound.value) {
|
|
508
|
+
value = Number(modelValue.value).toFixed(fixed(precision.value));
|
|
509
|
+
} else {
|
|
510
|
+
value = Number(modelValue.value).toFixed(fixed(precision.value) + 1).slice(0, -1);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const formattedValue = ref(format(value, props, "component setup"));
|
|
514
|
+
debug(props, "component setup() - data.formattedValue", formattedValue.value);
|
|
515
|
+
watch(modelValue, modelValueWatcher);
|
|
516
|
+
function modelValueWatcher(value2) {
|
|
517
|
+
debug(props, "component watch() -> value", value2);
|
|
518
|
+
const formatted = format(value2, filterOptRestrictions({ ...props }), "component watch");
|
|
519
|
+
if (formatted !== formattedValue.value) {
|
|
520
|
+
debug(props, "component watch() changed -> formatted", formatted);
|
|
521
|
+
formattedValue.value = formatted;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
let lastValue = null;
|
|
525
|
+
function change(evt) {
|
|
526
|
+
let value2 = evt.target?.value;
|
|
527
|
+
debug(props, "component change() -> evt.target.value", value2);
|
|
528
|
+
if (!(masked.value && !modelModifiers.value.number)) {
|
|
529
|
+
value2 = unformat(value2, filterOptRestrictions({ ...props }), "component change");
|
|
530
|
+
}
|
|
531
|
+
if (value2 !== lastValue) {
|
|
532
|
+
lastValue = value2;
|
|
533
|
+
debug(props, "component change() -> update:model-value", value2);
|
|
534
|
+
emit("update:model-value", value2);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
const attrs = useAttrs();
|
|
538
|
+
const listeners = computed(() => {
|
|
539
|
+
const payload = {
|
|
540
|
+
...attrs
|
|
541
|
+
};
|
|
542
|
+
delete payload["onUpdate:modelValue"];
|
|
543
|
+
return payload;
|
|
544
|
+
});
|
|
545
|
+
return (_ctx, _cache) => {
|
|
546
|
+
const _directive_money3 = resolveDirective("money3");
|
|
547
|
+
return withDirectives((openBlock(), createElementBlock("input", mergeProps({
|
|
548
|
+
id: `${__props.id}`
|
|
549
|
+
}, unref(listeners), {
|
|
550
|
+
type: "tel",
|
|
551
|
+
class: "v-money3",
|
|
552
|
+
value: formattedValue.value,
|
|
553
|
+
disabled: props.disabled,
|
|
554
|
+
onChange: change
|
|
555
|
+
}), null, 16, _hoisted_1)), [
|
|
556
|
+
[_directive_money3, {
|
|
557
|
+
precision: unref(precision),
|
|
558
|
+
decimal: props.decimal,
|
|
559
|
+
thousands: props.thousands,
|
|
560
|
+
prefix: props.prefix,
|
|
561
|
+
suffix: props.suffix,
|
|
562
|
+
disableNegative: props.disableNegative,
|
|
563
|
+
min: props.min,
|
|
564
|
+
max: props.max,
|
|
565
|
+
allowBlank: props.allowBlank,
|
|
566
|
+
minimumNumberOfCharacters: props.minimumNumberOfCharacters,
|
|
567
|
+
debug: props.debug,
|
|
568
|
+
modelModifiers: unref(modelModifiers),
|
|
569
|
+
shouldRound: unref(shouldRound)
|
|
570
|
+
}]
|
|
571
|
+
]);
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
var index = {
|
|
576
|
+
install(app) {
|
|
577
|
+
app.component("money3", _sfc_main);
|
|
578
|
+
app.directive("money3", Money3Directive);
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
export { BigNumber, _sfc_main as Money, _sfc_main as Money3, _sfc_main as Money3Component, Money3Directive, Money3Directive as VMoney, Money3Directive as VMoney3, index as default, format, unformat };
|
package/dist/v-money3.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __defProp=Object.defineProperty,__defNormalProp=(e,t,n)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,__publicField=(e,t,n)=>(__defNormalProp(e,"symbol"!=typeof t?t+"":t,n),n);!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["v-money3"]={},e.Vue)}(this,(function(e,t){"use strict";var n={debug:!1,masked:!1,prefix:"",suffix:"",thousands:",",decimal:".",precision:2,disableNegative:!1,disabled:!1,min:null,max:null,allowBlank:!1,minimumNumberOfCharacters:0,modelModifiers:{number:!1},shouldRound:!0};const i=["+","-"],r=["decimal","thousands","prefix","suffix"];function o(e){return Math.max(0,Math.min(e,1e3))}function u(e,t){return e=e.padStart(t+1,"0"),0===t?e:`${e.slice(0,-t)}.${e.slice(-t)}`}function a(e){return(e=e?e.toString():"").replace(/\D+/g,"")||"0"}function l(e,t){return i.includes(e)?(console.warn(`v-money3 "${t}" property don't accept "${e}" as a value.`),!1):!/\d/g.test(e)||(console.warn(`v-money3 "${t}" property don't accept "${e}" (any number) as a value.`),!1)}function s(e){for(const t of r){e[t]=e[t].replace(/\d+/g,"");for(const n of i)e[t]=e[t].replaceAll(n,"")}return e}function d(e){return e.length-(e.indexOf(".")+1)}function c(e){return e.replace(/^(-?)0+(?!\.)(.+)/,"$1$2")}function m(e){return/^-?[\d]+$/g.test(e)}function f(e){return/^-?[\d]+(\.[\d]+)$/g.test(e)}function p(e,t,n){return t>e.length-1?e:e.substring(0,t)+n+e.substring(t+1)}function v(e,t){const n=t-d(e);if(n>=0)return e;let i=e.slice(0,n);const r=e.slice(n);if("."===i.charAt(i.length-1)&&(i=i.slice(0,-1)),parseInt(r.charAt(0),10)>=5){for(let e=i.length-1;e>=0;e-=1){const t=i.charAt(e);if("."!==t&&"-"!==t){const n=parseInt(t,10)+1;if(n<10)return p(i,e,n);i=p(i,e,"0")}}return`1${i}`}return i}function g(e){return new Event(e,{bubbles:!0,cancelable:!1})}function b({debug:e=!1},...t){e&&console.log(...t)}class h{constructor(e){__publicField(this,"number",0n),__publicField(this,"decimal",0),this.setNumber(e)}getNumber(){return this.number}getDecimalPrecision(){return this.decimal}setNumber(e){this.decimal=0,"bigint"==typeof e?this.number=e:"number"==typeof e?this.setupString(e.toString()):this.setupString(e)}toFixed(e=0,t=!0){let n=this.toString();const i=e-this.getDecimalPrecision();return i>0?(n.includes(".")||(n+="."),n.padEnd(n.length+i,"0")):i<0?t?v(n,e):n.slice(0,i):n}toString(){let e=this.number.toString();if(this.decimal){let t=!1;return"-"===e.charAt(0)&&(e=e.substring(1),t=!0),e=e.padStart(e.length+this.decimal,"0"),e=`${e.slice(0,-this.decimal)}.${e.slice(-this.decimal)}`,e=c(e),(t?"-":"")+e}return e}lessThan(e){const[t,n]=this.adjustComparisonNumbers(e);return t<n}biggerThan(e){const[t,n]=this.adjustComparisonNumbers(e);return t>n}isEqual(e){const[t,n]=this.adjustComparisonNumbers(e);return t===n}setupString(e){if(m(e=c(e)))this.number=BigInt(e);else{if(!f(e))throw new Error(`BigNumber has received and invalid format for the constructor: ${e}`);this.decimal=d(e),this.number=BigInt(e.replace(".",""))}}adjustComparisonNumbers(e){let t;t="BigNumber"!==e.constructor.name?new h(e):e;const n=this.getDecimalPrecision()-t.getDecimalPrecision();let i=this.getNumber(),r=t.getNumber();return n>0?r=t.getNumber()*10n**BigInt(n):n<0&&(i=this.getNumber()*10n**BigInt(-1*n)),[i,r]}}function y(e,t=n,i=""){b(t,"utils format() - caller",i),b(t,"utils format() - input1",e),null==e?e="":"number"==typeof e?e=t.shouldRound?e.toFixed(o(t.precision)):e.toFixed(o(t.precision)+1).slice(0,-1):t.modelModifiers&&t.modelModifiers.number&&m(e)&&(e=Number(e).toFixed(o(t.precision))),b(t,"utils format() - input2",e);const r=t.disableNegative?"":e.indexOf("-")>=0?"-":"";let l=e.replace(t.prefix,"").replace(t.suffix,"");b(t,"utils format() - filtered",l),!t.precision&&"."!==t.thousands&&f(l)&&(l=v(l,0),b(t,"utils format() - !opt.precision && isValidFloat()",l));const s=a(l);b(t,"utils format() - numbers",s),b(t,"utils format() - numbersToCurrency",r+u(s,t.precision));const d=new h(r+u(s,t.precision));b(t,"utils format() - bigNumber1",d.toString()),t.max&&d.biggerThan(t.max)&&d.setNumber(t.max),t.min&&d.lessThan(t.min)&&d.setNumber(t.min);const c=d.toFixed(o(t.precision),t.shouldRound);if(b(t,"utils format() - bigNumber2",d.toFixed(o(t.precision))),/^0(\.0+)?$/g.test(c)&&t.allowBlank)return"";let[p,g]=c.split(".");const y=void 0!==g?g.length:0;p=p.padStart(t.minimumNumberOfCharacters-y,"0"),p=function(e,t){return e.replace(/(\d)(?=(?:\d{3})+\b)/gm,`$1${t}`)}(p,t.thousands);const x=t.prefix+function(e,t,n){return t?e+n+t:e}(p,g,t.decimal)+t.suffix;return b(t,"utils format() - output",x),x}function x(e,t=n,i=""){b(t,"utils unformat() - caller",i),b(t,"utils unformat() - input",e);const r=t.disableNegative?"":e.indexOf("-")>=0?"-":"",l=e.replace(t.prefix,"").replace(t.suffix,"");b(t,"utils unformat() - filtered",l);const s=a(l);b(t,"utils unformat() - numbers",s);const d=new h(r+u(s,t.precision));b(t,"utils unformat() - bigNumber1",s.toString()),t.max&&d.biggerThan(t.max)&&d.setNumber(t.max),t.min&&d.lessThan(t.min)&&d.setNumber(t.min);let c=d.toFixed(o(t.precision),t.shouldRound);return t.modelModifiers&&t.modelModifiers.number&&(c=parseFloat(c)),b(t,"utils unformat() - output",c),c}const N=(e,t,n)=>{if(b(t,"directive setValue() - caller",n),!function(e){for(const t of r)if(!l(e[t],t))return!1;return!0}(t))return void b(t,"directive setValue() - validateRestrictedOptions() return false. Stopping here...",e.value);let i=e.value.length-(e.selectionEnd||0);e.value=y(e.value,t,n),i=Math.max(i,t.suffix.length),i=e.value.length-i,i=Math.max(i,t.prefix.length),function(e,t){const n=()=>{e.setSelectionRange(t,t)};e===document.activeElement&&(n(),setTimeout(n,1))}(e,i),e.dispatchEvent(g("change"))},w=(e,t)=>{const n=e.currentTarget,i="Backspace"===e.code||"Delete"===e.code,r=n.value.length-(n.selectionEnd||0)==0;if(b(t,"directive onkeydown() - el.value",n.value),b(t,"directive onkeydown() - backspacePressed",i),b(t,"directive onkeydown() - isAtEndPosition",r),t.allowBlank&&i&&r&&0===x(n.value,t,"directive onkeydown allowBlank")&&(b(t,'directive onkeydown() - set el.value = ""',n.value),n.value="",n.dispatchEvent(g("change"))),b(t,"directive onkeydown() - e.key",e.key),"+"===e.key){b(t,"directive onkeydown() - unformat el.value",n.value);let e=x(n.value,t,"directive onkeydown +");"string"==typeof e&&(e=parseFloat(e)),e<0&&(n.value=String(-1*e))}},k=(e,t)=>{const n=e.currentTarget;b(t,"directive oninput()",n.value),/^[1-9]$/.test(n.value)&&(n.value=u(n.value,o(t.precision)),b(t,"directive oninput() - is 1-9",n.value)),N(n,t,"directive oninput")};var S={mounted(e,t){if(!t.value)return;const i=s({...n,...t.value});if(b(i,"directive mounted() - opt",i),"INPUT"!==e.tagName.toLocaleUpperCase()){const t=e.getElementsByTagName("input");1!==t.length||(e=t[0])}e.onkeydown=e=>{w(e,i)},e.oninput=e=>{k(e,i)},b(i,"directive mounted() - el.value",e.value),N(e,i,"directive mounted")},updated(e,t){if(!t.value)return;const i=s({...n,...t.value});e.onkeydown=e=>{w(e,i)},e.oninput=e=>{k(e,i)},b(i,"directive updated() - el.value",e.value),b(i,"directive updated() - opt",i),N(e,i,"directive updated")},beforeUnmount(e){e.onkeydown=null,e.oninput=null,e.onfocus=null}};const B=["id","value","disabled"];const M={inheritAttrs:!1,name:"Money3",directives:{money3:S}},$=t.defineComponent({...M,props:{debug:{required:!1,type:Boolean,default:!1},id:{required:!1,type:[Number,String],default:()=>{const e=t.getCurrentInstance();return e?e.uid:null}},modelValue:{required:!0,type:[Number,String]},modelModifiers:{required:!1,type:Object,default:()=>({number:!1})},masked:{type:Boolean,default:!1},precision:{type:Number,default:()=>n.precision},decimal:{type:String,default:()=>n.decimal,validator:e=>l(e,"decimal")},thousands:{type:String,default:()=>n.thousands,validator:e=>l(e,"thousands")},prefix:{type:String,default:()=>n.prefix,validator:e=>l(e,"prefix")},suffix:{type:String,default:()=>n.suffix,validator:e=>l(e,"suffix")},disableNegative:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},max:{type:[Number,String],default:()=>n.max},min:{type:[Number,String],default:()=>n.min},allowBlank:{type:Boolean,default:()=>n.allowBlank},minimumNumberOfCharacters:{type:Number,default:()=>n.minimumNumberOfCharacters},shouldRound:{type:Boolean,default:()=>n.shouldRound}},emits:["update:model-value"],setup:function(e,{emit:n}){const i=e,{modelValue:r,modelModifiers:u,masked:a,precision:l,shouldRound:d}=t.toRefs(i);b(i,"component setup()",i);let c=r.value;u.value&&u.value.number&&(c=d.value?Number(r.value).toFixed(o(l.value)):Number(r.value).toFixed(o(l.value)+1).slice(0,-1));const m=t.ref(y(c,i,"component setup"));b(i,"component setup() - data.formattedValue",m.value),t.watch(r,(function(e){b(i,"component watch() -> value",e);const t=y(e,s({...i}),"component watch");t!==m.value&&(b(i,"component watch() changed -> formatted",t),m.value=t)}));let f=null;function p(e){let t;b(i,"component change() -> evt.target.value",e.target.value),t=a.value&&!u.value.number?e.target.value:x(e.target.value,s({...i}),"component change"),t!==f&&(f=t,b(i,"component change() -> update:model-value",t),n("update:model-value",t))}const v=t.useAttrs(),g=t.computed((()=>{const e={...v};return delete e["onUpdate:modelValue"],e}));return(e,n)=>{const r=t.resolveDirective("money3");return t.withDirectives((t.openBlock(),t.createElementBlock("input",t.mergeProps({id:i.id},t.unref(g),{type:"tel",class:"v-money3",value:m.value,disabled:i.disabled,onChange:p}),null,16,B)),[[r,{precision:t.unref(l),decimal:i.decimal,thousands:i.thousands,prefix:i.prefix,suffix:i.suffix,disableNegative:i.disableNegative,min:i.min,max:i.max,allowBlank:i.allowBlank,minimumNumberOfCharacters:i.minimumNumberOfCharacters,debug:i.debug,modelModifiers:t.unref(u),shouldRound:t.unref(d)}]])}}});var C={install(e){e.component("money3",$),e.directive("money3",S)}};e.BigNumber=h,e.Money=$,e.Money3=$,e.Money3Component=$,e.Money3Directive=S,e.VMoney=S,e.VMoney3=S,e.default=C,e.format=y,e.unformat=x,Object.defineProperty(e,"__esModule",{value:!0}),e[Symbol.toStringTag]="Module"}));
|
|
1
|
+
var X=Object.defineProperty;var Y=(l,a,g)=>a in l?X(l,a,{enumerable:!0,configurable:!0,writable:!0,value:g}):l[a]=g;var R=(l,a,g)=>(Y(l,typeof a!="symbol"?a+"":a,g),g);(function(l,a){typeof exports=="object"&&typeof module!="undefined"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(l=typeof globalThis!="undefined"?globalThis:l||self,a(l["v-money3"]={},l.Vue))})(this,function(l,a){"use strict";const g=["+","-"],E=["decimal","thousands","prefix","suffix"];function m(t){return Math.max(0,Math.min(t,1e3))}function w(t,e){return t=t.padStart(e+1,"0"),e===0?t:`${t.slice(0,-e)}.${t.slice(-e)}`}function V(t){return t=t?t.toString():"",t.replace(/\D+/g,"")||"0"}function q(t,e){return t.replace(/(\d)(?=(?:\d{3})+\b)/gm,`$1${e}`)}function U(t,e,n){return e?t+n+e:t}function y(t,e){return g.includes(t)?(console.warn(`v-money3 "${e}" property don't accept "${t}" as a value.`),!1):/\d/g.test(t)?(console.warn(`v-money3 "${e}" property don't accept "${t}" (any number) as a value.`),!1):!0}function L(t){for(const e of E)if(!y(t[e],e))return!1;return!0}function S(t){for(const e of E){t[e]=t[e].replace(/\d+/g,"");for(const n of g)t[e]=t[e].replaceAll(n,"")}return t}function $(t){const e=t.length,n=t.indexOf(".");return e-(n+1)}function O(t){return t.replace(/^(-?)0+(?!\.)(.+)/,"$1$2")}function F(t){return/^-?[\d]+$/g.test(t)}function I(t){return/^-?[\d]+(\.[\d]+)$/g.test(t)}function D(t,e,n){return e>t.length-1?t:t.substring(0,e)+n+t.substring(e+1)}function A(t,e){const n=e-$(t);if(n>=0)return t;let i=t.slice(0,n);const u=t.slice(n);if(i.charAt(i.length-1)==="."&&(i=i.slice(0,-1)),parseInt(u.charAt(0),10)>=5){for(let s=i.length-1;s>=0;s-=1){const o=i.charAt(s);if(o!=="."&&o!=="-"){const c=parseInt(o,10)+1;if(c<10)return D(i,s,c);i=D(i,s,"0")}}return`1${i}`}return i}function H(t,e){const n=()=>{t.setSelectionRange(e,e)};t===document.activeElement&&(n(),setTimeout(n,1))}function P(t){return new Event(t,{bubbles:!0,cancelable:!1})}function r({debug:t=!1},...e){t&&console.log(...e)}var d={debug:!1,masked:!1,prefix:"",suffix:"",thousands:",",decimal:".",precision:2,disableNegative:!1,disabled:!1,min:null,max:null,allowBlank:!1,minimumNumberOfCharacters:0,modelModifiers:{number:!1},shouldRound:!0};class N{constructor(e){R(this,"number",0n);R(this,"decimal",0);this.setNumber(e)}getNumber(){return this.number}getDecimalPrecision(){return this.decimal}setNumber(e){this.decimal=0,typeof e=="bigint"?this.number=e:typeof e=="number"?this.setupString(e.toString()):this.setupString(e)}toFixed(e=0,n=!0){let i=this.toString();const u=e-this.getDecimalPrecision();return u>0?(i.includes(".")||(i+="."),i.padEnd(i.length+u,"0")):u<0?n?A(i,e):i.slice(0,u):i}toString(){let e=this.number.toString();if(this.decimal){let n=!1;return e.charAt(0)==="-"&&(e=e.substring(1),n=!0),e=e.padStart(e.length+this.decimal,"0"),e=`${e.slice(0,-this.decimal)}.${e.slice(-this.decimal)}`,e=O(e),(n?"-":"")+e}return e}lessThan(e){const[n,i]=this.adjustComparisonNumbers(e);return n<i}biggerThan(e){const[n,i]=this.adjustComparisonNumbers(e);return n>i}isEqual(e){const[n,i]=this.adjustComparisonNumbers(e);return n===i}setupString(e){if(e=O(e),F(e))this.number=BigInt(e);else if(I(e))this.decimal=$(e),this.number=BigInt(e.replace(".",""));else throw new Error(`BigNumber has received and invalid format for the constructor: ${e}`)}adjustComparisonNumbers(e){let n;e.constructor.name!=="BigNumber"?n=new N(e):n=e;const i=this.getDecimalPrecision()-n.getDecimalPrecision();let u=this.getNumber(),s=n.getNumber();return i>0?s=n.getNumber()*10n**BigInt(i):i<0&&(u=this.getNumber()*10n**BigInt(i*-1)),[u,s]}}function k(t,e=d,n=""){r(e,"utils format() - caller",n),r(e,"utils format() - input1",t),t==null?t="":typeof t=="number"?e.shouldRound?t=t.toFixed(m(e.precision)):t=t.toFixed(m(e.precision)+1).slice(0,-1):e.modelModifiers&&e.modelModifiers.number&&F(t)&&(t=Number(t).toFixed(m(e.precision))),r(e,"utils format() - input2",t);const i=e.disableNegative?"":t.indexOf("-")>=0?"-":"";let u=t.replace(e.prefix,"").replace(e.suffix,"");r(e,"utils format() - filtered",u),!e.precision&&e.thousands!=="."&&I(u)&&(u=A(u,0),r(e,"utils format() - !opt.precision && isValidFloat()",u));const s=V(u);r(e,"utils format() - numbers",s),r(e,"utils format() - numbersToCurrency",i+w(s,e.precision));const o=new N(i+w(s,e.precision));r(e,"utils format() - bigNumber1",o.toString()),e.max&&o.biggerThan(e.max)&&o.setNumber(e.max),e.min&&o.lessThan(e.min)&&o.setNumber(e.min);const c=o.toFixed(m(e.precision),e.shouldRound);if(r(e,"utils format() - bigNumber2",o.toFixed(m(e.precision))),/^0(\.0+)?$/g.test(c)&&e.allowBlank)return"";let[h,v]=c.split(".");const M=v!==void 0?v.length:0;h=h.padStart(e.minimumNumberOfCharacters-M,"0"),h=q(h,e.thousands);const x=e.prefix+U(h,v,e.decimal)+e.suffix;return r(e,"utils format() - output",x),x}function B(t,e=d,n=""){r(e,"utils unformat() - caller",n),r(e,"utils unformat() - input",t);const i=e.disableNegative?"":t.indexOf("-")>=0?"-":"",u=t.replace(e.prefix,"").replace(e.suffix,"");r(e,"utils unformat() - filtered",u);const s=V(u);r(e,"utils unformat() - numbers",s);const o=new N(i+w(s,e.precision));r(e,"utils unformat() - bigNumber1",s.toString()),e.max&&o.biggerThan(e.max)&&o.setNumber(e.max),e.min&&o.lessThan(e.min)&&o.setNumber(e.min);let c=o.toFixed(m(e.precision),e.shouldRound);return e.modelModifiers&&e.modelModifiers.number&&(c=parseFloat(c)),r(e,"utils unformat() - output",c),c}const C=(t,e,n)=>{if(r(e,"directive setValue() - caller",n),!L(e)){r(e,"directive setValue() - validateRestrictedOptions() return false. Stopping here...",t.value);return}let i=t.value.length-(t.selectionEnd||0);t.value=k(t.value,e,n),i=Math.max(i,e.suffix.length),i=t.value.length-i,i=Math.max(i,e.prefix.length),H(t,i),t.dispatchEvent(P("change"))},_=(t,e)=>{const n=t.currentTarget,i=t.code==="Backspace"||t.code==="Delete",u=n.value.length-(n.selectionEnd||0)==0;if(r(e,"directive onkeydown() - el.value",n.value),r(e,"directive onkeydown() - backspacePressed",i),r(e,"directive onkeydown() - isAtEndPosition",u),e.allowBlank&&i&&u&&B(n.value,e,"directive onkeydown allowBlank")===0&&(r(e,'directive onkeydown() - set el.value = ""',n.value),n.value="",n.dispatchEvent(P("change"))),r(e,"directive onkeydown() - e.key",t.key),t.key==="+"){r(e,"directive onkeydown() - unformat el.value",n.value);let s=B(n.value,e,"directive onkeydown +");typeof s=="string"&&(s=parseFloat(s)),s<0&&(n.value=String(s*-1))}},j=(t,e)=>{const n=t.currentTarget;r(e,"directive oninput()",n.value),/^[1-9]$/.test(n.value)&&(n.value=w(n.value,m(e.precision)),r(e,"directive oninput() - is 1-9",n.value)),C(n,e,"directive oninput")};var p={mounted(t,e){if(!e.value)return;const n=S({...d,...e.value});if(r(n,"directive mounted() - opt",n),t.tagName.toLocaleUpperCase()!=="INPUT"){const i=t.getElementsByTagName("input");i.length!==1||(t=i[0])}t.onkeydown=i=>{_(i,n)},t.oninput=i=>{j(i,n)},r(n,"directive mounted() - el.value",t.value),C(t,n,"directive mounted")},updated(t,e){if(!e.value)return;const n=S({...d,...e.value});t.onkeydown=i=>{_(i,n)},t.oninput=i=>{j(i,n)},r(n,"directive updated() - el.value",t.value),r(n,"directive updated() - opt",n),C(t,n,"directive updated")},beforeUnmount(t){t.onkeydown=null,t.oninput=null,t.onfocus=null}};const K=["id","value","disabled"],W={inheritAttrs:!1,name:"Money3",directives:{money3:p}},T=a.defineComponent({...W,props:{debug:{required:!1,type:Boolean,default:!1},id:{required:!1,type:[Number,String],default:()=>{const t=a.getCurrentInstance();return t?t.uid:null}},modelValue:{required:!0,type:[Number,String]},modelModifiers:{required:!1,type:Object,default:()=>({number:!1})},masked:{type:Boolean,default:!1},precision:{type:Number,default:()=>d.precision},decimal:{type:String,default:()=>d.decimal,validator(t){return y(t,"decimal")}},thousands:{type:String,default:()=>d.thousands,validator(t){return y(t,"thousands")}},prefix:{type:String,default:()=>d.prefix,validator(t){return y(t,"prefix")}},suffix:{type:String,default:()=>d.suffix,validator(t){return y(t,"suffix")}},disableNegative:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},max:{type:[Number,String],default:()=>d.max},min:{type:[Number,String],default:()=>d.min},allowBlank:{type:Boolean,default:()=>d.allowBlank},minimumNumberOfCharacters:{type:Number,default:()=>d.minimumNumberOfCharacters},shouldRound:{type:Boolean,default:()=>d.shouldRound}},emits:["update:model-value"],setup(t,{emit:e}){const n=t,{modelValue:i,modelModifiers:u,masked:s,precision:o,shouldRound:c}=a.toRefs(n);r(n,"component setup()",n);let h=i.value;u.value&&u.value.number&&(c.value?h=Number(i.value).toFixed(m(o.value)):h=Number(i.value).toFixed(m(o.value)+1).slice(0,-1));const v=a.ref(k(h,n,"component setup"));r(n,"component setup() - data.formattedValue",v.value),a.watch(i,M);function M(b){r(n,"component watch() -> value",b);const f=k(b,S({...n}),"component watch");f!==v.value&&(r(n,"component watch() changed -> formatted",f),v.value=f)}let x=null;function z(b){let f=b.target?.value;r(n,"component change() -> evt.target.value",f),s.value&&!u.value.number||(f=B(f,S({...n}),"component change")),f!==x&&(x=f,r(n,"component change() -> update:model-value",f),e("update:model-value",f))}const G=a.useAttrs(),J=a.computed(()=>{const b={...G};return delete b["onUpdate:modelValue"],b});return(b,f)=>{const Q=a.resolveDirective("money3");return a.withDirectives((a.openBlock(),a.createElementBlock("input",a.mergeProps({id:`${t.id}`},a.unref(J),{type:"tel",class:"v-money3",value:v.value,disabled:n.disabled,onChange:z}),null,16,K)),[[Q,{precision:a.unref(o),decimal:n.decimal,thousands:n.thousands,prefix:n.prefix,suffix:n.suffix,disableNegative:n.disableNegative,min:n.min,max:n.max,allowBlank:n.allowBlank,minimumNumberOfCharacters:n.minimumNumberOfCharacters,debug:n.debug,modelModifiers:a.unref(u),shouldRound:a.unref(c)}]])}}});var Z={install(t){t.component("money3",T),t.directive("money3",p)}};l.BigNumber=N,l.Money=T,l.Money3=T,l.Money3Component=T,l.Money3Directive=p,l.VMoney=p,l.VMoney3=p,l.default=Z,l.format=k,l.unformat=B,Object.defineProperty(l,"__esModule",{value:!0}),l[Symbol.toStringTag]="Module"});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "v-money3",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.21.0",
|
|
4
4
|
"description": "Vue3 currency input/directive mask",
|
|
5
5
|
"main": "./dist/v-money3.umd.js",
|
|
6
6
|
"module": "./dist/v-money3.es.js",
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
"require": "./dist/v-money3.umd.js"
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
+
"typings": "./dist/index.d.ts",
|
|
13
14
|
"scripts": {
|
|
14
15
|
"lint": "./node_modules/node/bin/node ./node_modules/eslint/bin/eslint.js --ext .ts,.vue ./src",
|
|
16
|
+
"dts": "vue-tsc --declaration --emitDeclarationOnly --declarationDir ./dist --removeComments false",
|
|
15
17
|
"serve": "./node_modules/node/bin/node ./node_modules/vite/bin/vite.js --host=localhost --port=3000 --open --force",
|
|
16
|
-
"build": "./node_modules/node/bin/node ./node_modules/vite/bin/vite.js build",
|
|
18
|
+
"build": "./node_modules/node/bin/node ./node_modules/vite/bin/vite.js build; npm run dts",
|
|
17
19
|
"test": "./node_modules/node/bin/node ./node_modules/jest/bin/jest.js",
|
|
18
20
|
"lock": "npm i --package-lock-only",
|
|
19
21
|
"pack": "npm run build; npm pack;",
|
|
@@ -51,9 +53,9 @@
|
|
|
51
53
|
"@types/puppeteer": "5.4.4",
|
|
52
54
|
"@typescript-eslint/eslint-plugin": "^4.31.2",
|
|
53
55
|
"@typescript-eslint/parser": "^4.31.2",
|
|
54
|
-
"@vitejs/plugin-vue": "^1.
|
|
55
|
-
"@vue/compiler-sfc": "^3.2.
|
|
56
|
-
"@vue/test-utils": "^2.0.0-rc.
|
|
56
|
+
"@vitejs/plugin-vue": "^1.10.2",
|
|
57
|
+
"@vue/compiler-sfc": "^3.2.27",
|
|
58
|
+
"@vue/test-utils": "^2.0.0-rc.18",
|
|
57
59
|
"babel-jest": "^26.6.3",
|
|
58
60
|
"eslint": "^7.32.0",
|
|
59
61
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
@@ -61,11 +63,12 @@
|
|
|
61
63
|
"eslint-plugin-import": "^2.24.2",
|
|
62
64
|
"eslint-plugin-vue": "^7.18.0",
|
|
63
65
|
"jest": "^26.6.3",
|
|
64
|
-
"jest-puppeteer": "^
|
|
65
|
-
"node": "^16.
|
|
66
|
+
"jest-puppeteer": "^6.0.3",
|
|
67
|
+
"node": "^16.13.2",
|
|
66
68
|
"ts-jest": "^26.5.6",
|
|
67
|
-
"vite": "^2.
|
|
68
|
-
"vue": "^3.2.
|
|
69
|
-
"vue-jest": "^5.0.0-alpha.10"
|
|
69
|
+
"vite": "^2.7.13",
|
|
70
|
+
"vue": "^3.2.27",
|
|
71
|
+
"vue-jest": "^5.0.0-alpha.10",
|
|
72
|
+
"vue-tsc": "^0.30.6"
|
|
70
73
|
}
|
|
71
74
|
}
|