bkui-vue 0.0.1-beta.393 → 0.0.1-beta.395

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 (175) hide show
  1. package/dist/index.cjs.js +36 -36
  2. package/dist/index.esm.js +93 -49
  3. package/dist/index.umd.js +36 -36
  4. package/dist/style.css +1 -1
  5. package/dist/style.variable.css +1 -1
  6. package/lib/affix/index.js +1 -353
  7. package/lib/alert/index.js +1 -251
  8. package/lib/animate-number/index.js +1 -226
  9. package/lib/backtop/index.js +1 -260
  10. package/lib/badge/badge.css +0 -2
  11. package/lib/badge/badge.less +2 -2
  12. package/lib/badge/badge.variable.css +0 -2
  13. package/lib/badge/index.js +1 -274
  14. package/lib/breadcrumb/index.js +1 -329
  15. package/lib/button/index.js +1 -371
  16. package/lib/card/index.js +1 -326
  17. package/lib/cascader/index.js +1 -2168
  18. package/lib/checkbox/index.js +1 -571
  19. package/lib/code-diff/index.js +1 -5520
  20. package/lib/collapse/collapse-panel.d.ts +11 -0
  21. package/lib/collapse/index.d.ts +20 -5
  22. package/lib/collapse/index.js +1 -698
  23. package/lib/collapse/props.d.ts +5 -0
  24. package/lib/color-picker/index.js +1 -2816
  25. package/lib/components.d.ts +2 -0
  26. package/lib/components.js +1 -759
  27. package/lib/container/index.js +1 -369
  28. package/lib/date-picker/index.js +1 -5601
  29. package/lib/dialog/index.js +1 -545
  30. package/lib/directives/index.js +2 -1427
  31. package/lib/directives/index.js.LICENSE.txt +14 -0
  32. package/lib/dist.index.js +1 -166
  33. package/lib/divider/index.js +1 -512
  34. package/lib/dropdown/index.js +1 -414
  35. package/lib/exception/exception.d.ts +13 -0
  36. package/lib/exception/index.d.ts +2 -0
  37. package/lib/exception/index.js +1 -405
  38. package/lib/fixed-navbar/index.js +1 -214
  39. package/lib/form/index.js +1 -986
  40. package/lib/icon/angle-double-down-line.js +1 -426
  41. package/lib/icon/angle-double-left-line.js +1 -426
  42. package/lib/icon/angle-double-left.js +1 -426
  43. package/lib/icon/angle-double-right-line.js +1 -426
  44. package/lib/icon/angle-double-right.js +1 -426
  45. package/lib/icon/angle-double-up-line.js +1 -426
  46. package/lib/icon/angle-down-fill.js +1 -426
  47. package/lib/icon/angle-down-line.js +1 -426
  48. package/lib/icon/angle-down.js +1 -426
  49. package/lib/icon/angle-left.js +1 -426
  50. package/lib/icon/angle-right.js +1 -426
  51. package/lib/icon/angle-up-fill.js +1 -426
  52. package/lib/icon/angle-up.js +1 -426
  53. package/lib/icon/archive-fill.js +1 -426
  54. package/lib/icon/arrows-left.js +1 -426
  55. package/lib/icon/arrows-right.js +1 -426
  56. package/lib/icon/audio-fill.js +1 -426
  57. package/lib/icon/bk.js +1 -426
  58. package/lib/icon/circle.js +1 -426
  59. package/lib/icon/close-line.js +1 -426
  60. package/lib/icon/close.js +1 -426
  61. package/lib/icon/code.js +1 -426
  62. package/lib/icon/cog-shape.js +1 -426
  63. package/lib/icon/collapse-left.js +1 -426
  64. package/lib/icon/copy.js +1 -426
  65. package/lib/icon/data-shape.js +1 -426
  66. package/lib/icon/del.js +1 -426
  67. package/lib/icon/doc-fill.js +1 -426
  68. package/lib/icon/done.js +1 -426
  69. package/lib/icon/down-shape.js +1 -426
  70. package/lib/icon/down-small.js +1 -426
  71. package/lib/icon/edit-line.js +1 -426
  72. package/lib/icon/ellipsis.js +1 -426
  73. package/lib/icon/enlarge-line.js +1 -426
  74. package/lib/icon/error.js +1 -426
  75. package/lib/icon/excel-fill.js +1 -426
  76. package/lib/icon/exclamation-circle-shape.js +1 -426
  77. package/lib/icon/eye.js +1 -426
  78. package/lib/icon/filliscreen-line.js +1 -426
  79. package/lib/icon/folder-open.js +1 -426
  80. package/lib/icon/folder-shape-open.js +1 -426
  81. package/lib/icon/folder-shape.js +1 -426
  82. package/lib/icon/folder.js +1 -426
  83. package/lib/icon/funnel.js +1 -426
  84. package/lib/icon/help-document-fill.js +1 -426
  85. package/lib/icon/help-fill.js +1 -426
  86. package/lib/icon/help.js +1 -426
  87. package/lib/icon/image-fill.js +1 -426
  88. package/lib/icon/img-placehoulder.js +1 -448
  89. package/lib/icon/index.js +1 -2275
  90. package/lib/icon/info-line.js +1 -448
  91. package/lib/icon/info.js +1 -448
  92. package/lib/icon/left-shape.js +1 -448
  93. package/lib/icon/left-turn-line.js +1 -448
  94. package/lib/icon/narrow-line.js +1 -448
  95. package/lib/icon/original.js +1 -448
  96. package/lib/icon/pdf-fill.js +1 -448
  97. package/lib/icon/play-shape.js +1 -448
  98. package/lib/icon/plus.js +1 -448
  99. package/lib/icon/ppt-fill.js +1 -448
  100. package/lib/icon/qq.js +1 -448
  101. package/lib/icon/right-shape.js +1 -448
  102. package/lib/icon/right-turn-line.js +1 -448
  103. package/lib/icon/search.js +1 -448
  104. package/lib/icon/share.js +1 -448
  105. package/lib/icon/spinner.js +1 -448
  106. package/lib/icon/success.js +1 -448
  107. package/lib/icon/switcher-loading.js +1 -448
  108. package/lib/icon/text-file.js +1 -448
  109. package/lib/icon/text-fill.js +1 -448
  110. package/lib/icon/transfer.js +1 -448
  111. package/lib/icon/tree-application-shape.js +1 -448
  112. package/lib/icon/unfull-screen.js +1 -448
  113. package/lib/icon/unvisible.js +1 -448
  114. package/lib/icon/up-shape.js +1 -448
  115. package/lib/icon/upload.js +1 -448
  116. package/lib/icon/video-fill.js +1 -448
  117. package/lib/icon/warn.js +1 -448
  118. package/lib/icon/weixin.js +1 -448
  119. package/lib/image/index.js +1 -873
  120. package/lib/index.js +1 -169
  121. package/lib/info-box/index.js +1 -1784
  122. package/lib/input/index.d.ts +4 -4
  123. package/lib/input/index.js +1 -846
  124. package/lib/input/input.d.ts +1 -1
  125. package/lib/link/index.js +1 -226
  126. package/lib/loading/index.js +1 -309
  127. package/lib/menu/index.js +1 -796
  128. package/lib/message/index.js +1 -401
  129. package/lib/modal/index.js +1 -395
  130. package/lib/navigation/index.js +1 -431
  131. package/lib/notify/index.js +1 -430
  132. package/lib/overflow-title/index.js +1 -512
  133. package/lib/pagination/index.js +1 -1026
  134. package/lib/plugin-popover/index.js +1 -2581
  135. package/lib/plugins/index.js +1 -130
  136. package/lib/popover/index.js +1 -2587
  137. package/lib/popover2/index.js +1 -172
  138. package/lib/preset.js +1 -129
  139. package/lib/process/index.js +1 -1417
  140. package/lib/progress/index.js +1 -479
  141. package/lib/radio/index.js +1 -649
  142. package/lib/rate/index.js +1 -358
  143. package/lib/resize-layout/index.js +1 -495
  144. package/lib/search-select/index.js +1 -3388
  145. package/lib/search-select/search-select.css +1 -1
  146. package/lib/search-select/search-select.less +1 -1
  147. package/lib/search-select/search-select.variable.css +1 -1
  148. package/lib/select/index.d.ts +9 -9
  149. package/lib/select/index.js +1 -2819
  150. package/lib/select/select.css +0 -1
  151. package/lib/select/select.d.ts +3 -3
  152. package/lib/select/select.less +0 -1
  153. package/lib/select/select.variable.css +0 -1
  154. package/lib/select/selectTagInput.d.ts +1 -1
  155. package/lib/shared/index.js +1 -2813
  156. package/lib/shared/vue-types.d.ts +1 -1
  157. package/lib/sideslider/index.js +1 -1362
  158. package/lib/slider/index.js +1 -2060
  159. package/lib/steps/index.js +1 -1504
  160. package/lib/swiper/index.js +1 -374
  161. package/lib/switcher/index.js +1 -308
  162. package/lib/tab/index.d.ts +10 -6
  163. package/lib/tab/index.js +1 -919
  164. package/lib/tab/props.d.ts +6 -0
  165. package/lib/table/index.js +1 -6635
  166. package/lib/table-column/index.js +1 -737
  167. package/lib/tag/index.js +1 -278
  168. package/lib/tag-input/index.js +1 -1897
  169. package/lib/time-picker/index.js +1 -142
  170. package/lib/timeline/index.js +1 -315
  171. package/lib/transfer/index.js +1 -658
  172. package/lib/tree/index.js +1 -2917
  173. package/lib/upload/index.js +1 -3735
  174. package/lib/virtual-render/index.js +1 -825
  175. package/package.json +2 -1
