Refactor #5426 - For InputMask

pull/5507/head
tugcekucukoglu 2024-03-18 13:02:00 +03:00
parent 3869287056
commit 898337667e
4 changed files with 45 additions and 13 deletions

View File

@ -31,6 +31,10 @@ export default {
type: Boolean,
default: false
},
disabled: {
type: Boolean,
default: false
},
variant: {
type: String,
default: null

View File

@ -8,6 +8,7 @@
*
*/
import { ComponentHooks } from '../basecomponent';
import { InputTextPassThroughOptions } from '../inputtext';
import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
@ -43,15 +44,26 @@ export interface InputMaskPassThroughMethodOptions {
global: object | undefined;
}
/**
* Custom shared passthrough(pt) option method.
*/
export interface InputMaskSharedPassThroughMethodOptions {
/**
* Defines valid properties.
*/
props: InputMaskProps;
}
/**
* Custom passthrough(pt) options.
* @see {@link InputMaskProps.pt}
*/
export interface InputMaskPassThroughOptions {
/**
* Used to pass attributes to the root's DOM element.
* Used to pass attributes to the InputText component.
* @see {@link InputTextPassThroughOptions}
*/
root?: InputMaskPassThroughOptionType;
root?: InputTextPassThroughOptions<InputMaskSharedPassThroughMethodOptions>;
/**
* Used to manage all lifecycle hooks.
* @see {@link BaseComponent.ComponentHooks}
@ -124,6 +136,11 @@ export interface InputMaskProps {
* @defaultValue outlined
*/
variant?: 'outlined' | 'filled' | undefined;
/**
* When present, it specifies that the component should be disabled.
* @defaultValue false
*/
disabled?: boolean | undefined;
/**
* Used to pass attributes to DOM elements inside the component.
* @type {InputMaskPassThroughOptions}

View File

@ -1,8 +1,24 @@
<template>
<input :class="cx('root')" :readonly="readonly" :aria-invalid="invalid || undefined" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @keypress="onKeyPress" @paste="onPaste" v-bind="ptmi('root', ptmParams)" />
<IMInputText
:value="modelValue"
:class="cx('root')"
:readonly="readonly"
:disabled="disabled"
:invalid="invalid"
:variant="variant"
:unstyled="unstyled"
@input="onInput"
@focus="onFocus"
@blur="onBlur"
@keydown="onKeyDown"
@keypress="onKeyPress"
@paste="onPaste"
:pt="ptmi('root', ptmParams)"
/>
</template>
<script>
import InputText from 'primevue/inputtext';
import { DomHandler } from 'primevue/utils';
import BaseInputMask from './BaseInputMask.vue';
@ -503,11 +519,13 @@ export default {
ptmParams() {
return {
context: {
filled: this.filled,
disabled: this.$attrs.disabled || this.$attrs.disabled === ''
filled: this.filled
}
};
}
},
components: {
IMInputText: InputText
}
};
</script>

View File

@ -1,14 +1,7 @@
import BaseStyle from 'primevue/base/style';
const classes = {
root: ({ props, instance }) => [
'p-inputmask p-inputtext p-component',
{
'p-filled': instance.filled,
'p-invalid': props.invalid,
'p-variant-filled': props.variant ? props.variant === 'filled' : instance.$primevue.config.inputStyle === 'filled'
}
]
root: 'p-inputmask p-inputmask-text p-component'
};
export default BaseStyle.extend({