2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Tree is used to display hierarchical data.
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/tree/)
|
|
|
|
*
|
|
|
|
* @module tree
|
|
|
|
*
|
|
|
|
*/
|
2023-03-07 13:40:44 +00:00
|
|
|
import { VNode } from 'vue';
|
2022-09-06 12:03:37 +00:00
|
|
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
|
|
|
|
2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
* Custom TreeNode metadata.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
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.
|
2023-03-10 14:00:58 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
selectable?: boolean;
|
|
|
|
/**
|
|
|
|
* Specifies if the node has children. Used in lazy loading.
|
2023-03-10 14:00:58 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
leaf?: boolean;
|
|
|
|
/**
|
|
|
|
* Optional
|
|
|
|
*/
|
|
|
|
[key: string]: any;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Icon to use in expanded state.
|
|
|
|
*/
|
|
|
|
expandedIcon?: string;
|
|
|
|
/**
|
|
|
|
* Icon to use in collapsed state.
|
|
|
|
*/
|
|
|
|
collapsedIcon?: string;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
* Custom expanded keys metadata.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface TreeExpandedKeys {
|
|
|
|
/**
|
|
|
|
* Optional
|
|
|
|
*/
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
* Custom selection keys metadata.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface TreeSelectionKeys {
|
|
|
|
/**
|
|
|
|
* Optional
|
|
|
|
*/
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
|
2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
* Defines valid properties in Tree component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface TreeProps {
|
|
|
|
/**
|
|
|
|
* An array of treenodes.
|
|
|
|
*/
|
|
|
|
value?: TreeNode[] | undefined;
|
|
|
|
/**
|
|
|
|
* A map of keys to represent the expansion state in controlled mode.
|
|
|
|
*/
|
|
|
|
expandedKeys?: TreeExpandedKeys;
|
|
|
|
/**
|
|
|
|
* A map of keys to control the selection state.
|
|
|
|
*/
|
|
|
|
selectionKeys?: TreeSelectionKeys;
|
|
|
|
/**
|
|
|
|
* Defines the selection mode.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
selectionMode?: 'single' | 'multiple' | 'checkbox' | undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Defines how multiple items can be selected, when true metaKey needs to be pressed to select or unselect an item and when set to false selection of each item can be toggled individually.
|
|
|
|
* On touch enabled devices, metaKeySelection is turned off automatically.
|
2023-03-01 12:02:31 +00:00
|
|
|
* @defaultValue true
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
metaKeySelection?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* Whether to display loading indicator.
|
2023-03-01 12:02:31 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
loading?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* Icon to display when tree is loading.
|
2023-03-08 10:51:52 +00:00
|
|
|
* @defaultValue pi pi-spin
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
loadingIcon?: string | undefined;
|
|
|
|
/**
|
|
|
|
* When specified, displays an input field to filter the items.
|
2023-03-10 14:00:58 +00:00
|
|
|
* @defaultValue false
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
filter?: boolean | undefined;
|
|
|
|
/**
|
|
|
|
* When filtering is enabled, filterBy decides which field or fields (comma separated) to search against.
|
2023-03-08 10:51:52 +00:00
|
|
|
* @defaultValue label
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
|
|
|
filterBy?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Mode for filtering.
|
2023-03-08 10:51:52 +00:00
|
|
|
* @defaultValue lenient
|
2022-09-06 12:03:37 +00:00
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
filterMode?: 'lenient' | 'strict' | undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Placeholder text to show when filter input is empty.
|
|
|
|
*/
|
|
|
|
filterPlaceholder?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Locale to use in filtering. The default locale is the host environment's current locale.
|
|
|
|
*/
|
|
|
|
filterLocale?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Height of the scroll viewport in fixed units or the 'flex' keyword for a dynamic size.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
scrollHeight?: 'flex' | string | undefined;
|
2022-12-08 11:04:25 +00:00
|
|
|
/**
|
|
|
|
* Defines a string value that labels an interactive element.
|
|
|
|
*/
|
|
|
|
'aria-label'?: string | undefined;
|
|
|
|
/**
|
|
|
|
* Identifier of the underlying menu element.
|
|
|
|
*/
|
|
|
|
'aria-labelledby'?: string | undefined;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in Tree component.
|
|
|
|
*/
|
2022-09-06 12:03:37 +00:00
|
|
|
export interface TreeSlots {
|
|
|
|
/**
|
|
|
|
* Optional slots.
|
2023-03-01 12:02:31 +00:00
|
|
|
* @todo
|
|
|
|
*/
|
2023-03-07 13:40:44 +00:00
|
|
|
[key: string]: (scope: {
|
|
|
|
/**
|
|
|
|
* Tree node instance
|
|
|
|
*/
|
|
|
|
node: TreeNode;
|
|
|
|
}) => VNode[];
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
|
2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
* Defines valid slots in Tree component.
|
|
|
|
*/
|
|
|
|
export interface TreeEmits {
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Emitted when the expanded keys change.
|
|
|
|
* @param {TreeNode} value - New expanded keys.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
'update:expandedKeys'(value: TreeExpandedKeys): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
2022-09-14 11:26:01 +00:00
|
|
|
* Emitted when the selection keys change.
|
|
|
|
* @param {TreeSelectionKeys} value - New selection keys.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
'update:selectionKeys'(event: TreeSelectionKeys): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when a node is selected.
|
|
|
|
* @param {TreeNode} node - Node instance.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
'node-select'(node: TreeNode): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when a node is unselected.
|
|
|
|
* @param {TreeNode} node - Node instance.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
'node-unselect'(node: TreeNode): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when a node is expanded.
|
|
|
|
* @param {TreeNode} node - Node instance.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
'node-expand'(node: TreeNode): void;
|
2022-09-06 12:03:37 +00:00
|
|
|
/**
|
|
|
|
* Callback to invoke when a node is collapsed.
|
|
|
|
* @param {TreeNode} node - Node instance.
|
|
|
|
*/
|
2023-03-01 12:02:31 +00:00
|
|
|
'node-collapse'(node: TreeNode): void;
|
|
|
|
}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
2023-03-01 12:02:31 +00:00
|
|
|
/**
|
|
|
|
* **PrimeVue - Tree**
|
|
|
|
*
|
|
|
|
* _Tree is used to display hierarchical data._
|
|
|
|
*
|
|
|
|
* [Live Demo](https://www.primevue.org/tree/)
|
|
|
|
* --- ---
|
|
|
|
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
|
|
|
|
*
|
|
|
|
* @group Component
|
|
|
|
*/
|
2022-09-14 11:26:01 +00:00
|
|
|
declare class Tree extends ClassComponent<TreeProps, TreeSlots, TreeEmits> {}
|
2022-09-06 12:03:37 +00:00
|
|
|
|
|
|
|
declare module '@vue/runtime-core' {
|
|
|
|
interface GlobalComponents {
|
2022-09-14 11:26:01 +00:00
|
|
|
Tree: GlobalComponentConstructor<Tree>;
|
2022-09-06 12:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Tree;
|