View as Markdown

API reference: @salmonui/dropdowns/tree-select

TreeSelectSinglePropsinterface

import type { TreeSelectSingleProps } from '@salmonui/dropdowns/tree-select';
interface TreeSelectSingleProps<Item> extends TreeSelectOwnProps<Item> {
    readonly multiple?: false;
    readonly value?: DropdownValue | null;
    readonly defaultValue?: DropdownValue | null;
    readonly onValueChange?: (value: DropdownValue | null, event: DropdownValueChangeEvent<Item>) => void;
}
TreeSelectSingleProps members (66, 62 inherited)
NameSignatureDescription
multipleoptionalreadonly multiple?: false;
valueoptionalreadonly value?: DropdownValue | null;
defaultValueoptionalreadonly defaultValue?: DropdownValue | null;
onValueChangeoptionalreadonly onValueChange?: (value: DropdownValue | null, event: DropdownValueChangeEvent<Item>) => void;
datainheriteddata: readonly Item[];

Items: nested (getChildren) or flat (getParentId).

getItemValueoptionalinheritedgetItemValue?: ((item: Item) => TreeSelectValue);

Default: item.value, or item.id when there is no value field.

getItemLabeloptionalinheritedgetItemLabel?: ((item: Item) => string);

Default: item.label, else item.text, else the value.

getChildrenoptionalinheritedgetChildren?: ((item: Item) => readonly Item[] | null | undefined);

Nested data: the children of an item. Default item.children.

getParentIdoptionalinheritedgetParentId?: ((item: Item) => TreeSelectValue | null | undefined);

Flat (self-referential) data: the parent value of an item; replaces getChildren.

hasChildrenoptionalinheritedhasChildren?: ((item: Item) => boolean);

Shows an expand twisty before the children are known; expanding then calls loadChildren.

loadChildrenoptionalinheritedloadChildren?: ((item: Item, options: { readonly signal: AbortSignal; }) => Promise<readonly Item[]>);

Load on demand: the children of item (aborted through signal when stale).

onLoadErroroptionalinheritedonLoadError?: ((error: unknown, item: Item) => void);
isItemDisabledoptionalinheritedisItemDisabled?: ((item: Item) => boolean);

Default: item.disabled === true. A disabled parent disables its subtree.

isItemSelectableoptionalinheritedisItemSelectable?: ((item: Item) => boolean);

Nodes that cannot be chosen still expand (default: every enabled node).

getItemIconoptionalinheritedgetItemIcon?: ((item: Item) => ReactNode);
getItemPropsoptionalinheritedgetItemProps?: ((item: Item) => (DropdownPartProps & { readonly title?: string | undefined; }) | undefined);

Pure per-item props merged onto the rendered treeitem (title, data-*, className, style).

selectedItemsoptionalinheritedselectedItems?: readonly Item[];

Items of the current value that are not in loaded data (lazily loaded nodes): their labels.

expandedoptionalinheritedexpanded?: readonly TreeSelectValue[];
defaultExpandedoptionalinheriteddefaultExpanded?: readonly TreeSelectValue[];
onExpandedChangeoptionalinheritedonExpandedChange?: ((expanded: readonly TreeSelectValue[], event: TreeSelectExpandedChangeEvent<Item>) => void);
expandOnoptionalinheritedexpandOn?: TreeSelectExpandOn;
openoptionalinheritedopen?: boolean;
defaultOpenoptionalinheriteddefaultOpen?: boolean;
onOpenChangeoptionalinheritedonOpenChange?: ((open: boolean, event: DropdownOpenChangeEvent) => void);
popupModeoptionalinheritedpopupMode?: "auto" | "popover" | "sheet";

'popover' (default), 'sheet' (full-screen dialog) or 'auto' (the sheet on coarse-pointer phones, decided at open time).

searchableoptionalinheritedsearchable?: boolean;

A search field in the popup; matches keep their ancestors visible.

searchPlaceholderoptionalinheritedsearchPlaceholder?: string;
searchOperatoroptionalinheritedsearchOperator?: "contains" | "endsWith" | "startsWith" | ((item: Item, text: string) => boolean);
matchCaseoptionalinheritedmatchCase?: boolean;
ignoreAccentsoptionalinheritedignoreAccents?: boolean;
onSearchChangeoptionalinheritedonSearchChange?: ((text: string, event: { readonly source: DropdownEventSource; }) => void);
indicatoroptionalinheritedindicator?: "check" | "checkbox";

'checkbox' (with multiple): tri-state checks; the value is every checked node.

checkPropagationoptionalinheritedcheckPropagation?: "cascade" | "none";

Checks of a parent and its descendants follow each other (default 'cascade').

showSelectAlloptionalinheritedshowSelectAll?: boolean;
closeOnSelectoptionalinheritedcloseOnSelect?: boolean;
valueDisplayoptionalinheritedvalueDisplay?: "chips" | "count" | "text";
maxVisibleValuesoptionalinheritedmaxVisibleValues?: number;
valueSeparatoroptionalinheritedvalueSeparator?: string;
showTriggeroptionalinheritedshowTrigger?: boolean;
clearableoptionalinheritedclearable?: boolean;
placeholderoptionalinheritedplaceholder?: string;
disabledoptionalinheriteddisabled?: boolean;
readOnlyoptionalinheritedreadOnly?: boolean;
nameoptionalinheritedname?: string;
requiredoptionalinheritedrequired?: boolean;
formoptionalinheritedform?: string;
idoptionalinheritedid?: string;
autoFocusoptionalinheritedautoFocus?: boolean;
maxVisibleItemsoptionalinheritedmaxVisibleItems?: number;

Popup height in rows. Default 8.

virtualizationoptionalinheritedvirtualization?: boolean;

Windowed tree; on by default above 100 visible rows.

localeoptionalinheritedlocale?: string;
renderItemoptionalinheritedrenderItem?: ((props: TreeSelectItemRenderProps<Item>) => ReactNode);
renderValueoptionalinheritedrenderValue?: ((props: { readonly items: readonly Item[]; readonly labels: readonly string[]; }) => ReactNode);
renderEmptyoptionalinheritedrenderEmpty?: ((props: { readonly reason: "noData" | "noMatch"; }) => ReactNode);
renderErroroptionalinheritedrenderError?: ((props: { readonly error: unknown; readonly item: Item; readonly retry: () => void; }) => ReactNode);
renderLoadingoptionalinheritedrenderLoading?: ((props: { readonly item: Item; }) => ReactNode);
popupHeaderoptionalinheritedpopupHeader?: ReactNode;
popupFooteroptionalinheritedpopupFooter?: ReactNode;
highlightMatchesoptionalinheritedhighlightMatches?: boolean;
sizeoptionalinheritedsize?: "lg" | "md" | "sm";

Control size: 'sm' 24px, 'md' 32px (default), 'lg' 40px tall.

localeTextoptionalinheritedlocaleText?: Partial<TreeSelectLocaleText>;
classNameoptionalinheritedclassName?: string;
styleoptionalinheritedstyle?: CSSProperties;
classNamesoptionalinheritedclassNames?: Partial<Record<TreeSelectPart, string>>;
stylesoptionalinheritedstyles?: Partial<Record<TreeSelectPart, CSSProperties>>;
refoptionalinheritedref?: Ref<HTMLButtonElement>;

The trigger <button role="combobox">.