From 636bd1de8f7a00d66a6204e210fc39818204b48e 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 16:10:07 +0300 Subject: [PATCH] Refactor #3922 - For InputSwitch --- api-generator/components/inputswitch.js | 6 +++ components/lib/config/PrimeVue.d.ts | 2 + components/lib/inputswitch/InputSwitch.d.ts | 51 +++++++++++++++++++++ components/lib/inputswitch/InputSwitch.vue | 11 +++-- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/api-generator/components/inputswitch.js b/api-generator/components/inputswitch.js index 6b06ebda27..f4b2eb0761 100644 --- a/api-generator/components/inputswitch.js +++ b/api-generator/components/inputswitch.js @@ -40,6 +40,12 @@ const InputSwitchProps = [ type: 'object', default: 'null', description: 'Uses to pass all properties of the HTMLInputElement to the focusable input element 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 1cc8a8e37b..f93e1e7f8a 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -32,6 +32,7 @@ import { InlineMessagePassThroughOptions } from '../inlinemessage'; import { InplacePassThroughOptions } from '../inplace'; import { InputMaskPassThroughOptions } from '../inputmask'; import { InputNumberPassThroughOptions } from '../inputnumber'; +import { InputSwitchPassThroughOptions } from '../inputswitch'; import { InputTextPassThroughOptions } from '../inputtext'; import { MegaMenuPassThroughOptions } from '../megamenu'; import { MenuPassThroughOptions } from '../menu'; @@ -110,6 +111,7 @@ interface PrimeVuePTOptions { inplace?: InplacePassThroughOptions; inputmask?: InputMaskPassThroughOptions; inputnumber?: InputNumberPassThroughOptions; + inputswitch?: InputSwitchPassThroughOptions; inputtext?: InputTextPassThroughOptions; megamenu?: MegaMenuPassThroughOptions; menu?: MenuPassThroughOptions; diff --git a/components/lib/inputswitch/InputSwitch.d.ts b/components/lib/inputswitch/InputSwitch.d.ts index 6b280cc506..53a18176a6 100755 --- a/components/lib/inputswitch/InputSwitch.d.ts +++ b/components/lib/inputswitch/InputSwitch.d.ts @@ -10,6 +10,57 @@ import { InputHTMLAttributes } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type InputSwitchPassThroughOptionType = InputSwitchPassThroughAttributes | ((options: InputSwitchPassThroughMethodOptions) => InputSwitchPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface InputSwitchPassThroughMethodOptions { + props: InputSwitchProps; + state: InputSwitchState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link InputSwitchProps.pt} + */ +export interface InputSwitchPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: InputSwitchPassThroughOptionType; + /** + * Uses to pass attributes to the slider's DOM element. + */ + slider?: InputSwitchPassThroughOptionType; + /** + * Uses to pass attributes to the hidden accessible DOM element. + */ + hiddenAccessible?: InputSwitchPassThroughOptionType; + /** + * Uses to pass attributes to the input aria's DOM element. + */ + inputAria?: InputSwitchPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface InputSwitchPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in InputSwitch component. + */ +export interface InputSwitchState { + /** + * Current focus state as a boolean. + * @defaultValue false + */ + focused: boolean; +} + /** * Defines valid properties in InputSwitch component. */ diff --git a/components/lib/inputswitch/InputSwitch.vue b/components/lib/inputswitch/InputSwitch.vue index d213b50a88..cbb102d904 100755 --- a/components/lib/inputswitch/InputSwitch.vue +++ b/components/lib/inputswitch/InputSwitch.vue @@ -1,6 +1,6 @@