import { ShallowRef, Slot } from 'vue'; import { TreeNode } from '../basetree'; import { QueryParams, ShortFetchListResponse } from '../datatable'; import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers.d'; export type KeysModelValue = string[] | number[] | undefined; export type NodeModelValue = | number | TreeNode | string | (number | TreeNode | string)[]; export interface ButtonSelectTreeProps { /** * Below are props that commonly used * @example - [type, value as modelvalue, fieldDataKey, selectionMode, useValidator, mandatory, fieldName, validatorMessage, label, dialogHeader] */ /** * The tree type. */ type: 'group' | 'category'; /** * The model value. * If you deal with form validation of edit action, * you need to bind the initital value :value="yourValue" * Please take a note that you should pass value that match your `props.fieldDataKey` */ value?: NodeModelValue; /** * If selection mode is single mode and you're on edit form, this props should be used */ selectedNode?: TreeNode; /** * To determine which field key that will be used as value */ fieldDataKey?: string; /** * The selection Mode. * * @default 'checkbox'; */ selectionMode?: 'single' | 'checkbox'; /** * Wether the input should be validated with vee-validator or not. * If you use this component within form input, you need to set this props as true. */ useValidator?: boolean; /** * This prop is required if you use this component in a form input. * Specify the unique field name, match with your needs for API request. * * @default 'selectTree' */ fieldName?: string; /** * Make this field as mandatory on form input. */ mandatory?: boolean; /** * Set custom validator message. * Will be show if invalid="true" */ validatorMessage?: string; /** * Set custom header Dialog Select Tree */ dialogHeader?: string; /** * The button label. * * @default 'Select ${props.type}' */ label?: string; fetchTree?: ( type: 'group' | 'category', params?: QueryParams, ) => Promise | undefined>; params?: QueryParams; /** * Specify wether the all tree node should be auto checked once it rendered. * @default false */ autoSelectAll?: 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[]; /** * Disable the Select button */ disabled?: boolean; exactDisableKey?: string | number; /** * Disable node 'All' selection */ disableNodeAll?: boolean; /** * A function to determine when the node should be disabled, * When true, it will disabled selection on current node and all level childrend * * @return true to disabled */ disableNodeWhen?: (node: TreeNode) => boolean; /** * Old behavior is preventing select if there is no node selected. * * This props comes to make options, wether the selection can be empty or not. * @default true */ allowEmptySelection?: boolean; /** * The field label */ fieldLabel?: string; /** * The information to be shown to user by hovering info icon. */ fieldInfo?: string; /** * Invalid state. */ invalid?: boolean; /** * Defines width of button for 'Select Group' / 'Select Category' in px. * Deprecated, use props `width` instead * * @deprecated */ btnWidth?: number; /** * Defines width of button for 'Select Group' / 'Select Category' in px. */ width?: number; /** * Defines the tree is readonly and disabled. */ readonly?: boolean; /** * Defines the group tree to showing disposable groups. */ showDisposableGroups?: boolean; /** * Defines the tree to be flattened and shows disposable only */ flattenDisposableNode?: boolean; /** * Defines the group tree to disable excluded keys */ excludedKeys?: string[]; /** * Define wether single selection can be edited or readonly * @default true */ singleEditable?: boolean; /** * Define wether single selection can be reset with close button * @default false */ singleResetable?: boolean; /** * Show all selected node on button render * * @default false */ fetchTreeOnButtonRender?: boolean; } export type ButtonSelectTreeEmits = { 'update:value': [keys: NodeModelValue, isAllSelected?: boolean]; 'dialogShown': []; 'dialogHidden': []; 'reset': []; }; export interface ButtonSelectTreeSlots { treenode: Slot<{ node: TreeNode }>; } /** * **WangsVue - ButtonSelectTree** * * _ButtonSelectTree handles select tree dialog and field validaion._ * * --- --- * ![TSVue](https://ik.imagekit.io/kurniadev/TS-HEAD-BLACK.png) * * @group Component */ declare class ButtonSelectTree extends ClassComponent< ButtonSelectTreeProps, ButtonSelectTreeSlots, ButtonSelectTreeEmits > { dialogTreeKey: ShallowRef; } declare module '@vue/runtime-core' { interface GlobalComponents { ButtonSelectTree: GlobalComponentConstructor; } } export default ButtonSelectTree;