@kdcloudjs/kdesign 1.3.9 → 1.5.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.
Files changed (74) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/kdesign-complete.less +89 -44
  3. package/dist/kdesign.css +98 -55
  4. package/dist/kdesign.css.map +1 -1
  5. package/dist/kdesign.js +418 -262
  6. package/dist/kdesign.js.map +1 -1
  7. package/dist/kdesign.min.css +3 -3
  8. package/dist/kdesign.min.js +8 -8
  9. package/dist/kdesign.min.js.map +1 -1
  10. package/es/carousel/carousel.js +4 -4
  11. package/es/config-provider/compDefaultProps.d.ts +0 -1
  12. package/es/config-provider/compDefaultProps.js +0 -1
  13. package/es/date-picker/range-picker.d.ts +1 -0
  14. package/es/date-picker/range-picker.js +2 -0
  15. package/es/date-picker/style/index.css +6 -3
  16. package/es/date-picker/style/index.less +7 -3
  17. package/es/dropdown/style/index.css +3 -0
  18. package/es/dropdown/style/index.less +4 -0
  19. package/es/dropdown/style/token.less +1 -0
  20. package/es/input/style/index.css +8 -0
  21. package/es/input/style/index.less +4 -0
  22. package/es/input/style/mixin.less +6 -1
  23. package/es/menu/menu.d.ts +1 -0
  24. package/es/menu/menu.js +13 -14
  25. package/es/menu/menuItem.js +13 -3
  26. package/es/menu/style/index.css +50 -50
  27. package/es/menu/style/index.less +15 -15
  28. package/es/menu/style/mixin.less +24 -24
  29. package/es/menu/subMenu.js +19 -13
  30. package/es/radio/radio.js +6 -1
  31. package/es/tree/style/index.css +30 -1
  32. package/es/tree/style/index.less +25 -1
  33. package/es/tree/style/token.less +3 -0
  34. package/es/tree/tree.d.ts +2 -0
  35. package/es/tree/tree.js +77 -12
  36. package/es/tree/treeHooks.d.ts +1 -1
  37. package/es/tree/treeHooks.js +3 -3
  38. package/es/tree/treeNode.d.ts +1 -0
  39. package/es/tree/treeNode.js +11 -8
  40. package/es/tree/utils/treeUtils.d.ts +4 -2
  41. package/es/tree/utils/treeUtils.js +64 -10
  42. package/lib/carousel/carousel.js +4 -4
  43. package/lib/config-provider/compDefaultProps.d.ts +0 -1
  44. package/lib/config-provider/compDefaultProps.js +0 -1
  45. package/lib/date-picker/range-picker.d.ts +1 -0
  46. package/lib/date-picker/range-picker.js +2 -0
  47. package/lib/date-picker/style/index.css +6 -3
  48. package/lib/date-picker/style/index.less +7 -3
  49. package/lib/dropdown/style/index.css +3 -0
  50. package/lib/dropdown/style/index.less +4 -0
  51. package/lib/dropdown/style/token.less +1 -0
  52. package/lib/input/style/index.css +8 -0
  53. package/lib/input/style/index.less +4 -0
  54. package/lib/input/style/mixin.less +6 -1
  55. package/lib/menu/menu.d.ts +1 -0
  56. package/lib/menu/menu.js +13 -14
  57. package/lib/menu/menuItem.js +15 -3
  58. package/lib/menu/style/index.css +50 -50
  59. package/lib/menu/style/index.less +15 -15
  60. package/lib/menu/style/mixin.less +24 -24
  61. package/lib/menu/subMenu.js +21 -14
  62. package/lib/radio/radio.js +7 -1
  63. package/lib/tree/style/index.css +30 -1
  64. package/lib/tree/style/index.less +25 -1
  65. package/lib/tree/style/token.less +3 -0
  66. package/lib/tree/tree.d.ts +2 -0
  67. package/lib/tree/tree.js +79 -11
  68. package/lib/tree/treeHooks.d.ts +1 -1
  69. package/lib/tree/treeHooks.js +3 -3
  70. package/lib/tree/treeNode.d.ts +1 -0
  71. package/lib/tree/treeNode.js +11 -8
  72. package/lib/tree/utils/treeUtils.d.ts +4 -2
  73. package/lib/tree/utils/treeUtils.js +71 -13
  74. package/package.json +1 -1
@@ -135,55 +135,55 @@
135
135
  }
136
136
 
