antd3-esm 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/LICENSE +21 -0
  2. package/dist/Checkbox.js +164 -0
  3. package/dist/CommonMixin.js +816 -0
  4. package/dist/Divider.js +646 -0
  5. package/dist/Notification.js +279 -0
  6. package/dist/Pagination.js +1106 -0
  7. package/dist/PortalWrapper.js +347 -0
  8. package/dist/RowContext.js +5 -0
  9. package/dist/Sider.js +533 -0
  10. package/dist/TextArea.js +432 -0
  11. package/dist/_arrayMap.js +68 -0
  12. package/dist/_assignValue.js +95 -0
  13. package/dist/_copyArray.js +31 -0
  14. package/dist/_hasPath.js +53 -0
  15. package/dist/_overArg.js +437 -0
  16. package/dist/_stringToArray.js +136 -0
  17. package/dist/antd/es/affix.js +12 -0
  18. package/dist/antd/es/alert.js +5 -0
  19. package/dist/antd/es/anchor.js +466 -0
  20. package/dist/antd/es/auto-complete.js +5 -0
  21. package/dist/antd/es/avatar.js +5 -0
  22. package/dist/antd/es/back-top.js +5 -0
  23. package/dist/antd/es/badge.js +5 -0
  24. package/dist/antd/es/breadcrumb.js +18 -0
  25. package/dist/antd/es/button.js +12 -0
  26. package/dist/antd/es/calendar.js +953 -0
  27. package/dist/antd/es/card.js +5 -0
  28. package/dist/antd/es/carousel.js +5 -0
  29. package/dist/antd/es/cascader.js +1275 -0
  30. package/dist/antd/es/checkbox.js +11 -0
  31. package/dist/antd/es/col.js +4 -0
  32. package/dist/antd/es/collapse.js +688 -0
  33. package/dist/antd/es/comment.js +5 -0
  34. package/dist/antd/es/config-provider.js +2 -0
  35. package/dist/antd/es/date-picker.js +4322 -0
  36. package/dist/antd/es/descriptions.js +342 -0
  37. package/dist/antd/es/divider.js +53 -0
  38. package/dist/antd/es/drawer.js +1115 -0
  39. package/dist/antd/es/dropdown.js +14 -0
  40. package/dist/antd/es/empty.js +6 -0
  41. package/dist/antd/es/form.js +5008 -0
  42. package/dist/antd/es/grid.js +13 -0
  43. package/dist/antd/es/icon.js +6 -0
  44. package/dist/antd/es/input-number.js +5 -0
  45. package/dist/antd/es/input.js +16 -0
  46. package/dist/antd/es/layout.js +14 -0
  47. package/dist/antd/es/list.js +5 -0
  48. package/dist/antd/es/locale/ar_EG.js +102 -0
  49. package/dist/antd/es/locale/bg_BG.js +98 -0
  50. package/dist/antd/es/locale/ca_ES.js +96 -0
  51. package/dist/antd/es/locale/cs_CZ.js +96 -0
  52. package/dist/antd/es/locale/da_DK.js +98 -0
  53. package/dist/antd/es/locale/de_DE.js +98 -0
  54. package/dist/antd/es/locale/default.js +2 -0
  55. package/dist/antd/es/locale/el_GR.js +98 -0
  56. package/dist/antd/es/locale/en_GB.js +98 -0
  57. package/dist/antd/es/locale/en_US.js +2 -0
  58. package/dist/antd/es/locale/es_ES.js +114 -0
  59. package/dist/antd/es/locale/et_EE.js +98 -0
  60. package/dist/antd/es/locale/fa_IR.js +98 -0
  61. package/dist/antd/es/locale/fi_FI.js +99 -0
  62. package/dist/antd/es/locale/fr_BE.js +102 -0
  63. package/dist/antd/es/locale/fr_FR.js +102 -0
  64. package/dist/antd/es/locale/ga_IE.js +99 -0
  65. package/dist/antd/es/locale/he_IL.js +99 -0
  66. package/dist/antd/es/locale/hi_IN.js +107 -0
  67. package/dist/antd/es/locale/hr_HR.js +113 -0
  68. package/dist/antd/es/locale/hu_HU.js +99 -0
  69. package/dist/antd/es/locale/hy_AM.js +109 -0
  70. package/dist/antd/es/locale/id_ID.js +101 -0
  71. package/dist/antd/es/locale/is_IS.js +98 -0
  72. package/dist/antd/es/locale/it_IT.js +111 -0
  73. package/dist/antd/es/locale/ja_JP.js +96 -0
  74. package/dist/antd/es/locale/kn_IN.js +107 -0
  75. package/dist/antd/es/locale/ko_KR.js +98 -0
  76. package/dist/antd/es/locale/ku_IQ.js +98 -0
  77. package/dist/antd/es/locale/lv_LV.js +98 -0
  78. package/dist/antd/es/locale/mk_MK.js +113 -0
  79. package/dist/antd/es/locale/mn_MN.js +99 -0
  80. package/dist/antd/es/locale/ms_MY.js +118 -0
  81. package/dist/antd/es/locale/nb_NO.js +97 -0
  82. package/dist/antd/es/locale/ne_NP.js +44 -0
  83. package/dist/antd/es/locale/nl_BE.js +98 -0
  84. package/dist/antd/es/locale/nl_NL.js +117 -0
  85. package/dist/antd/es/locale/pl_PL.js +98 -0
  86. package/dist/antd/es/locale/pt_BR.js +104 -0
  87. package/dist/antd/es/locale/pt_PT.js +127 -0
  88. package/dist/antd/es/locale/ro_RO.js +118 -0
  89. package/dist/antd/es/locale/ru_RU.js +110 -0
  90. package/dist/antd/es/locale/sk_SK.js +118 -0
  91. package/dist/antd/es/locale/sl_SI.js +96 -0
  92. package/dist/antd/es/locale/sr_RS.js +97 -0
  93. package/dist/antd/es/locale/sv_SE.js +101 -0
  94. package/dist/antd/es/locale/ta_IN.js +119 -0
  95. package/dist/antd/es/locale/th_TH.js +117 -0
  96. package/dist/antd/es/locale/tr_TR.js +112 -0
  97. package/dist/antd/es/locale/uk_UA.js +97 -0
  98. package/dist/antd/es/locale/vi_VN.js +99 -0
  99. package/dist/antd/es/locale/zh_CN.js +104 -0
  100. package/dist/antd/es/locale/zh_TW.js +100 -0
  101. package/dist/antd/es/locale-provider.js +6 -0
  102. package/dist/antd/es/mention.js +23215 -0
  103. package/dist/antd/es/mentions.js +961 -0
  104. package/dist/antd/es/menu.js +5 -0
  105. package/dist/antd/es/message.js +161 -0
  106. package/dist/antd/es/modal.js +885 -0
  107. package/dist/antd/es/notification.js +216 -0
  108. package/dist/antd/es/page-header.js +350 -0
  109. package/dist/antd/es/pagination.js +15 -0
  110. package/dist/antd/es/popconfirm.js +215 -0
  111. package/dist/antd/es/popover.js +5 -0
  112. package/dist/antd/es/progress.js +10 -0
  113. package/dist/antd/es/radio.js +10 -0
  114. package/dist/antd/es/rate.js +5 -0
  115. package/dist/antd/es/result.js +828 -0
  116. package/dist/antd/es/row.js +9 -0
  117. package/dist/antd/es/select.js +5 -0
  118. package/dist/antd/es/skeleton.js +370 -0
  119. package/dist/antd/es/slider.js +5 -0
  120. package/dist/antd/es/spin.js +11 -0
  121. package/dist/antd/es/statistic.js +650 -0
  122. package/dist/antd/es/steps.js +5 -0
  123. package/dist/antd/es/style.js +5 -0
  124. package/dist/antd/es/switch.js +5 -0
  125. package/dist/antd/es/table.js +7057 -0
  126. package/dist/antd/es/tabs.js +5 -0
  127. package/dist/antd/es/tag.js +12 -0
  128. package/dist/antd/es/time-picker.js +10 -0
  129. package/dist/antd/es/timeline.js +206 -0
  130. package/dist/antd/es/tooltip.js +9 -0
  131. package/dist/antd/es/transfer.js +2508 -0
  132. package/dist/antd/es/tree-select.js +5 -0
  133. package/dist/antd/es/tree.js +10 -0
  134. package/dist/antd/es/typography.js +1246 -0
  135. package/dist/antd/es/upload.js +3418 -0
  136. package/dist/antd/es/version.js +7 -0
  137. package/dist/col.js +142 -0
  138. package/dist/config-provider.js +6949 -0
  139. package/dist/dropdown.js +442 -0
  140. package/dist/get.js +1043 -0
  141. package/dist/icon.js +6138 -0
  142. package/dist/identity.js +230 -0
  143. package/dist/index.js +462 -0
  144. package/dist/index10.js +478 -0
  145. package/dist/index11.js +232 -0
  146. package/dist/index12.js +2766 -0
  147. package/dist/index13.js +422 -0
  148. package/dist/index14.js +283 -0
  149. package/dist/index15.js +1755 -0
  150. package/dist/index2.js +374 -0
  151. package/dist/index3.js +407 -0
  152. package/dist/index4.js +522 -0
  153. package/dist/index5.js +601 -0
  154. package/dist/index6.js +601 -0
  155. package/dist/index7.js +364 -0
  156. package/dist/index8.js +436 -0
  157. package/dist/index9.js +130 -0
  158. package/dist/input.js +475 -0
  159. package/dist/isLength.js +402 -0
  160. package/dist/keys.js +292 -0
  161. package/dist/menu.js +8138 -0
  162. package/dist/progress.js +852 -0
  163. package/dist/raf.js +34 -0
  164. package/dist/responsiveObserve.js +444 -0
  165. package/dist/row.js +173 -0
  166. package/dist/scrollTo.js +66 -0
  167. package/dist/toInteger.js +123 -0
  168. package/dist/toString.js +84 -0
  169. package/dist/transButton.js +121 -0
  170. package/dist/tree.js +3017 -0
  171. package/dist/warning.js +55 -0
  172. package/dist/wave.js +230 -0
  173. package/dist/zh_CN.js +17 -0
  174. package/package.json +160 -0
