1 | 'use strict';
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.default = undefined;
|
5 |
|
6 | var _extends2 = require('babel-runtime/helpers/extends');
|
7 |
|
8 | var _extends3 = _interopRequireDefault(_extends2);
|
9 |
|
10 | var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
11 |
|
12 | var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
13 |
|
14 | var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
15 |
|
16 | var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
17 |
|
18 | var _inherits2 = require('babel-runtime/helpers/inherits');
|
19 |
|
20 | var _inherits3 = _interopRequireDefault(_inherits2);
|
21 |
|
22 | var _class, _temp;
|
23 |
|
24 | var _react = require('react');
|
25 |
|
26 | var _react2 = _interopRequireDefault(_react);
|
27 |
|
28 | var _reactDom = require('react-dom');
|
29 |
|
30 | var _propTypes = require('prop-types');
|
31 |
|
32 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
33 |
|
34 | var _classnames = require('classnames');
|
35 |
|
36 | var _classnames2 = _interopRequireDefault(_classnames);
|
37 |
|
38 | var _util = require('../util');
|
39 |
|
40 | var _menu = require('../menu');
|
41 |
|
42 | var _menu2 = _interopRequireDefault(_menu);
|
43 |
|
44 | var _overlay = require('../overlay');
|
45 |
|
46 | var _overlay2 = _interopRequireDefault(_overlay);
|
47 |
|
48 | var _input = require('../input');
|
49 |
|
50 | var _input2 = _interopRequireDefault(_input);
|
51 |
|
52 | var _zhCn = require('../locale/zh-cn');
|
53 |
|
54 | var _zhCn2 = _interopRequireDefault(_zhCn);
|
55 |
|
56 | var _dataStore = require('./data-store');
|
57 |
|
58 | var _dataStore2 = _interopRequireDefault(_dataStore);
|
59 |
|
60 | var _virtualList = require('../virtual-list');
|
61 |
|
62 | var _virtualList2 = _interopRequireDefault(_virtualList);
|
63 |
|
64 | var _util2 = require('./util');
|
65 |
|
66 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
67 |
|
68 | var Popup = _overlay2.default.Popup;
|
69 | var MenuItem = _menu2.default.Item,
|
70 | MenuGroup = _menu2.default.Group;
|
71 | var noop = _util.func.noop,
|
72 | bindCtx = _util.func.bindCtx,
|
73 | makeChain = _util.func.makeChain;
|
74 |
|
75 |
|
76 | function preventDefault(e) {
|
77 | e.preventDefault();
|
78 | }
|
79 |
|
80 | var 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 |
|
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 |
|
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 |
|
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 |
|
162 |
|
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 |
|
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 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | Base.prototype.setDataSource = function setDataSource(props) {
|
213 | var dataSource = props.dataSource,
|
214 | children = props.children;
|
215 |
|
216 |
|
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 |
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 |
|
234 | Base.prototype.setVisible = function setVisible(visible, type) {
|
235 |
|
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 |
|
251 | var highlightKey = this.state.highlightKey;
|
252 |
|
253 | if (!this.props.autoHighlightFirstItem) {
|
254 | return;
|
255 | }
|
256 |
|
257 |
|
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 |
|
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 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 | Base.prototype.handleMenuBodyClick = function handleMenuBodyClick(e) {
|
299 | if (!this.props.popupAutoFocus) {
|
300 | this.focusInput(e);
|
301 | }
|
302 | };
|
303 |
|
304 | |
305 |
|
306 |
|
307 |
|
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 |
|
319 | if (!maxCount) {
|
320 | return false;
|
321 | }
|
322 |
|
323 | var highlightKey = this.state.highlightKey;
|
324 |
|
325 | var highlightIndex = -1;
|
326 |
|
327 |
|
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 |
|
336 | highlightIndex += dir;
|
337 | if (highlightIndex < 0) {
|
338 | highlightIndex = maxCount - 1;
|
339 | }
|
340 | if (highlightIndex >= maxCount) {
|
341 | highlightIndex = 0;
|
342 | }
|
343 |
|
344 |
|
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 |
|
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 |
|
372 | }
|
373 | });
|
374 | };
|
375 |
|
376 | |
377 |
|
378 |
|
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 |
|
397 |
|
398 |
|
399 | |
400 |
|
401 |
|
402 |
|
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 |
|
487 |
|
488 |
|
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 |
|
500 |
|
501 | var searchKey = void 0;
|
502 | if (this.isAutoComplete) {
|
503 |
|
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 |
|
542 |
|
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 |
|
655 |
|
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,
|
707 |
|
708 | defaultValue: _propTypes2.default.any,
|
709 | |
710 |
|
711 |
|
712 | placeholder: _propTypes2.default.string,
|
713 | |
714 |
|
715 |
|
716 | autoWidth: _propTypes2.default.bool,
|
717 | |
718 |
|
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 |
|
748 |
|
749 |
|
750 | onVisibleChange: _propTypes2.default.func,
|
751 | |
752 |
|
753 |
|
754 | popupContainer: _propTypes2.default.any,
|
755 | |
756 |
|
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 |
|
778 |
|
779 | menuProps: _propTypes2.default.object,
|
780 | |
781 |
|
782 |
|
783 | filterLocal: _propTypes2.default.bool,
|
784 | |
785 |
|
786 |
|
787 |
|
788 |
|
789 |
|
790 | filter: _propTypes2.default.func,
|
791 | |
792 |
|
793 |
|
794 | defaultHighlightKey: _propTypes2.default.string,
|
795 | |
796 |
|
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 |
|
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);
|
849 | Base.displayName = 'Base';
|
850 | exports.default = Base;
|
851 | module.exports = exports['default']; |
\ | No newline at end of file |