137
137
  .@{menuitem-prefix-cls} {
138
- &:hover {
139
- .hover();
138
+ &:not(.@{menuitem-prefix-cls}-disabled):not(.@{menuitem-prefix-cls}-active):hover {
139
+ .menu-dark-hover();
140
140
  }
141
141
 
142
142
  &-active {
143
- .active()
143
+ .menu-dark-active()
144
144
  }
145
145
  }
146
146
 
147
147
  .@{menuitem-prefix-cls}-active, .@{submenu-prefix-cls}-active {
148
- .active()
148
+ .menu-dark-active()
149
149
  }
150
150
 
151
151
  .@{menuitem-prefix-cls}-hover, .@{submenu-prefix-cls}-hover {
152
- .hover()
152
+ .menu-dark-hover()
153
153
  }
154
154
  }
155
155
 
156
156
  .@{menu-inline-prefix-cls}.@{menu-dark-prefix-cls} {
157
157
  .@{menuitem-prefix-cls}-active, .@{submenu-prefix-cls}-active {
158
158
  .@{submenu-prefix-cls}-title {
159
- .active-inline-title()
159
+ .menu-dark-active-inline-title()
160
160
  }
161
161
  }
162
162
 
163
- .@{submenu-prefix-cls}:not(.@{submenu-prefix-cls}-disabled) {
163
+ .@{submenu-prefix-cls}:not(.@{submenu-prefix-cls}-disabled):not(.@{submenu-prefix-cls}-active) {
164
164
  > .@{submenu-prefix-cls}-title:hover {
165
- .active-inline-title()
165
+ .menu-dark-active-inline-title()
166
166
  }
167
167
  }
168
168
  }
169
169
 
170
170
  // light
171
171
  .@{menu-light-prefix-cls} {
172
- .light();
172
+ .menu-light-base();
173
173
  }
174
174
 
175
175
  .@{menu-inline-prefix-cls}.@{menu-light-prefix-cls} {
176
176
  .@{menuitem-prefix-cls}-active, .@{submenu-prefix-cls}-active {
177
177
  .@{submenu-prefix-cls}-title {
178
- .light-active-inline-title()
178
+ .menu-light-active-inline-title()
179
179
  }
180
180
  }
181
181
  }
182
182
 
183
183
  .@{menu-popper-prefix-cls} {
184
- .@{submenu-prefix-cls}:hover,
184
+ .@{submenu-prefix-cls}:not(.@{submenu-prefix-cls}-disabled):not(.@{submenu-prefix-cls}-active):hover,
185
185
  .@{submenu-prefix-cls}-hover {
186
- .hover();
186
+ .menu-dark-hover();
187
187
  }
188
188
 
189
189
  &.hidden {
@@ -206,9 +206,9 @@
206
206
  0 9px 28px 8px rgba(0, 0, 0, 0.05);
207
207
 
208
208
  .@{menuitem-prefix-cls} {
209
- &:hover,
209
+ &:not(.@{menuitem-prefix-cls}-disabled):not(.@{menuitem-prefix-cls}-active):hover,
210
210
  &-active {
211
- .hover()
211
+ .menu-dark-hover()
212
212
  }
213
213
  }
214
214
 
@@ -234,7 +234,7 @@
234
234
  }
235
235
 
236
236
  &.light {
237
- .light();
237
+ .menu-light-base();
238
238
  }
239
239
  }
240
240
 
@@ -24,6 +24,7 @@
24
24
  align-items: center;
25
25
  height: 50px;
26
26
  .ellipsis();
27
+
27
28
  & > span {
28
29
  .ellipsis();
29
30
  opacity: 1;
@@ -57,8 +58,8 @@
57
58
 
58
59
  &-disabled {
59
60
  cursor: not-allowed;
60
- color: @menu-color-disabled !important;
61
- background-color: @menu-color-background !important;
61
+ color: @menu-color-disabled;
62
+ background-color: @menu-color-background;
62
63
  }
63
64
 
64
65
  &-arrow {
@@ -78,68 +79,67 @@
78
79
  }
79
80
 
80
81
 
81
- .hover {
82
+ .menu-dark-hover {
82
83
  background-color: @menu-sub-color-background;
83
84
  color: @menu-sub-color-hover;
84
85
  }
85
86
 
86
- .active {
87
+ .menu-dark-active {
87
88
  background-color: @menu-sub-color-background;
88
89
  color: @menu-sub-color-hover;
89
90
  }
90
91
 
91
- .active-inline-title {
92
- color: @menu-sub-color-hover !important;
93
- background: @menu-color-background !important;
92
+ .menu-dark-active-inline-title {
93
+ color: @menu-sub-color-hover;
94
+ background: @menu-color-background;
94
95
  border: none;
95
96
  }
96
97
 
97
-
98
- .light {
99
- .light-default();
98
+ .menu-light-base {
99
+ .menu-light-default();
100
100
 
101
101
  .@{menuitem-prefix-cls}-disabled, .@{submenu-prefix-cls}-disabled {
102
- background-color: #fff !important;
102
+ background-color: #fff;
103
103
  }
104
104
 
105
105
  .@{submenu-prefix-cls}-sub {
106
106
  color: @menu-light-color;
107
- background: #FAFAFA;
107
+ background: #fafafa;
108
108
  }
109
109
 
110
- .@{menuitem-prefix-cls}:hover {
111
- .light-hover();
110
+ .@{menuitem-prefix-cls}:not(.@{menuitem-prefix-cls}-disabled):not(.@{menuitem-prefix-cls}-active):hover {
111
+ .menu-light-hover();
112
112
  }
113
113
 
114
114
  .@{menuitem-prefix-cls}-hover, .@{submenu-prefix-cls}-hover {
115
- .light-hover();
115
+ .menu-light-hover();
116
116
  }
117
117
 
118
118
  .@{menuitem-prefix-cls}-active, .@{submenu-prefix-cls}-active {
119
- .light-active();
119
+ .menu-light-active();
120
120
  }
121
121
  }
122
122
 
123
- .light-default {
123
+ .menu-light-default {
124
124
  color: @menu-light-color;
125
125
  background: #ffffff;
126
126
  }
127
127
 
128
- .light-hover {
128
+ .menu-light-hover {
129
129
  background-color: @menu-light-color-background-hover;
130
130
  color: @menu-light-color-hover;
131
131
  border: none;
132
132
  }
133
133
 
134
- .light-active {
135
- background-color: @menu-light-color-background-active !important;
136
- color: @menu-light-color-active !important;
134
+ .menu-light-active {
135
+ background-color: @menu-light-color-background-active;
136
+ color: @menu-light-color-active;
137
137
  border: none;
138
138
  }
139
139
 
140
- .light-active-inline-title {
141
- color: @menu-light-color-active !important;
142
- background: #ffffff !important;
140
+ .menu-light-active-inline-title {
141
+ color: @menu-light-color-active;
142
+ background: #ffffff;
143
143
  border: none;
144
144
  }
145
145
 
@@ -1,8 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
2
2
  import _extends from "@babel/runtime-corejs3/helpers/extends";
3
+ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
3
4
  import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
4
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
5
5
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
6
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
6
7
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
7
8
 
8
9
  var __rest = this && this.__rest || function (s, e) {
@@ -51,6 +52,7 @@ var SubMenu = function SubMenu(props) {
51
52
  keyValue = _a.keyValue,
52
53
  selectedKey = _a.selectedKey,
53
54
  selectedKeyPath = _a.selectedKeyPath,
55
+ setSelectedKeyPath = _a.setSelectedKeyPath,
54
56
  openKeys = _a.openKeys,
55
57
  triggerSubMenuAction = _a.triggerSubMenuAction,
56
58
  forceSubMenuRender = _a.forceSubMenuRender,
@@ -60,7 +62,7 @@ var SubMenu = function SubMenu(props) {
60
62
  handleOnOpenChange = _a.handleOnOpenChange,
61
63
  _a$paddingLeft = _a.paddingLeft,
62
64
  paddingLeft = _a$paddingLeft === void 0 ? 0 : _a$paddingLeft,
63
- restProps = __rest(_a, ["prefixCls", "theme", "mode", "title", "icon", "disabled", "children", "collapsed", "keyValue", "selectedKey", "selectedKeyPath", "openKeys", "triggerSubMenuAction", "forceSubMenuRender", "inlineIndent", "className", "style", "handleOnOpenChange", "paddingLeft"]);
65
+ restProps = __rest(_a, ["prefixCls", "theme", "mode", "title", "icon", "disabled", "children", "collapsed", "keyValue", "selectedKey", "selectedKeyPath", "setSelectedKeyPath", "openKeys", "triggerSubMenuAction", "forceSubMenuRender", "inlineIndent", "className", "style", "handleOnOpenChange", "paddingLeft"]);
64
66
 
65
67
  var isVertical = mode === 'vertical'; // 初始化level
66
68
 
@@ -68,6 +70,14 @@ var SubMenu = function SubMenu(props) {
68
70
  restProps.level = 1;
69
71
  }
70
72
 
73
+ if (Array.isArray(restProps.parentPath)) {
74
+ var _context;
75
+
76
+ restProps.parentPath = _concatInstanceProperty(_context = []).call(_context, _toConsumableArray(restProps.parentPath), [keyValue]);
77
+ } else {
78
+ restProps.parentPath = [keyValue];
79
+ }
80
+
71
81
  if (mode === 'inline') {
72
82
  restProps.subMenuMode = 'vertical';
73
83
  restProps.popupOffset = [];
@@ -189,10 +199,7 @@ var SubMenu = function SubMenu(props) {
189
199
  if (!_includesInstanceProperty(className).call(className, MENU_ITEM_CONTAINER_NAME)) {
190
200
  closeSubMenu();
191
201
  }
192
- }); // // 缩略模式自动关闭子菜单
193
- // if (triggerSubMenuAction === 'click' && mode === 'vertical' && collapsed) {
194
- // closeSubMenu()
195
- // }
202
+ });
196
203
 
197
204
  var handleMouseEvent = function handleMouseEvent(status) {
198
205
  if (disabled || triggerSubMenuAction === 'click') return;
@@ -208,11 +215,6 @@ var SubMenu = function SubMenu(props) {
208
215
  };
209
216
 
210
217
  var handleOnClick = function handleOnClick(info) {
211
- var _context;
212
-
213
- // 保存路径
214
- info.keyPath = _concatInstanceProperty(_context = info.keyPath).call(_context, [keyValue]);
215
-
216
218
  if (triggerSubMenuAction === 'click' && isVertical) {
217
219
  closeSubMenu();
218
220
  }
@@ -321,13 +323,15 @@ var SubMenu = function SubMenu(props) {
321
323
  mode: mode,
322
324
  theme: theme,
323
325
  selectedKey: selectedKey,
326
+ setSelectedKeyPath: setSelectedKeyPath,
324
327
  openKeys: openKeys,
325
328
  forceSubMenuRender: forceSubMenuRender,
326
329
  triggerSubMenuAction: triggerSubMenuAction,
327
330
  handleOnOpenChange: handleOnOpenChange,
328
331
  handleOnClick: handleOnClick,
329
332
  inlineIndent: inlineIndent,
330
- paddingLeft: curPaddingLeft
333
+ paddingLeft: curPaddingLeft,
334
+ parentPath: restProps.parentPath
331
335
  });
332
336
  }))), {
333
337
  arrow: false,
@@ -369,13 +373,15 @@ var SubMenu = function SubMenu(props) {
369
373
  collapsed: collapsed,
370
374
  mode: mode,
371
375
  selectedKey: selectedKey,
376
+ setSelectedKeyPath: setSelectedKeyPath,
372
377
  openKeys: openKeys,
373
378
  forceSubMenuRender: forceSubMenuRender,
374
379
  triggerSubMenuAction: triggerSubMenuAction,
375
380
  handleOnOpenChange: handleOnOpenChange,
376
381
  handleOnClick: handleOnClick,
377
382
  inlineIndent: inlineIndent,
378
- paddingLeft: curPaddingLeft
383
+ paddingLeft: curPaddingLeft,
384
+ parentPath: restProps.parentPath
379
385
  });
380
386
  }))));
381
387
  }
package/es/radio/radio.js CHANGED
@@ -18,6 +18,7 @@ var __rest = this && this.__rest || function (s, e) {
18
18
 
19
19
  import React, { useEffect } from 'react';
20
20
  import classNames from 'classnames';
21
+ import isBoolean from 'lodash/isBoolean';
21
22
  import ConfigContext from '../config-provider/ConfigContext';
22
23
  import { getCompProps } from '../_utils';
23
24
  import RadioGroupContext from './context';
@@ -46,13 +47,17 @@ var InternalRadio = function InternalRadio(props, ref) {
46
47
  restProps = __rest(_a, ["style", "checked", "children", "className", "radioType", "defaultChecked", "prefixCls"]); // 属性需要合并一遍用户定义的默认属性
47
48
 
48
49
 
50
+ var getChecked = function getChecked() {
51
+ return isBoolean(checked) ? checked : defaultChecked;
52
+ };
53
+
49
54
  var getPrefix = function getPrefix(radioType) {
50
55
  return "radio".concat(radioType === 'square' ? "-".concat(radioType) : '');
51
56
  };
52
57
 
53
58
  var radioPrefixCls = getPrefixCls === null || getPrefixCls === void 0 ? void 0 : getPrefixCls(prefixCls, getPrefix(radioType), customPrefixcls); // 样式前缀
54
59
 
55
- var _React$useState = React.useState(checked || defaultChecked),
60
+ var _React$useState = React.useState(getChecked()),
56
61
  _React$useState2 = _slicedToArray(_React$useState, 2),
57
62
  isChecked = _React$useState2[0],
58
63
  setIsChecked = _React$useState2[1];
@@ -221,6 +221,19 @@
221
221
  .kd-tree-node-title-disabled {
222
222
  color: var(--kd-c-tree-node-color-disabled, var(--kd-g-color-disabled, #b2b2b2));
223
223
  }
224
+ .kd-tree-node-title-wrap {
225
+ -webkit-box-flex: 1;
226
+ -ms-flex: 1;
227
+ flex: 1;
228
+ position: relative;
229
+ display: -webkit-box;
230
+ display: -ms-flexbox;
231
+ display: flex;
232
+ -webkit-box-align: center;
233
+ -ms-flex-align: center;
234
+ align-items: center;
235
+ height: 100%;
236
+ }
224
237
  .kd-tree-node-title {
225
238
  white-space: nowrap;
226
239
  margin-left: 6px;
@@ -248,12 +261,28 @@
248
261
  width: 100%;
249
262
  height: 100%;
250
263
  }
264
+ .kd-tree-node-drag-over {
265
+ background-color: var(--kd-c-tree-node-drag-over-color-background, #E3EBFF);
266
+ border: 2px solid var(--kd-c-tree-node-drag-over-color-border, #5582f3);
267
+ }
251
268
  .kd-tree-node-drag-line {
252
269
  position: absolute;
253
270
  left: 0;
254
271
  top: 100%;
255
272
  width: 100%;
256
- border-top: 1px solid #fc8555;
273
+ border-top: 2px solid var(--kd-c-tree-node-drag-line-color-background, #276FF5);
274
+ }
275
+ .kd-tree-node-drag-line::before {
276
+ content: '';
277
+ width: 4px;
278
+ height: 4px;
279
+ background-color: #fff;
280
+ border-radius: 50%;
281
+ border: 2px solid var(--kd-c-tree-node-drag-line-color-background, #276FF5);
282
+ position: absolute;
283
+ top: -1px;
284
+ -webkit-transform: translateY(-50%);
285
+ transform: translateY(-50%);
257
286
  }
258
287
  .kd-tree-node-leaf-icon {
259
288
  height: var(--kd-c-tree-node-icon-sizing-height, 20px);
@@ -93,6 +93,13 @@
93
93
  &-title-disabled {
94
94
  color: @tree-node-disabled-color;
95
95
  }
96
+ &-title-wrap {
97
+ flex: 1;
98
+ position: relative;
99
+ display: flex;
100
+ align-items: center;
101
+ height: 100%;
102
+ }
96
103
  &-title {
97
104
  white-space: nowrap;
98
105
  margin-left: 6px;
@@ -118,12 +125,29 @@
118
125
  height: 100%;
119
126
  }
120
127
 
128
+ &-drag-over {
129
+ background-color: @tree-node-drag-over-color-background;
130
+ border: 2px solid @tree-node-drag-over-border-color;
131
+ }
132
+
121
133
  &-drag-line {
122
134
  position: absolute;
123
135
  left: 0;
124
136
  top: 100%;
125
137
  width: 100%;
126
- border-top: 1px solid #fc8555;
138
+ border-top: 2px solid @tree-node-drag-line-border-color;
139
+
140
+ &::before {
141
+ content: '';
142
+ width: 4px;
143
+ height: 4px;
144
+ background-color: #fff;
145
+ border-radius: 50%;
146
+ border: 2px solid @tree-node-drag-line-border-color;
147
+ position: absolute;
148
+ top: -1px;
149
+ transform: translateY(-50%);
150
+ }
127
151
  }
128
152
  &-leaf-icon {
129
153
  height: @tree-node-icon-height;
@@ -11,6 +11,9 @@
11
11
  @tree-node-checked-text-color: var(~'@{tree-prefix}-node-color-text-checked', @color-theme);
12
12
  @tree-node-hover-bg-color: var(~'@{tree-prefix}-node-color-backgroung-hover', @color-hover);
13
13
  @tree-node-icon-color-text: var(~'@{tree-prefix}-node-icon-color-text', #666666);
14
+ @tree-node-drag-over-border-color: var(~'@{tree-prefix}-node-drag-over-color-border', #5582f3);
15
+ @tree-node-drag-over-color-background: var(~'@{tree-prefix}-node-drag-over-color-background', #E3EBFF);
16
+ @tree-node-drag-line-border-color: var(~'@{tree-prefix}-node-drag-line-color-background', #276FF5);
14
17
 
15
18
  // sizing
16
19
  @tree-expand-icon-height: var(~'@{tree-prefix}-expand-icon-sizing-height', 22px);
package/es/tree/tree.d.ts CHANGED
@@ -12,6 +12,8 @@ export interface TreeProps {
12
12
  disabled?: boolean;
13
13
  draggable?: boolean;
14
14
  expandedKeys?: string[];
15
+ filterValue?: string;
16
+ filterTreeNode?: () => boolean;
15
17
  height?: number;
16
18
  icon?: ReactNode | ((props: any) => ReactNode);
17
19
  switcherIcon?: ReactNode | ((props: any) => ReactNode) | [ReactNode | ((props: any) => ReactNode)];
package/es/tree/tree.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import _extends from "@babel/runtime-corejs3/helpers/extends";
2
+ import _toConsumableArray from "@babel/runtime-corejs3/helpers/toConsumableArray";
2
3
  import _slicedToArray from "@babel/runtime-corejs3/helpers/slicedToArray";
3
4
  import _defineProperty from "@babel/runtime-corejs3/helpers/defineProperty";
5
+ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
4
6
  import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
5
7
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
6
8
  import React, { useContext, useCallback, useEffect } from 'react';
@@ -8,7 +10,7 @@ import classNames from 'classnames';
8
10
  import ConfigContext from '../config-provider/ConfigContext';
9
11
  import { getCompProps } from '../_utils';
10
12
  import TreeNode from './treeNode';
11
- import { getChecked, getHalfChecked, addKeys, flattenAll, delKey, getFilterData, getSpreadAttrData, getDataCheckededState, getDataCheckededStateStrictly, getMaxLevel, getAllChildKeys, getPos, getSelected } from './utils/treeUtils';
13
+ import { getChecked, getHalfChecked, addKeys, flattenAll, delKey, getFilterData, getSpreadAttrData, getDataCheckededState, getDataCheckededStateStrictly, getMaxLevel, getAllChildKeys, getPos, getSelected, calcDropPosition } from './utils/treeUtils';
12
14
  import { useChecked, useExpand, usePlantomHeightEffect, useViewportHeight, useVisibleDataMemo, useScrollToKey, useSelect } from './treeHooks';
13
15
  import isBoolean from 'lodash/isBoolean';
14
16
  var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
@@ -58,7 +60,9 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
58
60
  return '';
59
61
  } : _TreeProps$setTreeNod2,
60
62
  innerEstimatedItemSize = TreeProps.estimatedItemSize,
61
- style = TreeProps.style;
63
+ style = TreeProps.style,
64
+ filterTreeNode = TreeProps.filterTreeNode,
65
+ filterValue = TreeProps.filterValue;
62
66
  var treePrefixCls = getPrefixCls(prefixCls, 'tree', customPrefixcls); // 树样式前缀
63
67
 
64
68
  var treeNodePrefixCls = getPrefixCls(prefixCls, 'tree-node', customPrefixcls); // 树节点样式前缀
@@ -102,22 +106,34 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
102
106
  var scrollRef = ref || rootRef;
103
107
  var treeNodeRef = React.useRef(null);
104
108
  var dragNodeRef = React.useRef(null);
109
+ var delayedDragEnterRef = React.useRef(null);
105
110
 
106
111
  var _React$useState5 = React.useState(true),
107
112
  _React$useState6 = _slicedToArray(_React$useState5, 2),
108
113
  isInit = _React$useState6[0],
109
114
  setIsInit = _React$useState6[1];
110
115
 
111
- var _useExpand = useExpand(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, isInit),
112
- _useExpand2 = _slicedToArray(_useExpand, 1),
113
- expandedKeys = _useExpand2[0];
116
+ var _React$useState7 = React.useState(null),
117
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
118
+ dropPosition = _React$useState8[0],
119
+ setDropPosition = _React$useState8[1];
120
+
121
+ var _React$useState9 = React.useState(null),
122
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
123
+ dragOverNodeKey = _React$useState10[0],
124
+ setDragOverNodeKey = _React$useState10[1];
125
+
126
+ var _useExpand = useExpand(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, isInit, filterTreeNode, filterValue),
127
+ _useExpand2 = _slicedToArray(_useExpand, 2),
128
+ expandedKeys = _useExpand2[0],
129
+ setExpandedKeys = _useExpand2[1];
114
130
 
115
131
  var spreadAttrData = React.useMemo(function () {
116
132
  return getSpreadAttrData(flattenAllData, expandedKeys);
117
133
  }, [flattenAllData, expandedKeys]);
118
134
  var filterData = React.useMemo(function () {
119
- return getFilterData(spreadAttrData);
120
- }, [spreadAttrData]);
135
+ return getFilterData(spreadAttrData, filterTreeNode, filterValue);
136
+ }, [spreadAttrData, filterTreeNode, filterValue]);
121
137
 
122
138
  var _useViewportHeight = useViewportHeight(height, listRef),
123
139
  _useViewportHeight2 = _slicedToArray(_useViewportHeight, 1),
@@ -176,7 +192,15 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
176
192
  node: node
177
193
  });
178
194
  }, [onDragStart]);
179
- var handleDragOver = React.useCallback(function (event, node) {
195
+ var handleDragOver = React.useCallback(function (event, node, dropTarget) {
196
+ var dropPos = calcDropPosition(event, dropTarget);
197
+ setDropPosition(dropPos);
198
+ var dragNode = getDragNode();
199
+
200
+ if (dragNode.key === node.key) {
201
+ setDropPosition(null);
202
+ }
203
+
180
204
  onDragOver && onDragOver({
181
205
  event: event,
182
206
  node: node
@@ -188,13 +212,52 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
188
212
  node: node
189
213
  });
190
214
  }, [onDragLeave]);
191
- var handleDragEnter = React.useCallback(function (event, node) {
215
+ var handleDragEnter = React.useCallback(function (event, node, dropTarget) {
216
+ var key = node.key,
217
+ pos = node.pos;
218
+ var dragNode = getDragNode();
219
+
220
+ if (!dragNode) {
221
+ return;
222
+ }
223
+
224
+ if (!delayedDragEnterRef.current) {
225
+ delayedDragEnterRef.current = {};
226
+ }
227
+
228
+ _Object$keys(delayedDragEnterRef.current).forEach(function (key) {
229
+ clearTimeout(delayedDragEnterRef.current[key]);
230
+ });
231
+
232
+ if ((dragNode === null || dragNode === void 0 ? void 0 : dragNode.key) !== key) {
233
+ var dragPos = calcDropPosition(event, dropTarget);
234
+ setDragOverNodeKey(key);
235
+ setDropPosition(dragPos);
236
+ delayedDragEnterRef.current[pos] = setTimeout(function () {
237
+ var newExpandedKeys = _toConsumableArray(expandedKeys);
238
+
239
+ if (!node.expand) {
240
+ newExpandedKeys = addKeys(expandedKeys, [key]);
241
+ }
242
+
243
+ if (!('expandedKeys' in TreeProps)) {
244
+ setExpandedKeys(newExpandedKeys);
245
+ }
246
+
247
+ onExpand === null || onExpand === void 0 ? void 0 : onExpand(newExpandedKeys, {
248
+ node: node,
249
+ expanded: true
250
+ });
251
+ }, 800);
252
+ }
253
+
192
254
  onDragEnter && onDragEnter({
193
255
  event: event,
194
256
  node: node
195
257
  });
196
- }, [onDragEnter]);
258
+ }, [TreeProps, expandedKeys, onDragEnter, onExpand, setExpandedKeys]);
197
259
  var handleDragEnd = React.useCallback(function (event, node) {
260
+ setDragOverNodeKey('');
198
261
  onDragEnd && onDragEnd({
199
262
  event: event,
200
263
  node: node
@@ -211,9 +274,10 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
211
274
  event: event,
212
275
  node: node,
213
276
  dragNode: dragNode,
214
- keys: keys
277
+ dragNodesKeys: keys,
278
+ dropPosition: dropPosition
215
279
  });
216
- }, [onDrop, flattenAllData]);
280
+ }, [flattenAllData, onDrop, dropPosition]);
217
281
  var handleSelect = React.useCallback(function (event, node, key) {
218
282
  var checked = getChecked(checkedKeys, key);
219
283
  onSelect && onSelect([key], {
@@ -300,6 +364,7 @@ var InternalTree = /*#__PURE__*/React.forwardRef(function (props, ref) {
300
364
  item.style = setTreeNodeStyle(_extends({}, item));
301
365
  item.getDragNode = getDragNode;
302
366
  item.setDragNode = setDragNode;
367
+ item.dragOver = dragOverNodeKey === item.key && dropPosition === 0;
303
368
  return /*#__PURE__*/React.createElement(TreeNode, _extends({}, item, {
304
369
  key: item.key,
305
370
  ref: treeNodeRef
@@ -4,6 +4,6 @@ export declare const useViewportHeight: (height: number, listRef: React.RefObjec
4
4
  export declare const useVisibleDataMemo: (virtual: boolean, filterData: TreeNodeData[], viewportHeight: number, estimatedItemSize: number, start: number) => TreeNodeData[][];
5
5
  export declare const usePlantomHeightEffect: (plantomRef: React.RefObject<HTMLElement>, filterData: TreeNodeData[], estimatedItemSize: number) => void;
6
6
  export declare const useChecked: (checkStrictly: boolean, checkedKeysProps: string[], defaultCheckedKeys: string[], flattenAllData: any[], maxLevel: number, checkable: boolean) => readonly [string[], string[], React.Dispatch<React.SetStateAction<string[]>>, React.Dispatch<React.SetStateAction<string[]>>];
7
- export declare const useExpand: (flattenAllData: any[], expandedKeysProps: string[], defaultExpandedKeys: string[], defaultExpandAll: boolean, defaultExpandRoot: boolean, defaultExpandParent: boolean, scrollKey: string, isInit: boolean) => readonly [string[], React.Dispatch<React.SetStateAction<string[]>>];
7
+ export declare const useExpand: (flattenAllData: any[], expandedKeysProps: string[], defaultExpandedKeys: string[], defaultExpandAll: boolean, defaultExpandRoot: boolean, defaultExpandParent: boolean, scrollKey: string, isInit: boolean, filterTreeNode: FunctionConstructor, filterValue: string) => readonly [string[], React.Dispatch<React.SetStateAction<string[]>>];
8
8
  export declare const useScrollToKey: (scrollKey: string, index: number, estimatedItemSize: number, scrollRef: any, viewportHeight: number, treeNodePrefixCls: string) => void;
9
9
  export declare const useSelect: (selectedKeysProps: string[], defaultSelectedKeys: string[]) => readonly [string[], React.Dispatch<React.SetStateAction<string[]>>];
@@ -64,7 +64,7 @@ export var useChecked = function useChecked(checkStrictly, checkedKeysProps, def
64
64
  }, [nextHalfCheckedKeys]);
65
65
  return [checkedKeys, halfCheckedKeys, setCheckedKeys, setHalfCheckedKeys];
66
66
  };
67
- export var useExpand = function useExpand(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, isInit) {
67
+ export var useExpand = function useExpand(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, isInit, filterTreeNode, filterValue) {
68
68
  var expandScrollkeys = [];
69
69
 
70
70
  if (scrollKey) {
@@ -73,8 +73,8 @@ export var useExpand = function useExpand(flattenAllData, expandedKeysProps, def
73
73
  }
74
74
 
75
75
  var initialExpandedKeys = React.useMemo(function () {
76
- return getInitExpandedKeys(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, expandScrollkeys);
77
- }, [flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey]);
76
+ return getInitExpandedKeys(flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, expandScrollkeys, filterTreeNode, filterValue);
77
+ }, [flattenAllData, expandedKeysProps, defaultExpandedKeys, defaultExpandAll, defaultExpandRoot, defaultExpandParent, scrollKey, filterTreeNode, filterValue]);
78
78
  var newExpandedKeys = React.useMemo(function () {
79
79
  return getExpandedKeys(expandedKeysProps, expandScrollkeys);
80
80
  }, [expandedKeysProps]);
@@ -24,6 +24,7 @@ export interface TreeNodeProps {
24
24
  checked?: boolean;
25
25
  pos?: string;
26
26
  estimatedItemSize?: number;
27
+ dragOver?: boolean;
27
28
  onCheck?: (key: string, value: boolean, node: React.ReactNode, event: React.MouseEvent<MouseEvent>, pos: string) => void;
28
29
  onSelect?: (event: React.MouseEvent<MouseEvent>, node: React.ReactNode, key: string) => void;
29
30
  onExpand?: (value: boolean, node: React.ReactNode) => void;