File tree Expand file tree Collapse file tree 13 files changed +281
-252
lines changed Expand file tree Collapse file tree 13 files changed +281
-252
lines changed Original file line number Diff line number Diff line change 1
1
module . exports = {
2
- "env" : {
3
- "browser" : true ,
4
- "es2021" : true ,
5
- "node" : true
6
- } ,
7
- "extends" : [
8
- "eslint:recommended" ,
9
- "plugin:vue/essential"
10
- ] ,
11
- "parserOptions" : {
12
- "ecmaVersion" : 12 ,
13
- "sourceType" : "module"
14
- } ,
15
- "plugins" : [
16
- "vue"
17
- ] ,
18
- "rules" : {
19
- }
20
- } ;
2
+ env : {
3
+ node : true ,
4
+ } ,
5
+ extends : [
6
+ 'eslint:recommended' ,
7
+ 'plugin:vue/vue3-recommended' ,
8
+ 'prettier'
9
+ ] ,
10
+ parserOptions : {
11
+ ecmaVersion : 12 ,
12
+ sourceType : 'module' ,
13
+ } ,
14
+ plugins : [ 'vue' ] ,
15
+ rules : { } ,
16
+ }
Original file line number Diff line number Diff line change 1
- import number from " ../../src" ;
2
- import { defineClientAppEnhance } from " @vuepress/client" ;
3
- import " virtual:windi.css" ;
1
+ import number from ' ../../src'
2
+ import { defineClientAppEnhance } from ' @vuepress/client'
3
+ import ' virtual:windi.css'
4
4
5
5
export default defineClientAppEnhance ( ( { app } ) => {
6
- app . use ( number ) ;
7
- } ) ;
6
+ app . use ( number )
7
+ } )
Original file line number Diff line number Diff line change 10
10
11
11
<script >
12
12
export default {
13
- name: " BaseLabel" ,
13
+ name: ' BaseLabel' ,
14
14
props: {
15
15
label: {
16
16
type: String ,
@@ -21,7 +21,7 @@ export default {
21
21
default: undefined ,
22
22
},
23
23
},
24
- };
24
+ }
25
25
</script >
26
26
27
27
<style scoped></style >
Original file line number Diff line number Diff line change 11
11
12
12
<script >
13
13
export default {
14
- name: " BaseInput" ,
14
+ name: ' BaseInput' ,
15
15
props: {
16
16
modelValue: {
17
17
default: undefined ,
@@ -21,8 +21,8 @@ export default {
21
21
required: false ,
22
22
},
23
23
},
24
- emits: [" update:modelValue" ],
25
- };
24
+ emits: [' update:modelValue' ],
25
+ }
26
26
</script >
27
27
28
28
<style scoped></style >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <label class =" flex items-center" :class =" { 'text-gray-300 cursor-not-allowed': disabled, 'cursor-pointer': !disabled }" >
2
+ <label
3
+ class =" flex items-center"
4
+ :class =" {
5
+ 'text-gray-300 cursor-not-allowed': disabled,
6
+ 'cursor-pointer': !disabled,
7
+ }"
8
+ >
3
9
<input
4
10
:checked =" modelValue"
5
11
:disabled =" disabled"
@@ -18,14 +24,14 @@ export default {
18
24
modelValue: Boolean ,
19
25
disabled: {
20
26
type: Boolean ,
21
- default: false
27
+ default: false ,
22
28
},
23
29
label: {
24
30
type: String ,
25
- required: true
26
- }
31
+ required: true ,
32
+ },
27
33
},
28
- emits: [' update:modelValue' ]
34
+ emits: [' update:modelValue' ],
29
35
}
30
36
</script >
31
37
Original file line number Diff line number Diff line change 1
1
<template >
2
- <div v-if =" modelValue" class =" w-screen h-screen fixed z-50 inset-0 flex bg-gray-600 bg-opacity-50" @click.self =" $emit('update:modelValue', false)" >
3
- <div class =" max-w-md md:relative m-auto p-8 bg-white rounded w-full h-auto shadow" >
2
+ <div
3
+ v-if =" modelValue"
4
+ class =" w-screen h-screen fixed z-50 inset-0 flex bg-gray-600 bg-opacity-50"
5
+ @click.self =" $emit('update:modelValue', false)"
6
+ >
7
+ <div
8
+ class =" max-w-md md:relative m-auto p-8 bg-white rounded w-full h-auto shadow"
9
+ >
4
10
<slot />
5
11
</div >
6
12
</div >
10
16
export default {
11
17
name: ' Dialog' ,
12
18
props: {
13
- modelValue: Boolean
19
+ modelValue: Boolean ,
14
20
},
15
- emits: [' update:modelValue' ]
21
+ emits: [' update:modelValue' ],
16
22
}
17
23
</script >
Original file line number Diff line number Diff line change 1
- [type = " text" ],
2
- [type = " email" ],
3
- [type = " url" ],
4
- [type = " password" ],
5
- [type = " number" ],
6
- [type = " date" ],
7
- [type = " datetime-local" ],
8
- [type = " month" ],
9
- [type = " search" ],
10
- [type = " tel" ],
11
- [type = " time" ],
12
- [type = " week" ],
1
+ [type = ' text' ],
2
+ [type = ' email' ],
3
+ [type = ' url' ],
4
+ [type = ' password' ],
5
+ [type = ' number' ],
6
+ [type = ' date' ],
7
+ [type = ' datetime-local' ],
8
+ [type = ' month' ],
9
+ [type = ' search' ],
10
+ [type = ' tel' ],
11
+ [type = ' time' ],
12
+ [type = ' week' ],
13
13
[multiple ],
14
14
textarea ,
15
15
select {
Original file line number Diff line number Diff line change 61
61
"babel-eslint" : " ^10.1.0" ,
62
62
"babel-jest" : " ^27.2.0" ,
63
63
"core-js" : " ^3.6.5" ,
64
- "eslint" : " ^7.32 .0" ,
64
+ "eslint" : " ^8.33 .0" ,
65
65
"eslint-plugin-import" : " ^2.24.2" ,
66
- "eslint-plugin-vue" : " ^7.18 .0" ,
66
+ "eslint-plugin-vue" : " ^9.9 .0" ,
67
67
"jest" : " ^27.2.0" ,
68
- "prettier-config-vuepress" : " ^1.4.0" ,
68
+ "prettier" : " 2.8.3" ,
69
+ "prettier-config-vuepress" : " ^4.0.0" ,
69
70
"rollup" : " ^2.79.0" ,
70
71
"rollup-plugin-filesize" : " ^9.1.1" ,
71
72
"rollup-plugin-vue" : " ^6.0.0" ,
Original file line number Diff line number Diff line change @@ -40,18 +40,20 @@ export default {
40
40
const { target } = e
41
41
const regExp = new RegExp ( `${ config . prefix } |${ config . suffix } ` , 'g' )
42
42
let newValue = target . value . replace ( regExp , '' )
43
+ const canNegativeInput = config . min && config . min < 0
43
44
if (
44
45
( [ 110 , 190 ] . includes ( e . keyCode ) || e . key === config . decimal ) &&
45
46
newValue . includes ( config . decimal )
46
47
) {
47
48
e . preventDefault ( )
49
+ } else if ( [ 109 ] . includes ( e . keyCode ) && ! canNegativeInput ) {
50
+ e . preventDefault ( )
48
51
} else if ( [ 8 ] . includes ( e . keyCode ) ) {
49
52
// check current cursor position is after separator when backspace key down
50
53
const character = el . value . slice ( el . selectionEnd - 1 , el . selectionEnd )
51
54
const replace = el . value . slice ( el . selectionEnd - 2 , el . selectionEnd )
52
55
if ( character === config . separator ) {
53
56
e . preventDefault ( )
54
-
55
57
let positionFromEnd = el . value . length - el . selectionEnd
56
58
// remove separator and before character
57
59
el . value = el . value . replace ( replace , '' )
Original file line number Diff line number Diff line change @@ -30,12 +30,11 @@ export default function NumberFormat(config = options) {
30
30
}
31
31
32
32
this . sign = ( ) => {
33
+ const hasMinus = this . input . toString ( ) . indexOf ( '-' ) >= 0
33
34
if ( this . isClean ) {
34
- return this . input . toString ( ) . indexOf ( '-' ) >= 0 && this . realNumber ( ) > 0
35
- ? '-'
36
- : ''
35
+ return hasMinus && this . realNumber ( ) > 0 ? '-' : ''
37
36
}
38
- return this . input . toString ( ) . indexOf ( '-' ) >= 0 ? '-' : ''
37
+ return hasMinus ? '-' : ''
39
38
}
40
39
41
40
function between ( min , n , max ) {
@@ -132,12 +131,12 @@ export default function NumberFormat(config = options) {
132
131
this . input = input
133
132
if ( this . isNull ( ) && ! this . options . reverseFill )
134
133
return this . options . nullValue
135
- return (
136
- this . sign ( ) +
137
- this . options . prefix +
138
- this . addSeparator ( ) +
139
- this . options . suffix
140
- )
134
+ return [
135
+ this . sign ( ) ,
136
+ this . options . prefix ,
137
+ this . addSeparator ( ) ,
138
+ this . options . suffix ,
139
+ ] . join
141
140
}
142
141
143
142
/**
You can’t perform that action at this time.
0 commit comments