Refactor #3922 - For InputMask

pull/3938/head
Tuğçe Küçükoğlu 2023-05-05 14:08:41 +03:00
parent 80300daa8f
commit 003c8b7127
4 changed files with 36 additions and 1 deletions

View File

@ -28,6 +28,12 @@ const InputMaskProps = [
type: 'boolean', type: 'boolean',
default: 'false', default: 'false',
description: 'Defines if model sets the raw unmasked value to bound value or the formatted mask value.' description: 'Defines if model sets the raw unmasked value to bound value or the formatted mask value.'
},
{
name: 'pt',
type: 'any',
default: 'null',
description: 'Uses to pass attributes to DOM elements inside the component.'
} }
]; ];

View File

@ -30,6 +30,7 @@ import { GalleriaPassThroughOptions } from '../galleria';
import { ImagePassThroughOptions } from '../image'; import { ImagePassThroughOptions } from '../image';
import { InlineMessagePassThroughOptions } from '../inlinemessage'; import { InlineMessagePassThroughOptions } from '../inlinemessage';
import { InplacePassThroughOptions } from '../inplace'; import { InplacePassThroughOptions } from '../inplace';
import { InputMaskPassThroughOptions } from '../inputmask';
import { MegaMenuPassThroughOptions } from '../megamenu'; import { MegaMenuPassThroughOptions } from '../megamenu';
import { MenuPassThroughOptions } from '../menu'; import { MenuPassThroughOptions } from '../menu';
import { MenubarPassThroughOptions } from '../menubar'; import { MenubarPassThroughOptions } from '../menubar';
@ -105,6 +106,7 @@ interface PrimeVuePTOptions {
image?: ImagePassThroughOptions; image?: ImagePassThroughOptions;
inlinemessage?: InlineMessagePassThroughOptions; inlinemessage?: InlineMessagePassThroughOptions;
inplace?: InplacePassThroughOptions; inplace?: InplacePassThroughOptions;
inputmask?: InputMaskPassThroughOptions;
megamenu?: MegaMenuPassThroughOptions; megamenu?: MegaMenuPassThroughOptions;
menu?: MenuPassThroughOptions; menu?: MenuPassThroughOptions;
menubar?: MenubarPassThroughOptions; menubar?: MenubarPassThroughOptions;

View File

@ -9,6 +9,26 @@
*/ */
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
export declare type InputMaskPassThroughOptionType = InputMaskPassThroughAttributes | null | undefined;
/**
* Custom passthrough(pt) options.
* @see {@link InputMaskProps.pt}
*/
export interface InputMaskPassThroughOptions {
/**
* Uses to pass attributes to the root's DOM element.
*/
root?: InputMaskPassThroughOptionType;
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface InputMaskPassThroughAttributes {
[key: string]: any;
}
/** /**
* Defines valid properties in InputMask component. * Defines valid properties in InputMask component.
*/ */
@ -41,6 +61,11 @@ export interface InputMaskProps {
* @defaultValue false * @defaultValue false
*/ */
readonly?: boolean | undefined; readonly?: boolean | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {InputMaskPassThroughOptions}
*/
pt?: InputMaskPassThroughOptions;
} }
export interface InputMaskSlots {} export interface InputMaskSlots {}

View File

@ -1,12 +1,14 @@
<template> <template>
<input :class="inputClass" :readonly="readonly" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @keypress="onKeyPress" @paste="onPaste" /> <input :class="inputClass" :readonly="readonly" @input="onInput" @focus="onFocus" @blur="onBlur" @keydown="onKeyDown" @keypress="onKeyPress" @paste="onPaste" v-bind="ptm('root')" />
</template> </template>
<script> <script>
import BaseComponent from 'primevue/basecomponent';
import { DomHandler } from 'primevue/utils'; import { DomHandler } from 'primevue/utils';
export default { export default {
name: 'InputMask', name: 'InputMask',
extends: BaseComponent,
emits: ['update:modelValue', 'focus', 'blur', 'keydown', 'complete', 'keypress', 'paste'], emits: ['update:modelValue', 'focus', 'blur', 'keydown', 'complete', 'keypress', 'paste'],
props: { props: {
modelValue: null, modelValue: null,