rsuite 4.11.0 → 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.
@@ -21,7 +21,7 @@ import { CHECK_STATE } from '../constants';
21
21
  import { clone, defaultProps, prefix, defaultClassPrefix, getUnhandledProps, createChainedFunction, mergeRefs } from '../utils';
22
22
  import { PickerToggle, getToggleWrapperClassName, onMenuKeyDown, MenuWrapper, SearchBar, SelectedElement, PickerToggleTrigger, createConcatChildrenFunction, shouldDisplay } from '../Picker';
23
23
  import { isEveryChildChecked, isSomeChildChecked, isSomeNodeHasChildren, getSiblingNodeUncheckable, getEveryFisrtLevelNodeUncheckable, getUncheckableState, getFormattedTree, getDisabledState } from './utils';
24
- import { compareArray, shouldShowNodeByExpanded, flattenTree, getNodeParents, getVirtualLisHeight, hasVisibleChildren, treeDeprecatedWarning, getExpandItemValues, getExpandAll, getExpandState, getExpandWhenSearching } from '../utils/treeUtils';
24
+ import { compareArray, shouldShowNodeByExpanded, flattenTree, getNodeParents, hasVisibleChildren, treeDeprecatedWarning, getExpandItemValues, getExpandAll, getExpandState, getExpandWhenSearching } from '../utils/treeUtils';
25
25
  import { listPickerPropTypes, listPickerDefaultProps } from '../Picker/propTypes'; // default value for virtualized
26
26
 
27
27
  var defaultHeight = 360;
