@@ -41,11 +41,6 @@ function isPrimitive(value) {
41
41
var type = typeof value ;
42
42
return value == null || ( type !== "object" && type !== "function" ) ;
43
43
}
44
- function warn ( message ) {
45
- if ( typeof console !== 'undefined' ) {
46
- console . warn ( '[vue-class-component] ' + message ) ;
47
- }
48
- }
49
44
50
45
function collectDataFromConstructor ( vm , Component ) {
51
46
// override _init to prevent to init as Vue instance
@@ -83,12 +78,6 @@ function collectDataFromConstructor(vm, Component) {
83
78
plainData [ key ] = data [ key ] ;
84
79
}
85
80
} ) ;
86
- if ( process . env . NODE_ENV !== 'production' ) {
87
- if ( ! ( Component . prototype instanceof Vue ) && Object . keys ( plainData ) . length > 0 ) {
88
- warn ( 'Component class must inherit Vue or its descendant class ' +
89
- 'when class property is used.' ) ;
90
- }
91
- }
92
81
return plainData ;
93
82
}
94
83
@@ -154,21 +143,6 @@ function componentFactory(Component, options) {
154
143
forwardStaticMembers ( Extended , Component , Super ) ;
155
144
return Extended ;
156
145
}
157
- var reservedPropertyNames = [
158
- // Unique id
159
- 'cid' ,
160
- // Super Vue constructor
161
- 'super' ,
162
- // Component options that will be used by the component
163
- 'options' ,
164
- 'superOptions' ,
165
- 'extendOptions' ,
166
- 'sealedOptions' ,
167
- // Private assets
168
- 'component' ,
169
- 'directive' ,
170
- 'filter'
171
- ] ;
172
146
function forwardStaticMembers ( Extended , Original , Super ) {
173
147
// We have to use getOwnPropertyNames since Babel registers methods as non-enumerable
174
148
Object . getOwnPropertyNames ( Original ) . forEach ( function ( key ) {
@@ -203,13 +177,6 @@ function forwardStaticMembers(Extended, Original, Super) {
203
177
return ;
204
178
}
205
179
}
206
- // Warn if the users manually declare reserved properties
207
- if ( process . env . NODE_ENV !== 'production'
208
- && reservedPropertyNames . indexOf ( key ) >= 0 ) {
209
- warn ( "Static property name '" + key + "' declared on class '" + Original . name + "' " +
210
- 'conflicts with reserved property name of Vue internal. ' +
211
- 'It may cause unexpected behavior of the component. Consider renaming the property.' ) ;
212
- }
213
180
Object . defineProperty ( Extended , key , descriptor ) ;
214
181
} ) ;
215
182
}
@@ -243,7 +210,6 @@ function Prop(options) {
243
210
} ) ;
244
211
}
245
212
246
- // import Component from 'vue-class-component';
247
213
var NumberString = function NumberString ( maxLength ) {
248
214
this . value = '' ;
249
215
this . maxLength = maxLength || 4 ;
@@ -258,7 +224,10 @@ NumberString.prototype.pop = function pop () {
258
224
this . value = this . value . slice ( 0 , - 1 ) ;
259
225
}
260
226
} ;
261
- NumberString . prototype . getDisplayString = function getDisplayString ( ) {
227
+ NumberString . prototype . getDisplayString = function getDisplayString ( password ) {
228
+ if ( password ) {
229
+ return new Array ( this . value . length ) . fill ( '*' ) . join ( '' ) . padEnd ( this . maxLength , ' ' ) . split ( '' ) . join ( '|' ) ;
230
+ }
262
231
return this . value . padEnd ( this . maxLength , ' ' ) . split ( '' ) . join ( '|' ) ;
263
232
} ;
264
233
NumberString . prototype . setValue = function setValue ( inputNumber ) {
@@ -281,19 +250,19 @@ var SingleNumberInput = (function (Vue$$1) {
281
250
SingleNumberInput . prototype . mounted = function mounted ( ) {
282
251
this . stringValue = new NumberString ( Number ( this . chNumber ) ) ;
283
252
this . stringValue . setValue ( this . value ) ;
284
- this . displayString = this . stringValue . getDisplayString ( ) ;
253
+ this . displayString = this . stringValue . getDisplayString ( this . password ) ;
285
254
this . widthStyle . width = Number ( this . chNumber ) * 4 + 'ch' ;
286
255
} ;
287
256
SingleNumberInput . prototype . keydown = function keydown ( event ) {
288
257
var numberValue = '0123456789' . indexOf ( event . key ) ;
289
258
if ( numberValue !== - 1 ) {
290
259
this . stringValue . push ( event . key ) ;
291
- this . displayString = this . stringValue . getDisplayString ( ) ;
260
+ this . displayString = this . stringValue . getDisplayString ( this . password ) ;
292
261
this . $emit ( 'input' , this . stringValue . value ) ;
293
262
}
294
263
else if ( event . key === "Backspace" ) {
295
264
this . stringValue . pop ( ) ;
296
- this . displayString = this . stringValue . getDisplayString ( ) ;
265
+ this . displayString = this . stringValue . getDisplayString ( this . password ) ;
297
266
this . $emit ( 'input' , this . stringValue . value ) ;
298
267
}
299
268
event . cancelBubble = true ;
@@ -305,6 +274,9 @@ var SingleNumberInput = (function (Vue$$1) {
305
274
__decorate ( [
306
275
Prop ( )
307
276
] , SingleNumberInput . prototype , "chNumber" , void 0 ) ;
277
+ __decorate ( [
278
+ Prop ( )
279
+ ] , SingleNumberInput . prototype , "password" , void 0 ) ;
308
280
__decorate ( [
309
281
Prop ( )
310
282
] , SingleNumberInput . prototype , "value" , void 0 ) ;
@@ -352,11 +324,11 @@ __vue_render__._withStripped = true;
352
324
/* style */
353
325
var __vue_inject_styles__ = function ( inject ) {
354
326
if ( ! inject ) { return }
355
- inject ( "data-v-ceba03e8_0" , { source : "\ninput[data-v-ceba03e8]{\n background: transparent;\n border: black solid 1px;\n text-align: center;\n border-radius: 5px;\n font-size: xx-large;\n letter-spacing: 1ch;\n text-indent: 1ch;\n font-family: monospace;\n color: transparent;\n text-shadow: 0 0 0 #000;\n}\n" , map : { "version" :3 , "sources" :[ "/Users/muffin/workspace/single-number-input-vue/src/singleNumberInput.vue" ] , "names" :[ ] , "mappings" :";AAwEA;EACA,wBAAA;EACA,wBAAA;EACA,mBAAA;EACA,mBAAA;EACA,oBAAA;EACA,oBAAA;EACA,iBAAA;EACA,uBAAA;EACA,mBAAA;EACA,wBAAA;CACA" , "file" :"singleNumberInput.vue" , "sourcesContent" :[ "<template>\n <div>\n <input type=\"text\" v-model=\"displayString\" :style=\"widthStyle\" @keydown=\"keydown\">\n </div>\n</template>\n\n<script lang=\"ts\">\n\nimport Vue from \"vue\";\nimport {Component, Prop, Watch} from 'vue-property-decorator';\n// import Component from 'vue-class-component';\n\nclass NumberString {\n value = '';\n maxLength: number;\n\n constructor(maxLength: number){\n this.maxLength = maxLength || 4;\n }\n push(char: string){\n if(this.value.length < this.maxLength && char.length === 1){\n this.value = [this.value, char].join('');\n }\n }\n pop(){\n if(this.value.length !== 0){\n this.value = this.value.slice(0, -1);\n } \n }\n getDisplayString(){\n return this.value.padEnd(this.maxLength, ' ').split('').join('|');\n }\n setValue(inputNumber: string){\n if(inputNumber.length>= this.maxLength && !isNaN(parseInt(inputNumber))){\n this.value = inputNumber;\n }\n }\n}\n@Component({})\nexport default class SingleNumberInput extends Vue {\n displayString = '';\n widthStyle = {\n width: '16ch'\n }\n @Prop() private chNumber!: string;\n stringValue! : NumberString;\n @Prop() value!: string;\n mounted() {\n this.stringValue = new NumberString(Number(this.chNumber));\n this.stringValue.setValue(this.value);\n this.displayString = this.stringValue.getDisplayString();\n this.widthStyle.width = Number(this.chNumber) * 4 + 'ch';\n }\n\n keydown(event: KeyboardEvent){\n let numberValue = '0123456789'.indexOf(event.key);\n if(numberValue !== -1){\n this.stringValue.push(event.key);\n this.displayString = this.stringValue.getDisplayString();\n this.$emit('input', this.stringValue.value);\n }else if(event.key === \"Backspace\"){\n this.stringValue.pop()\n this.displayString = this.stringValue.getDisplayString();\n this.$emit('input', this.stringValue.value);\n }\n event.cancelBubble = true;\n event.preventDefault();\n }\n}\n</script>\n\n<style scoped>\n input{\n background: transparent;\n border: black solid 1px;\n text-align: center;\n border-radius: 5px;\n font-size: xx-large;\n letter-spacing: 1ch;\n text-indent: 1ch;\n font-family: monospace;\n color: transparent;\n text-shadow: 0 0 0 #000;\n }\n</style>\n\n" ] } , media : undefined } ) ;
327
+ inject ( "data-v-70028fc6_0" , { source : "\ninput[data-v-70028fc6]{\n background: transparent;\n border: black solid 1px;\n text-align: center;\n border-radius: 5px;\n font-size: xx-large;\n letter-spacing: 1ch;\n text-indent: 1ch;\n font-family: monospace;\n color: transparent;\n text-shadow: 0 0 0 #000;\n}\n" , map : { "version" :3 , "sources" :[ "/Users/muffin/workspace/single-number-input-vue/src/singleNumberInput.vue" ] , "names" :[ ] , "mappings" :";AA2EA;EACA,wBAAA;EACA,wBAAA;EACA,mBAAA;EACA,mBAAA;EACA,oBAAA;EACA,oBAAA;EACA,iBAAA;EACA,uBAAA;EACA,mBAAA;EACA,wBAAA;CACA" , "file" :"singleNumberInput.vue" , "sourcesContent" :[ "<template>\n <div>\n <input type=\"text\" v-model=\"displayString\" :style=\"widthStyle\" @keydown=\"keydown\">\n </div>\n</template>\n\n<script lang=\"ts\">\n\nimport Vue from \"vue\";\nimport {Component, Prop, Watch} from 'vue-property-decorator';\n\nclass NumberString {\n value = '';\n maxLength: number;\n\n constructor(maxLength: number){\n this.maxLength = maxLength || 4;\n }\n push(char: string){\n if(this.value.length < this.maxLength && char.length === 1){\n this.value = [this.value, char].join('');\n }\n }\n pop(){\n if(this.value.length !== 0){\n this.value = this.value.slice(0, -1);\n } \n }\n getDisplayString(password: boolean){\n if(password){\n return new Array(this.value.length).fill('*').join('').padEnd(this.maxLength, ' ').split('').join('|');\n }\n return this.value.padEnd(this.maxLength, ' ').split('').join('|');\n }\n setValue(inputNumber: string){\n if(inputNumber.length>= this.maxLength && !isNaN(parseInt(inputNumber))){\n this.value = inputNumber;\n }\n }\n}\n@Component({})\nexport default class SingleNumberInput extends Vue {\n displayString = '';\n widthStyle = {\n width: '16ch'\n }\n @Prop() private chNumber!: string;\n @Prop() private password!: boolean;\n stringValue! : NumberString;\n @Prop() value!: string;\n mounted() {\n this.stringValue = new NumberString(Number(this.chNumber));\n this.stringValue.setValue(this.value);\n this.displayString = this.stringValue.getDisplayString(this.password);\n this.widthStyle.width = Number(this.chNumber) * 4 + 'ch';\n }\n\n keydown(event: KeyboardEvent){\n let numberValue = '0123456789'.indexOf(event.key);\n if(numberValue !== -1){\n this.stringValue.push(event.key);\n this.displayString = this.stringValue.getDisplayString(this.password);\n this.$emit('input', this.stringValue.value);\n }else if(event.key === \"Backspace\"){\n this.stringValue.pop()\n this.displayString = this.stringValue.getDisplayString(this.password);\n this.$emit('input', this.stringValue.value);\n }\n event.cancelBubble = true;\n event.preventDefault();\n }\n}\n</script>\n\n<style scoped>\n input{\n background: transparent;\n border: black solid 1px;\n text-align: center;\n border-radius: 5px;\n font-size: xx-large;\n letter-spacing: 1ch;\n text-indent: 1ch;\n font-family: monospace;\n color: transparent;\n text-shadow: 0 0 0 #000;\n }\n</style>\n\n" ] } , media : undefined } ) ;
356
328
357
329
} ;
358
330
/* scoped */
359
- var __vue_scope_id__ = "data-v-ceba03e8 " ;
331
+ var __vue_scope_id__ = "data-v-70028fc6 " ;
360
332
/* module identifier */
361
333
var __vue_module_identifier__ = undefined ;
362
334
/* functional template */
@@ -505,5 +477,5 @@ if (GlobalVue) {
505
477
GlobalVue . use ( plugin ) ;
506
478
}
507
479
508
- export default component ;
480
+ export default SingleNumberInput$1 ;
509
481
export { install } ;
0 commit comments