UNPKG

2.59 kBJavaScriptView Raw
1import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
2import ConfigProvider from '../config-provider';
3import Select from './select';
4import AutoComplete from './auto-complete';
5import Option from './option';
6import OptionGroup from './option-group';
7
8Select.AutoComplete = ConfigProvider.config(AutoComplete, {
9 componentName: 'Select'
10});
11
12Select.Option = Option;
13Select.OptionGroup = OptionGroup;
14
15// compatible with 0.x version
16/* istanbul ignore next */
17function _transform(props, deprecated) {
18 var shape = props.shape,
19 container = props.container,
20 multiple = props.multiple,
21 filterBy = props.filterBy,
22 overlay = props.overlay,
23 safeNode = props.safeNode,
24 noFoundContent = props.noFoundContent,
25 others = _objectWithoutProperties(props, ['shape', 'container', 'multiple', 'filterBy', 'overlay', 'safeNode', 'noFoundContent']);
26
27 var newprops = others;
28 if (shape === 'arrow-only') {
29 deprecated('shape=arrow-only', 'hasBorder=false', 'Select');
30 newprops.hasBorder = false;
31 }
32 if (container) {
33 deprecated('container', 'popupContainer', 'Select');
34 newprops.popupContainer = container;
35 }
36 if (multiple) {
37 deprecated('multiple', 'mode=multiple', 'Select');
38 newprops.mode = 'multiple';
39 }
40 if (filterBy) {
41 deprecated('filterBy', 'filter', 'Select');
42 newprops.filter = filterBy;
43 }
44 if (overlay) {
45 deprecated('overlay', 'popupContent', 'Select');
46 newprops.popupContent = overlay;
47 newprops.autoWidth = false;
48 }
49
50 if (noFoundContent) {
51 deprecated('noFoundContent', 'notFoundContent', 'Select');
52 newprops.notFoundContent = noFoundContent;
53 }
54
55 if (safeNode) {
56 deprecated('safeNode', 'popupProps={safeNode}', 'Select');
57 newprops.popupProps = {
58 safeNode: safeNode
59 };
60 }
61
62 return newprops;
63}
64
65// compatible with 0.x version: Select.Combobox
66Select.Combobox = ConfigProvider.config(Select, {
67 transform: /* istanbul ignore next */function transform(props, deprecated) {
68 deprecated('Select.Combobox', '<Select showSearch={true}/>', 'Select');
69
70 var newprops = _transform(props, deprecated);
71 if (props.onInputUpdate) {
72 newprops.onSearch = props.onInputUpdate;
73 newprops.showSearch = true;
74 }
75 return newprops;
76 }
77});
78
79export default ConfigProvider.config(Select, {
80 transform: _transform,
81 exportNames: ['focusInput', 'handleSearchClear']
82});
\No newline at end of file