From 57cf4b6abb3bb47d6a63407b66a56bbd97457ed1 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:13:58 +0300 Subject: [PATCH] Refactor #3922 - For Knob --- api-generator/components/knob.js | 6 +++ components/lib/config/PrimeVue.d.ts | 2 + components/lib/knob/Knob.d.ts | 78 +++++++++++++++++++++++++++++ components/lib/knob/Knob.vue | 12 +++-- 4 files changed, 94 insertions(+), 4 deletions(-) diff --git a/api-generator/components/knob.js b/api-generator/components/knob.js index 81b026e0e..95d48e58b 100644 --- a/api-generator/components/knob.js +++ b/api-generator/components/knob.js @@ -94,6 +94,12 @@ const KnobProps = [ 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 f93e1e7f8..de8800566 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -34,6 +34,7 @@ import { InputMaskPassThroughOptions } from '../inputmask'; import { InputNumberPassThroughOptions } from '../inputnumber'; import { InputSwitchPassThroughOptions } from '../inputswitch'; import { InputTextPassThroughOptions } from '../inputtext'; +import { KnobPassThroughOptions } from '../knob'; import { MegaMenuPassThroughOptions } from '../megamenu'; import { MenuPassThroughOptions } from '../menu'; import { MenubarPassThroughOptions } from '../menubar'; @@ -113,6 +114,7 @@ interface PrimeVuePTOptions { inputnumber?: InputNumberPassThroughOptions; inputswitch?: InputSwitchPassThroughOptions; inputtext?: InputTextPassThroughOptions; + knob?: KnobPassThroughOptions; megamenu?: MegaMenuPassThroughOptions; menu?: MenuPassThroughOptions; menubar?: MenubarPassThroughOptions; diff --git a/components/lib/knob/Knob.d.ts b/components/lib/knob/Knob.d.ts index 9e7c16512..b12751a51 100644 --- a/components/lib/knob/Knob.d.ts +++ b/components/lib/knob/Knob.d.ts @@ -9,6 +9,79 @@ */ import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type KnobPassThroughOptionType = KnobPassThroughAttributes | ((options: KnobPassThroughMethodOptions) => KnobPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface KnobPassThroughMethodOptions { + props: KnobProps; + state: KnobState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link KnobProps.pt} + */ +export interface KnobPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: KnobPassThroughOptionType; + /** + * Uses to pass attributes to the svg's DOM element. + */ + svg?: KnobPassThroughOptionType; + /** + * Uses to pass attributes to the range's DOM element. + */ + range?: KnobPassThroughOptionType; + /** + * Uses to pass attributes to the value' DOM element. + */ + value?: KnobPassThroughOptionType; + /** + * Uses to pass attributes to the label's DOM element. + */ + label?: KnobPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface KnobPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in Knob component. + */ +export interface KnobState { + /** + * Current radius state as a number. + * @defaultValue 40 + */ + radius: number; + /** + * Current middle x axis state as a number. + * @defaultValue 50 + */ + midX: number; + /** + * Current middle y axis state as a number. + * @defaultValue 50 + */ + midY: number; + /** + * Current minimum radian state as a number. + */ + minRadians: number; + /** + * Current maximum radian state as a number. + */ + maxRadians: number; +} + /** * Defines valid properties in Knob component. */ @@ -90,6 +163,11 @@ export interface KnobProps { * Used to define a string that labels the element. */ 'aria-label'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {KnobPassThroughOptions} + */ + pt?: KnobPassThroughOptions; } /** diff --git a/components/lib/knob/Knob.vue b/components/lib/knob/Knob.vue index c7cb14cdb..10c05f0c2 100644 --- a/components/lib/knob/Knob.vue +++ b/components/lib/knob/Knob.vue @@ -1,5 +1,5 @@