rsuite 4.10.10 → 4.11.0
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 +12 -0
- package/dist/rsuite.js +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/es/CheckPicker/CheckPicker.d.ts +10 -3
- package/es/CheckTreePicker/CheckTreePicker.js +7 -3
- 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/lib/CheckPicker/CheckPicker.d.ts +10 -3
- package/lib/CheckTreePicker/CheckTreePicker.js +7 -3
- 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/package.json +1 -1
- package/src/CheckPicker/CheckPicker.d.ts +10 -3
- package/src/CheckTreePicker/CheckTreePicker.tsx +4 -3
- 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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
<a name="4.11.0"></a>
|
|
2
|
+
# [4.11.0](https://github.com/rsuite/rsuite/compare/v4.10.10...v4.11.0) (2022-08-24)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **CheckTreePicker:** when data changes Cannot close ([#2543](https://github.com/rsuite/rsuite/issues/2543)) ([ee247d1](https://github.com/rsuite/rsuite/commit/ee247d1))
|
|
8
|
+
* delete test case only ([#2410](https://github.com/rsuite/rsuite/issues/2410)) ([e0d9c9e](https://github.com/rsuite/rsuite/commit/e0d9c9e))
|
|
9
|
+
* **SelectPicker:** fix renderValue prop declaration ([#2399](https://github.com/rsuite/rsuite/issues/2399)) ([0914942](https://github.com/rsuite/rsuite/commit/0914942))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
1
13
|
<a name="4.10.10"></a>
|
|
2
14
|
## [4.10.10](https://github.com/rsuite/rsuite/compare/v4.10.9...v4.10.10) (2022-03-22)
|
|
3
15
|
|
package/dist/rsuite.js
CHANGED
|
@@ -7648,7 +7648,7 @@ eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/he
|
|
|
7648
7648
|
/***/ (function(module, exports, __webpack_require__) {
|
|
7649
7649
|
|
|
7650
7650
|
"use strict";
|
|
7651
|
-
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\n\nvar _interopRequireWildcard = __webpack_require__(/*! @babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\");\n\nexports.__esModule = true;\nexports.default = void 0;\n\nvar _objectWithoutPropertiesLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/objectWithoutPropertiesLoose */ \"./node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js\"));\n\nvar _extends2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/extends */ \"./node_modules/@babel/runtime/helpers/extends.js\"));\n\nvar _inheritsLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inheritsLoose */ \"./node_modules/@babel/runtime/helpers/inheritsLoose.js\"));\n\nvar _isNil2 = _interopRequireDefault(__webpack_require__(/*! lodash/isNil */ \"./node_modules/lodash/isNil.js\"));\n\nvar _isFunction2 = _interopRequireDefault(__webpack_require__(/*! lodash/isFunction */ \"./node_modules/lodash/isFunction.js\"));\n\nvar _isNumber2 = _interopRequireDefault(__webpack_require__(/*! lodash/isNumber */ \"./node_modules/lodash/isNumber.js\"));\n\nvar _isString2 = _interopRequireDefault(__webpack_require__(/*! lodash/isString */ \"./node_modules/lodash/isString.js\"));\n\nvar _isEmpty2 = _interopRequireDefault(__webpack_require__(/*! lodash/isEmpty */ \"./node_modules/lodash/isEmpty.js\"));\n\nvar _isUndefined2 = _interopRequireDefault(__webpack_require__(/*! lodash/isUndefined */ \"./node_modules/lodash/isUndefined.js\"));\n\nvar _isArray2 = _interopRequireDefault(__webpack_require__(/*! lodash/isArray */ \"./node_modules/lodash/isArray.js\"));\n\nvar React = _interopRequireWildcard(__webpack_require__(/*! react */ \"react\"));\n\nvar _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ \"./node_modules/prop-types/index.js\"));\n\nvar _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ \"./node_modules/classnames/index.js\"));\n\nvar _List = _interopRequireDefault(__webpack_require__(/*! react-virtualized/dist/commonjs/List */ \"./node_modules/react-virtualized/dist/commonjs/List/index.js\"));\n\nvar _AutoSizer = _interopRequireDefault(__webpack_require__(/*! react-virtualized/dist/commonjs/AutoSizer */ \"./node_modules/react-virtualized/dist/commonjs/AutoSizer/index.js\"));\n\nvar _CellMeasurer = __webpack_require__(/*! react-virtualized/dist/commonjs/CellMeasurer */ \"./node_modules/react-virtualized/dist/commonjs/CellMeasurer/index.js\");\n\nvar _reactLifecyclesCompat = __webpack_require__(/*! react-lifecycles-compat */ \"./node_modules/react-lifecycles-compat/react-lifecycles-compat.es.js\");\n\nvar _shallowEqual = _interopRequireDefault(__webpack_require__(/*! ../utils/shallowEqual */ \"./src/utils/shallowEqual.ts\"));\n\nvar _CheckTreeNode = _interopRequireDefault(__webpack_require__(/*! ./CheckTreeNode */ \"./src/CheckTreePicker/CheckTreeNode.tsx\"));\n\nvar _constants = __webpack_require__(/*! ../constants */ \"./src/constants.ts\");\n\nvar _utils = __webpack_require__(/*! ../utils */ \"./src/utils/index.ts\");\n\nvar _Picker = __webpack_require__(/*! ../Picker */ \"./src/Picker/index.ts\");\n\nvar _utils2 = __webpack_require__(/*! ./utils */ \"./src/CheckTreePicker/utils.ts\");\n\nvar _treeUtils = __webpack_require__(/*! ../utils/treeUtils */ \"./src/utils/treeUtils.ts\");\n\nvar _propTypes2 = __webpack_require__(/*! ../Picker/propTypes */ \"./src/Picker/propTypes.ts\");\n\nvar _jsxFileName = \"/home/runner/work/rsuite/rsuite/src/CheckTreePicker/CheckTreePicker.tsx\";\n// default value for virtualized\nvar defaultHeight = 360;\nvar defaultWidth = 200;\n\nvar CheckTreePicker =\n/*#__PURE__*/\nfunction (_React$Component) {\n (0, _inheritsLoose2.default)(CheckTreePicker, _React$Component);\n\n function CheckTreePicker(_props) {\n var _this;\n\n _this = _React$Component.call(this, _props) || this;\n _this.menuRef = void 0;\n _this.treeViewRef = void 0;\n _this.positionRef = void 0;\n _this.listRef = void 0;\n _this.triggerRef = void 0;\n _this.toggleRef = void 0;\n\n _this.getValue = function (props) {\n if (props === void 0) {\n props = _this.props;\n }\n\n var _props2 = props,\n value = _props2.value,\n defaultValue = _props2.defaultValue,\n _props2$uncheckableIt = _props2.uncheckableItemValues,\n uncheckableItemValues = _props2$uncheckableIt === void 0 ? [] : _props2$uncheckableIt;\n\n if (value && value.length) {\n return value.filter(function (v) {\n return !uncheckableItemValues.includes(v);\n });\n }\n\n if (defaultValue && defaultValue.length > 0) {\n return defaultValue.filter(function (v) {\n return !uncheckableItemValues.includes(v);\n });\n }\n\n return [];\n };\n\n _this.getElementByDataKey = function (dataKey) {\n var ele = _this.nodeRefs[dataKey];\n\n if (ele instanceof Element) {\n return ele.querySelector(\".\" + _this.addTreePrefix('node-label'));\n }\n\n return null;\n };\n\n _this.getFocusableMenuItems = function () {\n var filterData = _this.state.filterData;\n var childrenKey = _this.props.childrenKey;\n var items = [];\n\n var loop = function loop(treeNodes) {\n treeNodes.forEach(function (node) {\n var nodeData = (0, _extends2.default)({}, node, {}, _this.nodes[node.refKey]);\n\n if (!(0, _utils2.getDisabledState)(_this.nodes, node, _this.props) && node.visible) {\n items.push(node);\n }\n\n if (node[childrenKey] && (0, _treeUtils.getExpandState)(nodeData, _this.props)) {\n loop(node[childrenKey]);\n }\n });\n };\n\n loop(filterData);\n return items;\n };\n\n _this.nodes = {};\n _this.activeNode = null;\n _this.cache = new _CellMeasurer.CellMeasurerCache({\n fixedWidth: true,\n minHeight: 20\n });\n _this.nodeRefs = {};\n\n _this.bindNodeRefs = function (refKey, ref) {\n _this.nodeRefs[refKey] = ref;\n };\n\n _this.getPositionInstance = function () {\n return _this.positionRef.current;\n };\n\n _this.getToggleInstance = function () {\n return _this.toggleRef.current;\n };\n\n _this.selectActiveItem = function (event) {\n var _this$getActiveItem = _this.getActiveItem(),\n nodeData = _this$getActiveItem.nodeData;\n\n _this.handleSelect(nodeData, event);\n };\n\n _this.focusNextItem = function () {\n var _node$focus;\n\n var _this$getItemsAndActi = _this.getItemsAndActiveIndex(),\n items = _this$getItemsAndActi.items,\n activeIndex = _this$getItemsAndActi.activeIndex;\n\n if (items.length === 0) {\n return;\n }\n\n var nextIndex = activeIndex === items.length - 1 ? 0 : activeIndex + 1;\n\n var node = _this.getElementByDataKey(items[nextIndex].refKey);\n\n node === null || node === void 0 ? void 0 : (_node$focus = node.focus) === null || _node$focus === void 0 ? void 0 : _node$focus.call(node);\n };\n\n _this.focusPreviousItem = function () {\n var _node$focus2;\n\n var _this$getItemsAndActi2 = _this.getItemsAndActiveIndex(),\n items = _this$getItemsAndActi2.items,\n activeIndex = _this$getItemsAndActi2.activeIndex;\n\n if (items.length === 0) {\n return;\n }\n\n var prevIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1;\n prevIndex = prevIndex >= 0 ? prevIndex : 0;\n\n var node = _this.getElementByDataKey(items[prevIndex].refKey);\n\n node === null || node === void 0 ? void 0 : (_node$focus2 = node.focus) === null || _node$focus2 === void 0 ? void 0 : _node$focus2.call(node);\n };\n\n _this.handleCloseDropdown = function () {\n var _this$triggerRef$curr, _this$triggerRef$curr2;\n\n (_this$triggerRef$curr = _this.triggerRef.current) === null || _this$triggerRef$curr === void 0 ? void 0 : (_this$triggerRef$curr2 = _this$triggerRef$curr.hide) === null || _this$triggerRef$curr2 === void 0 ? void 0 : _this$triggerRef$curr2.call(_this$triggerRef$curr);\n };\n\n _this.handleOpenDropdown = function () {\n var _this$triggerRef$curr3, _this$triggerRef$curr4;\n\n (_this$triggerRef$curr3 = _this.triggerRef.current) === null || _this$triggerRef$curr3 === void 0 ? void 0 : (_this$triggerRef$curr4 = _this$triggerRef$curr3.show) === null || _this$triggerRef$curr4 === void 0 ? void 0 : _this$triggerRef$curr4.call(_this$triggerRef$curr3);\n };\n\n _this.open = function () {\n var _this$handleOpenDropd, _this2;\n\n (_this$handleOpenDropd = (_this2 = _this).handleOpenDropdown) === null || _this$handleOpenDropd === void 0 ? void 0 : _this$handleOpenDropd.call(_this2);\n };\n\n _this.close = function () {\n var _this$handleCloseDrop, _this3;\n\n (_this$handleCloseDrop = (_this3 = _this).handleCloseDropdown) === null || _this$handleCloseDrop === void 0 ? void 0 : _this$handleCloseDrop.call(_this3);\n };\n\n _this.handleToggleDropdown = function () {\n var active = _this.state.active;\n\n if (active) {\n _this.handleCloseDropdown();\n\n return;\n }\n\n _this.handleOpenDropdown();\n };\n\n _this.everyChildChecked = function (nodes, node) {\n var list = [];\n Object.keys(nodes).forEach(function (refKey) {\n var _curNode$parentNode;\n\n var curNode = nodes[refKey];\n\n if (((_curNode$parentNode = curNode.parentNode) === null || _curNode$parentNode === void 0 ? void 0 : _curNode$parentNode.refKey) === node.refKey && !curNode.uncheckable) {\n list.push(curNode);\n }\n });\n return list.every(function (l) {\n return l.check;\n });\n };\n\n _this.addPrefix = function (name) {\n return (0, _utils.prefix)(_this.props.classPrefix)(name);\n };\n\n _this.addTreePrefix = function (name) {\n return (0, _utils.prefix)((0, _utils.defaultClassPrefix)('check-tree'))(name);\n };\n\n _this.handleSelect = function (activeNode, event) {\n var _this$props = _this.props,\n onChange = _this$props.onChange,\n onSelect = _this$props.onSelect,\n value = _this$props.value;\n\n var selectedValues = _this.toggleChecked(activeNode, !_this.nodes[activeNode.refKey].check);\n\n if (!(0, _isUndefined2.default)(value)) {\n _this.activeNode = activeNode;\n } else {\n _this.unserializeLists({\n check: selectedValues\n });\n\n _this.setState({\n activeNode: activeNode,\n selectedValues: selectedValues,\n hasValue: !!selectedValues.length\n });\n }\n\n onChange === null || onChange === void 0 ? void 0 : onChange(selectedValues, event);\n onSelect === null || onSelect === void 0 ? void 0 : onSelect(activeNode, selectedValues, event);\n };\n\n _this.handleToggle = function (node) {\n var _this$props2 = _this.props,\n valueKey = _this$props2.valueKey,\n childrenKey = _this$props2.childrenKey,\n onExpand = _this$props2.onExpand,\n expandItemValues = _this$props2.expandItemValues;\n\n var nextExpandItemValues = _this.toggleExpand(node, !node.expand);\n\n if ((0, _isUndefined2.default)(expandItemValues)) {\n _this.unserializeLists({\n expand: nextExpandItemValues\n });\n\n _this.setState({\n expandItemValues: nextExpandItemValues\n });\n }\n\n onExpand === null || onExpand === void 0 ? void 0 : onExpand(nextExpandItemValues, node, (0, _Picker.createConcatChildrenFunction)(node, node[valueKey], {\n valueKey: valueKey,\n childrenKey: childrenKey\n }));\n };\n\n _this.handleKeyDown = function (event) {\n (0, _Picker.onMenuKeyDown)(event, {\n down: _this.focusNextItem,\n up: _this.focusPreviousItem,\n enter: _this.selectActiveItem,\n del: _this.handleClean\n });\n };\n\n _this.handleToggleKeyDown = function (event) {\n var _this$state = _this.state,\n activeNode = _this$state.activeNode,\n active = _this$state.active; // enter\n\n if ((!activeNode || !active) && event.keyCode === 13) {\n _this.handleToggleDropdown();\n } // delete\n\n\n if (event.keyCode === 8) {\n _this.handleClean(event);\n }\n\n if (!_this.treeViewRef.current) {\n return;\n }\n\n if (event.target instanceof HTMLElement) {\n var className = event.target.className;\n\n if (className.includes(_this.addPrefix('toggle')) || className.includes(_this.addPrefix('toggle-custom')) || className.includes(_this.addPrefix('search-bar-input'))) {\n (0, _Picker.onMenuKeyDown)(event, {\n down: _this.focusNextItem\n });\n }\n }\n };\n\n _this.handleSearch = function (value, event) {\n var filterData = _this.state.filterData;\n var _this$props3 = _this.props,\n onSearch = _this$props3.onSearch,\n searchKeyword = _this$props3.searchKeyword;\n\n if ((0, _isUndefined2.default)(searchKeyword)) {\n _this.setState({\n filterData: _this.getFilterData(value, filterData),\n searchKeyword: value\n });\n }\n\n onSearch === null || onSearch === void 0 ? void 0 : onSearch(value, event);\n };\n\n _this.handleClean = function (evnet) {\n var _this$props$onChange, _this$props4;\n\n _this.setState({\n selectedValues: [],\n hasValue: false,\n activeNode: {}\n });\n\n _this.unserializeLists({\n check: []\n });\n\n (_this$props$onChange = (_this$props4 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props4, [], evnet);\n };\n\n _this.handleOnOpen = function () {\n var _this$props$onOpen, _this$props5;\n\n var activeNode = _this.state.activeNode;\n\n if (activeNode) {\n var _node$focus3;\n\n var node = _this.getElementByDataKey(activeNode.refKey);\n\n node === null || node === void 0 ? void 0 : (_node$focus3 = node.focus) === null || _node$focus3 === void 0 ? void 0 : _node$focus3.call(node);\n }\n\n (_this$props$onOpen = (_this$props5 = _this.props).onOpen) === null || _this$props$onOpen === void 0 ? void 0 : _this$props$onOpen.call(_this$props5);\n\n _this.setState({\n active: true\n });\n };\n\n _this.handleOnClose = function () {\n var filterData = _this.state.filterData;\n var _this$props6 = _this.props,\n onClose = _this$props6.onClose,\n searchKeyword = _this$props6.searchKeyword;\n\n if ((0, _isUndefined2.default)(searchKeyword)) {\n _this.setState({\n filterData: _this.getFilterData('', filterData),\n searchKeyword: ''\n });\n }\n\n onClose === null || onClose === void 0 ? void 0 : onClose();\n\n _this.setState({\n active: false\n });\n };\n\n _this.measureRowRenderer = function (nodes) {\n return function (_ref) {\n var key = _ref.key,\n index = _ref.index,\n style = _ref.style,\n parent = _ref.parent;\n var node = nodes[index];\n return React.createElement(_CellMeasurer.CellMeasurer, {\n cache: _this.cache,\n columnIndex: 0,\n key: key,\n rowIndex: index,\n parent: parent,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1072\n },\n __self: this\n }, function () {\n return _this.renderVirtualNode(node, {\n key: key,\n style: style\n });\n });\n };\n };\n\n var _value = _props.value,\n data = _props.data,\n cascade = _props.cascade,\n _childrenKey = _props.childrenKey,\n _searchKeyword = _props.searchKeyword;\n _this.nodes = {};\n\n var nextValue = _this.getValue(_props);\n\n var _nextExpandItemValues = (0, _treeUtils.getExpandItemValues)(_props);\n\n var nextData = [].concat(data);\n\n _this.flattenNodes(nextData, _props);\n\n _this.unserializeLists({\n check: nextValue,\n expand: _nextExpandItemValues\n }, _props);\n\n _this.state = {\n data: data,\n value: _value,\n cascade: cascade,\n hasValue: _this.hasValue(nextValue),\n expandAll: (0, _treeUtils.getExpandAll)(_props),\n filterData: _this.getFilterData(_searchKeyword, nextData, _props),\n searchKeyword: _searchKeyword || '',\n selectedValues: nextValue,\n expandItemValues: _this.serializeList('expand'),\n uncheckableItemValues: _props.uncheckableItemValues,\n isSomeNodeHasChildren: (0, _utils2.isSomeNodeHasChildren)(data, _childrenKey)\n };\n _this.treeViewRef = React.createRef();\n _this.positionRef = React.createRef();\n _this.listRef = React.createRef();\n _this.triggerRef = React.createRef();\n _this.toggleRef = React.createRef(); // for test\n\n _this.menuRef = React.createRef();\n (0, _treeUtils.treeDeprecatedWarning)(_props, ['expandAll']);\n return _this;\n }\n\n CheckTreePicker.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {\n var value = nextProps.value,\n data = nextProps.data,\n cascade = nextProps.cascade,\n expandAll = nextProps.expandAll,\n searchKeyword = nextProps.searchKeyword,\n uncheckableItemValues = nextProps.uncheckableItemValues,\n expandItemValues = nextProps.expandItemValues;\n var nextState = {};\n\n if ((0, _isArray2.default)(data) && (0, _isArray2.default)(prevState.data) && prevState.data !== data) {\n nextState.data = data;\n }\n\n if ((0, _treeUtils.compareArray)(value, prevState.value)) {\n nextState.value = value;\n }\n\n if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues) && (0, _isArray2.default)(expandItemValues)) {\n nextState.expandItemValues = expandItemValues;\n }\n\n if ((0, _treeUtils.compareArray)(uncheckableItemValues, prevState.uncheckableItemValues) && (0, _isArray2.default)(uncheckableItemValues)) {\n nextState.uncheckableItemValues = uncheckableItemValues;\n }\n\n if (!(0, _isUndefined2.default)(searchKeyword) && searchKeyword !== prevState.searchKeyword) {\n nextState.searchKeyword = searchKeyword;\n }\n\n if (cascade !== prevState.cascade) {\n nextState.cascade = cascade;\n }\n\n if (expandAll !== prevState.expandAll) {\n nextState.expandAll = expandAll;\n }\n\n return Object.keys(nextState).length ? nextState : null;\n };\n\n var _proto = CheckTreePicker.prototype;\n\n _proto.componentDidUpdate = function componentDidUpdate(_prevProps, prevState) {\n this.updateDataChange(prevState);\n this.updateValueChange(prevState);\n this.updateExpandItemValuesChange(prevState);\n this.updateUncheckableItemValuesChange(prevState);\n this.updateCascadeChange(prevState);\n this.updateSearchKeywordChange(prevState);\n\n if (this.listRef.current) {\n this.listRef.current.forceUpdateGrid();\n }\n };\n\n _proto.updateDataChange = function updateDataChange(prevState) {\n var searchKeyword = this.state.searchKeyword;\n var _this$props7 = this.props,\n _this$props7$data = _this$props7.data,\n data = _this$props7$data === void 0 ? [] : _this$props7$data,\n childrenKey = _this$props7.childrenKey;\n\n if (prevState.data !== data) {\n var nextData = [].concat(data);\n this.nodes = {};\n this.flattenNodes(nextData);\n this.unserializeLists({\n check: this.getValue()\n });\n this.setState({\n data: nextData,\n filterData: this.getFilterData(searchKeyword, nextData),\n isSomeNodeHasChildren: (0, _utils2.isSomeNodeHasChildren)(nextData, childrenKey),\n hasValue: this.hasValue(),\n expandItemValues: this.serializeList('expand')\n });\n }\n };\n\n _proto.updateValueChange = function updateValueChange(prevState) {\n var expandItemValues = this.state.expandItemValues;\n var value = this.props.value;\n\n if ((0, _treeUtils.compareArray)(value, prevState.value)) {\n this.unserializeLists({\n check: value !== null && value !== void 0 ? value : [],\n expand: expandItemValues\n });\n this.setState({\n selectedValues: value,\n hasValue: this.hasValue(value),\n activeNode: value.length ? this.activeNode : null\n });\n }\n };\n\n _proto.updateExpandItemValuesChange = function updateExpandItemValuesChange(prevState) {\n var expandItemValues = this.props.expandItemValues;\n\n if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues) && (0, _isArray2.default)(expandItemValues)) {\n this.unserializeLists({\n expand: expandItemValues\n });\n this.setState({\n expandItemValues: expandItemValues\n });\n }\n };\n\n _proto.updateUncheckableItemValuesChange = function updateUncheckableItemValuesChange(prevState) {\n var _this$state2 = this.state,\n data = _this$state2.data,\n selectedValues = _this$state2.selectedValues,\n expandItemValues = _this$state2.expandItemValues;\n var uncheckableItemValues = this.props.uncheckableItemValues;\n\n if ((0, _treeUtils.compareArray)(uncheckableItemValues, prevState.uncheckableItemValues) && (0, _isArray2.default)(uncheckableItemValues)) {\n this.flattenNodes(data);\n this.unserializeLists({\n check: selectedValues,\n expand: expandItemValues\n });\n this.setState({\n hasValue: this.hasValue()\n });\n }\n };\n\n _proto.updateCascadeChange = function updateCascadeChange(prevState) {\n var _this$state3 = this.state,\n data = _this$state3.data,\n selectedValues = _this$state3.selectedValues,\n expandItemValues = _this$state3.expandItemValues;\n var cascade = this.props.cascade; // cascade 改变时,重新初始化\n\n if (cascade !== prevState.cascade && cascade) {\n this.flattenNodes(data);\n this.unserializeLists({\n check: selectedValues,\n expand: expandItemValues\n });\n this.setState({\n cascade: cascade\n });\n }\n };\n\n _proto.updateSearchKeywordChange = function updateSearchKeywordChange(prevState) {\n var filterData = this.state.filterData;\n var searchKeyword = this.props.searchKeyword;\n\n if (!(0, _isUndefined2.default)(searchKeyword) && prevState.searchKeyword !== searchKeyword) {\n this.setState({\n filterData: this.getFilterData(searchKeyword, filterData)\n });\n }\n };\n\n _proto.getNodeCheckState = function getNodeCheckState(node, cascade) {\n var childrenKey = this.props.childrenKey;\n\n if (!node[childrenKey] || !node[childrenKey].length || !cascade) {\n this.nodes[node.refKey].checkAll = false;\n return node.check ? _constants.CHECK_STATE.CHECK : _constants.CHECK_STATE.UNCHECK;\n }\n\n if ((0, _utils2.isEveryChildChecked)(node, this.nodes, this.props)) {\n this.nodes[node.refKey].checkAll = true;\n this.nodes[node.refKey].check = true;\n return _constants.CHECK_STATE.CHECK;\n }\n\n if ((0, _utils2.isSomeChildChecked)(node, this.nodes, this.props)) {\n this.nodes[node.refKey].checkAll = false;\n return _constants.CHECK_STATE.INDETERMINATE;\n }\n\n return _constants.CHECK_STATE.UNCHECK;\n };\n\n _proto.getFilterData = function getFilterData(searchKeyword, data, props) {\n if (searchKeyword === void 0) {\n searchKeyword = '';\n }\n\n if (props === void 0) {\n props = this.props;\n }\n\n var _props3 = props,\n labelKey = _props3.labelKey,\n childrenKey = _props3.childrenKey,\n searchBy = _props3.searchBy;\n\n var setVisible = function setVisible(nodes) {\n if (nodes === void 0) {\n nodes = [];\n }\n\n return nodes.forEach(function (item) {\n item.visible = searchBy ? searchBy(searchKeyword, item[labelKey], item) : (0, _Picker.shouldDisplay)(item[labelKey], searchKeyword);\n\n if ((0, _isArray2.default)(item[childrenKey])) {\n setVisible(item[childrenKey]);\n item[childrenKey].forEach(function (child) {\n if (child.visible) {\n item.visible = child.visible;\n }\n });\n }\n });\n };\n\n setVisible(data);\n return data;\n };\n\n _proto.getActiveElementOption = function getActiveElementOption(options, refKey) {\n var childrenKey = this.props.childrenKey;\n\n for (var i = 0; i < options.length; i += 1) {\n var _options$i$childrenKe;\n\n if (options[i].refKey === refKey) {\n return options[i];\n } else if ((_options$i$childrenKe = options[i][childrenKey]) === null || _options$i$childrenKe === void 0 ? void 0 : _options$i$childrenKe.length) {\n var active = this.getActiveElementOption(options[i][childrenKey], refKey);\n\n if (!(0, _isEmpty2.default)(active)) {\n return active;\n }\n }\n }\n\n return {};\n };\n\n _proto.getFlattenTreeData = function getFlattenTreeData(nodes) {\n var _this4 = this;\n\n var expandItemValues = this.state.expandItemValues;\n var _this$props8 = this.props,\n childrenKey = _this$props8.childrenKey,\n valueKey = _this$props8.valueKey;\n return (0, _treeUtils.flattenTree)(nodes, childrenKey, function (node) {\n var formatted = {};\n var curNode = _this4.nodes[node.refKey];\n var parentKeys = (0, _treeUtils.getNodeParents)(curNode, 'parentNode', valueKey);\n\n if (curNode) {\n formatted = (0, _extends2.default)({}, node, {\n check: curNode.check,\n expand: curNode.expand,\n uncheckable: curNode.uncheckable,\n layer: curNode.layer,\n parentNode: curNode.parentNode,\n showNode: (0, _treeUtils.shouldShowNodeByExpanded)(expandItemValues, parentKeys)\n });\n }\n\n return formatted;\n });\n };\n\n _proto.getItemsAndActiveIndex = function getItemsAndActiveIndex() {\n var items = this.getFocusableMenuItems();\n var activeIndex = -1;\n items.forEach(function (item, index) {\n if (document.activeElement !== null) {\n if (item.refKey === document.activeElement.getAttribute('data-key')) {\n activeIndex = index;\n }\n }\n });\n return {\n items: items,\n activeIndex: activeIndex\n };\n };\n\n _proto.getActiveItem = function getActiveItem() {\n var filterData = this.state.filterData;\n var activeItem = document.activeElement;\n\n if (activeItem !== null) {\n var _activeItem$dataset, _activeItem$dataset2, _this$nodes$nodeData$, _this$nodes$nodeData$2;\n\n var key = activeItem === null || activeItem === void 0 ? void 0 : (_activeItem$dataset = activeItem.dataset) === null || _activeItem$dataset === void 0 ? void 0 : _activeItem$dataset.key;\n var layer = activeItem === null || activeItem === void 0 ? void 0 : (_activeItem$dataset2 = activeItem.dataset) === null || _activeItem$dataset2 === void 0 ? void 0 : _activeItem$dataset2.layer;\n var nodeData = this.getActiveElementOption(filterData, key);\n nodeData.check = !((_this$nodes$nodeData$ = this.nodes[nodeData.refKey]) === null || _this$nodes$nodeData$ === void 0 ? void 0 : _this$nodes$nodeData$.check);\n nodeData.parentNode = (_this$nodes$nodeData$2 = this.nodes[nodeData.refKey]) === null || _this$nodes$nodeData$2 === void 0 ? void 0 : _this$nodes$nodeData$2.parentNode;\n return {\n nodeData: nodeData,\n layer: layer\n };\n }\n\n return {};\n }\n /**\n * 获取已选择的items,用于显示在placeholder\n */\n ;\n\n _proto.getSelectedItems = function getSelectedItems(selectedValues) {\n var _this5 = this;\n\n var valueKey = this.props.valueKey;\n var checkItems = [];\n Object.keys(this.nodes).map(function (refKey) {\n var node = _this5.nodes[refKey];\n\n if (selectedValues.some(function (value) {\n return (0, _shallowEqual.default)(node[valueKey], value);\n })) {\n checkItems.push(node);\n }\n });\n return checkItems;\n }\n /**\n * 判断传入的 value 是否存在于data 中\n * @param {*} values\n */\n ;\n\n _proto.hasValue = function hasValue(values) {\n var _this6 = this;\n\n if (values === void 0) {\n values = this.state.selectedValues;\n }\n\n var valueKey = this.props.valueKey;\n var selectedValues = Object.keys(this.nodes).map(function (refKey) {\n return _this6.nodes[refKey][valueKey];\n }).filter(function (item) {\n return values.some(function (v) {\n return (0, _shallowEqual.default)(v, item);\n });\n });\n return !!selectedValues.length;\n }\n /**\n * 拍平数组,将tree 转换为一维对象\n * @param {*} nodes tree data\n * @param {*} ref 当前层级\n */\n ;\n\n _proto.flattenNodes = function flattenNodes(nodes, props, ref, parentNode, layer) {\n var _this7 = this;\n\n if (ref === void 0) {\n ref = '0';\n }\n\n if (layer === void 0) {\n layer = 0;\n }\n\n var _ref2 = props || this.props,\n labelKey = _ref2.labelKey,\n valueKey = _ref2.valueKey,\n childrenKey = _ref2.childrenKey;\n\n if (!Array.isArray(nodes) || nodes.length === 0) {\n return;\n }\n\n nodes.forEach(function (node, index) {\n var _this7$nodes$refKey;\n\n var refKey = ref + \"-\" + index;\n node.refKey = refKey;\n _this7.nodes[refKey] = (_this7$nodes$refKey = {\n layer: layer\n }, _this7$nodes$refKey[labelKey] = node[labelKey], _this7$nodes$refKey[valueKey] = node[valueKey], _this7$nodes$refKey.expand = (0, _treeUtils.getExpandState)(node, props || _this7.props), _this7$nodes$refKey.uncheckable = (0, _utils2.getUncheckableState)(node, props || _this7.props), _this7$nodes$refKey.refKey = refKey, _this7$nodes$refKey);\n\n if (parentNode) {\n _this7.nodes[refKey].parentNode = parentNode;\n }\n\n _this7.flattenNodes(node[childrenKey], props, refKey, _this7.nodes[refKey], layer + 1);\n });\n }\n /**\n * 过滤选中的 values 中不包含 uncheckableItemValues 的那些值\n * @param {*} values\n */\n ;\n\n _proto.filterSelectedValues = function filterSelectedValues(values) {\n var _this$props$uncheckab = this.props.uncheckableItemValues,\n uncheckableItemValues = _this$props$uncheckab === void 0 ? [] : _this$props$uncheckab;\n return values.filter(function (value) {\n return !uncheckableItemValues.includes(value);\n });\n };\n\n _proto.serializeList = function serializeList(key, nodes) {\n if (nodes === void 0) {\n nodes = this.nodes;\n }\n\n var valueKey = this.props.valueKey;\n var list = [];\n Object.keys(nodes).forEach(function (refKey) {\n if (nodes[refKey][key]) {\n list.push(nodes[refKey][valueKey]);\n }\n });\n return list;\n };\n\n _proto.serializeListOnlyParent = function serializeListOnlyParent(key, nodes) {\n if (nodes === void 0) {\n nodes = this.nodes;\n }\n\n var valueKey = this.props.valueKey;\n var list = [];\n Object.keys(nodes).forEach(function (refKey) {\n var currentNode = nodes[refKey];\n\n if (currentNode.parentNode) {\n var _currentNode$parentNo;\n\n var parentNode = nodes[(_currentNode$parentNo = currentNode.parentNode) === null || _currentNode$parentNo === void 0 ? void 0 : _currentNode$parentNo.refKey];\n\n if (currentNode[key]) {\n if (!(parentNode === null || parentNode === void 0 ? void 0 : parentNode.checkAll)) {\n list.push(nodes[refKey][valueKey]);\n } else if (parentNode === null || parentNode === void 0 ? void 0 : parentNode.uncheckable) {\n list.push(nodes[refKey][valueKey]);\n }\n }\n } else {\n if (currentNode[key]) {\n list.push(nodes[refKey][valueKey]);\n }\n }\n });\n return list;\n };\n\n _proto.unserializeLists = function unserializeLists(lists, nextProps) {\n var _this8 = this;\n\n if (nextProps === void 0) {\n nextProps = this.props;\n }\n\n var _nextProps = nextProps,\n valueKey = _nextProps.valueKey,\n cascade = _nextProps.cascade,\n _nextProps$uncheckabl = _nextProps.uncheckableItemValues,\n uncheckableItemValues = _nextProps$uncheckabl === void 0 ? [] : _nextProps$uncheckabl;\n var expandAll = (0, _treeUtils.getExpandAll)(nextProps); // Reset values to false\n\n Object.keys(this.nodes).forEach(function (refKey) {\n Object.keys(lists).forEach(function (listKey) {\n if (listKey === 'check') {\n var node = _this8.nodes[refKey];\n\n if (cascade && 'parentNode' in node) {\n node[listKey] = node.parentNode[listKey];\n } else {\n node[listKey] = false;\n }\n\n lists[listKey].forEach(function (value) {\n if ((0, _shallowEqual.default)(_this8.nodes[refKey][valueKey], value) && !uncheckableItemValues.some(function (uncheckableValue) {\n return (0, _shallowEqual.default)(value, uncheckableValue);\n })) {\n _this8.nodes[refKey][listKey] = true;\n }\n });\n }\n\n if (listKey === 'expand') {\n _this8.nodes[refKey][listKey] = false;\n\n if (lists[listKey].length) {\n lists[listKey].forEach(function (value) {\n if ((0, _shallowEqual.default)(_this8.nodes[refKey][valueKey], value)) {\n _this8.nodes[refKey][listKey] = true;\n }\n });\n } else {\n _this8.nodes[refKey][listKey] = expandAll;\n }\n }\n });\n });\n };\n\n _proto.toggleChecked = function toggleChecked(node, isChecked) {\n var nodes = (0, _utils.clone)(this.nodes);\n this.toggleDownChecked(nodes, node, isChecked);\n node.parentNode && this.toggleUpChecked(nodes, node.parentNode, isChecked);\n var values = this.serializeListOnlyParent('check', nodes);\n return this.filterSelectedValues(values);\n };\n\n _proto.toggleUpChecked = function toggleUpChecked(nodes, node, checked) {\n var cascade = this.props.cascade;\n var currentNode = nodes[node.refKey];\n\n if (cascade) {\n if (!checked) {\n currentNode.check = checked;\n currentNode.checkAll = checked;\n } else {\n if (this.everyChildChecked(nodes, node)) {\n currentNode.check = true;\n currentNode.checkAll = true;\n } else {\n currentNode.check = false;\n currentNode.checkAll = false;\n }\n }\n\n if (node.parentNode) {\n this.toggleUpChecked(nodes, node.parentNode, checked);\n }\n }\n };\n\n _proto.toggleDownChecked = function toggleDownChecked(nodes, node, isChecked) {\n var _this9 = this;\n\n var _this$props9 = this.props,\n childrenKey = _this$props9.childrenKey,\n cascade = _this$props9.cascade;\n nodes[node.refKey].check = isChecked;\n\n if (!node[childrenKey] || !node[childrenKey].length || !cascade) {\n nodes[node.refKey].checkAll = false;\n } else {\n nodes[node.refKey].checkAll = isChecked;\n node[childrenKey].forEach(function (child) {\n _this9.toggleDownChecked(nodes, child, isChecked);\n });\n }\n };\n\n _proto.toggleNode = function toggleNode(key, node, toggleValue) {\n // 如果该节点处于 disabledCheckbox,则忽略该值\n if (!node.uncheckable) {\n this.nodes[node.refKey][key] = toggleValue;\n }\n };\n\n _proto.toggleExpand = function toggleExpand(node, isExpand) {\n var valueKey = this.props.valueKey;\n var expandItemValues = new Set(this.serializeList('expand'));\n\n if (isExpand) {\n expandItemValues.add(node[valueKey]);\n } else {\n expandItemValues.delete(node[valueKey]);\n }\n\n return Array.from(expandItemValues);\n };\n\n _proto.renderDropdownMenu = function renderDropdownMenu() {\n var _this$props10 = this.props,\n _this$props10$height = _this$props10.height,\n height = _this$props10$height === void 0 ? defaultHeight : _this$props10$height,\n locale = _this$props10.locale,\n menuStyle = _this$props10.menuStyle,\n searchable = _this$props10.searchable,\n renderMenu = _this$props10.renderMenu,\n virtualized = _this$props10.virtualized,\n searchKeyword = _this$props10.searchKeyword,\n renderExtraFooter = _this$props10.renderExtraFooter,\n menuClassName = _this$props10.menuClassName,\n menuAutoWidth = _this$props10.menuAutoWidth;\n var keyword = !(0, _isUndefined2.default)(searchKeyword) ? searchKeyword : this.state.searchKeyword;\n var classes = (0, _classnames.default)(menuClassName, this.addPrefix('check-tree-menu'));\n var menu = this.renderCheckTree();\n var styles = virtualized ? (0, _extends2.default)({\n height: height\n }, menuStyle) : menuStyle;\n return React.createElement(_Picker.MenuWrapper, {\n autoWidth: menuAutoWidth,\n className: classes,\n style: styles,\n ref: this.menuRef,\n getToggleInstance: this.getToggleInstance,\n getPositionInstance: this.getPositionInstance,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 924\n },\n __self: this\n }, searchable ? React.createElement(_Picker.SearchBar, {\n placeholder: locale.searchPlaceholder,\n key: \"searchBar\",\n onChange: this.handleSearch,\n value: keyword,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 933\n },\n __self: this\n }) : null, renderMenu ? renderMenu(menu) : menu, renderExtraFooter === null || renderExtraFooter === void 0 ? void 0 : renderExtraFooter());\n };\n\n _proto.renderNode = function renderNode(node, layer) {\n var _this10 = this;\n\n var _this$state4 = this.state,\n activeNode = _this$state4.activeNode,\n searchKeyword = _this$state4.searchKeyword;\n var _this$props11 = this.props,\n valueKey = _this$props11.valueKey,\n labelKey = _this$props11.labelKey,\n childrenKey = _this$props11.childrenKey,\n renderTreeNode = _this$props11.renderTreeNode,\n renderTreeIcon = _this$props11.renderTreeIcon,\n cascade = _this$props11.cascade,\n locale = _this$props11.locale;\n var visible = node.visible,\n refKey = node.refKey; // 当处于搜索时,需要将所有节点都展开\n\n var expand = (0, _treeUtils.getExpandWhenSearching)(searchKeyword, node.expand);\n\n if (!visible) {\n return null;\n }\n\n var key = (0, _isString2.default)(node[valueKey]) || (0, _isNumber2.default)(node[valueKey]) ? node[valueKey] : refKey;\n var children = node[childrenKey]; // 当用户进行搜索时,hasChildren的判断要变成判断是否存在 visible 为 true 的子节点\n\n var visibleChildren = (0, _isUndefined2.default)(searchKeyword) || searchKeyword.length === 0 ? !!children : (0, _treeUtils.hasVisibleChildren)(node, childrenKey);\n var props = {\n value: node[valueKey],\n label: node[labelKey],\n layer: layer,\n expand: expand,\n rtl: locale.rtl,\n focus: activeNode ? (0, _shallowEqual.default)(activeNode[valueKey], node[valueKey]) : false,\n visible: node.visible,\n disabled: (0, _utils2.getDisabledState)(this.nodes, node, this.props),\n nodeData: node,\n checkState: this.getNodeCheckState(node, cascade),\n hasChildren: visibleChildren,\n uncheckable: node.uncheckable,\n allUncheckable: (0, _utils2.getSiblingNodeUncheckable)(node, this.nodes),\n onSelect: this.handleSelect,\n onTreeToggle: this.handleToggle,\n onRenderTreeNode: renderTreeNode,\n onRenderTreeIcon: renderTreeIcon\n };\n\n if (props.hasChildren) {\n var _classNames;\n\n layer += 1; // 是否展开树节点且子节点不为空\n\n var openClass = this.addTreePrefix('open');\n var childrenClass = (0, _classnames.default)(this.addTreePrefix('node-children'), (_classNames = {}, _classNames[openClass] = expand && visibleChildren, _classNames));\n var nodes = children || [];\n return React.createElement(\"div\", {\n className: childrenClass,\n key: key,\n ref: this.bindNodeRefs.bind(this, refKey),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1004\n },\n __self: this\n }, React.createElement(_CheckTreeNode.default, (0, _extends2.default)({}, props, {\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1005\n },\n __self: this\n })), React.createElement(\"div\", {\n className: this.addTreePrefix('children'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1006\n },\n __self: this\n }, nodes.map(function (child) {\n return _this10.renderNode(child, layer);\n })));\n }\n\n return React.createElement(_CheckTreeNode.default, (0, _extends2.default)({\n key: key,\n innerRef: this.bindNodeRefs.bind(this, refKey)\n }, props, {\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1013\n },\n __self: this\n }));\n };\n\n _proto.renderVirtualNode = function renderVirtualNode(node, options) {\n var _this$state5 = this.state,\n activeNode = _this$state5.activeNode,\n expandAll = _this$state5.expandAll,\n searchKeyword = _this$state5.searchKeyword;\n var _this$props12 = this.props,\n valueKey = _this$props12.valueKey,\n labelKey = _this$props12.labelKey,\n childrenKey = _this$props12.childrenKey,\n renderTreeNode = _this$props12.renderTreeNode,\n renderTreeIcon = _this$props12.renderTreeIcon,\n cascade = _this$props12.cascade,\n locale = _this$props12.locale;\n var key = options.key,\n style = options.style;\n var layer = node.layer,\n refKey = node.refKey,\n showNode = node.showNode;\n var expand = (0, _treeUtils.getExpandWhenSearching)(searchKeyword, node.expand);\n var children = node[childrenKey];\n var props = {\n value: node[valueKey],\n label: node[labelKey],\n layer: layer,\n expand: expand,\n rtl: locale.rtl,\n focus: activeNode ? (0, _shallowEqual.default)(activeNode[valueKey], node[valueKey]) : false,\n visible: node.visible,\n disabled: (0, _utils2.getDisabledState)(this.nodes, node, this.props),\n nodeData: node,\n children: children,\n expandAll: expandAll,\n checkState: this.getNodeCheckState(node, cascade),\n parentNode: node.parentNode,\n hasChildren: !!children,\n uncheckable: node.uncheckable,\n allUncheckable: (0, _utils2.getSiblingNodeUncheckable)(node, this.nodes),\n onSelect: this.handleSelect,\n onTreeToggle: this.handleToggle,\n onRenderTreeNode: renderTreeNode,\n onRenderTreeIcon: renderTreeIcon\n };\n return showNode && React.createElement(_CheckTreeNode.default, (0, _extends2.default)({\n style: style,\n key: key,\n innerRef: this.bindNodeRefs.bind(this, refKey)\n }, props, {\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1058\n },\n __self: this\n }));\n };\n\n _proto.renderCheckTree = function renderCheckTree() {\n var _classNames2,\n _this11 = this,\n _classNames3;\n\n var _this$state6 = this.state,\n filterData = _this$state6.filterData,\n isSomeNodeHasChildren = _this$state6.isSomeNodeHasChildren;\n var _this$props13 = this.props,\n inline = _this$props13.inline,\n style = _this$props13.style,\n height = _this$props13.height,\n className = _this$props13.className,\n onScroll = _this$props13.onScroll,\n locale = _this$props13.locale,\n virtualized = _this$props13.virtualized,\n searchable = _this$props13.searchable; // 树节点的层级\n\n var layer = 0;\n var classes = (0, _classnames.default)((0, _utils.defaultClassPrefix)('check-tree'), (_classNames2 = {}, _classNames2[className] = inline, _classNames2['without-children'] = !isSomeNodeHasChildren, _classNames2));\n var formattedNodes = [];\n\n if (!virtualized) {\n formattedNodes = (0, _utils2.getFormattedTree)(filterData, this.nodes, this.props).map(function (node) {\n return _this11.renderNode(node, layer);\n });\n\n if (!formattedNodes.some(function (v) {\n return v !== null;\n })) {\n return React.createElement(\"div\", {\n className: this.addPrefix('none'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1106\n },\n __self: this\n }, locale.noResultsText);\n }\n } else {\n formattedNodes = this.getFlattenTreeData(filterData).filter(function (n) {\n return n.showNode && n.visible;\n });\n\n if (!formattedNodes.length) {\n return React.createElement(\"div\", {\n className: this.addPrefix('none'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1111\n },\n __self: this\n }, locale.noResultsText);\n }\n } // 当未定义 height 且 设置了 virtualized 为 true,treeHeight 设置默认高度\n\n\n var treeHeight = (0, _isUndefined2.default)(height) && virtualized ? defaultHeight : height;\n var treeWidth = (0, _isUndefined2.default)(style === null || style === void 0 ? void 0 : style.width) ? defaultWidth : style.width;\n var styles = inline ? (0, _extends2.default)({\n height: treeHeight\n }, style) : {};\n var treeNodesClass = (0, _classnames.default)(this.addTreePrefix('nodes'), (_classNames3 = {}, _classNames3[this.addTreePrefix('all-uncheckable')] = (0, _utils2.getEveryFisrtLevelNodeUncheckable)(this.nodes), _classNames3));\n var listHeight = (0, _treeUtils.getVirtualLisHeight)(inline, searchable, treeHeight);\n return React.createElement(\"div\", {\n ref: this.treeViewRef,\n className: classes,\n style: styles,\n onScroll: onScroll,\n onKeyDown: this.handleKeyDown,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1125\n },\n __self: this\n }, React.createElement(\"div\", {\n className: treeNodesClass,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1132\n },\n __self: this\n }, virtualized ? React.createElement(_AutoSizer.default, {\n defaultHeight: listHeight,\n defaultWidth: treeWidth,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1134\n },\n __self: this\n }, function (_ref3) {\n var height = _ref3.height,\n width = _ref3.width;\n return React.createElement(_List.default, {\n ref: _this11.listRef,\n width: width || treeWidth,\n height: height || listHeight,\n rowHeight: 36,\n rowCount: formattedNodes.length,\n rowRenderer: _this11.measureRowRenderer(formattedNodes),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1136\n },\n __self: this\n });\n }) : formattedNodes));\n };\n\n _proto.render = function render() {\n var _this$props14 = this.props,\n cascade = _this$props14.cascade,\n style = _this$props14.style,\n locale = _this$props14.locale,\n inline = _this$props14.inline,\n disabled = _this$props14.disabled,\n valueKey = _this$props14.valueKey,\n labelKey = _this$props14.labelKey,\n cleanable = _this$props14.cleanable,\n countable = _this$props14.countable,\n placeholder = _this$props14.placeholder,\n toggleComponentClass = _this$props14.toggleComponentClass,\n onExited = _this$props14.onExited,\n onEntered = _this$props14.onEntered,\n onClean = _this$props14.onClean,\n renderValue = _this$props14.renderValue,\n positionRef = _this$props14.positionRef,\n rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props14, [\"cascade\", \"style\", \"locale\", \"inline\", \"disabled\", \"valueKey\", \"labelKey\", \"cleanable\", \"countable\", \"placeholder\", \"toggleComponentClass\", \"onExited\", \"onEntered\", \"onClean\", \"renderValue\", \"positionRef\"]);\n var _this$state7 = this.state,\n hasValue = _this$state7.hasValue,\n selectedValues = _this$state7.selectedValues;\n var hasValidValue = hasValue || selectedValues.length > 0 && (0, _isFunction2.default)(renderValue);\n var selectedItems = this.getSelectedItems(selectedValues);\n var selectedElement = placeholder;\n /**\n * if value is invalid and renderValue is undefined, then using placeholder.\n * if value is valid and renderValue is't undefined, then using renderValue()\n */\n\n if (selectedValues.length) {\n if (hasValue) {\n selectedElement = React.createElement(_Picker.SelectedElement, {\n selectedItems: selectedItems,\n countable: countable,\n valueKey: valueKey,\n labelKey: labelKey,\n prefix: this.addPrefix,\n cascade: cascade,\n locale: locale,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1187\n },\n __self: this\n });\n }\n\n if ((0, _isFunction2.default)(renderValue)) {\n selectedElement = renderValue(selectedValues, selectedItems, selectedElement);\n\n if ((0, _isNil2.default)(selectedElement)) {\n hasValidValue = false;\n }\n }\n }\n\n var unhandled = (0, _utils.getUnhandledProps)(CheckTreePicker, rest);\n var classes = (0, _Picker.getToggleWrapperClassName)('check-tree', this.addPrefix, this.props, hasValidValue);\n\n if (inline) {\n return this.renderCheckTree();\n }\n\n return React.createElement(_Picker.PickerToggleTrigger, {\n pickerProps: this.props,\n ref: this.triggerRef,\n positionRef: (0, _utils.mergeRefs)(this.positionRef, positionRef),\n onEntered: (0, _utils.createChainedFunction)(this.handleOnOpen, onEntered),\n onExited: (0, _utils.createChainedFunction)(this.handleOnClose, onExited),\n speaker: this.renderDropdownMenu(),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1218\n },\n __self: this\n }, React.createElement(\"div\", {\n className: classes,\n style: style,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1226\n },\n __self: this\n }, React.createElement(_Picker.PickerToggle, (0, _extends2.default)({}, unhandled, {\n ref: this.toggleRef,\n onKeyDown: this.handleToggleKeyDown,\n onClean: (0, _utils.createChainedFunction)(this.handleClean, onClean),\n componentClass: toggleComponentClass,\n cleanable: cleanable && !disabled,\n hasValue: hasValidValue,\n active: this.state.active,\n \"aria-disabled\": disabled,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1227\n },\n __self: this\n }), selectedElement || locale.placeholder)));\n };\n\n return CheckTreePicker;\n}(React.Component);\n\nCheckTreePicker.propTypes = (0, _extends2.default)({}, _propTypes2.listPickerPropTypes, {\n height: _propTypes.default.number,\n inline: _propTypes.default.bool,\n cascade: _propTypes.default.bool,\n countable: _propTypes.default.bool,\n expandAll: _propTypes.default.bool,\n searchable: _propTypes.default.bool,\n virtualized: _propTypes.default.bool,\n searchKeyword: _propTypes.default.string,\n menuAutoWidth: _propTypes.default.bool,\n defaultExpandAll: _propTypes.default.bool,\n containerPadding: _propTypes.default.number,\n disabledItemValues: _propTypes.default.array,\n expandItemValues: _propTypes.default.array,\n defaultExpandItemValues: _propTypes.default.array,\n uncheckableItemValues: _propTypes.default.array,\n onSearch: _propTypes.default.func,\n onExpand: _propTypes.default.func,\n onSelect: _propTypes.default.func,\n onScroll: _propTypes.default.func,\n renderMenu: _propTypes.default.func,\n renderTreeNode: _propTypes.default.func,\n renderTreeIcon: _propTypes.default.func,\n searchBy: _propTypes.default.func\n});\nCheckTreePicker.defaultProps = (0, _extends2.default)({}, _propTypes2.listPickerDefaultProps, {\n cascade: true,\n countable: true,\n searchable: true,\n menuAutoWidth: true,\n defaultValue: [],\n uncheckableItemValues: [],\n locale: {\n placeholder: 'Select',\n searchPlaceholder: 'Search',\n noResultsText: 'No results found',\n checkAll: 'All'\n }\n});\n(0, _reactLifecyclesCompat.polyfill)(CheckTreePicker);\n\nvar _default = (0, _utils.defaultProps)({\n classPrefix: 'picker'\n})(CheckTreePicker);\n\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://rsuite/./src/CheckTreePicker/CheckTreePicker.tsx?");
|
|
7651
|
+
eval("\n\nvar _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ \"./node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\n\nvar _interopRequireWildcard = __webpack_require__(/*! @babel/runtime/helpers/interopRequireWildcard */ \"./node_modules/@babel/runtime/helpers/interopRequireWildcard.js\");\n\nexports.__esModule = true;\nexports.default = void 0;\n\nvar _objectWithoutPropertiesLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/objectWithoutPropertiesLoose */ \"./node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js\"));\n\nvar _extends2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/extends */ \"./node_modules/@babel/runtime/helpers/extends.js\"));\n\nvar _inheritsLoose2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/inheritsLoose */ \"./node_modules/@babel/runtime/helpers/inheritsLoose.js\"));\n\nvar _isNil2 = _interopRequireDefault(__webpack_require__(/*! lodash/isNil */ \"./node_modules/lodash/isNil.js\"));\n\nvar _isFunction2 = _interopRequireDefault(__webpack_require__(/*! lodash/isFunction */ \"./node_modules/lodash/isFunction.js\"));\n\nvar _isNumber2 = _interopRequireDefault(__webpack_require__(/*! lodash/isNumber */ \"./node_modules/lodash/isNumber.js\"));\n\nvar _isString2 = _interopRequireDefault(__webpack_require__(/*! lodash/isString */ \"./node_modules/lodash/isString.js\"));\n\nvar _isEmpty2 = _interopRequireDefault(__webpack_require__(/*! lodash/isEmpty */ \"./node_modules/lodash/isEmpty.js\"));\n\nvar _isUndefined2 = _interopRequireDefault(__webpack_require__(/*! lodash/isUndefined */ \"./node_modules/lodash/isUndefined.js\"));\n\nvar _isArray2 = _interopRequireDefault(__webpack_require__(/*! lodash/isArray */ \"./node_modules/lodash/isArray.js\"));\n\nvar React = _interopRequireWildcard(__webpack_require__(/*! react */ \"react\"));\n\nvar _propTypes = _interopRequireDefault(__webpack_require__(/*! prop-types */ \"./node_modules/prop-types/index.js\"));\n\nvar _classnames = _interopRequireDefault(__webpack_require__(/*! classnames */ \"./node_modules/classnames/index.js\"));\n\nvar _List = _interopRequireDefault(__webpack_require__(/*! react-virtualized/dist/commonjs/List */ \"./node_modules/react-virtualized/dist/commonjs/List/index.js\"));\n\nvar _AutoSizer = _interopRequireDefault(__webpack_require__(/*! react-virtualized/dist/commonjs/AutoSizer */ \"./node_modules/react-virtualized/dist/commonjs/AutoSizer/index.js\"));\n\nvar _CellMeasurer = __webpack_require__(/*! react-virtualized/dist/commonjs/CellMeasurer */ \"./node_modules/react-virtualized/dist/commonjs/CellMeasurer/index.js\");\n\nvar _reactLifecyclesCompat = __webpack_require__(/*! react-lifecycles-compat */ \"./node_modules/react-lifecycles-compat/react-lifecycles-compat.es.js\");\n\nvar _shallowEqual = _interopRequireDefault(__webpack_require__(/*! ../utils/shallowEqual */ \"./src/utils/shallowEqual.ts\"));\n\nvar _CheckTreeNode = _interopRequireDefault(__webpack_require__(/*! ./CheckTreeNode */ \"./src/CheckTreePicker/CheckTreeNode.tsx\"));\n\nvar _constants = __webpack_require__(/*! ../constants */ \"./src/constants.ts\");\n\nvar _utils = __webpack_require__(/*! ../utils */ \"./src/utils/index.ts\");\n\nvar _Picker = __webpack_require__(/*! ../Picker */ \"./src/Picker/index.ts\");\n\nvar _utils2 = __webpack_require__(/*! ./utils */ \"./src/CheckTreePicker/utils.ts\");\n\nvar _treeUtils = __webpack_require__(/*! ../utils/treeUtils */ \"./src/utils/treeUtils.ts\");\n\nvar _propTypes2 = __webpack_require__(/*! ../Picker/propTypes */ \"./src/Picker/propTypes.ts\");\n\nvar _jsxFileName = \"/home/runner/work/rsuite/rsuite/src/CheckTreePicker/CheckTreePicker.tsx\";\n// default value for virtualized\nvar defaultHeight = 360;\nvar defaultWidth = 200;\n\nvar CheckTreePicker =\n/*#__PURE__*/\nfunction (_React$Component) {\n (0, _inheritsLoose2.default)(CheckTreePicker, _React$Component);\n\n function CheckTreePicker(_props) {\n var _this;\n\n _this = _React$Component.call(this, _props) || this;\n _this.menuRef = void 0;\n _this.treeViewRef = void 0;\n _this.positionRef = void 0;\n _this.listRef = void 0;\n _this.triggerRef = void 0;\n _this.toggleRef = void 0;\n\n _this.getValue = function (props) {\n if (props === void 0) {\n props = _this.props;\n }\n\n var _props2 = props,\n value = _props2.value,\n defaultValue = _props2.defaultValue,\n _props2$uncheckableIt = _props2.uncheckableItemValues,\n uncheckableItemValues = _props2$uncheckableIt === void 0 ? [] : _props2$uncheckableIt;\n\n if (value && value.length) {\n return value.filter(function (v) {\n return !uncheckableItemValues.includes(v);\n });\n }\n\n if (defaultValue && defaultValue.length > 0) {\n return defaultValue.filter(function (v) {\n return !uncheckableItemValues.includes(v);\n });\n }\n\n return [];\n };\n\n _this.getElementByDataKey = function (dataKey) {\n var ele = _this.nodeRefs[dataKey];\n\n if (ele instanceof Element) {\n return ele.querySelector(\".\" + _this.addTreePrefix('node-label'));\n }\n\n return null;\n };\n\n _this.getFocusableMenuItems = function () {\n var filterData = _this.state.filterData;\n var childrenKey = _this.props.childrenKey;\n var items = [];\n\n var loop = function loop(treeNodes) {\n treeNodes.forEach(function (node) {\n var nodeData = (0, _extends2.default)({}, node, {}, _this.nodes[node.refKey]);\n\n if (!(0, _utils2.getDisabledState)(_this.nodes, node, _this.props) && node.visible) {\n items.push(node);\n }\n\n if (node[childrenKey] && (0, _treeUtils.getExpandState)(nodeData, _this.props)) {\n loop(node[childrenKey]);\n }\n });\n };\n\n loop(filterData);\n return items;\n };\n\n _this.nodes = {};\n _this.activeNode = null;\n _this.cache = new _CellMeasurer.CellMeasurerCache({\n fixedWidth: true,\n minHeight: 20\n });\n _this.nodeRefs = {};\n\n _this.bindNodeRefs = function (refKey, ref) {\n _this.nodeRefs[refKey] = ref;\n };\n\n _this.getPositionInstance = function () {\n return _this.positionRef.current;\n };\n\n _this.getToggleInstance = function () {\n return _this.toggleRef.current;\n };\n\n _this.selectActiveItem = function (event) {\n var _this$getActiveItem = _this.getActiveItem(),\n nodeData = _this$getActiveItem.nodeData;\n\n _this.handleSelect(nodeData, event);\n };\n\n _this.focusNextItem = function () {\n var _node$focus;\n\n var _this$getItemsAndActi = _this.getItemsAndActiveIndex(),\n items = _this$getItemsAndActi.items,\n activeIndex = _this$getItemsAndActi.activeIndex;\n\n if (items.length === 0) {\n return;\n }\n\n var nextIndex = activeIndex === items.length - 1 ? 0 : activeIndex + 1;\n\n var node = _this.getElementByDataKey(items[nextIndex].refKey);\n\n node === null || node === void 0 ? void 0 : (_node$focus = node.focus) === null || _node$focus === void 0 ? void 0 : _node$focus.call(node);\n };\n\n _this.focusPreviousItem = function () {\n var _node$focus2;\n\n var _this$getItemsAndActi2 = _this.getItemsAndActiveIndex(),\n items = _this$getItemsAndActi2.items,\n activeIndex = _this$getItemsAndActi2.activeIndex;\n\n if (items.length === 0) {\n return;\n }\n\n var prevIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1;\n prevIndex = prevIndex >= 0 ? prevIndex : 0;\n\n var node = _this.getElementByDataKey(items[prevIndex].refKey);\n\n node === null || node === void 0 ? void 0 : (_node$focus2 = node.focus) === null || _node$focus2 === void 0 ? void 0 : _node$focus2.call(node);\n };\n\n _this.handleCloseDropdown = function () {\n var _this$triggerRef$curr, _this$triggerRef$curr2;\n\n (_this$triggerRef$curr = _this.triggerRef.current) === null || _this$triggerRef$curr === void 0 ? void 0 : (_this$triggerRef$curr2 = _this$triggerRef$curr.hide) === null || _this$triggerRef$curr2 === void 0 ? void 0 : _this$triggerRef$curr2.call(_this$triggerRef$curr);\n };\n\n _this.handleOpenDropdown = function () {\n var _this$triggerRef$curr3, _this$triggerRef$curr4;\n\n (_this$triggerRef$curr3 = _this.triggerRef.current) === null || _this$triggerRef$curr3 === void 0 ? void 0 : (_this$triggerRef$curr4 = _this$triggerRef$curr3.show) === null || _this$triggerRef$curr4 === void 0 ? void 0 : _this$triggerRef$curr4.call(_this$triggerRef$curr3);\n };\n\n _this.open = function () {\n var _this$handleOpenDropd, _this2;\n\n (_this$handleOpenDropd = (_this2 = _this).handleOpenDropdown) === null || _this$handleOpenDropd === void 0 ? void 0 : _this$handleOpenDropd.call(_this2);\n };\n\n _this.close = function () {\n var _this$handleCloseDrop, _this3;\n\n (_this$handleCloseDrop = (_this3 = _this).handleCloseDropdown) === null || _this$handleCloseDrop === void 0 ? void 0 : _this$handleCloseDrop.call(_this3);\n };\n\n _this.handleToggleDropdown = function () {\n var active = _this.state.active;\n\n if (active) {\n _this.handleCloseDropdown();\n\n return;\n }\n\n _this.handleOpenDropdown();\n };\n\n _this.everyChildChecked = function (nodes, node) {\n var list = [];\n Object.keys(nodes).forEach(function (refKey) {\n var _curNode$parentNode;\n\n var curNode = nodes[refKey];\n\n if (((_curNode$parentNode = curNode.parentNode) === null || _curNode$parentNode === void 0 ? void 0 : _curNode$parentNode.refKey) === node.refKey && !curNode.uncheckable) {\n list.push(curNode);\n }\n });\n return list.every(function (l) {\n return l.check;\n });\n };\n\n _this.addPrefix = function (name) {\n return (0, _utils.prefix)(_this.props.classPrefix)(name);\n };\n\n _this.addTreePrefix = function (name) {\n return (0, _utils.prefix)((0, _utils.defaultClassPrefix)('check-tree'))(name);\n };\n\n _this.handleSelect = function (activeNode, event) {\n var _this$props = _this.props,\n onChange = _this$props.onChange,\n onSelect = _this$props.onSelect,\n value = _this$props.value;\n\n var selectedValues = _this.toggleChecked(activeNode, !_this.nodes[activeNode.refKey].check);\n\n if (!(0, _isUndefined2.default)(value)) {\n _this.activeNode = activeNode;\n } else {\n _this.unserializeLists({\n check: selectedValues\n });\n\n _this.setState({\n activeNode: activeNode,\n selectedValues: selectedValues,\n hasValue: !!selectedValues.length\n });\n }\n\n onChange === null || onChange === void 0 ? void 0 : onChange(selectedValues, event);\n onSelect === null || onSelect === void 0 ? void 0 : onSelect(activeNode, selectedValues, event);\n };\n\n _this.handleToggle = function (node) {\n var _this$props2 = _this.props,\n valueKey = _this$props2.valueKey,\n childrenKey = _this$props2.childrenKey,\n onExpand = _this$props2.onExpand,\n expandItemValues = _this$props2.expandItemValues;\n\n var nextExpandItemValues = _this.toggleExpand(node, !node.expand);\n\n if ((0, _isUndefined2.default)(expandItemValues)) {\n _this.unserializeLists({\n expand: nextExpandItemValues\n });\n\n _this.setState({\n expandItemValues: nextExpandItemValues\n });\n }\n\n onExpand === null || onExpand === void 0 ? void 0 : onExpand(nextExpandItemValues, node, (0, _Picker.createConcatChildrenFunction)(node, node[valueKey], {\n valueKey: valueKey,\n childrenKey: childrenKey\n }));\n };\n\n _this.handleKeyDown = function (event) {\n (0, _Picker.onMenuKeyDown)(event, {\n down: _this.focusNextItem,\n up: _this.focusPreviousItem,\n enter: _this.selectActiveItem,\n del: _this.handleClean\n });\n };\n\n _this.handleToggleKeyDown = function (event) {\n var _this$state = _this.state,\n activeNode = _this$state.activeNode,\n active = _this$state.active; // enter\n\n if ((!activeNode || !active) && event.keyCode === 13) {\n _this.handleToggleDropdown();\n } // delete\n\n\n if (event.keyCode === 8) {\n _this.handleClean(event);\n }\n\n if (!_this.treeViewRef.current) {\n return;\n }\n\n if (event.target instanceof HTMLElement) {\n var className = event.target.className;\n\n if (className.includes(_this.addPrefix('toggle')) || className.includes(_this.addPrefix('toggle-custom')) || className.includes(_this.addPrefix('search-bar-input'))) {\n (0, _Picker.onMenuKeyDown)(event, {\n down: _this.focusNextItem\n });\n }\n }\n };\n\n _this.handleSearch = function (value, event) {\n var filterData = _this.state.filterData;\n var _this$props3 = _this.props,\n onSearch = _this$props3.onSearch,\n searchKeyword = _this$props3.searchKeyword;\n\n if ((0, _isUndefined2.default)(searchKeyword)) {\n _this.setState({\n filterData: _this.getFilterData(value, filterData),\n searchKeyword: value\n });\n }\n\n onSearch === null || onSearch === void 0 ? void 0 : onSearch(value, event);\n };\n\n _this.handleClean = function (evnet) {\n var _this$props$onChange, _this$props4;\n\n _this.setState({\n selectedValues: [],\n hasValue: false,\n activeNode: {}\n });\n\n _this.unserializeLists({\n check: []\n });\n\n (_this$props$onChange = (_this$props4 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props4, [], evnet);\n };\n\n _this.handleOnOpen = function () {\n var _this$props$onOpen, _this$props5;\n\n var activeNode = _this.state.activeNode;\n\n if (activeNode) {\n var _node$focus3;\n\n var node = _this.getElementByDataKey(activeNode.refKey);\n\n node === null || node === void 0 ? void 0 : (_node$focus3 = node.focus) === null || _node$focus3 === void 0 ? void 0 : _node$focus3.call(node);\n }\n\n (_this$props$onOpen = (_this$props5 = _this.props).onOpen) === null || _this$props$onOpen === void 0 ? void 0 : _this$props$onOpen.call(_this$props5);\n\n _this.setState({\n active: true\n });\n };\n\n _this.handleOnClose = function () {\n var filterData = _this.state.filterData;\n var _this$props6 = _this.props,\n onClose = _this$props6.onClose,\n searchKeyword = _this$props6.searchKeyword;\n\n if ((0, _isUndefined2.default)(searchKeyword)) {\n _this.setState({\n filterData: _this.getFilterData('', filterData),\n searchKeyword: ''\n });\n }\n\n onClose === null || onClose === void 0 ? void 0 : onClose();\n\n _this.setState({\n active: false\n });\n };\n\n _this.measureRowRenderer = function (nodes) {\n return function (_ref) {\n var key = _ref.key,\n index = _ref.index,\n style = _ref.style,\n parent = _ref.parent;\n var node = nodes[index];\n return React.createElement(_CellMeasurer.CellMeasurer, {\n cache: _this.cache,\n columnIndex: 0,\n key: key,\n rowIndex: index,\n parent: parent,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1073\n },\n __self: this\n }, function () {\n return _this.renderVirtualNode(node, {\n key: key,\n style: style\n });\n });\n };\n };\n\n var _value = _props.value,\n data = _props.data,\n cascade = _props.cascade,\n _childrenKey = _props.childrenKey,\n _searchKeyword = _props.searchKeyword;\n _this.nodes = {};\n\n var nextValue = _this.getValue(_props);\n\n var _nextExpandItemValues = (0, _treeUtils.getExpandItemValues)(_props);\n\n var nextData = [].concat(data);\n\n _this.flattenNodes(nextData, _props);\n\n _this.unserializeLists({\n check: nextValue,\n expand: _nextExpandItemValues\n }, _props, true);\n\n _this.state = {\n data: data,\n value: _value,\n cascade: cascade,\n hasValue: _this.hasValue(nextValue),\n expandAll: (0, _treeUtils.getExpandAll)(_props),\n filterData: _this.getFilterData(_searchKeyword, nextData, _props),\n searchKeyword: _searchKeyword || '',\n selectedValues: nextValue,\n expandItemValues: _this.serializeList('expand'),\n uncheckableItemValues: _props.uncheckableItemValues,\n isSomeNodeHasChildren: (0, _utils2.isSomeNodeHasChildren)(data, _childrenKey)\n };\n _this.treeViewRef = React.createRef();\n _this.positionRef = React.createRef();\n _this.listRef = React.createRef();\n _this.triggerRef = React.createRef();\n _this.toggleRef = React.createRef(); // for test\n\n _this.menuRef = React.createRef();\n (0, _treeUtils.treeDeprecatedWarning)(_props, ['expandAll']);\n return _this;\n }\n\n CheckTreePicker.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {\n var value = nextProps.value,\n data = nextProps.data,\n cascade = nextProps.cascade,\n expandAll = nextProps.expandAll,\n searchKeyword = nextProps.searchKeyword,\n uncheckableItemValues = nextProps.uncheckableItemValues,\n expandItemValues = nextProps.expandItemValues;\n var nextState = {};\n\n if ((0, _isArray2.default)(data) && (0, _isArray2.default)(prevState.data) && prevState.data !== data) {\n nextState.data = data;\n }\n\n if ((0, _treeUtils.compareArray)(value, prevState.value)) {\n nextState.value = value;\n }\n\n if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues) && (0, _isArray2.default)(expandItemValues)) {\n nextState.expandItemValues = expandItemValues;\n }\n\n if ((0, _treeUtils.compareArray)(uncheckableItemValues, prevState.uncheckableItemValues) && (0, _isArray2.default)(uncheckableItemValues)) {\n nextState.uncheckableItemValues = uncheckableItemValues;\n }\n\n if (!(0, _isUndefined2.default)(searchKeyword) && searchKeyword !== prevState.searchKeyword) {\n nextState.searchKeyword = searchKeyword;\n }\n\n if (cascade !== prevState.cascade) {\n nextState.cascade = cascade;\n }\n\n if (expandAll !== prevState.expandAll) {\n nextState.expandAll = expandAll;\n }\n\n return Object.keys(nextState).length ? nextState : null;\n };\n\n var _proto = CheckTreePicker.prototype;\n\n _proto.componentDidUpdate = function componentDidUpdate(_prevProps, prevState) {\n this.updateDataChange(prevState);\n this.updateValueChange(prevState);\n this.updateExpandItemValuesChange(prevState);\n this.updateUncheckableItemValuesChange(prevState);\n this.updateCascadeChange(prevState);\n this.updateSearchKeywordChange(prevState);\n\n if (this.listRef.current) {\n this.listRef.current.forceUpdateGrid();\n }\n };\n\n _proto.updateDataChange = function updateDataChange(prevState) {\n var searchKeyword = this.state.searchKeyword;\n var _this$props7 = this.props,\n _this$props7$data = _this$props7.data,\n data = _this$props7$data === void 0 ? [] : _this$props7$data,\n childrenKey = _this$props7.childrenKey;\n\n if (prevState.data !== data) {\n var nextData = [].concat(data);\n this.nodes = {};\n this.flattenNodes(nextData);\n this.unserializeLists({\n check: this.getValue()\n });\n this.setState({\n data: nextData,\n filterData: this.getFilterData(searchKeyword, nextData),\n isSomeNodeHasChildren: (0, _utils2.isSomeNodeHasChildren)(nextData, childrenKey),\n hasValue: this.hasValue(),\n expandItemValues: this.serializeList('expand')\n });\n }\n };\n\n _proto.updateValueChange = function updateValueChange(prevState) {\n var expandItemValues = this.state.expandItemValues;\n var value = this.props.value;\n\n if ((0, _treeUtils.compareArray)(value, prevState.value)) {\n this.unserializeLists({\n check: value !== null && value !== void 0 ? value : [],\n expand: expandItemValues\n });\n this.setState({\n selectedValues: value,\n hasValue: this.hasValue(value),\n activeNode: value.length ? this.activeNode : null\n });\n }\n };\n\n _proto.updateExpandItemValuesChange = function updateExpandItemValuesChange(prevState) {\n var expandItemValues = this.props.expandItemValues;\n\n if ((0, _treeUtils.compareArray)(expandItemValues, prevState.expandItemValues) && (0, _isArray2.default)(expandItemValues)) {\n this.unserializeLists({\n expand: expandItemValues\n });\n this.setState({\n expandItemValues: expandItemValues\n });\n }\n };\n\n _proto.updateUncheckableItemValuesChange = function updateUncheckableItemValuesChange(prevState) {\n var _this$state2 = this.state,\n data = _this$state2.data,\n selectedValues = _this$state2.selectedValues,\n expandItemValues = _this$state2.expandItemValues;\n var uncheckableItemValues = this.props.uncheckableItemValues;\n\n if ((0, _treeUtils.compareArray)(uncheckableItemValues, prevState.uncheckableItemValues) && (0, _isArray2.default)(uncheckableItemValues)) {\n this.flattenNodes(data);\n this.unserializeLists({\n check: selectedValues,\n expand: expandItemValues\n });\n this.setState({\n hasValue: this.hasValue()\n });\n }\n };\n\n _proto.updateCascadeChange = function updateCascadeChange(prevState) {\n var _this$state3 = this.state,\n data = _this$state3.data,\n selectedValues = _this$state3.selectedValues,\n expandItemValues = _this$state3.expandItemValues;\n var cascade = this.props.cascade; // cascade 改变时,重新初始化\n\n if (cascade !== prevState.cascade && cascade) {\n this.flattenNodes(data);\n this.unserializeLists({\n check: selectedValues,\n expand: expandItemValues\n });\n this.setState({\n cascade: cascade\n });\n }\n };\n\n _proto.updateSearchKeywordChange = function updateSearchKeywordChange(prevState) {\n var filterData = this.state.filterData;\n var searchKeyword = this.props.searchKeyword;\n\n if (!(0, _isUndefined2.default)(searchKeyword) && prevState.searchKeyword !== searchKeyword) {\n this.setState({\n filterData: this.getFilterData(searchKeyword, filterData)\n });\n }\n };\n\n _proto.getNodeCheckState = function getNodeCheckState(node, cascade) {\n var childrenKey = this.props.childrenKey;\n\n if (!node[childrenKey] || !node[childrenKey].length || !cascade) {\n this.nodes[node.refKey].checkAll = false;\n return node.check ? _constants.CHECK_STATE.CHECK : _constants.CHECK_STATE.UNCHECK;\n }\n\n if ((0, _utils2.isEveryChildChecked)(node, this.nodes, this.props)) {\n this.nodes[node.refKey].checkAll = true;\n this.nodes[node.refKey].check = true;\n return _constants.CHECK_STATE.CHECK;\n }\n\n if ((0, _utils2.isSomeChildChecked)(node, this.nodes, this.props)) {\n this.nodes[node.refKey].checkAll = false;\n return _constants.CHECK_STATE.INDETERMINATE;\n }\n\n return _constants.CHECK_STATE.UNCHECK;\n };\n\n _proto.getFilterData = function getFilterData(searchKeyword, data, props) {\n if (searchKeyword === void 0) {\n searchKeyword = '';\n }\n\n if (props === void 0) {\n props = this.props;\n }\n\n var _props3 = props,\n labelKey = _props3.labelKey,\n childrenKey = _props3.childrenKey,\n searchBy = _props3.searchBy;\n\n var setVisible = function setVisible(nodes) {\n if (nodes === void 0) {\n nodes = [];\n }\n\n return nodes.forEach(function (item) {\n item.visible = searchBy ? searchBy(searchKeyword, item[labelKey], item) : (0, _Picker.shouldDisplay)(item[labelKey], searchKeyword);\n\n if ((0, _isArray2.default)(item[childrenKey])) {\n setVisible(item[childrenKey]);\n item[childrenKey].forEach(function (child) {\n if (child.visible) {\n item.visible = child.visible;\n }\n });\n }\n });\n };\n\n setVisible(data);\n return data;\n };\n\n _proto.getActiveElementOption = function getActiveElementOption(options, refKey) {\n var childrenKey = this.props.childrenKey;\n\n for (var i = 0; i < options.length; i += 1) {\n var _options$i$childrenKe;\n\n if (options[i].refKey === refKey) {\n return options[i];\n } else if ((_options$i$childrenKe = options[i][childrenKey]) === null || _options$i$childrenKe === void 0 ? void 0 : _options$i$childrenKe.length) {\n var active = this.getActiveElementOption(options[i][childrenKey], refKey);\n\n if (!(0, _isEmpty2.default)(active)) {\n return active;\n }\n }\n }\n\n return {};\n };\n\n _proto.getFlattenTreeData = function getFlattenTreeData(nodes) {\n var _this4 = this;\n\n var expandItemValues = this.state.expandItemValues;\n var _this$props8 = this.props,\n childrenKey = _this$props8.childrenKey,\n valueKey = _this$props8.valueKey;\n return (0, _treeUtils.flattenTree)(nodes, childrenKey, function (node) {\n var formatted = {};\n var curNode = _this4.nodes[node.refKey];\n var parentKeys = (0, _treeUtils.getNodeParents)(curNode, 'parentNode', valueKey);\n\n if (curNode) {\n formatted = (0, _extends2.default)({}, node, {\n check: curNode.check,\n expand: curNode.expand,\n uncheckable: curNode.uncheckable,\n layer: curNode.layer,\n parentNode: curNode.parentNode,\n showNode: (0, _treeUtils.shouldShowNodeByExpanded)(expandItemValues, parentKeys)\n });\n }\n\n return formatted;\n });\n };\n\n _proto.getItemsAndActiveIndex = function getItemsAndActiveIndex() {\n var items = this.getFocusableMenuItems();\n var activeIndex = -1;\n items.forEach(function (item, index) {\n if (document.activeElement !== null) {\n if (item.refKey === document.activeElement.getAttribute('data-key')) {\n activeIndex = index;\n }\n }\n });\n return {\n items: items,\n activeIndex: activeIndex\n };\n };\n\n _proto.getActiveItem = function getActiveItem() {\n var filterData = this.state.filterData;\n var activeItem = document.activeElement;\n\n if (activeItem !== null) {\n var _activeItem$dataset, _activeItem$dataset2, _this$nodes$nodeData$, _this$nodes$nodeData$2;\n\n var key = activeItem === null || activeItem === void 0 ? void 0 : (_activeItem$dataset = activeItem.dataset) === null || _activeItem$dataset === void 0 ? void 0 : _activeItem$dataset.key;\n var layer = activeItem === null || activeItem === void 0 ? void 0 : (_activeItem$dataset2 = activeItem.dataset) === null || _activeItem$dataset2 === void 0 ? void 0 : _activeItem$dataset2.layer;\n var nodeData = this.getActiveElementOption(filterData, key);\n nodeData.check = !((_this$nodes$nodeData$ = this.nodes[nodeData.refKey]) === null || _this$nodes$nodeData$ === void 0 ? void 0 : _this$nodes$nodeData$.check);\n nodeData.parentNode = (_this$nodes$nodeData$2 = this.nodes[nodeData.refKey]) === null || _this$nodes$nodeData$2 === void 0 ? void 0 : _this$nodes$nodeData$2.parentNode;\n return {\n nodeData: nodeData,\n layer: layer\n };\n }\n\n return {};\n }\n /**\n * 获取已选择的items,用于显示在placeholder\n */\n ;\n\n _proto.getSelectedItems = function getSelectedItems(selectedValues) {\n var _this5 = this;\n\n var valueKey = this.props.valueKey;\n var checkItems = [];\n Object.keys(this.nodes).map(function (refKey) {\n var node = _this5.nodes[refKey];\n\n if (selectedValues.some(function (value) {\n return (0, _shallowEqual.default)(node[valueKey], value);\n })) {\n checkItems.push(node);\n }\n });\n return checkItems;\n }\n /**\n * 判断传入的 value 是否存在于data 中\n * @param {*} values\n */\n ;\n\n _proto.hasValue = function hasValue(values) {\n var _this6 = this;\n\n if (values === void 0) {\n values = this.state.selectedValues;\n }\n\n var valueKey = this.props.valueKey;\n var selectedValues = Object.keys(this.nodes).map(function (refKey) {\n return _this6.nodes[refKey][valueKey];\n }).filter(function (item) {\n return values.some(function (v) {\n return (0, _shallowEqual.default)(v, item);\n });\n });\n return !!selectedValues.length;\n }\n /**\n * 拍平数组,将tree 转换为一维对象\n * @param {*} nodes tree data\n * @param {*} ref 当前层级\n */\n ;\n\n _proto.flattenNodes = function flattenNodes(nodes, props, ref, parentNode, layer) {\n var _this7 = this;\n\n if (ref === void 0) {\n ref = '0';\n }\n\n if (layer === void 0) {\n layer = 0;\n }\n\n var _ref2 = props || this.props,\n labelKey = _ref2.labelKey,\n valueKey = _ref2.valueKey,\n childrenKey = _ref2.childrenKey;\n\n if (!Array.isArray(nodes) || nodes.length === 0) {\n return;\n }\n\n nodes.forEach(function (node, index) {\n var _this7$nodes$refKey;\n\n var refKey = ref + \"-\" + index;\n node.refKey = refKey;\n _this7.nodes[refKey] = (_this7$nodes$refKey = {\n layer: layer\n }, _this7$nodes$refKey[labelKey] = node[labelKey], _this7$nodes$refKey[valueKey] = node[valueKey], _this7$nodes$refKey.expand = (0, _treeUtils.getExpandState)(node, props || _this7.props), _this7$nodes$refKey.uncheckable = (0, _utils2.getUncheckableState)(node, props || _this7.props), _this7$nodes$refKey.refKey = refKey, _this7$nodes$refKey);\n\n if (parentNode) {\n _this7.nodes[refKey].parentNode = parentNode;\n }\n\n _this7.flattenNodes(node[childrenKey], props, refKey, _this7.nodes[refKey], layer + 1);\n });\n }\n /**\n * 过滤选中的 values 中不包含 uncheckableItemValues 的那些值\n * @param {*} values\n */\n ;\n\n _proto.filterSelectedValues = function filterSelectedValues(values) {\n var _this$props$uncheckab = this.props.uncheckableItemValues,\n uncheckableItemValues = _this$props$uncheckab === void 0 ? [] : _this$props$uncheckab;\n return values.filter(function (value) {\n return !uncheckableItemValues.includes(value);\n });\n };\n\n _proto.serializeList = function serializeList(key, nodes) {\n if (nodes === void 0) {\n nodes = this.nodes;\n }\n\n var valueKey = this.props.valueKey;\n var list = [];\n Object.keys(nodes).forEach(function (refKey) {\n if (nodes[refKey][key]) {\n list.push(nodes[refKey][valueKey]);\n }\n });\n return list;\n };\n\n _proto.serializeListOnlyParent = function serializeListOnlyParent(key, nodes) {\n if (nodes === void 0) {\n nodes = this.nodes;\n }\n\n var valueKey = this.props.valueKey;\n var list = [];\n Object.keys(nodes).forEach(function (refKey) {\n var currentNode = nodes[refKey];\n\n if (currentNode.parentNode) {\n var _currentNode$parentNo;\n\n var parentNode = nodes[(_currentNode$parentNo = currentNode.parentNode) === null || _currentNode$parentNo === void 0 ? void 0 : _currentNode$parentNo.refKey];\n\n if (currentNode[key]) {\n if (!(parentNode === null || parentNode === void 0 ? void 0 : parentNode.checkAll)) {\n list.push(nodes[refKey][valueKey]);\n } else if (parentNode === null || parentNode === void 0 ? void 0 : parentNode.uncheckable) {\n list.push(nodes[refKey][valueKey]);\n }\n }\n } else {\n if (currentNode[key]) {\n list.push(nodes[refKey][valueKey]);\n }\n }\n });\n return list;\n };\n\n _proto.unserializeLists = function unserializeLists(lists, nextProps, initial) {\n var _this8 = this;\n\n if (nextProps === void 0) {\n nextProps = this.props;\n }\n\n if (initial === void 0) {\n initial = false;\n }\n\n var _nextProps = nextProps,\n valueKey = _nextProps.valueKey,\n cascade = _nextProps.cascade,\n _nextProps$uncheckabl = _nextProps.uncheckableItemValues,\n uncheckableItemValues = _nextProps$uncheckabl === void 0 ? [] : _nextProps$uncheckabl;\n var expandAll = (0, _treeUtils.getExpandAll)(nextProps); // Reset values to false\n\n Object.keys(this.nodes).forEach(function (refKey) {\n Object.keys(lists).forEach(function (listKey) {\n if (listKey === 'check') {\n var node = _this8.nodes[refKey];\n\n if (cascade && 'parentNode' in node) {\n node[listKey] = node.parentNode[listKey];\n } else {\n node[listKey] = false;\n }\n\n lists[listKey].forEach(function (value) {\n if ((0, _shallowEqual.default)(_this8.nodes[refKey][valueKey], value) && !uncheckableItemValues.some(function (uncheckableValue) {\n return (0, _shallowEqual.default)(value, uncheckableValue);\n })) {\n _this8.nodes[refKey][listKey] = true;\n }\n });\n }\n\n if (listKey === 'expand') {\n _this8.nodes[refKey][listKey] = false;\n\n if (lists[listKey].length) {\n lists[listKey].forEach(function (value) {\n if ((0, _shallowEqual.default)(_this8.nodes[refKey][valueKey], value)) {\n _this8.nodes[refKey][listKey] = true;\n }\n });\n } else {\n _this8.nodes[refKey][listKey] = initial ? expandAll : false;\n }\n }\n });\n });\n };\n\n _proto.toggleChecked = function toggleChecked(node, isChecked) {\n var nodes = (0, _utils.clone)(this.nodes);\n this.toggleDownChecked(nodes, node, isChecked);\n node.parentNode && this.toggleUpChecked(nodes, node.parentNode, isChecked);\n var values = this.serializeListOnlyParent('check', nodes);\n return this.filterSelectedValues(values);\n };\n\n _proto.toggleUpChecked = function toggleUpChecked(nodes, node, checked) {\n var cascade = this.props.cascade;\n var currentNode = nodes[node.refKey];\n\n if (cascade) {\n if (!checked) {\n currentNode.check = checked;\n currentNode.checkAll = checked;\n } else {\n if (this.everyChildChecked(nodes, node)) {\n currentNode.check = true;\n currentNode.checkAll = true;\n } else {\n currentNode.check = false;\n currentNode.checkAll = false;\n }\n }\n\n if (node.parentNode) {\n this.toggleUpChecked(nodes, node.parentNode, checked);\n }\n }\n };\n\n _proto.toggleDownChecked = function toggleDownChecked(nodes, node, isChecked) {\n var _this9 = this;\n\n var _this$props9 = this.props,\n childrenKey = _this$props9.childrenKey,\n cascade = _this$props9.cascade;\n nodes[node.refKey].check = isChecked;\n\n if (!node[childrenKey] || !node[childrenKey].length || !cascade) {\n nodes[node.refKey].checkAll = false;\n } else {\n nodes[node.refKey].checkAll = isChecked;\n node[childrenKey].forEach(function (child) {\n _this9.toggleDownChecked(nodes, child, isChecked);\n });\n }\n };\n\n _proto.toggleNode = function toggleNode(key, node, toggleValue) {\n // 如果该节点处于 disabledCheckbox,则忽略该值\n if (!node.uncheckable) {\n this.nodes[node.refKey][key] = toggleValue;\n }\n };\n\n _proto.toggleExpand = function toggleExpand(node, isExpand) {\n var valueKey = this.props.valueKey;\n var expandItemValues = new Set(this.serializeList('expand'));\n\n if (isExpand) {\n expandItemValues.add(node[valueKey]);\n } else {\n expandItemValues.delete(node[valueKey]);\n }\n\n return Array.from(expandItemValues);\n };\n\n _proto.renderDropdownMenu = function renderDropdownMenu() {\n var _this$props10 = this.props,\n _this$props10$height = _this$props10.height,\n height = _this$props10$height === void 0 ? defaultHeight : _this$props10$height,\n locale = _this$props10.locale,\n menuStyle = _this$props10.menuStyle,\n searchable = _this$props10.searchable,\n renderMenu = _this$props10.renderMenu,\n virtualized = _this$props10.virtualized,\n searchKeyword = _this$props10.searchKeyword,\n renderExtraFooter = _this$props10.renderExtraFooter,\n menuClassName = _this$props10.menuClassName,\n menuAutoWidth = _this$props10.menuAutoWidth;\n var keyword = !(0, _isUndefined2.default)(searchKeyword) ? searchKeyword : this.state.searchKeyword;\n var classes = (0, _classnames.default)(menuClassName, this.addPrefix('check-tree-menu'));\n var menu = this.renderCheckTree();\n var styles = virtualized ? (0, _extends2.default)({\n height: height\n }, menuStyle) : menuStyle;\n return React.createElement(_Picker.MenuWrapper, {\n autoWidth: menuAutoWidth,\n className: classes,\n style: styles,\n ref: this.menuRef,\n getToggleInstance: this.getToggleInstance,\n getPositionInstance: this.getPositionInstance,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 925\n },\n __self: this\n }, searchable ? React.createElement(_Picker.SearchBar, {\n placeholder: locale.searchPlaceholder,\n key: \"searchBar\",\n onChange: this.handleSearch,\n value: keyword,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 934\n },\n __self: this\n }) : null, renderMenu ? renderMenu(menu) : menu, renderExtraFooter === null || renderExtraFooter === void 0 ? void 0 : renderExtraFooter());\n };\n\n _proto.renderNode = function renderNode(node, layer) {\n var _this10 = this;\n\n var _this$state4 = this.state,\n activeNode = _this$state4.activeNode,\n searchKeyword = _this$state4.searchKeyword;\n var _this$props11 = this.props,\n valueKey = _this$props11.valueKey,\n labelKey = _this$props11.labelKey,\n childrenKey = _this$props11.childrenKey,\n renderTreeNode = _this$props11.renderTreeNode,\n renderTreeIcon = _this$props11.renderTreeIcon,\n cascade = _this$props11.cascade,\n locale = _this$props11.locale;\n var visible = node.visible,\n refKey = node.refKey; // 当处于搜索时,需要将所有节点都展开\n\n var expand = (0, _treeUtils.getExpandWhenSearching)(searchKeyword, node.expand);\n\n if (!visible) {\n return null;\n }\n\n var key = (0, _isString2.default)(node[valueKey]) || (0, _isNumber2.default)(node[valueKey]) ? node[valueKey] : refKey;\n var children = node[childrenKey]; // 当用户进行搜索时,hasChildren的判断要变成判断是否存在 visible 为 true 的子节点\n\n var visibleChildren = (0, _isUndefined2.default)(searchKeyword) || searchKeyword.length === 0 ? !!children : (0, _treeUtils.hasVisibleChildren)(node, childrenKey);\n var props = {\n value: node[valueKey],\n label: node[labelKey],\n layer: layer,\n expand: expand,\n rtl: locale.rtl,\n focus: activeNode ? (0, _shallowEqual.default)(activeNode[valueKey], node[valueKey]) : false,\n visible: node.visible,\n disabled: (0, _utils2.getDisabledState)(this.nodes, node, this.props),\n nodeData: node,\n checkState: this.getNodeCheckState(node, cascade),\n hasChildren: visibleChildren,\n uncheckable: node.uncheckable,\n allUncheckable: (0, _utils2.getSiblingNodeUncheckable)(node, this.nodes),\n onSelect: this.handleSelect,\n onTreeToggle: this.handleToggle,\n onRenderTreeNode: renderTreeNode,\n onRenderTreeIcon: renderTreeIcon\n };\n\n if (props.hasChildren) {\n var _classNames;\n\n layer += 1; // 是否展开树节点且子节点不为空\n\n var openClass = this.addTreePrefix('open');\n var childrenClass = (0, _classnames.default)(this.addTreePrefix('node-children'), (_classNames = {}, _classNames[openClass] = expand && visibleChildren, _classNames));\n var nodes = children || [];\n return React.createElement(\"div\", {\n className: childrenClass,\n key: key,\n ref: this.bindNodeRefs.bind(this, refKey),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1005\n },\n __self: this\n }, React.createElement(_CheckTreeNode.default, (0, _extends2.default)({}, props, {\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1006\n },\n __self: this\n })), React.createElement(\"div\", {\n className: this.addTreePrefix('children'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1007\n },\n __self: this\n }, nodes.map(function (child) {\n return _this10.renderNode(child, layer);\n })));\n }\n\n return React.createElement(_CheckTreeNode.default, (0, _extends2.default)({\n key: key,\n innerRef: this.bindNodeRefs.bind(this, refKey)\n }, props, {\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1014\n },\n __self: this\n }));\n };\n\n _proto.renderVirtualNode = function renderVirtualNode(node, options) {\n var _this$state5 = this.state,\n activeNode = _this$state5.activeNode,\n expandAll = _this$state5.expandAll,\n searchKeyword = _this$state5.searchKeyword;\n var _this$props12 = this.props,\n valueKey = _this$props12.valueKey,\n labelKey = _this$props12.labelKey,\n childrenKey = _this$props12.childrenKey,\n renderTreeNode = _this$props12.renderTreeNode,\n renderTreeIcon = _this$props12.renderTreeIcon,\n cascade = _this$props12.cascade,\n locale = _this$props12.locale;\n var key = options.key,\n style = options.style;\n var layer = node.layer,\n refKey = node.refKey,\n showNode = node.showNode;\n var expand = (0, _treeUtils.getExpandWhenSearching)(searchKeyword, node.expand);\n var children = node[childrenKey];\n var props = {\n value: node[valueKey],\n label: node[labelKey],\n layer: layer,\n expand: expand,\n rtl: locale.rtl,\n focus: activeNode ? (0, _shallowEqual.default)(activeNode[valueKey], node[valueKey]) : false,\n visible: node.visible,\n disabled: (0, _utils2.getDisabledState)(this.nodes, node, this.props),\n nodeData: node,\n children: children,\n expandAll: expandAll,\n checkState: this.getNodeCheckState(node, cascade),\n parentNode: node.parentNode,\n hasChildren: !!children,\n uncheckable: node.uncheckable,\n allUncheckable: (0, _utils2.getSiblingNodeUncheckable)(node, this.nodes),\n onSelect: this.handleSelect,\n onTreeToggle: this.handleToggle,\n onRenderTreeNode: renderTreeNode,\n onRenderTreeIcon: renderTreeIcon\n };\n return showNode && React.createElement(_CheckTreeNode.default, (0, _extends2.default)({\n style: style,\n key: key,\n innerRef: this.bindNodeRefs.bind(this, refKey)\n }, props, {\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1059\n },\n __self: this\n }));\n };\n\n _proto.renderCheckTree = function renderCheckTree() {\n var _classNames2,\n _this11 = this,\n _classNames3;\n\n var _this$state6 = this.state,\n filterData = _this$state6.filterData,\n isSomeNodeHasChildren = _this$state6.isSomeNodeHasChildren;\n var _this$props13 = this.props,\n inline = _this$props13.inline,\n style = _this$props13.style,\n height = _this$props13.height,\n className = _this$props13.className,\n onScroll = _this$props13.onScroll,\n locale = _this$props13.locale,\n virtualized = _this$props13.virtualized,\n searchable = _this$props13.searchable; // 树节点的层级\n\n var layer = 0;\n var classes = (0, _classnames.default)((0, _utils.defaultClassPrefix)('check-tree'), (_classNames2 = {}, _classNames2[className] = inline, _classNames2['without-children'] = !isSomeNodeHasChildren, _classNames2));\n var formattedNodes = [];\n\n if (!virtualized) {\n formattedNodes = (0, _utils2.getFormattedTree)(filterData, this.nodes, this.props).map(function (node) {\n return _this11.renderNode(node, layer);\n });\n\n if (!formattedNodes.some(function (v) {\n return v !== null;\n })) {\n return React.createElement(\"div\", {\n className: this.addPrefix('none'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1107\n },\n __self: this\n }, locale.noResultsText);\n }\n } else {\n formattedNodes = this.getFlattenTreeData(filterData).filter(function (n) {\n return n.showNode && n.visible;\n });\n\n if (!formattedNodes.length) {\n return React.createElement(\"div\", {\n className: this.addPrefix('none'),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1112\n },\n __self: this\n }, locale.noResultsText);\n }\n } // 当未定义 height 且 设置了 virtualized 为 true,treeHeight 设置默认高度\n\n\n var treeHeight = (0, _isUndefined2.default)(height) && virtualized ? defaultHeight : height;\n var treeWidth = (0, _isUndefined2.default)(style === null || style === void 0 ? void 0 : style.width) ? defaultWidth : style.width;\n var styles = inline ? (0, _extends2.default)({\n height: treeHeight\n }, style) : {};\n var treeNodesClass = (0, _classnames.default)(this.addTreePrefix('nodes'), (_classNames3 = {}, _classNames3[this.addTreePrefix('all-uncheckable')] = (0, _utils2.getEveryFisrtLevelNodeUncheckable)(this.nodes), _classNames3));\n var listHeight = (0, _treeUtils.getVirtualLisHeight)(inline, searchable, treeHeight);\n return React.createElement(\"div\", {\n ref: this.treeViewRef,\n className: classes,\n style: styles,\n onScroll: onScroll,\n onKeyDown: this.handleKeyDown,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1126\n },\n __self: this\n }, React.createElement(\"div\", {\n className: treeNodesClass,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1133\n },\n __self: this\n }, virtualized ? React.createElement(_AutoSizer.default, {\n defaultHeight: listHeight,\n defaultWidth: treeWidth,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1135\n },\n __self: this\n }, function (_ref3) {\n var height = _ref3.height,\n width = _ref3.width;\n return React.createElement(_List.default, {\n ref: _this11.listRef,\n width: width || treeWidth,\n height: height || listHeight,\n rowHeight: 36,\n rowCount: formattedNodes.length,\n rowRenderer: _this11.measureRowRenderer(formattedNodes),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1137\n },\n __self: this\n });\n }) : formattedNodes));\n };\n\n _proto.render = function render() {\n var _this$props14 = this.props,\n cascade = _this$props14.cascade,\n style = _this$props14.style,\n locale = _this$props14.locale,\n inline = _this$props14.inline,\n disabled = _this$props14.disabled,\n valueKey = _this$props14.valueKey,\n labelKey = _this$props14.labelKey,\n cleanable = _this$props14.cleanable,\n countable = _this$props14.countable,\n placeholder = _this$props14.placeholder,\n toggleComponentClass = _this$props14.toggleComponentClass,\n onExited = _this$props14.onExited,\n onEntered = _this$props14.onEntered,\n onClean = _this$props14.onClean,\n renderValue = _this$props14.renderValue,\n positionRef = _this$props14.positionRef,\n rest = (0, _objectWithoutPropertiesLoose2.default)(_this$props14, [\"cascade\", \"style\", \"locale\", \"inline\", \"disabled\", \"valueKey\", \"labelKey\", \"cleanable\", \"countable\", \"placeholder\", \"toggleComponentClass\", \"onExited\", \"onEntered\", \"onClean\", \"renderValue\", \"positionRef\"]);\n var _this$state7 = this.state,\n hasValue = _this$state7.hasValue,\n selectedValues = _this$state7.selectedValues;\n var hasValidValue = hasValue || selectedValues.length > 0 && (0, _isFunction2.default)(renderValue);\n var selectedItems = this.getSelectedItems(selectedValues);\n var selectedElement = placeholder;\n /**\n * if value is invalid and renderValue is undefined, then using placeholder.\n * if value is valid and renderValue is't undefined, then using renderValue()\n */\n\n if (selectedValues.length) {\n if (hasValue) {\n selectedElement = React.createElement(_Picker.SelectedElement, {\n selectedItems: selectedItems,\n countable: countable,\n valueKey: valueKey,\n labelKey: labelKey,\n prefix: this.addPrefix,\n cascade: cascade,\n locale: locale,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1188\n },\n __self: this\n });\n }\n\n if ((0, _isFunction2.default)(renderValue)) {\n selectedElement = renderValue(selectedValues, selectedItems, selectedElement);\n\n if ((0, _isNil2.default)(selectedElement)) {\n hasValidValue = false;\n }\n }\n }\n\n var unhandled = (0, _utils.getUnhandledProps)(CheckTreePicker, rest);\n var classes = (0, _Picker.getToggleWrapperClassName)('check-tree', this.addPrefix, this.props, hasValidValue);\n\n if (inline) {\n return this.renderCheckTree();\n }\n\n return React.createElement(_Picker.PickerToggleTrigger, {\n pickerProps: this.props,\n ref: this.triggerRef,\n positionRef: (0, _utils.mergeRefs)(this.positionRef, positionRef),\n onEntered: (0, _utils.createChainedFunction)(this.handleOnOpen, onEntered),\n onExited: (0, _utils.createChainedFunction)(this.handleOnClose, onExited),\n speaker: this.renderDropdownMenu(),\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1219\n },\n __self: this\n }, React.createElement(\"div\", {\n className: classes,\n style: style,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1227\n },\n __self: this\n }, React.createElement(_Picker.PickerToggle, (0, _extends2.default)({}, unhandled, {\n ref: this.toggleRef,\n onKeyDown: this.handleToggleKeyDown,\n onClean: (0, _utils.createChainedFunction)(this.handleClean, onClean),\n componentClass: toggleComponentClass,\n cleanable: cleanable && !disabled,\n hasValue: hasValidValue,\n active: this.state.active,\n \"aria-disabled\": disabled,\n __source: {\n fileName: _jsxFileName,\n lineNumber: 1228\n },\n __self: this\n }), selectedElement || locale.placeholder)));\n };\n\n return CheckTreePicker;\n}(React.Component);\n\nCheckTreePicker.propTypes = (0, _extends2.default)({}, _propTypes2.listPickerPropTypes, {\n height: _propTypes.default.number,\n inline: _propTypes.default.bool,\n cascade: _propTypes.default.bool,\n countable: _propTypes.default.bool,\n expandAll: _propTypes.default.bool,\n searchable: _propTypes.default.bool,\n virtualized: _propTypes.default.bool,\n searchKeyword: _propTypes.default.string,\n menuAutoWidth: _propTypes.default.bool,\n defaultExpandAll: _propTypes.default.bool,\n containerPadding: _propTypes.default.number,\n disabledItemValues: _propTypes.default.array,\n expandItemValues: _propTypes.default.array,\n defaultExpandItemValues: _propTypes.default.array,\n uncheckableItemValues: _propTypes.default.array,\n onSearch: _propTypes.default.func,\n onExpand: _propTypes.default.func,\n onSelect: _propTypes.default.func,\n onScroll: _propTypes.default.func,\n renderMenu: _propTypes.default.func,\n renderTreeNode: _propTypes.default.func,\n renderTreeIcon: _propTypes.default.func,\n searchBy: _propTypes.default.func\n});\nCheckTreePicker.defaultProps = (0, _extends2.default)({}, _propTypes2.listPickerDefaultProps, {\n cascade: true,\n countable: true,\n searchable: true,\n menuAutoWidth: true,\n defaultValue: [],\n uncheckableItemValues: [],\n locale: {\n placeholder: 'Select',\n searchPlaceholder: 'Search',\n noResultsText: 'No results found',\n checkAll: 'All'\n }\n});\n(0, _reactLifecyclesCompat.polyfill)(CheckTreePicker);\n\nvar _default = (0, _utils.defaultProps)({\n classPrefix: 'picker'\n})(CheckTreePicker);\n\nexports.default = _default;\nmodule.exports = exports.default;\n\n//# sourceURL=webpack://rsuite/./src/CheckTreePicker/CheckTreePicker.tsx?");
|
|
7652
7652
|
|
|
7653
7653
|
/***/ }),
|
|
7654
7654
|
|