rsuite 4.10.10 → 4.11.1
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 +22 -0
- package/dist/rsuite.js +3 -3
- package/dist/rsuite.min.js +3 -3
- package/dist/rsuite.min.js.map +1 -1
- package/es/CheckPicker/CheckPicker.d.ts +10 -3
- package/es/CheckTreePicker/CheckTreePicker.js +24 -23
- package/es/InputPicker/InputPicker.d.ts +2 -2
- package/es/SelectPicker/SelectPicker.d.ts +9 -8
- package/es/TagPicker/TagPicker.d.ts +10 -3
- package/es/TreePicker/TreePicker.js +20 -23
- package/es/utils/treeUtils.js +3 -18
- package/lib/CheckPicker/CheckPicker.d.ts +10 -3
- package/lib/CheckTreePicker/CheckTreePicker.js +23 -22
- package/lib/InputPicker/InputPicker.d.ts +2 -2
- package/lib/SelectPicker/SelectPicker.d.ts +9 -8
- package/lib/TagPicker/TagPicker.d.ts +10 -3
- package/lib/TreePicker/TreePicker.js +19 -22
- package/lib/utils/treeUtils.js +3 -20
- package/package.json +1 -1
- package/src/CheckPicker/CheckPicker.d.ts +10 -3
- package/src/CheckTreePicker/CheckTreePicker.tsx +17 -26
- package/src/CheckTreePicker/test/CheckTreePickerSpec.js +58 -38
- package/src/InputPicker/InputPicker.d.ts +2 -2
- package/src/SelectPicker/SelectPicker.d.ts +9 -8
- package/src/SelectPicker/test/SelectPickerSpec.js +9 -7
- package/src/TagPicker/TagPicker.d.ts +10 -3
- package/src/TreePicker/TreePicker.tsx +22 -18
- package/src/TreePicker/test/TreePickerSpec.js +5 -0
- package/src/utils/treeUtils.ts +2 -13
|
@@ -581,7 +581,7 @@ function (_React$Component) {
|
|
|
581
581
|
nextState.selectedValue = value;
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues)) {
|
|
584
|
+
if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues) && Array.isArray(expandItemValues)) {
|
|
585
585
|
nextState.expandItemValues = expandItemValues;
|
|
586
586
|
}
|
|
587
587
|
|
|
@@ -673,7 +673,7 @@ function (_React$Component) {
|
|
|
673
673
|
_proto.updateExpandItemValuesChange = function updateExpandItemValuesChange(prevState) {
|
|
674
674
|
var expandItemValues = this.props.expandItemValues;
|
|
675
675
|
|
|
676
|
-
if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues)) {
|
|
676
|
+
if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues) && Array.isArray(expandItemValues)) {
|
|
677
677
|
this.unserializeLists('expand', expandItemValues);
|
|
678
678
|
this.setState({
|
|
679
679
|
expandItemValues: expandItemValues
|
|
@@ -1034,26 +1034,20 @@ function (_React$Component) {
|
|
|
1034
1034
|
|
|
1035
1035
|
_proto.renderDropdownMenu = function renderDropdownMenu() {
|
|
1036
1036
|
var _this$props16 = this.props,
|
|
1037
|
-
_this$props16$height = _this$props16.height,
|
|
1038
|
-
height = _this$props16$height === void 0 ? defaultHeight : _this$props16$height,
|
|
1039
1037
|
searchable = _this$props16.searchable,
|
|
1040
1038
|
searchKeyword = _this$props16.searchKeyword,
|
|
1041
1039
|
renderExtraFooter = _this$props16.renderExtraFooter,
|
|
1042
1040
|
locale = _this$props16.locale,
|
|
1043
1041
|
renderMenu = _this$props16.renderMenu,
|
|
1044
1042
|
menuStyle = _this$props16.menuStyle,
|
|
1045
|
-
virtualized = _this$props16.virtualized,
|
|
1046
1043
|
menuClassName = _this$props16.menuClassName,
|
|
1047
1044
|
menuAutoWidth = _this$props16.menuAutoWidth;
|
|
1048
1045
|
var keyword = !(0, _isUndefined2.default)(searchKeyword) ? searchKeyword : this.state.searchKeyword;
|
|
1049
1046
|
var classes = (0, _classnames.default)(menuClassName, this.addPrefix('tree-menu'));
|
|
1050
|
-
var styles = virtualized ? (0, _extends3.default)({
|
|
1051
|
-
height: height
|
|
1052
|
-
}, menuStyle) : menuStyle;
|
|
1053
1047
|
return React.createElement(_Picker.MenuWrapper, {
|
|
1054
1048
|
autoWidth: menuAutoWidth,
|
|
1055
1049
|
className: classes,
|
|
1056
|
-
style:
|
|
1050
|
+
style: menuStyle,
|
|
1057
1051
|
ref: this.menuRef,
|
|
1058
1052
|
getToggleInstance: this.getToggleInstance,
|
|
1059
1053
|
getPositionInstance: this.getPositionInstance
|
|
@@ -1152,8 +1146,7 @@ function (_React$Component) {
|
|
|
1152
1146
|
inline = _this$props18.inline,
|
|
1153
1147
|
style = _this$props18.style,
|
|
1154
1148
|
locale = _this$props18.locale,
|
|
1155
|
-
virtualized = _this$props18.virtualized
|
|
1156
|
-
searchable = _this$props18.searchable;
|
|
1149
|
+
virtualized = _this$props18.virtualized;
|
|
1157
1150
|
var layer = 0;
|
|
1158
1151
|
var classes = (0, _classnames.default)((0, _utils.defaultClassPrefix)('tree'), (_classNames2 = {}, _classNames2[className] = inline, _classNames2));
|
|
1159
1152
|
var nodes = [];
|
|
@@ -1180,33 +1173,36 @@ function (_React$Component) {
|
|
|
1180
1173
|
className: this.addPrefix('none')
|
|
1181
1174
|
}, locale.noResultsText);
|
|
1182
1175
|
}
|
|
1183
|
-
} //
|
|
1176
|
+
} // The height of virtualized tree should be subtract the value of paddingBottom
|
|
1184
1177
|
|
|
1185
1178
|
|
|
1186
|
-
var treeHeight =
|
|
1179
|
+
var treeHeight = height - 12;
|
|
1187
1180
|
var treeWidth = (0, _isUndefined2.default)(style === null || style === void 0 ? void 0 : style.width) ? defaultWidth : style.width;
|
|
1188
|
-
var
|
|
1189
|
-
height:
|
|
1190
|
-
}, style) :
|
|
1191
|
-
var listHeight = (0, _treeUtils.getVirtualLisHeight)(inline, searchable, treeHeight);
|
|
1181
|
+
var listStyles = inline ? (0, _extends3.default)({
|
|
1182
|
+
height: height
|
|
1183
|
+
}, style) : style;
|
|
1192
1184
|
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
1193
1185
|
ref: this.treeViewRef,
|
|
1194
1186
|
className: classes,
|
|
1195
|
-
style:
|
|
1187
|
+
style: listStyles,
|
|
1196
1188
|
onKeyDown: this.handleKeyDown
|
|
1197
1189
|
}, React.createElement("div", {
|
|
1198
1190
|
className: this.addTreePrefix('nodes')
|
|
1199
1191
|
}, virtualized ? React.createElement(_AutoSizer.default, {
|
|
1200
|
-
defaultHeight:
|
|
1201
|
-
defaultWidth: treeWidth
|
|
1192
|
+
defaultHeight: treeHeight,
|
|
1193
|
+
defaultWidth: treeWidth,
|
|
1194
|
+
style: {
|
|
1195
|
+
width: 'auto',
|
|
1196
|
+
height: 'auto'
|
|
1197
|
+
}
|
|
1202
1198
|
}, function (_ref4) {
|
|
1203
1199
|
var height = _ref4.height,
|
|
1204
1200
|
width = _ref4.width;
|
|
1205
1201
|
return React.createElement(_List.default, {
|
|
1206
1202
|
ref: _this9.listRef,
|
|
1207
1203
|
width: width || treeWidth,
|
|
1208
|
-
height: height
|
|
1209
|
-
rowHeight:
|
|
1204
|
+
height: height,
|
|
1205
|
+
rowHeight: 36,
|
|
1210
1206
|
rowCount: nodes.length,
|
|
1211
1207
|
rowRenderer: _this9.measureRowRenderer(nodes)
|
|
1212
1208
|
});
|
|
@@ -1333,6 +1329,7 @@ TreePicker.propTypes = (0, _extends3.default)({}, _propTypes2.listPickerPropType
|
|
|
1333
1329
|
searchBy: _propTypes.default.func
|
|
1334
1330
|
});
|
|
1335
1331
|
TreePicker.defaultProps = (0, _extends3.default)({}, _propTypes2.listPickerDefaultProps, {
|
|
1332
|
+
height: defaultHeight,
|
|
1336
1333
|
searchable: true,
|
|
1337
1334
|
menuAutoWidth: true,
|
|
1338
1335
|
locale: {
|
package/lib/utils/treeUtils.js
CHANGED
|
@@ -6,7 +6,6 @@ exports.__esModule = true;
|
|
|
6
6
|
exports.shouldShowNodeByExpanded = shouldShowNodeByExpanded;
|
|
7
7
|
exports.flattenTree = flattenTree;
|
|
8
8
|
exports.getNodeParents = getNodeParents;
|
|
9
|
-
exports.getVirtualLisHeight = getVirtualLisHeight;
|
|
10
9
|
exports.hasVisibleChildren = hasVisibleChildren;
|
|
11
10
|
exports.treeDeprecatedWarning = treeDeprecatedWarning;
|
|
12
11
|
exports.compareArray = compareArray;
|
|
@@ -41,12 +40,11 @@ var _shallowEqualArray = _interopRequireDefault(require("../utils/shallowEqualAr
|
|
|
41
40
|
|
|
42
41
|
var _constants = require("../constants");
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
var MENU_PADDING = 12; // Tree Node 之间的 间隔
|
|
46
|
-
|
|
43
|
+
// Tree Node 之间的 间隔
|
|
47
44
|
var TREE_NODE_GAP = 4;
|
|
48
45
|
/**
|
|
49
|
-
*
|
|
46
|
+
* Whether current node is visible
|
|
47
|
+
* when all the parents of the current node is expanded, the current node should be visible
|
|
50
48
|
* @param {*} expandItemValues
|
|
51
49
|
* @param {*} parentKeys
|
|
52
50
|
*/
|
|
@@ -130,21 +128,6 @@ function getNodeParents(node, parentKey, valueKey) {
|
|
|
130
128
|
traverse(node);
|
|
131
129
|
return parents;
|
|
132
130
|
}
|
|
133
|
-
/**
|
|
134
|
-
* 获取 VirtualList 的高度
|
|
135
|
-
* @param {*} inline
|
|
136
|
-
* @param {*} height
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
function getVirtualLisHeight(inline, searchable, height) {
|
|
141
|
-
if (height === void 0) {
|
|
142
|
-
height = 0;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
var searchBarHeight = searchable ? SEARCH_BAR_HEIGHT : 0;
|
|
146
|
-
return inline ? height - MENU_PADDING * 2 : height - searchBarHeight - MENU_PADDING * 2;
|
|
147
|
-
}
|
|
148
131
|
/**
|
|
149
132
|
* 判断节点是否存在可见的子节点。
|
|
150
133
|
* @param node
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
|
|
6
|
-
export interface CheckPickerProps extends FormControlPickerProps<any[]>,
|
|
6
|
+
export interface CheckPickerProps extends FormControlPickerProps<any[]>, BaseSelectProps {
|
|
7
7
|
/** Top the selected option in the options */
|
|
8
8
|
sticky?: boolean;
|
|
9
9
|
|
|
10
10
|
/** A picker that can be counted */
|
|
11
11
|
countable?: boolean;
|
|
12
|
+
|
|
13
|
+
/** Custom render selected items */
|
|
14
|
+
renderValue?: (
|
|
15
|
+
value: any[],
|
|
16
|
+
item: ItemDataType[],
|
|
17
|
+
selectedElement: React.ReactNode
|
|
18
|
+
) => React.ReactNode;
|
|
12
19
|
}
|
|
13
20
|
|
|
14
21
|
declare const CheckPicker: React.ComponentType<CheckPickerProps>;
|
|
@@ -50,7 +50,6 @@ import {
|
|
|
50
50
|
shouldShowNodeByExpanded,
|
|
51
51
|
flattenTree,
|
|
52
52
|
getNodeParents,
|
|
53
|
-
getVirtualLisHeight,
|
|
54
53
|
hasVisibleChildren,
|
|
55
54
|
treeDeprecatedWarning,
|
|
56
55
|
getExpandItemValues,
|
|
@@ -111,6 +110,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
111
110
|
};
|
|
112
111
|
static defaultProps = {
|
|
113
112
|
...listPickerDefaultProps,
|
|
113
|
+
height: defaultHeight,
|
|
114
114
|
cascade: true,
|
|
115
115
|
countable: true,
|
|
116
116
|
searchable: true,
|
|
@@ -144,7 +144,8 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
144
144
|
check: nextValue,
|
|
145
145
|
expand: nextExpandItemValues
|
|
146
146
|
},
|
|
147
|
-
props
|
|
147
|
+
props,
|
|
148
|
+
true
|
|
148
149
|
);
|
|
149
150
|
|
|
150
151
|
this.state = {
|
|
@@ -582,7 +583,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
582
583
|
return list;
|
|
583
584
|
}
|
|
584
585
|
|
|
585
|
-
unserializeLists(lists: any, nextProps: CheckTreePickerProps = this.props) {
|
|
586
|
+
unserializeLists(lists: any, nextProps: CheckTreePickerProps = this.props, initial = false) {
|
|
586
587
|
const { valueKey, cascade, uncheckableItemValues = [] } = nextProps;
|
|
587
588
|
const expandAll = getExpandAll(nextProps);
|
|
588
589
|
// Reset values to false
|
|
@@ -613,7 +614,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
613
614
|
}
|
|
614
615
|
});
|
|
615
616
|
} else {
|
|
616
|
-
this.nodes[refKey][listKey] = expandAll;
|
|
617
|
+
this.nodes[refKey][listKey] = initial ? expandAll : false;
|
|
617
618
|
}
|
|
618
619
|
}
|
|
619
620
|
});
|
|
@@ -903,12 +904,10 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
903
904
|
|
|
904
905
|
renderDropdownMenu() {
|
|
905
906
|
const {
|
|
906
|
-
height = defaultHeight,
|
|
907
907
|
locale,
|
|
908
908
|
menuStyle,
|
|
909
909
|
searchable,
|
|
910
910
|
renderMenu,
|
|
911
|
-
virtualized,
|
|
912
911
|
searchKeyword,
|
|
913
912
|
renderExtraFooter,
|
|
914
913
|
menuClassName,
|
|
@@ -918,13 +917,12 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
918
917
|
const keyword = !_.isUndefined(searchKeyword) ? searchKeyword : this.state.searchKeyword;
|
|
919
918
|
const classes = classNames(menuClassName, this.addPrefix('check-tree-menu'));
|
|
920
919
|
const menu = this.renderCheckTree();
|
|
921
|
-
const styles = virtualized ? { height, ...menuStyle } : menuStyle;
|
|
922
920
|
|
|
923
921
|
return (
|
|
924
922
|
<MenuWrapper
|
|
925
923
|
autoWidth={menuAutoWidth}
|
|
926
924
|
className={classes}
|
|
927
|
-
style={
|
|
925
|
+
style={menuStyle}
|
|
928
926
|
ref={this.menuRef}
|
|
929
927
|
getToggleInstance={this.getToggleInstance}
|
|
930
928
|
getPositionInstance={this.getPositionInstance}
|
|
@@ -1077,16 +1075,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
1077
1075
|
|
|
1078
1076
|
renderCheckTree() {
|
|
1079
1077
|
const { filterData, isSomeNodeHasChildren } = this.state;
|
|
1080
|
-
const {
|
|
1081
|
-
inline,
|
|
1082
|
-
style,
|
|
1083
|
-
height,
|
|
1084
|
-
className,
|
|
1085
|
-
onScroll,
|
|
1086
|
-
locale,
|
|
1087
|
-
virtualized,
|
|
1088
|
-
searchable
|
|
1089
|
-
} = this.props;
|
|
1078
|
+
const { inline, style, height, className, onScroll, locale, virtualized } = this.props;
|
|
1090
1079
|
|
|
1091
1080
|
// 树节点的层级
|
|
1092
1081
|
const layer = 0;
|
|
@@ -1096,7 +1085,6 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
1096
1085
|
});
|
|
1097
1086
|
|
|
1098
1087
|
let formattedNodes = [];
|
|
1099
|
-
|
|
1100
1088
|
if (!virtualized) {
|
|
1101
1089
|
formattedNodes = getFormattedTree(filterData, this.nodes, this.props).map(node =>
|
|
1102
1090
|
this.renderNode(node, layer)
|
|
@@ -1112,31 +1100,34 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
|
|
|
1112
1100
|
}
|
|
1113
1101
|
}
|
|
1114
1102
|
|
|
1115
|
-
//
|
|
1116
|
-
const treeHeight =
|
|
1103
|
+
// The height of virtualized tree should be subtract the value of paddingBottom
|
|
1104
|
+
const treeHeight = height - 12;
|
|
1117
1105
|
const treeWidth = _.isUndefined(style?.width) ? defaultWidth : style.width;
|
|
1118
|
-
const
|
|
1106
|
+
const listStyles = inline ? { height: height, ...style } : style;
|
|
1119
1107
|
|
|
1120
1108
|
const treeNodesClass = classNames(this.addTreePrefix('nodes'), {
|
|
1121
1109
|
[this.addTreePrefix('all-uncheckable')]: getEveryFisrtLevelNodeUncheckable(this.nodes)
|
|
1122
1110
|
});
|
|
1123
|
-
const listHeight = getVirtualLisHeight(inline, searchable, treeHeight);
|
|
1124
1111
|
return (
|
|
1125
1112
|
<div
|
|
1126
1113
|
ref={this.treeViewRef}
|
|
1127
1114
|
className={classes}
|
|
1128
|
-
style={
|
|
1115
|
+
style={listStyles}
|
|
1129
1116
|
onScroll={onScroll}
|
|
1130
1117
|
onKeyDown={this.handleKeyDown}
|
|
1131
1118
|
>
|
|
1132
1119
|
<div className={treeNodesClass}>
|
|
1133
1120
|
{virtualized ? (
|
|
1134
|
-
<AutoSizer
|
|
1121
|
+
<AutoSizer
|
|
1122
|
+
defaultHeight={treeHeight}
|
|
1123
|
+
defaultWidth={treeWidth}
|
|
1124
|
+
style={{ width: 'auto', height: 'auto' }}
|
|
1125
|
+
>
|
|
1135
1126
|
{({ height, width }) => (
|
|
1136
1127
|
<List
|
|
1137
1128
|
ref={this.listRef}
|
|
1138
1129
|
width={width || treeWidth}
|
|
1139
|
-
height={height
|
|
1130
|
+
height={height}
|
|
1140
1131
|
rowHeight={36}
|
|
1141
1132
|
rowCount={formattedNodes.length}
|
|
1142
1133
|
rowRenderer={this.measureRowRenderer(formattedNodes)}
|
|
@@ -567,45 +567,65 @@ describe('CheckTreePicker', () => {
|
|
|
567
567
|
4
|
|
568
568
|
);
|
|
569
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
|
-
|
|
570
|
+
|
|
571
|
+
describe('data change', () => {
|
|
572
|
+
const renderStart = () => {
|
|
573
|
+
const containerRef = React.createRef();
|
|
574
|
+
const Wrapper = () => {
|
|
575
|
+
const nextData = [
|
|
576
|
+
{
|
|
577
|
+
label: 'Fujian',
|
|
578
|
+
value: 3,
|
|
579
|
+
children: [
|
|
580
|
+
{
|
|
581
|
+
label: 'Fuzhou',
|
|
582
|
+
value: 36
|
|
583
|
+
}
|
|
584
|
+
]
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
label: 'Guangdong',
|
|
588
|
+
value: 4,
|
|
589
|
+
children: [
|
|
590
|
+
{
|
|
591
|
+
label: 'Guangzhou',
|
|
592
|
+
value: 45
|
|
593
|
+
}
|
|
594
|
+
]
|
|
595
|
+
}
|
|
596
|
+
];
|
|
597
|
+
const [willChangeData, setData] = useState(data);
|
|
598
|
+
const handleClick = () => {
|
|
599
|
+
setData(nextData);
|
|
600
|
+
};
|
|
601
|
+
return (
|
|
602
|
+
<div ref={containerRef}>
|
|
603
|
+
<button onClick={handleClick} className="change-data">
|
|
604
|
+
change data
|
|
605
|
+
</button>
|
|
606
|
+
<CheckTreePicker inline defaultExpandAll data={willChangeData} />
|
|
607
|
+
</div>
|
|
608
|
+
);
|
|
597
609
|
};
|
|
598
|
-
|
|
599
|
-
<
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
);
|
|
610
|
+
ReactTestUtils.act(() => {
|
|
611
|
+
ReactDOM.render(<Wrapper />, container);
|
|
612
|
+
});
|
|
613
|
+
return containerRef.current;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
it('Should expand when has props defaultExpandAll', () => {
|
|
617
|
+
const container = renderStart();
|
|
618
|
+
ReactTestUtils.Simulate.click(container.querySelector('.change-data'));
|
|
619
|
+
expect(container.querySelectorAll('.rs-check-tree-open').length).to.equal(2);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it('Should be all closed, when click close icon', () => {
|
|
623
|
+
const container = renderStart();
|
|
624
|
+
ReactTestUtils.Simulate.click(container.querySelector('.change-data'));
|
|
625
|
+
container.querySelectorAll('.rs-check-tree-node-expand-icon').forEach(element => {
|
|
626
|
+
ReactTestUtils.Simulate.click(element);
|
|
627
|
+
});
|
|
628
|
+
expect(container.querySelectorAll('.rs-check-tree-open').length).to.equal(0);
|
|
606
629
|
});
|
|
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
630
|
});
|
|
611
631
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface InputPickerProps extends FormControlPickerProps<any>,
|
|
7
|
+
export interface InputPickerProps extends FormControlPickerProps<any>, BaseSelectProps {
|
|
8
8
|
/** Settings can create new options */
|
|
9
9
|
creatable?: boolean;
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
4
|
import { ListProps } from 'react-virtualized/dist/commonjs/List';
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface BaseSelectProps {
|
|
7
7
|
/** Set group condition key in data */
|
|
8
8
|
groupBy?: string;
|
|
9
9
|
|
|
@@ -22,13 +22,6 @@ export interface SelectProps<ValueType = any> {
|
|
|
22
22
|
/** Custom render menu group */
|
|
23
23
|
renderMenuGroup?: (title: React.ReactNode, item: ItemDataType) => React.ReactNode;
|
|
24
24
|
|
|
25
|
-
/** Custom render selected items */
|
|
26
|
-
renderValue?: (
|
|
27
|
-
value: ValueType,
|
|
28
|
-
item: ItemDataType | ItemDataType[],
|
|
29
|
-
selectedElement: React.ReactNode
|
|
30
|
-
) => React.ReactNode;
|
|
31
|
-
|
|
32
25
|
/** Called when the option is selected */
|
|
33
26
|
onSelect?: (value: any, item: ItemDataType, event: React.SyntheticEvent<any>) => void;
|
|
34
27
|
|
|
@@ -53,6 +46,14 @@ export interface SelectProps<ValueType = any> {
|
|
|
53
46
|
/** Custom search rules. */
|
|
54
47
|
searchBy?: (keyword: string, label: React.ReactNode, item: ItemDataType) => boolean;
|
|
55
48
|
}
|
|
49
|
+
export interface SelectProps<ValueType> extends BaseSelectProps {
|
|
50
|
+
/** Custom render selected items */
|
|
51
|
+
renderValue?: (
|
|
52
|
+
value: ValueType,
|
|
53
|
+
item: ItemDataType,
|
|
54
|
+
selectedElement: React.ReactNode
|
|
55
|
+
) => React.ReactNode;
|
|
56
|
+
}
|
|
56
57
|
|
|
57
58
|
export interface SelectPickerProps extends FormControlPickerProps<any>, SelectProps<any> {}
|
|
58
59
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import ReactTestUtils from 'react-dom/test-utils';
|
|
4
4
|
import { globalKey, getDOMNode, getInstance } from '@test/testUtils';
|
|
@@ -338,14 +338,15 @@ describe('SelectPicker', () => {
|
|
|
338
338
|
assert.ok(list[0].innerText, 'Louisa');
|
|
339
339
|
});
|
|
340
340
|
|
|
341
|
-
it
|
|
341
|
+
it('SearchWord should be reset when controlled and triggered off', done => {
|
|
342
342
|
let searchRef = '';
|
|
343
343
|
let onClose = null;
|
|
344
344
|
const promise = new Promise(resolve => {
|
|
345
345
|
onClose = resolve;
|
|
346
346
|
});
|
|
347
|
-
const Wrapper =
|
|
347
|
+
const Wrapper = () => {
|
|
348
348
|
const [search, setSearch] = useState(searchRef);
|
|
349
|
+
const containerRef = useRef();
|
|
349
350
|
searchRef = search;
|
|
350
351
|
const handleSearch = value => {
|
|
351
352
|
setSearch(value);
|
|
@@ -354,11 +355,11 @@ describe('SelectPicker', () => {
|
|
|
354
355
|
onClose();
|
|
355
356
|
};
|
|
356
357
|
return (
|
|
357
|
-
<div>
|
|
358
|
+
<div ref={containerRef}>
|
|
358
359
|
<button id="exit">exit</button>
|
|
359
360
|
<Dropdown
|
|
361
|
+
container={() => containerRef.current}
|
|
360
362
|
search={search}
|
|
361
|
-
ref={ref}
|
|
362
363
|
defaultOpen
|
|
363
364
|
onClose={handleClose}
|
|
364
365
|
onSearch={handleSearch}
|
|
@@ -366,14 +367,15 @@ describe('SelectPicker', () => {
|
|
|
366
367
|
/>
|
|
367
368
|
</div>
|
|
368
369
|
);
|
|
369
|
-
}
|
|
370
|
+
};
|
|
370
371
|
Wrapper.displayName = 'WrapperSelectPicker';
|
|
371
372
|
ReactTestUtils.act(() => {
|
|
372
373
|
ReactDOM.render(<Wrapper />, container);
|
|
373
374
|
});
|
|
374
375
|
|
|
375
376
|
const exit = container?.querySelector('#exit');
|
|
376
|
-
const input =
|
|
377
|
+
const input = container.querySelector(searchInputClassName);
|
|
378
|
+
|
|
377
379
|
// change search
|
|
378
380
|
input.value = 'a';
|
|
379
381
|
ReactTestUtils.Simulate.change(input);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import { FormControlPickerProps } from '../@types/common';
|
|
4
|
-
import {
|
|
3
|
+
import { FormControlPickerProps, ItemDataType } from '../@types/common';
|
|
4
|
+
import { BaseSelectProps } from '../SelectPicker/SelectPicker.d';
|
|
5
5
|
import { TagProps } from '../Tag/Tag.d';
|
|
6
6
|
|
|
7
|
-
export interface TagPickerProps extends FormControlPickerProps,
|
|
7
|
+
export interface TagPickerProps extends FormControlPickerProps, BaseSelectProps {
|
|
8
8
|
/** Option to cache value when searching asynchronously */
|
|
9
9
|
cacheData?: any[];
|
|
10
10
|
|
|
@@ -16,6 +16,13 @@ export interface TagPickerProps extends FormControlPickerProps, SelectProps<any[
|
|
|
16
16
|
* https://github.com/rsuite/rsuite/blob/master/src/Tag/Tag.d.ts
|
|
17
17
|
*/
|
|
18
18
|
tagProps?: TagProps;
|
|
19
|
+
|
|
20
|
+
/** Custom render selected items */
|
|
21
|
+
renderValue?: (
|
|
22
|
+
value: any[],
|
|
23
|
+
item: ItemDataType[],
|
|
24
|
+
selectedElement: React.ReactNode
|
|
25
|
+
) => React.ReactNode;
|
|
19
26
|
}
|
|
20
27
|
|
|
21
28
|
declare const TagPicker: React.ComponentType<TagPickerProps>;
|