primevue-mirror/packages/primevue/src/treeselect/TreeSelect.d.ts

578 lines
16 KiB
TypeScript
Raw Normal View History

2023-03-01 08:51:09 +00:00
/**
*
* TreeSelect is a form component to choose from hierarchical data.
*
* [Live Demo](https://www.primevue.org/treeselect/)
*
* @module treeselect
*
*/
import type { DefineComponent, DesignToken, EmitFn, HintedString, PassThrough } from '@primevue/core';
2024-06-11 23:08:08 +00:00
import type { ComponentHooks } from '@primevue/core/basecomponent';
import type { ChipPassThroughOptions } from 'primevue/chip';
import type { PassThroughOptions } from 'primevue/passthrough';
import type { TreeExpandedKeys, TreePassThroughOptions } from 'primevue/tree';
import type { TreeNode } from 'primevue/treenode';
2023-08-02 14:07:22 +00:00
import { InputHTMLAttributes, TransitionProps, VNode } from 'vue';
2022-09-06 12:03:37 +00:00
export declare type TreeSelectPassThroughOptionType = TreeSelectPassThroughAttributes | ((options: TreeSelectPassThroughMethodOptions) => TreeSelectPassThroughAttributes | string) | string | null | undefined;
2023-05-07 19:51:06 +00:00
2023-08-02 14:07:22 +00:00
export declare type TreeSelectPassThroughTransitionType = TransitionProps | ((options: TreeSelectPassThroughMethodOptions) => TransitionProps) | undefined;
2023-05-07 19:51:06 +00:00
/**
* Custom passthrough(pt) option method.
*/
export interface TreeSelectPassThroughMethodOptions {
/**
* Defines instance.
*/
2023-07-06 12:01:33 +00:00
instance: any;
/**
* Defines valid properties.
*/
2023-05-07 19:51:06 +00:00
props: TreeSelectProps;
/**
* Defines current inline state.
*/
2023-05-07 19:51:06 +00:00
state: TreeSelectState;
/**
* Defines valid attributes.
*/
attrs: any;
/**
* Defines parent options.
*/
parent: any;
2023-09-05 08:50:46 +00:00
/**
* Defines passthrough(pt) options in global config.
*/
global: object | undefined;
2023-05-07 19:51:06 +00:00
}
/**
* Custom shared passthrough(pt) option method.
*/
export interface TreeSelectSharedPassThroughMethodOptions {
/**
* Defines valid properties.
*/
props: TreeSelectProps;
/**
* Defines current inline state.
*/
state: TreeSelectState;
}
2023-05-07 19:51:06 +00:00
/**
* Custom passthrough(pt) options.
* @see {@link TreeSelectProps.pt}
*/
export interface TreeSelectPassThroughOptions {
/**
* Used to pass attributes to the root's DOM element.
2023-05-07 19:51:06 +00:00
*/
root?: TreeSelectPassThroughOptionType;
/**
* Used to pass attributes to the label container's DOM element.
2023-05-07 19:51:06 +00:00
*/
labelContainer?: TreeSelectPassThroughOptionType;
/**
* Used to pass attributes to the label's DOM element.
2023-05-07 19:51:06 +00:00
*/
label?: TreeSelectPassThroughOptionType;
/**
* Used to pass attributes to the chip's DOM element.
2023-05-07 19:51:06 +00:00
*/
2024-05-15 07:35:36 +00:00
chipItem?: TreeSelectPassThroughOptionType;
2023-05-07 19:51:06 +00:00
/**
2024-04-08 12:21:07 +00:00
* Used to pass attributes to the Chip.
* @see {@link ChipPassThroughOptions}
2023-05-07 19:51:06 +00:00
*/
2024-05-15 07:35:36 +00:00
pcChip?: ChipPassThroughOptions<TreeSelectSharedPassThroughMethodOptions>;
2023-05-07 19:51:06 +00:00
/**
* Used to pass attributes to the dropdown's DOM element.
2023-05-07 19:51:06 +00:00
*/
dropdown?: TreeSelectPassThroughOptionType;
2023-05-07 19:51:06 +00:00
/**
* Used to pass attributes to the dropdown icon's DOM element.
2023-05-07 19:51:06 +00:00
*/
dropdownIcon?: TreeSelectPassThroughOptionType;
2023-05-07 19:51:06 +00:00
/**
* Used to pass attributes to the panel's DOM element.
2023-05-07 19:51:06 +00:00
*/
panel?: TreeSelectPassThroughOptionType;
/**
* Used to pass attributes to the tree container's DOM element.
2023-05-07 19:51:06 +00:00
*/
2024-05-06 13:10:13 +00:00
treeContainer?: TreeSelectPassThroughOptionType;
2023-05-07 19:51:06 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to Tree component.
2023-12-05 09:41:04 +00:00
* @see {@link TreePassThroughOptions}
2023-05-07 19:51:06 +00:00
*/
2024-05-06 15:23:01 +00:00
pcTree?: TreePassThroughOptions<TreeSelectSharedPassThroughMethodOptions>;
2023-05-07 19:51:06 +00:00
/**
* Used to pass attributes to the empty message's DOM element.
2023-05-07 19:51:06 +00:00
*/
emptyMessage?: TreeSelectPassThroughOptionType;
/**
* Used to pass attributes to the hidden input container's DOM element.
2023-05-07 19:51:06 +00:00
*/
2024-05-06 15:32:04 +00:00
hiddenInputContainer?: TreeSelectPassThroughOptionType;
2023-05-07 19:51:06 +00:00
/**
* Used to pass attributes to the hidden input's DOM element.
2023-05-07 19:51:06 +00:00
*/
hiddenInput?: TreeSelectPassThroughOptionType;
2023-07-06 11:09:01 +00:00
/**
2023-11-07 06:16:39 +00:00
* Used to manage all lifecycle hooks.
2023-07-06 11:09:01 +00:00
* @see {@link BaseComponent.ComponentHooks}
*/
hooks?: ComponentHooks;
2023-08-02 12:03:08 +00:00
/**
* Used to control Vue Transition API.
*/
2023-08-02 14:07:22 +00:00
transition?: TreeSelectPassThroughTransitionType;
2023-05-07 19:51:06 +00:00
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface TreeSelectPassThroughAttributes {
[key: string]: any;
}
/**
* Defines current inline state in TreeSelect component.
*/
export interface TreeSelectState {
2024-10-02 08:32:49 +00:00
/**
* Current id state as a string.
* @defaultValue null
*/
id: string;
2023-05-07 19:51:06 +00:00
/**
2023-05-08 07:13:02 +00:00
* Current focused state as a boolean.
2023-05-07 19:51:06 +00:00
* @defaultValue false
*/
2023-05-08 07:13:02 +00:00
focused: boolean;
/**
* Current overlay visible state as a boolean.
* @defaultValue false
*/
overlayVisible: boolean;
/**
* Current expanded keys state.
*/
expandedKeys: TreeExpandedKeys;
2023-05-07 19:51:06 +00:00
}
2023-03-01 08:51:09 +00:00
/**
* Defines valid properties in TreeSelect component.
*/
2022-09-06 12:03:37 +00:00
export interface TreeSelectProps {
/**
* Value of the component.
*/
modelValue?: TreeNode | any;
2024-10-21 11:50:34 +00:00
/**
* The default value for the input when not controlled by `modelValue`.
*/
defaultValue?: TreeNode | any;
/**
* The name attribute for the element, typically used in form submissions.
*/
name?: string | undefined;
2022-09-06 12:03:37 +00:00
/**
* An array of treenodes.
*/
options?: TreeNode[] | undefined;
2024-10-02 08:32:49 +00:00
/**
* A map of keys to represent the expansion state in controlled mode.
*/
expandedKeys?: TreeExpandedKeys;
2022-09-06 12:03:37 +00:00
/**
* Height of the viewport, a scrollbar is defined if height of list exceeds this value.
2024-05-30 08:08:49 +00:00
* @defaultValue 20rem
2022-09-06 12:03:37 +00:00
*/
scrollHeight?: string | undefined;
/**
* Label to display when there are no selections.
*/
placeholder?: string | undefined;
2024-10-25 20:13:22 +00:00
/**
* Defines the size of the component.
*/
size?: 'small' | 'large' | undefined;
/**
* When present, it specifies that the component should have invalid state style.
* @defaultValue false
*/
invalid?: boolean | undefined;
2022-09-06 12:03:37 +00:00
/**
* When present, it specifies that the component should be disabled.
2023-03-01 08:51:09 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
disabled?: boolean | undefined;
2024-01-31 08:02:53 +00:00
/**
* Specifies the input variant of the component.
* @defaultValue outlined
*/
variant?: 'outlined' | 'filled' | undefined;
2022-09-06 12:03:37 +00:00
/**
* Index of the element in tabbing order.
*/
tabindex?: string | undefined;
/**
* Defines the selection mode.
*/
2023-03-01 08:51:09 +00:00
selectionMode?: 'single' | 'multiple' | 'checkbox' | undefined;
/**
* Spans 100% width of the container when enabled.
2024-07-26 11:14:05 +00:00
* @defaultValue null
*/
2024-07-26 11:14:05 +00:00
fluid?: boolean | undefined;
2022-09-06 12:03:37 +00:00
/**
2023-03-01 08:51:09 +00:00
* A valid query selector or an HTMLElement to specify where the overlay gets attached.
2023-03-08 10:51:52 +00:00
* @defaultValue body
2022-09-06 12:03:37 +00:00
*/
appendTo?: HintedString<'body' | 'self'> | undefined | HTMLElement;
2022-09-06 12:03:37 +00:00
/**
* Text to display when there are no options available. Defaults to value from PrimeVue locale configuration.
2024-06-12 14:55:24 +00:00
* @defaultValue No available options
2022-09-06 12:03:37 +00:00
*/
emptyMessage?: string | undefined;
/**
* Defines how the selected items are displayed.
2023-03-08 10:51:52 +00:00
* @defaultValue comma
2022-09-06 12:03:37 +00:00
*/
2023-03-01 08:51:09 +00:00
display?: 'comma' | 'chip' | 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-12-20 10:35:18 +00:00
* @defaultValue false
2022-09-06 12:03:37 +00:00
*/
metaKeySelection?: boolean | undefined;
2024-09-26 09:31:12 +00:00
/**
* Whether to display loading indicator.
* @defaultValue false
*/
loading?: boolean | undefined;
/**
* Icon to display when tree is loading.
*/
loadingIcon?: string | undefined;
/**
* Loading mode display.
* @defaultValue mask
*/
loadingMode?: 'mask' | 'icon' | undefined;
2024-09-26 07:47:26 +00:00
/**
* When specified, displays an input field to filter the items.
* @defaultValue false
*/
filter?: boolean | undefined;
/**
* When filtering is enabled, filterBy decides which field or fields (comma separated) to search against. A callable taking a TreeNode can be provided instead of a list of field names.
* @defaultValue label
*/
filterBy?: string | ((node: TreeNode) => string) | undefined;
/**
* Mode for filtering.
* @defaultValue lenient
*/
filterMode?: 'lenient' | 'strict' | undefined;
/**
* 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;
2022-09-06 12:03:37 +00:00
/**
* Identifier of the underlying input element.
*/
inputId?: string | undefined;
/**
* Style class of the input field.
*/
inputClass?: string | object | undefined;
2022-09-06 12:03:37 +00:00
/**
* Inline style of the input field.
*/
inputStyle?: object | undefined;
2022-09-06 12:03:37 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass all properties of the HTMLInputElement to the focusable input element inside the component.
2022-09-06 12:03:37 +00:00
*/
2023-03-01 08:51:09 +00:00
inputProps?: InputHTMLAttributes | undefined;
2024-09-26 07:47:26 +00:00
/**
* Style class of the overlay panel.
*/
panelClass?: any;
2022-09-06 12:03:37 +00:00
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
*/
2023-11-24 12:21:54 +00:00
ariaLabelledby?: string | undefined;
2022-09-06 12:03:37 +00:00
/**
2022-09-14 11:26:01 +00:00
* Establishes a string value that labels the component.
*/
2023-11-24 12:21:54 +00:00
ariaLabel?: string | undefined;
2024-10-21 11:50:34 +00:00
/**
* Form control object, typically used for handling validation and form state.
*/
formControl?: Record<string, any> | undefined;
/**
* It generates scoped CSS variables using design tokens for the component.
*/
dt?: DesignToken<any>;
2023-05-07 19:51:06 +00:00
/**
2023-08-01 14:01:12 +00:00
* Used to pass attributes to DOM elements inside the component.
2023-05-07 19:51:06 +00:00
* @type {TreeSelectPassThroughOptions}
*/
pt?: PassThrough<TreeSelectPassThroughOptions>;
2023-09-05 08:50:46 +00:00
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
2023-05-26 11:58:40 +00:00
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
2022-09-06 12:03:37 +00:00
}
2023-03-01 08:51:09 +00:00
/**
* Defines valid slots in TreeSelect component.
*/
2022-09-06 12:03:37 +00:00
export interface TreeSelectSlots {
/**
* Custom value template.
* @param {Object} scope - value slot's params.
*/
2023-03-01 08:51:09 +00:00
value(scope: {
2022-09-06 12:03:37 +00:00
/**
* Selected value
*/
value: TreeNode | any;
/**
* Placeholder
*/
placeholder: string;
2023-03-01 08:51:09 +00:00
}): VNode[];
/**
* Custom option template.
* @param {Object} scope - option slot's params.
*/
option(scope: {
/**
* Current node
*/
node: TreeNode | any;
/**
* Selection state
*/
selected: boolean;
/**
* Expanded state
*/
expanded: boolean;
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom header template.
* @param {Object} scope - header slot's params.
*/
2023-03-01 08:51:09 +00:00
header(scope: {
2022-09-06 12:03:37 +00:00
/**
* Selected value
*/
value: TreeNode | any;
/**
* An array of treenodes.
*/
options: TreeNode[];
2023-03-01 08:51:09 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom footer template.
* @param {Object} scope - footer slot's params.
*/
2023-03-01 08:51:09 +00:00
footer(scope: {
2022-09-06 12:03:37 +00:00
/**
* Selected value
*/
value: TreeNode | any;
/**
* An array of treenodes.
*/
options: TreeNode[];
2023-03-01 08:51:09 +00:00
}): VNode[];
2022-09-06 12:03:37 +00:00
/**
* Custom empty template.
*/
2023-03-01 08:51:09 +00:00
empty(): VNode[];
2022-09-06 12:03:37 +00:00
/**
* @deprecated since v4.0. use 'dropdownicon' slot instead.
2022-09-06 12:03:37 +00:00
* Custom indicator template.
* @param {Object} scope - dropdownicon slot's params.
2022-09-06 12:03:37 +00:00
*/
triggericon(scope: {
/**
* Style class of the icon.
*/
class: string;
}): VNode[];
/**
* Custom indicator template.
* @param {Object} scope - dropdownicon slot's params.
*/
dropdownicon(scope: {
2023-05-26 11:58:40 +00:00
/**
* Style class of the icon.
*/
class: string;
}): VNode[];
/**
2024-05-27 09:24:31 +00:00
* @deprecated since v4.0. Use 'itemtoggleicon' slot instead.
* Custom item toggler icon template.
* @param {Object} scope - item toggler icon slot's params.
*/
itemtogglericon(scope: {
/**
* Node instance
*/
node: TreeNode | any;
/**
* Expanded state of the node
*/
expanded: TreeNode[];
}): VNode[];
2024-05-27 09:24:31 +00:00
/**
* Custom item toggle icon template.
* @param {Object} scope - item toggle icon slot's params.
*/
itemtoggleicon(scope: {
/**
* Node instance
*/
node: TreeNode | any;
/**
* Expanded state of the node
*/
expanded: TreeNode[];
}): VNode[];
/**
* Custom item checkbox icon template.
* @param {Object} scope - item checkbox icon slot's params.
*/
itemcheckboxicon(scope: {
/**
* Check state of the node
*/
checked: boolean;
/**
* Partial check state of the node
*/
partialChecked: boolean;
}): VNode[];
2022-09-06 12:03:37 +00:00
}
2023-03-01 08:51:09 +00:00
/**
* Defines valid emits in TreeSelect component.
*/
2024-05-16 14:05:43 +00:00
export interface TreeSelectEmitsOptions {
2022-09-06 12:03:37 +00:00
/**
* Emitted when the value changes.
* @param {*} value - New value.
*/
2023-03-01 08:51:09 +00:00
'update:modelValue'(value: any): void;
2024-10-21 11:50:34 +00:00
/**
* Emitted when the value changes in uncontrolled mode.
* @param {*} value - New value.
*/
'value-change'(value: any): void;
2024-10-02 08:32:49 +00:00
/**
* Emitted when the expanded keys change.
* @param {TreeNode} value - New expanded keys.
*/
'update:expandedKeys'(value: TreeExpandedKeys): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke on value change.
* @param {*} value - Selected node keys
*/
2023-03-01 08:51:09 +00:00
change(value: string[]): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke before the overlay is shown.
*/
2023-03-01 08:51:09 +00:00
'before-show'(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke before the overlay is hidden.
*/
2023-03-01 08:51:09 +00:00
'before-hide'(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when the overlay is shown.
*/
2023-03-01 08:51:09 +00:00
show(): void;
2022-09-06 12:03:37 +00:00
/**
* Callback to invoke when the overlay is hidden.
*/
2023-03-01 08:51:09 +00:00
hide(): 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 08:51:09 +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 08:51:09 +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 08:51:09 +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 08:51:09 +00:00
'node-collapse'(node: TreeNode): void;
}
2022-09-06 12:03:37 +00:00
export declare type TreeSelectEmits = EmitFn<TreeSelectEmitsOptions>;
export interface TreeSelectMethods {
2022-09-06 12:03:37 +00:00
/**
* Shows the overlay.
*
* @memberof TreeSelect
*/
show: () => void;
/**
* Hides the overlay.
*
* @memberof TreeSelect
*/
hide: () => void;
}
/**
* **PrimeVue - TreeSelect**
*
* _TreeSelect is a form component to choose from hierarchical data._
*
* [Live Demo](https://www.primevue.org/treeselect/)
* --- ---
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
*
* @group Component
*
*/
declare const TreeSelect: DefineComponent<TreeSelectProps, TreeSelectSlots, TreeSelectEmits, TreeSelectMethods>;
declare module 'vue' {
export interface GlobalComponents {
TreeSelect: DefineComponent<TreeSelectProps, TreeSelectSlots, TreeSelectEmits, TreeSelectMethods>;
2022-09-06 12:03:37 +00:00
}
}
export default TreeSelect;