package/lib/tree/index.js CHANGED
@@ -1,2917 +1 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("../shared"), require("vue"), require("../virtual-render"), require("vue-types"), require("../exception"), require("../checkbox"), require("../icon"));
4
- else if(typeof define === 'function' && define.amd)
5
- define(["../shared", "vue", "../virtual-render", "vue-types", "../exception", "../checkbox", "../icon"], factory);
6
- else {
7
- var a = typeof exports === 'object' ? factory(require("../shared"), require("vue"), require("../virtual-render"), require("vue-types"), require("../exception"), require("../checkbox"), require("../icon")) : factory(root["../shared"], root["vue"], root["../virtual-render"], root["vue-types"], root["../exception"], root["../checkbox"], root["../icon"]);
8
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9
- }
10
- })(self, (__WEBPACK_EXTERNAL_MODULE__4212__, __WEBPACK_EXTERNAL_MODULE__748__, __WEBPACK_EXTERNAL_MODULE__3511__, __WEBPACK_EXTERNAL_MODULE__210__, __WEBPACK_EXTERNAL_MODULE__9911__, __WEBPACK_EXTERNAL_MODULE__5800__, __WEBPACK_EXTERNAL_MODULE__6870__) => {
11
- return /******/ (() => { // webpackBootstrap
12
- /******/ var __webpack_modules__ = ({
13
-
14
- /***/ 8022:
15
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
16
-
17
- var v1 = __webpack_require__(4481);
18
- var v4 = __webpack_require__(6426);
19
-
20
- var uuid = v4;
21
- uuid.v1 = v1;
22
- uuid.v4 = v4;
23
-
24
- module.exports = uuid;
25
-
26
-
27
- /***/ }),
28
-
29
- /***/ 8725:
30
- /***/ ((module) => {
31
-
32
- /**
33
- * Convert array of 16 byte values to UUID string format of the form:
34
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
35
- */
36
- var byteToHex = [];
37
- for (var i = 0; i < 256; ++i) {
38
- byteToHex[i] = (i + 0x100).toString(16).substr(1);
39
- }
40
-
41
- function bytesToUuid(buf, offset) {
42
- var i = offset || 0;
43
- var bth = byteToHex;
44
- // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
45
- return ([
46
- bth[buf[i++]], bth[buf[i++]],
47
- bth[buf[i++]], bth[buf[i++]], '-',
48
- bth[buf[i++]], bth[buf[i++]], '-',
49
- bth[buf[i++]], bth[buf[i++]], '-',
50
- bth[buf[i++]], bth[buf[i++]], '-',
51
- bth[buf[i++]], bth[buf[i++]],
52
- bth[buf[i++]], bth[buf[i++]],
53
- bth[buf[i++]], bth[buf[i++]]
54
- ]).join('');
55
- }
56
-
57
- module.exports = bytesToUuid;
58
-
59
-
60
- /***/ }),
61
-
62
- /***/ 9157:
63
- /***/ ((module) => {
64
-
65
- // Unique ID creation requires a high quality random # generator. In the
66
- // browser this is a little complicated due to unknown quality of Math.random()
67
- // and inconsistent support for the `crypto` API. We do the best we can via
68
- // feature-detection
69
-
70
- // getRandomValues needs to be invoked in a context where "this" is a Crypto
71
- // implementation. Also, find the complete implementation of crypto on IE11.
72
- var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||
73
- (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));
74
-
75
- if (getRandomValues) {
76
- // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
77
- var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
78
-
79
- module.exports = function whatwgRNG() {
80
- getRandomValues(rnds8);
81
- return rnds8;
82
- };
83
- } else {
84
- // Math.random()-based (RNG)
85
- //
86
- // If all else fails, use Math.random(). It's fast, but is of unspecified
87
- // quality.
88
- var rnds = new Array(16);
89
-
90
- module.exports = function mathRNG() {
91
- for (var i = 0, r; i < 16; i++) {
92
- if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
93
- rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
94
- }
95
-
96
- return rnds;
97
- };
98
- }
99
-
100
-
101
- /***/ }),
102
-
103
- /***/ 4481:
104
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
105
-
106
- var rng = __webpack_require__(9157);
107
- var bytesToUuid = __webpack_require__(8725);
108
-
109
- // **`v1()` - Generate time-based UUID**
110
- //
111
- // Inspired by https://github.com/LiosK/UUID.js
112
- // and http://docs.python.org/library/uuid.html
113
-
114
- var _nodeId;
115
- var _clockseq;
116
-
117
- // Previous uuid creation time
118
- var _lastMSecs = 0;
119
- var _lastNSecs = 0;
120
-
121
- // See https://github.com/uuidjs/uuid for API details
122
- function v1(options, buf, offset) {
123
- var i = buf && offset || 0;
124
- var b = buf || [];
125
-
126
- options = options || {};
127
- var node = options.node || _nodeId;
128
- var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
129
-
130
- // node and clockseq need to be initialized to random values if they're not
131
- // specified. We do this lazily to minimize issues related to insufficient
132
- // system entropy. See #189
133
- if (node == null || clockseq == null) {
134
- var seedBytes = rng();
135
- if (node == null) {
136
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
137
- node = _nodeId = [
138
- seedBytes[0] | 0x01,
139
- seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]
140
- ];
141
- }
142
- if (clockseq == null) {
143
- // Per 4.2.2, randomize (14 bit) clockseq
144
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
145
- }
146
- }
147
-
148
- // UUID timestamps are 100 nano-second units since the Gregorian epoch,
149
- // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
150
- // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
151
- // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
152
- var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
153
-
154
- // Per 4.2.1.2, use count of uuid's generated during the current clock
155
- // cycle to simulate higher resolution clock
156
- var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
157
-
158
- // Time since last uuid creation (in msecs)
159
- var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
160
-
161
- // Per 4.2.1.2, Bump clockseq on clock regression
162
- if (dt < 0 && options.clockseq === undefined) {
163
- clockseq = clockseq + 1 & 0x3fff;
164
- }
165
-
166
- // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
167
- // time interval
168
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
169
- nsecs = 0;
170
- }
171
-
172
- // Per 4.2.1.2 Throw error if too many uuids are requested
173
- if (nsecs >= 10000) {
174
- throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
175
- }
176
-
177
- _lastMSecs = msecs;
178
- _lastNSecs = nsecs;
179
- _clockseq = clockseq;
180
-
181
- // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
182
- msecs += 12219292800000;
183
-
184
- // `time_low`
185
- var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
186
- b[i++] = tl >>> 24 & 0xff;
187
- b[i++] = tl >>> 16 & 0xff;
188
- b[i++] = tl >>> 8 & 0xff;
189
- b[i++] = tl & 0xff;
190
-
191
- // `time_mid`
192
- var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
193
- b[i++] = tmh >>> 8 & 0xff;
194
- b[i++] = tmh & 0xff;
195
-
196
- // `time_high_and_version`
197
- b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
198
- b[i++] = tmh >>> 16 & 0xff;
199
-
200
- // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
201
- b[i++] = clockseq >>> 8 | 0x80;
202
-
203
- // `clock_seq_low`
204
- b[i++] = clockseq & 0xff;
205
-
206
- // `node`
207
- for (var n = 0; n < 6; ++n) {
208
- b[i + n] = node[n];
209
- }
210
-
211
- return buf ? buf : bytesToUuid(b);
212
- }
213
-
214
- module.exports = v1;
215
-
216
-
217
- /***/ }),
218
-
219
- /***/ 6426:
220
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
221
-
222
- var rng = __webpack_require__(9157);
223
- var bytesToUuid = __webpack_require__(8725);
224
-
225
- function v4(options, buf, offset) {
226
- var i = buf && offset || 0;
227
-
228
- if (typeof(options) == 'string') {
229
- buf = options === 'binary' ? new Array(16) : null;
230
- options = null;
231
- }
232
- options = options || {};
233
-
234
- var rnds = options.random || (options.rng || rng)();
235
-
236
- // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
237
- rnds[6] = (rnds[6] & 0x0f) | 0x40;
238
- rnds[8] = (rnds[8] & 0x3f) | 0x80;
239
-
240
- // Copy bytes to buffer, if provided
241
- if (buf) {
242
- for (var ii = 0; ii < 16; ++ii) {
243
- buf[i + ii] = rnds[ii];
244
- }
245
- }
246
-
247
- return buf || bytesToUuid(rnds);
248
- }
249
-
250
- module.exports = v4;
251
-
252
-
253
- /***/ }),
254
-
255
- /***/ 5800:
256
- /***/ ((module) => {
257
-
258
- "use strict";
259
- module.exports = __WEBPACK_EXTERNAL_MODULE__5800__;
260
-
261
- /***/ }),
262
-
263
- /***/ 9911:
264
- /***/ ((module) => {
265
-
266
- "use strict";
267
- module.exports = __WEBPACK_EXTERNAL_MODULE__9911__;
268
-
269
- /***/ }),
270
-
271
- /***/ 6870:
272
- /***/ ((module) => {
273
-
274
- "use strict";
275
- module.exports = __WEBPACK_EXTERNAL_MODULE__6870__;
276
-
277
- /***/ }),
278
-
279
- /***/ 4212:
280
- /***/ ((module) => {
281
-
282
- "use strict";
283
- module.exports = __WEBPACK_EXTERNAL_MODULE__4212__;
284
-
285
- /***/ }),
286
-
287
- /***/ 3511:
288
- /***/ ((module) => {
289
-
290
- "use strict";
291
- module.exports = __WEBPACK_EXTERNAL_MODULE__3511__;
292
-
293
- /***/ }),
294
-
295
- /***/ 748:
296
- /***/ ((module) => {
297
-
298
- "use strict";
299
- module.exports = __WEBPACK_EXTERNAL_MODULE__748__;
300
-
301
- /***/ }),
302
-
303
- /***/ 210:
304
- /***/ ((module) => {
305
-
306
- "use strict";
307
- module.exports = __WEBPACK_EXTERNAL_MODULE__210__;
308
-
309
- /***/ })
310
-
311
- /******/ });
312
- /************************************************************************/
313
- /******/ // The module cache
314
- /******/ var __webpack_module_cache__ = {};
315
- /******/
316
- /******/ // The require function
317
- /******/ function __webpack_require__(moduleId) {
318
- /******/ // Check if module is in cache
319
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
320
- /******/ if (cachedModule !== undefined) {
321
- /******/ return cachedModule.exports;
322
- /******/ }
323
- /******/ // Create a new module (and put it into the cache)
324
- /******/ var module = __webpack_module_cache__[moduleId] = {
325
- /******/ // no module.id needed
326
- /******/ // no module.loaded needed
327
- /******/ exports: {}
328
- /******/ };
329
- /******/
330
- /******/ // Execute the module function
331
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
332
- /******/
333
- /******/ // Return the exports of the module
334
- /******/ return module.exports;
335
- /******/ }
336
- /******/
337
- /************************************************************************/
338
- /******/ /* webpack/runtime/compat get default export */
339
- /******/ (() => {
340
- /******/ // getDefaultExport function for compatibility with non-harmony modules
341
- /******/ __webpack_require__.n = (module) => {
342
- /******/ var getter = module && module.__esModule ?
343
- /******/ () => (module['default']) :
344
- /******/ () => (module);
345
- /******/ __webpack_require__.d(getter, { a: getter });
346
- /******/ return getter;
347
- /******/ };
348
- /******/ })();
349
- /******/
350
- /******/ /* webpack/runtime/define property getters */
351
- /******/ (() => {
352
- /******/ // define getter functions for harmony exports
353
- /******/ __webpack_require__.d = (exports, definition) => {
354
- /******/ for(var key in definition) {
355
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
356
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
357
- /******/ }
358
- /******/ }
359
- /******/ };
360
- /******/ })();
361
- /******/
362
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
363
- /******/ (() => {
364
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
365
- /******/ })();
366
- /******/
367
- /******/ /* webpack/runtime/make namespace object */
368
- /******/ (() => {
369
- /******/ // define __esModule on exports
370
- /******/ __webpack_require__.r = (exports) => {
371
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
372
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
373
- /******/ }
374
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
375
- /******/ };
376
- /******/ })();
377
- /******/
378
- /************************************************************************/
379
- var __webpack_exports__ = {};
380
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
381
- (() => {
382
- "use strict";
383
- // ESM COMPAT FLAG
384
- __webpack_require__.r(__webpack_exports__);
385
-
386
- // EXPORTS
387
- __webpack_require__.d(__webpack_exports__, {
388
- "default": () => (/* binding */ src)
389
- });
390
-
391
- // EXTERNAL MODULE: external "../shared"
392
- var external_shared_ = __webpack_require__(4212);
393
- // EXTERNAL MODULE: external "vue"
394
- var external_vue_ = __webpack_require__(748);
395
- // EXTERNAL MODULE: external "../virtual-render"
396
- var external_virtual_render_ = __webpack_require__(3511);
397
- var external_virtual_render_default = /*#__PURE__*/__webpack_require__.n(external_virtual_render_);
398
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
399
- function _defineProperty(obj, key, value) {
400
- if (key in obj) {
401
- Object.defineProperty(obj, key, {
402
- value: value,
403
- enumerable: true,
404
- configurable: true,
405
- writable: true
406
- });
407
- } else {
408
- obj[key] = value;
409
- }
410
-
411
- return obj;
412
- }
413
- ;// CONCATENATED MODULE: ../../packages/tree/src/constant.ts
414
-
415
-
416
- var _TreeEmitEventsType, _NODE_SOURCE_ATTRS;
417
-
418
- /*
419
- * Tencent is pleased to support the open source community by making
420
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
421
- *
422
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
423
- *
424
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
425
- *
426
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
427
- *
428
- * ---------------------------------------------------
429
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
430
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
431
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
432
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
433
- *
434
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
435
- * the Software.
436
- *
437
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
438
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
439
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
440
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
441
- * IN THE SOFTWARE.
442
- */
443
- var EVENTS;
444
-
445
- (function (EVENTS) {
446
- EVENTS["NODE_CLICK"] = "nodeClick";
447
- EVENTS["NODE_COLLAPSE"] = "nodeCollapse";
448
- EVENTS["NODE_EXPAND"] = "nodeExpand";
449
- EVENTS["NODE_CHECKED"] = "nodeChecked";
450
- EVENTS["NODE_DRAG_START"] = "nodeDragStart";
451
- EVENTS["NODE_DRAG_OVER"] = "nodeDragOver";
452
- EVENTS["NODE_DRAG_LEAVE"] = "nodeDragLeave";
453
- EVENTS["NODE_DROP"] = "nodeDrop";
454
- })(EVENTS || (EVENTS = {}));
455
-
456
- var EMPTY = function EMPTY() {
457
- return true;
458
- };
459
-
460
- var TreeEmitEventsType = (_TreeEmitEventsType = {}, _defineProperty(_TreeEmitEventsType, EVENTS.NODE_CLICK, EMPTY), _defineProperty(_TreeEmitEventsType, EVENTS.NODE_COLLAPSE, EMPTY), _defineProperty(_TreeEmitEventsType, EVENTS.NODE_EXPAND, EMPTY), _defineProperty(_TreeEmitEventsType, EVENTS.NODE_CHECKED, EMPTY), _defineProperty(_TreeEmitEventsType, EVENTS.NODE_DRAG_START, EMPTY), _defineProperty(_TreeEmitEventsType, EVENTS.NODE_DRAG_OVER, EMPTY), _defineProperty(_TreeEmitEventsType, EVENTS.NODE_DRAG_LEAVE, EMPTY), _defineProperty(_TreeEmitEventsType, EVENTS.NODE_DROP, EMPTY), _TreeEmitEventsType);
461
- /**
462
- * 节点扩展属性
463
- */
464
- // eslint-disable-next-line @typescript-eslint/naming-convention
465
-
466
- var NODE_ATTRIBUTES;
467
-
468
- (function (NODE_ATTRIBUTES) {
469
- NODE_ATTRIBUTES["DEPTH"] = "__depth";
470
- NODE_ATTRIBUTES["INDEX"] = "__index";
471
- NODE_ATTRIBUTES["UUID"] = "__uuid";
472
- NODE_ATTRIBUTES["PARENT_ID"] = "__parent_id";
473
- NODE_ATTRIBUTES["HAS_CHILD"] = "__has_child";
474
- NODE_ATTRIBUTES["PATH"] = "__path";
475
- NODE_ATTRIBUTES["IS_ROOT"] = "__is_root";
476
- NODE_ATTRIBUTES["ORDER"] = "__order";
477
- NODE_ATTRIBUTES["IS_OPEN"] = "__is_open";
478
- NODE_ATTRIBUTES["IS_CHECKED"] = "__is_checked";
479
- NODE_ATTRIBUTES["IS_SELECTED"] = "__is_selected";
480
- NODE_ATTRIBUTES["IS_ASYNC_INIT"] = "__is_async_init";
481
- NODE_ATTRIBUTES["IS_MATCH"] = "__is_match";
482
- NODE_ATTRIBUTES["IS_NULL"] = "__IS_NULL";
483
- NODE_ATTRIBUTES["IS_CACHED"] = "__is_cached";
484
- NODE_ATTRIBUTES["IS_ASYNC"] = "__is_async";
485
- NODE_ATTRIBUTES["IS_LOADING"] = "__is_loading";
486
- NODE_ATTRIBUTES["TREE_NODE_ATTR"] = "__attr__";
487
- })(NODE_ATTRIBUTES || (NODE_ATTRIBUTES = {}));
488
-
489
- var NODE_SOURCE_ATTRS = (_NODE_SOURCE_ATTRS = {}, _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.IS_OPEN, 'isOpen'), _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.IS_SELECTED, 'selected'), _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.IS_MATCH, 'isMatch'), _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.HAS_CHILD, 'hasChild'), _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.IS_CHECKED, 'checked'), _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.IS_ASYNC, 'async'), _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.IS_LOADING, 'loading'), _defineProperty(_NODE_SOURCE_ATTRS, NODE_ATTRIBUTES.IS_ROOT, 'isRoot'), _NODE_SOURCE_ATTRS);
490
- /**
491
- * 节点点击可执行行为配置
492
- */
493
-
494
- var NodeContentActionEnum;
495
-
496
- (function (NodeContentActionEnum) {
497
- NodeContentActionEnum["CLICK"] = "click";
498
- NodeContentActionEnum["SELECTED"] = "selected";
499
- NodeContentActionEnum["EXPAND"] = "expand";
500
- NodeContentActionEnum["COLLAPSE"] = "collapse";
501
- })(NodeContentActionEnum || (NodeContentActionEnum = {}));
502
- // EXTERNAL MODULE: external "vue-types"
503
- var external_vue_types_ = __webpack_require__(210);
504
- ;// CONCATENATED MODULE: ../../packages/tree/src/props.ts
505
-
506
-
507
-
508
- var ColumnTypeEnum;
509
-
510
- (function (ColumnTypeEnum) {
511
- ColumnTypeEnum["ONCE"] = "once";
512
- ColumnTypeEnum["EVERY"] = "every";
513
- })(ColumnTypeEnum || (ColumnTypeEnum = {}));
514
-
515
- var TreeSearchMatchEnum;
516
-
517
- (function (TreeSearchMatchEnum) {
518
- TreeSearchMatchEnum["FUZZY"] = "fuzzy";
519
- TreeSearchMatchEnum["FULL"] = "full";
520
- })(TreeSearchMatchEnum || (TreeSearchMatchEnum = {}));
521
-
522
- var TreeSearchResultEnum;
523
-
524
- (function (TreeSearchResultEnum) {
525
- TreeSearchResultEnum["TREE"] = "tree";
526
- TreeSearchResultEnum["LIST"] = "list";
527
- })(TreeSearchResultEnum || (TreeSearchResultEnum = {}));
528
-
529
- var treeProps = {
530
- /**
531
- * 渲染列表
532
- */
533
- data: external_shared_.PropTypes.arrayOf(external_shared_.PropTypes.any).def([]),
534
-
535
- /**
536
- * 指定节点标签为节点对象的某个属性值
537
- */
538
- label: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.func.def(undefined), external_shared_.PropTypes.string.def('label')]),
539
-
540
- /**
541
- * 每个树节点用来作为唯一标识的属性,此标识应该是唯一的
542
- * 如果设置系统会默认自动生成唯一id
543
- */
544
- nodeKey: external_shared_.PropTypes.string.def(undefined),
545
-
546
- /**
547
- * 子节点 Key, 用于读取子节点
548
- * 默认 children
549
- */
550
- children: external_shared_.PropTypes.string.def('children'),
551
-
552
- /**
553
- * 相邻级节点间的水平缩进,单位为像素
554
- */
555
- indent: external_shared_.PropTypes.number.def(18),
556
-
557
- /**
558
- * 设置行高
559
- */
560
- lineHeight: external_shared_.PropTypes.number.def(32),
561
-
562
- /**
563
- * 设置层级连线
564
- */
565
- levelLine: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.bool.def(false), external_shared_.PropTypes.func.def(undefined), external_shared_.PropTypes.string.def('1px dashed #c3cdd7')]).def(false),
566
-
567
- /**
568
- * 是否开启虚拟滚动
569
- * 默认虚拟滚动是开启的,数据量大的情况下有利于性能优化,可以通过设置 virtualRender = false 关闭虚拟滚动
570
- */
571
- virtualRender: external_shared_.PropTypes.bool.def(false),
572
-
573
- /**
574
- * 当前节点标识图标
575
- * 默认 true
576
- */
577
- prefixIcon: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.func.def(function () {}), external_shared_.PropTypes.bool.def(false)]).def(true),
578
-
579
- /**
580
- * 异步加载节点数据配置
581
- * @param callback 请求数据回调函数,函数返回 Promise
582
- * @param cache 是否缓存请求结果,默认为True,只有在第一次才会发起请求,若设置为false则每次都会发起请求
583
- */
584
- async: external_shared_.PropTypes.shape({
585
- /**
586
- * 点击节点需要执行的异步函数
587
- * 返回 Promise
588
- */
589
- callback: external_shared_.PropTypes.func.def(undefined),
590
-
591
- /**
592
- * 是否缓存异步请求结果
593
- * true 只在第一次点击请求异步函数
594
- * false 每次点击都执行异步函数
595
- */
596
- cache: external_shared_.PropTypes.bool.def(true),
597
-
598
- /**
599
- * 异步请求节点是否自动展开
600
- * 可选值:once 只在初始化是执行一次
601
- * every 每次数据更新都执行
602
- */
603
- deepAutoOpen: (0,external_vue_types_.toType)('columnType', {}).def(ColumnTypeEnum.ONCE)
604
- }),
605
-
606
- /**
607
- * 每个节点偏移左侧距离
608
- */
609
- offsetLeft: external_shared_.PropTypes.number.def(5),
610
-
611
- /**
612
- * 搜索配置
613
- * 可以为一个配置项 SearchOption
614
- * 或者直接为一个字符串,如果直接为字符串则模糊匹配此值
615
- */
616
- search: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.shape({
617
- /**
618
- * 需要匹配的值
619
- * */
620
- value: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.number, external_shared_.PropTypes.string, external_shared_.PropTypes.bool]).def(''),
621
-
622
- /**
623
- * 匹配方式
624
- * 支持模糊匹配(fuzzy) || 完全匹配(full)
625
- * 默认 模糊匹配(fuzzy)
626
- * 支持自定义匹配函数 (searchValue, itemText, item) => true || false
627
- */
628
- match: external_shared_.PropTypes.oneOfType([(0,external_vue_types_.toType)('TreeSearchMatchType', {}).def(TreeSearchMatchEnum.FUZZY), external_shared_.PropTypes.func]),
629
-
630
- /**
631
- * 搜索结果如何展示
632
- * 显示为 tree || list
633
- * 默认 tree
634
- */
635
- resultType: (0,external_vue_types_.toType)('treeSearchResultType', {}).def(TreeSearchResultEnum.TREE),
636
-
637
- /**
638
- * 默认展开所有搜索结果
639
- */
640
- openResultNode: external_shared_.PropTypes.bool
641
- }), external_shared_.PropTypes.string, external_shared_.PropTypes.number, external_shared_.PropTypes.bool]).def(undefined),
642
- emptyText: external_shared_.PropTypes.string.def('没有数据'),
643
- draggable: external_shared_.PropTypes.bool.def(false),
644
- disableDrag: external_shared_.PropTypes.func.def(null),
645
- disableDrop: external_shared_.PropTypes.func.def(null),
646
-
647
- /**
648
- * 节点拖拽时可交换位置(开启拖拽可交换位置后将不支持改变层级)
649
- */
650
- dragSort: external_shared_.PropTypes.bool.def(false),
651
-
652
- /**
653
- * 节点是否可以选中
654
- */
655
- selectable: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.bool, external_shared_.PropTypes.func]).def(true),
656
- disabledFolderSelectable: external_shared_.PropTypes.bool.def(false),
657
-
658
- /**
659
- * 是否支持多选
660
- */
661
- showCheckbox: external_shared_.PropTypes.bool.def(false),
662
-
663
- /**
664
- * 是否显示节点类型Icon
665
- */
666
- showNodeTypeIcon: external_shared_.PropTypes.bool.def(true),
667
-
668
- /**
669
- * 默认选中的节点id,selectable为false时无效
670
- */
671
- selected: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.string, null, external_shared_.PropTypes.number, external_shared_.PropTypes.object]).def(null),
672
-
673
- /**
674
- * 是否自动检查当前节点是否有子节点
675
- * 节点前面的展开收起Icon会根据判定值做改变
676
- * 如果需要自已控制,请设置为false
677
- */
678
- autoCheckChildren: external_shared_.PropTypes.bool.def(true),
679
-
680
- /**
681
- * 如果设置了某一个叶子节点状态为展开,是否自动展开所有父级节点
682
- * 默认为true,如果设置为false,则每层状态需要自己控制
683
- */
684
- autoOpenParentNode: external_shared_.PropTypes.bool.def(true),
685
-
686
- /**
687
- * 默认是否展开所有节点
688
- */
689
- expandAll: external_shared_.PropTypes.bool.def(false),
690
-
691
- /**
692
- * 节点内容点击行为
693
- * 此处配置每个节点除了展开\收起箭头之外的内容块时的行为
694
- * 默认为 ['selected', 'expand', 'click'],点击内容块为选中当前节点
695
- */
696
- nodeContentAction: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.arrayOf((0,external_vue_types_.toType)('nodeContentActionType', {}).def(NodeContentActionEnum.CLICK)), external_shared_.PropTypes.func.def(function () {
697
- return ['selected'];
698
- })]).def(['selected', 'expand', 'click'])
699
- };
700
- // EXTERNAL MODULE: external "../exception"
701
- var external_exception_ = __webpack_require__(9911);
702
- var external_exception_default = /*#__PURE__*/__webpack_require__.n(external_exception_);
703
- ;// CONCATENATED MODULE: ../../packages/tree/src/use-empty.tsx
704
-
705
-
706
- /*
707
- * Tencent is pleased to support the open source community by making
708
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
709
- *
710
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
711
- *
712
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
713
- *
714
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
715
- *
716
- * ---------------------------------------------------
717
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
718
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
719
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
720
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
721
- *
722
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
723
- * the Software.
724
- *
725
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
726
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
727
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
728
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
729
- * IN THE SOFTWARE.
730
- */
731
-
732
- /* harmony default export */ const use_empty = (function (props, _ref) {
733
- var slots = _ref.slots;
734
- return {
735
- renderEmpty: function renderEmpty(type) {
736
- var _a, _b;
737
-
738
- return (0,external_vue_.createVNode)((external_exception_default()), {
739
- "scene": "part",
740
- "type": type
741
- }, {
742
- "default": function _default() {
743
- return [(_b = (_a = slots["default"]) === null || _a === void 0 ? void 0 : _a.call(slots)) !== null && _b !== void 0 ? _b : props.emptyText];
744
- }
745
- });
746
- }
747
- };
748
- });
749
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/typeof.js
750
- function _typeof(obj) {
751
- "@babel/helpers - typeof";
752
-
753
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
754
- return typeof obj;
755
- } : function (obj) {
756
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
757
- }, _typeof(obj);
758
- }
759
- // EXTERNAL MODULE: external "../checkbox"
760
- var external_checkbox_ = __webpack_require__(5800);
761
- var external_checkbox_default = /*#__PURE__*/__webpack_require__.n(external_checkbox_);
762
- // EXTERNAL MODULE: external "../icon"
763
- var external_icon_ = __webpack_require__(6870);
764
- ;// CONCATENATED MODULE: ../../packages/tree/src/use-node-attribute.tsx
765
-
766
-
767
-
768
- /*
769
- * Tencent is pleased to support the open source community by making
770
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
771
- *
772
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
773
- *
774
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
775
- *
776
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
777
- *
778
- * ---------------------------------------------------
779
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
780
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
781
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
782
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
783
- *
784
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
785
- * the Software.
786
- *
787
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
788
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
789
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
790
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
791
- * IN THE SOFTWARE.
792
- */
793
-
794
- /* harmony default export */ const use_node_attribute = (function (flatData, props) {
795
- /**
796
- * 获取Schema中指定的对象值
797
- * @param key
798
- * @returns
799
- */
800
- var getSchemaVal = function getSchemaVal(key) {
801
- return flatData.schema.get(key);
802
- };
803
- /**
804
- * 获取节点属性
805
- * @param node 当前节点
806
- * @param attr 节点属性
807
- * @returns
808
- */
809
-
810
-
811
- var getNodeAttr = function getNodeAttr(node, attr) {
812
- var _a;
813
-
814
- return (_a = getSchemaVal(node[NODE_ATTRIBUTES.UUID])) === null || _a === void 0 ? void 0 : _a[attr];
815
- };
816
- /**
817
- * 设置节点属性
818
- * @param node 指定节点
819
- * @param attr 节点属性
820
- * @param val 属性值
821
- * @returns
822
- */
823
-
824
-
825
- var setNodeAttr = function setNodeAttr(node, attr, val) {
826
- flatData.schema.set(node[NODE_ATTRIBUTES.UUID], Object.assign(Object.assign({}, getSchemaVal(node[NODE_ATTRIBUTES.UUID])), _defineProperty({}, attr, val)));
827
- };
828
-
829
- var getNodePath = function getNodePath(node) {
830
- return getNodeAttr(node, NODE_ATTRIBUTES.PATH);
831
- };
832
-
833
- var getNodeId = function getNodeId(node) {
834
- return getNodeAttr(node, NODE_ATTRIBUTES.UUID);
835
- };
836
-
837
- var isRootNode = function isRootNode(node) {
838
- return getNodeAttr(node, NODE_ATTRIBUTES.IS_ROOT);
839
- };
840
-
841
- var isNodeOpened = function isNodeOpened(node) {
842
- return getNodeAttr(node, NODE_ATTRIBUTES.IS_OPEN);
843
- };
844
-
845
- var hasChildNode = function hasChildNode(node) {
846
- return getNodeAttr(node, NODE_ATTRIBUTES.HAS_CHILD);
847
- };
848
-
849
- var isNodeMatched = function isNodeMatched(node) {
850
- return getNodeAttr(node, NODE_ATTRIBUTES.IS_MATCH);
851
- };
852
-
853
- var isNodeChecked = function isNodeChecked(node) {
854
- return getNodeAttr(node, NODE_ATTRIBUTES.IS_CHECKED);
855
- };
856
-
857
- var getNodeParentId = function getNodeParentId(node) {
858
- return getNodeAttr(node, NODE_ATTRIBUTES.PARENT_ID);
859
- };
860
-
861
- var getNodeParentIdById = function getNodeParentIdById(id) {
862
- return getNodeAttr(_defineProperty({}, NODE_ATTRIBUTES.UUID, id), NODE_ATTRIBUTES.PARENT_ID);
863
- };
864
-
865
- var isNodeLoading = function isNodeLoading(node) {
866
- return getNodeAttr(node, NODE_ATTRIBUTES.IS_LOADING);
867
- };
868
-
869
- var setTreeNodeLoading = function setTreeNodeLoading(node, value) {
870
- setNodeAttr(node, NODE_ATTRIBUTES.IS_LOADING, value);
871
- };
872
-
873
- var deleteNodeSchema = function deleteNodeSchema(id) {
874
- return flatData.schema["delete"](id);
875
- };
876
-
877
- var getParentNode = function getParentNode(node) {
878
- return getSchemaVal(getNodeParentId(node));
879
- };
880
- /**
881
- * 判定指定节点是否为展开状态
882
- * @param item 节点或者节点 UUID
883
- * @returns
884
- */
885
-
886
-
887
- var isItemOpen = function isItemOpen(item) {
888
- var _a;
889
-
890
- if (_typeof(item) === 'object') {
891
- return isNodeOpened(item);
892
- }
893
-
894
- if (typeof item === 'string') {
895
- return (_a = getSchemaVal(item)) === null || _a === void 0 ? void 0 : _a[NODE_ATTRIBUTES.IS_OPEN];
896
- }
897
-
898
- return false;
899
- };
900
-
901
- var isParentNodeOpened = function isParentNodeOpened(node) {
902
- return isItemOpen(getNodeAttr(node, NODE_ATTRIBUTES.PARENT_ID));
903
- };
904
- /**
905
- * 过滤当前状态为Open的节点
906
- * 页面展示只会展示Open的节点
907
- * @param item
908
- * @returns
909
- */
910
-
911
-
912
- var checkNodeIsOpen = function checkNodeIsOpen(node) {
913
- return isRootNode(node) || isParentNodeOpened(node);
914
- };
915
- /**
916
- * 根据节点path返回源数据中节点信息
917
- * @param path
918
- * @returns
919
- */
920
-
921
-
922
- var getSourceNodeByPath = function getSourceNodeByPath(path) {
923
- var paths = path.split('-');
924
- return paths.reduce(function (pre, nodeIndex) {
925
- var index = Number(nodeIndex);
926
- return Array.isArray(pre) ? pre[index] : pre[props.children][index];
927
- }, props.data);
928
- };
929
-
930
- var getChildNodes = function getChildNodes(node) {
931
- var source = flatData.schema;
932
- return Array.prototype.filter.call(Array.from(source.keys()), function (key) {
933
- return source.get(key)[NODE_ATTRIBUTES.PARENT_ID] === node[NODE_ATTRIBUTES.UUID];
934
- });
935
- };
936
-
937
- var getSourceNodeByUID = function getSourceNodeByUID(uid) {
938
- return getSourceNodeByPath(getNodePath(_defineProperty({}, NODE_ATTRIBUTES.UUID, uid)));
939
- };
940
-
941
- var getParentNodeData = function getParentNodeData(uid) {
942
- if (isRootNode(_defineProperty({}, NODE_ATTRIBUTES.UUID, uid))) {
943
- return _defineProperty({}, props.children, props.data);
944
- }
945
-
946
- return getSourceNodeByUID(getNodeParentIdById(uid));
947
- };
948
- /**
949
- * 处理scoped slot 透传数据
950
- * @param item 当前节点数据
951
- * @returns
952
- */
953
-
954
-
955
- var resolveScopedSlotParam = function resolveScopedSlotParam(item) {
956
- var _ref2;
957
-
958
- return _ref2 = {}, _defineProperty(_ref2, NODE_SOURCE_ATTRS[NODE_ATTRIBUTES.IS_LOADING], getNodeAttr(item, NODE_ATTRIBUTES.IS_LOADING)), _defineProperty(_ref2, NODE_SOURCE_ATTRS[NODE_ATTRIBUTES.HAS_CHILD], hasChildNode(item)), _defineProperty(_ref2, NODE_SOURCE_ATTRS[NODE_ATTRIBUTES.IS_MATCH], isNodeMatched(item)), _defineProperty(_ref2, NODE_SOURCE_ATTRS[NODE_ATTRIBUTES.IS_CHECKED], isNodeChecked(item)), _defineProperty(_ref2, NODE_SOURCE_ATTRS[NODE_ATTRIBUTES.IS_OPEN], isNodeOpened(item)), _defineProperty(_ref2, NODE_SOURCE_ATTRS[NODE_ATTRIBUTES.IS_ROOT], isRootNode(item)), _defineProperty(_ref2, "fullPath", getNodeAttr(item, NODE_ATTRIBUTES.PATH)), _defineProperty(_ref2, "uuid", getNodeId(item)), _defineProperty(_ref2, "parentId", getNodeAttr(item, NODE_ATTRIBUTES.PARENT_ID)), _ref2;
959
- };
960
-
961
- var extendNodeAttr = function extendNodeAttr(item) {
962
- return Object.assign(Object.assign({}, item), _defineProperty({}, NODE_ATTRIBUTES.TREE_NODE_ATTR, resolveScopedSlotParam(item)));
963
- };
964
-
965
- return {
966
- getSchemaVal: getSchemaVal,
967
- getNodeAttr: getNodeAttr,
968
- getNodeId: getNodeId,
969
- getNodeParentId: getNodeParentId,
970
- getNodeParentIdById: getNodeParentIdById,
971
- getParentNodeData: getParentNodeData,
972
- getParentNode: getParentNode,
973
- setNodeAttr: setNodeAttr,
974
- getNodePath: getNodePath,
975
- isRootNode: isRootNode,
976
- isNodeOpened: isNodeOpened,
977
- hasChildNode: hasChildNode,
978
- isItemOpen: isItemOpen,
979
- isNodeChecked: isNodeChecked,
980
- isNodeMatched: isNodeMatched,
981
- isNodeLoading: isNodeLoading,
982
- checkNodeIsOpen: checkNodeIsOpen,
983
- getSourceNodeByPath: getSourceNodeByPath,
984
- getSourceNodeByUID: getSourceNodeByUID,
985
- deleteNodeSchema: deleteNodeSchema,
986
- resolveScopedSlotParam: resolveScopedSlotParam,
987
- setTreeNodeLoading: setTreeNodeLoading,
988
- extendNodeAttr: extendNodeAttr,
989
- getChildNodes: getChildNodes
990
- };
991
- });
992
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
993
- function _arrayLikeToArray(arr, len) {
994
- if (len == null || len > arr.length) len = arr.length;
995
-
996
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
997
- arr2[i] = arr[i];
998
- }
999
-
1000
- return arr2;
1001
- }
1002
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
1003
-
1004
- function _arrayWithoutHoles(arr) {
1005
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1006
- }
1007
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
1008
- function _iterableToArray(iter) {
1009
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1010
- }
1011
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
1012
-
1013
- function _unsupportedIterableToArray(o, minLen) {
1014
- if (!o) return;
1015
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1016
- var n = Object.prototype.toString.call(o).slice(8, -1);
1017
- if (n === "Object" && o.constructor) n = o.constructor.name;
1018
- if (n === "Map" || n === "Set") return Array.from(o);
1019
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1020
- }
1021
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
1022
- function _nonIterableSpread() {
1023
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1024
- }
1025
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
1026
-
1027
-
1028
-
1029
-
1030
- function _toConsumableArray(arr) {
1031
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1032
- }
1033
- ;// CONCATENATED MODULE: ../../packages/tree/src/util.ts
1034
-
1035
-
1036
-
1037
-
1038
- var _this = undefined;
1039
-
1040
- /*
1041
- * Tencent is pleased to support the open source community by making
1042
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
1043
- *
1044
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
1045
- *
1046
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
1047
- *
1048
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
1049
- *
1050
- * ---------------------------------------------------
1051
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
1052
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
1053
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
1054
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1055
- *
1056
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
1057
- * the Software.
1058
- *
1059
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
1060
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1061
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
1062
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1063
- * IN THE SOFTWARE.
1064
- */
1065
-
1066
-
1067
- var DEFAULT_LEVLE_LINE = '1px dashed #c3cdd7';
1068
- /**
1069
- * 获取配置项可为Bool|String|Function类型,如果为Bool则配置默认值
1070
- * @param props
1071
- * @param key
1072
- * @param item
1073
- * @param defaultTrueValue
1074
- * @param defaultFalseValue
1075
- * @returns
1076
- */
1077
-
1078
- var getPropsOneOfBoolValueWithDefault = function getPropsOneOfBoolValueWithDefault(props, key) {
1079
- var item = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1080
- var defaultTrueValue = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1081
- var defaultFalseValue = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
1082
- var args = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
1083
- var prop = props[key];
1084
-
1085
- if (typeof prop === 'boolean') {
1086
- return prop ? defaultTrueValue : defaultFalseValue;
1087
- }
1088
-
1089
- return getStringOrFuncStr(item, props, key, args);
1090
- };
1091
- /**
1092
- * 处理Props中用户给定的配置项(返回值为String或者Function)
1093
- * @param item 当前渲染数据(当item为Object时,返回当前Object中通过Props指定Key的Value,否则返回Props中指定的值)
1094
- * @param props Props
1095
- * @param key 配置项关键字
1096
- * @param args 其他参数
1097
- * @returns
1098
- */
1099
-
1100
-
1101
- var getStringOrFuncStr = function getStringOrFuncStr(item, props, key) {
1102
- var args = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1103
- var value = props[key];
1104
-
1105
- if (typeof value === 'string') {
1106
- if (_typeof(item) === 'object' && item !== null) {
1107
- if (!Object.prototype.hasOwnProperty.call(item, value)) {
1108
- console.error("cannot find node label with key ".concat(value));
1109
- }
1110
-
1111
- return item[value];
1112
- }
1113
-
1114
- return value;
1115
- }
1116
-
1117
- if (typeof value === 'function') {
1118
- var txt = value.apply(_this, [item].concat(_toConsumableArray(args)));
1119
-
1120
- if (typeof txt === 'string') {
1121
- return txt;
1122
- }
1123
-
1124
- console.error('props label with function return value is not string, please check and return string');
1125
- return undefined;
1126
- }
1127
-
1128
- return undefined;
1129
- };
1130
- /**
1131
- * 获取当前节点显示Label
1132
- * @param item 当前节点
1133
- * @param props Props
1134
- */
1135
-
1136
-
1137
- var getLabel = function getLabel(item, props) {
1138
- return getStringOrFuncStr(item, props, 'label');
1139
- };
1140
-
1141
- var getSchemaVal = function getSchemaVal(schema, uuid) {
1142
- return schema.get(uuid) || {};
1143
- };
1144
-
1145
- var getNodeAttr = function getNodeAttr(schema, uuid, key) {
1146
- var _a;
1147
-
1148
- return (_a = getSchemaVal(schema, uuid)) === null || _a === void 0 ? void 0 : _a[key];
1149
- };
1150
- /**
1151
- * 根据Props获取Tree样式设置
1152
- * @param item
1153
- * @param props
1154
- * @returns
1155
- */
1156
-
1157
-
1158
- var getTreeStyle = function getTreeStyle(item, props) {
1159
- // 处理Props回调函数,参数 [tree] 表示 levelLine 回调参数第二个,此次渲染请求为Tree外层样式
1160
- var levelLine = getPropsOneOfBoolValueWithDefault(props, 'levelLine', item, DEFAULT_LEVLE_LINE, null, ['tree']);
1161
- return {
1162
- '--level-line': levelLine,
1163
- '--lineHeight': "".concat(props.lineHeight, "px"),
1164
- '--indent': "".concat(props.indent, "px"),
1165
- '--offset-left': "".concat(props.offsetLeft, "px")
1166
- };
1167
- };
1168
- /**
1169
- * 获取节点样式配置
1170
- * @param item
1171
- * @param props
1172
- * @returns
1173
- */
1174
-
1175
- var getNodeItemStyle = function getNodeItemStyle(item, props) {
1176
- var flatData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1177
- var schema = flatData.schema;
1178
- var depth = getNodeAttr(schema, item[NODE_ATTRIBUTES.UUID], NODE_ATTRIBUTES.DEPTH);
1179
- return Object.assign({
1180
- '--depth': depth
1181
- }, typeof props.levelLine === 'function' ? {
1182
- '--level-line': getPropsOneOfBoolValueWithDefault(props, 'levelLine', item, DEFAULT_LEVLE_LINE, null, ['node'])
1183
- } : {});
1184
- };
1185
- /**
1186
- * 获取当前渲染节点Class List
1187
- * @param item
1188
- * @returns
1189
- */
1190
-
1191
- var getNodeItemClass = function getNodeItemClass(item, schema, props) {
1192
- // eslint-disable-next-line @typescript-eslint/naming-convention
1193
- var _ref = getSchemaVal(schema, item[NODE_ATTRIBUTES.UUID]) || {},
1194
- __is_root = _ref.__is_root,
1195
- __is_open = _ref.__is_open;
1196
-
1197
- return {
1198
- 'is-root': __is_root,
1199
- 'bk-tree-node': true,
1200
- 'is-open': __is_open,
1201
- 'is-virtual-render': props.virtualRender,
1202
- 'level-line': props.levelLine
1203
- };
1204
- };
1205
- /**
1206
- * 获取当前渲染节点Class List
1207
- * @param item
1208
- * @returns
1209
- */
1210
-
1211
- var getNodeRowClass = function getNodeRowClass(item, schema) {
1212
- // eslint-disable-next-line @typescript-eslint/naming-convention
1213
- var _ref2 = getSchemaVal(schema, item[NODE_ATTRIBUTES.UUID]) || {},
1214
- __is_checked = _ref2.__is_checked,
1215
- __is_selected = _ref2.__is_selected;
1216
-
1217
- return _defineProperty({
1218
- 'is-checked': __is_checked,
1219
- 'is-selected': __is_selected,
1220
- 'node-folder': item.is_folder,
1221
- 'node-leaf': item.is_leaf
1222
- }, (0,external_shared_.resolveClassName)('node-row'), true);
1223
- };
1224
- /**
1225
- * 根据路径更新指定节点Child-Data
1226
- * @param path 节点路径
1227
- * @param treeData Tree Data
1228
- * @param childKey Child Key
1229
- * @param nodekey 节点key
1230
- * @param nodeValue 节点值
1231
- */
1232
-
1233
- var updateTreeNode = function updateTreeNode(path, treeData, childKey, nodekey, nodeValue) {
1234
- assignTreeNode(path, treeData, childKey, _defineProperty({}, nodekey, nodeValue));
1235
- };
1236
- /**
1237
- * 根据路径更新指定节点Child-Data
1238
- * @param path 节点路径
1239
- * @param treeData Tree Data
1240
- * @param childKey Child Key
1241
- * @param assignVal value
1242
- */
1243
-
1244
- var assignTreeNode = function assignTreeNode(path, treeData, childKey, assignVal) {
1245
- var paths = path.split('-');
1246
- var targetNode = paths.reduce(function (pre, nodeIndex) {
1247
- var index = Number(nodeIndex);
1248
- return Array.isArray(pre) ? pre[index] : pre[childKey][index];
1249
- }, treeData);
1250
- Object.assign(targetNode, assignVal || {});
1251
- };
1252
- var resolveNodeItem = function resolveNodeItem(node) {
1253
- if (node === undefined || node === null) {
1254
- return {
1255
- __IS_NULL: true
1256
- };
1257
- }
1258
-
1259
- if (typeof node === 'string' || typeof node === 'number' || _typeof(node) === 'symbol') {
1260
- return _defineProperty({}, NODE_ATTRIBUTES.UUID, node);
1261
- }
1262
-
1263
- if (Object.prototype.hasOwnProperty.call(node, NODE_ATTRIBUTES.UUID)) {
1264
- return node;
1265
- }
1266
-
1267
- console.error('setNodeAction Error: node id cannot found');
1268
- return node;
1269
- };
1270
- ;// CONCATENATED MODULE: ../../packages/tree/src/use-node-async.tsx
1271
-
1272
-
1273
- /*
1274
- * Tencent is pleased to support the open source community by making
1275
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
1276
- *
1277
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
1278
- *
1279
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
1280
- *
1281
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
1282
- *
1283
- * ---------------------------------------------------
1284
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
1285
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
1286
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
1287
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1288
- *
1289
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
1290
- * the Software.
1291
- *
1292
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
1293
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1294
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
1295
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1296
- * IN THE SOFTWARE.
1297
- */
1298
-
1299
-
1300
-
1301
- ;
1302
- /* harmony default export */ const use_node_async = (function (props, flatData) {
1303
- var _useNodeAttribute = use_node_attribute(flatData, props),
1304
- setNodeAttr = _useNodeAttribute.setNodeAttr,
1305
- getNodePath = _useNodeAttribute.getNodePath,
1306
- getNodeAttr = _useNodeAttribute.getNodeAttr,
1307
- resolveScopedSlotParam = _useNodeAttribute.resolveScopedSlotParam,
1308
- setTreeNodeLoading = _useNodeAttribute.setTreeNodeLoading;
1309
- /**
1310
- * 处理异步加载节点数据返回结果
1311
- * @param resp 异步请求返回结果
1312
- * @param item 当前节点
1313
- */
1314
-
1315
-
1316
- var setNodeRemoteLoad = function setNodeRemoteLoad(resp, item) {
1317
- if (_typeof(resp) === 'object' && resp !== null) {
1318
- setNodeAttr(item, NODE_ATTRIBUTES.IS_OPEN, true);
1319
- var nodeValue = Array.isArray(resp) ? resp : [resp];
1320
- updateTreeNode(getNodePath(item), props.data, props.children, props.children, nodeValue);
1321
- return Promise.resolve(resp);
1322
- }
1323
-
1324
- return Promise.resolve(resp);
1325
- };
1326
-
1327
- var asyncNodeClick = function asyncNodeClick(item) {
1328
- var _ref = props.async || {},
1329
- _ref$callback = _ref.callback,
1330
- callback = _ref$callback === void 0 ? null : _ref$callback,
1331
- _ref$cache = _ref.cache,
1332
- cache = _ref$cache === void 0 ? true : _ref$cache;
1333
- /** 如果是异步请求加载 */
1334
-
1335
-
1336
- if (typeof callback === 'function' && getNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC)) {
1337
- /** 用于注释当前节点是否已经初始化过 */
1338
- setNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC_INIT, true);
1339
-
1340
- if (!getNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED)) {
1341
- setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, cache);
1342
- var dataAttr = resolveScopedSlotParam(item);
1343
- var callbackResult = callback(item, function (resp) {
1344
- return setNodeRemoteLoad(resp, item);
1345
- }, dataAttr);
1346
-
1347
- if (_typeof(callbackResult) === 'object' && callbackResult !== null) {
1348
- setTreeNodeLoading(item, true);
1349
-
1350
- if (callbackResult instanceof Promise) {
1351
- return Promise.resolve(callbackResult.then(function (resp) {
1352
- return setNodeRemoteLoad(resp, item);
1353
- })["catch"](function (err) {
1354
- return console.error('load remote data error:', err);
1355
- })["finally"](function () {
1356
- setTreeNodeLoading(item, false);
1357
- setNodeAttr(item, NODE_ATTRIBUTES.IS_CACHED, true);
1358
- }));
1359
- }
1360
-
1361
- setNodeRemoteLoad(callbackResult, item);
1362
- setTreeNodeLoading(item, false);
1363
- return Promise.resolve(true);
1364
- }
1365
- }
1366
-
1367
- return Promise.resolve(true);
1368
- }
1369
-
1370
- return Promise.resolve(true);
1371
- };
1372
-
1373
- var deepAutoOpen = function deepAutoOpen() {
1374
- /** 过滤节点为异步加载 & 默认为展开 & 没有初始化过的节点 */
1375
- var autoOpenNodes = flatData.data.filter(function (item) {
1376
- return getNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC) && item[NODE_SOURCE_ATTRS[NODE_ATTRIBUTES.IS_OPEN]] && !getNodeAttr(item, NODE_ATTRIBUTES.IS_ASYNC_INIT);
1377
- });
1378
-
1379
- if (autoOpenNodes.length) {
1380
- Promise.all(autoOpenNodes.map(function (item) {
1381
- return asyncNodeClick(item);
1382
- })).then(function () {
1383
- deepAutoOpen();
1384
- })["catch"](function (err) {
1385
- console.warn(err);
1386
- });
1387
- }
1388
- };
1389
-
1390
- return {
1391
- asyncNodeClick: asyncNodeClick,
1392
- deepAutoOpen: deepAutoOpen
1393
- };
1394
- });
1395
- ;// CONCATENATED MODULE: ../../packages/tree/src/use-node-action.tsx
1396
-
1397
-
1398
-
1399
- var use_node_action_this = undefined;
1400
-
1401
-
1402
-
1403
- /*
1404
- * Tencent is pleased to support the open source community by making
1405
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
1406
- *
1407
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
1408
- *
1409
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
1410
- *
1411
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
1412
- *
1413
- * ---------------------------------------------------
1414
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
1415
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
1416
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
1417
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1418
- *
1419
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
1420
- * the Software.
1421
- *
1422
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
1423
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1424
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
1425
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1426
- * IN THE SOFTWARE.
1427
- */
1428
-
1429
-
1430
-
1431
-
1432
-
1433
-
1434
-
1435
-
1436
- /* harmony default export */ const use_node_action = (function (props, ctx, flatData, _renderData, schemaValues, initOption) {
1437
- // const checkedNodes = [];
1438
- var selectedNodeId = props.selected;
1439
-
1440
- var _useNodeAttribute = use_node_attribute(flatData, props),
1441
- setNodeAttr = _useNodeAttribute.setNodeAttr,
1442
- getNodePath = _useNodeAttribute.getNodePath,
1443
- getSchemaVal = _useNodeAttribute.getSchemaVal,
1444
- getNodeAttr = _useNodeAttribute.getNodeAttr,
1445
- getNodeId = _useNodeAttribute.getNodeId,
1446
- getChildNodes = _useNodeAttribute.getChildNodes,
1447
- isRootNode = _useNodeAttribute.isRootNode,
1448
- hasChildNode = _useNodeAttribute.hasChildNode,
1449
- isItemOpen = _useNodeAttribute.isItemOpen,
1450
- isNodeOpened = _useNodeAttribute.isNodeOpened,
1451
- isNodeLoading = _useNodeAttribute.isNodeLoading,
1452
- isNodeChecked = _useNodeAttribute.isNodeChecked,
1453
- getParentNode = _useNodeAttribute.getParentNode,
1454
- resolveScopedSlotParam = _useNodeAttribute.resolveScopedSlotParam,
1455
- extendNodeAttr = _useNodeAttribute.extendNodeAttr;
1456
-
1457
- var registerNextLoop = initOption.registerNextLoop;
1458
-
1459
- var _useNodeAsync = use_node_async(props, flatData),
1460
- asyncNodeClick = _useNodeAsync.asyncNodeClick,
1461
- deepAutoOpen = _useNodeAsync.deepAutoOpen;
1462
- /**
1463
- * 根据当前节点状态获取节点类型Icon
1464
- * @param item
1465
- * @returns
1466
- */
1467
-
1468
-
1469
- var getRootIcon = function getRootIcon(item) {
1470
- return isItemOpen(item) ? (0,external_vue_.createVNode)(external_icon_.FolderShapeOpen, {
1471
- "class": [(0,external_shared_.resolveClassName)('tree-icon'), (0,external_shared_.resolveClassName)('node-prefix')]
1472
- }, null) : (0,external_vue_.createVNode)(external_icon_.Folder, {
1473
- "class": [(0,external_shared_.resolveClassName)('tree-icon'), (0,external_shared_.resolveClassName)('node-prefix')]
1474
- }, null);
1475
- };
1476
- /**
1477
- * 渲染动态设置的节点样式
1478
- * @param val
1479
- * @returns
1480
- */
1481
-
1482
-
1483
- var renderPrefixVal = function renderPrefixVal(val) {
1484
- if (typeof val === 'string') {
1485
- return val;
1486
- }
1487
-
1488
- if (_typeof(val) === 'object' && val !== null) {
1489
- if (val.__v_isVNode) {
1490
- return val;
1491
- }
1492
-
1493
- var node = val.node,
1494
- className = val.className,
1495
- text = val.text,
1496
- style = val.style;
1497
- return (0,external_vue_.h)(node, {
1498
- "class": className,
1499
- style: style
1500
- }, text);
1501
- }
1502
-
1503
- return null;
1504
- };
1505
-
1506
- var getLoadingIcon = function getLoadingIcon(item) {
1507
- var _a, _b, _c;
1508
-
1509
- return ((_c = (_b = (_a = ctx.slots).nodeLoading) === null || _b === void 0 ? void 0 : _b.call(_a, extendNodeAttr(item))) !== null && _c !== void 0 ? _c : isNodeLoading(item)) ? (0,external_vue_.createVNode)(external_icon_.Spinner, null, null) : '';
1510
- };
1511
- /**
1512
- * 根据节点状态获取节点操作Icon
1513
- * @param item
1514
- * @returns
1515
- */
1516
-
1517
-
1518
- var getActionIcon = function getActionIcon(item) {
1519
- if (ctx.slots.nodeAction) {
1520
- return ctx.slots.nodeAction(extendNodeAttr(item));
1521
- }
1522
-
1523
- var prefixFnVal = null;
1524
-
1525
- if (isNodeLoading(item)) {
1526
- return getLoadingIcon(item);
1527
- }
1528
-
1529
- if (typeof props.prefixIcon === 'function') {
1530
- prefixFnVal = props.prefixIcon(extendNodeAttr(item), 'node_action');
1531
-
1532
- if (prefixFnVal !== 'default') {
1533
- return renderPrefixVal(prefixFnVal);
1534
- }
1535
- }
1536
-
1537
- if (prefixFnVal === 'default' || typeof props.prefixIcon === 'boolean' && props.prefixIcon) {
1538
- if (hasChildNode(item) || item.async || !props.autoCheckChildren) {
1539
- return isItemOpen(item) ? (0,external_vue_.createVNode)(external_icon_.DownShape, {
1540
- "class": (0,external_shared_.resolveClassName)('node-prefix')
1541
- }, null) : (0,external_vue_.createVNode)(external_icon_.RightShape, {
1542
- "class": (0,external_shared_.resolveClassName)('node-prefix')
1543
- }, null);
1544
- }
1545
- }
1546
-
1547
- return null;
1548
- };
1549
- /**
1550
- * 获取节点类型Icon
1551
- * @param item
1552
- * @returns
1553
- */
1554
-
1555
-
1556
- var getNodePrefixIcon = function getNodePrefixIcon(item) {
1557
- if (!props.showNodeTypeIcon) {
1558
- return null;
1559
- }
1560
-
1561
- if (ctx.slots.nodeType) {
1562
- return ctx.slots.nodeType(extendNodeAttr(item));
1563
- }
1564
-
1565
- var prefixFnVal = null;
1566
-
1567
- if (typeof props.prefixIcon === 'function') {
1568
- prefixFnVal = props.prefixIcon(extendNodeAttr(item), 'node_type');
1569
-
1570
- if (prefixFnVal !== 'default') {
1571
- return renderPrefixVal(prefixFnVal);
1572
- }
1573
- }
1574
-
1575
- if (prefixFnVal === 'default' || typeof props.prefixIcon === 'boolean' && props.prefixIcon) {
1576
- return isRootNode(item) || hasChildNode(item) ? getRootIcon(item) : (0,external_vue_.createVNode)(external_icon_.TextFile, {
1577
- "class": [(0,external_shared_.resolveClassName)('tree-icon'), (0,external_shared_.resolveClassName)('node-prefix')]
1578
- }, null);
1579
- }
1580
-
1581
- return null;
1582
- };
1583
-
1584
- var updateParentChecked = function updateParentChecked(item, isChecked) {
1585
- var parent = getParentNode(item);
1586
-
1587
- if (parent) {
1588
- setNodeAttr(parent, NODE_ATTRIBUTES.IS_CHECKED, isChecked);
1589
-
1590
- if (!isRootNode(parent)) {
1591
- updateParentChecked(parent, isChecked);
1592
- }
1593
- }
1594
- };
1595
-
1596
- var deepUpdateChildNode = function deepUpdateChildNode(node, attr, value) {
1597
- getChildNodes(node).forEach(function (id) {
1598
- setNodeAttr(_defineProperty({}, NODE_ATTRIBUTES.UUID, id), attr, value);
1599
- deepUpdateChildNode(_defineProperty({}, NODE_ATTRIBUTES.UUID, id), attr, value);
1600
- });
1601
- };
1602
-
1603
- var handleNodeItemCheckboxChange = function handleNodeItemCheckboxChange(item, value) {
1604
- setNodeAttr(item, NODE_ATTRIBUTES.IS_CHECKED, !!value);
1605
- deepUpdateChildNode(item, NODE_ATTRIBUTES.IS_CHECKED, !!value);
1606
- updateParentChecked(item, value);
1607
- ctx.emit(EVENTS.NODE_CHECKED, schemaValues.value.filter(function (t) {
1608
- return isNodeChecked(t);
1609
- }).map(function (n) {
1610
- return n[NODE_ATTRIBUTES.UUID];
1611
- }));
1612
- };
1613
-
1614
- var isIndeterminate = function isIndeterminate(item) {
1615
- return isNodeChecked(item) && !schemaValues.value.filter(function (node) {
1616
- var _a;
1617
-
1618
- return (_a = getNodePath(node)) === null || _a === void 0 ? void 0 : _a.startsWith(getNodePath(item));
1619
- }).every(function (filterNode) {
1620
- return isNodeChecked(filterNode);
1621
- });
1622
- };
1623
-
1624
- var isNodeItemChecked = function isNodeItemChecked(item) {
1625
- return isNodeChecked(item) || schemaValues.value.filter(function (node) {
1626
- var _a;
1627
-
1628
- return (_a = getNodePath(node)) === null || _a === void 0 ? void 0 : _a.startsWith(getNodePath(item));
1629
- }).some(function (filterNode) {
1630
- return isNodeChecked(filterNode);
1631
- });
1632
- };
1633
-
1634
- var getCheckboxRender = function getCheckboxRender(item) {
1635
- if (!props.showCheckbox) {
1636
- return null;
1637
- }
1638
-
1639
- return (0,external_vue_.createVNode)((external_checkbox_default()), {
1640
- "size": 'small',
1641
- "modelValue": isNodeItemChecked(item),
1642
- "indeterminate": isIndeterminate(item),
1643
- "onChange": function onChange(val) {
1644
- return handleNodeItemCheckboxChange(item, val);
1645
- }
1646
- }, null);
1647
- };
1648
- /**
1649
- * 设置指定节点是否展开
1650
- * @param item
1651
- * @param isOpen
1652
- */
1653
-
1654
-
1655
- var setNodeOpened = function setNodeOpened(item) {
1656
- var isOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1657
- var e = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1658
- var fireEmit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
1659
- var newVal = isOpen === null ? !isItemOpen(item) : !!isOpen;
1660
- /**
1661
- * 在收起节点时需要重置当前节点的所有叶子节点状态为 __isOpen = false
1662
- * 如果是需要点击当前节点展开所有叶子节点此处也可以打开
1663
- */
1664
-
1665
- if (!newVal) {
1666
- deepUpdateChildNode(item, NODE_ATTRIBUTES.IS_OPEN, newVal);
1667
- }
1668
-
1669
- setNodeAttr(item, NODE_ATTRIBUTES.IS_OPEN, newVal);
1670
-
1671
- if (fireEmit) {
1672
- var emitEvent = isItemOpen(item) ? EVENTS.NODE_EXPAND : EVENTS.NODE_COLLAPSE;
1673
- ctx.emit(emitEvent, item, resolveScopedSlotParam(item), getSchemaVal(item[NODE_ATTRIBUTES.UUID]), e);
1674
- }
1675
- };
1676
- /**
1677
- * 设置指定节点行为 checked isOpen
1678
- * @param args
1679
- * @param action
1680
- * @param value
1681
- * @returns
1682
- */
1683
-
1684
-
1685
- var setNodeAction = function setNodeAction(args, action, value) {
1686
- if (Array.isArray(args)) {
1687
- args.forEach(function (node) {
1688
- return setNodeAttr(resolveNodeItem(node), action, value);
1689
- });
1690
- return;
1691
- }
1692
-
1693
- setNodeAttr(resolveNodeItem(args), action, value);
1694
- };
1695
- /**
1696
- * 指定节点展开
1697
- * @param item 节点数据 | Node Id
1698
- * @param isOpen 是否展开
1699
- * @param autoOpenParents 如果是 isOpen = true,是否自动设置所有父级展开
1700
- * @returns
1701
- */
1702
-
1703
-
1704
- var setOpen = function setOpen(item) {
1705
- var isOpen = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1706
- var autoOpenParents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1707
- var resolvedItem = resolveNodeItem(item);
1708
-
1709
- if (resolvedItem[NODE_ATTRIBUTES.IS_NULL]) {
1710
- return;
1711
- }
1712
-
1713
- if (autoOpenParents) {
1714
- if (isOpen) {
1715
- setNodeAction(resolvedItem, NODE_ATTRIBUTES.IS_OPEN, true);
1716
-
1717
- if (!isRootNode(resolvedItem)) {
1718
- var parentId = getNodeAttr(resolvedItem, NODE_ATTRIBUTES.PARENT_ID);
1719
- setOpen(parentId, true, true);
1720
- }
1721
- } else {
1722
- setNodeOpened(resolvedItem, false, null, false);
1723
- }
1724
- } else {
1725
- setNodeAction(resolvedItem, NODE_ATTRIBUTES.IS_OPEN, isOpen);
1726
- }
1727
- };
1728
- /**
1729
- * 节点点击
1730
- * @param item
1731
- */
1732
-
1733
-
1734
- var handleTreeNodeClick = function handleTreeNodeClick(item, e) {
1735
- var isOpen = isNodeOpened(item);
1736
-
1737
- if (isOpen) {
1738
- setNodeOpened(item, false, e);
1739
- return;
1740
- }
1741
- /** 如果是异步请求加载 */
1742
-
1743
-
1744
- asyncNodeClick(item)["finally"](function () {
1745
- if (getNodeAttr(item, NODE_ATTRIBUTES.IS_LOADING)) {
1746
- registerNextLoop('setNodeOpenedAfterLoading', {
1747
- type: 'once',
1748
- fn: function fn() {
1749
- return setNodeOpened(item, true, e);
1750
- }
1751
- });
1752
- } else {
1753
- setNodeOpened(item, true, e);
1754
- }
1755
- });
1756
- };
1757
- /**
1758
- * 点击树形节点展开、收起图标处理事件
1759
- * @param e 鼠标事件
1760
- * @param node 当前节点
1761
- */
1762
-
1763
-
1764
- var handleNodeActionClick = function handleNodeActionClick(e, node) {
1765
- e.stopImmediatePropagation();
1766
- e.stopPropagation();
1767
- e.preventDefault();
1768
- handleTreeNodeClick(node, e);
1769
- };
1770
-
1771
- var setSelect = function setSelect(uuid) {
1772
- var selected = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1773
- var autoOpen = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1774
- var nodeList = Array.isArray(uuid) ? uuid : [uuid];
1775
-
1776
- if (!nodeList.length) {
1777
- return;
1778
- }
1779
-
1780
- var resolvedItem = resolveNodeItem(nodeList[0]);
1781
-
1782
- if (resolvedItem[NODE_ATTRIBUTES.IS_NULL]) {
1783
- return;
1784
- }
1785
-
1786
- if (!props.selectable || typeof props.selectable === 'function' && !props.selectable(uuid) || props.disabledFolderSelectable && (uuid === null || uuid === void 0 ? void 0 : uuid.is_folder) === true) {
1787
- console.warn('props.selectable is false or undefined, please set selectable with true');
1788
- return;
1789
- }
1790
-
1791
- if (selectedNodeId !== null && selectedNodeId !== undefined) {
1792
- setNodeAttr(_defineProperty({}, NODE_ATTRIBUTES.UUID, selectedNodeId), NODE_ATTRIBUTES.IS_SELECTED, !selected);
1793
- }
1794
-
1795
- if (props.selected && props.selected !== selectedNodeId) {
1796
- setNodeAttr(_defineProperty({}, NODE_ATTRIBUTES.UUID, props.selected), NODE_ATTRIBUTES.IS_SELECTED, !selected);
1797
- }
1798
-
1799
- setNodeAttr(resolvedItem, NODE_ATTRIBUTES.IS_SELECTED, selected);
1800
- selectedNodeId = getNodeId(resolvedItem);
1801
- /**
1802
- * 如果设置了自动展开
1803
- * 判定长度是为了处理异步节点,如果当前设置selected的节点为多级异步节点
1804
- * 此时需要一层一层展开所有数据,只需要在最后一次执行setOpen即可
1805
- */
1806
-
1807
- if (autoOpen && nodeList.length === 1) {
1808
- setOpen(resolvedItem, true, true);
1809
- }
1810
- /**
1811
- * 处理异步节点多层级展开选中
1812
- */
1813
-
1814
-
1815
- if (getNodeAttr(resolvedItem, NODE_ATTRIBUTES.IS_ASYNC)) {
1816
- asyncNodeClick(resolvedItem).then(function () {
1817
- (0,external_vue_.nextTick)(function () {
1818
- nodeList.shift();
1819
- setSelect(nodeList, selected, autoOpen);
1820
- });
1821
- });
1822
- }
1823
- };
1824
-
1825
- var resolveNodeAction = function resolveNodeAction(node) {
1826
- if (typeof props.nodeContentAction === 'function') {
1827
- return Reflect.apply(props.nodeContentAction, use_node_action_this, [{
1828
- node: node
1829
- }]);
1830
- }
1831
-
1832
- if (typeof props.nodeContentAction === 'string') {
1833
- return [props.nodeContentAction];
1834
- }
1835
-
1836
- if (Array.isArray(props.nodeContentAction)) {
1837
- return props.nodeContentAction;
1838
- }
1839
-
1840
- return ['selected', 'expand', 'click'];
1841
- };
1842
- /**
1843
- * 点击节点事件
1844
- * @param item
1845
- */
1846
-
1847
-
1848
- var handleNodeContentClick = function handleNodeContentClick(item, e) {
1849
- var nodeActions = resolveNodeAction(item);
1850
-
1851
- if (nodeActions.includes('selected')) {
1852
- setSelect(item, true, false);
1853
- }
1854
-
1855
- if (nodeActions.includes('expand')) {
1856
- if (!isNodeOpened(item)) {
1857
- handleTreeNodeClick(item, e);
1858
- }
1859
- }
1860
-
1861
- if (nodeActions.includes('collapse')) {
1862
- if (isNodeOpened(item)) {
1863
- handleTreeNodeClick(item, e);
1864
- }
1865
- }
1866
-
1867
- if (nodeActions.includes('click')) {
1868
- var eventName = EVENTS.NODE_CLICK;
1869
- ctx.emit(eventName, item, resolveScopedSlotParam(item), getSchemaVal(item[NODE_ATTRIBUTES.UUID]), e);
1870
- }
1871
- };
1872
- /**
1873
- * 用于判定当前节点需要展示的连线
1874
- * 当前指定的depth需不需要展示连线
1875
- * @param depth 当前需要判定的depth
1876
- * @param node 当前节点
1877
- * @returns
1878
- */
1879
-
1880
-
1881
- var filterNextNode = function filterNextNode(depth, node) {
1882
- if (isRootNode(node)) {
1883
- return false;
1884
- }
1885
-
1886
- var nodepath = getNodePath(node);
1887
- var paths = "".concat(nodepath).split('-').slice(0, depth + 1);
1888
- var currentPath = paths.join('-'); // 如果是判定当前节点,则必须要有一条线
1889
-
1890
- if (currentPath === nodepath) {
1891
- return true;
1892
- }
1893
-
1894
- var lastLevel = paths.pop();
1895
- var nextLevel = parseInt(lastLevel, 10);
1896
- paths.push("".concat(nextLevel + 1));
1897
- var nextNodePath = paths.join('-');
1898
- return schemaValues.value.some(function (val) {
1899
- return val[NODE_ATTRIBUTES.PATH] === nextNodePath;
1900
- });
1901
- };
1902
- /**
1903
- * 获取层级连线
1904
- * @param node 节点
1905
- * @returns
1906
- */
1907
-
1908
-
1909
- var getVirtualLines = function getVirtualLines(node) {
1910
- if (!props.levelLine) {
1911
- return null;
1912
- }
1913
-
1914
- var getNodeLineStyle = function getNodeLineStyle(dpth) {
1915
- return {
1916
- '--depth': dpth
1917
- };
1918
- };
1919
-
1920
- var maxDeep = getNodeAttr(node, NODE_ATTRIBUTES.DEPTH) + 1;
1921
- return new Array(maxDeep).fill('').map(function (_, index) {
1922
- return index;
1923
- }).filter(function (depth) {
1924
- return filterNextNode(depth, node);
1925
- }).filter(function (depth) {
1926
- return depth > 0;
1927
- }) // @ts-ignore:next-line
1928
- .map(function (index) {
1929
- return (0,external_vue_.createVNode)("span", {
1930
- "class": "node-virtual-line",
1931
- "style": getNodeLineStyle(maxDeep - index)
1932
- }, null);
1933
- });
1934
- };
1935
-
1936
- var renderTreeNode = function renderTreeNode(item) {
1937
- var _a, _b, _c, _d, _e;
1938
-
1939
- return (0,external_vue_.createVNode)("div", {
1940
- "data-tree-node": getNodeId(item),
1941
- "key": getNodeId(item),
1942
- "class": getNodeRowClass(item, flatData.schema)
1943
- }, [(0,external_vue_.createVNode)("div", {
1944
- "class": getNodeItemClass(item, flatData.schema, props),
1945
- "style": getNodeItemStyle(item, props, flatData),
1946
- "onClick": function onClick(e) {
1947
- return handleNodeContentClick(item, e);
1948
- }
1949
- }, [(0,external_vue_.createVNode)("div", {
1950
- "class": [(0,external_shared_.resolveClassName)('node-action')],
1951
- "onClick": function onClick(e) {
1952
- return handleNodeActionClick(e, item);
1953
- }
1954
- }, [getActionIcon(item)]), (0,external_vue_.createVNode)("div", {
1955
- "class": (0,external_shared_.resolveClassName)('node-content')
1956
- }, [[getCheckboxRender(item), getNodePrefixIcon(item)], (0,external_vue_.createVNode)("span", {
1957
- "class": (0,external_shared_.resolveClassName)('node-text')
1958
- }, [(_c = (_b = (_a = ctx.slots).node) === null || _b === void 0 ? void 0 : _b.call(_a, extendNodeAttr(item))) !== null && _c !== void 0 ? _c : [getLabel(item, props)]]), (_e = (_d = ctx.slots).nodeAppend) === null || _e === void 0 ? void 0 : _e.call(_d, extendNodeAttr(item))]), getVirtualLines(item)])]);
1959
- };
1960
-
1961
- return {
1962
- renderTreeNode: renderTreeNode,
1963
- handleTreeNodeClick: handleTreeNodeClick,
1964
- deepAutoOpen: deepAutoOpen,
1965
- asyncNodeClick: asyncNodeClick,
1966
- setNodeAction: setNodeAction,
1967
- setNodeOpened: setNodeOpened,
1968
- setSelect: setSelect,
1969
- setOpen: setOpen
1970
- };
1971
- });
1972
- ;// CONCATENATED MODULE: ../../packages/tree/src/use-node-drag.tsx
1973
-
1974
-
1975
- var use_node_drag_this = undefined;
1976
-
1977
- /*
1978
- * Tencent is pleased to support the open source community by making
1979
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
1980
- *
1981
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
1982
- *
1983
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
1984
- *
1985
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
1986
- *
1987
- * ---------------------------------------------------
1988
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
1989
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
1990
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
1991
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1992
- *
1993
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
1994
- * the Software.
1995
- *
1996
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
1997
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1998
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
1999
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2000
- * IN THE SOFTWARE.
2001
- */
2002
-
2003
-
2004
-
2005
- /* harmony default export */ const use_node_drag = (function (props, ctx, root, flatData) {
2006
- var _useNodeAttribute = use_node_attribute(flatData, props),
2007
- getSourceNodeByUID = _useNodeAttribute.getSourceNodeByUID,
2008
- getNodeParentIdById = _useNodeAttribute.getNodeParentIdById,
2009
- getParentNodeData = _useNodeAttribute.getParentNodeData,
2010
- getNodeAttr = _useNodeAttribute.getNodeAttr,
2011
- getNodePath = _useNodeAttribute.getNodePath,
2012
- isRootNode = _useNodeAttribute.isRootNode;
2013
-
2014
- var isNeedCheckDraggable = (0,external_vue_.computed)(function () {
2015
- return typeof props.disableDrag === 'function';
2016
- });
2017
- var isNeedCheckDroppable = (0,external_vue_.computed)(function () {
2018
- return typeof props.disableDrop === 'function';
2019
- });
2020
-
2021
- var getTargetTreeNode = function getTargetTreeNode(e) {
2022
- var target = e.target;
2023
- return target.closest('[data-tree-node]');
2024
- };
2025
-
2026
- var getNodeByTargetTreeNode = function getNodeByTargetTreeNode(targetNode) {
2027
- var _a;
2028
-
2029
- var uid = (_a = targetNode === null || targetNode === void 0 ? void 0 : targetNode.dataset) === null || _a === void 0 ? void 0 : _a.treeNode;
2030
- return getSourceNodeByUID(uid);
2031
- };
2032
-
2033
- var handleTreeNodeMouseup = function handleTreeNodeMouseup(e) {
2034
- var targetNode = getTargetTreeNode(e);
2035
- targetNode.removeEventListener('mouseup', handleTreeNodeMouseup);
2036
- };
2037
-
2038
- var handleTreeNodeMousedown = function handleTreeNodeMousedown(e) {
2039
- var targetNode = getTargetTreeNode(e);
2040
- var data = getNodeByTargetTreeNode(targetNode);
2041
-
2042
- if (data.draggable === false || isNeedCheckDraggable.value && props.disableDrag(data)) {
2043
- targetNode.classList.add('bk-tree-drag-disabled');
2044
- return;
2045
- }
2046
-
2047
- targetNode.setAttribute('draggable', 'true');
2048
- targetNode.addEventListener('mouseup', handleTreeNodeMouseup);
2049
- };
2050
-
2051
- var handleTreeNodeDragover = function handleTreeNodeDragover(e) {
2052
- e.preventDefault();
2053
- var targetNode = getTargetTreeNode(e);
2054
- var data = getNodeByTargetTreeNode(targetNode);
2055
- ctx.emit(EVENTS.NODE_DRAG_OVER, e, targetNode, data);
2056
-
2057
- if (isNeedCheckDroppable.value && (props === null || props === void 0 ? void 0 : props.disableDrop(data))) {
2058
- e.dataTransfer.effectAllowed = 'move';
2059
- e.dataTransfer.dropEffect = 'none';
2060
- targetNode.classList.add('bk-tree-drop-disabled');
2061
- return;
2062
- }
2063
-
2064
- targetNode.classList.add('bk-tree-drop-active');
2065
- var sourceNodeId = e.dataTransfer.getData('node-id');
2066
- var targetNodeId = targetNode.getAttribute('data-tree-node');
2067
- var transferEffect = isNodeSortable(sourceNodeId, targetNodeId) ? 'move' : 'none';
2068
- e.dataTransfer.effectAllowed = transferEffect;
2069
- e.dataTransfer.dropEffect = transferEffect;
2070
- };
2071
-
2072
- var handleTreeNodeDragStart = function handleTreeNodeDragStart(e) {
2073
- e.dataTransfer.effectAllowed = 'move';
2074
- e.dataTransfer.dropEffect = 'move';
2075
- var targetNode = getTargetTreeNode(e);
2076
- e.dataTransfer.setData('text/plain', '');
2077
- e.dataTransfer.setData('node-id', targetNode.getAttribute('data-tree-node'));
2078
- ctx.emit(EVENTS.NODE_DRAG_START, e, targetNode);
2079
- };
2080
-
2081
- var handleTreeNodeDrop = function handleTreeNodeDrop(e) {
2082
- /** firefox的drop事件必须调用preventDefault()和stopPropagation(), 否则会自动重定向 */
2083
- e.preventDefault();
2084
- e.stopPropagation();
2085
- var targetNode = getTargetTreeNode(e);
2086
- targetNode.classList.remove('bk-tree-drop-active', 'bk-tree-drop-disabled');
2087
- var data = getNodeByTargetTreeNode(targetNode);
2088
-
2089
- if (isNeedCheckDroppable.value && props.disableDrop(data)) {
2090
- return;
2091
- }
2092
-
2093
- var sourceNodeId = e.dataTransfer.getData('node-id');
2094
- var targetNodeId = targetNode.getAttribute('data-tree-node');
2095
- Reflect.apply(props.dragSort ? dragSortData : dragAsChildNode, use_node_drag_this, [sourceNodeId, targetNodeId]);
2096
- ctx.emit(EVENTS.NODE_DROP, e, targetNode, data);
2097
- };
2098
-
2099
- var isNodeSortable = function isNodeSortable(sourceId, targetId) {
2100
- var sourcePath = getNodePath(_defineProperty({}, NODE_ATTRIBUTES.UUID, sourceId));
2101
- var targetPath = getNodePath(_defineProperty({}, NODE_ATTRIBUTES.UUID, targetId)); // if (!sourcePath || targetPath) {
2102
- // return false;
2103
- // }
2104
-
2105
- var sourceParentNodeId = getNodeParentIdById(sourceId);
2106
- var targetParentNode = getNodeParentIdById(targetId);
2107
-
2108
- if (sourceParentNodeId === targetParentNode) {
2109
- return true;
2110
- }
2111
-
2112
- return sourcePath.indexOf(targetPath) === -1 && targetPath.indexOf(sourcePath) === -1;
2113
- };
2114
-
2115
- var dragSortData = function dragSortData(sourceId, targetId) {
2116
- if (!isNodeSortable(sourceId, targetId)) {
2117
- return;
2118
- }
2119
-
2120
- var sourceNodeData = JSON.parse(JSON.stringify(getSourceNodeByUID(sourceId)));
2121
- var targetNodeData = JSON.parse(JSON.stringify(getSourceNodeByUID(targetId)));
2122
- var sourceNodeParent = getParentNodeData(sourceId);
2123
- var targetNodeParent = getParentNodeData(targetId);
2124
- var sourceNodeIndex = getNodeAttr(_defineProperty({}, NODE_ATTRIBUTES.UUID, sourceId), NODE_ATTRIBUTES.INDEX);
2125
- var targetNodeIndex = getNodeAttr(_defineProperty({}, NODE_ATTRIBUTES.UUID, targetId), NODE_ATTRIBUTES.INDEX);
2126
- sourceNodeParent === null || sourceNodeParent === void 0 ? void 0 : sourceNodeParent[props.children].splice(sourceNodeIndex, 1, targetNodeData);
2127
- targetNodeParent === null || targetNodeParent === void 0 ? void 0 : targetNodeParent[props.children].splice(targetNodeIndex, 1, sourceNodeData);
2128
- };
2129
-
2130
- var dragAsChildNode = function dragAsChildNode(sourceNodeId, targetNodeId) {
2131
- var sourceNodeData = getSourceNodeByUID(sourceNodeId);
2132
- var targetNodeData = getSourceNodeByUID(targetNodeId);
2133
- var parentNode = null;
2134
-
2135
- if (isRootNode(_defineProperty({}, NODE_ATTRIBUTES.UUID, sourceNodeId))) {
2136
- parentNode = props.data;
2137
- } else {
2138
- var sourceNodeParentId = getNodeParentIdById(sourceNodeId);
2139
-
2140
- if (sourceNodeParentId !== undefined && sourceNodeParentId !== null) {
2141
- parentNode = getSourceNodeByUID(sourceNodeParentId);
2142
- var sourceNodeIndex = getNodeAttr(_defineProperty({}, NODE_ATTRIBUTES.UUID, sourceNodeId), NODE_ATTRIBUTES.INDEX);
2143
- parentNode === null || parentNode === void 0 ? void 0 : parentNode[props.children].splice(sourceNodeIndex, 1);
2144
- }
2145
- }
2146
-
2147
- if (!targetNodeData[props.children]) {
2148
- targetNodeData[props.children] = [];
2149
- }
2150
-
2151
- targetNodeData[props.children].unshift(sourceNodeData);
2152
- };
2153
-
2154
- var handleTreeNodeDragLeave = function handleTreeNodeDragLeave(e) {
2155
- e.preventDefault();
2156
- var targetNode = getTargetTreeNode(e);
2157
- targetNode.classList.remove('bk-tree-drop-active', 'bk-tree-drop-disabled');
2158
- ctx.emit(EVENTS.NODE_DRAG_LEAVE, e, targetNode);
2159
- };
2160
-
2161
- (0,external_vue_.onMounted)(function () {
2162
- if (props.draggable && root.value) {
2163
- var rootTree = root.value.$el;
2164
- rootTree.addEventListener('mousedown', handleTreeNodeMousedown);
2165
- rootTree.addEventListener('dragstart', handleTreeNodeDragStart);
2166
- rootTree.addEventListener('dragover', handleTreeNodeDragover);
2167
- rootTree.addEventListener('dragleave', handleTreeNodeDragLeave);
2168
- rootTree.addEventListener('drop', handleTreeNodeDrop);
2169
- }
2170
- });
2171
- (0,external_vue_.onUnmounted)(function () {
2172
- if (props.draggable && root.value) {
2173
- var rootTree = root.value.$el;
2174
- rootTree.removeEventListener('mousedown', handleTreeNodeMousedown);
2175
- rootTree.removeEventListener('dragstart', handleTreeNodeDragStart);
2176
- rootTree.removeEventListener('dragover', handleTreeNodeDragover);
2177
- rootTree.removeEventListener('dragleave', handleTreeNodeDragLeave);
2178
- rootTree.removeEventListener('drop', handleTreeNodeDrop);
2179
- }
2180
- });
2181
- });
2182
- ;// CONCATENATED MODULE: ../../packages/tree/src/use-search.tsx
2183
-
2184
-
2185
- var use_search_this = undefined;
2186
-
2187
- /*
2188
- * Tencent is pleased to support the open source community by making
2189
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
2190
- *
2191
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
2192
- *
2193
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
2194
- *
2195
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
2196
- *
2197
- * ---------------------------------------------------
2198
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
2199
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
2200
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
2201
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2202
- *
2203
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
2204
- * the Software.
2205
- *
2206
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
2207
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2208
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
2209
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2210
- * IN THE SOFTWARE.
2211
- */
2212
-
2213
- /* harmony default export */ const use_search = (function (props) {
2214
- var _a;
2215
-
2216
- var refSearch = (0,external_vue_.toRef)(props, 'search');
2217
-
2218
- var _ref = (_a = props.search) !== null && _a !== void 0 ? _a : {},
2219
- _ref$openResultNode = _ref.openResultNode,
2220
- openResultNode = _ref$openResultNode === void 0 ? false : _ref$openResultNode,
2221
- _ref$resultType = _ref.resultType,
2222
- resultType = _ref$resultType === void 0 ? 'tree' : _ref$resultType;
2223
-
2224
- var isCommonType = function isCommonType(val) {
2225
- return ['string', 'number', 'boolean'].includes(_typeof(val));
2226
- };
2227
-
2228
- var exactMath = function exactMath(matchValue, itemValue) {
2229
- return matchValue === itemValue;
2230
- };
2231
-
2232
- var regMatch = function regMatch(matchValue, itemValue) {
2233
- return new RegExp("".concat(matchValue), 'i').test("".concat(itemValue));
2234
- };
2235
-
2236
- var matchFn = function matchFn(match, args) {
2237
- return Reflect.apply(match, use_search_this, args);
2238
- };
2239
-
2240
- var isSearchDisabled = refSearch.value === undefined || refSearch.value === false;
2241
-
2242
- var searchFn = function searchFn(itemValue, item) {
2243
- if (isSearchDisabled) {
2244
- return true;
2245
- }
2246
-
2247
- if (isCommonType(refSearch.value)) {
2248
- return matchFn(regMatch, [refSearch.value, itemValue, item]);
2249
- }
2250
-
2251
- var _refSearch$value = refSearch.value,
2252
- _refSearch$value$valu = _refSearch$value.value,
2253
- value = _refSearch$value$valu === void 0 ? '' : _refSearch$value$valu,
2254
- _refSearch$value$matc = _refSearch$value.match,
2255
- match = _refSearch$value$matc === void 0 ? 'fuzzy' : _refSearch$value$matc;
2256
- var defultMatch = match === 'fuzzy' ? regMatch : exactMath;
2257
- var matchCallback = typeof match === 'function' ? match : defultMatch;
2258
-
2259
- if ("".concat(value).length === 0) {
2260
- return true;
2261
- }
2262
-
2263
- return matchFn(matchCallback, [value, itemValue, item]);
2264
- };
2265
-
2266
- var isSearchActive = (0,external_vue_.computed)(function () {
2267
- return refSearch.value !== false && (isCommonType(refSearch.value) ? "".concat(refSearch.value).length > 0 : _typeof(refSearch.value) === 'object');
2268
- });
2269
- /**
2270
- * 索索结果展示为Tree
2271
- */
2272
-
2273
- var isTreeUI = resultType === 'tree';
2274
- return {
2275
- searchFn: searchFn,
2276
- refSearch: refSearch,
2277
- isSearchActive: isSearchActive,
2278
- isSearchDisabled: isSearchDisabled,
2279
- openResultNode: openResultNode,
2280
- resultType: resultType,
2281
- isTreeUI: isTreeUI
2282
- };
2283
- });
2284
- // EXTERNAL MODULE: ../../node_modules/uuid/index.js
2285
- var uuid = __webpack_require__(8022);
2286
- ;// CONCATENATED MODULE: ../../packages/tree/src/use-tree-init.tsx
2287
-
2288
-
2289
-
2290
- var use_tree_init_this = undefined;
2291
-
2292
- /*
2293
- * Tencent is pleased to support the open source community by making
2294
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
2295
- *
2296
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
2297
- *
2298
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
2299
- *
2300
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
2301
- *
2302
- * ---------------------------------------------------
2303
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
2304
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
2305
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
2306
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2307
- *
2308
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
2309
- * the Software.
2310
- *
2311
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
2312
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2313
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
2314
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2315
- * IN THE SOFTWARE.
2316
- */
2317
-
2318
-
2319
-
2320
-
2321
- /* harmony default export */ const use_tree_init = (function (props) {
2322
- var _a;
2323
- /**
2324
- * 扁平化当前数据
2325
- * @param arrData
2326
- * @returns
2327
- */
2328
-
2329
-
2330
- var getFlatdata = function getFlatdata(props) {
2331
- var _cachedDefaultVal;
2332
-
2333
- var treeData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
2334
- var cachedSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
2335
- var data = props.data,
2336
- children = props.children;
2337
- var checkedList = [];
2338
- var outputData = [];
2339
- var order = 0;
2340
- var schema = new Map();
2341
- /**
2342
- * 递归更新节点属性
2343
- * @param uuid 当前节点id
2344
- * @param attrName 需要更新的节点属性名称
2345
- * @param attrValue 需要更新的节点属性值
2346
- * @param callFn 回电函数
2347
- * @returns
2348
- */
2349
-
2350
- function loopUpdateNodeAttr(uuid, attrName, attrValue, callFn) {
2351
- if (uuid === undefined || uuid === null) {
2352
- return;
2353
- }
2354
-
2355
- if (schema.has(uuid) && ![NODE_ATTRIBUTES.UUID, NODE_ATTRIBUTES.PARENT_ID].includes(attrName)) {
2356
- var target = schema.get(uuid);
2357
-
2358
- if (Object.prototype.hasOwnProperty.call(target, attrName)) {
2359
- if (typeof callFn === 'function' && Reflect.apply(callFn, self, [target, attrName, attrValue])) {
2360
- Object.assign(target, _defineProperty({}, attrName, attrValue));
2361
- loopUpdateNodeAttr(target[NODE_ATTRIBUTES.PARENT_ID], attrName, attrValue, callFn);
2362
- }
2363
- }
2364
- }
2365
- }
2366
-
2367
- function getUid(item) {
2368
- var uid = null;
2369
-
2370
- if (typeof props.nodeKey === 'string') {
2371
- uid = item[props.nodeKey] || (0,uuid.v4)();
2372
- }
2373
-
2374
- return uid || item[NODE_ATTRIBUTES.UUID] || (0,uuid.v4)();
2375
- }
2376
-
2377
- var cachedDefaultVal = (_cachedDefaultVal = {}, _defineProperty(_cachedDefaultVal, NODE_ATTRIBUTES.IS_OPEN, function () {
2378
- return !!props.expandAll;
2379
- }), _defineProperty(_cachedDefaultVal, NODE_ATTRIBUTES.IS_CHECKED, function () {
2380
- return false;
2381
- }), _defineProperty(_cachedDefaultVal, NODE_ATTRIBUTES.IS_MATCH, function () {
2382
- return true;
2383
- }), _defineProperty(_cachedDefaultVal, NODE_ATTRIBUTES.IS_SELECTED, function (uuid) {
2384
- return props.selected === uuid;
2385
- }), _defineProperty(_cachedDefaultVal, NODE_ATTRIBUTES.IS_CACHED, function () {
2386
- return false;
2387
- }), _defineProperty(_cachedDefaultVal, NODE_ATTRIBUTES.IS_ASYNC, function () {
2388
- return null;
2389
- }), _defineProperty(_cachedDefaultVal, NODE_ATTRIBUTES.IS_LOADING, function () {
2390
- return false;
2391
- }), _cachedDefaultVal);
2392
-
2393
- function getCachedTreeNodeAttr(uuid, node, cachedAttr) {
2394
- var defVal = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined;
2395
- var defaultValue = defVal;
2396
-
2397
- if (defVal === undefined && typeof cachedDefaultVal[cachedAttr] === 'function') {
2398
- defaultValue = cachedDefaultVal[cachedAttr](uuid, node);
2399
- }
2400
-
2401
- var sourceAttr = NODE_SOURCE_ATTRS[cachedAttr];
2402
-
2403
- if (Object.prototype.hasOwnProperty.call(node, sourceAttr)) {
2404
- return node[sourceAttr];
2405
- }
2406
-
2407
- var cached = (cachedSchema || []).find(function (item) {
2408
- return item[NODE_ATTRIBUTES.UUID] === uuid;
2409
- });
2410
- var result = undefined;
2411
-
2412
- if (cached) {
2413
- result = cached[cachedAttr];
2414
- }
2415
-
2416
- if (result === undefined || result === null) {
2417
- result = defaultValue;
2418
- }
2419
-
2420
- return result;
2421
- }
2422
-
2423
- function isCachedTreeNodeSelected(uuid, node) {
2424
- if (!props.selectable) {
2425
- return false;
2426
- }
2427
-
2428
- return getCachedTreeNodeAttr(uuid, node, NODE_ATTRIBUTES.IS_SELECTED, props.selected === uuid);
2429
- }
2430
-
2431
- function isNodeOpend(uuid, item, parent) {
2432
- var _a;
2433
-
2434
- var isItemOpened = getCachedTreeNodeAttr(uuid, item, NODE_ATTRIBUTES.IS_OPEN);
2435
- var isParentOpened = schema.has(parent) ? (_a = schema.get(parent)) === null || _a === void 0 ? void 0 : _a[NODE_ATTRIBUTES.IS_OPEN] : true;
2436
- return isItemOpened && isParentOpened;
2437
- }
2438
-
2439
- function validateIsOpenLoopFn(target) {
2440
- return !target[NODE_ATTRIBUTES.IS_OPEN];
2441
- }
2442
-
2443
- function flatten(array) {
2444
- var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
2445
- var parent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
2446
- var path = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
2447
- var arrLength = array.length;
2448
-
2449
- for (var i = 0; i < arrLength; i++) {
2450
- var item = array[i];
2451
-
2452
- if (Array.isArray(item)) {
2453
- flatten(item, depth, parent, path);
2454
- } else {
2455
- if (_typeof(item) === 'object' && item !== null) {
2456
- var _schema$set, _Object$assign3;
2457
-
2458
- var currentPath = path !== null ? "".concat(path, "-").concat(i) : "".concat(i);
2459
- var uuid = "".concat(getUid(item));
2460
- var hasChildren = !!(item[children] || []).length;
2461
- /**
2462
- * 当前节点设置是否为展开状态
2463
- */
2464
-
2465
- var isOpened = getCachedTreeNodeAttr(uuid, item, NODE_ATTRIBUTES.IS_OPEN);
2466
- /**
2467
- * 如果初始化发现当前属性为展开或者选中 & 设置了 autoOpenParentNode = true
2468
- * 此时需要设置当前节点的所有父级节点都为展开状态
2469
- */
2470
-
2471
- if (props.autoOpenParentNode) {
2472
- isOpened && loopUpdateNodeAttr(parent, NODE_ATTRIBUTES.IS_OPEN, true, validateIsOpenLoopFn);
2473
- } else {
2474
- /**
2475
- * 如果没有设置自动展开所有父级
2476
- * 此时需要判定当前节点是否可以展开状态需要同时判定父级是否展开
2477
- * 如果父级不是展开状态,此节点不能展示,应该也是关闭状态,只有当父级展开时,此节点才为展开状态
2478
- */
2479
- isOpened = isNodeOpend(uuid, item, parent);
2480
- }
2481
-
2482
- Object.assign(item, _defineProperty({}, NODE_ATTRIBUTES.UUID, uuid));
2483
- var isChecked = props.showCheckbox && getCachedTreeNodeAttr(uuid, item, NODE_ATTRIBUTES.IS_CHECKED);
2484
-
2485
- if (isChecked) {
2486
- checkedList.push(uuid);
2487
- }
2488
-
2489
- schema.set(uuid, (_schema$set = {}, _defineProperty(_schema$set, NODE_ATTRIBUTES.DEPTH, depth), _defineProperty(_schema$set, NODE_ATTRIBUTES.INDEX, i), _defineProperty(_schema$set, NODE_ATTRIBUTES.UUID, uuid), _defineProperty(_schema$set, NODE_ATTRIBUTES.PARENT_ID, parent), _defineProperty(_schema$set, NODE_ATTRIBUTES.HAS_CHILD, hasChildren), _defineProperty(_schema$set, NODE_ATTRIBUTES.PATH, currentPath), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_ROOT, parent === null), _defineProperty(_schema$set, NODE_ATTRIBUTES.ORDER, order), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_SELECTED, isCachedTreeNodeSelected(uuid, item)), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_MATCH, getCachedTreeNodeAttr(uuid, item, NODE_ATTRIBUTES.IS_MATCH)), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_OPEN, isOpened), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_CHECKED, isChecked), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_CACHED, getCachedTreeNodeAttr(uuid, item, NODE_ATTRIBUTES.IS_CACHED)), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_ASYNC, getCachedTreeNodeAttr(uuid, item, NODE_ATTRIBUTES.IS_ASYNC)), _defineProperty(_schema$set, NODE_ATTRIBUTES.IS_LOADING, getCachedTreeNodeAttr(uuid, item, NODE_ATTRIBUTES.IS_LOADING)), _defineProperty(_schema$set, children, null), _schema$set));
2490
- order += 1;
2491
- outputData.push(Object.assign(Object.assign({}, JSON.parse(JSON.stringify(item, function (k, v) {
2492
- return k === props.children ? null : v;
2493
- }))), (_Object$assign3 = {}, _defineProperty(_Object$assign3, NODE_ATTRIBUTES.IS_OPEN, isOpened), _defineProperty(_Object$assign3, children, null), _Object$assign3)));
2494
-
2495
- if (Object.prototype.hasOwnProperty.call(item, children)) {
2496
- flatten(item[children] || [], depth + 1, uuid, currentPath);
2497
- }
2498
- }
2499
- }
2500
- }
2501
- }
2502
-
2503
- flatten(treeData ? treeData : data);
2504
-
2505
- if (props.showCheckbox) {
2506
- checkedList === null || checkedList === void 0 ? void 0 : checkedList.forEach(function (value) {
2507
- Array.from(schema.values()).filter(function (t) {
2508
- var _a;
2509
-
2510
- return (_a = t[NODE_ATTRIBUTES.PATH]) === null || _a === void 0 ? void 0 : _a.startsWith(schema.get(value)[NODE_ATTRIBUTES.PATH]);
2511
- }).forEach(function (n) {
2512
- return Object.assign(n, _defineProperty({}, NODE_ATTRIBUTES.IS_CHECKED, true));
2513
- });
2514
- loopUpdateNodeAttr(value, NODE_ATTRIBUTES.IS_CHECKED, true, function () {
2515
- return true;
2516
- });
2517
- });
2518
- }
2519
-
2520
- return [outputData, schema];
2521
- };
2522
-
2523
- var formatData = getFlatdata(props);
2524
- var nextLoopEvents = new Map();
2525
- var afterSelectEvents = [];
2526
- var afterSelectWatch = [];
2527
- /**
2528
- * 扁平化数据
2529
- * schema: 需要展示连线时,用于计算连线高度
2530
- */
2531
-
2532
- var flatData = (0,external_vue_.reactive)({
2533
- data: formatData[0],
2534
- schema: formatData[1],
2535
- levelLineSchema: {}
2536
- });
2537
- var schemaValues = (0,external_vue_.computed)(function () {
2538
- return Array.from(flatData.schema.values());
2539
- });
2540
-
2541
- var _useNodeAsync = use_node_async(props, flatData),
2542
- asyncNodeClick = _useNodeAsync.asyncNodeClick,
2543
- deepAutoOpen = _useNodeAsync.deepAutoOpen;
2544
- /**
2545
- * 抛出缓存函数,用于注册selected watch
2546
- * @param event
2547
- */
2548
-
2549
-
2550
- var onSelected = function onSelected(event) {
2551
- afterSelectEvents.push(event);
2552
- };
2553
-
2554
- var registerNextLoop = function registerNextLoop(key, event) {
2555
- var reset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
2556
-
2557
- if (reset && nextLoopEvents.has(key)) {
2558
- nextLoopEvents["delete"](key);
2559
- }
2560
-
2561
- nextLoopEvents.set(key, event);
2562
- };
2563
-
2564
- var resolveEventOption = function resolveEventOption(event) {
2565
- if (typeof event === 'function') {
2566
- return {
2567
- type: 'loop',
2568
- fn: event
2569
- };
2570
- }
2571
-
2572
- if (_typeof(event) === 'object' && typeof event.type === 'string' && typeof event.fn === 'function') {
2573
- return event;
2574
- }
2575
-
2576
- console.error('loop event error', event);
2577
- return null;
2578
- };
2579
-
2580
- var executeFn = function executeFn(event) {
2581
- var _a;
2582
-
2583
- var resoveEvent = resolveEventOption(event);
2584
-
2585
- if (resoveEvent !== null) {
2586
- Reflect.apply(resoveEvent.fn, use_tree_init_this, []);
2587
- }
2588
-
2589
- return (_a = resoveEvent === null || resoveEvent === void 0 ? void 0 : resoveEvent.type) !== null && _a !== void 0 ? _a : 'once';
2590
- };
2591
-
2592
- var executeNextEvent = function executeNextEvent() {
2593
- Array.from(nextLoopEvents.keys()).forEach(function (key) {
2594
- var target = nextLoopEvents.get(key);
2595
-
2596
- if (Array.isArray(target)) {
2597
- var clearList = [];
2598
- target.forEach(function (event, index) {
2599
- var result = executeFn(event);
2600
-
2601
- if (result === 'once') {
2602
- clearList.unshift(index);
2603
- }
2604
- });
2605
-
2606
- if (clearList.length) {
2607
- clearList.forEach(function (index) {
2608
- return target.splice(index, 1);
2609
- });
2610
- }
2611
-
2612
- if (target.length === 0) {
2613
- nextLoopEvents["delete"](key);
2614
- }
2615
- } else {
2616
- var result = executeFn(target);
2617
-
2618
- if (result === 'once') {
2619
- nextLoopEvents["delete"](key);
2620
- }
2621
- }
2622
- });
2623
- };
2624
- /**
2625
- * 监听组件配置Data改变
2626
- */
2627
-
2628
-
2629
- (0,external_vue_.watch)(function () {
2630
- return [props.data];
2631
- }, function (newData) {
2632
- var _a, _b;
2633
-
2634
- var formatData = getFlatdata(props, newData, schemaValues.value);
2635
- flatData.data = formatData[0];
2636
- flatData.schema = formatData[1];
2637
-
2638
- if (((_a = props.async) === null || _a === void 0 ? void 0 : _a.callback) && ((_b = props.async) === null || _b === void 0 ? void 0 : _b.deepAutoOpen) === 'every') {
2639
- deepAutoOpen();
2640
- }
2641
- /**
2642
- * 执行缓存下来的周期函数
2643
- * 保证data改变之后执行相关操作
2644
- */
2645
-
2646
-
2647
- executeNextEvent();
2648
- }, {
2649
- deep: true
2650
- });
2651
-
2652
- if (props.selectable) {
2653
- (0,external_vue_.onMounted)(function () {
2654
- (0,external_vue_.watch)(function () {
2655
- return props.selected;
2656
- }, function (newData) {
2657
- // console.log('watch selected changed');
2658
- afterSelectWatch.length = 0;
2659
- afterSelectEvents.forEach(function (event) {
2660
- Reflect.apply(event, use_tree_init_this, [newData]);
2661
- /**
2662
- * selected设置生效有可能会在props.data 改变之前
2663
- * 此时需要缓存当前执行函数,保证在watch data change 之后执行
2664
- */
2665
-
2666
- afterSelectWatch.push(function () {
2667
- return Reflect.apply(event, use_tree_init_this, [newData]);
2668
- });
2669
- });
2670
- registerNextLoop('afterSelectWatch', afterSelectWatch);
2671
- }, {
2672
- immediate: true
2673
- });
2674
- });
2675
- }
2676
-
2677
- var afterDataUpdate = function afterDataUpdate(callFn) {
2678
- registerNextLoop('afterDataUpdate', callFn);
2679
- };
2680
- /** 如果设置了异步请求 */
2681
-
2682
-
2683
- if ((_a = props.async) === null || _a === void 0 ? void 0 : _a.callback) {
2684
- deepAutoOpen();
2685
- }
2686
-
2687
- return {
2688
- flatData: flatData,
2689
- schemaValues: schemaValues,
2690
- asyncNodeClick: asyncNodeClick,
2691
- deepAutoOpen: deepAutoOpen,
2692
- afterDataUpdate: afterDataUpdate,
2693
- registerNextLoop: registerNextLoop,
2694
- onSelected: onSelected
2695
- };
2696
- });
2697
- ;// CONCATENATED MODULE: ../../packages/tree/src/tree.tsx
2698
-
2699
-
2700
- /*
2701
- * Tencent is pleased to support the open source community by making
2702
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
2703
- *
2704
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
2705
- *
2706
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
2707
- *
2708
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
2709
- *
2710
- * ---------------------------------------------------
2711
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
2712
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
2713
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
2714
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2715
- *
2716
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
2717
- * the Software.
2718
- *
2719
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
2720
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2721
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
2722
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2723
- * IN THE SOFTWARE.
2724
- */
2725
-
2726
-
2727
-
2728
-
2729
-
2730
-
2731
-
2732
-
2733
-
2734
-
2735
-
2736
-
2737
- /* harmony default export */ const tree = ((0,external_vue_.defineComponent)({
2738
- name: 'Tree',
2739
- props: treeProps,
2740
- emits: TreeEmitEventsType,
2741
- setup: function setup(props, ctx) {
2742
- var _useTreeInit = use_tree_init(props),
2743
- flatData = _useTreeInit.flatData,
2744
- schemaValues = _useTreeInit.schemaValues,
2745
- onSelected = _useTreeInit.onSelected,
2746
- registerNextLoop = _useTreeInit.registerNextLoop;
2747
-
2748
- var _useNodeAttribute = use_node_attribute(flatData, props),
2749
- setNodeAttr = _useNodeAttribute.setNodeAttr,
2750
- checkNodeIsOpen = _useNodeAttribute.checkNodeIsOpen,
2751
- getNodeAttr = _useNodeAttribute.getNodeAttr,
2752
- getNodePath = _useNodeAttribute.getNodePath,
2753
- isRootNode = _useNodeAttribute.isRootNode,
2754
- isNodeOpened = _useNodeAttribute.isNodeOpened,
2755
- isNodeChecked = _useNodeAttribute.isNodeChecked,
2756
- isNodeMatched = _useNodeAttribute.isNodeMatched,
2757
- hasChildNode = _useNodeAttribute.hasChildNode;
2758
-
2759
- var _useSearch = use_search(props),
2760
- searchFn = _useSearch.searchFn,
2761
- isSearchActive = _useSearch.isSearchActive,
2762
- refSearch = _useSearch.refSearch,
2763
- openResultNode = _useSearch.openResultNode,
2764
- isTreeUI = _useSearch.isTreeUI,
2765
- isSearchDisabled = _useSearch.isSearchDisabled;
2766
-
2767
- if (!isSearchDisabled) {
2768
- (0,external_vue_.watch)([refSearch], function () {
2769
- flatData.data.forEach(function (item) {
2770
- var isMatch = searchFn(getLabel(item, props), item);
2771
- setNodeAttr(item, NODE_ATTRIBUTES.IS_MATCH, isMatch);
2772
-
2773
- if (openResultNode) {
2774
- setOpen(item, true, true);
2775
- }
2776
- });
2777
- });
2778
- }
2779
-
2780
- var filterFn = function filterFn(item) {
2781
- if (isSearchActive.value) {
2782
- var treeUiFilter = function treeUiFilter() {
2783
- return isTreeUI ? schemaValues.value.some(function (schema) {
2784
- var _a;
2785
-
2786
- return ((_a = schema[NODE_ATTRIBUTES.PATH]) === null || _a === void 0 ? void 0 : _a.startsWith(getNodePath(item))) && schema[NODE_ATTRIBUTES.IS_MATCH];
2787
- }) : false;
2788
- };
2789
-
2790
- return getNodeAttr(item, NODE_ATTRIBUTES.IS_MATCH) || treeUiFilter();
2791
- }
2792
-
2793
- return true;
2794
- }; // 计算当前需要渲染的节点信息
2795
-
2796
-
2797
- var renderData = (0,external_vue_.computed)(function () {
2798
- return flatData.data.filter(function (item) {
2799
- return checkNodeIsOpen(item) && filterFn(item);
2800
- });
2801
- });
2802
-
2803
- var _useNodeAction = use_node_action(props, ctx, flatData, renderData, schemaValues, {
2804
- registerNextLoop: registerNextLoop
2805
- }),
2806
- renderTreeNode = _useNodeAction.renderTreeNode,
2807
- handleTreeNodeClick = _useNodeAction.handleTreeNodeClick,
2808
- setNodeOpened = _useNodeAction.setNodeOpened,
2809
- setOpen = _useNodeAction.setOpen,
2810
- setNodeAction = _useNodeAction.setNodeAction,
2811
- setSelect = _useNodeAction.setSelect,
2812
- asyncNodeClick = _useNodeAction.asyncNodeClick;
2813
- /**
2814
- * 设置指定节点是否选中
2815
- * @param item Node item | Node Id
2816
- * @param checked
2817
- */
2818
-
2819
-
2820
- var setChecked = function setChecked(item) {
2821
- var checked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2822
- setNodeAction(resolveNodeItem(item), NODE_ATTRIBUTES.IS_CHECKED, checked);
2823
- };
2824
-
2825
- onSelected(function (newData) {
2826
- setSelect(newData, true, props.autoOpenParentNode);
2827
- });
2828
-
2829
- var getData = function getData() {
2830
- return flatData;
2831
- };
2832
-
2833
- ctx.expose({
2834
- handleTreeNodeClick: handleTreeNodeClick,
2835
- isNodeChecked: isNodeChecked,
2836
- isRootNode: isRootNode,
2837
- isNodeOpened: isNodeOpened,
2838
- isNodeMatched: isNodeMatched,
2839
- hasChildNode: hasChildNode,
2840
- setOpen: setOpen,
2841
- setChecked: setChecked,
2842
- setNodeAction: setNodeAction,
2843
- setNodeOpened: setNodeOpened,
2844
- setSelect: setSelect,
2845
- asyncNodeClick: asyncNodeClick,
2846
- getData: getData
2847
- });
2848
- var root = (0,external_vue_.ref)();
2849
-
2850
- var _useEmpty = use_empty(props, ctx),
2851
- renderEmpty = _useEmpty.renderEmpty;
2852
-
2853
- use_node_drag(props, ctx, root, flatData);
2854
-
2855
- var renderTreeContent = function renderTreeContent(scopedData) {
2856
- if (scopedData.length) {
2857
- return scopedData.map(renderTreeNode);
2858
- }
2859
-
2860
- var emptyType = isSearchActive.value ? 'search-empty' : 'empty';
2861
- return renderEmpty(emptyType);
2862
- };
2863
-
2864
- return function () {
2865
- return (0,external_vue_.createVNode)((external_virtual_render_default()), {
2866
- "class": (0,external_shared_.resolveClassName)('tree'),
2867
- "style": getTreeStyle(null, props),
2868
- "list": renderData.value,
2869
- "lineHeight": props.lineHeight,
2870
- "enabled": props.virtualRender,
2871
- "contentClassName": (0,external_shared_.resolveClassName)('container'),
2872
- "throttleDelay": 0,
2873
- "ref": root
2874
- }, {
2875
- "default": function _default(scoped) {
2876
- return renderTreeContent(scoped.data || []);
2877
- }
2878
- });
2879
- };
2880
- }
2881
- }));
2882
- ;// CONCATENATED MODULE: ../../packages/tree/src/index.ts
2883
- /*
2884
- * Tencent is pleased to support the open source community by making
2885
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
2886
- *
2887
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
2888
- *
2889
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
2890
- *
2891
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
2892
- *
2893
- * ---------------------------------------------------
2894
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
2895
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
2896
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
2897
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2898
- *
2899
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
2900
- * the Software.
2901
- *
2902
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
2903
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2904
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
2905
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2906
- * IN THE SOFTWARE.
2907
- */
2908
-
2909
-
2910
- var BkTree = (0,external_shared_.withInstall)(tree);
2911
- /* harmony default export */ const src = (BkTree);
2912
- })();
2913
-
2914
- /******/ return __webpack_exports__;
2915
- /******/ })()
2916
- ;
2917
- });
1
+ !function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n(require("../shared"),require("vue"),require("../virtual-render"),require("vue-types"),require("../exception"),require("../checkbox"),require("../icon"));else if("function"==typeof define&&define.amd)define(["../shared","vue","../virtual-render","vue-types","../exception","../checkbox","../icon"],n);else{var t="object"==typeof exports?n(require("../shared"),require("vue"),require("../virtual-render"),require("vue-types"),require("../exception"),require("../checkbox"),require("../icon")):n(e["../shared"],e.vue,e["../virtual-render"],e["vue-types"],e["../exception"],e["../checkbox"],e["../icon"]);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(self,((e,n,t,r,o,i,a)=>(()=>{var l={8022:(e,n,t)=>{var r=t(4481),o=t(6426),i=o;i.v1=r,i.v4=o,e.exports=i},8725:e=>{for(var n=[],t=0;t<256;++t)n[t]=(t+256).toString(16).substr(1);e.exports=function(e,t){var r=t||0,o=n;return[o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],"-",o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]],o[e[r++]]].join("")}},9157:e=>{var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var t=new Uint8Array(16);e.exports=function(){return n(t),t}}else{var r=new Array(16);e.exports=function(){for(var e,n=0;n<16;n++)0==(3&n)&&(e=4294967296*Math.random()),r[n]=e>>>((3&n)<<3)&255;return r}}},4481:(e,n,t)=>{var r,o,i=t(9157),a=t(8725),l=0,u=0;e.exports=function(e,n,t){var c=n&&t||0,s=n||[],d=(e=e||{}).node||r,f=void 0!==e.clockseq?e.clockseq:o;if(null==d||null==f){var p=i();null==d&&(d=r=[1|p[0],p[1],p[2],p[3],p[4],p[5]]),null==f&&(f=o=16383&(p[6]<<8|p[7]))}var v=void 0!==e.msecs?e.msecs:(new Date).getTime(),y=void 0!==e.nsecs?e.nsecs:u+1,N=v-l+(y-u)/1e4;if(N<0&&void 0===e.clockseq&&(f=f+1&16383),(N<0||v>l)&&void 0===e.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");l=v,u=y,o=f;var _=(1e4*(268435455&(v+=122192928e5))+y)%4294967296;s[c++]=_>>>24&255,s[c++]=_>>>16&255,s[c++]=_>>>8&255,s[c++]=255&_;var h=v/4294967296*1e4&268435455;s[c++]=h>>>8&255,s[c++]=255&h,s[c++]=h>>>24&15|16,s[c++]=h>>>16&255,s[c++]=f>>>8|128,s[c++]=255&f;for(var I=0;I<6;++I)s[c+I]=d[I];return n||a(s)}},6426:(e,n,t)=>{var r=t(9157),o=t(8725);e.exports=function(e,n,t){var i=n&&t||0;"string"==typeof e&&(n="binary"===e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||r)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,n)for(var l=0;l<16;++l)n[i+l]=a[l];return n||o(a)}},5800:e=>{"use strict";e.exports=i},9911:e=>{"use strict";e.exports=o},6870:e=>{"use strict";e.exports=a},4212:n=>{"use strict";n.exports=e},3511:e=>{"use strict";e.exports=t},748:e=>{"use strict";e.exports=n},210:e=>{"use strict";e.exports=r}},u={};function c(e){var n=u[e];if(void 0!==n)return n.exports;var t=u[e]={exports:{}};return l[e](t,t.exports,c),t.exports}c.n=e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return c.d(n,{a:n}),n},c.d=(e,n)=>{for(var t in n)c.o(n,t)&&!c.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},c.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};return(()=>{"use strict";c.r(s),c.d(s,{default:()=>X});var e,n,t,r=c(4212),o=c(748),i=c(3511),a=c.n(i);function l(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}!function(e){e.NODE_CLICK="nodeClick",e.NODE_COLLAPSE="nodeCollapse",e.NODE_EXPAND="nodeExpand",e.NODE_CHECKED="nodeChecked",e.NODE_DRAG_START="nodeDragStart",e.NODE_DRAG_OVER="nodeDragOver",e.NODE_DRAG_LEAVE="nodeDragLeave",e.NODE_DROP="nodeDrop"}(t||(t={}));var u,d=function(){return!0},f=(l(e={},t.NODE_CLICK,d),l(e,t.NODE_COLLAPSE,d),l(e,t.NODE_EXPAND,d),l(e,t.NODE_CHECKED,d),l(e,t.NODE_DRAG_START,d),l(e,t.NODE_DRAG_OVER,d),l(e,t.NODE_DRAG_LEAVE,d),l(e,t.NODE_DROP,d),e);!function(e){e.DEPTH="__depth",e.INDEX="__index",e.UUID="__uuid",e.PARENT_ID="__parent_id",e.HAS_CHILD="__has_child",e.PATH="__path",e.IS_ROOT="__is_root",e.ORDER="__order",e.IS_OPEN="__is_open",e.IS_CHECKED="__is_checked",e.IS_SELECTED="__is_selected",e.IS_ASYNC_INIT="__is_async_init",e.IS_MATCH="__is_match",e.IS_NULL="__IS_NULL",e.IS_CACHED="__is_cached",e.IS_ASYNC="__is_async",e.IS_LOADING="__is_loading",e.TREE_NODE_ATTR="__attr__"}(u||(u={}));var p,v=(l(n={},u.IS_OPEN,"isOpen"),l(n,u.IS_SELECTED,"selected"),l(n,u.IS_MATCH,"isMatch"),l(n,u.HAS_CHILD,"hasChild"),l(n,u.IS_CHECKED,"checked"),l(n,u.IS_ASYNC,"async"),l(n,u.IS_LOADING,"loading"),l(n,u.IS_ROOT,"isRoot"),n);!function(e){e.CLICK="click",e.SELECTED="selected",e.EXPAND="expand",e.COLLAPSE="collapse"}(p||(p={}));var y,N,_,h=c(210);!function(e){e.ONCE="once",e.EVERY="every"}(y||(y={})),function(e){e.FUZZY="fuzzy",e.FULL="full"}(N||(N={})),function(e){e.TREE="tree",e.LIST="list"}(_||(_={}));var I={data:r.PropTypes.arrayOf(r.PropTypes.any).def([]),label:r.PropTypes.oneOfType([r.PropTypes.func.def(void 0),r.PropTypes.string.def("label")]),nodeKey:r.PropTypes.string.def(void 0),children:r.PropTypes.string.def("children"),indent:r.PropTypes.number.def(18),lineHeight:r.PropTypes.number.def(32),levelLine:r.PropTypes.oneOfType([r.PropTypes.bool.def(!1),r.PropTypes.func.def(void 0),r.PropTypes.string.def("1px dashed #c3cdd7")]).def(!1),virtualRender:r.PropTypes.bool.def(!1),prefixIcon:r.PropTypes.oneOfType([r.PropTypes.func.def((function(){})),r.PropTypes.bool.def(!1)]).def(!0),async:r.PropTypes.shape({callback:r.PropTypes.func.def(void 0),cache:r.PropTypes.bool.def(!0),deepAutoOpen:(0,h.toType)("columnType",{}).def(y.ONCE)}),offsetLeft:r.PropTypes.number.def(5),search:r.PropTypes.oneOfType([r.PropTypes.shape({value:r.PropTypes.oneOfType([r.PropTypes.number,r.PropTypes.string,r.PropTypes.bool]).def(""),match:r.PropTypes.oneOfType([(0,h.toType)("TreeSearchMatchType",{}).def(N.FUZZY),r.PropTypes.func]),resultType:(0,h.toType)("treeSearchResultType",{}).def(_.TREE),openResultNode:r.PropTypes.bool}),r.PropTypes.string,r.PropTypes.number,r.PropTypes.bool]).def(void 0),emptyText:r.PropTypes.string.def("没有数据"),draggable:r.PropTypes.bool.def(!1),disableDrag:r.PropTypes.func.def(null),disableDrop:r.PropTypes.func.def(null),dragSort:r.PropTypes.bool.def(!1),selectable:r.PropTypes.oneOfType([r.PropTypes.bool,r.PropTypes.func]).def(!0),disabledFolderSelectable:r.PropTypes.bool.def(!1),showCheckbox:r.PropTypes.bool.def(!1),showNodeTypeIcon:r.PropTypes.bool.def(!0),selected:r.PropTypes.oneOfType([r.PropTypes.string,null,r.PropTypes.number,r.PropTypes.object]).def(null),autoCheckChildren:r.PropTypes.bool.def(!0),autoOpenParentNode:r.PropTypes.bool.def(!0),expandAll:r.PropTypes.bool.def(!1),nodeContentAction:r.PropTypes.oneOfType([r.PropTypes.arrayOf((0,h.toType)("nodeContentActionType",{}).def(p.CLICK)),r.PropTypes.func.def((function(){return["selected"]}))]).def(["selected","expand","click"])},E=c(9911),S=c.n(E);function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}var g=c(5800),T=c.n(g),A=c(6870);const C=function(e,n){var t=function(n){return e.schema.get(n)},r=function(e,n){var r;return null===(r=t(e[u.UUID]))||void 0===r?void 0:r[n]},o=function(n,r,o){e.schema.set(n[u.UUID],Object.assign(Object.assign({},t(n[u.UUID])),l({},r,o)))},i=function(e){return r(e,u.PATH)},a=function(e){return r(e,u.UUID)},c=function(e){return r(e,u.IS_ROOT)},s=function(e){return r(e,u.IS_OPEN)},d=function(e){return r(e,u.HAS_CHILD)},f=function(e){return r(e,u.IS_MATCH)},p=function(e){return r(e,u.IS_CHECKED)},y=function(e){return r(e,u.PARENT_ID)},N=function(e){return r(l({},u.UUID,e),u.PARENT_ID)},_=function(e){var n;return"object"===D(e)?s(e):"string"==typeof e&&(null===(n=t(e))||void 0===n?void 0:n[u.IS_OPEN])},h=function(e){return e.split("-").reduce((function(e,t){var r=Number(t);return Array.isArray(e)?e[r]:e[n.children][r]}),n.data)},I=function(e){return h(i(l({},u.UUID,e)))},E=function(e){var n;return l(n={},v[u.IS_LOADING],r(e,u.IS_LOADING)),l(n,v[u.HAS_CHILD],d(e)),l(n,v[u.IS_MATCH],f(e)),l(n,v[u.IS_CHECKED],p(e)),l(n,v[u.IS_OPEN],s(e)),l(n,v[u.IS_ROOT],c(e)),l(n,"fullPath",r(e,u.PATH)),l(n,"uuid",a(e)),l(n,"parentId",r(e,u.PARENT_ID)),n};return{getSchemaVal:t,getNodeAttr:r,getNodeId:a,getNodeParentId:y,getNodeParentIdById:N,getParentNodeData:function(e){return c(l({},u.UUID,e))?l({},n.children,n.data):I(N(e))},getParentNode:function(e){return t(y(e))},setNodeAttr:o,getNodePath:i,isRootNode:c,isNodeOpened:s,hasChildNode:d,isItemOpen:_,isNodeChecked:p,isNodeMatched:f,isNodeLoading:function(e){return r(e,u.IS_LOADING)},checkNodeIsOpen:function(e){return c(e)||function(e){return _(r(e,u.PARENT_ID))}(e)},getSourceNodeByPath:h,getSourceNodeByUID:I,deleteNodeSchema:function(n){return e.schema.delete(n)},resolveScopedSlotParam:E,setTreeNodeLoading:function(e,n){o(e,u.IS_LOADING,n)},extendNodeAttr:function(e){return Object.assign(Object.assign({},e),l({},u.TREE_NODE_ATTR,E(e)))},getChildNodes:function(n){var t=e.schema;return Array.prototype.filter.call(Array.from(t.keys()),(function(e){return t.get(e)[u.PARENT_ID]===n[u.UUID]}))}}};function m(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function O(e){return function(e){if(Array.isArray(e))return m(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(e){if("string"==typeof e)return m(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var b=void 0,P="1px dashed #c3cdd7",L=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[],a=e[n];return"boolean"==typeof a?a?r:o:U(t,e,n,i)},U=function(e,n,t){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=n[t];if("string"==typeof o)return"object"===D(e)&&null!==e?(Object.prototype.hasOwnProperty.call(e,o)||console.error("cannot find node label with key ".concat(o)),e[o]):o;if("function"==typeof o){var i=o.apply(b,[e].concat(O(r)));return"string"==typeof i?i:void console.error("props label with function return value is not string, please check and return string")}},x=function(e,n){return U(e,n,"label")},R=function(e,n){return e.get(n)||{}},k=function(e,n,t){var r;return null===(r=R(e,n))||void 0===r?void 0:r[t]},H=function(e,n){return{"--level-line":L(n,"levelLine",e,P,null,["tree"]),"--lineHeight":"".concat(n.lineHeight,"px"),"--indent":"".concat(n.indent,"px"),"--offset-left":"".concat(n.offsetLeft,"px")}},w=function(e,n){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=t.schema,o=k(r,e[u.UUID],u.DEPTH);return Object.assign({"--depth":o},"function"==typeof n.levelLine?{"--level-line":L(n,"levelLine",e,P,null,["node"])}:{})},j=function(e,n,t){var r=R(n,e[u.UUID])||{};return{"is-root":r.__is_root,"bk-tree-node":!0,"is-open":r.__is_open,"is-virtual-render":t.virtualRender,"level-line":t.levelLine}},V=function(e,n){var t=R(n,e[u.UUID])||{};return l({"is-checked":t.__is_checked,"is-selected":t.__is_selected,"node-folder":e.is_folder,"node-leaf":e.is_leaf},(0,r.resolveClassName)("node-row"),!0)},M=function(e){return null==e?{__IS_NULL:!0}:"string"==typeof e||"number"==typeof e||"symbol"===D(e)?l({},u.UUID,e):(Object.prototype.hasOwnProperty.call(e,u.UUID)||console.error("setNodeAction Error: node id cannot found"),e)};const K=function(e,n){var t=C(n,e),r=t.setNodeAttr,o=t.getNodePath,i=t.getNodeAttr,a=t.resolveScopedSlotParam,c=t.setTreeNodeLoading,s=function(n,t){if("object"===D(n)&&null!==n){r(t,u.IS_OPEN,!0);var i=Array.isArray(n)?n:[n];return function(e,n,t,r,o){!function(e,n,t,r){var o=e.split("-").reduce((function(e,n){var r=Number(n);return Array.isArray(e)?e[r]:e[t][r]}),n);Object.assign(o,r||{})}(e,n,t,l({},r,o))}(o(t),e.data,e.children,e.children,i),Promise.resolve(n)}return Promise.resolve(n)},d=function(n){var t=e.async||{},o=t.callback,l=void 0===o?null:o,d=t.cache,f=void 0===d||d;if("function"==typeof l&&i(n,u.IS_ASYNC)){if(r(n,u.IS_ASYNC_INIT,!0),!i(n,u.IS_CACHED)){r(n,u.IS_CACHED,f);var p=a(n),v=l(n,(function(e){return s(e,n)}),p);if("object"===D(v)&&null!==v)return c(n,!0),v instanceof Promise?Promise.resolve(v.then((function(e){return s(e,n)})).catch((function(e){return console.error("load remote data error:",e)})).finally((function(){c(n,!1),r(n,u.IS_CACHED,!0)}))):(s(v,n),c(n,!1),Promise.resolve(!0))}return Promise.resolve(!0)}return Promise.resolve(!0)};return{asyncNodeClick:d,deepAutoOpen:function e(){var t=n.data.filter((function(e){return i(e,u.IS_ASYNC)&&e[v[u.IS_OPEN]]&&!i(e,u.IS_ASYNC_INIT)}));t.length&&Promise.all(t.map((function(e){return d(e)}))).then((function(){e()})).catch((function(e){console.warn(e)}))}}},G=function(e,n,i,a,c,s){var d=e.selected,f=C(i,e),p=f.setNodeAttr,v=f.getNodePath,y=f.getSchemaVal,N=f.getNodeAttr,_=f.getNodeId,h=f.getChildNodes,I=f.isRootNode,E=f.hasChildNode,S=f.isItemOpen,g=f.isNodeOpened,m=f.isNodeLoading,O=f.isNodeChecked,b=f.getParentNode,P=f.resolveScopedSlotParam,L=f.extendNodeAttr,U=s.registerNextLoop,R=K(e,i),k=R.asyncNodeClick,H=R.deepAutoOpen,G=function(e){if("string"==typeof e)return e;if("object"===D(e)&&null!==e){if(e.__v_isVNode)return e;var n=e.node,t=e.className,r=e.text,i=e.style;return(0,o.h)(n,{class:t,style:i},r)}return null},q=function(t){if(n.slots.nodeAction)return n.slots.nodeAction(L(t));var i=null;return m(t)?function(e){var t,r,i;return(null!==(i=null===(r=(t=n.slots).nodeLoading)||void 0===r?void 0:r.call(t,L(e)))&&void 0!==i?i:m(e))?(0,o.createVNode)(A.Spinner,null,null):""}(t):"function"==typeof e.prefixIcon&&"default"!==(i=e.prefixIcon(L(t),"node_action"))?G(i):("default"===i||"boolean"==typeof e.prefixIcon&&e.prefixIcon)&&(E(t)||t.async||!e.autoCheckChildren)?S(t)?(0,o.createVNode)(A.DownShape,{class:(0,r.resolveClassName)("node-prefix")},null):(0,o.createVNode)(A.RightShape,{class:(0,r.resolveClassName)("node-prefix")},null):null},Y=function(t){if(!e.showNodeTypeIcon)return null;if(n.slots.nodeType)return n.slots.nodeType(L(t));var i=null;return"function"==typeof e.prefixIcon&&"default"!==(i=e.prefixIcon(L(t),"node_type"))?G(i):"default"===i||"boolean"==typeof e.prefixIcon&&e.prefixIcon?I(t)||E(t)?function(e){return S(e)?(0,o.createVNode)(A.FolderShapeOpen,{class:[(0,r.resolveClassName)("tree-icon"),(0,r.resolveClassName)("node-prefix")]},null):(0,o.createVNode)(A.Folder,{class:[(0,r.resolveClassName)("tree-icon"),(0,r.resolveClassName)("node-prefix")]},null)}(t):(0,o.createVNode)(A.TextFile,{class:[(0,r.resolveClassName)("tree-icon"),(0,r.resolveClassName)("node-prefix")]},null):null},F=function e(n,t){var r=b(n);r&&(p(r,u.IS_CHECKED,t),I(r)||e(r,t))},X=function e(n,t,r){h(n).forEach((function(n){p(l({},u.UUID,n),t,r),e(l({},u.UUID,n),t,r)}))},z=function(e,r){p(e,u.IS_CHECKED,!!r),X(e,u.IS_CHECKED,!!r),F(e,r),n.emit(t.NODE_CHECKED,c.value.filter((function(e){return O(e)})).map((function(e){return e[u.UUID]})))},J=function(e){return O(e)&&!c.value.filter((function(n){var t;return null===(t=v(n))||void 0===t?void 0:t.startsWith(v(e))})).every((function(e){return O(e)}))},B=function(e){return O(e)||c.value.filter((function(n){var t;return null===(t=v(n))||void 0===t?void 0:t.startsWith(v(e))})).some((function(e){return O(e)}))},W=function(n){return e.showCheckbox?(0,o.createVNode)(T(),{size:"small",modelValue:B(n),indeterminate:J(n),onChange:function(e){return z(n,e)}},null):null},Z=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],a=null===r?!S(e):!!r;if(a||X(e,u.IS_OPEN,a),p(e,u.IS_OPEN,a),i){var l=S(e)?t.NODE_EXPAND:t.NODE_COLLAPSE;n.emit(l,e,P(e),y(e[u.UUID]),o)}},$=function(e,n,t){Array.isArray(e)?e.forEach((function(e){return p(M(e),n,t)})):p(M(e),n,t)},Q=function e(n){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=M(n);if(!o[u.IS_NULL])if(r)if(t){if($(o,u.IS_OPEN,!0),!I(o)){var i=N(o,u.PARENT_ID);e(i,!0,!0)}}else Z(o,!1,null,!1);else $(o,u.IS_OPEN,t)},ee=function(e,n){g(e)?Z(e,!1,n):k(e).finally((function(){N(e,u.IS_LOADING)?U("setNodeOpenedAfterLoading",{type:"once",fn:function(){return Z(e,!0,n)}}):Z(e,!0,n)}))},ne=function n(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=Array.isArray(t)?t:[t];if(a.length){var c=M(a[0]);c[u.IS_NULL]||(!e.selectable||"function"==typeof e.selectable&&!e.selectable(t)||e.disabledFolderSelectable&&!0===(null==t?void 0:t.is_folder)?console.warn("props.selectable is false or undefined, please set selectable with true"):(null!=d&&p(l({},u.UUID,d),u.IS_SELECTED,!r),e.selected&&e.selected!==d&&p(l({},u.UUID,e.selected),u.IS_SELECTED,!r),p(c,u.IS_SELECTED,r),d=_(c),i&&1===a.length&&Q(c,!0,!0),N(c,u.IS_ASYNC)&&k(c).then((function(){(0,o.nextTick)((function(){a.shift(),n(a,r,i)}))}))))}},te=function(n){if(!e.levelLine)return null;var t=N(n,u.DEPTH)+1;return new Array(t).fill("").map((function(e,n){return n})).filter((function(e){return function(e,n){if(I(n))return!1;var t=v(n),r="".concat(t).split("-").slice(0,e+1);if(r.join("-")===t)return!0;var o=r.pop(),i=parseInt(o,10);r.push("".concat(i+1));var a=r.join("-");return c.value.some((function(e){return e[u.PATH]===a}))}(e,n)})).filter((function(e){return e>0})).map((function(e){return(0,o.createVNode)("span",{class:"node-virtual-line",style:(n=t-e,{"--depth":n})},null);var n}))};return{renderTreeNode:function(a){var l,c,s,d,f;return(0,o.createVNode)("div",{"data-tree-node":_(a),key:_(a),class:V(a,i.schema)},[(0,o.createVNode)("div",{class:j(a,i.schema,e),style:w(a,e,i),onClick:function(r){return function(r,o){var i,a=(i=r,"function"==typeof e.nodeContentAction?Reflect.apply(e.nodeContentAction,void 0,[{node:i}]):"string"==typeof e.nodeContentAction?[e.nodeContentAction]:Array.isArray(e.nodeContentAction)?e.nodeContentAction:["selected","expand","click"]);if(a.includes("selected")&&ne(r,!0,!1),a.includes("expand")&&(g(r)||ee(r,o)),a.includes("collapse")&&g(r)&&ee(r,o),a.includes("click")){var l=t.NODE_CLICK;n.emit(l,r,P(r),y(r[u.UUID]),o)}}(a,r)}},[(0,o.createVNode)("div",{class:[(0,r.resolveClassName)("node-action")],onClick:function(e){return function(e,n){e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),ee(n,e)}(e,a)}},[q(a)]),(0,o.createVNode)("div",{class:(0,r.resolveClassName)("node-content")},[[W(a),Y(a)],(0,o.createVNode)("span",{class:(0,r.resolveClassName)("node-text")},[null!==(s=null===(c=(l=n.slots).node)||void 0===c?void 0:c.call(l,L(a)))&&void 0!==s?s:[x(a,e)]]),null===(f=(d=n.slots).nodeAppend)||void 0===f?void 0:f.call(d,L(a))]),te(a)])])},handleTreeNodeClick:ee,deepAutoOpen:H,asyncNodeClick:k,setNodeAction:$,setNodeOpened:Z,setSelect:ne,setOpen:Q}};var q=c(8022),Y=void 0;const F=(0,o.defineComponent)({name:"Tree",props:I,emits:f,setup:function(e,n){var i=function(e){var n,t=function(e){var n,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=e.data,i=e.children,a=[],c=[],s=0,d=new Map;function f(e,n,t,r){if(null!=e&&d.has(e)&&![u.UUID,u.PARENT_ID].includes(n)){var o=d.get(e);Object.prototype.hasOwnProperty.call(o,n)&&"function"==typeof r&&Reflect.apply(r,self,[o,n,t])&&(Object.assign(o,l({},n,t)),f(o[u.PARENT_ID],n,t,r))}}function p(n){var t=null;return"string"==typeof e.nodeKey&&(t=n[e.nodeKey]||(0,q.v4)()),t||n[u.UUID]||(0,q.v4)()}var y=(l(n={},u.IS_OPEN,(function(){return!!e.expandAll})),l(n,u.IS_CHECKED,(function(){return!1})),l(n,u.IS_MATCH,(function(){return!0})),l(n,u.IS_SELECTED,(function(n){return e.selected===n})),l(n,u.IS_CACHED,(function(){return!1})),l(n,u.IS_ASYNC,(function(){return null})),l(n,u.IS_LOADING,(function(){return!1})),n);function N(e,n,t){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:void 0,i=o;void 0===o&&"function"==typeof y[t]&&(i=y[t](e,n));var a=v[t];if(Object.prototype.hasOwnProperty.call(n,a))return n[a];var l=(r||[]).find((function(n){return n[u.UUID]===e})),c=void 0;return l&&(c=l[t]),null==c&&(c=i),c}function _(n,t){return!!e.selectable&&N(n,t,u.IS_SELECTED,e.selected===n)}function h(e,n,t){var r,o=N(e,n,u.IS_OPEN),i=!d.has(t)||(null===(r=d.get(t))||void 0===r?void 0:r[u.IS_OPEN]);return o&&i}function I(e){return!e[u.IS_OPEN]}function E(n){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,v=n.length,y=0;y<v;y++){var S=n[y];if(Array.isArray(S))E(S,t,r,o);else if("object"===D(S)&&null!==S){var g,T,A=null!==o?"".concat(o,"-").concat(y):"".concat(y),C="".concat(p(S)),m=!!(S[i]||[]).length,O=N(C,S,u.IS_OPEN);e.autoOpenParentNode?O&&f(r,u.IS_OPEN,!0,I):O=h(C,S,r),Object.assign(S,l({},u.UUID,C));var b=e.showCheckbox&&N(C,S,u.IS_CHECKED);b&&a.push(C),d.set(C,(l(g={},u.DEPTH,t),l(g,u.INDEX,y),l(g,u.UUID,C),l(g,u.PARENT_ID,r),l(g,u.HAS_CHILD,m),l(g,u.PATH,A),l(g,u.IS_ROOT,null===r),l(g,u.ORDER,s),l(g,u.IS_SELECTED,_(C,S)),l(g,u.IS_MATCH,N(C,S,u.IS_MATCH)),l(g,u.IS_OPEN,O),l(g,u.IS_CHECKED,b),l(g,u.IS_CACHED,N(C,S,u.IS_CACHED)),l(g,u.IS_ASYNC,N(C,S,u.IS_ASYNC)),l(g,u.IS_LOADING,N(C,S,u.IS_LOADING)),l(g,i,null),g)),s+=1,c.push(Object.assign(Object.assign({},JSON.parse(JSON.stringify(S,(function(n,t){return n===e.children?null:t})))),(l(T={},u.IS_OPEN,O),l(T,i,null),T))),Object.prototype.hasOwnProperty.call(S,i)&&E(S[i]||[],t+1,C,A)}}}return E(t||o),e.showCheckbox&&(null==a||a.forEach((function(e){Array.from(d.values()).filter((function(n){var t;return null===(t=n[u.PATH])||void 0===t?void 0:t.startsWith(d.get(e)[u.PATH])})).forEach((function(e){return Object.assign(e,l({},u.IS_CHECKED,!0))})),f(e,u.IS_CHECKED,!0,(function(){return!0}))}))),[c,d]},r=t(e),i=new Map,a=[],c=[],s=(0,o.reactive)({data:r[0],schema:r[1],levelLineSchema:{}}),d=(0,o.computed)((function(){return Array.from(s.schema.values())})),f=K(e,s),p=f.asyncNodeClick,y=f.deepAutoOpen,N=function(e,n){(!(arguments.length>2&&void 0!==arguments[2])||arguments[2])&&i.has(e)&&i.delete(e),i.set(e,n)},_=function(e){var n,t=function(e){return"function"==typeof e?{type:"loop",fn:e}:"object"===D(e)&&"string"==typeof e.type&&"function"==typeof e.fn?e:(console.error("loop event error",e),null)}(e);return null!==t&&Reflect.apply(t.fn,Y,[]),null!==(n=null==t?void 0:t.type)&&void 0!==n?n:"once"};return(0,o.watch)((function(){return[e.data]}),(function(n){var r,o,a=t(e,n,d.value);s.data=a[0],s.schema=a[1],(null===(r=e.async)||void 0===r?void 0:r.callback)&&"every"===(null===(o=e.async)||void 0===o?void 0:o.deepAutoOpen)&&y(),Array.from(i.keys()).forEach((function(e){var n=i.get(e);if(Array.isArray(n)){var t=[];n.forEach((function(e,n){"once"===_(e)&&t.unshift(n)})),t.length&&t.forEach((function(e){return n.splice(e,1)})),0===n.length&&i.delete(e)}else"once"===_(n)&&i.delete(e)}))}),{deep:!0}),e.selectable&&(0,o.onMounted)((function(){(0,o.watch)((function(){return e.selected}),(function(e){c.length=0,a.forEach((function(n){Reflect.apply(n,Y,[e]),c.push((function(){return Reflect.apply(n,Y,[e])}))})),N("afterSelectWatch",c)}),{immediate:!0})})),(null===(n=e.async)||void 0===n?void 0:n.callback)&&y(),{flatData:s,schemaValues:d,asyncNodeClick:p,deepAutoOpen:y,afterDataUpdate:function(e){N("afterDataUpdate",e)},registerNextLoop:N,onSelected:function(e){a.push(e)}}}(e),c=i.flatData,s=i.schemaValues,d=i.onSelected,f=i.registerNextLoop,p=C(c,e),y=p.setNodeAttr,N=p.checkNodeIsOpen,_=p.getNodeAttr,h=p.getNodePath,I=p.isRootNode,E=p.isNodeOpened,g=p.isNodeChecked,T=p.isNodeMatched,A=p.hasChildNode,m=function(e){var n,t=(0,o.toRef)(e,"search"),r=null!==(n=e.search)&&void 0!==n?n:{},i=r.openResultNode,a=void 0!==i&&i,l=r.resultType,u=void 0===l?"tree":l,c=function(e){return["string","number","boolean"].includes(D(e))},s=function(e,n){return e===n},d=function(e,n){return new RegExp("".concat(e),"i").test("".concat(n))},f=function(e,n){return Reflect.apply(e,void 0,n)},p=void 0===t.value||!1===t.value,v=(0,o.computed)((function(){return!1!==t.value&&(c(t.value)?"".concat(t.value).length>0:"object"===D(t.value))}));return{searchFn:function(e,n){if(p)return!0;if(c(t.value))return f(d,[t.value,e,n]);var r=t.value,o=r.value,i=void 0===o?"":o,a=r.match,l=void 0===a?"fuzzy":a,u="function"==typeof l?l:"fuzzy"===l?d:s;return 0==="".concat(i).length||f(u,[i,e,n])},refSearch:t,isSearchActive:v,isSearchDisabled:p,openResultNode:a,resultType:u,isTreeUI:"tree"===u}}(e),O=m.searchFn,b=m.isSearchActive,P=m.refSearch,L=m.openResultNode,U=m.isTreeUI;m.isSearchDisabled||(0,o.watch)([P],(function(){c.data.forEach((function(n){var t=O(x(n,e),n);y(n,u.IS_MATCH,t),L&&F(n,!0,!0)}))}));var R=(0,o.computed)((function(){return c.data.filter((function(e){return N(e)&&function(e){return!b.value||(_(e,u.IS_MATCH)||!!U&&s.value.some((function(n){var t;return(null===(t=n[u.PATH])||void 0===t?void 0:t.startsWith(h(e)))&&n[u.IS_MATCH]})))}(e)}))})),k=G(e,n,c,0,s,{registerNextLoop:f}),w=k.renderTreeNode,j=k.handleTreeNodeClick,V=k.setNodeOpened,F=k.setOpen,X=k.setNodeAction,z=k.setSelect,J=k.asyncNodeClick;d((function(n){z(n,!0,e.autoOpenParentNode)})),n.expose({handleTreeNodeClick:j,isNodeChecked:g,isRootNode:I,isNodeOpened:E,isNodeMatched:T,hasChildNode:A,setOpen:F,setChecked:function(e){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];X(M(e),u.IS_CHECKED,n)},setNodeAction:X,setNodeOpened:V,setSelect:z,asyncNodeClick:J,getData:function(){return c}});var B=(0,o.ref)(),W=function(e,n){var t=n.slots;return{renderEmpty:function(n){var r,i;return(0,o.createVNode)(S(),{scene:"part",type:n},{default:function(){return[null!==(i=null===(r=t.default)||void 0===r?void 0:r.call(t))&&void 0!==i?i:e.emptyText]}})}}}(e,n),Z=W.renderEmpty;return function(e,n,r,i){var a=C(i,e),c=a.getSourceNodeByUID,s=a.getNodeParentIdById,d=a.getParentNodeData,f=a.getNodeAttr,p=a.getNodePath,v=a.isRootNode,y=(0,o.computed)((function(){return"function"==typeof e.disableDrag})),N=(0,o.computed)((function(){return"function"==typeof e.disableDrop})),_=function(e){return e.target.closest("[data-tree-node]")},h=function(e){var n,t=null===(n=null==e?void 0:e.dataset)||void 0===n?void 0:n.treeNode;return c(t)},I=function e(n){_(n).removeEventListener("mouseup",e)},E=function(n){var t=_(n),r=h(t);!1===r.draggable||y.value&&e.disableDrag(r)?t.classList.add("bk-tree-drag-disabled"):(t.setAttribute("draggable","true"),t.addEventListener("mouseup",I))},S=function(r){r.preventDefault();var o=_(r),i=h(o);if(n.emit(t.NODE_DRAG_OVER,r,o,i),N.value&&(null==e?void 0:e.disableDrop(i)))return r.dataTransfer.effectAllowed="move",r.dataTransfer.dropEffect="none",void o.classList.add("bk-tree-drop-disabled");o.classList.add("bk-tree-drop-active");var a=r.dataTransfer.getData("node-id"),l=o.getAttribute("data-tree-node"),u=T(a,l)?"move":"none";r.dataTransfer.effectAllowed=u,r.dataTransfer.dropEffect=u},D=function(e){e.dataTransfer.effectAllowed="move",e.dataTransfer.dropEffect="move";var r=_(e);e.dataTransfer.setData("text/plain",""),e.dataTransfer.setData("node-id",r.getAttribute("data-tree-node")),n.emit(t.NODE_DRAG_START,e,r)},g=function(r){r.preventDefault(),r.stopPropagation();var o=_(r);o.classList.remove("bk-tree-drop-active","bk-tree-drop-disabled");var i=h(o);if(!N.value||!e.disableDrop(i)){var a=r.dataTransfer.getData("node-id"),l=o.getAttribute("data-tree-node");Reflect.apply(e.dragSort?A:m,void 0,[a,l]),n.emit(t.NODE_DROP,r,o,i)}},T=function(e,n){var t=p(l({},u.UUID,e)),r=p(l({},u.UUID,n));return s(e)===s(n)||-1===t.indexOf(r)&&-1===r.indexOf(t)},A=function(n,t){if(T(n,t)){var r=JSON.parse(JSON.stringify(c(n))),o=JSON.parse(JSON.stringify(c(t))),i=d(n),a=d(t),s=f(l({},u.UUID,n),u.INDEX),p=f(l({},u.UUID,t),u.INDEX);null==i||i[e.children].splice(s,1,o),null==a||a[e.children].splice(p,1,r)}},m=function(n,t){var r=c(n),o=c(t),i=null;if(v(l({},u.UUID,n)))i=e.data;else{var a=s(n);if(null!=a){i=c(a);var d=f(l({},u.UUID,n),u.INDEX);null==i||i[e.children].splice(d,1)}}o[e.children]||(o[e.children]=[]),o[e.children].unshift(r)},O=function(e){e.preventDefault();var r=_(e);r.classList.remove("bk-tree-drop-active","bk-tree-drop-disabled"),n.emit(t.NODE_DRAG_LEAVE,e,r)};(0,o.onMounted)((function(){if(e.draggable&&r.value){var n=r.value.$el;n.addEventListener("mousedown",E),n.addEventListener("dragstart",D),n.addEventListener("dragover",S),n.addEventListener("dragleave",O),n.addEventListener("drop",g)}})),(0,o.onUnmounted)((function(){if(e.draggable&&r.value){var n=r.value.$el;n.removeEventListener("mousedown",E),n.removeEventListener("dragstart",D),n.removeEventListener("dragover",S),n.removeEventListener("dragleave",O),n.removeEventListener("drop",g)}}))}(e,n,B,c),function(){return(0,o.createVNode)(a(),{class:(0,r.resolveClassName)("tree"),style:H(null,e),list:R.value,lineHeight:e.lineHeight,enabled:e.virtualRender,contentClassName:(0,r.resolveClassName)("container"),throttleDelay:0,ref:B},{default:function(e){return function(e){if(e.length)return e.map(w);var n=b.value?"search-empty":"empty";return Z(n)}(e.data||[])}})}}}),X=(0,r.withInstall)(F)})(),s})()));