Fixed #1836 - For TreeSelect

pull/1846/head
mertsincan 2021-12-02 00:09:25 +03:00
parent 9fee57dd9a
commit 2d7c762ccb
1 changed files with 201 additions and 44 deletions

View File

@ -1,58 +1,215 @@
import { VNode } from 'vue'; import { VNode } from 'vue';
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
import { TreeNode } from '../tree';
interface TreeSelectProps { type TreeSelectSelectionModeType = 'single' | 'multiple' | 'checkbox';
modelValue?: any;
options?: any[]; type TreeSelectAppendToType = 'body' | 'self' | string | undefined;
scrollHeight?: string;
placeholder?: string; type TreeSelectDisplayType = 'comma' | 'chip';
disabled?: boolean;
tabindex?: string; export interface TreeSelectProps {
inputId?: string; /**
ariaLabelledBy?: string; * Value of the component.
selectionMode?: string; */
panelClass?: string; modelValue?: TreeNode | any;
appendTo?: string; /**
emptyMessage?: string; * An array of treenodes.
display?: string; */
metaKeySelection?: boolean; options?: TreeNode[] | undefined;
/**
* Height of the viewport, a scrollbar is defined if height of list exceeds this value.
* Default value is '200px'.
*/
scrollHeight?: string | undefined;
/**
* Label to display when there are no selections.
*/
placeholder?: string | undefined;
/**
* When present, it specifies that the component should be disabled.
*/
disabled?: boolean | undefined;
/**
* Index of the element in tabbing order.
*/
tabindex?: string | undefined;
/**
* Identifier of the underlying input element.
*/
inputId?: string | undefined;
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
*/
ariaLabelledBy?: string | undefined;
/**
* Defines the selection mode.
* @see TreeSelectSelectionModeType
*/
selectionMode?: TreeSelectSelectionModeType;
/**
* Style class of the overlay panel.
*/
panelClass?: string | undefined;
/**
* A valid query selector or an HTMLElement to specify where the overlay gets attached. Special keywords are "body" for document body and "self" for the element itself.
* @see TreeSelectAppendToType
* Default value is 'body'.
*/
appendTo?: TreeSelectAppendToType;
/**
* Text to display when there are no options available. Defaults to value from PrimeVue locale configuration.
* Default value is 'No results found'.
*/
emptyMessage?: string | undefined;
/**
* Defines how the selected items are displayed.
* @see TreeSelectDisplayType
* Default value is 'comma'.
*/
display?: TreeSelectDisplayType;
/**
* 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.
* Default value is true.
*/
metaKeySelection?: boolean | undefined;
} }
interface TreeSelectValueSlotInterface { export interface TreeSelectSlots {
value: any; /**
placeholder: string; * Custom value template.
* @param {Object} scope - value slot's params.
*/
value: (scope: {
/**
* Selected value
*/
value: TreeNode | any;
/**
* Placeholder
*/
placeholder: string;
}) => VNode[];
/**
* Custom header template.
* @param {Object} scope - header slot's params.
*/
header: (scope: {
/**
* Selected value
*/
value: TreeNode | any;
/**
* An array of treenodes.
*/
options: TreeNode[];
}) => VNode[];
/**
* Custom footer template.
* @param {Object} scope - footer slot's params.
*/
footer: (scope: {
/**
* Selected value
*/
value: TreeNode | any;
/**
* An array of treenodes.
*/
options: TreeNode[];
}) => VNode[];
/**
* Custom empty template.
*/
empty: () => VNode[];
/**
* Custom indicator template.
*/
indicator: () => VNode[];
} }
interface TreeSelectHeaderSlotInterface { export declare type TreeSelectEmits = {
value: any; /**
options: any[]; * Emitted when the value changes.
* @param {*} value - New value.
*/
'update:modelValue': (value: any) => void;
/**
* Callback to invoke on value change.
* @param {*} value - Selected node keys
*/
'change': (value: string[]) => void;
/**
* Callback to invoke before the overlay is shown.
*/
'before-show': () => void;
/**
* Callback to invoke before the overlay is hidden.
*/
'before-hide': () => void;
/**
* Callback to invoke when the overlay is shown.
*/
'show': () => void;
/**
* Callback to invoke when the overlay is hidden.
*/
'hide': () => void;
/**
* Callback to invoke when a node is selected.
* @param {TreeNode} node - Node instance.
*/
'node-select': (node: TreeNode) => void;
/**
* Callback to invoke when a node is unselected.
* @param {TreeNode} node - Node instance.
*/
'node-unselect': (node: TreeNode) => void;
/**
* Callback to invoke when a node is expanded.
* @param {TreeNode} node - Node instance.
*/
'node-expand': (node: TreeNode) => void;
/**
* Callback to invoke when a node is collapsed.
* @param {TreeNode} node - Node instance.
*/
'node-collapse': (node: TreeNode) => void;
} }
interface TreeSelectFooterSlotInterface { declare class TreeSelect extends ClassComponent<TreeSelectProps, TreeSelectSlots, TreeSelectEmits> {
value: any; /**
options: any[]; * Shows the overlay.
*
* @memberof TreeSelect
*/
show: () => void;
/**
* Hides the overlay.
*
* @memberof TreeSelect
*/
hide: () => void;
} }
declare class TreeSelect { declare module '@vue/runtime-core' {
$props: TreeSelectProps; interface GlobalComponents {
$emit(eventName: 'update:modelValue', value: any): this; TreeSelect: GlobalComponentConstructor<TreeSelect>
$emit(eventName: 'change', value: any): this;
$emit(eventName: 'before-show'): this;
$emit(eventName: 'before-hide'): this;
$emit(eventName: 'show'): this;
$emit(eventName: 'hide'): this;
$emit(eventName: 'node-select', node: any): this;
$emit(eventName: 'node-unselect', node: any): this;
$emit(eventName: 'node-expand', node: any): this;
$emit(eventName: 'node-collapse', node: any): this;
show(): void;
hide(): void;
$slots: {
value: TreeSelectValueSlotInterface;
header: TreeSelectHeaderSlotInterface;
footer: TreeSelectFooterSlotInterface;
empty: VNode[];
indicator: VNode[];
} }
} }
/**
*
* TreeSelect is a form component to choose from hierarchical data.
*
* Helper API:
*
* - TreeNode
*
* Demos:
*
* - [TreeSelect](https://www.primefaces.org/primevue/showcase/#/treeselect)
*
*/
export default TreeSelect; export default TreeSelect;