/** Position of the dropdown list relative to the input: auto, top, or bottom. */ export declare type DirectionType = 'auto' | 'top' | 'bottom'; /** * Icon set for arrows, checkboxes, clear, etc. * Each value is an SVG string or an HTMLElement. */ export declare type IconsType = { arrowUp: string | HTMLElement; arrowDown: string | HTMLElement; arrowRight: string | HTMLElement; attention: string | HTMLElement; clear: string | HTMLElement; cross: string | HTMLElement; check: string | HTMLElement; partialCheck: string | HTMLElement; }; declare interface ITreeselect { parentHtmlContainer: HTMLElement; value: ValueType; options: OptionType[]; openLevel: number; appendToBody: boolean; alwaysOpen: boolean; showTags: boolean; tagsCountText: string; tagsSortFn: TagsSortFnType; clearable: boolean; searchable: boolean; placeholder: string; grouped: boolean; isGroupedValue: boolean; listSlotHtmlComponent: HTMLElement | null; disabled: boolean; emptyText: string; staticList: boolean; id: string; ariaLabel: string; isSingleSelect: boolean; showCount: boolean; disabledBranchNode: boolean; direction: DirectionType; expandSelected: boolean; saveScrollPosition: boolean; isIndependentNodes: boolean; rtl: boolean; iconElements: IconsType; ungroupedValue: ValueOptionType[]; groupedValue: ValueOptionType[]; isListOpened: boolean; selectedName: string; srcElement: HTMLElement | null; inputCallback: ((value: ValueType) => void) | undefined; openCallback: ((value: ValueType) => void) | undefined; closeCallback: ((value: ValueType) => void) | undefined; nameChangeCallback: ((name: string) => void) | undefined; searchCallback: ((value: string) => void) | undefined; openCloseGroupCallback: ((groupId: ValueOptionType, isClosed: boolean) => void) | undefined; mount: () => void; updateValue: (newValue: ValueInputType) => void; destroy: () => void; focus: () => void; toggleOpenClose: () => void; } /** * Options passed to the Treeselect constructor. * All properties except `parentHtmlContainer` are optional. */ export declare interface ITreeselectParams { /** HTML element (e.g. div) that will be replaced by the treeselect container (required). */ parentHtmlContainer: HTMLElement; /** Array of `value` from options to select on load. Use updateValue or set treeselect.value and call mount to update. Changes when checkboxes/tags change. */ value?: ValueInputType; /** Array of option objects { name, value, disabled?, htmlAttr?, isGroupSelectable?, children }. No duplicated values; names may duplicate. See Option description. */ options?: OptionType[]; /** All groups will be opened to this level (0 = all collapsed). */ openLevel?: number; /** List will be appended to the body instead of the input container. */ appendToBody?: boolean; /** List is always opened. Use for styling; for a fixed open list set staticList to true. */ alwaysOpen?: boolean; /** Selected values appear as tags. If false, shows '{count} elements selected' (use tagsCountText). Single selection shows the element name. */ showTags?: boolean; /** Text shown after count when showTags is false: '{count} {tagsCountText}'. */ tagsCountText?: string; /** Defines sort order for tags in the input. TagsSortItem: { value, name }. Use null for default order. */ tagsSortFn?: TagsSortFnType; /** Clear icon is available when value is set. */ clearable?: boolean; /** Search/filter input is available. */ searchable?: boolean; /** Placeholder text for the search input. */ placeholder?: string; /** Show groups in the input and group leaves when the whole group is selected. */ grouped?: boolean; /** Return selected groups instead of leaf ids only. By default only leaf ids are returned. */ isGroupedValue?: boolean; /** HTML element appended to the end of the list (e.g. custom footer/slot). */ listSlotHtmlComponent?: HTMLElement | null; /** List/control is disabled. */ disabled?: boolean; /** Text shown when the list is empty (e.g. no results). */ emptyText?: string; /** List is a static DOM element (no overlay). Ignored if appendToBody is true. */ staticList?: boolean; /** id attribute for the main input (accessibility). */ id?: string; /** aria-label attribute for the search input (accessibility). */ ariaLabel?: string; /** Single-value select: one option only, no checkboxes. Pass one id; showTags: false shows treeselect as dropdown. */ isSingleSelect?: boolean; /** Show count of children next to the group name. */ showCount?: boolean; /** Groups cannot be selected; only leaves can be selected. */ disabledBranchNode?: boolean; /** Force list direction. Supported: 'auto', 'top', 'bottom'. */ direction?: DirectionType; /** Groups that contain checked values are expanded on init/open. */ expandSelected?: boolean; /** Restore list scroll position when reopened. If false, scroll resets to 0 and first item is focused. */ saveScrollPosition?: boolean; /** Nodes are independent: check/uncheck does not update children/parent. Disabled nodes also ignore parent/child workflow. */ isIndependentNodes?: boolean; /** RTL mode. */ rtl?: boolean; /** Class name(s) for the list container. Useful for styling when using appendToBody. */ listClassName?: string; /** Experimental: improves list performance for large trees (visibility + IntersectionObserver). */ isBoostedRendering?: boolean; /** Object of SVG icons (arrowUp, arrowDown, arrowRight, attention, clear, cross, check, partialCheck). Use HTMLElement or string. Update styles after reset; use alwaysOpen for easier styling. */ iconElements?: Partial; /** Callback for input (selected value) instead of eventListener. */ inputCallback?: (value: ValueType) => void; /** Callback for open instead of eventListener. */ openCallback?: (value: ValueType) => void; /** Callback for close instead of eventListener. */ closeCallback?: (value: ValueType) => void; /** Callback for name-change (selected name in input) instead of eventListener. */ nameChangeCallback?: (name: string) => void; /** Callback for search (typed value) instead of eventListener. */ searchCallback?: (value: string) => void; /** Callback for open-close-group (groupId, isClosed) instead of eventListener. */ openCloseGroupCallback?: (groupId: ValueOptionType, isClosed: boolean) => void; } /** * Tree option node. Used in `options` and can be nested via `children`. */ export declare type OptionType = { /** Unique option id (string or number). */ value: ValueOptionType; /** Display name. */ name: string; /** If true, option is disabled and not selectable. */ disabled?: boolean; /** If true (group only), the group row can be selected. */ isGroupSelectable?: boolean; /** Optional HTML attributes applied to the option row (string values only). */ htmlAttr?: Record; /** Child options (nested tree). */ children: OptionType[]; }; /** Custom sort for tags. Return negative/zero/positive like Array.sort. Use null for default order. */ export declare type TagsSortFnType = ((itemA: TagsSortItem, itemB: TagsSortItem) => number) | null; /** Item passed to tags sort function. */ export declare type TagsSortItem = { value: ValueOptionType; name: string; }; /** * Tree-select component: hierarchical options, single/multi select, tags, search. * Create with `new Treeselect(params)` then call `mount()` to render. * @see ITreeselectParams for constructor options */ declare class Treeselect implements ITreeselect { #private; parentHtmlContainer: HTMLElement; /** Current value: single id (single select), array of ids (multi), or null. */ value: ValueType; options: OptionType[]; openLevel: number; appendToBody: boolean; alwaysOpen: boolean; showTags: boolean; tagsCountText: string; tagsSortFn: TagsSortFnType; clearable: boolean; searchable: boolean; placeholder: string; grouped: boolean; isGroupedValue: boolean; listSlotHtmlComponent: HTMLElement | null; disabled: boolean; emptyText: string; staticList: boolean; id: string; ariaLabel: string; isSingleSelect: boolean; showCount: boolean; disabledBranchNode: boolean; direction: DirectionType; expandSelected: boolean; saveScrollPosition: boolean; isIndependentNodes: boolean; rtl: boolean; listClassName: string; isBoostedRendering: boolean; iconElements: IconsType; inputCallback: ((value: ValueType) => void) | undefined; openCallback: ((value: ValueType) => void) | undefined; closeCallback: ((value: ValueType) => void) | undefined; nameChangeCallback: ((name: string) => void) | undefined; searchCallback: ((value: string) => void) | undefined; openCloseGroupCallback: ((groupId: ValueOptionType, isClosed: boolean) => void) | undefined; ungroupedValue: ValueOptionType[]; groupedValue: ValueOptionType[]; allValue: ValueOptionType[]; /** True when the dropdown list is open. */ isListOpened: boolean; /** Selected option label (single select). */ selectedName: string; /** Root DOM element of the treeselect (null after destroy). */ srcElement: HTMLElement | null; /** * @param params - Configuration and callbacks; only parentHtmlContainer is required */ constructor({ parentHtmlContainer, value, options, openLevel, appendToBody, alwaysOpen, showTags, tagsCountText, tagsSortFn, clearable, searchable, placeholder, grouped, isGroupedValue, listSlotHtmlComponent, disabled, emptyText, staticList, id, ariaLabel, isSingleSelect, showCount, disabledBranchNode, direction, expandSelected, saveScrollPosition, isIndependentNodes, rtl, listClassName, isBoostedRendering, iconElements, inputCallback, openCallback, closeCallback, nameChangeCallback, searchCallback, openCloseGroupCallback, }: ITreeselectParams); /** Renders the treeselect into parentHtmlContainer. Call after constructor or to re-mount. */ mount(): void; /** Sets the current value (single id, array of ids, or null). Updates UI and callbacks. */ updateValue(newValue: ValueInputType): void; /** Removes the component from DOM and clears listeners. Call before removing the container. */ destroy(): void; /** Moves focus to the treeselect input. */ focus(): void; /** Opens the list if closed, closes if open. */ toggleOpenClose(): void; scrollWindowHandler(): void; focusWindowHandler(e: Event): void; blurWindowHandler(): void; updateListPosition(): void; } export default Treeselect; /** Initial value accepted by constructor (can be undefined). */ export declare type ValueInputType = ValueOptionType[] | ValueOptionType | null | undefined; /** Id/value of a single option (string or number). */ declare type ValueOptionType = string | number; /** Current value: array of ids (multi), single id (single), or null. */ export declare type ValueType = ValueOptionType[] | ValueOptionType | null; export { }