Skip to content

Commit b89200a

Browse files
committed
changed packages and component
1 parent 984e2b0 commit b89200a

File tree

7 files changed

+1075
-155
lines changed

7 files changed

+1075
-155
lines changed

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
},
2121
"sideeffects": false,
2222
"scripts": {
23-
"build": "tsc --emitDeclarationOnly --skipLibCheck --declaration --outDir .temp/types && rollup --c rollup.config.js",
23+
"prebuild": "rimraf dist",
24+
"build": "rollup --c rollup.config.js && rimraf dist/src",
2425
"docs:build": "vuepress build docs",
2526
"docs:dev": "vuepress dev docs",
2627
"test": "vitest",
@@ -44,17 +45,19 @@
4445
"jsdom": "latest",
4546
"lint-staged": "^13.1.2",
4647
"prettier": "^2.7.1",
47-
"rimraf": "^3.0.2",
48+
"rimraf": "^4.1.2",
4849
"rollup": "^2.6.1",
4950
"rollup-plugin-dts": "^4.2.2",
5051
"rollup-plugin-filesize": "^9.1.2",
5152
"rollup-plugin-typescript2": "^0.34.1",
53+
"rollup-plugin-vue": "^5.1.6",
54+
"vue-jest": "^3.0.5",
5255
"typescript": "^4.9.5",
5356
"vite": "^4.1.1",
5457
"vite-plugin-vue2": "^1.9.3",
5558
"vitest": "^0.28.5",
56-
"vue": "^2.6.0",
57-
"vue-template-compiler": "^2.6.0"
59+
"vue": "^2.6.11",
60+
"vue-template-compiler": "^2.6.11"
5861
},
5962
"bugs": {
6063
"url": "https://github.com/coders-tm/vue-number-format/issues"

rollup.config.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import typescript from 'rollup-plugin-typescript2'
2+
import vue from 'rollup-plugin-vue'
23
import filesize from 'rollup-plugin-filesize'
34
import resolve from '@rollup/plugin-node-resolve'
45
import dts from 'rollup-plugin-dts'
@@ -31,18 +32,19 @@ export default [
3132
typescript({
3233
tsconfigOverride: {
3334
compilerOptions: {
34-
declaration: false
35+
declaration: true
3536
}
3637
}
3738
}),
39+
vue(),
3840
resolve(),
3941
filesize()
4042
],
4143
external: ['vue']
4244
},
4345
{
44-
input: './.temp/types/src/index.d.ts',
45-
output: [{ file: 'dist/index.d.ts', format: 'es' }],
46+
input: 'dist/src/index.d.ts',
47+
output: [{ file: pkg.types, format: 'es' }],
4648
plugins: [dts()]
4749
}
4850
]

src/component.ts renamed to src/component.vue

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
<template>
2+
<input
3+
v-number="config"
4+
type="text"
5+
autocomplete="off"
6+
:value="maskedValue"
7+
class="v-number"
8+
@change="change"
9+
@input="input"
10+
@blur="(evt) => $emit('blur', evt)"
11+
@focus="(evt) => $emit('focus', evt)"
12+
/>
13+
</template>
14+
15+
<script lang="ts">
116
import Vue from 'vue'
217
import directive from './directive'
318
import { cloneDeep, CustomInputEvent, Input } from './core'
@@ -16,7 +31,7 @@ export default Vue.extend({
1631
},
1732
nullValue: {
1833
type: [Number, String],
19-
default: () => options.nullValue
34+
default: options.nullValue
2035
},
2136
masked: {
2237
type: Boolean,
@@ -32,35 +47,35 @@ export default Vue.extend({
3247
},
3348
precision: {
3449
type: Number,
35-
default: () => options.precision
50+
default: options.precision
3651
},
3752
minimumFractionDigits: {
3853
type: Number,
39-
default: () => options.minimumFractionDigits
54+
default: options.minimumFractionDigits
4055
},
4156
decimal: {
4257
type: String,
43-
default: () => options.decimal
58+
default: options.decimal
4459
},
4560
min: {
4661
type: Number,
47-
default: () => options.min
62+
default: options.min
4863
},
4964
max: {
5065
type: Number,
51-
default: () => options.max
66+
default: options.max
5267
},
5368
separator: {
5469
type: String,
55-
default: () => options.separator
70+
default: options.separator
5671
},
5772
prefix: {
5873
type: String,
59-
default: () => options.prefix
74+
default: options.prefix
6075
},
6176
suffix: {
6277
type: String,
63-
default: () => options.suffix
78+
default: options.suffix
6479
}
6580
},
6681
data() {
@@ -98,25 +113,15 @@ export default Vue.extend({
98113
}
99114
},
100115
methods: {
101-
input(event: CustomInputEvent) {
102-
const { target } = event
116+
input(event: Event) {
117+
const { target } = event as CustomInputEvent
103118
this.maskedValue = target.value
104119
this.unmaskedValue = target.unmaskedValue
105120
this.$emit('input', this.emittedValue)
106121
},
107122
change() {
108123
this.$emit('change', this.emittedValue)
109124
}
110-
},
111-
template: `<input
112-
v-number="config"
113-
type="text"
114-
autocomplete="off"
115-
:value="maskedValue"
116-
class="v-number"
117-
@change="change"
118-
@input="input"
119-
@blur="(evt) => $emit('blur', evt)"
120-
@focus="(evt) => $emit('focus', evt)"
121-
>`
125+
}
122126
})
127+
</script>

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import component from './component'
1+
import component from './component.vue'
22
import directive from './directive'
33
import options, { Options as Config } from './options'
44
import NumberFormat from './number-format'

src/shims-vue.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.vue' {
2+
import Vue from 'vue'
3+
export default Vue
4+
}

tsconfig.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
"rootDir": ".",
1313
"skipLibCheck": true,
1414
"noUnusedLocals": true,
15-
"baseUrl": "."
16-
}
15+
"declaration": true,
16+
"declarationDir": "dist/types",
17+
"baseUrl": ".",
18+
"paths": {
19+
"@/*": [
20+
"src/*"
21+
]
22+
},
23+
},
24+
"include": [
25+
"src/**/*.ts",
26+
"src/**/*.tsx",
27+
"src/**/*.vue"
28+
]
1729
}

0 commit comments

Comments
 (0)