TreeNode .d.ts and apidoc updates

pull/4879/head
tugcekucukoglu 2023-11-23 17:00:44 +03:00
parent 1100647eee
commit fb6a5ceebf
9 changed files with 79 additions and 67 deletions

View File

@ -324,14 +324,14 @@ export default {
return interfaces; return interfaces;
}, },
findOptions(values, docName) { findOptions(values, docName) {
const validOptionsDocNames = ['MenuItem', 'ConfirmationOptions']; const validOptionsDocNames = ['MenuItem', 'ConfirmationOptions', 'TreeNode'];
if (!validOptionsDocNames.includes(docName)) return; if (!validOptionsDocNames.includes(docName)) return;
const options = []; const options = [];
for (const key of Object.keys(values)) { 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] }); options.push({ key, values: values[key] });
} }
} }

View File

@ -10,6 +10,7 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
import { ComponentHooks } from '../basecomponent'; import { ComponentHooks } from '../basecomponent';
import { PassThroughOptions } from '../passthrough'; import { PassThroughOptions } from '../passthrough';
import { TreeNode } from '../treenode';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
export declare type TreePassThroughOptionType = TreePassThroughAttributes | ((options: TreePassThroughMethodOptions) => TreePassThroughAttributes | string) | string | null | undefined; export declare type TreePassThroughOptionType = TreePassThroughAttributes | ((options: TreePassThroughMethodOptions) => TreePassThroughAttributes | string) | string | null | undefined;
@ -40,66 +41,6 @@ export interface TreePassThroughMethodOptions {
global: object | undefined; 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. * Custom expanded keys metadata.
*/ */

67
components/lib/treenode/TreeNode.d.ts vendored Normal file
View File

@ -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;
}

View File

@ -0,0 +1,3 @@
{
"types": "./TreeNode.d.ts"
}

View File

@ -10,7 +10,8 @@
import { InputHTMLAttributes, TransitionProps, VNode } from 'vue'; import { InputHTMLAttributes, TransitionProps, VNode } from 'vue';
import { ComponentHooks } from '../basecomponent'; import { ComponentHooks } from '../basecomponent';
import { PassThroughOptions } from '../passthrough'; 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'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
export declare type TreeSelectPassThroughOptionType = TreeSelectPassThroughAttributes | ((options: TreeSelectPassThroughMethodOptions) => TreeSelectPassThroughAttributes | string) | string | null | undefined; export declare type TreeSelectPassThroughOptionType = TreeSelectPassThroughAttributes | ((options: TreeSelectPassThroughMethodOptions) => TreeSelectPassThroughAttributes | string) | string | null | undefined;

View File

@ -12,7 +12,7 @@ import { ComponentHooks } from '../basecomponent';
import { ColumnPassThroughOptionType } from '../column'; import { ColumnPassThroughOptionType } from '../column';
import { PaginatorPassThroughOptionType } from '../paginator'; import { PaginatorPassThroughOptionType } from '../paginator';
import { PassThroughOptions } from '../passthrough'; import { PassThroughOptions } from '../passthrough';
import { TreeNode } from '../tree'; import { TreeNode } from '../treenode';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers'; import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
export declare type TreeTablePassThroughOptionType = TreeTablePassThroughAttributes | ((options: TreeTablePassThroughMethodOptions) => TreeTablePassThroughAttributes | string) | string | null | undefined; export declare type TreeTablePassThroughOptionType = TreeTablePassThroughAttributes | ((options: TreeTablePassThroughMethodOptions) => TreeTablePassThroughAttributes | string) | string | null | undefined;

View File

@ -1,5 +1,5 @@
<template> <template>
<DocComponent title="Vue Tree Component" header="Tree" description="Tree is used to display hierarchical data." :componentDocs="docs" :apiDocs="['Tree']" :ptTabComponent="ptComponent" :themingDocs="themingDoc" /> <DocComponent title="Vue Tree Component" header="Tree" description="Tree is used to display hierarchical data." :componentDocs="docs" :apiDocs="['Tree', 'TreeNode']" :ptTabComponent="ptComponent" :themingDocs="themingDoc" />
</template> </template>
<script> <script>
import AccessibilityDoc from '@/doc/tree/AccessibilityDoc.vue'; import AccessibilityDoc from '@/doc/tree/AccessibilityDoc.vue';

View File

@ -4,7 +4,7 @@
header="TreeSelect" header="TreeSelect"
description="TreeSelect is a form component to choose from hierarchical data." description="TreeSelect is a form component to choose from hierarchical data."
:componentDocs="docs" :componentDocs="docs"
:apiDocs="['TreeSelect']" :apiDocs="['TreeSelect', 'TreeNode']"
:ptTabComponent="ptComponent" :ptTabComponent="ptComponent"
:themingDocs="themingDoc" :themingDocs="themingDoc"
/> />

View File

@ -4,7 +4,7 @@
header="TreeTable" header="TreeTable"
description="TreeTable is used to display hierarchical data in tabular format." description="TreeTable is used to display hierarchical data in tabular format."
:componentDocs="docs" :componentDocs="docs"
:apiDocs="['TreeTable', 'Column']" :apiDocs="['TreeTable', 'Column', 'TreeNode']"
:ptTabComponent="ptComponent" :ptTabComponent="ptComponent"
:themingDocs="themingDoc" :themingDocs="themingDoc"
/> />