forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cascader.jsx
841 lines (734 loc) · 26.2 KB
/
cascader.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { polyfill } from 'react-lifecycles-compat';
import cloneDeep from 'lodash.clonedeep';
import cx from 'classnames';
import Menu from '../menu';
import { func, obj, dom } from '../util';
import CascaderMenu from './menu';
import CascaderMenuItem from './item';
import {
filterChildValue,
getAllCheckedValues,
forEachEnableNode,
isSiblingOrSelf,
isDescendantOrSelf,
isNodeChecked,
} from './utils';
const { bindCtx } = func;
const { pickOthers } = obj;
const { addClass, removeClass, setStyle, getStyle } = dom;
// 数据打平
const flatDataSource = (data, prefix = '0', v2n = {}, p2n = {}) => {
data.forEach((item, index) => {
const { value, children } = item;
const pos = `${prefix}-${index}`;
const newValue = String(value);
item.value = newValue;
v2n[newValue] = p2n[pos] = {
...item,
pos,
_source: item,
};
if (children && children.length) {
flatDataSource(children, pos, v2n, p2n);
}
});
return { v2n, p2n };
};
function preHandleData(data, immutable) {
const _data = immutable ? cloneDeep(data) : data;
try {
return flatDataSource(_data);
} catch (err) {
if ((err.message || '').match('Cannot assign to read only property')) {
// eslint-disable-next-line no-console
console.error(err.message, 'try to set immutable to true to allow immutable dataSource');
}
throw err;
}
}
const getExpandedValue = (v, _v2n, _p2n) => {
if (!v || !_v2n[v]) {
return [];
}
const pos = _v2n[v].pos;
if (pos.split('-').length === 2) {
return [];
}
const expandedMap = {};
Object.keys(_p2n).forEach(p => {
if (isDescendantOrSelf(p, pos) && p !== pos) {
expandedMap[_p2n[p].value] = p;
}
});
return Object.keys(expandedMap).sort((prev, next) => {
return expandedMap[prev].split('-').length - expandedMap[next].split('-').length;
});
};
const normalizeValue = value => {
if (value) {
if (Array.isArray(value)) {
return value;
}
return [value];
}
return [];
};
/**
* Cascader
*/
class Cascader extends Component {
static propTypes = {
prefix: PropTypes.string,
rtl: PropTypes.bool,
pure: PropTypes.bool,
className: PropTypes.string,
/**
* 数据源,结构可参考下方说明
*/
dataSource: PropTypes.arrayOf(PropTypes.object),
/**
* (非受控)默认值
*/
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
/**
* (受控)当前值
*/
value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
/**
* 选中值改变时触发的回调函数
* @param {String|Array} value 选中的值,单选时返回单个值,多选时返回数组
* @param {Object|Array} data 选中的数据,包括 value 和 label,单选时返回单个值,多选时返回数组,父子节点选中关联时,同时选中,只返回父节点
* @param {Object} extra 额外参数
* @param {Array} extra.selectedPath 单选时选中的数据的路径
* @param {Boolean} extra.checked 多选时当前的操作是选中还是取消选中
* @param {Object} extra.currentData 多选时当前操作的数据
* @param {Array} extra.checkedData 多选时所有被选中的数据
* @param {Array} extra.indeterminateData 多选时半选的数据
*/
onChange: PropTypes.func,
onSelect: PropTypes.func,
/**
* (非受控)默认展开值,如果不设置,组件内部会根据 defaultValue/value 进行自动设置
*/
defaultExpandedValue: PropTypes.arrayOf(PropTypes.string),
/**
* (受控)当前展开值
*/
expandedValue: PropTypes.arrayOf(PropTypes.string),
/**
* 展开触发的方式
*/
expandTriggerType: PropTypes.oneOf(['click', 'hover']),
/**
* 展开时触发的回调函数
* @param {Array} expandedValue 各列展开值的数组
*/
onExpand: PropTypes.func,
/**
* 是否开启虚拟滚动
*/
useVirtual: PropTypes.bool,
/**
* 是否多选
*/
multiple: PropTypes.bool,
/**
* 单选时是否只能选中叶子节点
*/
canOnlySelectLeaf: PropTypes.bool,
/**
* 多选时是否只能选中叶子节点
*/
canOnlyCheckLeaf: PropTypes.bool,
/**
* 父子节点是否选中不关联
*/
checkStrictly: PropTypes.bool,
/**
* 每列列表样式对象
*/
listStyle: PropTypes.object,
/**
* 每列列表类名
*/
listClassName: PropTypes.string,
/**
* 每列列表项渲染函数
* @param {Object} data 数据
* @return {ReactNode} 列表项内容
*/
itemRender: PropTypes.func,
/**
* 异步加载数据函数
* @param {Object} data 当前点击异步加载的数据
* @param {Object} source 当前点击数据,source是原始对象
*/
loadData: PropTypes.func,
searchValue: PropTypes.string,
onBlur: PropTypes.func,
filteredPaths: PropTypes.array,
filteredListStyle: PropTypes.object,
resultRender: PropTypes.func,
/**
* 是否是不可变数据
* @version 1.23
*/
immutable: PropTypes.bool,
};
static defaultProps = {
prefix: 'next-',
rtl: false,
pure: false,
dataSource: [],
defaultValue: null,
canOnlySelectLeaf: false,
canOnlyCheckLeaf: false,
expandTriggerType: 'click',
multiple: false,
useVirtual: false,
checkStrictly: false,
itemRender: item => item.label,
immutable: false,
};
constructor(props, context) {
super(props, context);
const {
defaultValue,
value,
defaultExpandedValue,
expandedValue,
dataSource,
multiple,
checkStrictly,
canOnlyCheckLeaf,
loadData,
immutable,
} = props;
const { v2n, p2n } = preHandleData(dataSource, immutable);
let normalizedValue = normalizeValue(typeof value === 'undefined' ? defaultValue : value);
if (!loadData) {
normalizedValue = normalizedValue.filter(v => v2n[v]);
}
const realExpandedValue =
typeof expandedValue === 'undefined'
? typeof defaultExpandedValue === 'undefined'
? getExpandedValue(normalizedValue[0], v2n, p2n)
: normalizeValue(defaultExpandedValue)
: normalizeValue(expandedValue);
const st = {
value: normalizedValue,
expandedValue: realExpandedValue,
};
if (multiple && !checkStrictly && !canOnlyCheckLeaf) {
st.value = getAllCheckedValues(st.value, v2n, p2n);
}
this.lastExpandedValue = [...st.expandedValue];
this.state = {
...st,
_v2n: v2n,
_p2n: p2n,
};
bindCtx(this, ['handleMouseLeave', 'handleFocus', 'handleFold', 'getCascaderNode', 'onBlur']);
}
static getDerivedStateFromProps(props, state) {
const { v2n, p2n } = preHandleData(props.dataSource, props.immutable);
const states = {};
if ('value' in props) {
states.value = normalizeValue(props.value);
if (!props.loadData) {
states.value = states.value.filter(v => v2n[v]);
}
const { multiple, checkStrictly, canOnlyCheckLeaf } = props;
if (multiple && !checkStrictly && !canOnlyCheckLeaf) {
states.value = getAllCheckedValues(states.value, v2n, p2n);
}
if (!state.expandedValue.length && !('expandedValue' in props)) {
states.expandedValue = getExpandedValue(states.value[0], v2n, p2n);
}
}
if ('expandedValue' in props) {
states.expandedValue = normalizeValue(props.expandedValue);
}
return {
...states,
_v2n: v2n,
_p2n: p2n,
};
}
componentDidMount() {
this.setCascaderInnerWidth();
}
componentDidUpdate() {
this.setCascaderInnerWidth();
}
getCascaderNode(ref) {
this.cascader = ref;
if (this.cascader) {
this.cascaderInner = this.cascader.querySelector(`.${this.props.prefix}cascader-inner`);
}
}
setCascaderInnerWidth() {
if (!this.cascaderInner) {
return;
}
const menus = [].slice.call(this.cascaderInner.querySelectorAll(`.${this.props.prefix}cascader-menu-wrapper`));
if (menus.length === 0) {
return;
}
const menusWidth = Math.ceil(
menus.reduce((ret, menu) => {
return ret + Math.ceil(menu.getBoundingClientRect().width);
}, 0)
);
if (getStyle(this.cascaderInner, 'width') !== menusWidth) {
setStyle(this.cascaderInner, 'width', menusWidth);
}
if (getStyle(this.cascader, 'display') === 'inline-block') {
const hasRightBorderClass = `${this.props.prefix}has-right-border`;
menus.forEach(menu => removeClass(menu, hasRightBorderClass));
if (this.cascader.clientWidth > menusWidth) {
addClass(menus[menus.length - 1], hasRightBorderClass);
}
}
}
/*eslint-enable*/
flatValue(value) {
return filterChildValue(value, this.state._v2n, this.state._p2n);
}
getValue(pos) {
return this.state._p2n[pos] ? this.state._p2n[pos].value : null;
}
getPos(value) {
return this.state._v2n[value] ? this.state._v2n[value].pos : null;
}
getData(value) {
return value.map(v => this.state._v2n[v]);
}
processValue(value, v, checked) {
const index = value.indexOf(v);
if (checked && index === -1) {
value.push(v);
} else if (!checked && index > -1) {
value.splice(index, 1);
}
}
handleSelect(v, canExpand) {
if (!(this.props.canOnlySelectLeaf && canExpand)) {
const data = this.state._v2n[v];
const nums = data.pos.split('-');
const selectedPath = nums.slice(1).reduce((ret, num, index) => {
const p = nums.slice(0, index + 2).join('-');
ret.push(this.state._p2n[p]);
return ret;
}, []);
if (this.state.value[0] !== v) {
if (!('value' in this.props)) {
this.setState({
value: [v],
});
}
if ('onChange' in this.props) {
this.props.onChange(v, data, {
selectedPath,
});
}
}
if ('onSelect' in this.props) {
this.props.onSelect(v, data, {
selectedPath,
});
}
}
if (canExpand) {
if (!this.props.canOnlySelectLeaf) {
this.lastExpandedValue = this.state.expandedValue.slice(0, -1);
}
} else {
this.lastExpandedValue = [...this.state.expandedValue];
}
}
/*eslint-disable max-statements*/
handleCheck(v, checked) {
const { checkStrictly, canOnlyCheckLeaf } = this.props;
const value = [...this.state.value];
if (checkStrictly || canOnlyCheckLeaf) {
this.processValue(value, v, checked);
} else {
const pos = this.getPos(v);
const ps = Object.keys(this.state._p2n);
forEachEnableNode(this.state._v2n[v], node => {
if (node.checkable === false) return;
this.processValue(value, node.value, checked);
});
let currentPos = pos;
const nums = pos.split('-');
for (let i = nums.length; i > 2; i--) {
let parentCheck = true;
const parentPos = nums.slice(0, i - 1).join('-');
if (
this.state._p2n[parentPos].disabled ||
this.state._p2n[parentPos].checkboxDisabled ||
this.state._p2n[parentPos].checkable === false
) {
currentPos = parentPos;
continue;
}
const parentValue = this.state._p2n[parentPos].value;
const parentChecked = value.indexOf(parentValue) > -1;
if (!checked && !parentChecked) {
break;
}
for (let j = 0; j < ps.length; j++) {
const p = ps[j];
const pnode = this.state._p2n[p];
if (isSiblingOrSelf(currentPos, p) && !pnode.disabled && !pnode.checkboxDisabled) {
const k = pnode.value;
// eslint-disable-next-line max-depth
if (pnode.checkable === false) {
// eslint-disable-next-line max-depth
if (!pnode.children || pnode.children.length === 0) {
continue;
}
// eslint-disable-next-line max-depth
for (let m = 0; m < pnode.children.length; m++) {
// eslint-disable-next-line max-depth
if (!pnode.children.every(child => isNodeChecked(child, value))) {
parentCheck = false;
break;
}
}
} else if (value.indexOf(k) === -1) {
parentCheck = false;
}
if (!parentCheck) break;
}
}
this.processValue(value, parentValue, parentCheck);
currentPos = parentPos;
}
}
if (!('value' in this.props)) {
this.setState({
value,
});
}
if ('onChange' in this.props) {
if (checkStrictly || canOnlyCheckLeaf) {
const data = this.getData(value);
this.props.onChange(value, data, {
checked,
currentData: this.state._v2n[v],
checkedData: data,
});
} else {
const flatValue = this.flatValue(value);
const flatData = this.getData(flatValue);
const checkedData = this.getData(value);
const indeterminateValue = this.getIndeterminate(value);
const indeterminateData = this.getData(indeterminateValue);
this.props.onChange(flatValue, flatData, {
checked,
currentData: this.state._v2n[v],
checkedData,
indeterminateData,
});
}
}
this.lastExpandedValue = [...this.state.expandedValue];
}
handleExpand(value, level, canExpand, focusedFirstChild) {
const { expandedValue } = this.state;
if (canExpand || expandedValue.length > level) {
if (canExpand) {
expandedValue.splice(level, expandedValue.length - level, value);
} else {
expandedValue.splice(level);
}
const callback = () => {
this.setExpandValue(expandedValue);
if (focusedFirstChild) {
const endExpandedValue = expandedValue[expandedValue.length - 1];
this.setState({
focusedValue: this.state._v2n[endExpandedValue].children[0].value,
});
}
};
const { loadData } = this.props;
if (canExpand && loadData) {
const data = this.state._v2n[value];
return loadData(data, data._source).then(callback);
} else {
return callback();
}
}
}
handleMouseLeave() {
this.setExpandValue([...this.lastExpandedValue]);
}
setExpandValue(expandedValue) {
if (!('expandedValue' in this.props)) {
this.setState({
expandedValue,
});
}
if ('onExpand' in this.props) {
this.props.onExpand(expandedValue);
}
}
getFirstFocusKeyByDataSource(dataSource) {
if (!dataSource || dataSource.length === 0) {
return '';
}
for (let i = 0; i < dataSource.length; i++) {
if (dataSource[i] && !dataSource[i].disabled) {
return dataSource[i].value;
}
}
return '';
}
getFirstFocusKeyByFilteredPaths(filteredPaths) {
if (!filteredPaths || filteredPaths.length === 0) {
return '';
}
for (let i = 0; i < filteredPaths.length; i++) {
const path = filteredPaths[i];
if (!path.some(item => item.disabled)) {
const lastItem = path[path.length - 1];
return lastItem.value;
}
}
return '';
}
getFirstFocusKey() {
const { dataSource, searchValue, filteredPaths } = this.props;
return !searchValue
? this.getFirstFocusKeyByDataSource(dataSource)
: this.getFirstFocusKeyByFilteredPaths(filteredPaths);
}
setFocusValue() {
this.setState({
focusedValue: this.getFirstFocusKey(),
});
}
handleFocus(focusedValue) {
this.setState({
focusedValue,
});
}
handleFold() {
const { expandedValue } = this.state;
if (expandedValue.length > 0) {
this.setExpandValue(expandedValue.slice(0, -1));
}
this.setState({
focusedValue: expandedValue[expandedValue.length - 1],
});
}
getIndeterminate(value) {
const indeterminateValues = [];
const poss = filterChildValue(
value
.filter(v => !!this.state._v2n[v])
.filter(
v =>
!this.state._v2n[v].disabled &&
!this.state._v2n[v].checkboxDisabled &&
this.state._v2n[v].checkable !== false
),
this.state._v2n,
this.state._p2n
).map(v => this.state._v2n[v].pos);
poss.forEach(pos => {
const nums = pos.split('-');
for (let i = nums.length; i > 2; i--) {
const parentPos = nums.slice(0, i - 1).join('-');
const parent = this.state._p2n[parentPos];
if (parent.disabled || parent.checkboxDisabled) break;
const parentValue = parent.value;
if (indeterminateValues.indexOf(parentValue) === -1) {
indeterminateValues.push(parentValue);
}
}
});
return indeterminateValues;
}
onBlur(e) {
this.setState({
focusedValue: undefined,
});
this.props.onBlur && this.props.onBlur(e);
}
renderMenu(data, level) {
const {
prefix,
multiple,
useVirtual,
checkStrictly,
expandTriggerType,
loadData,
canOnlyCheckLeaf,
listClassName,
listStyle,
itemRender,
} = this.props;
const { value, expandedValue, focusedValue } = this.state;
return (
<CascaderMenu
key={level}
prefix={prefix}
useVirtual={useVirtual}
className={listClassName}
style={listStyle}
ref={this.saveMenuRef}
focusedKey={focusedValue}
onItemFocus={this.handleFocus}
onBlur={this.onBlur}
>
{data.map(item => {
const disabled = !!item.disabled;
const canExpand = (!!item.children && !!item.children.length) || (!!loadData && !item.isLeaf);
const expanded = expandedValue[level] === item.value;
const props = {
prefix,
disabled,
canExpand,
expanded,
expandTriggerType,
onExpand: this.handleExpand.bind(this, item.value, level, canExpand),
onFold: this.handleFold,
};
if ('title' in item) {
props.title = item.title;
}
if (multiple) {
props.checkable = !(canOnlyCheckLeaf && canExpand);
props.checked = value.indexOf(item.value) > -1 || !!item.checked;
props.indeterminate =
(checkStrictly || canOnlyCheckLeaf ? false : this.indeterminate.indexOf(item.value) > -1) ||
!!item.indeterminate;
props.checkboxDisabled = !!item.checkboxDisabled;
props.onCheck = this.handleCheck.bind(this, item.value);
} else {
props.selected = value[0] === item.value;
props.onSelect = this.handleSelect.bind(this, item.value, canExpand);
}
return (
<CascaderMenuItem key={item.value} {...props}>
{itemRender(item)}
</CascaderMenuItem>
);
})}
</CascaderMenu>
);
}
renderMenus() {
const { dataSource } = this.props;
const { expandedValue } = this.state;
const menus = [];
let data = dataSource;
for (let i = 0; i <= expandedValue.length; i++) {
if (!data) {
break;
}
menus.push(this.renderMenu(data, i));
let expandedItem;
for (let j = 0; j < data.length; j++) {
if (data[j].value === expandedValue[i]) {
expandedItem = data[j];
break;
}
}
data = expandedItem ? expandedItem.children : null;
}
return menus;
}
renderFilteredItem(path) {
const { prefix, resultRender, searchValue, multiple } = this.props;
const { value } = this.state;
const lastItem = path[path.length - 1];
let Item;
const props = {
key: lastItem.value,
className: `${prefix}cascader-filtered-item`,
disabled: path.some(item => item.disabled),
children: resultRender(searchValue, path),
};
if (multiple) {
Item = Menu.CheckboxItem;
const { checkStrictly, canOnlyCheckLeaf } = this.props;
props.checked = value.indexOf(lastItem.value) > -1;
props.indeterminate =
!checkStrictly && !canOnlyCheckLeaf && this.indeterminate.indexOf(lastItem.value) > -1;
props.checkboxDisabled = lastItem.checkboxDisabled;
props.onChange = this.handleCheck.bind(this, lastItem.value);
} else {
Item = Menu.Item;
props.selected = value[0] === lastItem.value;
props.onSelect = this.handleSelect.bind(this, lastItem.value, false);
}
return <Item {...props} />;
}
renderFilteredList() {
const { prefix, filteredListStyle, filteredPaths } = this.props;
const { focusedValue } = this.state;
return (
<Menu
// 如果不设置为false, CascaderSelect 开启 showSearch后,弹窗展开时,光标无法到input上去,也无法输入
focusable={false}
focusedKey={focusedValue}
onItemFocus={this.handleFocus}
className={`${prefix}cascader-filtered-list`}
style={filteredListStyle}
>
{filteredPaths.map(path => this.renderFilteredItem(path))}
</Menu>
);
}
render() {
const {
prefix,
rtl,
className,
expandTriggerType,
multiple,
dataSource,
checkStrictly,
canOnlyCheckLeaf,
searchValue,
} = this.props;
const others = pickOthers(Object.keys(Cascader.propTypes), this.props);
const { value } = this.state;
if (rtl) {
others.dir = 'rtl';
}
const props = {
className: cx({
[`${prefix}cascader`]: true,
multiple,
[className]: !!className,
}),
ref: 'cascader',
...others,
};
if (expandTriggerType === 'hover') {
props.onMouseLeave = this.handleMouseLeave;
}
if (multiple && !checkStrictly && !canOnlyCheckLeaf) {
this.indeterminate = this.getIndeterminate(value);
}
return (
<div {...props} ref={this.getCascaderNode}>
{!searchValue ? (
<div className={`${prefix}cascader-inner`}>
{dataSource && dataSource.length ? this.renderMenus() : null}
</div>
) : (
this.renderFilteredList()
)}
</div>
);
}
}
export default polyfill(Cascader);