diff --git a/components/doc/DocApiSection.vue b/components/doc/DocApiSection.vue index 2fe05f7a7..f35db1b8a 100644 --- a/components/doc/DocApiSection.vue +++ b/components/doc/DocApiSection.vue @@ -324,14 +324,14 @@ export default { return interfaces; }, findOptions(values, docName) { - const validOptionsDocNames = ['MenuItem', 'ConfirmationOptions']; + const validOptionsDocNames = ['MenuItem', 'ConfirmationOptions', 'TreeNode']; if (!validOptionsDocNames.includes(docName)) return; const options = []; for (const key of Object.keys(values)) { - if (key === 'MenuItem' || key === 'ConfirmationOptions') { + if (key === 'MenuItem' || key === 'ConfirmationOptions' || key === 'TreeNode') { options.push({ key, values: values[key] }); } } diff --git a/components/lib/tree/Tree.d.ts b/components/lib/tree/Tree.d.ts index e10178ff2..be5e23892 100755 --- a/components/lib/tree/Tree.d.ts +++ b/components/lib/tree/Tree.d.ts @@ -10,6 +10,7 @@ import { VNode } from 'vue'; import { ComponentHooks } from '../basecomponent'; import { PassThroughOptions } from '../passthrough'; +import { TreeNode } from '../treenode'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; export declare type TreePassThroughOptionType = TreePassThroughAttributes | ((options: TreePassThroughMethodOptions) => TreePassThroughAttributes | string) | string | null | undefined; @@ -40,66 +41,6 @@ export interface TreePassThroughMethodOptions { global: object | undefined; } -/** - * Custom TreeNode metadata. - */ -export interface TreeNode { - /** - * Mandatory unique key of the node. - */ - key?: string; - /** - * Label of the node. - */ - label?: string; - /** - * Data represented by the node. - */ - data?: any; - /** - * Type of the node to match a template. - */ - type?: string; - /** - * Icon of the node to display next to content. - */ - icon?: string; - /** - * An array of treenodes as children. - */ - children?: TreeNode[]; - /** - * Inline style of the node. - */ - style?: any; - /** - * Style class of the node. - */ - styleClass?: string; - /** - * Whether the node is selectable when selection mode is enabled. - * @defaultValue false - */ - selectable?: boolean; - /** - * Specifies if the node has children. Used in lazy loading. - * @defaultValue false - */ - leaf?: boolean; - /** - * Optional - */ - [key: string]: any; - /** - * Icon to use in expanded state. - */ - expandedIcon?: string; - /** - * Icon to use in collapsed state. - */ - collapsedIcon?: string; -} - /** * Custom expanded keys metadata. */ diff --git a/components/lib/treenode/TreeNode.d.ts b/components/lib/treenode/TreeNode.d.ts new file mode 100644 index 000000000..54940ab55 --- /dev/null +++ b/components/lib/treenode/TreeNode.d.ts @@ -0,0 +1,67 @@ +/** + * + * PrimeVue tree components share a common api to specify the node. + * + * @module treenode + * + */ + +/** + * Custom TreeNode metadata. + */ +export interface TreeNode { + /** + * Mandatory unique key of the node. + */ + key?: string; + /** + * Label of the node. + */ + label?: string; + /** + * Data represented by the node. + */ + data?: any; + /** + * Type of the node to match a template. + */ + type?: string; + /** + * Icon of the node to display next to content. + */ + icon?: string; + /** + * An array of treenodes as children. + */ + children?: TreeNode[]; + /** + * Inline style of the node. + */ + style?: any; + /** + * Style class of the node. + */ + styleClass?: string; + /** + * Whether the node is selectable when selection mode is enabled. + * @defaultValue false + */ + selectable?: boolean; + /** + * Specifies if the node has children. Used in lazy loading. + * @defaultValue false + */ + leaf?: boolean; + /** + * Optional + */ + [key: string]: any; + /** + * Icon to use in expanded state. + */ + expandedIcon?: string; + /** + * Icon to use in collapsed state. + */ + collapsedIcon?: string; +} diff --git a/components/lib/treenode/package.json b/components/lib/treenode/package.json new file mode 100644 index 000000000..d31d5169f --- /dev/null +++ b/components/lib/treenode/package.json @@ -0,0 +1,3 @@ +{ + "types": "./TreeNode.d.ts" +} diff --git a/components/lib/treeselect/TreeSelect.d.ts b/components/lib/treeselect/TreeSelect.d.ts index 780617102..4a1846a64 100644 --- a/components/lib/treeselect/TreeSelect.d.ts +++ b/components/lib/treeselect/TreeSelect.d.ts @@ -10,7 +10,8 @@ import { InputHTMLAttributes, TransitionProps, VNode } from 'vue'; import { ComponentHooks } from '../basecomponent'; import { PassThroughOptions } from '../passthrough'; -import { TreeExpandedKeys, TreeNode, TreePassThroughOptionType } from '../tree'; +import { TreeExpandedKeys, TreePassThroughOptionType } from '../tree'; +import { TreeNode } from '../treenode'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; export declare type TreeSelectPassThroughOptionType = TreeSelectPassThroughAttributes | ((options: TreeSelectPassThroughMethodOptions) => TreeSelectPassThroughAttributes | string) | string | null | undefined; diff --git a/components/lib/treetable/TreeTable.d.ts b/components/lib/treetable/TreeTable.d.ts index 048c35967..5c2fe43eb 100755 --- a/components/lib/treetable/TreeTable.d.ts +++ b/components/lib/treetable/TreeTable.d.ts @@ -12,7 +12,7 @@ import { ComponentHooks } from '../basecomponent'; import { ColumnPassThroughOptionType } from '../column'; import { PaginatorPassThroughOptionType } from '../paginator'; import { PassThroughOptions } from '../passthrough'; -import { TreeNode } from '../tree'; +import { TreeNode } from '../treenode'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; export declare type TreeTablePassThroughOptionType = TreeTablePassThroughAttributes | ((options: TreeTablePassThroughMethodOptions) => TreeTablePassThroughAttributes | string) | string | null | undefined; diff --git a/pages/tree/index.vue b/pages/tree/index.vue index 95d37be3d..88711795d 100755 --- a/pages/tree/index.vue +++ b/pages/tree/index.vue @@ -1,5 +1,5 @@