import { TreeSelectionKeys } from 'primevue/tree'; import { Slot } from 'vue'; import { MenuItem } from '../menuitem'; import { BaseTreeProps, TreeNode } from '../basetree'; import { QueryParams, ShortFetchListResponse } from '../datatable'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers.d'; export interface TreeProps extends BaseTreeProps { /** * Keyword to filter the Tree by name/label. */ filter: string; type: 'group' | 'category'; fetchTree?: ( type: 'group' | 'category', params?: QueryParams, ) => Promise | undefined>; /** * For query: roleType, transactionAttribute, systemRole is already stringified in components default props, but for the rest of query params need to be stringified outside */ params?: QueryParams; selectedKeys?: TreeSelectionKeys | string[] | number[] | undefined; selectedTreeNodes?: TreeNode[] | undefined; selectionMode?: 'single' | 'checkbox' | undefined; /** * Wether show node button action or not. * * @default false; */ useOption?: boolean; /** * List of labels that has no menu option */ listLabelsNoOption?: string[]; treeNodeMenus?: MenuItem[]; /** * Specify wether the all tree node should be auto checked once it rendered. * @default false */ autoSelectAll?: boolean; selectLastNode?: boolean; /** * Disable node 'All' selection */ disableNodeAll?: boolean; /** * Include node All key (-1) on Checkbox Selection * * @default false - (-1) is excluded */ includeNodeAllKey?: boolean; /** * A list of node keys that should be disabled along with their children. */ disableKeys?: string[] | number[]; /** * A list of node keys that should be disabled, affecting only the specified nodes and not their children. */ exactDisableKeys?: string[] | number[]; /** * Defines the tree is readonly and disabled. */ readonly?: boolean; /** * Defines the tree to select disposable group only. */ selectDisposableOnly?: boolean; /** * Defines the tree to be flattened and shows disposable only */ flattenDisposableNode?: boolean; /** * Defines the group tree to disable excluded keys */ excludedKeys?: string[] | number[]; /** * Will emit update selection when value is `true` * * @default false - to prevent auto emit in every possible unhandled way */ shouldEmitEventOnChange?: boolean; } export type TreeEmits = { 'update:selectedKeys': [keys: TreeSelectionKeys]; 'update:selectedTreeNodes': [nodes: TreeNode[] | undefined]; 'nodeSelect': [node: TreeNode]; 'nodeUnselect': [node: TreeNode]; 'toggleMenu': [node: TreeNode]; }; export interface TreeSlots { default: Slot<{ node: TreeNode; checked: boolean; disabled: boolean }>; } /** * **WangsVue - Tree** * * _Tree is used to display hierarchical data._ * * --- --- * ![TSVue](https://ik.imagekit.io/kurniadev/TS-HEAD-BLACK.png) * * @group Component */ declare class Tree extends ClassComponent { /** * The Tree Node array. */ treeNodes: TreeNode[]; /** * The Flat Tree Node array. */ flatNodes: TreeNode[]; /** * Tree Nodes loading state. */ isLoading: boolean; /** * Show disposable group icon. */ showDisposableGroups: boolean; /** * State where all tree node expanded. */ isExpandedAll: boolean; /** * Method to collapse all node. */ collapseAll: () => void; /** * Method to expand all node. */ expandAll: () => void; /** * Expand the All node to show all Parent Group */ expandNodeAll: () => void; /** * Trigger fetch tree list */ fetchTreeList: () => void; } declare module '@vue/runtime-core' { interface GlobalComponents { Tree: GlobalComponentConstructor; } } export default Tree;