antd APIs
- Button
- Input
- Modal
- Form
- message
- Row
- Tooltip
- Select
- Menu
- Col
- Spin
- Table
- Dropdown
- Card
- Switch
- Checkbox
- Space
- Tag
- Radio
- Tabs
- Typography
- Divider
- InputNumber
- Popover
- Alert
- Layout
- DatePicker
- List
- Collapse
- Avatar
- ConfigProvider
- notification
- Drawer
- Empty
- Badge
- Result
- Popconfirm
- Upload
- AutoComplete
- Progress
- Skeleton
- Image
- Tree
- Breadcrumb
- Slider
- FormInstance
- Descriptions
- Pagination
- PageHeader
- ButtonProps
- Statistic
- Steps
- FormItemProps
- TreeSelect
- Anchor
- Icon
- RadioChangeEvent
- TimePicker
- SelectProps
- Cascader
- ModalProps
- Affix
- TableProps
- Rate
- MenuProps
- InputProps
- Transfer
- FormProps
- MenuItemProps
- TooltipProps
- UploadProps
- PopoverProps
- Timeline
- Carousel
- CheckboxProps
- Mentions
- CardProps
- SpinProps
- InputNumberProps
- SubMenuProps
- Comment
- CascaderProps
- DatePickerProps
- SliderSingleProps
- TreeSelectProps
- RadioProps
- Grid
- Calendar
- AlertProps
- PaginationProps
- DropDownProps
- ColProps
- TableColumnsType
- LocaleProvider
- LayoutProps
- AutoCompleteProps
- RateProps
- MentionProps
- SwitchProps
- TimePickerProps
- AnchorProps
- TablePaginationConfig
- MessageArgsProps
- TabsProps
- CarouselProps
- RadioGroupProps
- RowProps
- BackTop
- ModalFuncProps
- InputRef
- AvatarProps
- TreeDataNode
- TableColumnProps
- TableColumnType
- TreeNodeProps
Other Related APIs
antd#TreeNodeProps TypeScript Examples
The following examples show how to use
antd#TreeNodeProps.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts From datart with Apache License 2.0 | 6 votes |
export function listToTree<
T extends {
id: string;
name: string;
parentId: string | null;
isFolder: boolean;
index: number | null;
},
>(
list: undefined | T[],
parentId: null | string = null,
parentPath: string[] = [],
options?: {
getIcon?: (o: T) => ReactElement | ((props: TreeNodeProps) => ReactElement);
getDisabled?: (o: T, path: string[]) => boolean;
getSelectable?: (o: T) => boolean;
filter?: (path: string[], o: T) => boolean;
},
): undefined | any[] {
if (!list) {
return list;
}
const treeNodes: any[] = [];
const childrenList: T[] = [];
list.forEach(o => {
const path = parentPath.concat(o.id);
if (options?.filter && !options.filter(path, o)) {
return false;
}
if (o.parentId === parentId) {
treeNodes.push({
...o,
key: o.id,
title: o.name,
value: o.id,
path,
...(options?.getIcon && { icon: options.getIcon(o) }),
...(options?.getDisabled && { disabled: options.getDisabled(o, path) }),
...(options?.getSelectable && { selectable: options.getSelectable(o) }),
});
} else {
childrenList.push(o);
}
});
treeNodes.sort((a, b) => Number(a.index) - Number(b.index));
return treeNodes.map(node => {
const children = listToTree(childrenList, node.key, node.path, options);
return children?.length ? { ...node, children } : { ...node, isLeaf: true };
});
}