Refactor #3965 - For InputMask
parent
98599434e8
commit
c51d223526
|
@ -0,0 +1,57 @@
|
|||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import { useStyle } from 'primevue/usestyle';
|
||||
|
||||
const styles = `
|
||||
`;
|
||||
|
||||
const classes = {
|
||||
root: ({ instance }) => [
|
||||
'p-inputmask p-inputtext p-component',
|
||||
{
|
||||
'p-filled': instance.filled
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const { load: loadStyle, unload: unloadStyle } = useStyle(styles, { id: 'primevue_inputmask_style', manual: true });
|
||||
|
||||
export default {
|
||||
name: 'BaseInputMask',
|
||||
extends: BaseComponent,
|
||||
props: {
|
||||
modelValue: null,
|
||||
slotChar: {
|
||||
type: String,
|
||||
default: '_'
|
||||
},
|
||||
mask: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
autoClear: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
unmask: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
readonly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
css: {
|
||||
classes
|
||||
},
|
||||
watch: {
|
||||
isUnstyled: {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
!newValue && loadStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -66,6 +66,11 @@ export interface InputMaskProps {
|
|||
* @type {InputMaskPassThroughOptions}
|
||||
*/
|
||||
pt?: InputMaskPassThroughOptions;
|
||||
/**
|
||||
* When enabled, it removes component related styles in the core.
|
||||
* @defaultValue false
|
||||
*/
|
||||
unstyled?: boolean;
|
||||
}
|
||||
|
||||
export interface InputMaskSlots {}
|
||||
|
|
|
@ -1,38 +1,15 @@
|
|||
<template>
|
||||
<input :class="inputClass" :readonly="readonly" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @keypress="onKeyPress" @paste="onPaste" v-bind="ptm('root')" />
|
||||
<input :class="cx('root')" :readonly="readonly" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @keypress="onKeyPress" @paste="onPaste" v-bind="ptm('root')" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import { DomHandler } from 'primevue/utils';
|
||||
import BaseInputMask from './BaseInputMask.vue';
|
||||
|
||||
export default {
|
||||
name: 'InputMask',
|
||||
extends: BaseComponent,
|
||||
extends: BaseInputMask,
|
||||
emits: ['update:modelValue', 'focus', 'blur', 'keydown', 'complete', 'keypress', 'paste'],
|
||||
props: {
|
||||
modelValue: null,
|
||||
slotChar: {
|
||||
type: String,
|
||||
default: '_'
|
||||
},
|
||||
mask: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
autoClear: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
unmask: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
readonly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
mask(newMask, oldMask) {
|
||||
if (oldMask !== newMask) {
|
||||
|
@ -519,14 +496,6 @@ export default {
|
|||
computed: {
|
||||
filled() {
|
||||
return this.modelValue != null && this.modelValue.toString().length > 0;
|
||||
},
|
||||
inputClass() {
|
||||
return [
|
||||
'p-inputmask p-inputtext p-component',
|
||||
{
|
||||
'p-filled': this.filled
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue