@qsxy/element-plus-react 1.0.0-next.5 → 1.0.0-next.8

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.
Files changed (119) hide show
  1. package/dist/Avatar/Avatar.d.ts +4 -0
  2. package/dist/Avatar/Avatar.js +86 -0
  3. package/dist/Avatar/index.d.ts +2 -0
  4. package/dist/{VirtualList → Avatar}/index.js +7 -7
  5. package/dist/Avatar/typings.d.ts +21 -0
  6. package/dist/{VirtualList/interface.js → Avatar/typings.js} +3 -3
  7. package/dist/Cascader/Cascader.js +147 -182
  8. package/dist/Cascader/CascaderContext.d.ts +4 -10
  9. package/dist/Cascader/CascaderContext.js +2 -6
  10. package/dist/Cascader/CascaderDropdown.js +1 -1
  11. package/dist/Cascader/CascaderMenu.d.ts +0 -7
  12. package/dist/Cascader/CascaderMenu.js +4 -77
  13. package/dist/Cascader/Utils.d.ts +0 -2
  14. package/dist/Cascader/Utils.js +0 -44
  15. package/dist/Cascader/index.d.ts +1 -1
  16. package/dist/Cascader/typings.d.ts +2 -18
  17. package/dist/Cascader/useCascader.d.ts +1 -15
  18. package/dist/Cascader/useCascader.js +14 -41
  19. package/dist/DatePicker/DatePicker.js +5 -5
  20. package/dist/Empty/ImgEmpty.js +1 -1
  21. package/dist/Loading/Loading.js +14 -4
  22. package/dist/Tree/DirectoryTree.d.ts +6 -13
  23. package/dist/Tree/DirectoryTree.js +32 -81
  24. package/dist/Tree/DropIndicator.d.ts +4 -2
  25. package/dist/Tree/DropIndicator.js +7 -2
  26. package/dist/Tree/Indent.d.ts +2 -2
  27. package/dist/Tree/Indent.js +4 -4
  28. package/dist/Tree/MotionTreeNode.d.ts +4 -5
  29. package/dist/Tree/MotionTreeNode.js +69 -52
  30. package/dist/Tree/NodeList.d.ts +15 -11
  31. package/dist/Tree/NodeList.js +38 -29
  32. package/dist/Tree/RCTree.d.ts +77 -75
  33. package/dist/Tree/RCTree.js +199 -188
  34. package/dist/Tree/Tree.d.ts +3 -3
  35. package/dist/Tree/Tree.js +27 -27
  36. package/dist/Tree/TreeNode.d.ts +5 -90
  37. package/dist/Tree/TreeNode.js +320 -422
  38. package/dist/Tree/contextTypes.d.ts +36 -30
  39. package/dist/Tree/contextTypes.js +17 -4
  40. package/dist/Tree/index.d.ts +2 -2
  41. package/dist/Tree/typings.d.ts +60 -19
  42. package/dist/Tree/typings.js +1 -13
  43. package/dist/Tree/typings.tsx--bak +245 -0
  44. package/dist/Tree/useUnmount.d.ts +5 -0
  45. package/dist/{VirtualList/hooks/useChildren.js → Tree/useUnmount.js} +24 -16
  46. package/dist/Tree/util.d.ts +17 -21
  47. package/dist/Tree/util.js +21 -52
  48. package/dist/Tree/utils/conductUtil.d.ts +2 -2
  49. package/dist/Tree/utils/conductUtil.js +14 -3
  50. package/dist/Tree/utils/dictUtil.d.ts +7 -3
  51. package/dist/Tree/utils/dictUtil.js +49 -32
  52. package/dist/Tree/utils/diffUtil.d.ts +4 -3
  53. package/dist/Tree/utils/keyUtil.d.ts +2 -0
  54. package/dist/{VirtualList/utils/isFirefox.js → Tree/utils/keyUtil.js} +8 -7
  55. package/dist/Tree/utils/motion.js +6 -5
  56. package/dist/Tree/utils/treeUtil.d.ts +16 -18
  57. package/dist/Tree/utils/treeUtil.js +35 -14
  58. package/dist/TreeSelect/Utils.d.ts +1 -1
  59. package/dist/Util/base.d.ts +1 -1
  60. package/dist/Util/base.js +14 -2
  61. package/dist/hooks/useClassNames.d.ts +1 -0
  62. package/dist/hooks/useClassNames.js +11 -1
  63. package/dist/index.css +58 -6
  64. package/dist/index.d.ts +5 -5
  65. package/dist/index.js +3 -5
  66. package/dist/theme-chalk/avatar/index.scss +50 -0
  67. package/dist/theme-chalk/calendar/month-table.scss +1 -1
  68. package/dist/theme-chalk/index.scss +1 -0
  69. package/dist/theme-chalk/input/input.scss +5 -3
  70. package/dist/theme-chalk/loading/index.scss +5 -7
  71. package/package.json +2 -1
  72. package/dist/Tree/utils/KeyCode.d.ts +0 -436
  73. package/dist/Tree/utils/KeyCode.js +0 -550
  74. package/dist/VirtualList/Filler.d.ts +0 -16
  75. package/dist/VirtualList/Filler.js +0 -78
  76. package/dist/VirtualList/Item.d.ts +0 -7
  77. package/dist/VirtualList/Item.js +0 -37
  78. package/dist/VirtualList/ScrollBar.d.ts +0 -43
  79. package/dist/VirtualList/ScrollBar.js +0 -216
  80. package/dist/VirtualList/VirtualList.d.ts +0 -36
  81. package/dist/VirtualList/VirtualList.js +0 -280
  82. package/dist/VirtualList/hooks/useChildren.d.ts +0 -3
  83. package/dist/VirtualList/hooks/useDiffItem.d.ts +0 -2
  84. package/dist/VirtualList/hooks/useDiffItem.js +0 -39
  85. package/dist/VirtualList/hooks/useFrameWheel.d.ts +0 -6
  86. package/dist/VirtualList/hooks/useFrameWheel.js +0 -72
  87. package/dist/VirtualList/hooks/useHeights.d.ts +0 -3
  88. package/dist/VirtualList/hooks/useHeights.js +0 -83
  89. package/dist/VirtualList/hooks/useLayoutEffect.d.ts +0 -6
  90. package/dist/VirtualList/hooks/useLayoutEffect.js +0 -30
  91. package/dist/VirtualList/hooks/useMobileTouchMove.d.ts +0 -2
  92. package/dist/VirtualList/hooks/useMobileTouchMove.js +0 -92
  93. package/dist/VirtualList/hooks/useOriginScroll.d.ts +0 -2
  94. package/dist/VirtualList/hooks/useOriginScroll.js +0 -56
  95. package/dist/VirtualList/hooks/useScrollTo.d.ts +0 -5
  96. package/dist/VirtualList/hooks/useScrollTo.js +0 -111
  97. package/dist/VirtualList/index.d.ts +0 -2
  98. package/dist/VirtualList/interface.d.ts +0 -8
  99. package/dist/VirtualList/mock.d.ts +0 -6
  100. package/dist/VirtualList/mock.js +0 -29
  101. package/dist/VirtualList/utils/CacheMap.d.ts +0 -7
  102. package/dist/VirtualList/utils/CacheMap.js +0 -36
  103. package/dist/VirtualList/utils/algorithmUtil.d.ts +0 -23
  104. package/dist/VirtualList/utils/algorithmUtil.js +0 -81
  105. package/dist/VirtualList/utils/findDOMNode.d.ts +0 -5
  106. package/dist/VirtualList/utils/findDOMNode.js +0 -30
  107. package/dist/VirtualList/utils/isFirefox.d.ts +0 -2
  108. package/dist/VirtualList/utils/raf.d.ts +0 -5
  109. package/dist/VirtualList/utils/raf.js +0 -57
  110. package/dist/theme-chalk/bak/common/popup.scss +0 -47
  111. package/dist/theme-chalk/bak/common/transition.scss +0 -118
  112. package/dist/theme-chalk/bak/common/var.scss +0 -1476
  113. package/dist/theme-chalk/bak/mixins/_button.scss +0 -224
  114. package/dist/theme-chalk/bak/mixins/_col.scss +0 -38
  115. package/dist/theme-chalk/bak/mixins/_var.scss +0 -55
  116. package/dist/theme-chalk/bak/mixins/config.scss +0 -5
  117. package/dist/theme-chalk/bak/mixins/function.scss +0 -85
  118. package/dist/theme-chalk/bak/mixins/mixins.scss +0 -215
  119. package/dist/theme-chalk/bak/mixins/utils.scss +0 -39
