From c70b5703cd1a9a5b9e4ca562c759c42d0cb4c705 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: Sun, 7 May 2023 22:51:06 +0300 Subject: [PATCH] Refactor #3922 - For TreeSelect --- api-generator/components/treeselect.js | 6 ++ components/lib/config/PrimeVue.d.ts | 2 + components/lib/treeselect/TreeSelect.d.ts | 95 ++++++++++++++++++++++- components/lib/treeselect/TreeSelect.vue | 27 ++++--- 4 files changed, 117 insertions(+), 13 deletions(-) diff --git a/api-generator/components/treeselect.js b/api-generator/components/treeselect.js index 7a0bd4afe..349987baa 100644 --- a/api-generator/components/treeselect.js +++ b/api-generator/components/treeselect.js @@ -101,6 +101,12 @@ const TreeSelectProps = [ 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 4d487458d..6ee74cc78 100644 --- a/components/lib/config/PrimeVue.d.ts +++ b/components/lib/config/PrimeVue.d.ts @@ -64,6 +64,7 @@ import { TieredMenuPassThroughOptions } from '../tieredmenu'; import { ToastPassThroughOptions } from '../toast'; import { ToolbarPassThroughOptions } from '../toolbar'; import { TreePassThroughOptions } from '../tree'; +import { TreeSelectPassThroughOptions } from '../treeselect'; import { VirtualScrollerPassThroughOptions } from '../virtualscroller'; interface PrimeVueConfiguration { @@ -150,6 +151,7 @@ interface PrimeVuePTOptions { toast?: ToastPassThroughOptions; toolbar?: ToolbarPassThroughOptions; tree?: TreePassThroughOptions; + treeselect?: TreeSelectPassThroughOptions; virtualscroller?: VirtualScrollerPassThroughOptions; } diff --git a/components/lib/treeselect/TreeSelect.d.ts b/components/lib/treeselect/TreeSelect.d.ts index 9a58d2664..4e3e6e0fa 100644 --- a/components/lib/treeselect/TreeSelect.d.ts +++ b/components/lib/treeselect/TreeSelect.d.ts @@ -8,9 +8,97 @@ * */ import { InputHTMLAttributes, VNode } from 'vue'; -import { TreeNode } from '../tree'; +import { TreeNode, TreePassThroughOptionType } from '../tree'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers'; +export declare type TreeSelectPassThroughOptionType = TreeSelectPassThroughAttributes | ((options: TreeSelectPassThroughMethodOptions) => TreeSelectPassThroughAttributes) | null | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface TreeSelectPassThroughMethodOptions { + props: TreeSelectProps; + state: TreeSelectState; +} + +/** + * Custom passthrough(pt) options. + * @see {@link TreeSelectProps.pt} + */ +export interface TreeSelectPassThroughOptions { + /** + * Uses to pass attributes to the root's DOM element. + */ + root?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the label container's DOM element. + */ + labelContainer?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the label's DOM element. + */ + label?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the token's DOM element. + */ + token?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the token label's DOM element. + */ + tokenLabel?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the trigger's DOM element. + */ + trigger?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the trigger icon's DOM element. + */ + triggerIcon?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the panel's DOM element. + */ + panel?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the wrapper's DOM element. + */ + wrapper?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the trigger's DOM element. + * @see {@link TreePassThroughOptionType} + */ + tree?: TreePassThroughOptionType; + /** + * Uses to pass attributes to the empty message's DOM element. + */ + emptyMessage?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the hidden input wrapper's DOM element. + */ + hiddenInputWrapper?: TreeSelectPassThroughOptionType; + /** + * Uses to pass attributes to the hidden input's DOM element. + */ + hiddenInput?: TreeSelectPassThroughOptionType; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface TreeSelectPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines current inline state in TreeSelect component. + */ +export interface TreeSelectState { + /** + * Current collapsed state as a boolean. + * @defaultValue false + */ + d_collapsed: boolean; +} + /** * Defines valid properties in TreeSelect component. */ @@ -94,6 +182,11 @@ export interface TreeSelectProps { * Establishes a string value that labels the component. */ 'aria-label'?: string | undefined; + /** + * Uses to pass attributes to DOM elements inside the component. + * @type {TreeSelectPassThroughOptions} + */ + pt?: TreeSelectPassThroughOptions; } /** diff --git a/components/lib/treeselect/TreeSelect.vue b/components/lib/treeselect/TreeSelect.vue index 8e0ed80f2..4e1659505 100644 --- a/components/lib/treeselect/TreeSelect.vue +++ b/components/lib/treeselect/TreeSelect.vue @@ -1,6 +1,6 @@