From 03f33ba7a78e9901a521a505bde0b167ae61843a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Fri, 5 May 2023 17:58:54 +0300 Subject: [PATCH] Refactor #3922 - For Password --- api-generator/components/password.js | 6 ++ components/lib/config/PrimeVue.d.ts | 2 + components/lib/password/Password.d.ts | 104 ++++++++++++++++++++++++++ components/lib/password/Password.vue | 20 ++--- 4 files changed, 123 insertions(+), 9 deletions(-) diff --git a/api-generator/components/password.js b/api-generator/components/password.js index 2c9492670..fc5d8224d 100644 --- a/api-generator/components/password.js +++ b/api-generator/components/password.js @@ -136,6 +136,12 @@ const PasswordProps = [ type: 'object', default: 'null', description: 'Uses to pass all properties of the HTMLDivElement to the overlay panel inside the component.' + }, + { + name: 'pt', + type: 'any', + default: 'null', + description: 'Uses to pass attributes to DOM elements inside the component.' } ]; diff --git a/components/lib/config/PrimeVue.d.ts b/components/lib/config/PrimeVue.d.ts index de8800566..3771363f0 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -42,6 +42,7 @@ import { MessagePassThroughOptions } from '../message'; import { OverlayPanelPassThroughOptions } from '../overlaypanel'; import { PanelPassThroughOptions } from '../panel'; import { PanelMenuPassThroughOptions } from '../panelmenu'; +import { PasswordPassThroughOptions } from '../password'; import { ProgressBarPassThroughOptions } from '../progressbar'; import { ProgressSpinnerPassThroughOptions } from '../progressspinner'; import { ScrollPanelPassThroughOptions } from '../scrollpanel'; @@ -122,6 +123,7 @@ interface PrimeVuePTOptions { overlaypanel?: OverlayPanelPassThroughOptions; panel?: PanelPassThroughOptions; panelmenu?: PanelMenuPassThroughOptions; + password?: PasswordPassThroughOptions; progressbar?: ProgressBarPassThroughOptions; progressspinner?: ProgressSpinnerPassThroughOptions; scrollpanel?: ScrollPanelPassThroughOptions; diff --git a/components/lib/password/Password.d.ts b/components/lib/password/Password.d.ts index 3f744faea..79482c484 100755 --- a/components/lib/password/Password.d.ts +++ b/components/lib/password/Password.d.ts @@ -8,8 +8,107 @@ * */ import { HTMLAttributes, InputHTMLAttributes, VNode } from 'vue'; +import { InputTextPassThroughOptionType } from '../inputtext'; import { ClassComponent, GlobalComponentConstructor, Nullable } from '../ts-helpers'; +export declare type PasswordPassThroughOptionType = PasswordPassThroughAttributes | ((options: PasswordPassThroughMethodOptions) => PasswordPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface PasswordPassThroughMethodOptions { + props: PasswordProps; + state: PasswordState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link PasswordProps.pt} + */ +export interface PasswordPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: PasswordPassThroughOptionType; + /** + * Uses to pass attributes to the InputText component. + * @see {@link InputTextPassThroughOptionType} + */ + input?: PasswordPassThroughOptionType; + /** + * Uses to pass attributes to the hide icon's DOM element. + */ + hideIcon?: PasswordPassThroughOptionType; + /** + * Uses to pass attributes to the show icon's DOM element. + */ + showIcon?: PasswordPassThroughOptionType; + /** + * Uses to pass attributes to the panel's DOM element. + */ + panel?: PasswordPassThroughOptionType; + /** + * Uses to pass attributes to the meter's DOM element. + */ + meter?: PasswordPassThroughOptionType; + /** + * Uses to pass attributes to the info's DOM element. + */ + info?: PasswordPassThroughOptionType; + /** + * Uses to pass attributes to the hidden accessible DOM element. + */ + hiddenAccesible?: PasswordPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface PasswordPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in Password component. + */ +export interface PasswordState { + /** + * Current overlay visible state as a boolean. + * @defaultValue false + */ + overlayVisible: boolean; + /** + * Current overlay visible state as a boolean. + * @see {@link PasswordMeterStateOptions} + */ + meter: PasswordMeterStateOptions; + /** + * Current info test state as a string. + */ + infoText: string; + /** + * Current focused state as a boolean. + * @defaultValue false + */ + focused: boolean; + /** + * Current unmasked state as a boolean. + * @defaultValue false + */ + unmasked: boolean; +} + +export interface PasswordMeterStateOptions { + /** + * Current strength of the meter state as a string. + */ + strength: string; + /** + * Current width of the meter state as a string. + */ + width: string; +} + /** * Defines valid properties in Password component. */ @@ -123,6 +222,11 @@ export interface PasswordProps extends InputHTMLAttributes { * Establishes a string value that labels the component. */ 'aria-label'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {PasswordPassThroughOptions} + */ + pt?: PasswordPassThroughOptions; } /** diff --git a/components/lib/password/Password.vue b/components/lib/password/Password.vue index b55857fc4..201de82f1 100755 --- a/components/lib/password/Password.vue +++ b/components/lib/password/Password.vue @@ -1,5 +1,5 @@