feat: update tree-select
parent
5a627fc5f3
commit
0b03957ebe
|
@ -19,6 +19,7 @@
|
||||||
| placeholder | Placeholder of the select input | string\|slot | - |
|
| placeholder | Placeholder of the select input | string\|slot | - |
|
||||||
| searchPlaceholder | Placeholder of the search input | string\|slot | - |
|
| searchPlaceholder | Placeholder of the search input | string\|slot | - |
|
||||||
| searchValue(.sync) | work with `search` event to make search value controlled. | string | - |
|
| searchValue(.sync) | work with `search` event to make search value controlled. | string | - |
|
||||||
|
| treeIcon | Shows the icon before a TreeNode's title. There is no default style; you must set a custom style for it if set to `true` | boolean | false |
|
||||||
| showCheckedStrategy | The way show selected item in box. **Default:** just show child nodes. **`TreeSelect.SHOW_ALL`:** show all checked treeNodes (include parent treeNode). **`TreeSelect.SHOW_PARENT`:** show checked treeNodes (just show parent treeNode). | enum { TreeSelect.SHOW_ALL, TreeSelect.SHOW_PARENT, TreeSelect.SHOW_CHILD } | TreeSelect.SHOW_CHILD |
|
| showCheckedStrategy | The way show selected item in box. **Default:** just show child nodes. **`TreeSelect.SHOW_ALL`:** show all checked treeNodes (include parent treeNode). **`TreeSelect.SHOW_PARENT`:** show checked treeNodes (just show parent treeNode). | enum { TreeSelect.SHOW_ALL, TreeSelect.SHOW_PARENT, TreeSelect.SHOW_CHILD } | TreeSelect.SHOW_CHILD |
|
||||||
| showSearch | Whether to display a search input in the dropdown menu(valid only in the single mode) | boolean | false |
|
| showSearch | Whether to display a search input in the dropdown menu(valid only in the single mode) | boolean | false |
|
||||||
| size | To set the size of the select input, options: `large` `small` | string | 'default' |
|
| size | To set the size of the select input, options: `large` `small` | string | 'default' |
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import VcTreeSelect, { TreeNode, SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from '../vc-tree-select';
|
import VcTreeSelect, { TreeNode, SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from '../vc-tree-select';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { TreeSelectProps } from './interface';
|
import { TreeSelectProps } from './interface';
|
||||||
import LocaleReceiver from '../locale-provider/LocaleReceiver';
|
|
||||||
import warning from '../_util/warning';
|
import warning from '../_util/warning';
|
||||||
import {
|
import {
|
||||||
initDefaultProps,
|
initDefaultProps,
|
||||||
|
@ -10,9 +9,8 @@ import {
|
||||||
filterEmpty,
|
filterEmpty,
|
||||||
isValidElement,
|
isValidElement,
|
||||||
} from '../_util/props-util';
|
} from '../_util/props-util';
|
||||||
|
import { ConfigConsumerProps } from '../config-provider';
|
||||||
export { TreeData, TreeSelectProps } from './interface';
|
export { TreeData, TreeSelectProps } from './interface';
|
||||||
|
|
||||||
import Icon from '../icon';
|
import Icon from '../icon';
|
||||||
import omit from 'omit.js';
|
import omit from 'omit.js';
|
||||||
import { cloneElement } from '../_util/vnode';
|
import { cloneElement } from '../_util/vnode';
|
||||||
|
@ -24,7 +22,6 @@ const TreeSelect = {
|
||||||
SHOW_CHILD,
|
SHOW_CHILD,
|
||||||
name: 'ATreeSelect',
|
name: 'ATreeSelect',
|
||||||
props: initDefaultProps(TreeSelectProps(), {
|
props: initDefaultProps(TreeSelectProps(), {
|
||||||
prefixCls: 'ant-select',
|
|
||||||
transitionName: 'slide-up',
|
transitionName: 'slide-up',
|
||||||
choiceTransitionName: 'zoom',
|
choiceTransitionName: 'zoom',
|
||||||
showSearch: false,
|
showSearch: false,
|
||||||
|
@ -50,8 +47,7 @@ const TreeSelect = {
|
||||||
blur() {
|
blur() {
|
||||||
this.$refs.vcTreeSelect.blur();
|
this.$refs.vcTreeSelect.blur();
|
||||||
},
|
},
|
||||||
renderSwitcherIcon({ isLeaf, loading }) {
|
renderSwitcherIcon(prefixCls, { isLeaf, loading }) {
|
||||||
const { prefixCls } = this.$props;
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <Icon type="loading" class={`${prefixCls}-switcher-loading-icon`} />;
|
return <Icon type="loading" class={`${prefixCls}-switcher-loading-icon`} />;
|
||||||
}
|
}
|
||||||
|
@ -83,18 +79,26 @@ const TreeSelect = {
|
||||||
Object.assign(list[i], item);
|
Object.assign(list[i], item);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renderTreeSelect(locale) {
|
},
|
||||||
const props = getOptionProps(this);
|
|
||||||
|
|
||||||
|
render(h) {
|
||||||
|
const props = getOptionProps(this);
|
||||||
const {
|
const {
|
||||||
prefixCls,
|
prefixCls: customizePrefixCls,
|
||||||
size,
|
size,
|
||||||
notFoundContent,
|
|
||||||
dropdownStyle,
|
dropdownStyle,
|
||||||
dropdownClassName,
|
dropdownClassName,
|
||||||
getPopupContainer,
|
getPopupContainer,
|
||||||
...restProps
|
...restProps
|
||||||
} = props;
|
} = props;
|
||||||
|
const getPrefixCls = this.configProvider.getPrefixCls || ConfigConsumerProps.getPrefixCls;
|
||||||
|
const prefixCls = getPrefixCls('select', customizePrefixCls);
|
||||||
|
|
||||||
|
const renderEmpty = (
|
||||||
|
this.configProvider.renderEmpty &&
|
||||||
|
this.configProvider.renderEmpty()
|
||||||
|
) || ConfigConsumerProps.renderEmpty;
|
||||||
|
const notFoundContent = getComponentFromProp(this, 'notFoundContent');
|
||||||
const { getPopupContainer: getContextPopupContainer } = this.configProvider;
|
const { getPopupContainer: getContextPopupContainer } = this.configProvider;
|
||||||
const rest = omit(restProps, [
|
const rest = omit(restProps, [
|
||||||
'inputIcon',
|
'inputIcon',
|
||||||
|
@ -126,10 +130,9 @@ const TreeSelect = {
|
||||||
const clearIcon = (
|
const clearIcon = (
|
||||||
<Icon type="close-circle" class={`${prefixCls}-clear-icon`} theme="filled" />
|
<Icon type="close-circle" class={`${prefixCls}-clear-icon`} theme="filled" />
|
||||||
);
|
);
|
||||||
|
|
||||||
const VcTreeSelectProps = {
|
const VcTreeSelectProps = {
|
||||||
props: {
|
props: {
|
||||||
switcherIcon: this.renderSwitcherIcon,
|
switcherIcon: (nodeProps) => this.renderSwitcherIcon(prefixCls, nodeProps),
|
||||||
inputIcon,
|
inputIcon,
|
||||||
removeIcon,
|
removeIcon,
|
||||||
clearIcon,
|
clearIcon,
|
||||||
|
@ -139,7 +142,7 @@ const TreeSelect = {
|
||||||
prefixCls,
|
prefixCls,
|
||||||
dropdownStyle: { maxHeight: '100vh', overflow: 'auto', ...dropdownStyle },
|
dropdownStyle: { maxHeight: '100vh', overflow: 'auto', ...dropdownStyle },
|
||||||
treeCheckable: checkable,
|
treeCheckable: checkable,
|
||||||
notFoundContent: notFoundContent || locale.notFoundContent,
|
notFoundContent: notFoundContent || renderEmpty(h, 'Select'),
|
||||||
__propsSymbol__: Symbol(),
|
__propsSymbol__: Symbol(),
|
||||||
},
|
},
|
||||||
class: cls,
|
class: cls,
|
||||||
|
@ -148,17 +151,6 @@ const TreeSelect = {
|
||||||
scopedSlots: this.$scopedSlots,
|
scopedSlots: this.$scopedSlots,
|
||||||
};
|
};
|
||||||
return <VcTreeSelect {...VcTreeSelectProps}>{filterEmpty(this.$slots.default)}</VcTreeSelect>;
|
return <VcTreeSelect {...VcTreeSelectProps}>{filterEmpty(this.$slots.default)}</VcTreeSelect>;
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<LocaleReceiver
|
|
||||||
componentName="Select"
|
|
||||||
defaultLocale={{}}
|
|
||||||
scopedSlots={{ default: this.renderTreeSelect }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
| placeholder | 选择框默认文字 | string\|slot | - |
|
| placeholder | 选择框默认文字 | string\|slot | - |
|
||||||
| searchPlaceholder | 搜索框默认文字 | string\|slot | - |
|
| searchPlaceholder | 搜索框默认文字 | string\|slot | - |
|
||||||
| searchValue(.sync) | 搜索框的值,可以通过 `search` 事件获取用户输入 | string | - |
|
| searchValue(.sync) | 搜索框的值,可以通过 `search` 事件获取用户输入 | string | - |
|
||||||
|
| treeIcon | 是否展示 TreeNode title 前的图标,没有默认样式,如设置为 true,需要自行定义图标相关样式 | boolean | false |
|
||||||
| showCheckedStrategy | 定义选中项回填的方式。`TreeSelect.SHOW_ALL`: 显示所有选中节点(包括父节点). `TreeSelect.SHOW_PARENT`: 只显示父节点(当父节点下所有子节点都选中时). 默认只显示子节点. | enum{TreeSelect.SHOW_ALL, TreeSelect.SHOW_PARENT, TreeSelect.SHOW_CHILD } | TreeSelect.SHOW_CHILD |
|
| showCheckedStrategy | 定义选中项回填的方式。`TreeSelect.SHOW_ALL`: 显示所有选中节点(包括父节点). `TreeSelect.SHOW_PARENT`: 只显示父节点(当父节点下所有子节点都选中时). 默认只显示子节点. | enum{TreeSelect.SHOW_ALL, TreeSelect.SHOW_PARENT, TreeSelect.SHOW_CHILD } | TreeSelect.SHOW_CHILD |
|
||||||
| showSearch | 在下拉中显示搜索框(仅在单选模式下生效) | boolean | false |
|
| showSearch | 在下拉中显示搜索框(仅在单选模式下生效) | boolean | false |
|
||||||
| size | 选择框大小,可选 `large` `small` | string | 'default' |
|
| size | 选择框大小,可选 `large` `small` | string | 'default' |
|
||||||
|
|
|
@ -22,6 +22,7 @@ export const TreeSelectProps = () => ({
|
||||||
value: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array]),
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array]),
|
||||||
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array]),
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array]),
|
||||||
multiple: PropTypes.bool,
|
multiple: PropTypes.bool,
|
||||||
|
notFoundContent: PropTypes.any,
|
||||||
// onSelect: (value: any) => void,
|
// onSelect: (value: any) => void,
|
||||||
// onChange: (value: any, label: any) => void,
|
// onChange: (value: any, label: any) => void,
|
||||||
// onSearch: (value: any) => void,
|
// onSearch: (value: any) => void,
|
||||||
|
@ -29,7 +30,7 @@ export const TreeSelectProps = () => ({
|
||||||
searchValue: PropTypes.string,
|
searchValue: PropTypes.string,
|
||||||
showCheckedStrategy: PropTypes.oneOf(['SHOW_ALL', 'SHOW_PARENT', 'SHOW_CHILD']),
|
showCheckedStrategy: PropTypes.oneOf(['SHOW_ALL', 'SHOW_PARENT', 'SHOW_CHILD']),
|
||||||
suffixIcon: PropTypes.any,
|
suffixIcon: PropTypes.any,
|
||||||
treeCheckable: PropTypes.bool,
|
treeCheckable: PropTypes.oneOfType([PropTypes.any, PropTypes.bool]),
|
||||||
treeCheckStrictly: PropTypes.bool,
|
treeCheckStrictly: PropTypes.bool,
|
||||||
treeData: PropTypes.arrayOf(Object),
|
treeData: PropTypes.arrayOf(Object),
|
||||||
treeDataSimpleMode: PropTypes.oneOfType([Boolean, Object]),
|
treeDataSimpleMode: PropTypes.oneOfType([Boolean, Object]),
|
||||||
|
@ -38,6 +39,7 @@ export const TreeSelectProps = () => ({
|
||||||
dropdownMatchSelectWidth: PropTypes.bool,
|
dropdownMatchSelectWidth: PropTypes.bool,
|
||||||
treeDefaultExpandAll: PropTypes.bool,
|
treeDefaultExpandAll: PropTypes.bool,
|
||||||
treeExpandedKeys: PropTypes.array,
|
treeExpandedKeys: PropTypes.array,
|
||||||
|
treeIcon: PropTypes.bool,
|
||||||
treeDefaultExpandedKeys: PropTypes.array,
|
treeDefaultExpandedKeys: PropTypes.array,
|
||||||
treeNodeFilterProp: PropTypes.string,
|
treeNodeFilterProp: PropTypes.string,
|
||||||
treeNodeLabelProp: PropTypes.string,
|
treeNodeLabelProp: PropTypes.string,
|
||||||
|
|
|
@ -104,7 +104,7 @@ const Select = {
|
||||||
treeDataSimpleMode: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
treeDataSimpleMode: PropTypes.oneOfType([PropTypes.bool, PropTypes.object]),
|
||||||
treeNodeFilterProp: PropTypes.string,
|
treeNodeFilterProp: PropTypes.string,
|
||||||
treeNodeLabelProp: PropTypes.string,
|
treeNodeLabelProp: PropTypes.string,
|
||||||
treeCheckable: PropTypes.oneOfType([PropTypes.any, PropTypes.bool]),
|
treeCheckable: PropTypes.oneOfType([PropTypes.any, PropTypes.object, PropTypes.bool]),
|
||||||
// treeCheckable: PropTypes.any,
|
// treeCheckable: PropTypes.any,
|
||||||
treeCheckStrictly: PropTypes.bool,
|
treeCheckStrictly: PropTypes.bool,
|
||||||
treeIcon: PropTypes.bool,
|
treeIcon: PropTypes.bool,
|
||||||
|
|
Loading…
Reference in New Issue