@@ -1028,13 +1028,10 @@ function (_React$Component) {
1028
1028
 
1029
1029
  _proto.renderDropdownMenu = function renderDropdownMenu() {
1030
1030
  var _this$props10 = this.props,
1031
- _this$props10$height = _this$props10.height,
1032
- height = _this$props10$height === void 0 ? defaultHeight : _this$props10$height,
1033
1031
  locale = _this$props10.locale,
1034
1032
  menuStyle = _this$props10.menuStyle,
1035
1033
  searchable = _this$props10.searchable,
1036
1034
  renderMenu = _this$props10.renderMenu,
1037
- virtualized = _this$props10.virtualized,
1038
1035
  searchKeyword = _this$props10.searchKeyword,
1039
1036
  renderExtraFooter = _this$props10.renderExtraFooter,
1040
1037
  menuClassName = _this$props10.menuClassName,
@@ -1042,13 +1039,10 @@ function (_React$Component) {
1042
1039
  var keyword = !_isUndefined(searchKeyword) ? searchKeyword : this.state.searchKeyword;
1043
1040
  var classes = classNames(menuClassName, this.addPrefix('check-tree-menu'));
1044
1041
  var menu = this.renderCheckTree();
1045
- var styles = virtualized ? _extends({
1046
- height: height
1047
- }, menuStyle) : menuStyle;
1048
1042
  return React.createElement(MenuWrapper, {
1049
1043
  autoWidth: menuAutoWidth,
1050
1044
  className: classes,
1051
- style: styles,
1045
+ style: menuStyle,
1052
1046
  ref: this.menuRef,
1053
1047
  getToggleInstance: this.getToggleInstance,
1054
1048
  getPositionInstance: this.getPositionInstance
@@ -1196,8 +1190,7 @@ function (_React$Component) {
1196
1190
  className = _this$props13.className,
1197
1191
  onScroll = _this$props13.onScroll,
1198
1192
  locale = _this$props13.locale,
1199
- virtualized = _this$props13.virtualized,
1200
- searchable = _this$props13.searchable; // 树节点的层级
1193
+ virtualized = _this$props13.virtualized; // 树节点的层级
1201
1194
 
1202
1195
  var layer = 0;
1203
1196
  var classes = classNames(defaultClassPrefix('check-tree'), (_classNames2 = {}, _classNames2[className] = inline, _classNames2['without-children'] = !isSomeNodeHasChildren, _classNames2));
@@ -1225,34 +1218,37 @@ function (_React$Component) {
1225
1218
  className: this.addPrefix('none')
1226
1219
  }, locale.noResultsText);
1227
1220
  }
1228
- } // 当未定义 height 设置了 virtualized true,treeHeight 设置默认高度
1221
+ } // The height of virtualized tree should be subtract the value of paddingBottom
1229
1222
 
1230
1223
 
1231
- var treeHeight = _isUndefined(height) && virtualized ? defaultHeight : height;
1224
+ var treeHeight = height - 12;
1232
1225
  var treeWidth = _isUndefined(style === null || style === void 0 ? void 0 : style.width) ? defaultWidth : style.width;
1233
- var styles = inline ? _extends({
1234
- height: treeHeight
1235
- }, style) : {};
1226
+ var listStyles = inline ? _extends({
1227
+ height: height
1228
+ }, style) : style;
1236
1229
  var treeNodesClass = classNames(this.addTreePrefix('nodes'), (_classNames3 = {}, _classNames3[this.addTreePrefix('all-uncheckable')] = getEveryFisrtLevelNodeUncheckable(this.nodes), _classNames3));
1237
- var listHeight = getVirtualLisHeight(inline, searchable, treeHeight);
1238
1230
  return React.createElement("div", {
1239
1231
  ref: this.treeViewRef,
1240
1232
  className: classes,
1241
- style: styles,
1233
+ style: listStyles,
1242
1234
  onScroll: onScroll,
1243
1235
  onKeyDown: this.handleKeyDown
1244
1236
  }, React.createElement("div", {
1245
1237
  className: treeNodesClass
1246
1238
  }, virtualized ? React.createElement(AutoSizer, {
1247
- defaultHeight: listHeight,
1248
- defaultWidth: treeWidth
1239
+ defaultHeight: treeHeight,
1240
+ defaultWidth: treeWidth,
1241
+ style: {
1242
+ width: 'auto',
1243
+ height: 'auto'
1244
+ }
1249
1245
  }, function (_ref3) {
1250
1246
  var height = _ref3.height,
1251
1247
  width = _ref3.width;
1252
1248
  return React.createElement(List, {
1253
1249
  ref: _this11.listRef,
1254
1250
  width: width || treeWidth,
1255
- height: height || listHeight,
1251
+ height: height,
1256
1252
  rowHeight: 36,
1257
1253
  rowCount: formattedNodes.length,
1258
1254
  rowRenderer: _this11.measureRowRenderer(formattedNodes)
@@ -1373,6 +1369,7 @@ CheckTreePicker.propTypes = _extends({}, listPickerPropTypes, {
1373
1369
  searchBy: PropTypes.func
1374
1370
  });
1375
1371
  CheckTreePicker.defaultProps = _extends({}, listPickerDefaultProps, {
1372
+ height: defaultHeight,
1376
1373
  cascade: true,
1377
1374
  countable: true,
1378
1375
  searchable: true,
@@ -20,7 +20,7 @@ import { polyfill } from 'react-lifecycles-compat';
20
20
  import shallowEqual from '../utils/shallowEqual';
21
21
  import TreeNode from './TreeNode';
22
22
  import { defaultProps, prefix, defaultClassPrefix, getUnhandledProps, createChainedFunction, mergeRefs } from '../utils';
23
- import { flattenTree, getExpandWhenSearching, getNodeParents, shouldShowNodeByExpanded, getVirtualLisHeight, treeDeprecatedWarning, hasVisibleChildren, compareArray, getExpandAll, getExpandItemValues, getExpandState, getDragNodeKeys, calDropNodePosition, createUpdateTreeDataFunction } from '../utils/treeUtils';
23
+ import { flattenTree, getExpandWhenSearching, getNodeParents, shouldShowNodeByExpanded, treeDeprecatedWarning, hasVisibleChildren, compareArray, getExpandAll, getExpandItemValues, getExpandState, getDragNodeKeys, calDropNodePosition, createUpdateTreeDataFunction } from '../utils/treeUtils';
24
24
  import { PickerToggle, getToggleWrapperClassName, onMenuKeyDown, MenuWrapper, SearchBar, PickerToggleTrigger, createConcatChildrenFunction, shouldDisplay } from '../Picker';
25
25
  import { TREE_NODE_DROP_POSITION } from '../constants';
26
26
  import { listPickerPropTypes, listPickerDefaultProps } from '../Picker/propTypes'; // default value for virtualized
@@ -547,7 +547,7 @@ function (_React$Component) {
547
547
  nextState.selectedValue = value;
548
548
  }
549
549
 
550
- if (compareArray(expandItemValues, prevState.expandItemValues)) {
550
+ if (compareArray(expandItemValues, prevState.expandItemValues) && Array.isArray(expandItemValues)) {
551
551
  nextState.expandItemValues = expandItemValues;
552
552
  }
553
553
 
@@ -639,7 +639,7 @@ function (_React$Component) {
639
639
  _proto.updateExpandItemValuesChange = function updateExpandItemValuesChange(prevState) {
640
640
  var expandItemValues = this.props.expandItemValues;
641
641
 
642
- if (compareArray(expandItemValues, prevState.expandItemValues)) {
642
+ if (compareArray(expandItemValues, prevState.expandItemValues) && Array.isArray(expandItemValues)) {
643
643
  this.unserializeLists('expand', expandItemValues);
644
644
  this.setState({
645
645
  expandItemValues: expandItemValues
@@ -1002,26 +1002,20 @@ function (_React$Component) {
1002
1002
 
1003
1003
  _proto.renderDropdownMenu = function renderDropdownMenu() {
1004
1004
  var _this$props16 = this.props,
1005
- _this$props16$height = _this$props16.height,
1006
- height = _this$props16$height === void 0 ? defaultHeight : _this$props16$height,
1007
1005
  searchable = _this$props16.searchable,
1008
1006
  searchKeyword = _this$props16.searchKeyword,
1009
1007
  renderExtraFooter = _this$props16.renderExtraFooter,
1010
1008
  locale = _this$props16.locale,
1011
1009
  renderMenu = _this$props16.renderMenu,
1012
1010
  menuStyle = _this$props16.menuStyle,
1013
- virtualized = _this$props16.virtualized,
1014
1011
  menuClassName = _this$props16.menuClassName,
1015
1012
  menuAutoWidth = _this$props16.menuAutoWidth;
1016
1013
  var keyword = !_isUndefined(searchKeyword) ? searchKeyword : this.state.searchKeyword;
1017
1014
  var classes = classNames(menuClassName, this.addPrefix('tree-menu'));
1018
- var styles = virtualized ? _extends({
1019
- height: height
1020
- }, menuStyle) : menuStyle;
1021
1015
  return React.createElement(MenuWrapper, {
1022
1016
  autoWidth: menuAutoWidth,
1023
1017
  className: classes,
1024
- style: styles,
1018
+ style: menuStyle,
1025
1019
  ref: this.menuRef,
1026
1020
  getToggleInstance: this.getToggleInstance,
1027
1021
  getPositionInstance: this.getPositionInstance
@@ -1122,8 +1116,7 @@ function (_React$Component) {
1122
1116
  inline = _this$props18.inline,
1123
1117
  style = _this$props18.style,
1124
1118
  locale = _this$props18.locale,
1125
- virtualized = _this$props18.virtualized,
1126
- searchable = _this$props18.searchable;
1119
+ virtualized = _this$props18.virtualized;
1127
1120
  var layer = 0;
1128
1121
  var classes = classNames(defaultClassPrefix('tree'), (_classNames2 = {}, _classNames2[className] = inline, _classNames2));
1129
1122
  var nodes = [];
@@ -1150,33 +1143,36 @@ function (_React$Component) {
1150
1143
  className: this.addPrefix('none')
1151
1144
  }, locale.noResultsText);
1152
1145
  }
1153
- } // 当未定义 height 设置了 virtualized true,treeHeight 设置默认高度
1146
+ } // The height of virtualized tree should be subtract the value of paddingBottom
1154
1147
 
1155
1148
 
1156
- var treeHeight = _isUndefined(height) && virtualized ? defaultHeight : height;
1149
+ var treeHeight = height - 12;
1157
1150
  var treeWidth = _isUndefined(style === null || style === void 0 ? void 0 : style.width) ? defaultWidth : style.width;
1158
- var styles = inline ? _extends({
1159
- height: treeHeight
1160
- }, style) : {};
1161
- var listHeight = getVirtualLisHeight(inline, searchable, treeHeight);
1151
+ var listStyles = inline ? _extends({
1152
+ height: height
1153
+ }, style) : style;
1162
1154
  return React.createElement(React.Fragment, null, React.createElement("div", {
1163
1155
  ref: this.treeViewRef,
1164
1156
  className: classes,
1165
- style: styles,
1157
+ style: listStyles,
1166
1158
  onKeyDown: this.handleKeyDown
1167
1159
  }, React.createElement("div", {
1168
1160
  className: this.addTreePrefix('nodes')
1169
1161
  }, virtualized ? React.createElement(AutoSizer, {
1170
- defaultHeight: listHeight,
1171
- defaultWidth: treeWidth
1162
+ defaultHeight: treeHeight,
1163
+ defaultWidth: treeWidth,
1164
+ style: {
1165
+ width: 'auto',
1166
+ height: 'auto'
1167
+ }
1172
1168
  }, function (_ref4) {
1173
1169
  var height = _ref4.height,
1174
1170
  width = _ref4.width;
1175
1171
  return React.createElement(List, {
1176
1172
  ref: _this9.listRef,
1177
1173
  width: width || treeWidth,
1178
- height: height || listHeight,
1179
- rowHeight: 38,
1174
+ height: height,
1175
+ rowHeight: 36,
1180
1176
  rowCount: nodes.length,
1181
1177
  rowRenderer: _this9.measureRowRenderer(nodes)
1182
1178
  });
@@ -1306,6 +1302,7 @@ TreePicker.propTypes = _extends({}, listPickerPropTypes, {
1306
1302
  searchBy: PropTypes.func
1307
1303
  });
1308
1304
  TreePicker.defaultProps = _extends({}, listPickerDefaultProps, {
1305
+ height: defaultHeight,
1309
1306
  searchable: true,
1310
1307
  menuAutoWidth: true,
1311
1308
  locale: {
@@ -8,12 +8,11 @@ import _intersection from "lodash/intersection";
8
8
  import shallowEqual from '../utils/shallowEqual';
9
9
  import shallowEqualArray from '../utils/shallowEqualArray';
10
10
  import { TREE_NODE_DROP_POSITION } from '../constants';
11
- var SEARCH_BAR_HEIGHT = 48;
12
- var MENU_PADDING = 12; // Tree Node 之间的 间隔
13
-
11
+ // Tree Node 之间的 间隔
14
12
  var TREE_NODE_GAP = 4;
15
13
  /**
16
- * 判断当前节点是否应该显示
14
+ * Whether current node is visible
15
+ * when all the parents of the current node is expanded, the current node should be visible
17
16
  * @param {*} expandItemValues
18
17
  * @param {*} parentKeys
19
18
  */
@@ -95,20 +94,6 @@ export function getNodeParents(node, parentKey, valueKey) {
95
94
  traverse(node);
96
95
  return parents;
97
96
  }
98
- /**
99
- * 获取 VirtualList 的高度
100
- * @param {*} inline
101
- * @param {*} height
102
- */
103
-
104
- export function getVirtualLisHeight(inline, searchable, height) {
105
- if (height === void 0) {
106
- height = 0;
107
- }
108
-
109
- var searchBarHeight = searchable ? SEARCH_BAR_HEIGHT : 0;
110
- return inline ? height - MENU_PADDING * 2 : height - searchBarHeight - MENU_PADDING * 2;
111
- }
112
97
  /**
113
98
  * 判断节点是否存在可见的子节点。
114
99
  * @param node
@@ -1062,13 +1062,10 @@ function (_React$Component) {
1062
1062
 
1063
1063
  _proto.renderDropdownMenu = function renderDropdownMenu() {
1064
1064
  var _this$props10 = this.props,
1065
- _this$props10$height = _this$props10.height,
1066
- height = _this$props10$height === void 0 ? defaultHeight : _this$props10$height,
1067
1065
  locale = _this$props10.locale,
1068
1066
  menuStyle = _this$props10.menuStyle,
1069
1067
  searchable = _this$props10.searchable,
1070
1068
  renderMenu = _this$props10.renderMenu,
1071
- virtualized = _this$props10.virtualized,
1072
1069
  searchKeyword = _this$props10.searchKeyword,
1073
1070
  renderExtraFooter = _this$props10.renderExtraFooter,
1074
1071
  menuClassName = _this$props10.menuClassName,
@@ -1076,13 +1073,10 @@ function (_React$Component) {
1076
1073
  var keyword = !(0, _isUndefined2.default)(searchKeyword) ? searchKeyword : this.state.searchKeyword;
1077
1074
  var classes = (0, _classnames.default)(menuClassName, this.addPrefix('check-tree-menu'));
1078
1075
  var menu = this.renderCheckTree();
1079
- var styles = virtualized ? (0, _extends2.default)({
1080
- height: height
1081
- }, menuStyle) : menuStyle;
1082
1076
  return React.createElement(_Picker.MenuWrapper, {
1083
1077
  autoWidth: menuAutoWidth,
1084
1078
  className: classes,
1085
- style: styles,
1079
+ style: menuStyle,
1086
1080
  ref: this.menuRef,
1087
1081
  getToggleInstance: this.getToggleInstance,
1088
1082
  getPositionInstance: this.getPositionInstance
@@ -1230,8 +1224,7 @@ function (_React$Component) {
1230
1224
  className = _this$props13.className,
1231
1225
  onScroll = _this$props13.onScroll,
1232
1226
  locale = _this$props13.locale,
1233
- virtualized = _this$props13.virtualized,
1234
- searchable = _this$props13.searchable; // 树节点的层级
1227
+ virtualized = _this$props13.virtualized; // 树节点的层级
1235
1228
 
1236
1229
  var layer = 0;
1237
1230
  var classes = (0, _classnames.default)((0, _utils.defaultClassPrefix)('check-tree'), (_classNames2 = {}, _classNames2[className] = inline, _classNames2['without-children'] = !isSomeNodeHasChildren, _classNames2));
@@ -1259,34 +1252,37 @@ function (_React$Component) {
1259
1252
  className: this.addPrefix('none')
1260
1253
  }, locale.noResultsText);
1261
1254
  }
1262
- } // 当未定义 height 设置了 virtualized true,treeHeight 设置默认高度
1255
+ } // The height of virtualized tree should be subtract the value of paddingBottom
1263
1256
 
1264
1257
 
1265
- var treeHeight = (0, _isUndefined2.default)(height) && virtualized ? defaultHeight : height;
1258
+ var treeHeight = height - 12;
1266
1259
  var treeWidth = (0, _isUndefined2.default)(style === null || style === void 0 ? void 0 : style.width) ? defaultWidth : style.width;
1267
- var styles = inline ? (0, _extends2.default)({
1268
- height: treeHeight
1269
- }, style) : {};
1260
+ var listStyles = inline ? (0, _extends2.default)({
1261
+ height: height
1262
+ }, style) : style;
1270
1263
  var treeNodesClass = (0, _classnames.default)(this.addTreePrefix('nodes'), (_classNames3 = {}, _classNames3[this.addTreePrefix('all-uncheckable')] = (0, _utils2.getEveryFisrtLevelNodeUncheckable)(this.nodes), _classNames3));
1271
- var listHeight = (0, _treeUtils.getVirtualLisHeight)(inline, searchable, treeHeight);
1272
1264
  return React.createElement("div", {
1273
1265
  ref: this.treeViewRef,
1274
1266
  className: classes,
1275
- style: styles,
1267
+ style: listStyles,
1276
1268
  onScroll: onScroll,
1277
1269
  onKeyDown: this.handleKeyDown
1278
1270
  }, React.createElement("div", {
1279
1271
  className: treeNodesClass
1280
1272
  }, virtualized ? React.createElement(_AutoSizer.default, {
1281
- defaultHeight: listHeight,
1282
- defaultWidth: treeWidth
1273
+ defaultHeight: treeHeight,
1274
+ defaultWidth: treeWidth,
1275
+ style: {
1276
+ width: 'auto',
1277
+ height: 'auto'
1278
+ }
1283
1279
  }, function (_ref3) {
1284
1280
  var height = _ref3.height,
1285
1281
  width = _ref3.width;
1286
1282
  return React.createElement(_List.default, {
1287
1283
  ref: _this11.listRef,
1288
1284
  width: width || treeWidth,
1289
- height: height || listHeight,
1285
+ height: height,
1290
1286
  rowHeight: 36,
1291
1287
  rowCount: formattedNodes.length,
1292
1288
  rowRenderer: _this11.measureRowRenderer(formattedNodes)
@@ -1404,6 +1400,7 @@ CheckTreePicker.propTypes = (0, _extends2.default)({}, _propTypes2.listPickerPro
1404
1400
  searchBy: _propTypes.default.func
1405
1401
  });
1406
1402
  CheckTreePicker.defaultProps = (0, _extends2.default)({}, _propTypes2.listPickerDefaultProps, {
1403
+ height: defaultHeight,
1407
1404
  cascade: true,
1408
1405
  countable: true,
1409
1406
  searchable: true,
@@ -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: styles,
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
- } // 当未定义 height 设置了 virtualized true,treeHeight 设置默认高度
1176
+ } // The height of virtualized tree should be subtract the value of paddingBottom
1184
1177
 
1185
1178
 
1186
- var treeHeight = (0, _isUndefined2.default)(height) && virtualized ? defaultHeight : height;
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 styles = inline ? (0, _extends3.default)({
1189
- height: treeHeight
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: styles,
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: listHeight,
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 || listHeight,
1209
- rowHeight: 38,
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: {
@@ -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
- var SEARCH_BAR_HEIGHT = 48;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "rsuite",
3
- "version": "4.11.0",
3
+ "version": "4.11.1",
4
4
  "description": "A suite of react components",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -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,
@@ -904,12 +904,10 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
904
904
 
905
905
  renderDropdownMenu() {
906
906
  const {
907
- height = defaultHeight,
908
907
  locale,
909
908
  menuStyle,
910
909
  searchable,
911
910
  renderMenu,
912
- virtualized,
913
911
  searchKeyword,
914
912
  renderExtraFooter,
915
913
  menuClassName,
@@ -919,13 +917,12 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
919
917
  const keyword = !_.isUndefined(searchKeyword) ? searchKeyword : this.state.searchKeyword;
920
918
  const classes = classNames(menuClassName, this.addPrefix('check-tree-menu'));
921
919
  const menu = this.renderCheckTree();
922
- const styles = virtualized ? { height, ...menuStyle } : menuStyle;
923
920
 
924
921
  return (
925
922
  <MenuWrapper
926
923
  autoWidth={menuAutoWidth}
927
924
  className={classes}
928
- style={styles}
925
+ style={menuStyle}
929
926
  ref={this.menuRef}
930
927
  getToggleInstance={this.getToggleInstance}
931
928
  getPositionInstance={this.getPositionInstance}
@@ -1078,16 +1075,7 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
1078
1075
 
1079
1076
  renderCheckTree() {
1080
1077
  const { filterData, isSomeNodeHasChildren } = this.state;
1081
- const {
1082
- inline,
1083
- style,
1084
- height,
1085
- className,
1086
- onScroll,
1087
- locale,
1088
- virtualized,
1089
- searchable
1090
- } = this.props;
1078
+ const { inline, style, height, className, onScroll, locale, virtualized } = this.props;
1091
1079
 
1092
1080
  // 树节点的层级
1093
1081
  const layer = 0;
@@ -1097,7 +1085,6 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
1097
1085
  });
1098
1086
 
1099
1087
  let formattedNodes = [];
1100
-
1101
1088
  if (!virtualized) {
1102
1089
  formattedNodes = getFormattedTree(filterData, this.nodes, this.props).map(node =>
1103
1090
  this.renderNode(node, layer)
@@ -1113,31 +1100,34 @@ class CheckTreePicker extends React.Component<CheckTreePickerProps, CheckTreePic
1113
1100
  }
1114
1101
  }
1115
1102
 
1116
- // 当未定义 height 设置了 virtualized true,treeHeight 设置默认高度
1117
- const treeHeight = _.isUndefined(height) && virtualized ? defaultHeight : height;
1103
+ // The height of virtualized tree should be subtract the value of paddingBottom
1104
+ const treeHeight = height - 12;
1118
1105
  const treeWidth = _.isUndefined(style?.width) ? defaultWidth : style.width;
1119
- const styles = inline ? { height: treeHeight, ...style } : {};
1106
+ const listStyles = inline ? { height: height, ...style } : style;
1120
1107
 
1121
1108
  const treeNodesClass = classNames(this.addTreePrefix('nodes'), {
1122
1109
  [this.addTreePrefix('all-uncheckable')]: getEveryFisrtLevelNodeUncheckable(this.nodes)
1123
1110
  });
1124
- const listHeight = getVirtualLisHeight(inline, searchable, treeHeight);
1125
1111
  return (
1126
1112
  <div
1127
1113
  ref={this.treeViewRef}
1128
1114
  className={classes}
1129
- style={styles}
1115
+ style={listStyles}
1130
1116
  onScroll={onScroll}
1131
1117
  onKeyDown={this.handleKeyDown}
1132
1118
  >
1133
1119
  <div className={treeNodesClass}>
1134
1120
  {virtualized ? (
1135
- <AutoSizer defaultHeight={listHeight} defaultWidth={treeWidth}>
1121
+ <AutoSizer
1122
+ defaultHeight={treeHeight}
1123
+ defaultWidth={treeWidth}
1124
+ style={{ width: 'auto', height: 'auto' }}
1125
+ >
1136
1126
  {({ height, width }) => (
1137
1127
  <List
1138
1128
  ref={this.listRef}
1139
1129
  width={width || treeWidth}
1140
- height={height || listHeight}
1130
+ height={height}
1141
1131
  rowHeight={36}
1142
1132
  rowCount={formattedNodes.length}
1143
1133
  rowRenderer={this.measureRowRenderer(formattedNodes)}