rsuite 4.10.7 → 4.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/dist/rsuite.js +3 -3
- package/dist/rsuite.min.js +3 -3
- package/dist/rsuite.min.js.map +1 -1
- package/es/CheckTreePicker/CheckTreePicker.js +23 -26
- package/es/SelectPicker/SelectPicker.d.ts +1 -1
- package/es/SelectPicker/SelectPicker.js +36 -35
- package/lib/CheckTreePicker/CheckTreePicker.js +23 -26
- package/lib/SelectPicker/SelectPicker.d.ts +1 -1
- package/lib/SelectPicker/SelectPicker.js +36 -35
- package/package.json +2 -2
- package/src/CheckTreePicker/CheckTreePicker.tsx +2 -3
- package/src/CheckTreePicker/test/CheckTreePickerSpec.js +42 -1
- package/src/SelectPicker/SelectPicker.d.ts +1 -1
- package/src/SelectPicker/SelectPicker.tsx +1 -1
- package/src/SelectPicker/test/SelectPickerSpec.js +67 -1
|
@@ -510,9 +510,7 @@ function (_React$Component) {
|
|
|
510
510
|
};
|
|
511
511
|
|
|
512
512
|
_proto.updateDataChange = function updateDataChange(prevState) {
|
|
513
|
-
var
|
|
514
|
-
searchKeyword = _this$state2.searchKeyword,
|
|
515
|
-
expandItemValues = _this$state2.expandItemValues;
|
|
513
|
+
var searchKeyword = this.state.searchKeyword;
|
|
516
514
|
var _this$props7 = this.props,
|
|
517
515
|
_this$props7$data = _this$props7.data,
|
|
518
516
|
data = _this$props7$data === void 0 ? [] : _this$props7$data,
|
|
@@ -523,8 +521,7 @@ function (_React$Component) {
|
|
|
523
521
|
this.nodes = {};
|
|
524
522
|
this.flattenNodes(nextData);
|
|
525
523
|
this.unserializeLists({
|
|
526
|
-
check: this.getValue()
|
|
527
|
-
expand: expandItemValues
|
|
524
|
+
check: this.getValue()
|
|
528
525
|
});
|
|
529
526
|
this.setState({
|
|
530
527
|
data: nextData,
|
|
@@ -567,10 +564,10 @@ function (_React$Component) {
|
|
|
567
564
|
};
|
|
568
565
|
|
|
569
566
|
_proto.updateUncheckableItemValuesChange = function updateUncheckableItemValuesChange(prevState) {
|
|
570
|
-
var _this$
|
|
571
|
-
data = _this$
|
|
572
|
-
selectedValues = _this$
|
|
573
|
-
expandItemValues = _this$
|
|
567
|
+
var _this$state2 = this.state,
|
|
568
|
+
data = _this$state2.data,
|
|
569
|
+
selectedValues = _this$state2.selectedValues,
|
|
570
|
+
expandItemValues = _this$state2.expandItemValues;
|
|
574
571
|
var uncheckableItemValues = this.props.uncheckableItemValues;
|
|
575
572
|
|
|
576
573
|
if (compareArray(uncheckableItemValues, prevState.uncheckableItemValues) && _isArray(uncheckableItemValues)) {
|
|
@@ -586,10 +583,10 @@ function (_React$Component) {
|
|
|
586
583
|
};
|
|
587
584
|
|
|
588
585
|
_proto.updateCascadeChange = function updateCascadeChange(prevState) {
|
|
589
|
-
var _this$
|
|
590
|
-
data = _this$
|
|
591
|
-
selectedValues = _this$
|
|
592
|
-
expandItemValues = _this$
|
|
586
|
+
var _this$state3 = this.state,
|
|
587
|
+
data = _this$state3.data,
|
|
588
|
+
selectedValues = _this$state3.selectedValues,
|
|
589
|
+
expandItemValues = _this$state3.expandItemValues;
|
|
593
590
|
var cascade = this.props.cascade; // cascade 改变时,重新初始化
|
|
594
591
|
|
|
595
592
|
if (cascade !== prevState.cascade && cascade) {
|
|
@@ -1062,9 +1059,9 @@ function (_React$Component) {
|
|
|
1062
1059
|
_proto.renderNode = function renderNode(node, layer) {
|
|
1063
1060
|
var _this10 = this;
|
|
1064
1061
|
|
|
1065
|
-
var _this$
|
|
1066
|
-
activeNode = _this$
|
|
1067
|
-
searchKeyword = _this$
|
|
1062
|
+
var _this$state4 = this.state,
|
|
1063
|
+
activeNode = _this$state4.activeNode,
|
|
1064
|
+
searchKeyword = _this$state4.searchKeyword;
|
|
1068
1065
|
var _this$props11 = this.props,
|
|
1069
1066
|
valueKey = _this$props11.valueKey,
|
|
1070
1067
|
labelKey = _this$props11.labelKey,
|
|
@@ -1132,10 +1129,10 @@ function (_React$Component) {
|
|
|
1132
1129
|
};
|
|
1133
1130
|
|
|
1134
1131
|
_proto.renderVirtualNode = function renderVirtualNode(node, options) {
|
|
1135
|
-
var _this$
|
|
1136
|
-
activeNode = _this$
|
|
1137
|
-
expandAll = _this$
|
|
1138
|
-
searchKeyword = _this$
|
|
1132
|
+
var _this$state5 = this.state,
|
|
1133
|
+
activeNode = _this$state5.activeNode,
|
|
1134
|
+
expandAll = _this$state5.expandAll,
|
|
1135
|
+
searchKeyword = _this$state5.searchKeyword;
|
|
1139
1136
|
var _this$props12 = this.props,
|
|
1140
1137
|
valueKey = _this$props12.valueKey,
|
|
1141
1138
|
labelKey = _this$props12.labelKey,
|
|
@@ -1185,9 +1182,9 @@ function (_React$Component) {
|
|
|
1185
1182
|
_this11 = this,
|
|
1186
1183
|
_classNames3;
|
|
1187
1184
|
|
|
1188
|
-
var _this$
|
|
1189
|
-
filterData = _this$
|
|
1190
|
-
isSomeNodeHasChildren = _this$
|
|
1185
|
+
var _this$state6 = this.state,
|
|
1186
|
+
filterData = _this$state6.filterData,
|
|
1187
|
+
isSomeNodeHasChildren = _this$state6.isSomeNodeHasChildren;
|
|
1191
1188
|
var _this$props13 = this.props,
|
|
1192
1189
|
inline = _this$props13.inline,
|
|
1193
1190
|
style = _this$props13.style,
|
|
@@ -1279,9 +1276,9 @@ function (_React$Component) {
|
|
|
1279
1276
|
positionRef = _this$props14.positionRef,
|
|
1280
1277
|
rest = _objectWithoutPropertiesLoose(_this$props14, ["cascade", "style", "locale", "inline", "disabled", "valueKey", "labelKey", "cleanable", "countable", "placeholder", "toggleComponentClass", "onExited", "onEntered", "onClean", "renderValue", "positionRef"]);
|
|
1281
1278
|
|
|
1282
|
-
var _this$
|
|
1283
|
-
hasValue = _this$
|
|
1284
|
-
selectedValues = _this$
|
|
1279
|
+
var _this$state7 = this.state,
|
|
1280
|
+
hasValue = _this$state7.hasValue,
|
|
1281
|
+
selectedValues = _this$state7.selectedValues;
|
|
1285
1282
|
|
|
1286
1283
|
var hasValidValue = hasValue || selectedValues.length > 0 && _isFunction(renderValue);
|
|
1287
1284
|
|
|
@@ -36,7 +36,7 @@ export interface SelectProps<ValueType = any> {
|
|
|
36
36
|
onGroupTitleClick?: (event: React.SyntheticEvent<any>) => void;
|
|
37
37
|
|
|
38
38
|
/** Called when searching */
|
|
39
|
-
onSearch?: (searchKeyword: string, event
|
|
39
|
+
onSearch?: (searchKeyword: string, event?: React.SyntheticEvent<any>) => void;
|
|
40
40
|
|
|
41
41
|
/** Called when clean */
|
|
42
42
|
onClean?: (event: React.SyntheticEvent<any>) => void;
|
|
@@ -239,18 +239,19 @@ function (_React$Component) {
|
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
_this.handleExit = function () {
|
|
242
|
-
var _this$props$onClose, _this$
|
|
242
|
+
var _this$props$onSearch, _this$props6, _this$props$onClose, _this$props7;
|
|
243
243
|
|
|
244
244
|
_this.setState({
|
|
245
245
|
searchKeyword: '',
|
|
246
246
|
active: false
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
(_this$props$
|
|
249
|
+
(_this$props$onSearch = (_this$props6 = _this.props).onSearch) === null || _this$props$onSearch === void 0 ? void 0 : _this$props$onSearch.call(_this$props6, '');
|
|
250
|
+
(_this$props$onClose = (_this$props7 = _this.props).onClose) === null || _this$props$onClose === void 0 ? void 0 : _this$props$onClose.call(_this$props7);
|
|
250
251
|
};
|
|
251
252
|
|
|
252
253
|
_this.handleOpen = function () {
|
|
253
|
-
var _this$props$onOpen, _this$
|
|
254
|
+
var _this$props$onOpen, _this$props8;
|
|
254
255
|
|
|
255
256
|
var value = _this.getValue();
|
|
256
257
|
|
|
@@ -259,7 +260,7 @@ function (_React$Component) {
|
|
|
259
260
|
focusItemValue: value
|
|
260
261
|
});
|
|
261
262
|
|
|
262
|
-
(_this$props$onOpen = (_this$
|
|
263
|
+
(_this$props$onOpen = (_this$props8 = _this.props).onOpen) === null || _this$props$onOpen === void 0 ? void 0 : _this$props$onOpen.call(_this$props8);
|
|
263
264
|
};
|
|
264
265
|
|
|
265
266
|
_this.addPrefix = function (name) {
|
|
@@ -303,9 +304,9 @@ function (_React$Component) {
|
|
|
303
304
|
* @param {node} label
|
|
304
305
|
*/
|
|
305
306
|
_proto.shouldDisplay = function shouldDisplay(item, word) {
|
|
306
|
-
var _this$
|
|
307
|
-
searchBy = _this$
|
|
308
|
-
labelKey = _this$
|
|
307
|
+
var _this$props9 = this.props,
|
|
308
|
+
searchBy = _this$props9.searchBy,
|
|
309
|
+
labelKey = _this$props9.labelKey;
|
|
309
310
|
var label = item === null || item === void 0 ? void 0 : item[labelKey];
|
|
310
311
|
var searchKeyword = typeof word === 'undefined' ? this.state.searchKeyword : word;
|
|
311
312
|
|
|
@@ -334,18 +335,18 @@ function (_React$Component) {
|
|
|
334
335
|
_proto.renderDropdownMenu = function renderDropdownMenu() {
|
|
335
336
|
var _this4 = this;
|
|
336
337
|
|
|
337
|
-
var _this$
|
|
338
|
-
data = _this$
|
|
339
|
-
groupBy = _this$
|
|
340
|
-
searchable = _this$
|
|
341
|
-
locale = _this$
|
|
342
|
-
renderMenu = _this$
|
|
343
|
-
renderExtraFooter = _this$
|
|
344
|
-
menuClassName = _this$
|
|
345
|
-
menuStyle = _this$
|
|
346
|
-
menuAutoWidth = _this$
|
|
347
|
-
sort = _this$
|
|
348
|
-
virtualized = _this$
|
|
338
|
+
var _this$props10 = this.props,
|
|
339
|
+
data = _this$props10.data,
|
|
340
|
+
groupBy = _this$props10.groupBy,
|
|
341
|
+
searchable = _this$props10.searchable,
|
|
342
|
+
locale = _this$props10.locale,
|
|
343
|
+
renderMenu = _this$props10.renderMenu,
|
|
344
|
+
renderExtraFooter = _this$props10.renderExtraFooter,
|
|
345
|
+
menuClassName = _this$props10.menuClassName,
|
|
346
|
+
menuStyle = _this$props10.menuStyle,
|
|
347
|
+
menuAutoWidth = _this$props10.menuAutoWidth,
|
|
348
|
+
sort = _this$props10.sort,
|
|
349
|
+
virtualized = _this$props10.virtualized;
|
|
349
350
|
var focusItemValue = this.state.focusItemValue;
|
|
350
351
|
var classes = classNames(this.addPrefix('select-menu'), menuClassName);
|
|
351
352
|
var filteredData = filterNodesOfTree(data, function (item) {
|
|
@@ -390,22 +391,22 @@ function (_React$Component) {
|
|
|
390
391
|
};
|
|
391
392
|
|
|
392
393
|
_proto.render = function render() {
|
|
393
|
-
var _this$
|
|
394
|
-
data = _this$
|
|
395
|
-
valueKey = _this$
|
|
396
|
-
labelKey = _this$
|
|
397
|
-
placeholder = _this$
|
|
398
|
-
renderValue = _this$
|
|
399
|
-
disabled = _this$
|
|
400
|
-
cleanable = _this$
|
|
401
|
-
locale = _this$
|
|
402
|
-
toggleComponentClass = _this$
|
|
403
|
-
style = _this$
|
|
404
|
-
onEntered = _this$
|
|
405
|
-
onExited = _this$
|
|
406
|
-
onClean = _this$
|
|
407
|
-
positionRef = _this$
|
|
408
|
-
rest = _objectWithoutPropertiesLoose(_this$
|
|
394
|
+
var _this$props11 = this.props,
|
|
395
|
+
data = _this$props11.data,
|
|
396
|
+
valueKey = _this$props11.valueKey,
|
|
397
|
+
labelKey = _this$props11.labelKey,
|
|
398
|
+
placeholder = _this$props11.placeholder,
|
|
399
|
+
renderValue = _this$props11.renderValue,
|
|
400
|
+
disabled = _this$props11.disabled,
|
|
401
|
+
cleanable = _this$props11.cleanable,
|
|
402
|
+
locale = _this$props11.locale,
|
|
403
|
+
toggleComponentClass = _this$props11.toggleComponentClass,
|
|
404
|
+
style = _this$props11.style,
|
|
405
|
+
onEntered = _this$props11.onEntered,
|
|
406
|
+
onExited = _this$props11.onExited,
|
|
407
|
+
onClean = _this$props11.onClean,
|
|
408
|
+
positionRef = _this$props11.positionRef,
|
|
409
|
+
rest = _objectWithoutPropertiesLoose(_this$props11, ["data", "valueKey", "labelKey", "placeholder", "renderValue", "disabled", "cleanable", "locale", "toggleComponentClass", "style", "onEntered", "onExited", "onClean", "positionRef"]);
|
|
409
410
|
|
|
410
411
|
var unhandled = getUnhandledProps(SelectPicker, rest);
|
|
411
412
|
var value = this.getValue(); // Find active `MenuItem` by `value`
|
|
@@ -544,9 +544,7 @@ function (_React$Component) {
|
|
|
544
544
|
};
|
|
545
545
|
|
|
546
546
|
_proto.updateDataChange = function updateDataChange(prevState) {
|
|
547
|
-
var
|
|
548
|
-
searchKeyword = _this$state2.searchKeyword,
|
|
549
|
-
expandItemValues = _this$state2.expandItemValues;
|
|
547
|
+
var searchKeyword = this.state.searchKeyword;
|
|
550
548
|
var _this$props7 = this.props,
|
|
551
549
|
_this$props7$data = _this$props7.data,
|
|
552
550
|
data = _this$props7$data === void 0 ? [] : _this$props7$data,
|
|
@@ -557,8 +555,7 @@ function (_React$Component) {
|
|
|
557
555
|
this.nodes = {};
|
|
558
556
|
this.flattenNodes(nextData);
|
|
559
557
|
this.unserializeLists({
|
|
560
|
-
check: this.getValue()
|
|
561
|
-
expand: expandItemValues
|
|
558
|
+
check: this.getValue()
|
|
562
559
|
});
|
|
563
560
|
this.setState({
|
|
564
561
|
data: nextData,
|
|
@@ -601,10 +598,10 @@ function (_React$Component) {
|
|
|
601
598
|
};
|
|
602
599
|
|
|
603
600
|
_proto.updateUncheckableItemValuesChange = function updateUncheckableItemValuesChange(prevState) {
|
|
604
|
-
var _this$
|
|
605
|
-
data = _this$
|
|
606
|
-
selectedValues = _this$
|
|
607
|
-
expandItemValues = _this$
|
|
601
|
+
var _this$state2 = this.state,
|
|
602
|
+
data = _this$state2.data,
|
|
603
|
+
selectedValues = _this$state2.selectedValues,
|
|
604
|
+
expandItemValues = _this$state2.expandItemValues;
|
|
608
605
|
var uncheckableItemValues = this.props.uncheckableItemValues;
|
|
609
606
|
|
|
610
607
|
if ((0, _treeUtils.compareArray)(uncheckableItemValues, prevState.uncheckableItemValues) && (0, _isArray2.default)(uncheckableItemValues)) {
|
|
@@ -620,10 +617,10 @@ function (_React$Component) {
|
|
|
620
617
|
};
|
|
621
618
|
|
|
622
619
|
_proto.updateCascadeChange = function updateCascadeChange(prevState) {
|
|
623
|
-
var _this$
|
|
624
|
-
data = _this$
|
|
625
|
-
selectedValues = _this$
|
|
626
|
-
expandItemValues = _this$
|
|
620
|
+
var _this$state3 = this.state,
|
|
621
|
+
data = _this$state3.data,
|
|
622
|
+
selectedValues = _this$state3.selectedValues,
|
|
623
|
+
expandItemValues = _this$state3.expandItemValues;
|
|
627
624
|
var cascade = this.props.cascade; // cascade 改变时,重新初始化
|
|
628
625
|
|
|
629
626
|
if (cascade !== prevState.cascade && cascade) {
|
|
@@ -1096,9 +1093,9 @@ function (_React$Component) {
|
|
|
1096
1093
|
_proto.renderNode = function renderNode(node, layer) {
|
|
1097
1094
|
var _this10 = this;
|
|
1098
1095
|
|
|
1099
|
-
var _this$
|
|
1100
|
-
activeNode = _this$
|
|
1101
|
-
searchKeyword = _this$
|
|
1096
|
+
var _this$state4 = this.state,
|
|
1097
|
+
activeNode = _this$state4.activeNode,
|
|
1098
|
+
searchKeyword = _this$state4.searchKeyword;
|
|
1102
1099
|
var _this$props11 = this.props,
|
|
1103
1100
|
valueKey = _this$props11.valueKey,
|
|
1104
1101
|
labelKey = _this$props11.labelKey,
|
|
@@ -1166,10 +1163,10 @@ function (_React$Component) {
|
|
|
1166
1163
|
};
|
|
1167
1164
|
|
|
1168
1165
|
_proto.renderVirtualNode = function renderVirtualNode(node, options) {
|
|
1169
|
-
var _this$
|
|
1170
|
-
activeNode = _this$
|
|
1171
|
-
expandAll = _this$
|
|
1172
|
-
searchKeyword = _this$
|
|
1166
|
+
var _this$state5 = this.state,
|
|
1167
|
+
activeNode = _this$state5.activeNode,
|
|
1168
|
+
expandAll = _this$state5.expandAll,
|
|
1169
|
+
searchKeyword = _this$state5.searchKeyword;
|
|
1173
1170
|
var _this$props12 = this.props,
|
|
1174
1171
|
valueKey = _this$props12.valueKey,
|
|
1175
1172
|
labelKey = _this$props12.labelKey,
|
|
@@ -1219,9 +1216,9 @@ function (_React$Component) {
|
|
|
1219
1216
|
_this11 = this,
|
|
1220
1217
|
_classNames3;
|
|
1221
1218
|
|
|
1222
|
-
var _this$
|
|
1223
|
-
filterData = _this$
|
|
1224
|
-
isSomeNodeHasChildren = _this$
|
|
1219
|
+
var _this$state6 = this.state,
|
|
1220
|
+
filterData = _this$state6.filterData,
|
|
1221
|
+
isSomeNodeHasChildren = _this$state6.isSomeNodeHasChildren;
|
|
1225
1222
|
var _this$props13 = this.props,
|
|
1226
1223
|
inline = _this$props13.inline,
|
|
1227
1224
|
style = _this$props13.style,
|
|
@@ -1312,9 +1309,9 @@ function (_React$Component) {
|
|
|
1312
1309
|
renderValue = _this$props14.renderValue,
|
|
1313
1310
|
positionRef = _this$props14.positionRef,
|
|
1314
1311
|
rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props14, ["cascade", "style", "locale", "inline", "disabled", "valueKey", "labelKey", "cleanable", "countable", "placeholder", "toggleComponentClass", "onExited", "onEntered", "onClean", "renderValue", "positionRef"]);
|
|
1315
|
-
var _this$
|
|
1316
|
-
hasValue = _this$
|
|
1317
|
-
selectedValues = _this$
|
|
1312
|
+
var _this$state7 = this.state,
|
|
1313
|
+
hasValue = _this$state7.hasValue,
|
|
1314
|
+
selectedValues = _this$state7.selectedValues;
|
|
1318
1315
|
var hasValidValue = hasValue || selectedValues.length > 0 && (0, _isFunction2.default)(renderValue);
|
|
1319
1316
|
var selectedItems = this.getSelectedItems(selectedValues);
|
|
1320
1317
|
var selectedElement = placeholder;
|
|
@@ -36,7 +36,7 @@ export interface SelectProps<ValueType = any> {
|
|
|
36
36
|
onGroupTitleClick?: (event: React.SyntheticEvent<any>) => void;
|
|
37
37
|
|
|
38
38
|
/** Called when searching */
|
|
39
|
-
onSearch?: (searchKeyword: string, event
|
|
39
|
+
onSearch?: (searchKeyword: string, event?: React.SyntheticEvent<any>) => void;
|
|
40
40
|
|
|
41
41
|
/** Called when clean */
|
|
42
42
|
onClean?: (event: React.SyntheticEvent<any>) => void;
|
|
@@ -264,18 +264,19 @@ function (_React$Component) {
|
|
|
264
264
|
};
|
|
265
265
|
|
|
266
266
|
_this.handleExit = function () {
|
|
267
|
-
var _this$props$onClose, _this$
|
|
267
|
+
var _this$props$onSearch, _this$props6, _this$props$onClose, _this$props7;
|
|
268
268
|
|
|
269
269
|
_this.setState({
|
|
270
270
|
searchKeyword: '',
|
|
271
271
|
active: false
|
|
272
272
|
});
|
|
273
273
|
|
|
274
|
-
(_this$props$
|
|
274
|
+
(_this$props$onSearch = (_this$props6 = _this.props).onSearch) === null || _this$props$onSearch === void 0 ? void 0 : _this$props$onSearch.call(_this$props6, '');
|
|
275
|
+
(_this$props$onClose = (_this$props7 = _this.props).onClose) === null || _this$props$onClose === void 0 ? void 0 : _this$props$onClose.call(_this$props7);
|
|
275
276
|
};
|
|
276
277
|
|
|
277
278
|
_this.handleOpen = function () {
|
|
278
|
-
var _this$props$onOpen, _this$
|
|
279
|
+
var _this$props$onOpen, _this$props8;
|
|
279
280
|
|
|
280
281
|
var value = _this.getValue();
|
|
281
282
|
|
|
@@ -284,7 +285,7 @@ function (_React$Component) {
|
|
|
284
285
|
focusItemValue: value
|
|
285
286
|
});
|
|
286
287
|
|
|
287
|
-
(_this$props$onOpen = (_this$
|
|
288
|
+
(_this$props$onOpen = (_this$props8 = _this.props).onOpen) === null || _this$props$onOpen === void 0 ? void 0 : _this$props$onOpen.call(_this$props8);
|
|
288
289
|
};
|
|
289
290
|
|
|
290
291
|
_this.addPrefix = function (name) {
|
|
@@ -328,9 +329,9 @@ function (_React$Component) {
|
|
|
328
329
|
* @param {node} label
|
|
329
330
|
*/
|
|
330
331
|
_proto.shouldDisplay = function shouldDisplay(item, word) {
|
|
331
|
-
var _this$
|
|
332
|
-
searchBy = _this$
|
|
333
|
-
labelKey = _this$
|
|
332
|
+
var _this$props9 = this.props,
|
|
333
|
+
searchBy = _this$props9.searchBy,
|
|
334
|
+
labelKey = _this$props9.labelKey;
|
|
334
335
|
var label = item === null || item === void 0 ? void 0 : item[labelKey];
|
|
335
336
|
var searchKeyword = typeof word === 'undefined' ? this.state.searchKeyword : word;
|
|
336
337
|
|
|
@@ -359,18 +360,18 @@ function (_React$Component) {
|
|
|
359
360
|
_proto.renderDropdownMenu = function renderDropdownMenu() {
|
|
360
361
|
var _this4 = this;
|
|
361
362
|
|
|
362
|
-
var _this$
|
|
363
|
-
data = _this$
|
|
364
|
-
groupBy = _this$
|
|
365
|
-
searchable = _this$
|
|
366
|
-
locale = _this$
|
|
367
|
-
renderMenu = _this$
|
|
368
|
-
renderExtraFooter = _this$
|
|
369
|
-
menuClassName = _this$
|
|
370
|
-
menuStyle = _this$
|
|
371
|
-
menuAutoWidth = _this$
|
|
372
|
-
sort = _this$
|
|
373
|
-
virtualized = _this$
|
|
363
|
+
var _this$props10 = this.props,
|
|
364
|
+
data = _this$props10.data,
|
|
365
|
+
groupBy = _this$props10.groupBy,
|
|
366
|
+
searchable = _this$props10.searchable,
|
|
367
|
+
locale = _this$props10.locale,
|
|
368
|
+
renderMenu = _this$props10.renderMenu,
|
|
369
|
+
renderExtraFooter = _this$props10.renderExtraFooter,
|
|
370
|
+
menuClassName = _this$props10.menuClassName,
|
|
371
|
+
menuStyle = _this$props10.menuStyle,
|
|
372
|
+
menuAutoWidth = _this$props10.menuAutoWidth,
|
|
373
|
+
sort = _this$props10.sort,
|
|
374
|
+
virtualized = _this$props10.virtualized;
|
|
374
375
|
var focusItemValue = this.state.focusItemValue;
|
|
375
376
|
var classes = (0, _classnames.default)(this.addPrefix('select-menu'), menuClassName);
|
|
376
377
|
var filteredData = (0, _treeUtils.filterNodesOfTree)(data, function (item) {
|
|
@@ -414,22 +415,22 @@ function (_React$Component) {
|
|
|
414
415
|
};
|
|
415
416
|
|
|
416
417
|
_proto.render = function render() {
|
|
417
|
-
var _this$
|
|
418
|
-
data = _this$
|
|
419
|
-
valueKey = _this$
|
|
420
|
-
labelKey = _this$
|
|
421
|
-
placeholder = _this$
|
|
422
|
-
renderValue = _this$
|
|
423
|
-
disabled = _this$
|
|
424
|
-
cleanable = _this$
|
|
425
|
-
locale = _this$
|
|
426
|
-
toggleComponentClass = _this$
|
|
427
|
-
style = _this$
|
|
428
|
-
onEntered = _this$
|
|
429
|
-
onExited = _this$
|
|
430
|
-
onClean = _this$
|
|
431
|
-
positionRef = _this$
|
|
432
|
-
rest = (0, _objectWithoutPropertiesLoose2.default)(_this$
|
|
418
|
+
var _this$props11 = this.props,
|
|
419
|
+
data = _this$props11.data,
|
|
420
|
+
valueKey = _this$props11.valueKey,
|
|
421
|
+
labelKey = _this$props11.labelKey,
|
|
422
|
+
placeholder = _this$props11.placeholder,
|
|
423
|
+
renderValue = _this$props11.renderValue,
|
|
424
|
+
disabled = _this$props11.disabled,
|
|
425
|
+
cleanable = _this$props11.cleanable,
|
|
426
|
+
locale = _this$props11.locale,
|
|
427
|
+
toggleComponentClass = _this$props11.toggleComponentClass,
|
|
428
|
+
style = _this$props11.style,
|
|
429
|
+
onEntered = _this$props11.onEntered,
|
|
430
|
+
onExited = _this$props11.onExited,
|
|
431
|
+
onClean = _this$props11.onClean,
|
|
432
|
+
positionRef = _this$props11.positionRef,
|
|
433
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props11, ["data", "valueKey", "labelKey", "placeholder", "renderValue", "disabled", "cleanable", "locale", "toggleComponentClass", "style", "onEntered", "onExited", "onClean", "positionRef"]);
|
|
433
434
|
var unhandled = (0, _utils.getUnhandledProps)(SelectPicker, rest);
|
|
434
435
|
var value = this.getValue(); // Find active `MenuItem` by `value`
|
|
435
436
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.10",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"prop-types": "^15.7.2",
|
|
64
64
|
"react-lifecycles-compat": "^3.0.4",
|
|
65
65
|
"react-virtualized": "^9.21.0",
|
|
66
|
-
"rsuite-table": "^3.16.
|
|
66
|
+
"rsuite-table": "^3.16.1",
|
|
67
67
|
"schema-typed": "^1.5.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
@@ -234,7 +234,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
updateDataChange(prevState: CheckTreePickerState) {
|
|
237
|
-
const { searchKeyword
|
|
237
|
+
const { searchKeyword } = this.state;
|
|
238
238
|
const { data = [], childrenKey } = this.props;
|
|
239
239
|
|
|
240
240
|
if (prevState.data !== data) {
|
|
@@ -242,8 +242,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
242
242
|
this.nodes = {};
|
|
243
243
|
this.flattenNodes(nextData);
|
|
244
244
|
this.unserializeLists({
|
|
245
|
-
check: this.getValue()
|
|
246
|
-
expand: expandItemValues
|
|
245
|
+
check: this.getValue()
|
|
247
246
|
});
|
|
248
247
|
|
|
249
248
|
this.setState({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import ReactTestUtils from 'react-dom/test-utils';
|
|
3
3
|
import Enzyme, { mount } from 'enzyme';
|
|
4
4
|
import Adapter from 'enzyme-adapter-react-16';
|
|
@@ -567,4 +567,45 @@ describe('CheckTreePicker', () => {
|
|
|
567
567
|
4
|
|
568
568
|
);
|
|
569
569
|
});
|
|
570
|
+
it('Should expand when has props defaultExpandAll and data change', () => {
|
|
571
|
+
const Wrapper = React.forwardRef((props, ref) => {
|
|
572
|
+
const nextData = [
|
|
573
|
+
{
|
|
574
|
+
label: 'Fujian',
|
|
575
|
+
value: 3,
|
|
576
|
+
children: [
|
|
577
|
+
{
|
|
578
|
+
label: 'Fuzhou',
|
|
579
|
+
value: 36
|
|
580
|
+
}
|
|
581
|
+
]
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
label: 'Guangdong',
|
|
585
|
+
value: 4,
|
|
586
|
+
children: [
|
|
587
|
+
{
|
|
588
|
+
label: 'Guangzhou',
|
|
589
|
+
value: 45
|
|
590
|
+
}
|
|
591
|
+
]
|
|
592
|
+
}
|
|
593
|
+
];
|
|
594
|
+
const [willChangeData, setData] = useState(data);
|
|
595
|
+
const handleClick = () => {
|
|
596
|
+
setData(nextData);
|
|
597
|
+
};
|
|
598
|
+
return (
|
|
599
|
+
<div ref={ref}>
|
|
600
|
+
<button onClick={handleClick} className="change-data">
|
|
601
|
+
change data
|
|
602
|
+
</button>
|
|
603
|
+
<CheckTreePicker inline defaultExpandAll data={willChangeData} />
|
|
604
|
+
</div>
|
|
605
|
+
);
|
|
606
|
+
});
|
|
607
|
+
const instance = getDOMNode(<Wrapper />);
|
|
608
|
+
ReactTestUtils.Simulate.click(instance.querySelector('.change-data'));
|
|
609
|
+
expect(instance.querySelectorAll('.rs-check-tree-open').length).to.equal(2);
|
|
610
|
+
});
|
|
570
611
|
});
|
|
@@ -36,7 +36,7 @@ export interface SelectProps<ValueType = any> {
|
|
|
36
36
|
onGroupTitleClick?: (event: React.SyntheticEvent<any>) => void;
|
|
37
37
|
|
|
38
38
|
/** Called when searching */
|
|
39
|
-
onSearch?: (searchKeyword: string, event
|
|
39
|
+
onSearch?: (searchKeyword: string, event?: React.SyntheticEvent<any>) => void;
|
|
40
40
|
|
|
41
41
|
/** Called when clean */
|
|
42
42
|
onClean?: (event: React.SyntheticEvent<any>) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
2
3
|
import ReactTestUtils from 'react-dom/test-utils';
|
|
3
4
|
import { globalKey, getDOMNode, getInstance } from '@test/testUtils';
|
|
4
5
|
|
|
@@ -34,6 +35,18 @@ const data = [
|
|
|
34
35
|
}
|
|
35
36
|
];
|
|
36
37
|
|
|
38
|
+
let container;
|
|
39
|
+
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
container = document.createElement('div');
|
|
42
|
+
document.body.appendChild(container);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
document.body.removeChild(container);
|
|
47
|
+
container = null;
|
|
48
|
+
});
|
|
49
|
+
|
|
37
50
|
describe('SelectPicker', () => {
|
|
38
51
|
it('Should clean selected default value', () => {
|
|
39
52
|
const instance = getDOMNode(<Dropdown defaultOpen data={data} defaultValue={'Eugenia'} />);
|
|
@@ -324,4 +337,57 @@ describe('SelectPicker', () => {
|
|
|
324
337
|
assert.equal(list.length, 1);
|
|
325
338
|
assert.ok(list[0].innerText, 'Louisa');
|
|
326
339
|
});
|
|
340
|
+
|
|
341
|
+
it.only('SearchWord should be reset when controlled and triggered off', done => {
|
|
342
|
+
let searchRef = '';
|
|
343
|
+
let onClose = null;
|
|
344
|
+
const promise = new Promise(resolve => {
|
|
345
|
+
onClose = resolve;
|
|
346
|
+
});
|
|
347
|
+
const Wrapper = React.forwardRef((props, ref) => {
|
|
348
|
+
const [search, setSearch] = useState(searchRef);
|
|
349
|
+
searchRef = search;
|
|
350
|
+
const handleSearch = value => {
|
|
351
|
+
setSearch(value);
|
|
352
|
+
};
|
|
353
|
+
const handleClose = () => {
|
|
354
|
+
onClose();
|
|
355
|
+
};
|
|
356
|
+
return (
|
|
357
|
+
<div>
|
|
358
|
+
<button id="exit">exit</button>
|
|
359
|
+
<Dropdown
|
|
360
|
+
search={search}
|
|
361
|
+
ref={ref}
|
|
362
|
+
defaultOpen
|
|
363
|
+
onClose={handleClose}
|
|
364
|
+
onSearch={handleSearch}
|
|
365
|
+
data={data}
|
|
366
|
+
/>
|
|
367
|
+
</div>
|
|
368
|
+
);
|
|
369
|
+
});
|
|
370
|
+
Wrapper.displayName = 'WrapperSelectPicker';
|
|
371
|
+
ReactTestUtils.act(() => {
|
|
372
|
+
ReactDOM.render(<Wrapper />, container);
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
const exit = container?.querySelector('#exit');
|
|
376
|
+
const input = document.querySelector(searchInputClassName);
|
|
377
|
+
// change search
|
|
378
|
+
input.value = 'a';
|
|
379
|
+
ReactTestUtils.Simulate.change(input);
|
|
380
|
+
assert.equal(searchRef, 'a');
|
|
381
|
+
|
|
382
|
+
ReactTestUtils.act(() => {
|
|
383
|
+
// close select
|
|
384
|
+
// ReactTestUtils can't trigger document click event
|
|
385
|
+
exit.dispatchEvent(new MouseEvent('click', { bubbles: true }));
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
promise.then(() => {
|
|
389
|
+
assert.equal(searchRef, '');
|
|
390
|
+
done();
|
|
391
|
+
});
|
|
392
|
+
});
|
|
327
393
|
});
|