UNPKG

27.4 kBJavaScriptView Raw
1'use strict';
2
3exports.__esModule = true;
4exports.default = undefined;
5
6var _extends2 = require('babel-runtime/helpers/extends');
7
8var _extends3 = _interopRequireDefault(_extends2);
9
10var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
11
12var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
13
14var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
15
16var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
17
18var _inherits2 = require('babel-runtime/helpers/inherits');
19
20var _inherits3 = _interopRequireDefault(_inherits2);
21
22var _class, _temp;
23
24var _react = require('react');
25
26var _react2 = _interopRequireDefault(_react);
27
28var _reactDom = require('react-dom');
29
30var _propTypes = require('prop-types');
31
32var _propTypes2 = _interopRequireDefault(_propTypes);
33
34var _classnames = require('classnames');
35
36var _classnames2 = _interopRequireDefault(_classnames);
37
38var _util = require('../util');
39
40var _menu = require('../menu');
41
42var _menu2 = _interopRequireDefault(_menu);
43
44var _overlay = require('../overlay');
45
46var _overlay2 = _interopRequireDefault(_overlay);
47
48var _input = require('../input');
49
50var _input2 = _interopRequireDefault(_input);
51
52var _zhCn = require('../locale/zh-cn');
53
54var _zhCn2 = _interopRequireDefault(_zhCn);
55
56var _dataStore = require('./data-store');
57
58var _dataStore2 = _interopRequireDefault(_dataStore);
59
60var _virtualList = require('../virtual-list');
61
62var _virtualList2 = _interopRequireDefault(_virtualList);
63
64var _util2 = require('./util');
65
66function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
67
68var Popup = _overlay2.default.Popup;
69var MenuItem = _menu2.default.Item,
70 MenuGroup = _menu2.default.Group;
71var noop = _util.func.noop,
72 bindCtx = _util.func.bindCtx,
73 makeChain = _util.func.makeChain;
74
75
76function preventDefault(e) {
77 e.preventDefault();
78}
79
80var Base = (_temp = _class = function (_React$Component) {
81 (0, _inherits3.default)(Base, _React$Component);
82
83 function Base(props) {
84 (0, _classCallCheck3.default)(this, Base);
85
86 var _this = (0, _possibleConstructorReturn3.default)(this, _React$Component.call(this, props));
87
88 _this.handleMouseDown = function (e) {
89 if (!_this.props.popupAutoFocus) {
90 preventDefault(e);
91 }
92 };
93
94 _this.saveSelectRef = function (ref) {
95 _this.selectDOM = (0, _reactDom.findDOMNode)(ref);
96 };
97
98 _this.saveInputRef = function (ref) {
99 if (ref && ref.getInstance()) {
100 _this.inputRef = ref.getInstance();
101 }
102 };
103
104 _this.savePopupRef = function (ref) {
105 _this.popupRef = ref;
106 };
107
108 _this.dataStore = new _dataStore2.default({
109 filter: props.filter,
110 filterLocal: props.filterLocal,
111 showDataSourceChildren: props.showDataSourceChildren
112 });
113
114 var mode = props.mode;
115
116 var value = 'value' in props ? props.value : props.defaultValue;
117
118 // 多选情况下做 value 数组订正
119 if (props.mode !== 'single' && value && !Array.isArray(value)) {
120 value = [value];
121 }
122
123 _this.state = {
124 dataStore: _this.dataStore,
125 value: value,
126 visible: 'visible' in props ? props.visible : props.defaultVisible,
127 dataSource: _this.setDataSource(_this.props),
128 width: 100,
129 // highlightKey应为String 多选初始化只赋值受控highlightKey/defaultHighlightKey
130 highlightKey: 'highlightKey' in props ? props.highlightKey : props.mode === 'single' ? props.value || props.defaultHighlightKey || props.defaultValue : props.defaultHighlightKey,
131 srReader: ''
132 };
133
134 bindCtx(_this, ['handleMenuBodyClick', 'handleVisibleChange', 'focusInput', 'beforeOpen', 'beforeClose', 'afterClose', 'handleResize']);
135 return _this;
136 }
137
138 Base.prototype.componentDidMount = function componentDidMount() {
139 var _this2 = this;
140
141 // overlay 还没有完成 mount,所以需要滞后同步宽度
142 setTimeout(function () {
143 return _this2.syncWidth();
144 }, 0);
145
146 _util.events.on(window, 'resize', this.handleResize);
147 };
148
149 Base.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
150 if (prevProps.label !== this.props.label || prevState.value !== this.state.value) {
151 this.syncWidth();
152 }
153 };
154
155 Base.prototype.componentWillUnmount = function componentWillUnmount() {
156 _util.events.off(window, 'resize', this.handleResize);
157 clearTimeout(this.resizeTimeout);
158 };
159
160 /**
161 * Calculate and set width of popup menu
162 * @protected
163 */
164
165
166 Base.prototype.syncWidth = function syncWidth() {
167 var _this3 = this;
168
169 var _props2 = this.props,
170 popupStyle = _props2.popupStyle,
171 popupProps = _props2.popupProps;
172
173 if (popupStyle && 'width' in popupStyle || popupProps && popupProps.style && 'width' in popupProps.style) {
174 return;
175 }
176
177 var width = _util.dom.getStyle(this.selectDOM, 'width');
178 if (width && this.width !== width) {
179 this.width = width;
180
181 if (this.popupRef && this.shouldAutoWidth()) {
182 // overy 的 node 节点可能没有挂载完成,所以这里需要异步
183 setTimeout(function () {
184 if (_this3.popupRef) {
185 _util.dom.setStyle(_this3.popupRef, 'width', _this3.width);
186 return;
187 }
188 }, 0);
189 }
190 }
191 };
192
193 Base.prototype.handleResize = function handleResize() {
194 var _this4 = this;
195
196 clearTimeout(this.resizeTimeout);
197 if (this.state.visible) {
198 this.resizeTimeout = setTimeout(function () {
199 _this4.syncWidth();
200 }, 200);
201 }
202 };
203
204 /**
205 * Get structured dataSource, for cache
206 * @protected
207 * @param {Object} [props=this.props]
208 * @return {Array}
209 */
210
211
212 Base.prototype.setDataSource = function setDataSource(props) {
213 var dataSource = props.dataSource,
214 children = props.children;
215
216 // children is higher priority then dataSource
217
218 if (_react.Children.count(children)) {
219 return this.dataStore.updateByDS(children, true);
220 } else if (Array.isArray(dataSource)) {
221 return this.dataStore.updateByDS(dataSource, false);
222 }
223 return [];
224 };
225
226 /**
227 * Set popup visible
228 * @protected
229 * @param {boolean} visible
230 * @param {string} type trigger type
231 */
232
233
234 Base.prototype.setVisible = function setVisible(visible, type) {
235 // disabled 状态下只允许关闭不允许打开
236 if (this.props.disabled && visible || this.state.visible === visible) {
237 return;
238 }
239
240 if (!('visible' in this.props)) {
241 this.setState({
242 visible: visible
243 });
244 }
245
246 this.props.onVisibleChange(visible, type);
247 };
248
249 Base.prototype.setFirstHightLightKeyForMenu = function setFirstHightLightKeyForMenu(searchValue) {
250 // 判断value/highlightKey解决受控后,默认高亮第一个元素问题。(当搜索值时,搜索后应执行默认选择第一个元素)
251 var highlightKey = this.state.highlightKey;
252
253 if (!this.props.autoHighlightFirstItem) {
254 return;
255 }
256
257 // 设置高亮 item key
258 if (this.dataStore.getMenuDS().length && this.dataStore.getEnableDS().length && (!highlightKey || searchValue)) {
259 var _highlightKey = '' + this.dataStore.getEnableDS()[0].value;
260 this.setState({
261 highlightKey: _highlightKey
262 });
263 this.props.onToggleHighlightItem(_highlightKey, 'autoFirstItem');
264 }
265
266 // 当有搜索值且搜索条件与dataSource不匹配时(搜索条件不满足不会出现可选择的列表,所以高亮key应为null)
267 if (searchValue && !this.dataStore.getEnableDS().length) {
268 this.setState({
269 highlightKey: null
270 });
271 this.props.onToggleHighlightItem(null, 'highlightKeyToNull');
272 }
273 };
274
275 Base.prototype.handleChange = function handleChange(value) {
276 var _props3;
277
278 // 非受控模式清空内部数据
279 if (!('value' in this.props)) {
280 this.setState({
281 value: value
282 });
283 }
284
285 for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
286 args[_key - 1] = arguments[_key];
287 }
288
289 (_props3 = this.props).onChange.apply(_props3, [value].concat(args));
290 };
291
292 /**
293 * Handle Menu body click
294 * @param {Event} e click event
295 */
296
297
298 Base.prototype.handleMenuBodyClick = function handleMenuBodyClick(e) {
299 if (!this.props.popupAutoFocus) {
300 this.focusInput(e);
301 }
302 };
303
304 /**
305 * Toggle highlight MenuItem
306 * @private
307 * @param {number} dir -1: up, 1: down
308 */
309
310
311 Base.prototype.toggleHighlightItem = function toggleHighlightItem(dir) {
312 if (!this.state.visible) {
313 this.setVisible(true, 'enter');
314 return;
315 }
316
317 var maxCount = this.dataStore.getEnableDS().length;
318 // When there is no enabled item
319 if (!maxCount) {
320 return false;
321 }
322
323 var highlightKey = this.state.highlightKey;
324
325 var highlightIndex = -1;
326
327 // find previous highlight index
328 highlightKey !== null && this.dataStore.getEnableDS().some(function (item, index) {
329 if ('' + item.value === highlightKey) {
330 highlightIndex = index;
331 }
332 return highlightIndex > -1;
333 });
334
335 // toggle highlight index
336 highlightIndex += dir;
337 if (highlightIndex < 0) {
338 highlightIndex = maxCount - 1;
339 }
340 if (highlightIndex >= maxCount) {
341 highlightIndex = 0;
342 }
343
344 // get highlight key
345 var highlightItem = this.dataStore.getEnableDS()[highlightIndex];
346 highlightKey = highlightItem ? '' + highlightItem.value : null;
347
348 this.setState({ highlightKey: highlightKey, srReader: highlightItem.label });
349
350 this.scrollMenuIntoView();
351
352 return highlightItem;
353 };
354
355 // scroll into focus item
356
357
358 Base.prototype.scrollMenuIntoView = function scrollMenuIntoView() {
359 var _this5 = this;
360
361 var prefix = this.props.prefix;
362
363
364 clearTimeout(this.highlightTimer);
365 this.highlightTimer = setTimeout(function () {
366 try {
367 var menuNode = (0, _reactDom.findDOMNode)(_this5.menuRef);
368 var itemNode = menuNode.querySelector('.' + prefix + 'select-menu-item.' + prefix + 'focused');
369 itemNode && itemNode.scrollIntoViewIfNeeded && itemNode.scrollIntoViewIfNeeded();
370 } catch (ex) {
371 // I don't care...
372 }
373 });
374 };
375
376 /**
377 * render popup menu header
378 * @abstract
379 */
380
381
382 Base.prototype.renderMenuHeader = function renderMenuHeader() {
383 var menuProps = this.props.menuProps;
384
385
386 if (menuProps && 'header' in menuProps) {
387 return menuProps.header;
388 }
389
390 return null;
391 };
392
393 Base.prototype.handleSelect = function handleSelect() {};
394
395 /**
396 * 防止 onBlur/onFocus 抖动
397 */
398
399 /**
400 * render popup children
401 * @protected
402 * @param {object} props
403 */
404 Base.prototype.renderMenu = function renderMenu() {
405 var _classNames,
406 _this6 = this;
407
408 var _props4 = this.props,
409 prefix = _props4.prefix,
410 mode = _props4.mode,
411 locale = _props4.locale,
412 notFoundContent = _props4.notFoundContent,
413 useVirtual = _props4.useVirtual,
414 menuProps = _props4.menuProps;
415 var _state = this.state,
416 dataSource = _state.dataSource,
417 highlightKey = _state.highlightKey;
418
419 var value = this.state.value;
420 var selectedKeys = void 0;
421
422 if ((0, _util2.isNull)(value) || value.length === 0 || this.isAutoComplete) {
423 selectedKeys = [];
424 } else if ((0, _util2.isSingle)(mode)) {
425 selectedKeys = [(0, _util2.valueToSelectKey)(value)];
426 } else {
427 selectedKeys = [].concat(value).map(function (n) {
428 return (0, _util2.valueToSelectKey)(n);
429 });
430 }
431
432 var children = this.renderMenuItem(dataSource);
433
434 var menuClassName = (0, _classnames2.default)((_classNames = {}, _classNames[prefix + 'select-menu'] = true, _classNames[prefix + 'select-menu-empty'] = !children || !children.length, _classNames));
435
436 if (!children || !children.length) {
437 children = _react2.default.createElement(
438 'span',
439 { className: prefix + 'select-menu-empty-content' },
440 notFoundContent || locale.notFoundContent
441 );
442 }
443
444 var customProps = (0, _extends3.default)({}, menuProps, {
445 children: children,
446 role: 'listbox',
447 selectedKeys: selectedKeys,
448 focusedKey: highlightKey,
449 focusable: false,
450 selectMode: (0, _util2.isSingle)(mode) ? 'single' : 'multiple',
451 onSelect: this.handleMenuSelect,
452 onItemClick: this.handleItemClick,
453 header: this.renderMenuHeader(),
454 onClick: this.handleMenuBodyClick,
455 onMouseDown: this.handleMouseDown,
456 className: menuClassName
457 });
458 var menuStyle = this.shouldAutoWidth() ? { width: '100%' } : { minWidth: this.width };
459
460 return useVirtual && children.length > 10 ? _react2.default.createElement(
461 'div',
462 { className: prefix + 'select-menu-wrapper', style: (0, _extends3.default)({ position: 'relative' }, menuStyle) },
463 _react2.default.createElement(
464 _virtualList2.default,
465 {
466 itemsRenderer: function itemsRenderer(items, _ref) {
467 return _react2.default.createElement(
468 _menu2.default,
469 (0, _extends3.default)({
470 ref: function ref(c) {
471 _ref(c);
472 _this6.menuRef = c;
473 },
474 flatenContent: true
475 }, customProps),
476 items
477 );
478 }
479 },
480 children
481 )
482 ) : _react2.default.createElement(_menu2.default, (0, _extends3.default)({}, customProps, { style: menuStyle }));
483 };
484
485 /**
486 * render menu item
487 * @protected
488 * @param {Array} dataSource
489 */
490
491
492 Base.prototype.renderMenuItem = function renderMenuItem(dataSource) {
493 var _this7 = this;
494
495 var _props5 = this.props,
496 prefix = _props5.prefix,
497 itemRender = _props5.itemRender,
498 showDataSourceChildren = _props5.showDataSourceChildren;
499 // If it has.
500
501 var searchKey = void 0;
502 if (this.isAutoComplete) {
503 // In AutoComplete, value is the searchKey
504 searchKey = this.state.value;
505 } else {
506 searchKey = this.state.searchValue;
507 }
508
509 return dataSource.map(function (item, index) {
510 if (!item) {
511 return null;
512 }
513 if (Array.isArray(item.children) && showDataSourceChildren) {
514 return _react2.default.createElement(
515 MenuGroup,
516 { key: index, label: item.label },
517 _this7.renderMenuItem(item.children)
518 );
519 } else {
520 var itemProps = {
521 role: 'option',
522 key: item.value,
523 className: prefix + 'select-menu-item',
524 disabled: item.disabled
525 };
526
527 if ('title' in item) {
528 itemProps.title = item.title;
529 }
530
531 return _react2.default.createElement(
532 MenuItem,
533 itemProps,
534 itemRender(item, searchKey)
535 );
536 }
537 });
538 };
539
540 /**
541 * 点击 arrow 或 label 的时候焦点切到 input 中
542 * @override
543 */
544 Base.prototype.focusInput = function focusInput() {
545 this.inputRef.focus();
546 };
547
548 Base.prototype.focus = function focus() {
549 var _inputRef;
550
551 (_inputRef = this.inputRef).focus.apply(_inputRef, arguments);
552 };
553
554 Base.prototype.beforeOpen = function beforeOpen() {
555 if (this.props.mode === 'single') {
556 this.setFirstHightLightKeyForMenu();
557 }
558 this.syncWidth();
559 };
560
561 Base.prototype.beforeClose = function beforeClose() {};
562
563 Base.prototype.afterClose = function afterClose() {};
564
565 Base.prototype.shouldAutoWidth = function shouldAutoWidth() {
566 if (this.props.popupComponent) {
567 return false;
568 }
569
570 return this.props.autoWidth;
571 };
572
573 Base.prototype.render = function render(props) {
574 var _classNames2;
575
576 var prefix = props.prefix,
577 mode = props.mode,
578 popupProps = props.popupProps,
579 popupContainer = props.popupContainer,
580 popupClassName = props.popupClassName,
581 popupStyle = props.popupStyle,
582 popupContent = props.popupContent,
583 canCloseByTrigger = props.canCloseByTrigger,
584 followTrigger = props.followTrigger,
585 cache = props.cache,
586 popupComponent = props.popupComponent,
587 isPreview = props.isPreview,
588 renderPreview = props.renderPreview,
589 style = props.style,
590 className = props.className;
591
592
593 var cls = (0, _classnames2.default)((_classNames2 = {}, _classNames2[prefix + 'select-auto-complete-menu'] = !popupContent && this.isAutoComplete, _classNames2[prefix + 'select-' + mode + '-menu'] = !popupContent && !!mode, _classNames2), popupClassName || popupProps.className);
594
595 if (isPreview) {
596 if (this.isAutoComplete) {
597 return _react2.default.createElement(_input2.default, {
598 style: style,
599 className: className,
600 isPreview: isPreview,
601 renderPreview: renderPreview,
602 value: this.state.value
603 });
604 } else {
605 var value = this.state.value;
606 var valueDS = this.state.value;
607
608 if (!this.useDetailValue()) {
609 if (value === this.valueDataSource.value) {
610 valueDS = this.valueDataSource.valueDS;
611 } else {
612 valueDS = (0, _util2.getValueDataSource)(value, this.valueDataSource.mapValueDS, this.dataStore.getMapDS()).valueDS;
613 }
614 }
615
616 if (typeof renderPreview === 'function') {
617 var _classNames3;
618
619 var previewCls = (0, _classnames2.default)((_classNames3 = {}, _classNames3[prefix + 'form-preview'] = true, _classNames3[className] = !!className, _classNames3));
620 return _react2.default.createElement(
621 'div',
622 { style: style, className: previewCls },
623 renderPreview(valueDS, this.props)
624 );
625 } else {
626 var fillProps = this.props.fillProps;
627
628 if (mode === 'single') {
629 return _react2.default.createElement(_input2.default, {
630 style: style,
631 className: className,
632 isPreview: isPreview,
633 value: valueDS ? fillProps ? valueDS[fillProps] : valueDS.label : ''
634 });
635 } else {
636 return _react2.default.createElement(_input2.default, {
637 style: style,
638 className: className,
639 isPreview: isPreview,
640 value: (valueDS || []).map(function (i) {
641 return i.label;
642 }).join(', ')
643 });
644 }
645 }
646 }
647 }
648
649 var _props = (0, _extends3.default)({
650 triggerType: 'click',
651 autoFocus: !!this.props.popupAutoFocus,
652 cache: cache
653 }, popupProps, {
654 //beforeOpen node not mount, afterOpen too slow.
655 // from display:none to block, we may need to recompute width
656 beforeOpen: makeChain(this.beforeOpen, popupProps.beforeOpen),
657 beforeClose: makeChain(this.beforeClose, popupProps.beforeClose),
658 afterClose: makeChain(this.afterClose, popupProps.afterClose),
659 canCloseByTrigger: canCloseByTrigger,
660 followTrigger: followTrigger,
661 visible: this.state.visible,
662 onVisibleChange: this.handleVisibleChange,
663 shouldUpdatePosition: true,
664 container: popupContainer || popupProps.container,
665 className: cls,
666 style: popupStyle || popupProps.style
667 });
668
669 if (popupProps.v2) {
670 delete _props.shouldUpdatePosition;
671 }
672
673 var Tag = popupComponent ? popupComponent : Popup;
674
675 return _react2.default.createElement(
676 Tag,
677 (0, _extends3.default)({}, _props, { trigger: this.renderSelect() }),
678 popupContent ? _react2.default.createElement(
679 'div',
680 {
681 className: prefix + 'select-popup-wrap',
682 style: this.shouldAutoWidth() ? { width: this.width } : {},
683 ref: this.savePopupRef
684 },
685 popupContent
686 ) : _react2.default.createElement(
687 'div',
688 {
689 className: prefix + 'select-spacing-tb',
690 style: this.shouldAutoWidth() ? { width: this.width } : {},
691 ref: this.savePopupRef
692 },
693 this.renderMenu()
694 )
695 );
696 };
697
698 return Base;
699}(_react2.default.Component), _class.propTypes = {
700 prefix: _propTypes2.default.string,
701 /**
702 * 选择器尺寸
703 */
704 size: _propTypes2.default.oneOf(['small', 'medium', 'large']),
705 // 当前值,用于受控模式
706 value: _propTypes2.default.any, // to be override
707 // 初始化的默认值
708 defaultValue: _propTypes2.default.any, // to be override
709 /**
710 * 没有值的时候的占位符
711 */
712 placeholder: _propTypes2.default.string,
713 /**
714 * 下拉菜单是否与选择器对齐
715 */
716 autoWidth: _propTypes2.default.bool,
717 /**
718 * 自定义内联 label
719 */
720 label: _propTypes2.default.node,
721 /**
722 * 是否有清除按钮(单选模式有效)
723 */
724 hasClear: _propTypes2.default.bool,
725 /**
726 * 校验状态
727 */
728 state: _propTypes2.default.oneOf(['error', 'loading', 'success', 'warning']),
729 /**
730 * 是否只读,只读模式下可以展开弹层但不能选
731 */
732 readOnly: _propTypes2.default.bool,
733 /**
734 * 是否禁用选择器
735 */
736 disabled: _propTypes2.default.bool,
737 /**
738 * 当前弹层是否显示
739 */
740 visible: _propTypes2.default.bool,
741 /**
742 * 弹层初始化是否显示
743 */
744 defaultVisible: _propTypes2.default.bool,
745 /**
746 * 弹层显示或隐藏时触发的回调
747 * @param {Boolean} visible 弹层是否显示
748 * @param {String} type 触发弹层显示或隐藏的来源 fromContent 表示由Dropdown内容触发; fromTrigger 表示由trigger的点击触发; docClick 表示由document的点击触发
749 */
750 onVisibleChange: _propTypes2.default.func,
751 /**
752 * 弹层挂载的容器节点
753 */
754 popupContainer: _propTypes2.default.any,
755 /**
756 * 弹层的 className
757 */
758 popupClassName: _propTypes2.default.any,
759 /**
760 * 弹层的内联样式
761 */
762 popupStyle: _propTypes2.default.object,
763 /**
764 * 添加到弹层上的属性
765 */
766 popupProps: _propTypes2.default.object,
767 /**
768 * 是否跟随滚动
769 */
770 followTrigger: _propTypes2.default.bool,
771 /**
772 * 自定义弹层的内容
773 */
774 popupContent: _propTypes2.default.node,
775 /**
776 * 添加到菜单上的属性
777 * @version 1.18
778 */
779 menuProps: _propTypes2.default.object,
780 /**
781 * 是否使用本地过滤,在数据源为远程的时候需要关闭此项
782 */
783 filterLocal: _propTypes2.default.bool,
784 /**
785 * 本地过滤方法,返回一个 Boolean 值确定是否保留
786 * @param {String} key 搜索关键字
787 * @param {Object} item 渲染节点的item
788 * @return {Boolean} 是否匹配
789 */
790 filter: _propTypes2.default.func,
791 /**
792 * 默认高亮的 key,不要和 autoHighlightFirstItem 同时使用
793 */
794 defaultHighlightKey: _propTypes2.default.string,
795 /**
796 * 高亮 key,不要和 autoHighlightFirstItem 同时使用,用于受控模式
797 */
798 highlightKey: _propTypes2.default.string,
799 /**
800 * 键盘上下键切换菜单高亮选项的回调
801 */
802 onToggleHighlightItem: _propTypes2.default.func,
803 /**
804 * 自动高亮第一个元素
805 */
806 autoHighlightFirstItem: _propTypes2.default.bool,
807 /**
808 * 是否开启虚拟滚动模式
809 */
810 useVirtual: _propTypes2.default.bool,
811 // 自定义类名
812 className: _propTypes2.default.any,
813 children: _propTypes2.default.any,
814 dataSource: _propTypes2.default.array,
815 itemRender: _propTypes2.default.func,
816 mode: _propTypes2.default.string,
817 notFoundContent: _propTypes2.default.node,
818 locale: _propTypes2.default.object,
819 rtl: _propTypes2.default.bool,
820 popupComponent: _propTypes2.default.any,
821 /**
822 * 是否为预览态
823 */
824 isPreview: _propTypes2.default.bool,
825 /**
826 * 预览态模式下渲染的内容
827 * @param {number} value 评分值
828 */
829 renderPreview: _propTypes2.default.func,
830 showDataSourceChildren: _propTypes2.default.bool
831}, _class.defaultProps = {
832 prefix: 'next-',
833 size: 'medium',
834 autoWidth: true,
835 onChange: noop,
836 onVisibleChange: noop,
837 onToggleHighlightItem: noop,
838 popupProps: {},
839 filterLocal: true,
840 filter: _util2.filter,
841 itemRender: function itemRender(item) {
842 return item.label || item.value;
843 },
844 locale: _zhCn2.default.Select,
845 autoHighlightFirstItem: true,
846 showDataSourceChildren: true,
847 defaultHighlightKey: null
848}, _temp);
849Base.displayName = 'Base';
850exports.default = Base;
851module.exports = exports['default'];
\No newline at end of file