UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

55 lines (54 loc) 2.44 kB
import * as React from 'react'; import { toDisplayValueDefault, toDisplayValueFromOptionTree } from '../treeUtils'; export type TreeListItem<T = any> = { id?: string | number; label: string; children?: TreeListItem<T>[]; }; export { toDisplayValueDefault, toDisplayValueFromOptionTree }; export type NewTreeDropdownProps<T extends TreeListItem<any>> = { isLoading?: boolean; placeholder?: string; style?: React.CSSProperties; fieldStyle?: React.CSSProperties; /** * Additional class name applied to the underlying `MultiCombobox` root. * Exposed so higher-level wrappers (e.g. `GridFilterTreeDropdown`) can * restyle the field without reaching into the component internals. */ className?: string; items: TreeListItem<T>[]; labelField?: string; primaryKey?: keyof T | string; value?: any[][] | string[]; defaultValue?: any[][] | string[]; /** * Formats a single selected path into the text shown on its chip. Called * once per chip with a single-path wrapper (`[path]`) so the same * `toDisplayValue` helpers used by the legacy TreeDropdown continue to work. */ toDisplayValue?: (value: any[][] | string[]) => string; /** * Replaces the default chip rendering for the field with a custom node. * Called with the current set of selected leaf paths and a helper for * resolving each path's display label. Used e.g. by `GridFilterTreeDropdown` * to show a compact comma-separated summary instead of chips. */ renderSelectedValues?: (args: { selectedLeafPaths: any[][]; getLabelForPath: (path: any[]) => string; }) => React.ReactNode; onValueChange: (value: any[][] | string[]) => void; onOpenChange?: (open: boolean) => void; resizable?: boolean; showClear?: boolean; }; export declare function TreeDropdown<T extends TreeListItem<any>>(props: NewTreeDropdownProps<T>): React.JSX.Element; export type GridFilterTreeDropdownProps<T extends TreeListItem<any>> = Omit<NewTreeDropdownProps<T>, 'renderSelectedValues'> & { /** * When true, prefix the selected-values summary with `(N)` where N is the * number of selected leaves. Mirrors `GridFilterCombobox.showSelectedCount`. */ showSelectedCount?: boolean; }; export declare function GridFilterTreeDropdown<T extends TreeListItem<any>>(props: GridFilterTreeDropdownProps<T>): React.JSX.Element;