From 7000136a6a14ae15bafc7944cc082f3ff19c4bc7 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 18:20:34 +0300 Subject: [PATCH] Refactor #3922 - For RadioButton --- api-generator/components/radiobutton.js | 6 +++ components/lib/config/PrimeVue.d.ts | 2 + components/lib/radiobutton/RadioButton.d.ts | 55 +++++++++++++++++++++ components/lib/radiobutton/RadioButton.vue | 12 +++-- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/api-generator/components/radiobutton.js b/api-generator/components/radiobutton.js index 620ad456b..ec531e6a4 100644 --- a/api-generator/components/radiobutton.js +++ b/api-generator/components/radiobutton.js @@ -58,6 +58,12 @@ const RadioButtonProps = [ type: 'string', default: 'null', description: 'Used to define a string that labels the element.' + }, + { + 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 3771363f0..4a6663e3d 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -45,6 +45,7 @@ import { PanelMenuPassThroughOptions } from '../panelmenu'; import { PasswordPassThroughOptions } from '../password'; import { ProgressBarPassThroughOptions } from '../progressbar'; import { ProgressSpinnerPassThroughOptions } from '../progressspinner'; +import { RadioButtonPassThroughOptions } from '../radiobutton'; import { ScrollPanelPassThroughOptions } from '../scrollpanel'; import { ScrollTopPassThroughOptions } from '../scrolltop'; import { SidebarPassThroughOptions } from '../sidebar'; @@ -126,6 +127,7 @@ interface PrimeVuePTOptions { password?: PasswordPassThroughOptions; progressbar?: ProgressBarPassThroughOptions; progressspinner?: ProgressSpinnerPassThroughOptions; + radiobutton?: RadioButtonPassThroughOptions; scrollpanel?: ScrollPanelPassThroughOptions; scrolltop?: ScrollTopPassThroughOptions; sidebar?: SidebarPassThroughOptions; diff --git a/components/lib/radiobutton/RadioButton.d.ts b/components/lib/radiobutton/RadioButton.d.ts index 5550884ec..22b13b872 100755 --- a/components/lib/radiobutton/RadioButton.d.ts +++ b/components/lib/radiobutton/RadioButton.d.ts @@ -10,6 +10,61 @@ import { InputHTMLAttributes } from 'vue'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type RadioButtonPassThroughOptionType = RadioButtonPassThroughAttributes | ((options: RadioButtonPassThroughMethodOptions) => RadioButtonPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface RadioButtonPassThroughMethodOptions { + props: RadioButtonProps; + state: RadioButtonState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link RadioButtonProps.pt} + */ +export interface RadioButtonPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: RadioButtonPassThroughOptionType; + /** + * Uses to pass attributes to the input's DOM element. + */ + input?: RadioButtonPassThroughOptionType; + /** + * Uses to pass attributes to the icon's DOM element. + */ + icon?: RadioButtonPassThroughOptionType; + /** + * Uses to pass attributes to the hidden accessible DOM element wrapper. + */ + hiddenInputWrapper?: RadioButtonPassThroughOptionType; + /** + * Uses to pass attributes to the hidden accessible DOM element. + */ + hiddenInput?: RadioButtonPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface RadioButtonPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in RadioButton component. + */ +export interface RadioButtonState { + /** + * Current focused state as a boolean. + * @defaultValue false + */ + focused: boolean; +} + /** * Defines valid properties in RadioButton component. */ diff --git a/components/lib/radiobutton/RadioButton.vue b/components/lib/radiobutton/RadioButton.vue index 7fec2faae..6eddfab2e 100755 --- a/components/lib/radiobutton/RadioButton.vue +++ b/components/lib/radiobutton/RadioButton.vue @@ -1,6 +1,6 @@