Skip to content

Commit 41def28

Browse files
committed
merged base brnach
2 parents d9a7254 + ca79f46 commit 41def28

16 files changed

+1103
-2603
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
!docs/.vitepress
22
dist
3-
examples

.eslintrc.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@ module.exports = {
66
env: {
77
node: true
88
},
9-
extends: ['plugin:vue/vue3-recommended', 'eslint:recommended', '@vue/eslint-config-typescript/recommended', '@vue/eslint-config-prettier']
9+
extends: ['plugin:vue/recommended', 'eslint:recommended', '@vue/eslint-config-typescript/recommended', '@vue/eslint-config-prettier'],
10+
rules: {
11+
// Customize your rules here
12+
}
1013
}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ npm-debug.log*
1010
yarn-debug.log*
1111
yarn-error.log*
1212
pnpm-debug.log*
13-
node_modules
1413
.temp
1514
.cache
15+
*.bak
1616
example*

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"editor.formatOnPaste": false,
3-
"editor.formatOnSave": true
2+
"editor.formatOnSave": true,
3+
"editor.formatOnSaveMode": "modificationsIfAvailable"
44
}

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ npm install @coders-tm/vue-number-format
1717
or
1818
yarn add @coders-tm/vue-number-format
1919
```
20-
20+
## Vue 2.0
21+
```bash
22+
npm install @coders-tm/vue-number-format@2.0.7
23+
or
24+
yarn add @coders-tm/vue-number-format@2.0.7
25+
```
2126
## Features
2227

2328
- Lightweight

docs/guide/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Introduction
2+
Vue Number Format is used to format a number using fixed-point notation. It can be used to format a number with a specific number of digits to the right of the decimal.
3+
## Installation
4+
Install the npm package: @coders-tm/vue-number-format@2.0.7 for Vue 2.0
25

36
[![npm Version](https://badgen.net/npm/v/@coders-tm/vue-number-format?color=green)](https://www.npmjs.com/package/@coders-tm/vue-number-format)
47
[![npm Downloads](https://badgen.net/npm/dt/@coders-tm/vue-number-format?color=green)](https://www.npmjs.com/package/@coders-tm/vue-number-format)

docs/guide/config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ The precision property returns the number of bits of precision that can be repre
5050
- Type: `string`
5151
- Default: `2`
5252
- Required: `false`
53+
## nullValue
5354

5455
## minimumFractionDigits
5556

package.json

Lines changed: 32 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coders-tm/vue-number-format",
3-
"version": "3.2.0",
3+
"version": "2.2.1",
44
"private": false,
55
"description": "Easy formatted numbers, currency and percentage with input/directive mask for Vue.js",
66
"author": "Dipak Sarkar <hello@dipaksarkar.in> (https://dipaksarkar.in/)",
@@ -20,15 +20,41 @@
2020
},
2121
"sideeffects": false,
2222
"scripts": {
23-
"coverage": "vitest run --coverage",
24-
"lint": "eslint --no-fix --max-warnings 0 {**/*,*}.{js,ts,vue}",
25-
"prebuild": "rimraf dist .temp",
26-
"build": "tsc --emitDeclarationOnly --declaration --outDir .temp/types && rollup -c rollup.config.js",
27-
"docs:dev": "vuepress dev docs",
23+
"build": "tsc --emitDeclarationOnly --skipLibCheck --declaration --outDir .temp/types && rollup --c rollup.config.js",
2824
"docs:build": "vuepress build docs",
25+
"docs:dev": "vuepress dev docs",
2926
"test": "vitest",
27+
"coverage": "vitest run --coverage",
28+
"lint": "eslint 'src/**/*.{js,vue}'",
3029
"push": "clear && git config core.ignorecase false && branch=\"$(git symbolic-ref -q HEAD)\" || \"dev\" && branch=${branch##refs/heads/} && branch=${branch:-HEAD} && echo Pushing to Branch \"$branch\" && echo Please type your commit message && read msg && clear && git add . && git commit -m \"$msg\" && git push origin \"$branch\""
3130
},
31+
"devDependencies": {
32+
"@rollup/plugin-node-resolve": "^15.0.1",
33+
"@rushstack/eslint-patch": "^1.2.0",
34+
"@types/jest": "^29.4.0",
35+
"@typescript-eslint/eslint-plugin": "^5.38.1",
36+
"@typescript-eslint/parser": "^5.38.1",
37+
"@vue/eslint-config-prettier": "^7.0.0",
38+
"@vue/eslint-config-typescript": "^11.0.2",
39+
"@vue/test-utils": "^1.3.0",
40+
"eslint": "^8.34.0",
41+
"eslint-config-prettier": "^8.5.0",
42+
"eslint-plugin-vue": "^9.9.0",
43+
"jsdom": "latest",
44+
"lint-staged": "^13.1.2",
45+
"prettier": "^2.7.1",
46+
"rimraf": "^3.0.2",
47+
"rollup": "^2.6.1",
48+
"rollup-plugin-dts": "^4.2.2",
49+
"rollup-plugin-filesize": "^9.1.2",
50+
"rollup-plugin-typescript2": "^0.34.1",
51+
"typescript": "^4.9.5",
52+
"vite": "^4.1.1",
53+
"vite-plugin-vue2": "^1.9.3",
54+
"vitest": "^0.28.5",
55+
"vue": "^2.6.0",
56+
"vue-template-compiler": "^2.6.0"
57+
},
3258
"bugs": {
3359
"url": "https://github.com/coders-tm/vue-number-format/issues"
3460
},
@@ -53,47 +79,6 @@
5379
"publishConfig": {
5480
"@coders-tm:registry": "https://npm.pkg.github.com"
5581
},
56-
"peerDependencies": {
57-
"vue": "^2.7 || ^3.0.0"
58-
},
59-
"devDependencies": {
60-
"@rushstack/eslint-patch": "^1.2.0",
61-
"@testing-library/dom": "^8.18.1",
62-
"@testing-library/user-event": "^13.5.0",
63-
"@types/jest": "^29.4.0",
64-
"@typescript-eslint/eslint-plugin": "^5.38.1",
65-
"@typescript-eslint/parser": "^5.38.1",
66-
"@vitejs/plugin-vue": "latest",
67-
"@vitest/coverage-c8": "^0.23.4",
68-
"@vue/eslint-config-prettier": "^7.0.0",
69-
"@vue/eslint-config-typescript": "^11.0.2",
70-
"@vue/test-utils": "^2.0.0",
71-
"@vuepress/plugin-google-analytics": "^2.0.0-beta.27",
72-
"@vuepress/plugin-medium-zoom": "^2.0.0-beta.27",
73-
"@vuepress/plugin-register-components": "2.0.0-beta.27",
74-
"@vuepress/plugin-search": "^2.0.0-beta.27",
75-
"eslint": "^8.24.0",
76-
"eslint-config-prettier": "^8.5.0",
77-
"eslint-plugin-vue": "^9.5.1",
78-
"jsdom": "latest",
79-
"lint-staged": "^13.0.3",
80-
"prettier": "^2.7.1",
81-
"rimraf": "^3.0.2",
82-
"rollup": "^2.79.1",
83-
"rollup-plugin-cleanup": "^3.2.1",
84-
"rollup-plugin-dts": "^4.2.2",
85-
"rollup-plugin-filesize": "^9.1.2",
86-
"rollup-plugin-typescript2": "^0.34.0",
87-
"simple-git-hooks": "^2.8.0",
88-
"typescript": "^4.8.4",
89-
"unplugin-vue-components": "^0.22.7",
90-
"vite": "^3.2.3",
91-
"vite-plugin-windicss": "^1.8.1",
92-
"vitest": "latest",
93-
"vue": "^3.0.0",
94-
"vuepress-vite": "^2.0.0-beta.27",
95-
"windicss": "^3.5.0"
96-
},
9782
"simple-git-hooks": {
9883
"pre-commit": "npx lint-staged"
9984
},

rollup.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import typescript from 'rollup-plugin-typescript2'
2-
import dts from 'rollup-plugin-dts'
3-
import cleanup from 'rollup-plugin-cleanup'
42
import filesize from 'rollup-plugin-filesize'
3+
import resolve from '@rollup/plugin-node-resolve'
4+
import dts from 'rollup-plugin-dts'
55
import pkg from './package.json'
66

77
const banner = `/**
@@ -12,7 +12,7 @@ const banner = `/**
1212

1313
export default [
1414
{
15-
input: `src/index.ts`,
15+
input: 'src/index.ts',
1616
output: [
1717
{
1818
file: pkg.main,
@@ -35,7 +35,7 @@ export default [
3535
}
3636
}
3737
}),
38-
cleanup({ extensions: ['js', 'ts'] }),
38+
resolve(),
3939
filesize()
4040
],
4141
external: ['vue']

src/component.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
import { defineComponent } from 'vue'
2-
import { cloneDeep, CustomInputEvent, Input } from './core'
1+
import Vue from 'vue'
32
import directive from './directive'
3+
import { cloneDeep, CustomInputEvent, Input } from './core'
44
import defaultOptions from './options'
55

6+
Vue.directive('number', directive)
7+
68
const options = cloneDeep(defaultOptions)
79

8-
export default defineComponent({
10+
export default Vue.extend({
911
name: 'VueNumber',
10-
directives: {
11-
number: directive
12-
},
1312
props: {
14-
modelValue: {
15-
type: [String, Number],
16-
required: true
13+
value: {
14+
required: true,
15+
type: [Number, String]
1716
},
1817
nullValue: {
1918
type: [Number, String],
@@ -36,19 +35,19 @@ export default defineComponent({
3635
default: () => options.precision
3736
},
3837
minimumFractionDigits: {
39-
type: [Number, Boolean],
38+
type: Number,
4039
default: () => options.minimumFractionDigits
4140
},
4241
decimal: {
4342
type: String,
4443
default: () => options.decimal
4544
},
4645
min: {
47-
type: [Number, Boolean],
46+
type: Number,
4847
default: () => options.min
4948
},
5049
max: {
51-
type: [Number, Boolean],
50+
type: Number,
5251
default: () => options.max
5352
},
5453
separator: {
@@ -64,10 +63,9 @@ export default defineComponent({
6463
default: () => options.suffix
6564
}
6665
},
67-
emits: ['update:model-value', 'input:model-value'],
6866
data() {
6967
return {
70-
maskedValue: this.modelValue,
68+
maskedValue: this.value,
7169
unmaskedValue: '' as Input | undefined
7270
}
7371
},
@@ -92,24 +90,33 @@ export default defineComponent({
9290
}
9391
}
9492
},
93+
watch: {
94+
value(val) {
95+
if (this.unmaskedValue !== val) {
96+
this.maskedValue = val
97+
}
98+
}
99+
},
95100
methods: {
96101
input(event: CustomInputEvent) {
97102
const { target } = event
98103
this.maskedValue = target.value
99104
this.unmaskedValue = target.unmaskedValue
100-
this.$emit('input:model-value', this.emittedValue)
105+
this.$emit('input', this.emittedValue)
101106
},
102107
change() {
103-
this.$emit('update:model-value', this.emittedValue)
108+
this.$emit('change', this.emittedValue)
104109
}
105110
},
106111
template: `<input
107112
v-number="config"
108113
type="text"
109114
autocomplete="off"
110115
:value="maskedValue"
111-
class="v-number vue-number-format"
116+
class="v-number"
112117
@change="change"
113118
@input="input"
114-
/>`
119+
@blur="(evt) => $emit('blur', evt)"
120+
@focus="(evt) => $emit('focus', evt)"
121+
>`
115122
})

0 commit comments

Comments
 (0)