@lemon-fe/components 1.4.22-alpha.7 → 1.4.22-alpha.9

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.
@@ -1,5 +1,5 @@
1
1
  var _excluded = ["tabs", "children"],
2
- _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "filterNode", "operation", "header", "footer", "height", "filterKeepParents", "filterKeepDescendants", "highlightKeywords"];
2
+ _excluded2 = ["data", "showSearch", "placeholder", "onSelect", "filterNode", "operation", "header", "footer", "height", "filterKeepParents", "filterKeepDescendants", "highlightKeywords", "onScroll"];
3
3
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
4
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
5
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -14,7 +14,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
14
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
15
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
16
16
  import { Input, Tabs, Tree } from 'antd';
17
- import React, { useMemo, useState } from 'react';
17
+ import React, { useCallback, useMemo, useRef, useState } from 'react';
18
18
  import { EmptyImage } from "../empty";
19
19
  import Icons from "../icons";
20
20
  import { useLocaleReceiver } from "../locale-receiver";
@@ -76,6 +76,7 @@ export default function SiderTree(props) {
76
76
  filterKeepParents = props.filterKeepParents,
77
77
  filterKeepDescendants = props.filterKeepDescendants,
78
78
  highlightKeywords = props.highlightKeywords,
79
+ onScroll = props.onScroll,
79
80
  restProps = _objectWithoutProperties(props, _excluded2);
80
81
  var _useState = useState(''),
81
82
  _useState2 = _slicedToArray(_useState, 2),
@@ -169,6 +170,15 @@ export default function SiderTree(props) {
169
170
  });
170
171
  }
171
172
  var prefixCls = prefix();
173
+
174
+ /** 解决Firefox 元素隐藏后,列表的scrollTop会被重置,但是rc-tree没有监听到的问题 */
175
+ var list = useRef(null);
176
+ var shouldRecoverScroll = useRef(false);
177
+ var scrollTop = useRef(0);
178
+ var handleScroll = useCallback(function (e) {
179
+ scrollTop.current = e.currentTarget.scrollTop;
180
+ onScroll === null || onScroll === void 0 || onScroll(e);
181
+ }, [onScroll]);
172
182
  var bodyContent = tree.length <= 0 ? /*#__PURE__*/React.createElement("div", {
173
183
  className: prefix('empty')
174
184
  }, /*#__PURE__*/React.createElement(EmptyImage, null), /*#__PURE__*/React.createElement("div", null, SiderTreeLocale.noDataText)) : /*#__PURE__*/React.createElement(Tree, _extends({
@@ -177,6 +187,7 @@ export default function SiderTree(props) {
177
187
  itemHeight: 28,
178
188
  showLine: true,
179
189
  height: height,
190
+ ref: list,
180
191
  titleRender: function titleRender(node) {
181
192
  return /*#__PURE__*/React.createElement(TreeNodeTitle, {
182
193
  operation: operation,
@@ -199,7 +210,8 @@ export default function SiderTree(props) {
199
210
  verticalAlign: '-0.125em'
200
211
  }
201
212
  });
202
- }
213
+ },
214
+ onScroll: handleScroll
203
215
  }, restProps));
204
216
  return /*#__PURE__*/React.createElement("div", {
205
217
  className: prefix('wrapper')
@@ -209,6 +221,15 @@ export default function SiderTree(props) {
209
221
  onResize: function onResize(e) {
210
222
  if (e.height) {
211
223
  setHeight(e.height);
224
+ if (shouldRecoverScroll.current) {
225
+ shouldRecoverScroll.current = false;
226
+ if (scrollTop.current) {
227
+ var _list$current;
228
+ (_list$current = list.current) === null || _list$current === void 0 || _list$current.scrollTo(scrollTop.current);
229
+ }
230
+ }
231
+ } else {
232
+ shouldRecoverScroll.current = true;
212
233
  }
213
234
  }
214
235
  }, /*#__PURE__*/React.createElement("div", {
@@ -216,7 +237,7 @@ export default function SiderTree(props) {
216
237
  style: {
217
238
  flex: 1
218
239
  }
219
- }, bodyContent)) : /*#__PURE__*/React.createElement("div", {
240
+ }, height ? bodyContent : null)) : /*#__PURE__*/React.createElement("div", {
220
241
  className: prefix('body')
221
242
  }, bodyContent), !!footer && /*#__PURE__*/React.createElement("div", {
222
243
  className: prefix('footer')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/components",
3
- "version": "1.4.22-alpha.7",
3
+ "version": "1.4.22-alpha.9",
4
4
  "description": "> TODO: description",
5
5
  "homepage": "",
6
6
  "license": "MIT",
@@ -58,5 +58,5 @@
58
58
  "publishConfig": {
59
59
  "registry": "https://registry.npmjs.org"
60
60
  },
61
- "gitHead": "b8a1624870c5bbf87f9a3b363e9742269c46b28c"
61
+ "gitHead": "bc70577102696abab10fb21da93d27306a2ef222"
62
62
  }