package/dist/tree.js ADDED
@@ -0,0 +1,3017 @@
1
+ import * as React from 'react';
2
+ import React__default, { Children } from 'react';
3
+ import { e as requireReactIs, g as getDefaultExportFromCjs, f as requireWarning, a as commonjsGlobal, h as createReactContext, P as PropTypes, c as classNames, C as ConfigConsumer } from './config-provider.js';
4
+ import { p as polyfill, O as OriginCSSMotion } from './menu.js';
5
+ import { o as omit } from './input.js';
6
+ import { I as Icon } from './icon.js';
7
+
8
+ var reactIsExports = requireReactIs();
9
+
10
+ function toArray(children) {
11
+ var ret = [];
12
+ React__default.Children.forEach(children, function (child) {
13
+ if (child === undefined || child === null) {
14
+ return;
15
+ }
16
+
17
+ if (Array.isArray(child)) {
18
+ ret = ret.concat(toArray(child));
19
+ } else if (reactIsExports.isFragment(child) && child.props) {
20
+ ret = ret.concat(toArray(child.props.children));
21
+ } else {
22
+ ret.push(child);
23
+ }
24
+ });
25
+ return ret;
26
+ }
27
+
28
+ var warningExports = requireWarning();
29
+ var warning = /*@__PURE__*/getDefaultExportFromCjs(warningExports);
30
+
31
+ // ================== Collapse Motion ==================
32
+ var getCollapsedHeight = function getCollapsedHeight() {
33
+ return {
34
+ height: 0,
35
+ opacity: 0
36
+ };
37
+ };
38
+
39
+ var getRealHeight = function getRealHeight(node) {
40
+ return {
41
+ height: node.scrollHeight,
42
+ opacity: 1
43
+ };
44
+ };
45
+
46
+ var getCurrentHeight = function getCurrentHeight(node) {
47
+ return {
48
+ height: node.offsetHeight
49
+ };
50
+ };
51
+
52
+ var collapseMotion = {
53
+ motionName: 'ant-motion-collapse',
54
+ onAppearStart: getCollapsedHeight,
55
+ onEnterStart: getCollapsedHeight,
56
+ onAppearActive: getRealHeight,
57
+ onEnterActive: getRealHeight,
58
+ onLeaveStart: getCurrentHeight,
59
+ onLeaveActive: getCollapsedHeight
60
+ };
61
+
62
+ /**
63
+ * Checks if `value` is the
64
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
65
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
66
+ *
67
+ * @static
68
+ * @memberOf _
69
+ * @since 0.1.0
70
+ * @category Lang
71
+ * @param {*} value The value to check.
72
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
73
+ * @example
74
+ *
75
+ * _.isObject({});
76
+ * // => true
77
+ *
78
+ * _.isObject([1, 2, 3]);
79
+ * // => true
80
+ *
81
+ * _.isObject(_.noop);
82
+ * // => true
83
+ *
84
+ * _.isObject(null);
85
+ * // => false
86
+ */
87
+
88
+ var isObject_1;
89
+ var hasRequiredIsObject;
90
+
91
+ function requireIsObject () {
92
+ if (hasRequiredIsObject) return isObject_1;
93
+ hasRequiredIsObject = 1;
94
+ function isObject(value) {
95
+ var type = typeof value;
96
+ return value != null && (type == 'object' || type == 'function');
97
+ }
98
+
99
+ isObject_1 = isObject;
100
+ return isObject_1;
101
+ }
102
+
103
+ /** Detect free variable `global` from Node.js. */
104
+
105
+ var _freeGlobal;
106
+ var hasRequired_freeGlobal;
107
+
108
+ function require_freeGlobal () {
109
+ if (hasRequired_freeGlobal) return _freeGlobal;
110
+ hasRequired_freeGlobal = 1;
111
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
112
+
113
+ _freeGlobal = freeGlobal;
114
+ return _freeGlobal;
115
+ }
116
+
117
+ var _root;
118
+ var hasRequired_root;
119
+
120
+ function require_root () {
121
+ if (hasRequired_root) return _root;
122
+ hasRequired_root = 1;
123
+ var freeGlobal = require_freeGlobal();
124
+
125
+ /** Detect free variable `self`. */
126
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
127
+
128
+ /** Used as a reference to the global object. */
129
+ var root = freeGlobal || freeSelf || Function('return this')();
130
+
131
+ _root = root;
132
+ return _root;
133
+ }
134
+
135
+ var now_1;
136
+ var hasRequiredNow;
137
+
138
+ function requireNow () {
139
+ if (hasRequiredNow) return now_1;
140
+ hasRequiredNow = 1;
141
+ var root = require_root();
142
+
143
+ /**
144
+ * Gets the timestamp of the number of milliseconds that have elapsed since
145
+ * the Unix epoch (1 January 1970 00:00:00 UTC).
146
+ *
147
+ * @static
148
+ * @memberOf _
149
+ * @since 2.4.0
150
+ * @category Date
151
+ * @returns {number} Returns the timestamp.
152
+ * @example
153
+ *
154
+ * _.defer(function(stamp) {
155
+ * console.log(_.now() - stamp);
156
+ * }, _.now());
157
+ * // => Logs the number of milliseconds it took for the deferred invocation.
158
+ */
159
+ var now = function() {
160
+ return root.Date.now();
161
+ };
162
+
163
+ now_1 = now;
164
+ return now_1;
165
+ }
166
+
167
+ /** Used to match a single whitespace character. */
168
+
169
+ var _trimmedEndIndex;
170
+ var hasRequired_trimmedEndIndex;
171
+
172
+ function require_trimmedEndIndex () {
173
+ if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
174
+ hasRequired_trimmedEndIndex = 1;
175
+ var reWhitespace = /\s/;
176
+
177
+ /**
178
+ * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
179
+ * character of `string`.
180
+ *
181
+ * @private
182
+ * @param {string} string The string to inspect.
183
+ * @returns {number} Returns the index of the last non-whitespace character.
184
+ */
185
+ function trimmedEndIndex(string) {
186
+ var index = string.length;
187
+
188
+ while (index-- && reWhitespace.test(string.charAt(index))) {}
189
+ return index;
190
+ }
191
+
192
+ _trimmedEndIndex = trimmedEndIndex;
193
+ return _trimmedEndIndex;
194
+ }
195
+
196
+ var _baseTrim;
197
+ var hasRequired_baseTrim;
198
+
199
+ function require_baseTrim () {
200
+ if (hasRequired_baseTrim) return _baseTrim;
201
+ hasRequired_baseTrim = 1;
202
+ var trimmedEndIndex = require_trimmedEndIndex();
203
+
204
+ /** Used to match leading whitespace. */
205
+ var reTrimStart = /^\s+/;
206
+
207
+ /**
208
+ * The base implementation of `_.trim`.
209
+ *
210
+ * @private
211
+ * @param {string} string The string to trim.
212
+ * @returns {string} Returns the trimmed string.
213
+ */
214
+ function baseTrim(string) {
215
+ return string
216
+ ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
217
+ : string;
218
+ }
219
+
220
+ _baseTrim = baseTrim;
221
+ return _baseTrim;
222
+ }
223
+
224
+ var _Symbol;
225
+ var hasRequired_Symbol;
226
+
227
+ function require_Symbol () {
228
+ if (hasRequired_Symbol) return _Symbol;
229
+ hasRequired_Symbol = 1;
230
+ var root = require_root();
231
+
232
+ /** Built-in value references. */
233
+ var Symbol = root.Symbol;
234
+
235
+ _Symbol = Symbol;
236
+ return _Symbol;
237
+ }
238
+
239
+ var _getRawTag;
240
+ var hasRequired_getRawTag;
241
+
242
+ function require_getRawTag () {
243
+ if (hasRequired_getRawTag) return _getRawTag;
244
+ hasRequired_getRawTag = 1;
245
+ var Symbol = require_Symbol();
246
+
247
+ /** Used for built-in method references. */
248
+ var objectProto = Object.prototype;
249
+
250
+ /** Used to check objects for own properties. */
251
+ var hasOwnProperty = objectProto.hasOwnProperty;
252
+
253
+ /**
254
+ * Used to resolve the
255
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
256
+ * of values.
257
+ */
258
+ var nativeObjectToString = objectProto.toString;
259
+
260
+ /** Built-in value references. */
261
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
262
+
263
+ /**
264
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
265
+ *
266
+ * @private
267
+ * @param {*} value The value to query.
268
+ * @returns {string} Returns the raw `toStringTag`.
269
+ */
270
+ function getRawTag(value) {
271
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
272
+ tag = value[symToStringTag];
273
+
274
+ try {
275
+ value[symToStringTag] = undefined;
276
+ var unmasked = true;
277
+ } catch (e) {}
278
+
279
+ var result = nativeObjectToString.call(value);
280
+ if (unmasked) {
281
+ if (isOwn) {
282
+ value[symToStringTag] = tag;
283
+ } else {
284
+ delete value[symToStringTag];
285
+ }
286
+ }
287
+ return result;
288
+ }
289
+
290
+ _getRawTag = getRawTag;
291
+ return _getRawTag;
292
+ }
293
+
294
+ /** Used for built-in method references. */
295
+
296
+ var _objectToString;
297
+ var hasRequired_objectToString;
298
+
299
+ function require_objectToString () {
300
+ if (hasRequired_objectToString) return _objectToString;
301
+ hasRequired_objectToString = 1;
302
+ var objectProto = Object.prototype;
303
+
304
+ /**
305
+ * Used to resolve the
306
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
307
+ * of values.
308
+ */
309
+ var nativeObjectToString = objectProto.toString;
310
+
311
+ /**
312
+ * Converts `value` to a string using `Object.prototype.toString`.
313
+ *
314
+ * @private
315
+ * @param {*} value The value to convert.
316
+ * @returns {string} Returns the converted string.
317
+ */
318
+ function objectToString(value) {
319
+ return nativeObjectToString.call(value);
320
+ }
321
+
322
+ _objectToString = objectToString;
323
+ return _objectToString;
324
+ }
325
+
326
+ var _baseGetTag;
327
+ var hasRequired_baseGetTag;
328
+
329
+ function require_baseGetTag () {
330
+ if (hasRequired_baseGetTag) return _baseGetTag;
331
+ hasRequired_baseGetTag = 1;
332
+ var Symbol = require_Symbol(),
333
+ getRawTag = require_getRawTag(),
334
+ objectToString = require_objectToString();
335
+
336
+ /** `Object#toString` result references. */
337
+ var nullTag = '[object Null]',
338
+ undefinedTag = '[object Undefined]';
339
+
340
+ /** Built-in value references. */
341
+ var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
342
+
343
+ /**
344
+ * The base implementation of `getTag` without fallbacks for buggy environments.
345
+ *
346
+ * @private
347
+ * @param {*} value The value to query.
348
+ * @returns {string} Returns the `toStringTag`.
349
+ */
350
+ function baseGetTag(value) {
351
+ if (value == null) {
352
+ return value === undefined ? undefinedTag : nullTag;
353
+ }
354
+ return (symToStringTag && symToStringTag in Object(value))
355
+ ? getRawTag(value)
356
+ : objectToString(value);
357
+ }
358
+
359
+ _baseGetTag = baseGetTag;
360
+ return _baseGetTag;
361
+ }
362
+
363
+ /**
364
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
365
+ * and has a `typeof` result of "object".
366
+ *
367
+ * @static
368
+ * @memberOf _
369
+ * @since 4.0.0
370
+ * @category Lang
371
+ * @param {*} value The value to check.
372
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
373
+ * @example
374
+ *
375
+ * _.isObjectLike({});
376
+ * // => true
377
+ *
378
+ * _.isObjectLike([1, 2, 3]);
379
+ * // => true
380
+ *
381
+ * _.isObjectLike(_.noop);
382
+ * // => false
383
+ *
384
+ * _.isObjectLike(null);
385
+ * // => false
386
+ */
387
+
388
+ var isObjectLike_1;
389
+ var hasRequiredIsObjectLike;
390
+
391
+ function requireIsObjectLike () {
392
+ if (hasRequiredIsObjectLike) return isObjectLike_1;
393
+ hasRequiredIsObjectLike = 1;
394
+ function isObjectLike(value) {
395
+ return value != null && typeof value == 'object';
396
+ }
397
+
398
+ isObjectLike_1 = isObjectLike;
399
+ return isObjectLike_1;
400
+ }
401
+
402
+ var isSymbol_1;
403
+ var hasRequiredIsSymbol;
404
+
405
+ function requireIsSymbol () {
406
+ if (hasRequiredIsSymbol) return isSymbol_1;
407
+ hasRequiredIsSymbol = 1;
408
+ var baseGetTag = require_baseGetTag(),
409
+ isObjectLike = requireIsObjectLike();
410
+
411
+ /** `Object#toString` result references. */
412
+ var symbolTag = '[object Symbol]';
413
+
414
+ /**
415
+ * Checks if `value` is classified as a `Symbol` primitive or object.
416
+ *
417
+ * @static
418
+ * @memberOf _
419
+ * @since 4.0.0
420
+ * @category Lang
421
+ * @param {*} value The value to check.
422
+ * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
423
+ * @example
424
+ *
425
+ * _.isSymbol(Symbol.iterator);
426
+ * // => true
427
+ *
428
+ * _.isSymbol('abc');
429
+ * // => false
430
+ */
431
+ function isSymbol(value) {
432
+ return typeof value == 'symbol' ||
433
+ (isObjectLike(value) && baseGetTag(value) == symbolTag);
434
+ }
435
+
436
+ isSymbol_1 = isSymbol;
437
+ return isSymbol_1;
438
+ }
439
+
440
+ var toNumber_1;
441
+ var hasRequiredToNumber;
442
+
443
+ function requireToNumber () {
444
+ if (hasRequiredToNumber) return toNumber_1;
445
+ hasRequiredToNumber = 1;
446
+ var baseTrim = require_baseTrim(),
447
+ isObject = requireIsObject(),
448
+ isSymbol = requireIsSymbol();
449
+
450
+ /** Used as references for various `Number` constants. */
451
+ var NAN = 0 / 0;
452
+
453
+ /** Used to detect bad signed hexadecimal string values. */
454
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
455
+
456
+ /** Used to detect binary string values. */
457
+ var reIsBinary = /^0b[01]+$/i;
458
+
459
+ /** Used to detect octal string values. */
460
+ var reIsOctal = /^0o[0-7]+$/i;
461
+
462
+ /** Built-in method references without a dependency on `root`. */
463
+ var freeParseInt = parseInt;
464
+
465
+ /**
466
+ * Converts `value` to a number.
467
+ *
468
+ * @static
469
+ * @memberOf _
470
+ * @since 4.0.0
471
+ * @category Lang
472
+ * @param {*} value The value to process.
473
+ * @returns {number} Returns the number.
474
+ * @example
475
+ *
476
+ * _.toNumber(3.2);
477
+ * // => 3.2
478
+ *
479
+ * _.toNumber(Number.MIN_VALUE);
480
+ * // => 5e-324
481
+ *
482
+ * _.toNumber(Infinity);
483
+ * // => Infinity
484
+ *
485
+ * _.toNumber('3.2');
486
+ * // => 3.2
487
+ */
488
+ function toNumber(value) {
489
+ if (typeof value == 'number') {
490
+ return value;
491
+ }
492
+ if (isSymbol(value)) {
493
+ return NAN;
494
+ }
495
+ if (isObject(value)) {
496
+ var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
497
+ value = isObject(other) ? (other + '') : other;
498
+ }
499
+ if (typeof value != 'string') {
500
+ return value === 0 ? value : +value;
501
+ }
502
+ value = baseTrim(value);
503
+ var isBinary = reIsBinary.test(value);
504
+ return (isBinary || reIsOctal.test(value))
505
+ ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
506
+ : (reIsBadHex.test(value) ? NAN : +value);
507
+ }
508
+
509
+ toNumber_1 = toNumber;
510
+ return toNumber_1;
511
+ }
512
+
513
+ var debounce_1;
514
+ var hasRequiredDebounce;
515
+
516
+ function requireDebounce () {
517
+ if (hasRequiredDebounce) return debounce_1;
518
+ hasRequiredDebounce = 1;
519
+ var isObject = requireIsObject(),
520
+ now = requireNow(),
521
+ toNumber = requireToNumber();
522
+
523
+ /** Error message constants. */
524
+ var FUNC_ERROR_TEXT = 'Expected a function';
525
+
526
+ /* Built-in method references for those with the same name as other `lodash` methods. */
527
+ var nativeMax = Math.max,
528
+ nativeMin = Math.min;
529
+
530
+ /**
531
+ * Creates a debounced function that delays invoking `func` until after `wait`
532
+ * milliseconds have elapsed since the last time the debounced function was
533
+ * invoked. The debounced function comes with a `cancel` method to cancel
534
+ * delayed `func` invocations and a `flush` method to immediately invoke them.
535
+ * Provide `options` to indicate whether `func` should be invoked on the
536
+ * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
537
+ * with the last arguments provided to the debounced function. Subsequent
538
+ * calls to the debounced function return the result of the last `func`
539
+ * invocation.
540
+ *
541
+ * **Note:** If `leading` and `trailing` options are `true`, `func` is
542
+ * invoked on the trailing edge of the timeout only if the debounced function
543
+ * is invoked more than once during the `wait` timeout.
544
+ *
545
+ * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
546
+ * until to the next tick, similar to `setTimeout` with a timeout of `0`.
547
+ *
548
+ * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
549
+ * for details over the differences between `_.debounce` and `_.throttle`.
550
+ *
551
+ * @static
552
+ * @memberOf _
553
+ * @since 0.1.0
554
+ * @category Function
555
+ * @param {Function} func The function to debounce.
556
+ * @param {number} [wait=0] The number of milliseconds to delay.
557
+ * @param {Object} [options={}] The options object.
558
+ * @param {boolean} [options.leading=false]
559
+ * Specify invoking on the leading edge of the timeout.
560
+ * @param {number} [options.maxWait]
561
+ * The maximum time `func` is allowed to be delayed before it's invoked.
562
+ * @param {boolean} [options.trailing=true]
563
+ * Specify invoking on the trailing edge of the timeout.
564
+ * @returns {Function} Returns the new debounced function.
565
+ * @example
566
+ *
567
+ * // Avoid costly calculations while the window size is in flux.
568
+ * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
569
+ *
570
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
571
+ * jQuery(element).on('click', _.debounce(sendMail, 300, {
572
+ * 'leading': true,
573
+ * 'trailing': false
574
+ * }));
575
+ *
576
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
577
+ * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
578
+ * var source = new EventSource('/stream');
579
+ * jQuery(source).on('message', debounced);
580
+ *
581
+ * // Cancel the trailing debounced invocation.
582
+ * jQuery(window).on('popstate', debounced.cancel);
583
+ */
584
+ function debounce(func, wait, options) {
585
+ var lastArgs,
586
+ lastThis,
587
+ maxWait,
588
+ result,
589
+ timerId,
590
+ lastCallTime,
591
+ lastInvokeTime = 0,
592
+ leading = false,
593
+ maxing = false,
594
+ trailing = true;
595
+
596
+ if (typeof func != 'function') {
597
+ throw new TypeError(FUNC_ERROR_TEXT);
598
+ }
599
+ wait = toNumber(wait) || 0;
600
+ if (isObject(options)) {
601
+ leading = !!options.leading;
602
+ maxing = 'maxWait' in options;
603
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
604
+ trailing = 'trailing' in options ? !!options.trailing : trailing;
605
+ }
606
+
607
+ function invokeFunc(time) {
608
+ var args = lastArgs,
609
+ thisArg = lastThis;
610
+
611
+ lastArgs = lastThis = undefined;
612
+ lastInvokeTime = time;
613
+ result = func.apply(thisArg, args);
614
+ return result;
615
+ }
616
+
617
+ function leadingEdge(time) {
618
+ // Reset any `maxWait` timer.
619
+ lastInvokeTime = time;
620
+ // Start the timer for the trailing edge.
621
+ timerId = setTimeout(timerExpired, wait);
622
+ // Invoke the leading edge.
623
+ return leading ? invokeFunc(time) : result;
624
+ }
625
+
626
+ function remainingWait(time) {
627
+ var timeSinceLastCall = time - lastCallTime,
628
+ timeSinceLastInvoke = time - lastInvokeTime,
629
+ timeWaiting = wait - timeSinceLastCall;
630
+
631
+ return maxing
632
+ ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
633
+ : timeWaiting;
634
+ }
635
+
636
+ function shouldInvoke(time) {
637
+ var timeSinceLastCall = time - lastCallTime,
638
+ timeSinceLastInvoke = time - lastInvokeTime;
639
+
640
+ // Either this is the first call, activity has stopped and we're at the
641
+ // trailing edge, the system time has gone backwards and we're treating
642
+ // it as the trailing edge, or we've hit the `maxWait` limit.
643
+ return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
644
+ (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
645
+ }
646
+
647
+ function timerExpired() {
648
+ var time = now();
649
+ if (shouldInvoke(time)) {
650
+ return trailingEdge(time);
651
+ }
652
+ // Restart the timer.
653
+ timerId = setTimeout(timerExpired, remainingWait(time));
654
+ }
655
+
656
+ function trailingEdge(time) {
657
+ timerId = undefined;
658
+
659
+ // Only invoke if we have `lastArgs` which means `func` has been
660
+ // debounced at least once.
661
+ if (trailing && lastArgs) {
662
+ return invokeFunc(time);
663
+ }
664
+ lastArgs = lastThis = undefined;
665
+ return result;
666
+ }
667
+
668
+ function cancel() {
669
+ if (timerId !== undefined) {
670
+ clearTimeout(timerId);
671
+ }
672
+ lastInvokeTime = 0;
673
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
674
+ }
675
+
676
+ function flush() {
677
+ return timerId === undefined ? result : trailingEdge(now());
678
+ }
679
+
680
+ function debounced() {
681
+ var time = now(),
682
+ isInvoking = shouldInvoke(time);
683
+
684
+ lastArgs = arguments;
685
+ lastThis = this;
686
+ lastCallTime = time;
687
+
688
+ if (isInvoking) {
689
+ if (timerId === undefined) {
690
+ return leadingEdge(lastCallTime);
691
+ }
692
+ if (maxing) {
693
+ // Handle invocations in a tight loop.
694
+ clearTimeout(timerId);
695
+ timerId = setTimeout(timerExpired, wait);
696
+ return invokeFunc(lastCallTime);
697
+ }
698
+ }
699
+ if (timerId === undefined) {
700
+ timerId = setTimeout(timerExpired, wait);
701
+ }
702
+ return result;
703
+ }
704
+ debounced.cancel = cancel;
705
+ debounced.flush = flush;
706
+ return debounced;
707
+ }
708
+
709
+ debounce_1 = debounce;
710
+ return debounce_1;
711
+ }
712
+
713
+ var debounceExports = requireDebounce();
714
+ var debounce = /*@__PURE__*/getDefaultExportFromCjs(debounceExports);
715
+
716
+ var TreeContext = createReactContext(null);
717
+
718
+ function _typeof$4(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$4 = function _typeof(obj) { return typeof obj; }; } else { _typeof$4 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$4(obj); }
719
+
720
+ function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose$1(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; }
721
+
722
+ function _objectWithoutPropertiesLoose$1(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; }
723
+
724
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
725
+
726
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty$2(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
727
+
728
+ function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
729
+
730
+ function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
731
+
732
+ function _defineProperties$3(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
733
+
734
+ function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); return Constructor; }
735
+
736
+ function _inherits$3(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$3(subClass, superClass); }
737
+
738
+ function _setPrototypeOf$3(o, p) { _setPrototypeOf$3 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$3(o, p); }
739
+
740
+ function _createSuper$3(Derived) { return function () { var Super = _getPrototypeOf$3(Derived), result; if (_isNativeReflectConstruct$3()) { var NewTarget = _getPrototypeOf$3(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$3(this, result); }; }
741
+
742
+ function _possibleConstructorReturn$3(self, call) { if (call && (_typeof$4(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$3(self); }
743
+
744
+ function _assertThisInitialized$3(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
745
+
746
+ function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
747
+
748
+ function _getPrototypeOf$3(o) { _getPrototypeOf$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$3(o); }
749
+ var ICON_OPEN = 'open';
750
+ var ICON_CLOSE = 'close';
751
+ var defaultTitle = '---';
752
+
753
+ var TreeNode = /*#__PURE__*/function (_React$Component) {
754
+ _inherits$3(TreeNode, _React$Component);
755
+
756
+ var _super = _createSuper$3(TreeNode);
757
+
758
+ function TreeNode() {
759
+ var _this;
760
+
761
+ _classCallCheck$3(this, TreeNode);
762
+
763
+ _this = _super.apply(this, arguments);
764
+ _this.state = {
765
+ dragNodeHighlight: false
766
+ };
767
+
768
+ _this.onSelectorClick = function (e) {
769
+ // Click trigger before select/check operation
770
+ var onNodeClick = _this.props.context.onNodeClick;
771
+ onNodeClick(e, _assertThisInitialized$3(_this));
772
+
773
+ if (_this.isSelectable()) {
774
+ _this.onSelect(e);
775
+ } else {
776
+ _this.onCheck(e);
777
+ }
778
+ };
779
+
780
+ _this.onSelectorDoubleClick = function (e) {
781
+ var onNodeDoubleClick = _this.props.context.onNodeDoubleClick;
782
+ onNodeDoubleClick(e, _assertThisInitialized$3(_this));
783
+ };
784
+
785
+ _this.onSelect = function (e) {
786
+ if (_this.isDisabled()) return;
787
+ var onNodeSelect = _this.props.context.onNodeSelect;
788
+ e.preventDefault();
789
+ onNodeSelect(e, _assertThisInitialized$3(_this));
790
+ };
791
+
792
+ _this.onCheck = function (e) {
793
+ if (_this.isDisabled()) return;
794
+ var _this$props = _this.props,
795
+ disableCheckbox = _this$props.disableCheckbox,
796
+ checked = _this$props.checked;
797
+ var onNodeCheck = _this.props.context.onNodeCheck;
798
+ if (!_this.isCheckable() || disableCheckbox) return;
799
+ e.preventDefault();
800
+ var targetChecked = !checked;
801
+ onNodeCheck(e, _assertThisInitialized$3(_this), targetChecked);
802
+ };
803
+
804
+ _this.onMouseEnter = function (e) {
805
+ var onNodeMouseEnter = _this.props.context.onNodeMouseEnter;
806
+ onNodeMouseEnter(e, _assertThisInitialized$3(_this));
807
+ };
808
+
809
+ _this.onMouseLeave = function (e) {
810
+ var onNodeMouseLeave = _this.props.context.onNodeMouseLeave;
811
+ onNodeMouseLeave(e, _assertThisInitialized$3(_this));
812
+ };
813
+
814
+ _this.onContextMenu = function (e) {
815
+ var onNodeContextMenu = _this.props.context.onNodeContextMenu;
816
+ onNodeContextMenu(e, _assertThisInitialized$3(_this));
817
+ };
818
+
819
+ _this.onDragStart = function (e) {
820
+ var onNodeDragStart = _this.props.context.onNodeDragStart;
821
+ e.stopPropagation();
822
+
823
+ _this.setState({
824
+ dragNodeHighlight: true
825
+ });
826
+
827
+ onNodeDragStart(e, _assertThisInitialized$3(_this));
828
+
829
+ try {
830
+ // ie throw error
831
+ // firefox-need-it
832
+ e.dataTransfer.setData('text/plain', '');
833
+ } catch (error) {// empty
834
+ }
835
+ };
836
+
837
+ _this.onDragEnter = function (e) {
838
+ var onNodeDragEnter = _this.props.context.onNodeDragEnter;
839
+ e.preventDefault();
840
+ e.stopPropagation();
841
+ onNodeDragEnter(e, _assertThisInitialized$3(_this));
842
+ };
843
+
844
+ _this.onDragOver = function (e) {
845
+ var onNodeDragOver = _this.props.context.onNodeDragOver;
846
+ e.preventDefault();
847
+ e.stopPropagation();
848
+ onNodeDragOver(e, _assertThisInitialized$3(_this));
849
+ };
850
+
851
+ _this.onDragLeave = function (e) {
852
+ var onNodeDragLeave = _this.props.context.onNodeDragLeave;
853
+ e.stopPropagation();
854
+ onNodeDragLeave(e, _assertThisInitialized$3(_this));
855
+ };
856
+
857
+ _this.onDragEnd = function (e) {
858
+ var onNodeDragEnd = _this.props.context.onNodeDragEnd;
859
+ e.stopPropagation();
860
+
861
+ _this.setState({
862
+ dragNodeHighlight: false
863
+ });
864
+
865
+ onNodeDragEnd(e, _assertThisInitialized$3(_this));
866
+ };
867
+
868
+ _this.onDrop = function (e) {
869
+ var onNodeDrop = _this.props.context.onNodeDrop;
870
+ e.preventDefault();
871
+ e.stopPropagation();
872
+
873
+ _this.setState({
874
+ dragNodeHighlight: false
875
+ });
876
+
877
+ onNodeDrop(e, _assertThisInitialized$3(_this));
878
+ }; // Disabled item still can be switch
879
+
880
+
881
+ _this.onExpand = function (e) {
882
+ var onNodeExpand = _this.props.context.onNodeExpand;
883
+ onNodeExpand(e, _assertThisInitialized$3(_this));
884
+ }; // Drag usage
885
+
886
+
887
+ _this.setSelectHandle = function (node) {
888
+ _this.selectHandle = node;
889
+ };
890
+
891
+ _this.getNodeChildren = function () {
892
+ var children = _this.props.children;
893
+ var originList = toArray(children).filter(function (node) {
894
+ return node;
895
+ });
896
+ var targetList = getNodeChildren(originList);
897
+
898
+ if (originList.length !== targetList.length) {
899
+ warnOnlyTreeNode();
900
+ }
901
+
902
+ return targetList;
903
+ };
904
+
905
+ _this.getNodeState = function () {
906
+ var expanded = _this.props.expanded;
907
+
908
+ if (_this.isLeaf()) {
909
+ return null;
910
+ }
911
+
912
+ return expanded ? ICON_OPEN : ICON_CLOSE;
913
+ };
914
+
915
+ _this.isLeaf = function () {
916
+ var _this$props2 = _this.props,
917
+ isLeaf = _this$props2.isLeaf,
918
+ loaded = _this$props2.loaded;
919
+ var loadData = _this.props.context.loadData;
920
+ var hasChildren = _this.getNodeChildren().length !== 0;
921
+
922
+ if (isLeaf === false) {
923
+ return false;
924
+ }
925
+
926
+ return isLeaf || !loadData && !hasChildren || loadData && loaded && !hasChildren;
927
+ };
928
+
929
+ _this.isDisabled = function () {
930
+ var disabled = _this.props.disabled;
931
+ var treeDisabled = _this.props.context.disabled; // Follow the logic of Selectable
932
+
933
+ if (disabled === false) {
934
+ return false;
935
+ }
936
+
937
+ return !!(treeDisabled || disabled);
938
+ };
939
+
940
+ _this.isCheckable = function () {
941
+ var checkable = _this.props.checkable;
942
+ var treeCheckable = _this.props.context.checkable; // Return false if tree or treeNode is not checkable
943
+
944
+ if (!treeCheckable || checkable === false) return false;
945
+ return treeCheckable;
946
+ }; // Load data to avoid default expanded tree without data
947
+
948
+
949
+ _this.syncLoadData = function (props) {
950
+ var expanded = props.expanded,
951
+ loading = props.loading,
952
+ loaded = props.loaded;
953
+ var _this$props$context = _this.props.context,
954
+ loadData = _this$props$context.loadData,
955
+ onNodeLoad = _this$props$context.onNodeLoad;
956
+ if (loading) return; // read from state to avoid loadData at same time
957
+
958
+ if (loadData && expanded && !_this.isLeaf()) {
959
+ // We needn't reload data when has children in sync logic
960
+ // It's only needed in node expanded
961
+ var hasChildren = _this.getNodeChildren().length !== 0;
962
+
963
+ if (!hasChildren && !loaded) {
964
+ onNodeLoad(_assertThisInitialized$3(_this));
965
+ }
966
+ }
967
+ }; // Switcher
968
+
969
+
970
+ _this.renderSwitcher = function () {
971
+ var _this$props3 = _this.props,
972
+ expanded = _this$props3.expanded,
973
+ switcherIconFromProps = _this$props3.switcherIcon;
974
+ var _this$props$context2 = _this.props.context,
975
+ prefixCls = _this$props$context2.prefixCls,
976
+ switcherIconFromCtx = _this$props$context2.switcherIcon;
977
+ var switcherIcon = switcherIconFromProps || switcherIconFromCtx;
978
+
979
+ if (_this.isLeaf()) {
980
+ return React.createElement("span", {
981
+ className: classNames("".concat(prefixCls, "-switcher"), "".concat(prefixCls, "-switcher-noop"))
982
+ }, typeof switcherIcon === 'function' ? switcherIcon(_objectSpread({}, _this.props, {
983
+ isLeaf: true
984
+ })) : switcherIcon);
985
+ }
986
+
987
+ var switcherCls = classNames("".concat(prefixCls, "-switcher"), "".concat(prefixCls, "-switcher_").concat(expanded ? ICON_OPEN : ICON_CLOSE));
988
+ return React.createElement("span", {
989
+ onClick: _this.onExpand,
990
+ className: switcherCls
991
+ }, typeof switcherIcon === 'function' ? switcherIcon(_objectSpread({}, _this.props, {
992
+ isLeaf: false
993
+ })) : switcherIcon);
994
+ }; // Checkbox
995
+
996
+
997
+ _this.renderCheckbox = function () {
998
+ var _this$props4 = _this.props,
999
+ checked = _this$props4.checked,
1000
+ halfChecked = _this$props4.halfChecked,
1001
+ disableCheckbox = _this$props4.disableCheckbox;
1002
+ var prefixCls = _this.props.context.prefixCls;
1003
+
1004
+ var disabled = _this.isDisabled();
1005
+
1006
+ var checkable = _this.isCheckable();
1007
+
1008
+ if (!checkable) return null; // [Legacy] Custom element should be separate with `checkable` in future
1009
+
1010
+ var $custom = typeof checkable !== 'boolean' ? checkable : null;
1011
+ return React.createElement("span", {
1012
+ className: classNames("".concat(prefixCls, "-checkbox"), checked && "".concat(prefixCls, "-checkbox-checked"), !checked && halfChecked && "".concat(prefixCls, "-checkbox-indeterminate"), (disabled || disableCheckbox) && "".concat(prefixCls, "-checkbox-disabled")),
1013
+ onClick: _this.onCheck
1014
+ }, $custom);
1015
+ };
1016
+
1017
+ _this.renderIcon = function () {
1018
+ var loading = _this.props.loading;
1019
+ var prefixCls = _this.props.context.prefixCls;
1020
+ return React.createElement("span", {
1021
+ className: classNames("".concat(prefixCls, "-iconEle"), "".concat(prefixCls, "-icon__").concat(_this.getNodeState() || 'docu'), loading && "".concat(prefixCls, "-icon_loading"))
1022
+ });
1023
+ }; // Icon + Title
1024
+
1025
+
1026
+ _this.renderSelector = function () {
1027
+ var dragNodeHighlight = _this.state.dragNodeHighlight;
1028
+ var _this$props5 = _this.props,
1029
+ title = _this$props5.title,
1030
+ selected = _this$props5.selected,
1031
+ icon = _this$props5.icon,
1032
+ loading = _this$props5.loading;
1033
+ var _this$props$context3 = _this.props.context,
1034
+ prefixCls = _this$props$context3.prefixCls,
1035
+ showIcon = _this$props$context3.showIcon,
1036
+ treeIcon = _this$props$context3.icon,
1037
+ draggable = _this$props$context3.draggable,
1038
+ loadData = _this$props$context3.loadData;
1039
+
1040
+ var disabled = _this.isDisabled();
1041
+
1042
+ var wrapClass = "".concat(prefixCls, "-node-content-wrapper"); // Icon - Still show loading icon when loading without showIcon
1043
+
1044
+ var $icon;
1045
+
1046
+ if (showIcon) {
1047
+ var currentIcon = icon || treeIcon;
1048
+ $icon = currentIcon ? React.createElement("span", {
1049
+ className: classNames("".concat(prefixCls, "-iconEle"), "".concat(prefixCls, "-icon__customize"))
1050
+ }, typeof currentIcon === 'function' ? currentIcon(_this.props) : currentIcon) : _this.renderIcon();
1051
+ } else if (loadData && loading) {
1052
+ $icon = _this.renderIcon();
1053
+ } // Title
1054
+
1055
+
1056
+ var $title = React.createElement("span", {
1057
+ className: "".concat(prefixCls, "-title")
1058
+ }, title);
1059
+ return React.createElement("span", {
1060
+ ref: _this.setSelectHandle,
1061
+ title: typeof title === 'string' ? title : '',
1062
+ className: classNames("".concat(wrapClass), "".concat(wrapClass, "-").concat(_this.getNodeState() || 'normal'), !disabled && (selected || dragNodeHighlight) && "".concat(prefixCls, "-node-selected"), !disabled && draggable && 'draggable'),
1063
+ draggable: !disabled && draggable || undefined,
1064
+ "aria-grabbed": !disabled && draggable || undefined,
1065
+ onMouseEnter: _this.onMouseEnter,
1066
+ onMouseLeave: _this.onMouseLeave,
1067
+ onContextMenu: _this.onContextMenu,
1068
+ onClick: _this.onSelectorClick,
1069
+ onDoubleClick: _this.onSelectorDoubleClick,
1070
+ onDragStart: draggable ? _this.onDragStart : undefined
1071
+ }, $icon, $title);
1072
+ }; // Children list wrapped with `Animation`
1073
+
1074
+
1075
+ _this.renderChildren = function () {
1076
+ var _this$props6 = _this.props,
1077
+ expanded = _this$props6.expanded,
1078
+ pos = _this$props6.pos;
1079
+ var _this$props$context4 = _this.props.context,
1080
+ prefixCls = _this$props$context4.prefixCls,
1081
+ motion = _this$props$context4.motion,
1082
+ renderTreeNode = _this$props$context4.renderTreeNode; // Children TreeNode
1083
+
1084
+ var nodeList = _this.getNodeChildren();
1085
+
1086
+ if (nodeList.length === 0) {
1087
+ return null;
1088
+ }
1089
+
1090
+ return React.createElement(OriginCSSMotion, Object.assign({
1091
+ visible: expanded
1092
+ }, motion), function (_ref) {
1093
+ var style = _ref.style,
1094
+ className = _ref.className;
1095
+ return React.createElement("ul", {
1096
+ className: classNames(className, "".concat(prefixCls, "-child-tree"), expanded && "".concat(prefixCls, "-child-tree-open")),
1097
+ style: style,
1098
+ "data-expanded": expanded,
1099
+ role: "group"
1100
+ }, mapChildren(nodeList, function (node, index) {
1101
+ return renderTreeNode(node, index, pos);
1102
+ }));
1103
+ });
1104
+ };
1105
+
1106
+ return _this;
1107
+ } // Isomorphic needn't load data in server side
1108
+
1109
+
1110
+ _createClass$3(TreeNode, [{
1111
+ key: "componentDidMount",
1112
+ value: function componentDidMount() {
1113
+ var _this$props7 = this.props,
1114
+ eventKey = _this$props7.eventKey,
1115
+ registerTreeNode = _this$props7.context.registerTreeNode;
1116
+ this.syncLoadData(this.props);
1117
+ registerTreeNode(eventKey, this);
1118
+ }
1119
+ }, {
1120
+ key: "componentDidUpdate",
1121
+ value: function componentDidUpdate() {
1122
+ this.syncLoadData(this.props);
1123
+ }
1124
+ }, {
1125
+ key: "componentWillUnmount",
1126
+ value: function componentWillUnmount() {
1127
+ var _this$props8 = this.props,
1128
+ eventKey = _this$props8.eventKey,
1129
+ registerTreeNode = _this$props8.context.registerTreeNode;
1130
+ registerTreeNode(eventKey, null);
1131
+ }
1132
+ }, {
1133
+ key: "isSelectable",
1134
+ value: function isSelectable() {
1135
+ var selectable = this.props.selectable;
1136
+ var treeSelectable = this.props.context.selectable; // Ignore when selectable is undefined or null
1137
+
1138
+ if (typeof selectable === 'boolean') {
1139
+ return selectable;
1140
+ }
1141
+
1142
+ return treeSelectable;
1143
+ }
1144
+ }, {
1145
+ key: "render",
1146
+ value: function render() {
1147
+ var _classNames;
1148
+
1149
+ var loading = this.props.loading;
1150
+
1151
+ var _this$props9 = this.props,
1152
+ className = _this$props9.className,
1153
+ style = _this$props9.style,
1154
+ dragOver = _this$props9.dragOver,
1155
+ dragOverGapTop = _this$props9.dragOverGapTop,
1156
+ dragOverGapBottom = _this$props9.dragOverGapBottom,
1157
+ isLeaf = _this$props9.isLeaf,
1158
+ expanded = _this$props9.expanded,
1159
+ selected = _this$props9.selected,
1160
+ checked = _this$props9.checked,
1161
+ halfChecked = _this$props9.halfChecked,
1162
+ otherProps = _objectWithoutProperties$1(_this$props9, ["className", "style", "dragOver", "dragOverGapTop", "dragOverGapBottom", "isLeaf", "expanded", "selected", "checked", "halfChecked"]);
1163
+
1164
+ var _this$props$context5 = this.props.context,
1165
+ prefixCls = _this$props$context5.prefixCls,
1166
+ filterTreeNode = _this$props$context5.filterTreeNode,
1167
+ draggable = _this$props$context5.draggable;
1168
+ var disabled = this.isDisabled();
1169
+ var dataOrAriaAttributeProps = getDataAndAria(otherProps);
1170
+ return React.createElement("li", Object.assign({
1171
+ className: classNames(className, (_classNames = {}, _defineProperty$2(_classNames, "".concat(prefixCls, "-treenode-disabled"), disabled), _defineProperty$2(_classNames, "".concat(prefixCls, "-treenode-switcher-").concat(expanded ? 'open' : 'close'), !isLeaf), _defineProperty$2(_classNames, "".concat(prefixCls, "-treenode-checkbox-checked"), checked), _defineProperty$2(_classNames, "".concat(prefixCls, "-treenode-checkbox-indeterminate"), halfChecked), _defineProperty$2(_classNames, "".concat(prefixCls, "-treenode-selected"), selected), _defineProperty$2(_classNames, "".concat(prefixCls, "-treenode-loading"), loading), _defineProperty$2(_classNames, 'drag-over', !disabled && dragOver), _defineProperty$2(_classNames, 'drag-over-gap-top', !disabled && dragOverGapTop), _defineProperty$2(_classNames, 'drag-over-gap-bottom', !disabled && dragOverGapBottom), _defineProperty$2(_classNames, 'filter-node', filterTreeNode && filterTreeNode(this)), _classNames)),
1172
+ style: style,
1173
+ role: "treeitem",
1174
+ onDragEnter: draggable ? this.onDragEnter : undefined,
1175
+ onDragOver: draggable ? this.onDragOver : undefined,
1176
+ onDragLeave: draggable ? this.onDragLeave : undefined,
1177
+ onDrop: draggable ? this.onDrop : undefined,
1178
+ onDragEnd: draggable ? this.onDragEnd : undefined
1179
+ }, dataOrAriaAttributeProps), this.renderSwitcher(), this.renderCheckbox(), this.renderSelector(), this.renderChildren());
1180
+ }
1181
+ }]);
1182
+
1183
+ return TreeNode;
1184
+ }(React.Component);
1185
+
1186
+ TreeNode.propTypes = {
1187
+ eventKey: PropTypes.string,
1188
+ prefixCls: PropTypes.string,
1189
+ className: PropTypes.string,
1190
+ style: PropTypes.object,
1191
+ onSelect: PropTypes.func,
1192
+ // By parent
1193
+ expanded: PropTypes.bool,
1194
+ selected: PropTypes.bool,
1195
+ checked: PropTypes.bool,
1196
+ loaded: PropTypes.bool,
1197
+ loading: PropTypes.bool,
1198
+ halfChecked: PropTypes.bool,
1199
+ children: PropTypes.node,
1200
+ title: PropTypes.node,
1201
+ pos: PropTypes.string,
1202
+ dragOver: PropTypes.bool,
1203
+ dragOverGapTop: PropTypes.bool,
1204
+ dragOverGapBottom: PropTypes.bool,
1205
+ // By user
1206
+ isLeaf: PropTypes.bool,
1207
+ checkable: PropTypes.bool,
1208
+ selectable: PropTypes.bool,
1209
+ disabled: PropTypes.bool,
1210
+ disableCheckbox: PropTypes.bool,
1211
+ icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
1212
+ switcherIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
1213
+ };
1214
+ polyfill(TreeNode);
1215
+
1216
+ var ContextTreeNode = function ContextTreeNode(props) {
1217
+ return React.createElement(TreeContext.Consumer, null, function (context) {
1218
+ return React.createElement(TreeNode, Object.assign({}, props, {
1219
+ context: context
1220
+ }));
1221
+ });
1222
+ };
1223
+
1224
+ ContextTreeNode.defaultProps = {
1225
+ title: defaultTitle
1226
+ };
1227
+ ContextTreeNode.isTreeNode = 1;
1228
+
1229
+ function _typeof$3(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$3 = function _typeof(obj) { return typeof obj; }; } else { _typeof$3 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$3(obj); }
1230
+
1231
+ 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; }
1232
+
1233
+ 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; }
1234
+ var DRAG_SIDE_RANGE = 0.25;
1235
+ var DRAG_MIN_GAP = 2;
1236
+ var onlyTreeNodeWarned = false;
1237
+ function warnOnlyTreeNode() {
1238
+ if (onlyTreeNodeWarned) return;
1239
+ onlyTreeNodeWarned = true;
1240
+ warning(false, 'Tree only accept TreeNode as children.');
1241
+ }
1242
+ function arrDel(list, value) {
1243
+ var clone = list.slice();
1244
+ var index = clone.indexOf(value);
1245
+
1246
+ if (index >= 0) {
1247
+ clone.splice(index, 1);
1248
+ }
1249
+
1250
+ return clone;
1251
+ }
1252
+ function arrAdd(list, value) {
1253
+ var clone = list.slice();
1254
+
1255
+ if (clone.indexOf(value) === -1) {
1256
+ clone.push(value);
1257
+ }
1258
+
1259
+ return clone;
1260
+ }
1261
+ function posToArr(pos) {
1262
+ return pos.split('-');
1263
+ }
1264
+ function getPosition(level, index) {
1265
+ return "".concat(level, "-").concat(index);
1266
+ }
1267
+ function isTreeNode(node) {
1268
+ return node && node.type && node.type.isTreeNode;
1269
+ }
1270
+ function getNodeChildren(children) {
1271
+ return toArray(children).filter(isTreeNode);
1272
+ }
1273
+ function isCheckDisabled(node) {
1274
+ var _ref = node.props || {},
1275
+ disabled = _ref.disabled,
1276
+ disableCheckbox = _ref.disableCheckbox,
1277
+ checkable = _ref.checkable;
1278
+
1279
+ return !!(disabled || disableCheckbox) || checkable === false;
1280
+ }
1281
+ function traverseTreeNodes(treeNodes, callback) {
1282
+ function processNode(node, index, parent) {
1283
+ var children = node ? node.props.children : treeNodes;
1284
+ var pos = node ? getPosition(parent.pos, index) : 0; // Filter children
1285
+
1286
+ var childList = getNodeChildren(children); // Process node if is not root
1287
+
1288
+ if (node) {
1289
+ var data = {
1290
+ node: node,
1291
+ index: index,
1292
+ pos: pos,
1293
+ key: node.key || pos,
1294
+ parentPos: parent.node ? parent.pos : null
1295
+ };
1296
+ callback(data);
1297
+ } // Process children node
1298
+
1299
+
1300
+ Children.forEach(childList, function (subNode, subIndex) {
1301
+ processNode(subNode, subIndex, {
1302
+ node: node,
1303
+ pos: pos
1304
+ });
1305
+ });
1306
+ }
1307
+
1308
+ processNode(null);
1309
+ }
1310
+ /**
1311
+ * Use `rc-util` `toArray` to get the children list which keeps the key.
1312
+ * And return single node if children is only one(This can avoid `key` missing check).
1313
+ */
1314
+
1315
+ function mapChildren(children, func) {
1316
+ var list = toArray(children).map(func);
1317
+
1318
+ if (list.length === 1) {
1319
+ return list[0];
1320
+ }
1321
+
1322
+ return list;
1323
+ }
1324
+ function getDragNodesKeys(treeNodes, node) {
1325
+ var _node$props = node.props,
1326
+ eventKey = _node$props.eventKey,
1327
+ pos = _node$props.pos;
1328
+ var dragNodesKeys = [];
1329
+ traverseTreeNodes(treeNodes, function (_ref2) {
1330
+ var key = _ref2.key;
1331
+ dragNodesKeys.push(key);
1332
+ });
1333
+ dragNodesKeys.push(eventKey || pos);
1334
+ return dragNodesKeys;
1335
+ } // Only used when drag, not affect SSR.
1336
+
1337
+ function calcDropPosition(event, treeNode) {
1338
+ var clientY = event.clientY;
1339
+
1340
+ var _treeNode$selectHandl = treeNode.selectHandle.getBoundingClientRect(),
1341
+ top = _treeNode$selectHandl.top,
1342
+ bottom = _treeNode$selectHandl.bottom,
1343
+ height = _treeNode$selectHandl.height;
1344
+
1345
+ var des = Math.max(height * DRAG_SIDE_RANGE, DRAG_MIN_GAP);
1346
+
1347
+ if (clientY <= top + des) {
1348
+ return -1;
1349
+ }
1350
+
1351
+ if (clientY >= bottom - des) {
1352
+ return 1;
1353
+ }
1354
+
1355
+ return 0;
1356
+ }
1357
+ /**
1358
+ * Return selectedKeys according with multiple prop
1359
+ * @param selectedKeys
1360
+ * @param props
1361
+ * @returns [string]
1362
+ */
1363
+
1364
+ function calcSelectedKeys(selectedKeys, props) {
1365
+ if (!selectedKeys) return undefined;
1366
+ var multiple = props.multiple;
1367
+
1368
+ if (multiple) {
1369
+ return selectedKeys.slice();
1370
+ }
1371
+
1372
+ if (selectedKeys.length) {
1373
+ return [selectedKeys[0]];
1374
+ }
1375
+
1376
+ return selectedKeys;
1377
+ }
1378
+ /**
1379
+ * Since React internal will convert key to string,
1380
+ * we need do this to avoid `checkStrictly` use number match
1381
+ */
1382
+
1383
+ function keyListToString(keyList) {
1384
+ if (!keyList) return keyList;
1385
+ return keyList.map(function (key) {
1386
+ return String(key);
1387
+ });
1388
+ }
1389
+
1390
+ var internalProcessProps = function internalProcessProps(props) {
1391
+ return props;
1392
+ };
1393
+
1394
+ function convertDataToTree(treeData, processor) {
1395
+ if (!treeData) return [];
1396
+
1397
+ var _ref3 = {},
1398
+ _ref3$processProps = _ref3.processProps,
1399
+ processProps = _ref3$processProps === void 0 ? internalProcessProps : _ref3$processProps;
1400
+
1401
+ var list = Array.isArray(treeData) ? treeData : [treeData];
1402
+ return list.map(function (_ref4) {
1403
+ var children = _ref4.children,
1404
+ props = _objectWithoutProperties(_ref4, ["children"]);
1405
+
1406
+ var childrenNodes = convertDataToTree(children);
1407
+ return React__default.createElement(ContextTreeNode, Object.assign({}, processProps(props)), childrenNodes);
1408
+ });
1409
+ }
1410
+ /**
1411
+ * Calculate treeNodes entities. `processTreeEntity` is used for `rc-tree-select`
1412
+ * @param treeNodes
1413
+ * @param processTreeEntity User can customize the entity
1414
+ */
1415
+
1416
+ function convertTreeToEntities(treeNodes) {
1417
+ var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
1418
+ initWrapper = _ref5.initWrapper,
1419
+ processEntity = _ref5.processEntity,
1420
+ onProcessFinished = _ref5.onProcessFinished;
1421
+
1422
+ var posEntities = {};
1423
+ var keyEntities = {};
1424
+ var wrapper = {
1425
+ posEntities: posEntities,
1426
+ keyEntities: keyEntities
1427
+ };
1428
+
1429
+ if (initWrapper) {
1430
+ wrapper = initWrapper(wrapper) || wrapper;
1431
+ }
1432
+
1433
+ traverseTreeNodes(treeNodes, function (item) {
1434
+ var node = item.node,
1435
+ index = item.index,
1436
+ pos = item.pos,
1437
+ key = item.key,
1438
+ parentPos = item.parentPos;
1439
+ var entity = {
1440
+ node: node,
1441
+ index: index,
1442
+ key: key,
1443
+ pos: pos
1444
+ };
1445
+ posEntities[pos] = entity;
1446
+ keyEntities[key] = entity; // Fill children
1447
+
1448
+ entity.parent = posEntities[parentPos];
1449
+
1450
+ if (entity.parent) {
1451
+ entity.parent.children = entity.parent.children || [];
1452
+ entity.parent.children.push(entity);
1453
+ }
1454
+
1455
+ if (processEntity) {
1456
+ processEntity(entity, wrapper);
1457
+ }
1458
+ });
1459
+
1460
+ if (onProcessFinished) {
1461
+ onProcessFinished(wrapper);
1462
+ }
1463
+
1464
+ return wrapper;
1465
+ }
1466
+ /**
1467
+ * Parse `checkedKeys` to { checkedKeys, halfCheckedKeys } style
1468
+ */
1469
+
1470
+ function parseCheckedKeys(keys) {
1471
+ if (!keys) {
1472
+ return null;
1473
+ } // Convert keys to object format
1474
+
1475
+
1476
+ var keyProps;
1477
+
1478
+ if (Array.isArray(keys)) {
1479
+ // [Legacy] Follow the api doc
1480
+ keyProps = {
1481
+ checkedKeys: keys,
1482
+ halfCheckedKeys: undefined
1483
+ };
1484
+ } else if (_typeof$3(keys) === 'object') {
1485
+ keyProps = {
1486
+ checkedKeys: keys.checked || undefined,
1487
+ halfCheckedKeys: keys.halfChecked || undefined
1488
+ };
1489
+ } else {
1490
+ warning(false, '`checkedKeys` is not an array or an object');
1491
+ return null;
1492
+ }
1493
+
1494
+ keyProps.checkedKeys = keyListToString(keyProps.checkedKeys);
1495
+ keyProps.halfCheckedKeys = keyListToString(keyProps.halfCheckedKeys);
1496
+ return keyProps;
1497
+ }
1498
+ /**
1499
+ * Conduct check state by the keyList. It will conduct up & from the provided key.
1500
+ * If the conduct path reach the disabled or already checked / unchecked node will stop conduct.
1501
+ */
1502
+
1503
+ function conductCheck(
1504
+ /** list of keys */
1505
+ keyList,
1506
+ /** is check the node or not */
1507
+ isCheck,
1508
+ /** parsed by `convertTreeToEntities` function in Tree */
1509
+ keyEntities) {
1510
+ var checkStatus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1511
+ var checkedKeys = {};
1512
+ var halfCheckedKeys = {}; // Record the key has some child checked (include child half checked)
1513
+
1514
+ (checkStatus.checkedKeys || []).forEach(function (key) {
1515
+ checkedKeys[key] = true;
1516
+ });
1517
+ (checkStatus.halfCheckedKeys || []).forEach(function (key) {
1518
+ halfCheckedKeys[key] = true;
1519
+ }); // Conduct up
1520
+
1521
+ function conductUp(key) {
1522
+ if (checkedKeys[key] === isCheck) return;
1523
+ var entity = keyEntities[key];
1524
+ if (!entity) return;
1525
+ var children = entity.children,
1526
+ parent = entity.parent,
1527
+ node = entity.node;
1528
+ if (isCheckDisabled(node)) return; // Check child node checked status
1529
+
1530
+ var everyChildChecked = true;
1531
+ var someChildChecked = false; // Child checked or half checked
1532
+
1533
+ (children || []).filter(function (child) {
1534
+ return !isCheckDisabled(child.node);
1535
+ }).forEach(function (_ref6) {
1536
+ var childKey = _ref6.key;
1537
+ var childChecked = checkedKeys[childKey];
1538
+ var childHalfChecked = halfCheckedKeys[childKey];
1539
+ if (childChecked || childHalfChecked) someChildChecked = true;
1540
+ if (!childChecked) everyChildChecked = false;
1541
+ }); // Update checked status
1542
+
1543
+ if (isCheck) {
1544
+ checkedKeys[key] = everyChildChecked;
1545
+ } else {
1546
+ checkedKeys[key] = false;
1547
+ }
1548
+
1549
+ halfCheckedKeys[key] = someChildChecked;
1550
+
1551
+ if (parent) {
1552
+ conductUp(parent.key);
1553
+ }
1554
+ } // Conduct down
1555
+
1556
+
1557
+ function conductDown(key) {
1558
+ if (checkedKeys[key] === isCheck) return;
1559
+ var entity = keyEntities[key];
1560
+ if (!entity) return;
1561
+ var children = entity.children,
1562
+ node = entity.node;
1563
+ if (isCheckDisabled(node)) return;
1564
+ checkedKeys[key] = isCheck;
1565
+ (children || []).forEach(function (child) {
1566
+ conductDown(child.key);
1567
+ });
1568
+ }
1569
+
1570
+ function conduct(key) {
1571
+ var entity = keyEntities[key];
1572
+
1573
+ if (!entity) {
1574
+ warning(false, "'".concat(key, "' does not exist in the tree."));
1575
+ return;
1576
+ }
1577
+
1578
+ var children = entity.children,
1579
+ parent = entity.parent,
1580
+ node = entity.node;
1581
+ checkedKeys[key] = isCheck;
1582
+ if (isCheckDisabled(node)) return; // Conduct down
1583
+
1584
+ (children || []).filter(function (child) {
1585
+ return !isCheckDisabled(child.node);
1586
+ }).forEach(function (child) {
1587
+ conductDown(child.key);
1588
+ }); // Conduct up
1589
+
1590
+ if (parent) {
1591
+ conductUp(parent.key);
1592
+ }
1593
+ }
1594
+
1595
+ (keyList || []).forEach(function (key) {
1596
+ conduct(key);
1597
+ });
1598
+ var checkedKeyList = [];
1599
+ var halfCheckedKeyList = []; // Fill checked list
1600
+
1601
+ Object.keys(checkedKeys).forEach(function (key) {
1602
+ if (checkedKeys[key]) {
1603
+ checkedKeyList.push(key);
1604
+ }
1605
+ }); // Fill half checked list
1606
+
1607
+ Object.keys(halfCheckedKeys).forEach(function (key) {
1608
+ if (!checkedKeys[key] && halfCheckedKeys[key]) {
1609
+ halfCheckedKeyList.push(key);
1610
+ }
1611
+ });
1612
+ return {
1613
+ checkedKeys: checkedKeyList,
1614
+ halfCheckedKeys: halfCheckedKeyList
1615
+ };
1616
+ }
1617
+ /**
1618
+ * If user use `autoExpandParent` we should get the list of parent node
1619
+ * @param keyList
1620
+ * @param keyEntities
1621
+ */
1622
+
1623
+ function conductExpandParent(keyList, keyEntities) {
1624
+ var expandedKeys = {};
1625
+
1626
+ function conductUp(key) {
1627
+ if (expandedKeys[key]) return;
1628
+ var entity = keyEntities[key];
1629
+ if (!entity) return;
1630
+ expandedKeys[key] = true;
1631
+ var parent = entity.parent,
1632
+ node = entity.node;
1633
+ if (node.props && node.props.disabled) return;
1634
+
1635
+ if (parent) {
1636
+ conductUp(parent.key);
1637
+ }
1638
+ }
1639
+
1640
+ (keyList || []).forEach(function (key) {
1641
+ conductUp(key);
1642
+ });
1643
+ return Object.keys(expandedKeys);
1644
+ }
1645
+ /**
1646
+ * Returns only the data- and aria- key/value pairs
1647
+ */
1648
+
1649
+ function getDataAndAria(props) {
1650
+ return Object.keys(props).reduce(function (prev, key) {
1651
+ if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
1652
+ prev[key] = props[key];
1653
+ }
1654
+
1655
+ return prev;
1656
+ }, {});
1657
+ }
1658
+
1659
+ function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
1660
+
1661
+ function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1662
+
1663
+ function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1664
+
1665
+ function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1666
+
1667
+ function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
1668
+
1669
+ function _inherits$2(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$2(subClass, superClass); }
1670
+
1671
+ function _setPrototypeOf$2(o, p) { _setPrototypeOf$2 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$2(o, p); }
1672
+
1673
+ function _createSuper$2(Derived) { return function () { var Super = _getPrototypeOf$2(Derived), result; if (_isNativeReflectConstruct$2()) { var NewTarget = _getPrototypeOf$2(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$2(this, result); }; }
1674
+
1675
+ function _possibleConstructorReturn$2(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$2(self); }
1676
+
1677
+ function _assertThisInitialized$2(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1678
+
1679
+ function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
1680
+
1681
+ function _getPrototypeOf$2(o) { _getPrototypeOf$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$2(o); }
1682
+
1683
+ var Tree$2 = /*#__PURE__*/function (_React$Component) {
1684
+ _inherits$2(Tree, _React$Component);
1685
+
1686
+ var _super = _createSuper$2(Tree);
1687
+
1688
+ function Tree() {
1689
+ var _this;
1690
+
1691
+ _classCallCheck$2(this, Tree);
1692
+
1693
+ _this = _super.apply(this, arguments);
1694
+ /** Internal usage for `rc-tree-select`, we don't promise it will not change. */
1695
+
1696
+ _this.domTreeNodes = {};
1697
+ _this.state = {
1698
+ keyEntities: {},
1699
+ selectedKeys: [],
1700
+ checkedKeys: [],
1701
+ halfCheckedKeys: [],
1702
+ loadedKeys: [],
1703
+ loadingKeys: [],
1704
+ expandedKeys: [],
1705
+ dragNodesKeys: [],
1706
+ dragOverNodeKey: null,
1707
+ dropPosition: null,
1708
+ treeNode: [],
1709
+ prevProps: null
1710
+ };
1711
+
1712
+ _this.onNodeDragStart = function (event, node) {
1713
+ var expandedKeys = _this.state.expandedKeys;
1714
+ var onDragStart = _this.props.onDragStart;
1715
+ var _node$props = node.props,
1716
+ eventKey = _node$props.eventKey,
1717
+ children = _node$props.children;
1718
+ _this.dragNode = node;
1719
+
1720
+ _this.setState({
1721
+ dragNodesKeys: getDragNodesKeys(children, node),
1722
+ expandedKeys: arrDel(expandedKeys, eventKey)
1723
+ });
1724
+
1725
+ if (onDragStart) {
1726
+ onDragStart({
1727
+ event: event,
1728
+ node: node
1729
+ });
1730
+ }
1731
+ };
1732
+ /**
1733
+ * [Legacy] Select handler is less small than node,
1734
+ * so that this will trigger when drag enter node or select handler.
1735
+ * This is a little tricky if customize css without padding.
1736
+ * Better for use mouse move event to refresh drag state.
1737
+ * But let's just keep it to avoid event trigger logic change.
1738
+ */
1739
+
1740
+
1741
+ _this.onNodeDragEnter = function (event, node) {
1742
+ var _this$state = _this.state,
1743
+ expandedKeys = _this$state.expandedKeys,
1744
+ dragNodesKeys = _this$state.dragNodesKeys;
1745
+ var onDragEnter = _this.props.onDragEnter;
1746
+ var _node$props2 = node.props,
1747
+ pos = _node$props2.pos,
1748
+ eventKey = _node$props2.eventKey;
1749
+ if (!_this.dragNode || dragNodesKeys.indexOf(eventKey) !== -1) return;
1750
+ var dropPosition = calcDropPosition(event, node); // Skip if drag node is self
1751
+
1752
+ if (_this.dragNode.props.eventKey === eventKey && dropPosition === 0) {
1753
+ _this.setState({
1754
+ dragOverNodeKey: '',
1755
+ dropPosition: null
1756
+ });
1757
+
1758
+ return;
1759
+ } // Ref: https://github.com/react-component/tree/issues/132
1760
+ // Add timeout to let onDragLevel fire before onDragEnter,
1761
+ // so that we can clean drag props for onDragLeave node.
1762
+ // Macro task for this:
1763
+ // https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script
1764
+
1765
+
1766
+ setTimeout(function () {
1767
+ // Update drag over node
1768
+ _this.setState({
1769
+ dragOverNodeKey: eventKey,
1770
+ dropPosition: dropPosition
1771
+ }); // Side effect for delay drag
1772
+
1773
+
1774
+ if (!_this.delayedDragEnterLogic) {
1775
+ _this.delayedDragEnterLogic = {};
1776
+ }
1777
+
1778
+ Object.keys(_this.delayedDragEnterLogic).forEach(function (key) {
1779
+ clearTimeout(_this.delayedDragEnterLogic[key]);
1780
+ });
1781
+ _this.delayedDragEnterLogic[pos] = window.setTimeout(function () {
1782
+ var newExpandedKeys = arrAdd(expandedKeys, eventKey);
1783
+
1784
+ if (!('expandedKeys' in _this.props)) {
1785
+ _this.setState({
1786
+ expandedKeys: newExpandedKeys
1787
+ });
1788
+ }
1789
+
1790
+ if (onDragEnter) {
1791
+ onDragEnter({
1792
+ event: event,
1793
+ node: node,
1794
+ expandedKeys: newExpandedKeys
1795
+ });
1796
+ }
1797
+ }, 400);
1798
+ }, 0);
1799
+ };
1800
+
1801
+ _this.onNodeDragOver = function (event, node) {
1802
+ var dragNodesKeys = _this.state.dragNodesKeys;
1803
+ var onDragOver = _this.props.onDragOver;
1804
+ var eventKey = node.props.eventKey;
1805
+
1806
+ if (dragNodesKeys.indexOf(eventKey) !== -1) {
1807
+ return;
1808
+ } // Update drag position
1809
+
1810
+
1811
+ if (_this.dragNode && eventKey === _this.state.dragOverNodeKey) {
1812
+ var dropPosition = calcDropPosition(event, node);
1813
+ if (dropPosition === _this.state.dropPosition) return;
1814
+
1815
+ _this.setState({
1816
+ dropPosition: dropPosition
1817
+ });
1818
+ }
1819
+
1820
+ if (onDragOver) {
1821
+ onDragOver({
1822
+ event: event,
1823
+ node: node
1824
+ });
1825
+ }
1826
+ };
1827
+
1828
+ _this.onNodeDragLeave = function (event, node) {
1829
+ var onDragLeave = _this.props.onDragLeave;
1830
+
1831
+ _this.setState({
1832
+ dragOverNodeKey: ''
1833
+ });
1834
+
1835
+ if (onDragLeave) {
1836
+ onDragLeave({
1837
+ event: event,
1838
+ node: node
1839
+ });
1840
+ }
1841
+ };
1842
+
1843
+ _this.onNodeDragEnd = function (event, node) {
1844
+ var onDragEnd = _this.props.onDragEnd;
1845
+
1846
+ _this.setState({
1847
+ dragOverNodeKey: ''
1848
+ });
1849
+
1850
+ if (onDragEnd) {
1851
+ onDragEnd({
1852
+ event: event,
1853
+ node: node
1854
+ });
1855
+ }
1856
+
1857
+ _this.dragNode = null;
1858
+ };
1859
+
1860
+ _this.onNodeDrop = function (event, node) {
1861
+ var _this$state2 = _this.state,
1862
+ _this$state2$dragNode = _this$state2.dragNodesKeys,
1863
+ dragNodesKeys = _this$state2$dragNode === void 0 ? [] : _this$state2$dragNode,
1864
+ dropPosition = _this$state2.dropPosition;
1865
+ var onDrop = _this.props.onDrop;
1866
+ var _node$props3 = node.props,
1867
+ eventKey = _node$props3.eventKey,
1868
+ pos = _node$props3.pos;
1869
+
1870
+ _this.setState({
1871
+ dragOverNodeKey: ''
1872
+ });
1873
+
1874
+ if (dragNodesKeys.indexOf(eventKey) !== -1) {
1875
+ warning(false, "Can not drop to dragNode(include it's children node)");
1876
+ return;
1877
+ }
1878
+
1879
+ var posArr = posToArr(pos);
1880
+ var dropResult = {
1881
+ event: event,
1882
+ node: node,
1883
+ dragNode: _this.dragNode,
1884
+ dragNodesKeys: dragNodesKeys.slice(),
1885
+ dropPosition: dropPosition + Number(posArr[posArr.length - 1]),
1886
+ dropToGap: false
1887
+ };
1888
+
1889
+ if (dropPosition !== 0) {
1890
+ dropResult.dropToGap = true;
1891
+ }
1892
+
1893
+ if (onDrop) {
1894
+ onDrop(dropResult);
1895
+ }
1896
+
1897
+ _this.dragNode = null;
1898
+ };
1899
+
1900
+ _this.onNodeClick = function (e, treeNode) {
1901
+ var onClick = _this.props.onClick;
1902
+
1903
+ if (onClick) {
1904
+ onClick(e, treeNode);
1905
+ }
1906
+ };
1907
+
1908
+ _this.onNodeDoubleClick = function (e, treeNode) {
1909
+ var onDoubleClick = _this.props.onDoubleClick;
1910
+
1911
+ if (onDoubleClick) {
1912
+ onDoubleClick(e, treeNode);
1913
+ }
1914
+ };
1915
+
1916
+ _this.onNodeSelect = function (e, treeNode) {
1917
+ var selectedKeys = _this.state.selectedKeys;
1918
+ var keyEntities = _this.state.keyEntities;
1919
+ var _this$props = _this.props,
1920
+ onSelect = _this$props.onSelect,
1921
+ multiple = _this$props.multiple;
1922
+ var _treeNode$props = treeNode.props,
1923
+ selected = _treeNode$props.selected,
1924
+ eventKey = _treeNode$props.eventKey;
1925
+ var targetSelected = !selected; // Update selected keys
1926
+
1927
+ if (!targetSelected) {
1928
+ selectedKeys = arrDel(selectedKeys, eventKey);
1929
+ } else if (!multiple) {
1930
+ selectedKeys = [eventKey];
1931
+ } else {
1932
+ selectedKeys = arrAdd(selectedKeys, eventKey);
1933
+ } // [Legacy] Not found related usage in doc or upper libs
1934
+
1935
+
1936
+ var selectedNodes = selectedKeys.map(function (key) {
1937
+ var entity = keyEntities[key];
1938
+ if (!entity) return null;
1939
+ return entity.node;
1940
+ }).filter(function (node) {
1941
+ return node;
1942
+ });
1943
+
1944
+ _this.setUncontrolledState({
1945
+ selectedKeys: selectedKeys
1946
+ });
1947
+
1948
+ if (onSelect) {
1949
+ onSelect(selectedKeys, {
1950
+ event: 'select',
1951
+ selected: targetSelected,
1952
+ node: treeNode,
1953
+ selectedNodes: selectedNodes,
1954
+ nativeEvent: e.nativeEvent
1955
+ });
1956
+ }
1957
+ };
1958
+
1959
+ _this.onNodeCheck = function (e, treeNode, checked) {
1960
+ var _this$state3 = _this.state,
1961
+ keyEntities = _this$state3.keyEntities,
1962
+ oriCheckedKeys = _this$state3.checkedKeys,
1963
+ oriHalfCheckedKeys = _this$state3.halfCheckedKeys;
1964
+ var _this$props2 = _this.props,
1965
+ checkStrictly = _this$props2.checkStrictly,
1966
+ onCheck = _this$props2.onCheck;
1967
+ var eventKey = treeNode.props.eventKey; // Prepare trigger arguments
1968
+
1969
+ var checkedObj;
1970
+ var eventObj = {
1971
+ event: 'check',
1972
+ node: treeNode,
1973
+ checked: checked,
1974
+ nativeEvent: e.nativeEvent
1975
+ };
1976
+
1977
+ if (checkStrictly) {
1978
+ var checkedKeys = checked ? arrAdd(oriCheckedKeys, eventKey) : arrDel(oriCheckedKeys, eventKey);
1979
+ var halfCheckedKeys = arrDel(oriHalfCheckedKeys, eventKey);
1980
+ checkedObj = {
1981
+ checked: checkedKeys,
1982
+ halfChecked: halfCheckedKeys
1983
+ };
1984
+ eventObj.checkedNodes = checkedKeys.map(function (key) {
1985
+ return keyEntities[key];
1986
+ }).filter(function (entity) {
1987
+ return entity;
1988
+ }).map(function (entity) {
1989
+ return entity.node;
1990
+ });
1991
+
1992
+ _this.setUncontrolledState({
1993
+ checkedKeys: checkedKeys
1994
+ });
1995
+ } else {
1996
+ var _conductCheck = conductCheck([eventKey], checked, keyEntities, {
1997
+ checkedKeys: oriCheckedKeys,
1998
+ halfCheckedKeys: oriHalfCheckedKeys
1999
+ }),
2000
+ _checkedKeys = _conductCheck.checkedKeys,
2001
+ _halfCheckedKeys = _conductCheck.halfCheckedKeys;
2002
+
2003
+ checkedObj = _checkedKeys; // [Legacy] This is used for `rc-tree-select`
2004
+
2005
+ eventObj.checkedNodes = [];
2006
+ eventObj.checkedNodesPositions = [];
2007
+ eventObj.halfCheckedKeys = _halfCheckedKeys;
2008
+
2009
+ _checkedKeys.forEach(function (key) {
2010
+ var entity = keyEntities[key];
2011
+ if (!entity) return;
2012
+ var node = entity.node,
2013
+ pos = entity.pos;
2014
+ eventObj.checkedNodes.push(node);
2015
+ eventObj.checkedNodesPositions.push({
2016
+ node: node,
2017
+ pos: pos
2018
+ });
2019
+ });
2020
+
2021
+ _this.setUncontrolledState({
2022
+ checkedKeys: _checkedKeys,
2023
+ halfCheckedKeys: _halfCheckedKeys
2024
+ });
2025
+ }
2026
+
2027
+ if (onCheck) {
2028
+ onCheck(checkedObj, eventObj);
2029
+ }
2030
+ };
2031
+
2032
+ _this.onNodeLoad = function (treeNode) {
2033
+ return new Promise(function (resolve) {
2034
+ // We need to get the latest state of loading/loaded keys
2035
+ _this.setState(function (_ref) {
2036
+ var _ref$loadedKeys = _ref.loadedKeys,
2037
+ loadedKeys = _ref$loadedKeys === void 0 ? [] : _ref$loadedKeys,
2038
+ _ref$loadingKeys = _ref.loadingKeys,
2039
+ loadingKeys = _ref$loadingKeys === void 0 ? [] : _ref$loadingKeys;
2040
+ var _this$props3 = _this.props,
2041
+ loadData = _this$props3.loadData,
2042
+ onLoad = _this$props3.onLoad;
2043
+ var eventKey = treeNode.props.eventKey;
2044
+
2045
+ if (!loadData || loadedKeys.indexOf(eventKey) !== -1 || loadingKeys.indexOf(eventKey) !== -1) {
2046
+ // react 15 will warn if return null
2047
+ return {};
2048
+ } // Process load data
2049
+
2050
+
2051
+ var promise = loadData(treeNode);
2052
+ promise.then(function () {
2053
+ var _this$state4 = _this.state,
2054
+ currentLoadedKeys = _this$state4.loadedKeys,
2055
+ currentLoadingKeys = _this$state4.loadingKeys;
2056
+ var newLoadedKeys = arrAdd(currentLoadedKeys, eventKey);
2057
+ var newLoadingKeys = arrDel(currentLoadingKeys, eventKey); // onLoad should trigger before internal setState to avoid `loadData` trigger twice.
2058
+ // https://github.com/ant-design/ant-design/issues/12464
2059
+
2060
+ if (onLoad) {
2061
+ onLoad(newLoadedKeys, {
2062
+ event: 'load',
2063
+ node: treeNode
2064
+ });
2065
+ }
2066
+
2067
+ _this.setUncontrolledState({
2068
+ loadedKeys: newLoadedKeys
2069
+ });
2070
+
2071
+ _this.setState({
2072
+ loadingKeys: newLoadingKeys
2073
+ });
2074
+
2075
+ resolve();
2076
+ });
2077
+ return {
2078
+ loadingKeys: arrAdd(loadingKeys, eventKey)
2079
+ };
2080
+ });
2081
+ });
2082
+ };
2083
+
2084
+ _this.onNodeExpand = function (e, treeNode) {
2085
+ var expandedKeys = _this.state.expandedKeys;
2086
+ var _this$props4 = _this.props,
2087
+ onExpand = _this$props4.onExpand,
2088
+ loadData = _this$props4.loadData;
2089
+ var _treeNode$props2 = treeNode.props,
2090
+ eventKey = _treeNode$props2.eventKey,
2091
+ expanded = _treeNode$props2.expanded; // Update selected keys
2092
+
2093
+ var index = expandedKeys.indexOf(eventKey);
2094
+ var targetExpanded = !expanded;
2095
+ warning(expanded && index !== -1 || !expanded && index === -1, 'Expand state not sync with index check');
2096
+
2097
+ if (targetExpanded) {
2098
+ expandedKeys = arrAdd(expandedKeys, eventKey);
2099
+ } else {
2100
+ expandedKeys = arrDel(expandedKeys, eventKey);
2101
+ }
2102
+
2103
+ _this.setUncontrolledState({
2104
+ expandedKeys: expandedKeys
2105
+ });
2106
+
2107
+ if (onExpand) {
2108
+ onExpand(expandedKeys, {
2109
+ node: treeNode,
2110
+ expanded: targetExpanded,
2111
+ nativeEvent: e.nativeEvent
2112
+ });
2113
+ } // Async Load data
2114
+
2115
+
2116
+ if (targetExpanded && loadData) {
2117
+ var loadPromise = _this.onNodeLoad(treeNode);
2118
+
2119
+ return loadPromise ? loadPromise.then(function () {
2120
+ // [Legacy] Refresh logic
2121
+ _this.setUncontrolledState({
2122
+ expandedKeys: expandedKeys
2123
+ });
2124
+ }) : null;
2125
+ }
2126
+
2127
+ return null;
2128
+ };
2129
+
2130
+ _this.onNodeMouseEnter = function (event, node) {
2131
+ var onMouseEnter = _this.props.onMouseEnter;
2132
+
2133
+ if (onMouseEnter) {
2134
+ onMouseEnter({
2135
+ event: event,
2136
+ node: node
2137
+ });
2138
+ }
2139
+ };
2140
+
2141
+ _this.onNodeMouseLeave = function (event, node) {
2142
+ var onMouseLeave = _this.props.onMouseLeave;
2143
+
2144
+ if (onMouseLeave) {
2145
+ onMouseLeave({
2146
+ event: event,
2147
+ node: node
2148
+ });
2149
+ }
2150
+ };
2151
+
2152
+ _this.onNodeContextMenu = function (event, node) {
2153
+ var onRightClick = _this.props.onRightClick;
2154
+
2155
+ if (onRightClick) {
2156
+ event.preventDefault();
2157
+ onRightClick({
2158
+ event: event,
2159
+ node: node
2160
+ });
2161
+ }
2162
+ };
2163
+ /**
2164
+ * Only update the value which is not in props
2165
+ */
2166
+
2167
+
2168
+ _this.setUncontrolledState = function (state) {
2169
+ var needSync = false;
2170
+ var newState = {};
2171
+ Object.keys(state).forEach(function (name) {
2172
+ if (name in _this.props) return;
2173
+ needSync = true;
2174
+ newState[name] = state[name];
2175
+ });
2176
+
2177
+ if (needSync) {
2178
+ _this.setState(newState);
2179
+ }
2180
+ };
2181
+
2182
+ _this.registerTreeNode = function (key, node) {
2183
+ if (node) {
2184
+ _this.domTreeNodes[key] = node;
2185
+ } else {
2186
+ delete _this.domTreeNodes[key];
2187
+ }
2188
+ };
2189
+
2190
+ _this.isKeyChecked = function (key) {
2191
+ var _this$state$checkedKe = _this.state.checkedKeys,
2192
+ checkedKeys = _this$state$checkedKe === void 0 ? [] : _this$state$checkedKe;
2193
+ return checkedKeys.indexOf(key) !== -1;
2194
+ };
2195
+ /**
2196
+ * [Legacy] Original logic use `key` as tracking clue.
2197
+ * We have to use `cloneElement` to pass `key`.
2198
+ */
2199
+
2200
+
2201
+ _this.renderTreeNode = function (child, index) {
2202
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
2203
+ var _this$state5 = _this.state,
2204
+ keyEntities = _this$state5.keyEntities,
2205
+ _this$state5$expanded = _this$state5.expandedKeys,
2206
+ expandedKeys = _this$state5$expanded === void 0 ? [] : _this$state5$expanded,
2207
+ _this$state5$selected = _this$state5.selectedKeys,
2208
+ selectedKeys = _this$state5$selected === void 0 ? [] : _this$state5$selected,
2209
+ _this$state5$halfChec = _this$state5.halfCheckedKeys,
2210
+ halfCheckedKeys = _this$state5$halfChec === void 0 ? [] : _this$state5$halfChec,
2211
+ _this$state5$loadedKe = _this$state5.loadedKeys,
2212
+ loadedKeys = _this$state5$loadedKe === void 0 ? [] : _this$state5$loadedKe,
2213
+ _this$state5$loadingK = _this$state5.loadingKeys,
2214
+ loadingKeys = _this$state5$loadingK === void 0 ? [] : _this$state5$loadingK,
2215
+ dragOverNodeKey = _this$state5.dragOverNodeKey,
2216
+ dropPosition = _this$state5.dropPosition;
2217
+ var pos = getPosition(level, index);
2218
+ var key = child.key || pos;
2219
+
2220
+ if (!keyEntities[key]) {
2221
+ warnOnlyTreeNode();
2222
+ return null;
2223
+ }
2224
+
2225
+ return React.cloneElement(child, {
2226
+ key: key,
2227
+ eventKey: key,
2228
+ expanded: expandedKeys.indexOf(key) !== -1,
2229
+ selected: selectedKeys.indexOf(key) !== -1,
2230
+ loaded: loadedKeys.indexOf(key) !== -1,
2231
+ loading: loadingKeys.indexOf(key) !== -1,
2232
+ checked: _this.isKeyChecked(key),
2233
+ halfChecked: halfCheckedKeys.indexOf(key) !== -1,
2234
+ pos: pos,
2235
+ // [Legacy] Drag props
2236
+ dragOver: dragOverNodeKey === key && dropPosition === 0,
2237
+ dragOverGapTop: dragOverNodeKey === key && dropPosition === -1,
2238
+ dragOverGapBottom: dragOverNodeKey === key && dropPosition === 1
2239
+ });
2240
+ };
2241
+
2242
+ return _this;
2243
+ }
2244
+
2245
+ _createClass$2(Tree, [{
2246
+ key: "render",
2247
+ value: function render() {
2248
+ var _this2 = this;
2249
+
2250
+ var treeNode = this.state.treeNode;
2251
+ var _this$props5 = this.props,
2252
+ prefixCls = _this$props5.prefixCls,
2253
+ className = _this$props5.className,
2254
+ focusable = _this$props5.focusable,
2255
+ style = _this$props5.style,
2256
+ showLine = _this$props5.showLine,
2257
+ _this$props5$tabIndex = _this$props5.tabIndex,
2258
+ tabIndex = _this$props5$tabIndex === void 0 ? 0 : _this$props5$tabIndex,
2259
+ selectable = _this$props5.selectable,
2260
+ showIcon = _this$props5.showIcon,
2261
+ icon = _this$props5.icon,
2262
+ switcherIcon = _this$props5.switcherIcon,
2263
+ draggable = _this$props5.draggable,
2264
+ checkable = _this$props5.checkable,
2265
+ checkStrictly = _this$props5.checkStrictly,
2266
+ disabled = _this$props5.disabled,
2267
+ motion = _this$props5.motion,
2268
+ loadData = _this$props5.loadData,
2269
+ filterTreeNode = _this$props5.filterTreeNode;
2270
+ var domProps = getDataAndAria(this.props);
2271
+
2272
+ if (focusable) {
2273
+ domProps.tabIndex = tabIndex;
2274
+ }
2275
+
2276
+ return React.createElement(TreeContext.Provider, {
2277
+ value: {
2278
+ prefixCls: prefixCls,
2279
+ selectable: selectable,
2280
+ showIcon: showIcon,
2281
+ icon: icon,
2282
+ switcherIcon: switcherIcon,
2283
+ draggable: draggable,
2284
+ checkable: checkable,
2285
+ checkStrictly: checkStrictly,
2286
+ disabled: disabled,
2287
+ motion: motion,
2288
+ loadData: loadData,
2289
+ filterTreeNode: filterTreeNode,
2290
+ renderTreeNode: this.renderTreeNode,
2291
+ isKeyChecked: this.isKeyChecked,
2292
+ onNodeClick: this.onNodeClick,
2293
+ onNodeDoubleClick: this.onNodeDoubleClick,
2294
+ onNodeExpand: this.onNodeExpand,
2295
+ onNodeSelect: this.onNodeSelect,
2296
+ onNodeCheck: this.onNodeCheck,
2297
+ onNodeLoad: this.onNodeLoad,
2298
+ onNodeMouseEnter: this.onNodeMouseEnter,
2299
+ onNodeMouseLeave: this.onNodeMouseLeave,
2300
+ onNodeContextMenu: this.onNodeContextMenu,
2301
+ onNodeDragStart: this.onNodeDragStart,
2302
+ onNodeDragEnter: this.onNodeDragEnter,
2303
+ onNodeDragOver: this.onNodeDragOver,
2304
+ onNodeDragLeave: this.onNodeDragLeave,
2305
+ onNodeDragEnd: this.onNodeDragEnd,
2306
+ onNodeDrop: this.onNodeDrop,
2307
+ registerTreeNode: this.registerTreeNode
2308
+ }
2309
+ }, React.createElement("ul", Object.assign({}, domProps, {
2310
+ className: classNames(prefixCls, className, _defineProperty$1({}, "".concat(prefixCls, "-show-line"), showLine)),
2311
+ style: style,
2312
+ role: "tree",
2313
+ unselectable: "on"
2314
+ }), mapChildren(treeNode, function (node, index) {
2315
+ return _this2.renderTreeNode(node, index);
2316
+ })));
2317
+ }
2318
+ }], [{
2319
+ key: "getDerivedStateFromProps",
2320
+ value: function getDerivedStateFromProps(props, prevState) {
2321
+ var prevProps = prevState.prevProps;
2322
+ var newState = {
2323
+ prevProps: props
2324
+ };
2325
+
2326
+ function needSync(name) {
2327
+ return !prevProps && name in props || prevProps && prevProps[name] !== props[name];
2328
+ } // ================== Tree Node ==================
2329
+
2330
+
2331
+ var treeNode = null; // Check if `treeData` or `children` changed and save into the state.
2332
+
2333
+ if (needSync('treeData')) {
2334
+ treeNode = convertDataToTree(props.treeData);
2335
+ } else if (needSync('children')) {
2336
+ treeNode = toArray(props.children);
2337
+ } // Tree support filter function which will break the tree structure in the vdm.
2338
+ // We cache the treeNodes in state so that we can return the treeNode in event trigger.
2339
+
2340
+
2341
+ if (treeNode) {
2342
+ newState.treeNode = treeNode; // Calculate the entities data for quick match
2343
+
2344
+ var entitiesMap = convertTreeToEntities(treeNode);
2345
+ newState.keyEntities = entitiesMap.keyEntities;
2346
+ }
2347
+
2348
+ var keyEntities = newState.keyEntities || prevState.keyEntities; // ================ expandedKeys =================
2349
+
2350
+ if (needSync('expandedKeys') || prevProps && needSync('autoExpandParent')) {
2351
+ newState.expandedKeys = props.autoExpandParent || !prevProps && props.defaultExpandParent ? conductExpandParent(props.expandedKeys, keyEntities) : props.expandedKeys;
2352
+ } else if (!prevProps && props.defaultExpandAll) {
2353
+ newState.expandedKeys = Object.keys(keyEntities);
2354
+ } else if (!prevProps && props.defaultExpandedKeys) {
2355
+ newState.expandedKeys = props.autoExpandParent || props.defaultExpandParent ? conductExpandParent(props.defaultExpandedKeys, keyEntities) : props.defaultExpandedKeys;
2356
+ } // ================ selectedKeys =================
2357
+
2358
+
2359
+ if (props.selectable) {
2360
+ if (needSync('selectedKeys')) {
2361
+ newState.selectedKeys = calcSelectedKeys(props.selectedKeys, props);
2362
+ } else if (!prevProps && props.defaultSelectedKeys) {
2363
+ newState.selectedKeys = calcSelectedKeys(props.defaultSelectedKeys, props);
2364
+ }
2365
+ } // ================= checkedKeys =================
2366
+
2367
+
2368
+ if (props.checkable) {
2369
+ var checkedKeyEntity;
2370
+
2371
+ if (needSync('checkedKeys')) {
2372
+ checkedKeyEntity = parseCheckedKeys(props.checkedKeys) || {};
2373
+ } else if (!prevProps && props.defaultCheckedKeys) {
2374
+ checkedKeyEntity = parseCheckedKeys(props.defaultCheckedKeys) || {};
2375
+ } else if (treeNode) {
2376
+ // If treeNode changed, we also need check it
2377
+ checkedKeyEntity = parseCheckedKeys(props.checkedKeys) || {
2378
+ checkedKeys: prevState.checkedKeys,
2379
+ halfCheckedKeys: prevState.halfCheckedKeys
2380
+ };
2381
+ }
2382
+
2383
+ if (checkedKeyEntity) {
2384
+ var _checkedKeyEntity = checkedKeyEntity,
2385
+ _checkedKeyEntity$che = _checkedKeyEntity.checkedKeys,
2386
+ checkedKeys = _checkedKeyEntity$che === void 0 ? [] : _checkedKeyEntity$che,
2387
+ _checkedKeyEntity$hal = _checkedKeyEntity.halfCheckedKeys,
2388
+ halfCheckedKeys = _checkedKeyEntity$hal === void 0 ? [] : _checkedKeyEntity$hal;
2389
+
2390
+ if (!props.checkStrictly) {
2391
+ var conductKeys = conductCheck(checkedKeys, true, keyEntities);
2392
+ checkedKeys = conductKeys.checkedKeys;
2393
+ halfCheckedKeys = conductKeys.halfCheckedKeys;
2394
+ }
2395
+
2396
+ newState.checkedKeys = checkedKeys;
2397
+ newState.halfCheckedKeys = halfCheckedKeys;
2398
+ }
2399
+ } // ================= loadedKeys ==================
2400
+
2401
+
2402
+ if (needSync('loadedKeys')) {
2403
+ newState.loadedKeys = props.loadedKeys;
2404
+ }
2405
+
2406
+ return newState;
2407
+ }
2408
+ }]);
2409
+
2410
+ return Tree;
2411
+ }(React.Component);
2412
+
2413
+ Tree$2.propTypes = {
2414
+ prefixCls: PropTypes.string,
2415
+ className: PropTypes.string,
2416
+ style: PropTypes.object,
2417
+ tabIndex: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
2418
+ children: PropTypes.any,
2419
+ treeData: PropTypes.array,
2420
+ showLine: PropTypes.bool,
2421
+ showIcon: PropTypes.bool,
2422
+ icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
2423
+ focusable: PropTypes.bool,
2424
+ selectable: PropTypes.bool,
2425
+ disabled: PropTypes.bool,
2426
+ multiple: PropTypes.bool,
2427
+ checkable: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
2428
+ checkStrictly: PropTypes.bool,
2429
+ draggable: PropTypes.bool,
2430
+ defaultExpandParent: PropTypes.bool,
2431
+ autoExpandParent: PropTypes.bool,
2432
+ defaultExpandAll: PropTypes.bool,
2433
+ defaultExpandedKeys: PropTypes.arrayOf(PropTypes.string),
2434
+ expandedKeys: PropTypes.arrayOf(PropTypes.string),
2435
+ defaultCheckedKeys: PropTypes.arrayOf(PropTypes.string),
2436
+ checkedKeys: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), PropTypes.object]),
2437
+ defaultSelectedKeys: PropTypes.arrayOf(PropTypes.string),
2438
+ selectedKeys: PropTypes.arrayOf(PropTypes.string),
2439
+ onClick: PropTypes.func,
2440
+ onDoubleClick: PropTypes.func,
2441
+ onExpand: PropTypes.func,
2442
+ onCheck: PropTypes.func,
2443
+ onSelect: PropTypes.func,
2444
+ onLoad: PropTypes.func,
2445
+ loadData: PropTypes.func,
2446
+ loadedKeys: PropTypes.arrayOf(PropTypes.string),
2447
+ onMouseEnter: PropTypes.func,
2448
+ onMouseLeave: PropTypes.func,
2449
+ onRightClick: PropTypes.func,
2450
+ onDragStart: PropTypes.func,
2451
+ onDragEnter: PropTypes.func,
2452
+ onDragOver: PropTypes.func,
2453
+ onDragLeave: PropTypes.func,
2454
+ onDragEnd: PropTypes.func,
2455
+ onDrop: PropTypes.func,
2456
+ filterTreeNode: PropTypes.func,
2457
+ motion: PropTypes.object,
2458
+ switcherIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
2459
+ };
2460
+ Tree$2.defaultProps = {
2461
+ prefixCls: 'rc-tree',
2462
+ showLine: false,
2463
+ showIcon: true,
2464
+ selectable: true,
2465
+ multiple: false,
2466
+ checkable: false,
2467
+ disabled: false,
2468
+ checkStrictly: false,
2469
+ draggable: false,
2470
+ defaultExpandParent: true,
2471
+ autoExpandParent: false,
2472
+ defaultExpandAll: false,
2473
+ defaultExpandedKeys: [],
2474
+ defaultCheckedKeys: [],
2475
+ defaultSelectedKeys: []
2476
+ };
2477
+ polyfill(Tree$2);
2478
+
2479
+ var Tree$1 = Tree$2;
2480
+ Tree$1.TreeNode = ContextTreeNode;
2481
+
2482
+ function _toConsumableArray$1(arr) { return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1(); }
2483
+
2484
+ function _nonIterableSpread$1() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2485
+
2486
+ function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
2487
+
2488
+ function _iterableToArray$1(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
2489
+
2490
+ function _arrayWithoutHoles$1(arr) { if (Array.isArray(arr)) return _arrayLikeToArray$1(arr); }
2491
+
2492
+ function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2493
+ var Record;
2494
+
2495
+ (function (Record) {
2496
+ Record[Record["None"] = 0] = "None";
2497
+ Record[Record["Start"] = 1] = "Start";
2498
+ Record[Record["End"] = 2] = "End";
2499
+ })(Record || (Record = {})); // TODO: Move this logic into `rc-tree`
2500
+
2501
+
2502
+ function traverseNodesKey(rootChildren, callback) {
2503
+ var nodeList = getNodeChildren(rootChildren) || [];
2504
+
2505
+ function processNode(node) {
2506
+ var key = node.key,
2507
+ children = node.props.children;
2508
+
2509
+ if (callback(key, node) !== false) {
2510
+ traverseNodesKey(children, callback);
2511
+ }
2512
+ }
2513
+
2514
+ nodeList.forEach(processNode);
2515
+ }
2516
+
2517
+ function getFullKeyList(children) {
2518
+ var _convertTreeToEntitie = convertTreeToEntities(children),
2519
+ keyEntities = _convertTreeToEntitie.keyEntities;
2520
+
2521
+ return Object.keys(keyEntities);
2522
+ }
2523
+ /** 计算选中范围,只考虑expanded情况以优化性能 */
2524
+
2525
+ function calcRangeKeys(rootChildren, expandedKeys, startKey, endKey) {
2526
+ var keys = [];
2527
+ var record = Record.None;
2528
+
2529
+ if (startKey && startKey === endKey) {
2530
+ return [startKey];
2531
+ }
2532
+
2533
+ if (!startKey || !endKey) {
2534
+ return [];
2535
+ }
2536
+
2537
+ function matchKey(key) {
2538
+ return key === startKey || key === endKey;
2539
+ }
2540
+
2541
+ traverseNodesKey(rootChildren, function (key) {
2542
+ if (record === Record.End) {
2543
+ return false;
2544
+ }
2545
+
2546
+ if (matchKey(key)) {
2547
+ // Match test
2548
+ keys.push(key);
2549
+
2550
+ if (record === Record.None) {
2551
+ record = Record.Start;
2552
+ } else if (record === Record.Start) {
2553
+ record = Record.End;
2554
+ return false;
2555
+ }
2556
+ } else if (record === Record.Start) {
2557
+ // Append selection
2558
+ keys.push(key);
2559
+ }
2560
+
2561
+ if (expandedKeys.indexOf(key) === -1) {
2562
+ return false;
2563
+ }
2564
+
2565
+ return true;
2566
+ });
2567
+ return keys;
2568
+ }
2569
+ function convertDirectoryKeysToNodes(rootChildren, keys) {
2570
+ var restKeys = _toConsumableArray$1(keys);
2571
+
2572
+ var nodes = [];
2573
+ traverseNodesKey(rootChildren, function (key, node) {
2574
+ var index = restKeys.indexOf(key);
2575
+
2576
+ if (index !== -1) {
2577
+ nodes.push(node);
2578
+ restKeys.splice(index, 1);
2579
+ }
2580
+
2581
+ return !!restKeys.length;
2582
+ });
2583
+ return nodes;
2584
+ }
2585
+ function getFullKeyListByTreeData(treeData) {
2586
+ var keys = [];
2587
+ (treeData || []).forEach(function (item) {
2588
+ keys.push(item.key);
2589
+
2590
+ if (item.children) {
2591
+ keys = [].concat(_toConsumableArray$1(keys), _toConsumableArray$1(getFullKeyListByTreeData(item.children)));
2592
+ }
2593
+ });
2594
+ return keys;
2595
+ }
2596
+
2597
+ function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
2598
+
2599
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2600
+
2601
+ 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."); }
2602
+
2603
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
2604
+
2605
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
2606
+
2607
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
2608
+
2609
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2610
+
2611
+ function _extends$1() { _extends$1 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$1.apply(this, arguments); }
2612
+
2613
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2614
+
2615
+ function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2616
+
2617
+ function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
2618
+
2619
+ function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf$1(subClass, superClass); }
2620
+
2621
+ function _setPrototypeOf$1(o, p) { _setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf$1(o, p); }
2622
+
2623
+ function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf$1(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf$1(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn$1(this, result); }; }
2624
+
2625
+ function _possibleConstructorReturn$1(self, call) { if (call && (_typeof$1(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized$1(self); }
2626
+
2627
+ function _assertThisInitialized$1(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2628
+
2629
+ function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
2630
+
2631
+ function _getPrototypeOf$1(o) { _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf$1(o); }
2632
+
2633
+ var __rest = undefined && undefined.__rest || function (s, e) {
2634
+ var t = {};
2635
+
2636
+ for (var p in s) {
2637
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
2638
+ }
2639
+
2640
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2641
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
2642
+ }
2643
+ return t;
2644
+ };
2645
+
2646
+ function getIcon(props) {
2647
+ var isLeaf = props.isLeaf,
2648
+ expanded = props.expanded;
2649
+
2650
+ if (isLeaf) {
2651
+ return /*#__PURE__*/React.createElement(Icon, {
2652
+ type: "file"
2653
+ });
2654
+ }
2655
+
2656
+ return /*#__PURE__*/React.createElement(Icon, {
2657
+ type: expanded ? 'folder-open' : 'folder'
2658
+ });
2659
+ }
2660
+
2661
+ var DirectoryTree = /*#__PURE__*/function (_React$Component) {
2662
+ _inherits$1(DirectoryTree, _React$Component);
2663
+
2664
+ var _super = _createSuper$1(DirectoryTree);
2665
+
2666
+ function DirectoryTree(props) {
2667
+ var _this;
2668
+
2669
+ _classCallCheck$1(this, DirectoryTree);
2670
+
2671
+ _this = _super.call(this, props);
2672
+
2673
+ _this.onExpand = function (expandedKeys, info) {
2674
+ var onExpand = _this.props.onExpand;
2675
+
2676
+ _this.setUncontrolledState({
2677
+ expandedKeys: expandedKeys
2678
+ }); // Call origin function
2679
+
2680
+
2681
+ if (onExpand) {
2682
+ return onExpand(expandedKeys, info);
2683
+ }
2684
+
2685
+ return undefined;
2686
+ };
2687
+
2688
+ _this.onClick = function (event, node) {
2689
+ var _this$props = _this.props,
2690
+ onClick = _this$props.onClick,
2691
+ expandAction = _this$props.expandAction; // Expand the tree
2692
+
2693
+ if (expandAction === 'click') {
2694
+ _this.onDebounceExpand(event, node);
2695
+ }
2696
+
2697
+ if (onClick) {
2698
+ onClick(event, node);
2699
+ }
2700
+ };
2701
+
2702
+ _this.onDoubleClick = function (event, node) {
2703
+ var _this$props2 = _this.props,
2704
+ onDoubleClick = _this$props2.onDoubleClick,
2705
+ expandAction = _this$props2.expandAction; // Expand the tree
2706
+
2707
+ if (expandAction === 'doubleClick') {
2708
+ _this.onDebounceExpand(event, node);
2709
+ }
2710
+
2711
+ if (onDoubleClick) {
2712
+ onDoubleClick(event, node);
2713
+ }
2714
+ };
2715
+
2716
+ _this.onSelect = function (keys, event) {
2717
+ var _this$props3 = _this.props,
2718
+ onSelect = _this$props3.onSelect,
2719
+ multiple = _this$props3.multiple,
2720
+ children = _this$props3.children;
2721
+ var _this$state$expandedK = _this.state.expandedKeys,
2722
+ expandedKeys = _this$state$expandedK === void 0 ? [] : _this$state$expandedK;
2723
+ var node = event.node,
2724
+ nativeEvent = event.nativeEvent;
2725
+ var _node$props$eventKey = node.props.eventKey,
2726
+ eventKey = _node$props$eventKey === void 0 ? '' : _node$props$eventKey;
2727
+ var newState = {}; // We need wrap this event since some value is not same
2728
+
2729
+ var newEvent = _extends$1(_extends$1({}, event), {
2730
+ selected: true
2731
+ }); // Windows / Mac single pick
2732
+
2733
+
2734
+ var ctrlPick = nativeEvent.ctrlKey || nativeEvent.metaKey;
2735
+ var shiftPick = nativeEvent.shiftKey; // Generate new selected keys
2736
+
2737
+ var newSelectedKeys;
2738
+
2739
+ if (multiple && ctrlPick) {
2740
+ // Control click
2741
+ newSelectedKeys = keys;
2742
+ _this.lastSelectedKey = eventKey;
2743
+ _this.cachedSelectedKeys = newSelectedKeys;
2744
+ newEvent.selectedNodes = convertDirectoryKeysToNodes(children, newSelectedKeys);
2745
+ } else if (multiple && shiftPick) {
2746
+ // Shift click
2747
+ newSelectedKeys = Array.from(new Set([].concat(_toConsumableArray(_this.cachedSelectedKeys || []), _toConsumableArray(calcRangeKeys(children, expandedKeys, eventKey, _this.lastSelectedKey)))));
2748
+ newEvent.selectedNodes = convertDirectoryKeysToNodes(children, newSelectedKeys);
2749
+ } else {
2750
+ // Single click
2751
+ newSelectedKeys = [eventKey];
2752
+ _this.lastSelectedKey = eventKey;
2753
+ _this.cachedSelectedKeys = newSelectedKeys;
2754
+ newEvent.selectedNodes = [event.node];
2755
+ }
2756
+
2757
+ newState.selectedKeys = newSelectedKeys;
2758
+
2759
+ if (onSelect) {
2760
+ onSelect(newSelectedKeys, newEvent);
2761
+ }
2762
+
2763
+ _this.setUncontrolledState(newState);
2764
+ };
2765
+
2766
+ _this.setTreeRef = function (node) {
2767
+ _this.tree = node;
2768
+ };
2769
+
2770
+ _this.expandFolderNode = function (event, node) {
2771
+ var isLeaf = node.props.isLeaf;
2772
+
2773
+ if (isLeaf || event.shiftKey || event.metaKey || event.ctrlKey) {
2774
+ return;
2775
+ } // Get internal rc-tree
2776
+
2777
+
2778
+ var internalTree = _this.tree.tree; // Call internal rc-tree expand function
2779
+ // https://github.com/ant-design/ant-design/issues/12567
2780
+
2781
+ internalTree.onNodeExpand(event, node);
2782
+ };
2783
+
2784
+ _this.setUncontrolledState = function (state) {
2785
+ var newState = omit(state, Object.keys(_this.props));
2786
+
2787
+ if (Object.keys(newState).length) {
2788
+ _this.setState(newState);
2789
+ }
2790
+ };
2791
+
2792
+ _this.renderDirectoryTree = function (_ref) {
2793
+ var getPrefixCls = _ref.getPrefixCls;
2794
+
2795
+ var _a = _this.props,
2796
+ customizePrefixCls = _a.prefixCls,
2797
+ className = _a.className,
2798
+ props = __rest(_a, ["prefixCls", "className"]);
2799
+
2800
+ var _this$state = _this.state,
2801
+ expandedKeys = _this$state.expandedKeys,
2802
+ selectedKeys = _this$state.selectedKeys;
2803
+ var prefixCls = getPrefixCls('tree', customizePrefixCls);
2804
+ var connectClassName = classNames("".concat(prefixCls, "-directory"), className);
2805
+ return /*#__PURE__*/React.createElement(Tree, _extends$1({
2806
+ icon: getIcon,
2807
+ ref: _this.setTreeRef
2808
+ }, props, {
2809
+ prefixCls: prefixCls,
2810
+ className: connectClassName,
2811
+ expandedKeys: expandedKeys,
2812
+ selectedKeys: selectedKeys,
2813
+ onSelect: _this.onSelect,
2814
+ onClick: _this.onClick,
2815
+ onDoubleClick: _this.onDoubleClick,
2816
+ onExpand: _this.onExpand
2817
+ }));
2818
+ };
2819
+
2820
+ var defaultExpandAll = props.defaultExpandAll,
2821
+ defaultExpandParent = props.defaultExpandParent,
2822
+ expandedKeys = props.expandedKeys,
2823
+ defaultExpandedKeys = props.defaultExpandedKeys,
2824
+ children = props.children;
2825
+
2826
+ var _convertTreeToEntitie = convertTreeToEntities(children),
2827
+ keyEntities = _convertTreeToEntitie.keyEntities; // Selected keys
2828
+
2829
+
2830
+ _this.state = {
2831
+ selectedKeys: props.selectedKeys || props.defaultSelectedKeys || []
2832
+ }; // Expanded keys
2833
+
2834
+ if (defaultExpandAll) {
2835
+ if (props.treeData) {
2836
+ _this.state.expandedKeys = getFullKeyListByTreeData(props.treeData);
2837
+ } else {
2838
+ _this.state.expandedKeys = getFullKeyList(props.children);
2839
+ }
2840
+ } else if (defaultExpandParent) {
2841
+ _this.state.expandedKeys = conductExpandParent(expandedKeys || defaultExpandedKeys, keyEntities);
2842
+ } else {
2843
+ _this.state.expandedKeys = expandedKeys || defaultExpandedKeys;
2844
+ }
2845
+
2846
+ _this.onDebounceExpand = debounce(_this.expandFolderNode, 200, {
2847
+ leading: true
2848
+ });
2849
+ return _this;
2850
+ }
2851
+
2852
+ _createClass$1(DirectoryTree, [{
2853
+ key: "render",
2854
+ value: function render() {
2855
+ return /*#__PURE__*/React.createElement(ConfigConsumer, null, this.renderDirectoryTree);
2856
+ }
2857
+ }], [{
2858
+ key: "getDerivedStateFromProps",
2859
+ value: function getDerivedStateFromProps(nextProps) {
2860
+ var newState = {};
2861
+
2862
+ if ('expandedKeys' in nextProps) {
2863
+ newState.expandedKeys = nextProps.expandedKeys;
2864
+ }
2865
+
2866
+ if ('selectedKeys' in nextProps) {
2867
+ newState.selectedKeys = nextProps.selectedKeys;
2868
+ }
2869
+
2870
+ return newState;
2871
+ }
2872
+ }]);
2873
+
2874
+ return DirectoryTree;
2875
+ }(React.Component);
2876
+
2877
+ DirectoryTree.defaultProps = {
2878
+ showIcon: true,
2879
+ expandAction: 'click'
2880
+ };
2881
+ polyfill(DirectoryTree);
2882
+
2883
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2884
+
2885
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2886
+
2887
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2888
+
2889
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2890
+
2891
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2892
+
2893
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); return Constructor; }
2894
+
2895
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
2896
+
2897
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2898
+
2899
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2900
+
2901
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
2902
+
2903
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2904
+
2905
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
2906
+
2907
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
2908
+
2909
+ var Tree = /*#__PURE__*/function (_React$Component) {
2910
+ _inherits(Tree, _React$Component);
2911
+
2912
+ var _super = _createSuper(Tree);
2913
+
2914
+ function Tree() {
2915
+ var _this;
2916
+
2917
+ _classCallCheck(this, Tree);
2918
+
2919
+ _this = _super.apply(this, arguments);
2920
+
2921
+ _this.renderSwitcherIcon = function (prefixCls, switcherIcon, _ref) {
2922
+ var isLeaf = _ref.isLeaf,
2923
+ expanded = _ref.expanded,
2924
+ loading = _ref.loading;
2925
+ var showLine = _this.props.showLine;
2926
+
2927
+ if (loading) {
2928
+ return /*#__PURE__*/React.createElement(Icon, {
2929
+ type: "loading",
2930
+ className: "".concat(prefixCls, "-switcher-loading-icon")
2931
+ });
2932
+ }
2933
+
2934
+ if (isLeaf) {
2935
+ return showLine ? /*#__PURE__*/React.createElement(Icon, {
2936
+ type: "file",
2937
+ className: "".concat(prefixCls, "-switcher-line-icon")
2938
+ }) : null;
2939
+ }
2940
+
2941
+ var switcherCls = "".concat(prefixCls, "-switcher-icon");
2942
+
2943
+ if (switcherIcon) {
2944
+ return /*#__PURE__*/React.cloneElement(switcherIcon, {
2945
+ className: classNames(switcherIcon.props.className || '', switcherCls)
2946
+ });
2947
+ }
2948
+
2949
+ return showLine ? /*#__PURE__*/React.createElement(Icon, {
2950
+ type: expanded ? 'minus-square' : 'plus-square',
2951
+ className: "".concat(prefixCls, "-switcher-line-icon"),
2952
+ theme: "outlined"
2953
+ }) : /*#__PURE__*/React.createElement(Icon, {
2954
+ type: "caret-down",
2955
+ className: switcherCls,
2956
+ theme: "filled"
2957
+ });
2958
+ };
2959
+
2960
+ _this.setTreeRef = function (node) {
2961
+ _this.tree = node;
2962
+ };
2963
+
2964
+ _this.renderTree = function (_ref2) {
2965
+ var _classNames;
2966
+
2967
+ var getPrefixCls = _ref2.getPrefixCls;
2968
+
2969
+ var _assertThisInitialize = _assertThisInitialized(_this),
2970
+ props = _assertThisInitialize.props;
2971
+
2972
+ var customizePrefixCls = props.prefixCls,
2973
+ className = props.className,
2974
+ showIcon = props.showIcon,
2975
+ _switcherIcon = props.switcherIcon,
2976
+ blockNode = props.blockNode,
2977
+ children = props.children;
2978
+ var checkable = props.checkable;
2979
+ var prefixCls = getPrefixCls('tree', customizePrefixCls);
2980
+ return /*#__PURE__*/React.createElement(Tree$1, _extends({
2981
+ ref: _this.setTreeRef
2982
+ }, props, {
2983
+ prefixCls: prefixCls,
2984
+ className: classNames(className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-icon-hide"), !showIcon), _defineProperty(_classNames, "".concat(prefixCls, "-block-node"), blockNode), _classNames)),
2985
+ checkable: checkable ? /*#__PURE__*/React.createElement("span", {
2986
+ className: "".concat(prefixCls, "-checkbox-inner")
2987
+ }) : checkable,
2988
+ switcherIcon: function switcherIcon(nodeProps) {
2989
+ return _this.renderSwitcherIcon(prefixCls, _switcherIcon, nodeProps);
2990
+ }
2991
+ }), children);
2992
+ };
2993
+
2994
+ return _this;
2995
+ }
2996
+
2997
+ _createClass(Tree, [{
2998
+ key: "render",
2999
+ value: function render() {
3000
+ return /*#__PURE__*/React.createElement(ConfigConsumer, null, this.renderTree);
3001
+ }
3002
+ }]);
3003
+
3004
+ return Tree;
3005
+ }(React.Component);
3006
+ Tree.TreeNode = ContextTreeNode;
3007
+ Tree.DirectoryTree = DirectoryTree;
3008
+ Tree.defaultProps = {
3009
+ checkable: false,
3010
+ showIcon: false,
3011
+ motion: _extends(_extends({}, collapseMotion), {
3012
+ motionAppear: false
3013
+ }),
3014
+ blockNode: false
3015
+ };
3016
+
3017
+ export { Tree as T, requireIsSymbol as a, requireToNumber as b, collapseMotion as c, debounce as d, reactIsExports as e, require_root as f, require_baseGetTag as g, requireIsObject as h, requireIsObjectLike as i, require_freeGlobal as j, require_Symbol as r, toArray as t, warning as w };