changing the interface of TreeSelect, updating docs (#11538)

pull/11608/head
Bartek 7 years ago committed by 偏右
parent a14ba62a07
commit b9c248f313

@ -40,7 +40,7 @@ Any data whose entries are defined in a hierarchical manner is fit to use this c
| treeCheckable | Whether to show checkbox on the treeNodes | boolean | false |
| treeCheckStrictly | Whether to check nodes precisely (in the `checkable` mode), means parent and child nodes are not associated, and it will make `labelInValue` be true | boolean | false |
| treeData | Data of the treeNodes, manual construction work is no longer needed if this property has been set(ensure the Uniqueness of each value) | array<{ value, title, children, [disabled, disableCheckbox, selectable] }> | \[] |
| treeDataSimpleMode | Enable simple mode of treeData.(treeData should like this: [{id:1, pId:0, value:'1', title:"test1",...},...], pId is parent node's id) | false\|Array<{ id: string, pId: string, rootPId: null }> | false |
| treeDataSimpleMode | Enable simple mode of treeData. Changes the `treeData` schema to: [{id:1, pId:0, value:'1', title:"test1",...},...] where pId is parent node's id). It is possible to replace the default `id` and `pId` keys by providing object to `treeDataSimpleMode` | false\|Array<{ id: string, pId: string, rootPId: null }> | false |
| treeDefaultExpandAll | Whether to expand all treeNodes by default | boolean | false |
| treeDefaultExpandedKeys | Default expanded treeNodes | string\[] | - |
| treeNodeFilterProp | Will be used for filtering if `filterTreeNode` returns true | string | 'value' |
@ -66,6 +66,6 @@ Any data whose entries are defined in a hierarchical manner is fit to use this c
| disableCheckbox | Disables the checkbox of the treeNode | boolean | false |
| disabled | Disabled or not | boolean | false |
| isLeaf | Leaf node or not | boolean | false |
| key | Required property, should be unique in the tree | string | - |
| key | Required property (unless using `treeDataSimpleMode`), should be unique in the tree | string | - |
| title | Content showed on the treeNodes | string\|ReactNode | '---' |
| value | Will be treated as `treeNodeFilterProp` by default, should be unique in the tree | string | - |

@ -6,7 +6,7 @@ import { SelectLocale } from '../select';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import warning from '../_util/warning';
export { TreeData, TreeSelectProps } from './interface';
export { TreeNode, TreeSelectProps } from './interface';
export default class TreeSelect extends React.Component<TreeSelectProps, any> {
static TreeNode = TreeNode;

@ -1,15 +1,32 @@
import * as React from 'react';
import { AbstractSelectProps } from '../select';
export interface TreeData {
key: string;
export type TreeNode = TreeNodeNormal | TreeNodeSimpleMode;
interface TreeNodeNormal {
value: string;
/**
* @deprecated Please use `title` instead.
*/
label?: React.ReactNode;
title?: React.ReactNode;
children?: TreeData[];
key: string;
isLeaf?: boolean;
disabled?: boolean;
disableCheckbox?: boolean;
selectable?: boolean;
children?: TreeNodeNormal[];
}
interface TreeNodeSimpleMode {
/* It is possible to change `id` and `pId` prop keys using TreeDataSimpleMode so those keys can be anything */
[key: string]: string | boolean | React.ReactNode;
}
interface TreeDataSimpleMode {
id?: string;
pId?: string;
rootPId?: string;
}
export interface TreeSelectProps extends AbstractSelectProps {
@ -27,8 +44,8 @@ export interface TreeSelectProps extends AbstractSelectProps {
filterTreeNode?: (inputValue: string, treeNode: any) => boolean | boolean;
treeNodeFilterProp?: string;
treeNodeLabelProp?: string;
treeData?: Array<TreeData>;
treeDataSimpleMode?: boolean | Object;
treeData?: Array<TreeNode>;
treeDataSimpleMode?: boolean | TreeDataSimpleMode;
loadData?: (node: any) => void;
showCheckedStrategy?: 'SHOW_ALL' | 'SHOW_PARENT' | 'SHOW_CHILD';
labelInValue?: boolean;

Loading…
Cancel
Save