@@ -33,19 +33,20 @@ __export(RCTree_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(RCTree_exports);
35
35
  var import_classnames = __toESM(require("classnames"));
36
- var import_react = __toESM(require("react"));
37
- var import_KeyCode = __toESM(require("./utils/KeyCode"));
38
- var import_pickAttrs = __toESM(require("./utils/pickAttrs"));
39
- var import_Util = require("../Util");
36
+ var import_KeyCode = __toESM(require("rc-util/lib/KeyCode"));
37
+ var import_pickAttrs = __toESM(require("rc-util/lib/pickAttrs"));
38
+ var import_warning = __toESM(require("rc-util/lib/warning"));
39
+ var React = __toESM(require("react"));
40
40
  var import_DropIndicator = __toESM(require("./DropIndicator"));
41
41
  var import_NodeList = __toESM(require("./NodeList"));
42
42
  var import_TreeNode = __toESM(require("./TreeNode"));
43
43
  var import_contextTypes = require("./contextTypes");
44
44
  var import_util = require("./util");
45
45
  var import_conductUtil = require("./utils/conductUtil");
46
+ var import_keyUtil = __toESM(require("./utils/keyUtil"));
46
47
  var import_treeUtil = require("./utils/treeUtil");
47
48
  var MAX_RETRY_TIMES = 10;
48
- var RCTree = class extends import_react.Component {
49
+ var Tree = class extends React.Component {
49
50
  constructor() {
50
51
  super(...arguments);
51
52
  this.destroyed = false;
@@ -88,13 +89,14 @@ var RCTree = class extends import_react.Component {
88
89
  fieldNames: (0, import_treeUtil.fillFieldNames)()
89
90
  };
90
91
  this.dragStartMousePosition = null;
92
+ this.dragNodeProps = null;
91
93
  this.currentMouseOverDroppableNodeKey = null;
92
- this.listRef = (0, import_react.createRef)();
93
- this.onNodeDragStart = (event, node) => {
94
+ this.listRef = React.createRef();
95
+ this.onNodeDragStart = (event, nodeProps) => {
94
96
  const { expandedKeys, keyEntities } = this.state;
95
97
  const { onDragStart } = this.props;
96
- const { eventKey } = node.props;
97
- this.dragNode = node;
98
+ const { eventKey } = nodeProps;
99
+ this.dragNodeProps = nodeProps;
98
100
  this.dragStartMousePosition = {
99
101
  x: event.clientX,
100
102
  y: event.clientY
@@ -107,7 +109,7 @@ var RCTree = class extends import_react.Component {
107
109
  });
108
110
  this.setExpandedKeys(newExpandedKeys);
109
111
  window.addEventListener("dragend", this.onWindowDragEnd);
110
- onDragStart == null ? void 0 : onDragStart({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(node.props) });
112
+ onDragStart == null ? void 0 : onDragStart({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(nodeProps) });
111
113
  };
112
114
  /**
113
115
  * [Legacy] Select handler is smaller than node,
@@ -116,22 +118,21 @@ var RCTree = class extends import_react.Component {
116
118
  * Better for use mouse move event to refresh drag state.
117
119
  * But let's just keep it to avoid event trigger logic change.
118
120
  */
119
- this.onNodeDragEnter = (event, node) => {
121
+ this.onNodeDragEnter = (event, nodeProps) => {
120
122
  const { expandedKeys, keyEntities, dragChildrenKeys, flattenNodes, indent } = this.state;
121
123
  const { onDragEnter, onExpand, allowDrop, direction } = this.props;
122
- const { pos, eventKey } = node.props;
123
- const { dragNode } = this;
124
+ const { pos, eventKey } = nodeProps;
124
125
  if (this.currentMouseOverDroppableNodeKey !== eventKey) {
125
126
  this.currentMouseOverDroppableNodeKey = eventKey;
126
127
  }
127
- if (!dragNode) {
128
+ if (!this.dragNodeProps) {
128
129
  this.resetDragState();
129
130
  return;
130
131
  }
131
132
  const { dropPosition, dropLevelOffset, dropTargetKey, dropContainerKey, dropTargetPos, dropAllowed, dragOverNodeKey } = (0, import_util.calcDropPosition)(
132
133
  event,
133
- dragNode,
134
- node,
134
+ this.dragNodeProps,
135
+ nodeProps,
135
136
  indent,
136
137
  this.dragStartMousePosition,
137
138
  allowDrop,
@@ -142,7 +143,7 @@ var RCTree = class extends import_react.Component {
142
143
  );
143
144
  if (
144
145
  // don't allow drop inside its children
145
- dragChildrenKeys.indexOf(dropTargetKey) !== -1 || // don't allow drop when drop is not allowed caculated by calcDropPosition
146
+ dragChildrenKeys.includes(dropTargetKey) || // don't allow drop when drop is not allowed caculated by calcDropPosition
146
147
  !dropAllowed
147
148
  ) {
148
149
  this.resetDragState();
@@ -154,28 +155,28 @@ var RCTree = class extends import_react.Component {
154
155
  Object.keys(this.delayedDragEnterLogic).forEach((key) => {
155
156
  clearTimeout(this.delayedDragEnterLogic[key]);
156
157
  });
157
- if (dragNode.props.eventKey !== node.props.eventKey) {
158
+ if (this.dragNodeProps.eventKey !== nodeProps.eventKey) {
158
159
  event.persist();
159
160
  this.delayedDragEnterLogic[pos] = window.setTimeout(() => {
160
161
  if (this.state.draggingNodeKey === null) {
161
162
  return;
162
163
  }
163
164
  let newExpandedKeys = [...expandedKeys];
164
- const entity = keyEntities[node.props.eventKey];
165
+ const entity = (0, import_keyUtil.default)(keyEntities, nodeProps.eventKey);
165
166
  if (entity && (entity.children || []).length) {
166
- newExpandedKeys = (0, import_util.arrAdd)(expandedKeys, node.props.eventKey);
167
+ newExpandedKeys = (0, import_util.arrAdd)(expandedKeys, nodeProps.eventKey);
167
168
  }
168
- if (!("expandedKeys" in this.props)) {
169
+ if (!Object.prototype.hasOwnProperty.call(this.props, "expandedKeys")) {
169
170
  this.setExpandedKeys(newExpandedKeys);
170
171
  }
171
172
  onExpand == null ? void 0 : onExpand(newExpandedKeys, {
172
- node: (0, import_treeUtil.convertNodePropsToEventData)(node.props),
173
+ node: (0, import_treeUtil.convertNodePropsToEventData)(nodeProps),
173
174
  expanded: true,
174
175
  nativeEvent: event.nativeEvent
175
176
  });
176
177
  }, 800);
177
178
  }
178
- if (dragNode.props.eventKey === dropTargetKey && dropLevelOffset === 0) {
179
+ if (this.dragNodeProps.eventKey === dropTargetKey && dropLevelOffset === 0) {
179
180
  this.resetDragState();
180
181
  return;
181
182
  }
@@ -190,21 +191,20 @@ var RCTree = class extends import_react.Component {
190
191
  });
191
192
  onDragEnter == null ? void 0 : onDragEnter({
192
193
  event,
193
- node: (0, import_treeUtil.convertNodePropsToEventData)(node.props),
194
+ node: (0, import_treeUtil.convertNodePropsToEventData)(nodeProps),
194
195
  expandedKeys
195
196
  });
196
197
  };
197
- this.onNodeDragOver = (event, node) => {
198
+ this.onNodeDragOver = (event, nodeProps) => {
198
199
  const { dragChildrenKeys, flattenNodes, keyEntities, expandedKeys, indent } = this.state;
199
200
  const { onDragOver, allowDrop, direction } = this.props;
200
- const { dragNode } = this;
201
- if (!dragNode) {
201
+ if (!this.dragNodeProps) {
202
202
  return;
203
203
  }
204
- const { dropPosition, dropLevelOffset, dropTargetKey, dropContainerKey, dropAllowed, dropTargetPos, dragOverNodeKey } = (0, import_util.calcDropPosition)(
204
+ const { dropPosition, dropLevelOffset, dropTargetKey, dropContainerKey, dropTargetPos, dropAllowed, dragOverNodeKey } = (0, import_util.calcDropPosition)(
205
205
  event,
206
- dragNode,
207
- node,
206
+ this.dragNodeProps,
207
+ nodeProps,
208
208
  indent,
209
209
  this.dragStartMousePosition,
210
210
  allowDrop,
@@ -213,10 +213,10 @@ var RCTree = class extends import_react.Component {
213
213
  expandedKeys,
214
214
  direction
215
215
  );
216
- if (dragChildrenKeys.indexOf(dropTargetKey) !== -1 || !dropAllowed) {
216
+ if (dragChildrenKeys.includes(dropTargetKey) || !dropAllowed) {
217
217
  return;
218
218
  }
219
- if (dragNode.props.eventKey === dropTargetKey && dropLevelOffset === 0) {
219
+ if (this.dragNodeProps.eventKey === dropTargetKey && dropLevelOffset === 0) {
220
220
  if (!(this.state.dropPosition === null && this.state.dropLevelOffset === null && this.state.dropTargetKey === null && this.state.dropContainerKey === null && this.state.dropTargetPos === null && this.state.dropAllowed === false && this.state.dragOverNodeKey === null)) {
221
221
  this.resetDragState();
222
222
  }
@@ -231,15 +231,15 @@ var RCTree = class extends import_react.Component {
231
231
  dragOverNodeKey
232
232
  });
233
233
  }
234
- onDragOver == null ? void 0 : onDragOver({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(node.props) });
234
+ onDragOver == null ? void 0 : onDragOver({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(nodeProps) });
235
235
  };
236
- this.onNodeDragLeave = (event, node) => {
237
- if (this.currentMouseOverDroppableNodeKey === node.props.eventKey && !event.currentTarget.contains(event.relatedTarget)) {
236
+ this.onNodeDragLeave = (event, nodeProps) => {
237
+ if (this.currentMouseOverDroppableNodeKey === nodeProps.eventKey && !event.currentTarget.contains(event.relatedTarget)) {
238
238
  this.resetDragState();
239
239
  this.currentMouseOverDroppableNodeKey = null;
240
240
  }
241
241
  const { onDragLeave } = this.props;
242
- onDragLeave == null ? void 0 : onDragLeave({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(node.props) });
242
+ onDragLeave == null ? void 0 : onDragLeave({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(nodeProps) });
243
243
  };
244
244
  // since stopPropagation() is called in treeNode
245
245
  // if onWindowDrag is called, whice means state is keeped, drag state should be cleared
@@ -248,16 +248,17 @@ var RCTree = class extends import_react.Component {
248
248
  window.removeEventListener("dragend", this.onWindowDragEnd);
249
249
  };
250
250
  // if onNodeDragEnd is called, onWindowDragEnd won't be called since stopPropagation() is called
251
- this.onNodeDragEnd = (event, node) => {
251
+ this.onNodeDragEnd = (event, nodeProps) => {
252
252
  const { onDragEnd } = this.props;
253
253
  this.setState({
254
254
  dragOverNodeKey: null
255
255
  });
256
256
  this.cleanDragState();
257
- onDragEnd == null ? void 0 : onDragEnd({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(node.props) });
258
- this.dragNode = null;
257
+ onDragEnd == null ? void 0 : onDragEnd({ event, node: (0, import_treeUtil.convertNodePropsToEventData)(nodeProps) });
258
+ this.dragNodeProps = null;
259
+ window.removeEventListener("dragend", this.onWindowDragEnd);
259
260
  };
260
- this.onNodeDrop = (event, node, outsideTree = false) => {
261
+ this.onNodeDrop = (event, _, outsideTree = false) => {
261
262
  var _a;
262
263
  const { dragChildrenKeys, dropPosition, dropTargetKey, dropTargetPos, dropAllowed } = this.state;
263
264
  if (!dropAllowed) {
@@ -273,24 +274,24 @@ var RCTree = class extends import_react.Component {
273
274
  }
274
275
  const abstractDropNodeProps = {
275
276
  ...(0, import_treeUtil.getTreeNodeProps)(dropTargetKey, this.getTreeNodeRequiredProps()),
276
- active: ((_a = this.getActiveItem()) == null ? void 0 : _a.data.key) === dropTargetKey,
277
- data: this.state.keyEntities[dropTargetKey].node
277
+ active: ((_a = this.getActiveItem()) == null ? void 0 : _a.key) === dropTargetKey,
278
+ data: (0, import_keyUtil.default)(this.state.keyEntities, dropTargetKey).node
278
279
  };
279
- const dropToChild = dragChildrenKeys.indexOf(dropTargetKey) !== -1;
280
- (0, import_Util.warning)(!dropToChild, "Can not drop to dragNode’s children node. This is a bug of rc-tree. Please report an issue.");
280
+ const dropToChild = dragChildrenKeys.includes(dropTargetKey);
281
+ (0, import_warning.default)(!dropToChild, "Can not drop to dragNodes children node. This is a bug of rc-tree. Please report an issue.");
281
282
  const posArr = (0, import_util.posToArr)(dropTargetPos);
282
283
  const dropResult = {
283
284
  event,
284
285
  node: (0, import_treeUtil.convertNodePropsToEventData)(abstractDropNodeProps),
285
- dragNode: this.dragNode ? (0, import_treeUtil.convertNodePropsToEventData)(this.dragNode.props) : null,
286
- dragNodesKeys: [this.dragNode.props.eventKey].concat(dragChildrenKeys),
286
+ dragNode: this.dragNodeProps ? (0, import_treeUtil.convertNodePropsToEventData)(this.dragNodeProps) : null,
287
+ dragNodesKeys: [this.dragNodeProps.eventKey].concat(dragChildrenKeys),
287
288
  dropToGap: dropPosition !== 0,
288
289
  dropPosition: dropPosition + Number(posArr[posArr.length - 1])
289
290
  };
290
291
  if (!outsideTree) {
291
292
  onDrop == null ? void 0 : onDrop(dropResult);
292
293
  }
293
- this.dragNode = null;
294
+ this.dragNodeProps = null;
294
295
  };
295
296
  this.cleanDragState = () => {
296
297
  const { draggingNodeKey } = this.state;
@@ -308,12 +309,32 @@ var RCTree = class extends import_react.Component {
308
309
  this.dragStartMousePosition = null;
309
310
  this.currentMouseOverDroppableNodeKey = null;
310
311
  };
312
+ this.triggerExpandActionExpand = (e, treeNode) => {
313
+ const { expandedKeys, flattenNodes } = this.state;
314
+ const { expanded, key, isLeaf } = treeNode;
315
+ if (isLeaf || e.shiftKey || e.metaKey || e.ctrlKey) {
316
+ return;
317
+ }
318
+ const node = flattenNodes.filter((nodeItem) => nodeItem.key === key)[0];
319
+ const eventNode = (0, import_treeUtil.convertNodePropsToEventData)({
320
+ ...(0, import_treeUtil.getTreeNodeProps)(key, this.getTreeNodeRequiredProps()),
321
+ data: node.data
322
+ });
323
+ this.setExpandedKeys(expanded ? (0, import_util.arrDel)(expandedKeys, key) : (0, import_util.arrAdd)(expandedKeys, key));
324
+ this.onNodeExpand(e, eventNode);
325
+ };
311
326
  this.onNodeClick = (e, treeNode) => {
312
- const { onClick } = this.props;
327
+ const { onClick, expandAction } = this.props;
328
+ if (expandAction === "click") {
329
+ this.triggerExpandActionExpand(e, treeNode);
330
+ }
313
331
  onClick == null ? void 0 : onClick(e, treeNode);
314
332
  };
315
333
  this.onNodeDoubleClick = (e, treeNode) => {
316
- const { onDoubleClick } = this.props;
334
+ const { onDoubleClick, expandAction } = this.props;
335
+ if (expandAction === "doubleClick") {
336
+ this.triggerExpandActionExpand(e, treeNode);
337
+ }
317
338
  onDoubleClick == null ? void 0 : onDoubleClick(e, treeNode);
318
339
  };
319
340
  this.onNodeSelect = (e, treeNode) => {
@@ -331,12 +352,9 @@ var RCTree = class extends import_react.Component {
331
352
  selectedKeys = (0, import_util.arrAdd)(selectedKeys, key);
332
353
  }
333
354
  const selectedNodes = selectedKeys.map((selectedKey) => {
334
- const entity = keyEntities[selectedKey];
335
- if (!entity) {
336
- return null;
337
- }
338
- return entity.node;
339
- }).filter((node) => node);
355
+ const entity = (0, import_keyUtil.default)(keyEntities, selectedKey);
356
+ return entity ? entity.node : null;
357
+ }).filter(Boolean);
340
358
  this.setUncontrolledState({ selectedKeys });
341
359
  onSelect == null ? void 0 : onSelect(selectedKeys, {
342
360
  event: "select",
@@ -361,7 +379,7 @@ var RCTree = class extends import_react.Component {
361
379
  const checkedKeys = checked ? (0, import_util.arrAdd)(oriCheckedKeys, key) : (0, import_util.arrDel)(oriCheckedKeys, key);
362
380
  const halfCheckedKeys = (0, import_util.arrDel)(oriHalfCheckedKeys, key);
363
381
  checkedObj = { checked: checkedKeys, halfChecked: halfCheckedKeys };
364
- eventObj.checkedNodes = checkedKeys.map((checkedKey) => keyEntities[checkedKey]).filter((entity) => entity).map((entity) => entity.node);
382
+ eventObj.checkedNodes = checkedKeys.map((checkedKey) => (0, import_keyUtil.default)(keyEntities, checkedKey)).filter(Boolean).map((entity) => entity.node);
365
383
  this.setUncontrolledState({ checkedKeys });
366
384
  } else {
367
385
  let { checkedKeys, halfCheckedKeys } = (0, import_conductUtil.conductCheck)([...oriCheckedKeys, key], true, keyEntities);
@@ -375,7 +393,7 @@ var RCTree = class extends import_react.Component {
375
393
  eventObj.checkedNodesPositions = [];
376
394
  eventObj.halfCheckedKeys = halfCheckedKeys;
377
395
  checkedKeys.forEach((checkedKey) => {
378
- const entity = keyEntities[checkedKey];
396
+ const entity = (0, import_keyUtil.default)(keyEntities, checkedKey);
379
397
  if (!entity) {
380
398
  return;
381
399
  }
@@ -383,24 +401,22 @@ var RCTree = class extends import_react.Component {
383
401
  eventObj.checkedNodes.push(node);
384
402
  eventObj.checkedNodesPositions.push({ node, pos });
385
403
  });
386
- this.setUncontrolledState(
387
- {
388
- checkedKeys
389
- },
390
- false,
391
- {
392
- halfCheckedKeys
393
- }
394
- );
404
+ this.setUncontrolledState({ checkedKeys }, false, { halfCheckedKeys });
395
405
  }
396
406
  onCheck == null ? void 0 : onCheck(checkedObj, eventObj);
397
407
  };
398
408
  this.onNodeLoad = (treeNode) => {
409
+ var _a;
399
410
  const { key } = treeNode;
411
+ const { keyEntities } = this.state;
412
+ const entity = (0, import_keyUtil.default)(keyEntities, key);
413
+ if ((_a = entity == null ? void 0 : entity.children) == null ? void 0 : _a.length) {
414
+ return;
415
+ }
400
416
  const loadPromise = new Promise((resolve, reject) => {
401
417
  this.setState(({ loadedKeys = [], loadingKeys = [] }) => {
402
418
  const { loadData, onLoad } = this.props;
403
- if (!loadData || loadedKeys.indexOf(key) !== -1 || loadingKeys.indexOf(key) !== -1) {
419
+ if (!loadData || loadedKeys.includes(key) || loadingKeys.includes(key)) {
404
420
  return null;
405
421
  }
406
422
  const promise = loadData(treeNode);
@@ -425,7 +441,7 @@ var RCTree = class extends import_react.Component {
425
441
  this.loadingRetryTimes[key] = (this.loadingRetryTimes[key] || 0) + 1;
426
442
  if (this.loadingRetryTimes[key] >= MAX_RETRY_TIMES) {
427
443
  const { loadedKeys: currentLoadedKeys } = this.state;
428
- (0, import_Util.warning)(false, "Retry for `loadData` many times but still failed. No more retry.");
444
+ (0, import_warning.default)(false, "Retry for `loadData` many times but still failed. No more retry.");
429
445
  this.setUncontrolledState({
430
446
  loadedKeys: (0, import_util.arrAdd)(currentLoadedKeys, key)
431
447
  });
@@ -460,13 +476,13 @@ var RCTree = class extends import_react.Component {
460
476
  this.onFocus = (...args) => {
461
477
  const { onFocus } = this.props;
462
478
  this.setState({ focused: true });
463
- onFocus == null ? void 0 : onFocus.apply(this, ...args);
479
+ onFocus == null ? void 0 : onFocus(...args);
464
480
  };
465
481
  this.onBlur = (...args) => {
466
482
  const { onBlur } = this.props;
467
483
  this.setState({ focused: false });
468
484
  this.onActiveChange(null);
469
- onBlur == null ? void 0 : onBlur.apply(this, ...args);
485
+ onBlur == null ? void 0 : onBlur(...args);
470
486
  };
471
487
  this.getTreeNodeRequiredProps = () => {
472
488
  const { expandedKeys, selectedKeys, loadedKeys, loadingKeys, checkedKeys, halfCheckedKeys, dragOverNodeKey, dropPosition, keyEntities } = this.state;
@@ -487,17 +503,7 @@ var RCTree = class extends import_react.Component {
487
503
  this.setExpandedKeys = (expandedKeys) => {
488
504
  const { treeData, fieldNames } = this.state;
489
505
  const flattenNodes = (0, import_treeUtil.flattenTreeData)(treeData, expandedKeys, fieldNames);
490
- this.setUncontrolledState(
491
- {
492
- expandedKeys,
493
- flattenNodes
494
- },
495
- true
496
- );
497
- };
498
- this.flattenTreeData = (expandedKeys) => {
499
- const { treeData, fieldNames } = this.state;
500
- return (0, import_treeUtil.flattenTreeData)(treeData, expandedKeys, fieldNames);
506
+ this.setUncontrolledState({ expandedKeys, flattenNodes }, true);
501
507
  };
502
508
  this.onNodeExpand = (e, treeNode) => {
503
509
  let { expandedKeys } = this.state;
@@ -508,14 +514,10 @@ var RCTree = class extends import_react.Component {
508
514
  if (listChanging) {
509
515
  return;
510
516
  }
511
- const index = expandedKeys.indexOf(key);
517
+ const certain = expandedKeys.includes(key);
512
518
  const targetExpanded = !expanded;
513
- (0, import_Util.warning)(expanded && index !== -1 || !expanded && index === -1, "Expand state not sync with index check");
514
- if (targetExpanded) {
515
- expandedKeys = (0, import_util.arrAdd)(expandedKeys, key);
516
- } else {
517
- expandedKeys = (0, import_util.arrDel)(expandedKeys, key);
518
- }
519
+ (0, import_warning.default)(expanded && certain || !expanded && !certain, "Expand state not sync with index check");
520
+ expandedKeys = targetExpanded ? (0, import_util.arrAdd)(expandedKeys, key) : (0, import_util.arrDel)(expandedKeys, key);
519
521
  this.setExpandedKeys(expandedKeys);
520
522
  onExpand == null ? void 0 : onExpand(expandedKeys, {
521
523
  node: treeNode,
@@ -551,13 +553,13 @@ var RCTree = class extends import_react.Component {
551
553
  // =========================== Keyboard ===========================
552
554
  this.onActiveChange = (newActiveKey) => {
553
555
  const { activeKey } = this.state;
554
- const { onActiveChange } = this.props;
556
+ const { onActiveChange, itemScrollOffset = 0 } = this.props;
555
557
  if (activeKey === newActiveKey) {
556
558
  return;
557
559
  }
558
560
  this.setState({ activeKey: newActiveKey });
559
561
  if (newActiveKey !== null) {
560
- this.scrollTo({ key: newActiveKey });
562
+ this.scrollTo({ key: newActiveKey, offset: itemScrollOffset });
561
563
  }
562
564
  onActiveChange == null ? void 0 : onActiveChange(newActiveKey);
563
565
  };
@@ -584,7 +586,7 @@ var RCTree = class extends import_react.Component {
584
586
  }
585
587
  };
586
588
  this.onKeyDown = (event) => {
587
- const { activeKey, expandedKeys, checkedKeys } = this.state;
589
+ const { activeKey, expandedKeys, checkedKeys, fieldNames } = this.state;
588
590
  const { onKeyDown, checkable, selectable } = this.props;
589
591
  switch (event.which) {
590
592
  case import_KeyCode.default.UP: {
@@ -601,7 +603,7 @@ var RCTree = class extends import_react.Component {
601
603
  const activeItem = this.getActiveItem();
602
604
  if (activeItem && activeItem.data) {
603
605
  const treeNodeRequiredProps = this.getTreeNodeRequiredProps();
604
- const expandable = activeItem.data.isLeaf === false || !!(activeItem.data.children || []).length;
606
+ const expandable = activeItem.data.isLeaf === false || !!(activeItem.data[fieldNames.children] || []).length;
605
607
  const eventNode = (0, import_treeUtil.convertNodePropsToEventData)({
606
608
  ...(0, import_treeUtil.getTreeNodeProps)(activeKey, treeNodeRequiredProps),
607
609
  data: activeItem.data,
@@ -612,7 +614,7 @@ var RCTree = class extends import_react.Component {
612
614
  if (expandable && expandedKeys.includes(activeKey)) {
613
615
  this.onNodeExpand({}, eventNode);
614
616
  } else if (activeItem.parent) {
615
- this.onActiveChange(activeItem.parent.data.key);
617
+ this.onActiveChange(activeItem.parent.key);
616
618
  }
617
619
  event.preventDefault();
618
620
  break;
@@ -621,7 +623,7 @@ var RCTree = class extends import_react.Component {
621
623
  if (expandable && !expandedKeys.includes(activeKey)) {
622
624
  this.onNodeExpand({}, eventNode);
623
625
  } else if (activeItem.children && activeItem.children.length) {
624
- this.onActiveChange(activeItem.children[0].data.key);
626
+ this.onActiveChange(activeItem.children[0].key);
625
627
  }
626
628
  event.preventDefault();
627
629
  break;
@@ -637,7 +639,7 @@ var RCTree = class extends import_react.Component {
637
639
  }
638
640
  }
639
641
  }
640
- onKeyDown == null ? void 0 : onKeyDown.call(this, event);
642
+ onKeyDown == null ? void 0 : onKeyDown(event);
641
643
  };
642
644
  /**
643
645
  * Only update the value which is not in props
@@ -648,7 +650,7 @@ var RCTree = class extends import_react.Component {
648
650
  let allPassed = true;
649
651
  const newState = {};
650
652
  Object.keys(state).forEach((name) => {
651
- if (name in this.props) {
653
+ if (Object.prototype.hasOwnProperty.call(this.props, name)) {
652
654
  allPassed = false;
653
655
  return;
654
656
  }
@@ -668,17 +670,18 @@ var RCTree = class extends import_react.Component {
668
670
  };
669
671
  }
670
672
  componentDidMount() {
673
+ this.destroyed = false;
671
674
  this.onUpdated();
672
675
  }
673
676
  componentDidUpdate() {
674
677
  this.onUpdated();
675
678
  }
676
679
  onUpdated() {
677
- const { activeKey } = this.props;
680
+ const { activeKey, itemScrollOffset = 0 } = this.props;
678
681
  if (activeKey !== void 0 && activeKey !== this.state.activeKey) {
679
682
  this.setState({ activeKey });
680
683
  if (activeKey !== null) {
681
- this.scrollTo({ key: activeKey });
684
+ this.scrollTo({ key: activeKey, offset: itemScrollOffset });
682
685
  }
683
686
  }
684
687
  }
@@ -692,7 +695,7 @@ var RCTree = class extends import_react.Component {
692
695
  prevProps: props
693
696
  };
694
697
  function needSync(name) {
695
- return !prevProps && name in props || prevProps && prevProps[name] !== props[name];
698
+ return !prevProps && Object.prototype.hasOwnProperty.call(props, name) || prevProps && prevProps[name] !== props[name];
696
699
  }
697
700
  let treeData;
698
701
  let { fieldNames } = prevState;
@@ -703,7 +706,7 @@ var RCTree = class extends import_react.Component {
703
706
  if (needSync("treeData")) {
704
707
  ({ treeData } = props);
705
708
  } else if (needSync("children")) {
706
- (0, import_Util.warning)(false, "`children` of Tree is deprecated. Please use `treeData` instead.");
709
+ (0, import_warning.default)(false, "`children` of Tree is deprecated. Please use `treeData` instead.");
707
710
  treeData = (0, import_treeUtil.convertTreeToData)(props.children);
708
711
  }
709
712
  if (treeData) {
@@ -723,7 +726,14 @@ var RCTree = class extends import_react.Component {
723
726
  } else if (!prevProps && props.defaultExpandAll) {
724
727
  const cloneKeyEntities = { ...keyEntities };
725
728
  delete cloneKeyEntities[import_NodeList.MOTION_KEY];
726
- newState.expandedKeys = Object.keys(cloneKeyEntities).map((key) => cloneKeyEntities[key].key);
729
+ const nextExpandedKeys = [];
730
+ Object.keys(cloneKeyEntities).forEach((key) => {
731
+ const entity = cloneKeyEntities[key];
732
+ if (entity.children && entity.children.length) {
733
+ nextExpandedKeys.push(entity.key);
734
+ }
735
+ });
736
+ newState.expandedKeys = nextExpandedKeys;
727
737
  } else if (!prevProps && props.defaultExpandedKeys) {
728
738
  newState.expandedKeys = props.autoExpandParent || props.defaultExpandParent ? (0, import_util.conductExpandParent)(props.defaultExpandedKeys, keyEntities) : props.defaultExpandedKeys;
729
739
  }
@@ -785,6 +795,8 @@ var RCTree = class extends import_react.Component {
785
795
  prefixCls,
786
796
  className,
787
797
  style,
798
+ styles,
799
+ classNames: treeClassNames,
788
800
  showLine,
789
801
  focusable,
790
802
  tabIndex = 0,
@@ -801,6 +813,7 @@ var RCTree = class extends import_react.Component {
801
813
  filterTreeNode,
802
814
  height,
803
815
  itemHeight,
816
+ scrollWidth,
804
817
  virtual,
805
818
  titleRender,
806
819
  dropIndicatorRender,
@@ -826,97 +839,94 @@ var RCTree = class extends import_react.Component {
826
839
  draggableConfig = {};
827
840
  }
828
841
  }
829
- return /* @__PURE__ */ import_react.default.createElement(
830
- import_contextTypes.TreeContext.Provider,
842
+ const contextValue = {
843
+ styles,
844
+ classNames: treeClassNames,
845
+ prefixCls,
846
+ selectable,
847
+ showIcon,
848
+ icon,
849
+ switcherIcon,
850
+ draggable: draggableConfig,
851
+ draggingNodeKey,
852
+ checkable,
853
+ checkStrictly,
854
+ disabled,
855
+ keyEntities,
856
+ dropLevelOffset,
857
+ dropContainerKey,
858
+ dropTargetKey,
859
+ dropPosition,
860
+ dragOverNodeKey,
861
+ indent,
862
+ direction,
863
+ dropIndicatorRender,
864
+ loadData,
865
+ filterTreeNode,
866
+ titleRender,
867
+ onNodeClick: this.onNodeClick,
868
+ onNodeDoubleClick: this.onNodeDoubleClick,
869
+ onNodeExpand: this.onNodeExpand,
870
+ onNodeSelect: this.onNodeSelect,
871
+ onNodeCheck: this.onNodeCheck,
872
+ onNodeLoad: this.onNodeLoad,
873
+ onNodeMouseEnter: this.onNodeMouseEnter,
874
+ onNodeMouseLeave: this.onNodeMouseLeave,
875
+ onNodeContextMenu: this.onNodeContextMenu,
876
+ onNodeDragStart: this.onNodeDragStart,
877
+ onNodeDragEnter: this.onNodeDragEnter,
878
+ onNodeDragOver: this.onNodeDragOver,
879
+ onNodeDragLeave: this.onNodeDragLeave,
880
+ onNodeDragEnd: this.onNodeDragEnd,
881
+ onNodeDrop: this.onNodeDrop
882
+ };
883
+ return /* @__PURE__ */ React.createElement(import_contextTypes.TreeContext.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement(
884
+ "div",
831
885
  {
832
- value: {
886
+ className: (0, import_classnames.default)(prefixCls, className, rootClassName, {
887
+ [`${prefixCls}-show-line`]: showLine,
888
+ [`${prefixCls}-focused`]: focused,
889
+ [`${prefixCls}-active-focused`]: activeKey !== null
890
+ }),
891
+ style: rootStyle
892
+ },
893
+ /* @__PURE__ */ React.createElement(
894
+ import_NodeList.default,
895
+ {
896
+ ref: this.listRef,
833
897
  prefixCls,
834
- selectable,
835
- showIcon,
836
- icon,
837
- switcherIcon,
838
- draggable: draggableConfig,
839
- draggingNodeKey,
840
- checkable,
841
- checkStrictly,
898
+ style,
899
+ data: flattenNodes,
842
900
  disabled,
843
- keyEntities,
844
- dropLevelOffset,
845
- dropContainerKey,
846
- dropTargetKey,
847
- dropPosition,
848
- dragOverNodeKey,
849
- indent,
850
- direction,
851
- dropIndicatorRender,
852
- loadData,
853
- filterTreeNode,
854
- titleRender,
855
- onNodeClick: this.onNodeClick,
856
- onNodeDoubleClick: this.onNodeDoubleClick,
857
- onNodeExpand: this.onNodeExpand,
858
- onNodeSelect: this.onNodeSelect,
859
- onNodeCheck: this.onNodeCheck,
860
- onNodeLoad: this.onNodeLoad,
861
- onNodeMouseEnter: this.onNodeMouseEnter,
862
- onNodeMouseLeave: this.onNodeMouseLeave,
863
- onNodeContextMenu: this.onNodeContextMenu,
864
- onNodeDragStart: this.onNodeDragStart,
865
- onNodeDragEnter: this.onNodeDragEnter,
866
- onNodeDragOver: this.onNodeDragOver,
867
- onNodeDragLeave: this.onNodeDragLeave,
868
- onNodeDragEnd: this.onNodeDragEnd,
869
- onNodeDrop: this.onNodeDrop
901
+ selectable,
902
+ checkable: !!checkable,
903
+ motion,
904
+ dragging: draggingNodeKey !== null,
905
+ height,
906
+ itemHeight,
907
+ virtual,
908
+ focusable,
909
+ focused,
910
+ tabIndex,
911
+ activeItem: this.getActiveItem(),
912
+ onFocus: this.onFocus,
913
+ onBlur: this.onBlur,
914
+ onKeyDown: this.onKeyDown,
915
+ onActiveChange: this.onActiveChange,
916
+ onListChangeStart: this.onListChangeStart,
917
+ onListChangeEnd: this.onListChangeEnd,
918
+ onContextMenu,
919
+ onScroll,
920
+ scrollWidth,
921
+ ...this.getTreeNodeRequiredProps(),
922
+ ...domProps
870
923
  }
871
- },
872
- /* @__PURE__ */ import_react.default.createElement(
873
- "div",
874
- {
875
- role: "tree",
876
- className: (0, import_classnames.default)(prefixCls, className, rootClassName, {
877
- [`${prefixCls}-show-line`]: showLine,
878
- [`${prefixCls}-focused`]: focused,
879
- [`${prefixCls}-active-focused`]: activeKey !== null
880
- }),
881
- style: rootStyle
882
- },
883
- /* @__PURE__ */ import_react.default.createElement(
884
- import_NodeList.default,
885
- {
886
- ref: this.listRef,
887
- prefixCls,
888
- style,
889
- data: flattenNodes,
890
- disabled,
891
- selectable,
892
- checkable: !!checkable,
893
- motion,
894
- dragging: draggingNodeKey !== null,
895
- height,
896
- itemHeight,
897
- virtual,
898
- focusable,
899
- focused,
900
- tabIndex,
901
- activeItem: this.getActiveItem(),
902
- onFocus: this.onFocus,
903
- onBlur: this.onBlur,
904
- onKeyDown: this.onKeyDown,
905
- onActiveChange: this.onActiveChange,
906
- onListChangeStart: this.onListChangeStart,
907
- onListChangeEnd: this.onListChangeEnd,
908
- onContextMenu,
909
- onScroll,
910
- ...this.getTreeNodeRequiredProps(),
911
- ...domProps
912
- }
913
- )
914
924
  )
915
- );
925
+ ));
916
926
  }
917
927
  };
918
- RCTree.defaultProps = {
919
- prefixCls: "r-tree",
928
+ Tree.defaultProps = {
929
+ prefixCls: "el-tree",
920
930
  showLine: false,
921
931
  showIcon: true,
922
932
  selectable: true,
@@ -932,7 +942,8 @@ RCTree.defaultProps = {
932
942
  defaultCheckedKeys: [],
933
943
  defaultSelectedKeys: [],
934
944
  dropIndicatorRender: import_DropIndicator.default,
935
- allowDrop: () => true
945
+ allowDrop: () => true,
946
+ expandAction: false
936
947
  };
937
- RCTree.TreeNode = import_TreeNode.default;
938
- var RCTree_default = RCTree;
948
+ Tree.TreeNode = import_TreeNode.default;
949
+ var RCTree_default = Tree;