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

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 (155) hide show
  1. package/dist/index.cjs.js +36 -36
  2. package/dist/index.esm.js +33 -3
  3. package/dist/index.umd.js +35 -35
  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/index.js +1 -274
  11. package/lib/breadcrumb/index.js +1 -329
  12. package/lib/button/index.js +1 -371
  13. package/lib/card/index.js +1 -326
  14. package/lib/cascader/index.js +1 -2168
  15. package/lib/checkbox/index.js +1 -571
  16. package/lib/code-diff/index.js +1 -5520
  17. package/lib/collapse/index.js +1 -698
  18. package/lib/color-picker/index.js +1 -2816
  19. package/lib/components.js +1 -759
  20. package/lib/container/index.js +1 -369
  21. package/lib/date-picker/index.js +1 -5601
  22. package/lib/dialog/index.js +1 -545
  23. package/lib/directives/index.js +2 -1427
  24. package/lib/directives/index.js.LICENSE.txt +14 -0
  25. package/lib/dist.index.js +1 -166
  26. package/lib/divider/index.js +1 -512
  27. package/lib/dropdown/index.js +1 -414
  28. package/lib/exception/index.js +1 -405
  29. package/lib/fixed-navbar/index.js +1 -214
  30. package/lib/form/index.js +1 -986
  31. package/lib/icon/angle-double-down-line.js +1 -426
  32. package/lib/icon/angle-double-left-line.js +1 -426
  33. package/lib/icon/angle-double-left.js +1 -426
  34. package/lib/icon/angle-double-right-line.js +1 -426
  35. package/lib/icon/angle-double-right.js +1 -426
  36. package/lib/icon/angle-double-up-line.js +1 -426
  37. package/lib/icon/angle-down-fill.js +1 -426
  38. package/lib/icon/angle-down-line.js +1 -426
  39. package/lib/icon/angle-down.js +1 -426
  40. package/lib/icon/angle-left.js +1 -426
  41. package/lib/icon/angle-right.js +1 -426
  42. package/lib/icon/angle-up-fill.js +1 -426
  43. package/lib/icon/angle-up.js +1 -426
  44. package/lib/icon/archive-fill.js +1 -426
  45. package/lib/icon/arrows-left.js +1 -426
  46. package/lib/icon/arrows-right.js +1 -426
  47. package/lib/icon/audio-fill.js +1 -426
  48. package/lib/icon/bk.js +1 -426
  49. package/lib/icon/circle.js +1 -426
  50. package/lib/icon/close-line.js +1 -426
  51. package/lib/icon/close.js +1 -426
  52. package/lib/icon/code.js +1 -426
  53. package/lib/icon/cog-shape.js +1 -426
  54. package/lib/icon/collapse-left.js +1 -426
  55. package/lib/icon/copy.js +1 -426
  56. package/lib/icon/data-shape.js +1 -426
  57. package/lib/icon/del.js +1 -426
  58. package/lib/icon/doc-fill.js +1 -426
  59. package/lib/icon/done.js +1 -426
  60. package/lib/icon/down-shape.js +1 -426
  61. package/lib/icon/down-small.js +1 -426
  62. package/lib/icon/edit-line.js +1 -426
  63. package/lib/icon/ellipsis.js +1 -426
  64. package/lib/icon/enlarge-line.js +1 -426
  65. package/lib/icon/error.js +1 -426
  66. package/lib/icon/excel-fill.js +1 -426
  67. package/lib/icon/exclamation-circle-shape.js +1 -426
  68. package/lib/icon/eye.js +1 -426
  69. package/lib/icon/filliscreen-line.js +1 -426
  70. package/lib/icon/folder-open.js +1 -426
  71. package/lib/icon/folder-shape-open.js +1 -426
  72. package/lib/icon/folder-shape.js +1 -426
  73. package/lib/icon/folder.js +1 -426
  74. package/lib/icon/funnel.js +1 -426
  75. package/lib/icon/help-document-fill.js +1 -426
  76. package/lib/icon/help-fill.js +1 -426
  77. package/lib/icon/help.js +1 -426
  78. package/lib/icon/image-fill.js +1 -426
  79. package/lib/icon/img-placehoulder.js +1 -448
  80. package/lib/icon/index.js +1 -2275
  81. package/lib/icon/info-line.js +1 -448
  82. package/lib/icon/info.js +1 -448
  83. package/lib/icon/left-shape.js +1 -448
  84. package/lib/icon/left-turn-line.js +1 -448
  85. package/lib/icon/narrow-line.js +1 -448
  86. package/lib/icon/original.js +1 -448
  87. package/lib/icon/pdf-fill.js +1 -448
  88. package/lib/icon/play-shape.js +1 -448
  89. package/lib/icon/plus.js +1 -448
  90. package/lib/icon/ppt-fill.js +1 -448
  91. package/lib/icon/qq.js +1 -448
  92. package/lib/icon/right-shape.js +1 -448
  93. package/lib/icon/right-turn-line.js +1 -448
  94. package/lib/icon/search.js +1 -448
  95. package/lib/icon/share.js +1 -448
  96. package/lib/icon/spinner.js +1 -448
  97. package/lib/icon/success.js +1 -448
  98. package/lib/icon/switcher-loading.js +1 -448
  99. package/lib/icon/text-file.js +1 -448
  100. package/lib/icon/text-fill.js +1 -448
  101. package/lib/icon/transfer.js +1 -448
  102. package/lib/icon/tree-application-shape.js +1 -448
  103. package/lib/icon/unfull-screen.js +1 -448
  104. package/lib/icon/unvisible.js +1 -448
  105. package/lib/icon/up-shape.js +1 -448
  106. package/lib/icon/upload.js +1 -448
  107. package/lib/icon/video-fill.js +1 -448
  108. package/lib/icon/warn.js +1 -448
  109. package/lib/icon/weixin.js +1 -448
  110. package/lib/image/index.js +1 -873
  111. package/lib/index.js +1 -169
  112. package/lib/info-box/index.js +1 -1784
  113. package/lib/input/index.js +1 -846
  114. package/lib/link/index.js +1 -226
  115. package/lib/loading/index.js +1 -309
  116. package/lib/menu/index.js +1 -796
  117. package/lib/message/index.js +1 -401
  118. package/lib/modal/index.js +1 -395
  119. package/lib/navigation/index.js +1 -431
  120. package/lib/notify/index.js +1 -430
  121. package/lib/overflow-title/index.js +1 -512
  122. package/lib/pagination/index.js +1 -1026
  123. package/lib/plugin-popover/index.js +1 -2581
  124. package/lib/plugins/index.js +1 -130
  125. package/lib/popover/index.js +1 -2587
  126. package/lib/popover2/index.js +1 -172
  127. package/lib/preset.js +1 -129
  128. package/lib/process/index.js +1 -1417
  129. package/lib/progress/index.js +1 -479
  130. package/lib/radio/index.js +1 -649
  131. package/lib/rate/index.js +1 -358
  132. package/lib/resize-layout/index.js +1 -495
  133. package/lib/search-select/index.js +1 -3388
  134. package/lib/search-select/search-select.css +1 -1
  135. package/lib/search-select/search-select.less +1 -1
  136. package/lib/search-select/search-select.variable.css +1 -1
  137. package/lib/select/index.js +1 -2819
  138. package/lib/shared/index.js +1 -2813
  139. package/lib/sideslider/index.js +1 -1362
  140. package/lib/slider/index.js +1 -2060
  141. package/lib/steps/index.js +1 -1504
  142. package/lib/swiper/index.js +1 -374
  143. package/lib/switcher/index.js +1 -308
  144. package/lib/tab/index.js +1 -919
  145. package/lib/table/index.js +1 -6635
  146. package/lib/table-column/index.js +1 -737
  147. package/lib/tag/index.js +1 -278
  148. package/lib/tag-input/index.js +1 -1897
  149. package/lib/time-picker/index.js +1 -142
  150. package/lib/timeline/index.js +1 -315
  151. package/lib/transfer/index.js +1 -658
  152. package/lib/tree/index.js +1 -2917
  153. package/lib/upload/index.js +1 -3735
  154. package/lib/virtual-render/index.js +1 -825
  155. package/package.json +2 -1
@@ -1,1897 +1 @@
1
- (function webpackUniversalModuleDefinition(root, factory) {
2
- if(typeof exports === 'object' && typeof module === 'object')
3
- module.exports = factory(require("../shared"), require("vue"), require("lodash"), require("../directives"), require("../icon"), require("../loading"), require("../popover"), require("vue-types"));
4
- else if(typeof define === 'function' && define.amd)
5
- define(["../shared", "vue", "lodash", "../directives", "../icon", "../loading", "../popover", "vue-types"], factory);
6
- else {
7
- var a = typeof exports === 'object' ? factory(require("../shared"), require("vue"), require("lodash"), require("../directives"), require("../icon"), require("../loading"), require("../popover"), require("vue-types")) : factory(root["../shared"], root["vue"], root["lodash"], root["../directives"], root["../icon"], root["../loading"], root["../popover"], root["vue-types"]);
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__467__, __WEBPACK_EXTERNAL_MODULE__4061__, __WEBPACK_EXTERNAL_MODULE__6870__, __WEBPACK_EXTERNAL_MODULE__4870__, __WEBPACK_EXTERNAL_MODULE__5537__, __WEBPACK_EXTERNAL_MODULE__210__) => {
11
- return /******/ (() => { // webpackBootstrap
12
- /******/ "use strict";
13
- /******/ var __webpack_modules__ = ({
14
-
15
- /***/ 4061:
16
- /***/ ((module) => {
17
-
18
- module.exports = __WEBPACK_EXTERNAL_MODULE__4061__;
19
-
20
- /***/ }),
21
-
22
- /***/ 6870:
23
- /***/ ((module) => {
24
-
25
- module.exports = __WEBPACK_EXTERNAL_MODULE__6870__;
26
-
27
- /***/ }),
28
-
29
- /***/ 4870:
30
- /***/ ((module) => {
31
-
32
- module.exports = __WEBPACK_EXTERNAL_MODULE__4870__;
33
-
34
- /***/ }),
35
-
36
- /***/ 5537:
37
- /***/ ((module) => {
38
-
39
- module.exports = __WEBPACK_EXTERNAL_MODULE__5537__;
40
-
41
- /***/ }),
42
-
43
- /***/ 4212:
44
- /***/ ((module) => {
45
-
46
- module.exports = __WEBPACK_EXTERNAL_MODULE__4212__;
47
-
48
- /***/ }),
49
-
50
- /***/ 467:
51
- /***/ ((module) => {
52
-
53
- module.exports = __WEBPACK_EXTERNAL_MODULE__467__;
54
-
55
- /***/ }),
56
-
57
- /***/ 748:
58
- /***/ ((module) => {
59
-
60
- module.exports = __WEBPACK_EXTERNAL_MODULE__748__;
61
-
62
- /***/ }),
63
-
64
- /***/ 210:
65
- /***/ ((module) => {
66
-
67
- module.exports = __WEBPACK_EXTERNAL_MODULE__210__;
68
-
69
- /***/ })
70
-
71
- /******/ });
72
- /************************************************************************/
73
- /******/ // The module cache
74
- /******/ var __webpack_module_cache__ = {};
75
- /******/
76
- /******/ // The require function
77
- /******/ function __webpack_require__(moduleId) {
78
- /******/ // Check if module is in cache
79
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
80
- /******/ if (cachedModule !== undefined) {
81
- /******/ return cachedModule.exports;
82
- /******/ }
83
- /******/ // Create a new module (and put it into the cache)
84
- /******/ var module = __webpack_module_cache__[moduleId] = {
85
- /******/ // no module.id needed
86
- /******/ // no module.loaded needed
87
- /******/ exports: {}
88
- /******/ };
89
- /******/
90
- /******/ // Execute the module function
91
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
92
- /******/
93
- /******/ // Return the exports of the module
94
- /******/ return module.exports;
95
- /******/ }
96
- /******/
97
- /************************************************************************/
98
- /******/ /* webpack/runtime/compat get default export */
99
- /******/ (() => {
100
- /******/ // getDefaultExport function for compatibility with non-harmony modules
101
- /******/ __webpack_require__.n = (module) => {
102
- /******/ var getter = module && module.__esModule ?
103
- /******/ () => (module['default']) :
104
- /******/ () => (module);
105
- /******/ __webpack_require__.d(getter, { a: getter });
106
- /******/ return getter;
107
- /******/ };
108
- /******/ })();
109
- /******/
110
- /******/ /* webpack/runtime/define property getters */
111
- /******/ (() => {
112
- /******/ // define getter functions for harmony exports
113
- /******/ __webpack_require__.d = (exports, definition) => {
114
- /******/ for(var key in definition) {
115
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
116
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
117
- /******/ }
118
- /******/ }
119
- /******/ };
120
- /******/ })();
121
- /******/
122
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
123
- /******/ (() => {
124
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
125
- /******/ })();
126
- /******/
127
- /******/ /* webpack/runtime/make namespace object */
128
- /******/ (() => {
129
- /******/ // define __esModule on exports
130
- /******/ __webpack_require__.r = (exports) => {
131
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
132
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
133
- /******/ }
134
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
135
- /******/ };
136
- /******/ })();
137
- /******/
138
- /************************************************************************/
139
- var __webpack_exports__ = {};
140
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
141
- (() => {
142
- // ESM COMPAT FLAG
143
- __webpack_require__.r(__webpack_exports__);
144
-
145
- // EXPORTS
146
- __webpack_require__.d(__webpack_exports__, {
147
- "default": () => (/* binding */ src)
148
- });
149
-
150
- // EXTERNAL MODULE: external "../shared"
151
- var external_shared_ = __webpack_require__(4212);
152
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/typeof.js
153
- function _typeof(obj) {
154
- "@babel/helpers - typeof";
155
-
156
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
157
- return typeof obj;
158
- } : function (obj) {
159
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
160
- }, _typeof(obj);
161
- }
162
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
163
- function _arrayWithHoles(arr) {
164
- if (Array.isArray(arr)) return arr;
165
- }
166
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
167
- function _iterableToArrayLimit(arr, i) {
168
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
169
-
170
- if (_i == null) return;
171
- var _arr = [];
172
- var _n = true;
173
- var _d = false;
174
-
175
- var _s, _e;
176
-
177
- try {
178
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
179
- _arr.push(_s.value);
180
-
181
- if (i && _arr.length === i) break;
182
- }
183
- } catch (err) {
184
- _d = true;
185
- _e = err;
186
- } finally {
187
- try {
188
- if (!_n && _i["return"] != null) _i["return"]();
189
- } finally {
190
- if (_d) throw _e;
191
- }
192
- }
193
-
194
- return _arr;
195
- }
196
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
197
- function _arrayLikeToArray(arr, len) {
198
- if (len == null || len > arr.length) len = arr.length;
199
-
200
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
201
- arr2[i] = arr[i];
202
- }
203
-
204
- return arr2;
205
- }
206
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
207
-
208
- function _unsupportedIterableToArray(o, minLen) {
209
- if (!o) return;
210
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
211
- var n = Object.prototype.toString.call(o).slice(8, -1);
212
- if (n === "Object" && o.constructor) n = o.constructor.name;
213
- if (n === "Map" || n === "Set") return Array.from(o);
214
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
215
- }
216
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
217
- function _nonIterableRest() {
218
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
219
- }
220
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/slicedToArray.js
221
-
222
-
223
-
224
-
225
- function _slicedToArray(arr, i) {
226
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
227
- }
228
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
229
- function _defineProperty(obj, key, value) {
230
- if (key in obj) {
231
- Object.defineProperty(obj, key, {
232
- value: value,
233
- enumerable: true,
234
- configurable: true,
235
- writable: true
236
- });
237
- } else {
238
- obj[key] = value;
239
- }
240
-
241
- return obj;
242
- }
243
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
244
-
245
- function _arrayWithoutHoles(arr) {
246
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
247
- }
248
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/iterableToArray.js
249
- function _iterableToArray(iter) {
250
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
251
- }
252
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
253
- function _nonIterableSpread() {
254
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
255
- }
256
- ;// CONCATENATED MODULE: ../../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
257
-
258
-
259
-
260
-
261
- function _toConsumableArray(arr) {
262
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
263
- }
264
- // EXTERNAL MODULE: external "vue"
265
- var external_vue_ = __webpack_require__(748);
266
- // EXTERNAL MODULE: external "lodash"
267
- var external_lodash_ = __webpack_require__(467);
268
- // EXTERNAL MODULE: external "../directives"
269
- var external_directives_ = __webpack_require__(4061);
270
- // EXTERNAL MODULE: external "../icon"
271
- var external_icon_ = __webpack_require__(6870);
272
- // EXTERNAL MODULE: external "../loading"
273
- var external_loading_ = __webpack_require__(4870);
274
- var external_loading_default = /*#__PURE__*/__webpack_require__.n(external_loading_);
275
- // EXTERNAL MODULE: external "../popover"
276
- var external_popover_ = __webpack_require__(5537);
277
- var external_popover_default = /*#__PURE__*/__webpack_require__.n(external_popover_);
278
- ;// CONCATENATED MODULE: ../../packages/tag-input/src/common.ts
279
-
280
-
281
- /*
282
- * Tencent is pleased to support the open source community by making
283
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
284
- *
285
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
286
- *
287
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
288
- *
289
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
290
- *
291
- * ---------------------------------------------------
292
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
293
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
294
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
295
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
296
- *
297
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
298
- * the Software.
299
- *
300
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
301
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
302
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
303
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
304
- * IN THE SOFTWARE.
305
- */
306
-
307
- var INPUT_MIN_WIDTH = 12;
308
- function useDebouncedRef(value) {
309
- var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
310
- var timeout;
311
- var innerValue = value;
312
- return customRef(function (track, trigger) {
313
- return {
314
- get: function get() {
315
- track();
316
- return innerValue;
317
- },
318
- set: function set(newValue) {
319
- clearTimeout(timeout);
320
- timeout = setTimeout(function () {
321
- innerValue = newValue;
322
- trigger();
323
- }, delay);
324
- }
325
- };
326
- });
327
- }
328
- function usePage(pageSize) {
329
- var state = (0,external_vue_.reactive)({
330
- curPage: 1,
331
- totalSize: 0,
332
- totalPage: 0,
333
- pageSize: pageSize,
334
- isPageLoading: false,
335
- curPageList: [],
336
- renderListPaged: []
337
- }); // 初始化分页信息
338
-
339
- var initPage = function initPage() {
340
- var _state$renderListPage, _state$curPageList;
341
-
342
- var allList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
343
- state.curPage = 1;
344
- state.totalSize = allList.length;
345
- state.totalPage = Math.ceil(state.totalSize / state.pageSize) || 1;
346
- var list = []; // 小于等于0会无限循环
347
-
348
- if (state.pageSize > 0) {
349
- for (var i = 0; i < state.totalSize; i += state.pageSize) {
350
- list.push(allList.slice(i, i + state.pageSize));
351
- }
352
- }
353
-
354
- (_state$renderListPage = state.renderListPaged).splice.apply(_state$renderListPage, [0, state.renderListPaged.length].concat(list));
355
-
356
- (_state$curPageList = state.curPageList).splice.apply(_state$curPageList, [0, state.curPageList.length].concat(_toConsumableArray(state.renderListPaged[state.curPage - 1] || [])));
357
- };
358
-
359
- var pageChange = function pageChange(page) {
360
- var _state$curPageList2;
361
-
362
- state.curPage = page;
363
-
364
- (_state$curPageList2 = state.curPageList).splice.apply(_state$curPageList2, [state.curPageList.length, 0].concat(_toConsumableArray(state.renderListPaged[state.curPage - 1] || [])));
365
-
366
- state.isPageLoading = false;
367
- };
368
-
369
- return {
370
- pageState: state,
371
- initPage: initPage,
372
- pageChange: pageChange
373
- };
374
- }
375
- function useFlatList(props) {
376
- var _toRefs = (0,external_vue_.toRefs)(props),
377
- useGroup = _toRefs.useGroup,
378
- saveKey = _toRefs.saveKey,
379
- displayKey = _toRefs.displayKey,
380
- list = _toRefs.list;
381
-
382
- var flatList = (0,external_vue_.ref)([]);
383
- var saveKeyMap = (0,external_vue_.ref)({});
384
- (0,external_vue_.watch)([useGroup, saveKey, displayKey, list], function () {
385
- flatList.value = [];
386
- var formatList = (0,external_vue_.markRaw)(list.value);
387
-
388
- if (useGroup.value) {
389
- formatList = formatList.reduce(function (formatList, item) {
390
- var children = [];
391
-
392
- if (item.children) {
393
- children = item.children.map(function (child) {
394
- return Object.assign({
395
- group: {
396
- groupId: item[saveKey.value],
397
- groupName: item[displayKey.value]
398
- }
399
- }, child);
400
- });
401
- }
402
-
403
- return formatList.concat(children);
404
- }, []);
405
- }
406
-
407
- flatList.value = formatList;
408
- saveKeyMap.value = formatList.reduce(function (acc, item) {
409
- acc[item[saveKey.value]] = item;
410
- return acc;
411
- }, {});
412
- }, {
413
- immediate: true,
414
- deep: true
415
- });
416
- return {
417
- flatList: flatList,
418
- saveKeyMap: saveKeyMap
419
- };
420
- }
421
- /**
422
- * 获取字符长度,汉字两个字节
423
- * @param str 需要计算长度的字符
424
- * @returns 字符长度
425
- */
426
-
427
- var getCharLength = function getCharLength(str) {
428
- var len = str.length;
429
- var bitLen = 0;
430
-
431
- for (var i = 0; i < len; i++) {
432
- if ((str.charCodeAt(i) & 0xff00) !== 0) {
433
- bitLen += 1;
434
- }
435
-
436
- bitLen += 1;
437
- }
438
-
439
- return bitLen;
440
- };
441
- /**
442
- * 获取隐藏 tag index
443
- * @param tagInputRef 组件容器 ref
444
- * @param collapseTags 是否折叠 tags
445
- * @param selectedTagList 已选择 tags
446
- */
447
-
448
- var useTagsOverflow = function useTagsOverflow(tagInputRef, collapseTags, selectedTagList) {
449
- (0,external_vue_.watch)([selectedTagList, collapseTags], function () {
450
- calcOverflow();
451
- }, {
452
- flush: 'post'
453
- });
454
- var overflowTagIndex = (0,external_vue_.ref)(null); // 计算出现换行的索引
455
-
456
- var calcOverflow = function calcOverflow() {
457
- if (!collapseTags.value) return;
458
- overflowTagIndex.value = null;
459
- setTimeout(function () {
460
- var tags = Array.from(tagInputRef.value.querySelectorAll('.tag-item'));
461
- var tagIndexInSecondRow = tags.findIndex(function (currentTag, index) {
462
- if (!index) {
463
- return false;
464
- }
465
-
466
- var previousTag = tags[index - 1];
467
- return previousTag.offsetTop !== currentTag.offsetTop;
468
- });
469
- overflowTagIndex.value = tagIndexInSecondRow > 0 ? tagIndexInSecondRow - 1 : null;
470
- });
471
- };
472
-
473
- return {
474
- overflowTagIndex: overflowTagIndex
475
- };
476
- };
477
- ;// CONCATENATED MODULE: ../../packages/tag-input/src/list-tag-render.tsx
478
-
479
-
480
- /*
481
- * Tencent is pleased to support the open source community by making
482
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
483
- *
484
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
485
- *
486
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
487
- *
488
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
489
- *
490
- * ---------------------------------------------------
491
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
492
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
493
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
494
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
495
- *
496
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
497
- * the Software.
498
- *
499
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
500
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
501
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
502
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
503
- * IN THE SOFTWARE.
504
- */
505
-
506
-
507
- /* harmony default export */ const list_tag_render = ((0,external_vue_.defineComponent)({
508
- name: 'ListTagRender',
509
- props: {
510
- node: external_shared_.PropTypes.object,
511
- searchKey: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.string, external_shared_.PropTypes.arrayOf(external_shared_.PropTypes.string)]),
512
- displayKey: external_shared_.PropTypes.string,
513
- searchKeyword: external_shared_.PropTypes.string,
514
- tpl: {
515
- type: Function
516
- }
517
- },
518
- render: function render() {
519
- var _this = this;
520
-
521
- var highlightKeyword = function highlightKeyword(value) {
522
- if (_this.searchKeyword) {
523
- var keywordReg = new RegExp("(".concat(_this.searchKeyword, ")"), 'i');
524
- return value.replace(keywordReg, '<strong class="highlight-text">$1</strong>');
525
- }
526
-
527
- return value;
528
- };
529
-
530
- if (this.tpl) {
531
- return this.tpl(this.node, highlightKeyword, external_vue_.h, this);
532
- }
533
-
534
- var displayText = this.node[this.displayKey];
535
- return (0,external_vue_.createVNode)("div", {
536
- "class": "bk-selector-node"
537
- }, [(0,external_vue_.createVNode)("span", {
538
- "class": "text",
539
- "innerHTML": highlightKeyword(displayText)
540
- }, [displayText])]);
541
- }
542
- }));
543
- // EXTERNAL MODULE: external "vue-types"
544
- var external_vue_types_ = __webpack_require__(210);
545
- ;// CONCATENATED MODULE: ../../packages/tag-input/src/tag-props.ts
546
- /*
547
- * Tencent is pleased to support the open source community by making
548
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
549
- *
550
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
551
- *
552
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
553
- *
554
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
555
- *
556
- * ---------------------------------------------------
557
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
558
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
559
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
560
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
561
- *
562
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
563
- * the Software.
564
- *
565
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
566
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
567
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
568
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
569
- * IN THE SOFTWARE.
570
- */
571
-
572
-
573
- var TagInputTriggerEnum;
574
-
575
- (function (TagInputTriggerEnum) {
576
- TagInputTriggerEnum["FOCUS"] = "focus";
577
- TagInputTriggerEnum["SEARCH"] = "search";
578
- })(TagInputTriggerEnum || (TagInputTriggerEnum = {}));
579
-
580
- var tagProps = function tagProps() {
581
- return {
582
- modelValue: external_shared_.PropTypes.arrayOf(external_shared_.PropTypes.string).def([]),
583
- placeholder: external_shared_.PropTypes.string.def('请输入并按 Enter 结束'),
584
- list: external_shared_.PropTypes.arrayOf(external_shared_.PropTypes.object).def([]),
585
- disabled: external_shared_.PropTypes.bool.def(false),
586
- tooltipKey: external_shared_.PropTypes.string.def(''),
587
- saveKey: external_shared_.PropTypes.string.def('id'),
588
- displayKey: external_shared_.PropTypes.string.def('name'),
589
- hasDeleteIcon: external_shared_.PropTypes.bool.def(false),
590
- clearable: external_shared_.PropTypes.bool.def(true),
591
- trigger: (0,external_vue_types_.toType)('treeTriggerType', {}).def(TagInputTriggerEnum.SEARCH),
592
- searchKey: external_shared_.PropTypes.oneOfType([external_shared_.PropTypes.string, external_shared_.PropTypes.arrayOf(external_shared_.PropTypes.string)]).def('name'),
593
- useGroup: external_shared_.PropTypes.bool.def(false),
594
- allowCreate: external_shared_.PropTypes.bool.def(false),
595
- maxData: external_shared_.PropTypes.number.def(-1),
596
- maxResult: external_shared_.PropTypes.number.def(10),
597
- contentMaxHeight: external_shared_.PropTypes.number.def(300),
598
- contentWidth: external_shared_.PropTypes.number.def(190),
599
- separator: external_shared_.PropTypes.string.def(''),
600
- allowNextFocus: external_shared_.PropTypes.bool.def(true),
601
- allowAutoMatch: external_shared_.PropTypes.bool.def(false),
602
- showClearOnlyHover: external_shared_.PropTypes.bool.def(false),
603
- leftSpace: external_shared_.PropTypes.number.def(0),
604
- createTagValidator: {
605
- type: Function
606
- },
607
- filterCallback: {
608
- type: Function
609
- },
610
- tagTpl: {
611
- type: Function
612
- },
613
- tpl: {
614
- type: Function
615
- },
616
- pasteFn: {
617
- type: Function
618
- },
619
- withValidate: {
620
- type: Boolean,
621
- "default": true
622
- },
623
- popoverProps: {
624
- type: Object,
625
- "default": function _default() {
626
- return {};
627
- }
628
- },
629
- collapseTags: {
630
- type: Boolean,
631
- "default": false
632
- },
633
- tagOverflowTips: {
634
- type: Object,
635
- "default": function _default() {
636
- return {};
637
- }
638
- }
639
- };
640
- };
641
-
642
- /* harmony default export */ const tag_props = (tagProps);
643
- ;// CONCATENATED MODULE: ../../packages/tag-input/src/tag-render.tsx
644
-
645
-
646
- /*
647
- * Tencent is pleased to support the open source community by making
648
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
649
- *
650
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
651
- *
652
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
653
- *
654
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
655
- *
656
- * ---------------------------------------------------
657
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
658
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
659
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
660
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
661
- *
662
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
663
- * the Software.
664
- *
665
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
666
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
667
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
668
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
669
- * IN THE SOFTWARE.
670
- */
671
-
672
-
673
-
674
- /* harmony default export */ const tag_render = ((0,external_vue_.defineComponent)({
675
- name: 'TagRender',
676
- directives: {
677
- bkTooltips: external_directives_.bkTooltips
678
- },
679
- props: {
680
- node: external_shared_.PropTypes.object,
681
- displayKey: external_shared_.PropTypes.string,
682
- tpl: {
683
- type: Function
684
- },
685
- hasTips: {
686
- type: Boolean,
687
- "default": false
688
- },
689
- tagOverflowTips: {
690
- type: Object,
691
- "default": function _default() {
692
- return {};
693
- }
694
- }
695
- },
696
- setup: function setup(props) {
697
- var tagRef = (0,external_vue_.ref)();
698
- var isOverflow = (0,external_vue_.ref)(false);
699
- var overflowTips = (0,external_vue_.computed)(function () {
700
- return Object.assign({
701
- boundary: 'window',
702
- theme: 'light',
703
- distance: 12,
704
- content: props.node[props.displayKey],
705
- disabled: props.hasTips || !isOverflow.value
706
- }, props.tagOverflowTips);
707
- });
708
- (0,external_vue_.onMounted)(function () {
709
- isOverflow.value = (0,external_shared_.checkOverflow)(tagRef.value);
710
- });
711
- return {
712
- overflowTips: overflowTips,
713
- tagRef: tagRef
714
- };
715
- },
716
- render: function render() {
717
- if (this.tpl) {
718
- return this.tpl(this.node, external_vue_.h, this);
719
- }
720
-
721
- return (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("div", {
722
- "class": "tag",
723
- "ref": "tagRef"
724
- }, [(0,external_vue_.createVNode)("span", {
725
- "class": "text"
726
- }, [this.node[this.displayKey]])]), [[(0,external_vue_.resolveDirective)("bk-tooltips"), this.overflowTips]]);
727
- }
728
- }));
729
- ;// CONCATENATED MODULE: ../../packages/tag-input/src/tag-input.tsx
730
-
731
-
732
-
733
-
734
-
735
-
736
- /*
737
- * Tencent is pleased to support the open source community by making
738
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
739
- *
740
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
741
- *
742
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
743
- *
744
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
745
- *
746
- * ---------------------------------------------------
747
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
748
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
749
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
750
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
751
- *
752
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
753
- * the Software.
754
- *
755
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
756
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
757
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
758
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
759
- * IN THE SOFTWARE.
760
- */
761
-
762
-
763
-
764
-
765
-
766
-
767
-
768
-
769
-
770
-
771
-
772
- /* harmony default export */ const tag_input = ((0,external_vue_.defineComponent)({
773
- name: 'TagInput',
774
- directives: {
775
- bkTooltips: external_directives_.bkTooltips
776
- },
777
- props: tag_props(),
778
- emits: ['update:modelValue', 'change', 'select', 'focus', 'blur', 'remove', 'removeAll', 'input'],
779
- setup: function setup(props, _ref) {
780
- var emit = _ref.emit;
781
- var formItem = (0,external_shared_.useFormItem)();
782
- var state = (0,external_vue_.reactive)({
783
- isEdit: false,
784
- isHover: false,
785
- focusItemIndex: props.allowCreate ? -1 : 0
786
- });
787
- var popoverProps = (0,external_vue_.reactive)(Object.assign({
788
- isShow: false,
789
- width: 190,
790
- offset: {
791
- mainAxis: 4,
792
- crossAxis: 0 // alignmentAxis: 50,
793
-
794
- }
795
- }, props.popoverProps)); // 分页处理
796
-
797
- var _toRefs = (0,external_vue_.toRefs)(props),
798
- maxResult = _toRefs.maxResult;
799
-
800
- var _usePage = usePage(maxResult),
801
- pageState = _usePage.pageState,
802
- initPage = _usePage.initPage,
803
- pageChange = _usePage.pageChange;
804
-
805
- var curInputValue = (0,external_vue_.ref)('');
806
- var tagInputRef = (0,external_vue_.ref)(null);
807
- var bkTagSelectorRef = (0,external_vue_.ref)(null);
808
- var tagListRef = (0,external_vue_.ref)(null);
809
- var tagInputItemRef = (0,external_vue_.ref)(null);
810
- var selectorListRef = (0,external_vue_.ref)(null);
811
- var timer = (0,external_vue_.ref)(null); // 是否展示tag close
812
-
813
- var showTagClose = (0,external_vue_.computed)(function () {
814
- return !props.disabled && props.hasDeleteIcon;
815
- }); // 是否单选
816
-
817
- var isSingleSelect = (0,external_vue_.computed)(function () {
818
- return props.maxData === 1;
819
- }); // 是否展示placeholder
820
-
821
- var isShowPlaceholder = (0,external_vue_.computed)(function () {
822
- return listState.selectedTagList.length === 0 && curInputValue.value === '' && !state.isEdit;
823
- }); // 是否展示清空Icon
824
-
825
- /**
826
- * 不显示条件:
827
- * 1. 设置不可清除
828
- * 2. 禁用时
829
- * 3. tag标签为空时
830
- * 4. 设置了showClearOnlyHover,且没有hover的时候
831
- */
832
-
833
- var isShowClear = (0,external_vue_.computed)(function () {
834
- return props.clearable && !props.disabled && listState.selectedTagList.length !== 0 && (props.showClearOnlyHover ? state.isHover : true);
835
- });
836
- var triggerClass = (0,external_vue_.computed)(function () {
837
- return {
838
- 'bk-tag-input-trigger': true,
839
- active: state.isEdit,
840
- disabled: props.disabled
841
- };
842
- });
843
- var listState = (0,external_vue_.reactive)({
844
- localList: [],
845
- tagListCache: [],
846
- selectedTagList: [],
847
- selectedTagListCache: []
848
- }); // 选中标签 save key 列表
849
-
850
- var tagList = (0,external_vue_.computed)(function () {
851
- return listState.selectedTagList.map(function (tag) {
852
- return tag[props.saveKey];
853
- });
854
- }); // 扁平化 list
855
-
856
- var _useFlatList = useFlatList(props),
857
- flatList = _useFlatList.flatList,
858
- saveKeyMap = _useFlatList.saveKeyMap; // 下拉框渲染列表
859
-
860
-
861
- var renderList = (0,external_vue_.computed)(function () {
862
- if (props.useGroup) {
863
- var groupMap = {};
864
- pageState.curPageList.forEach(function (item, index) {
865
- item.__index__ = index;
866
-
867
- if (!groupMap[item.group.groupId]) {
868
- groupMap[item.group.groupId] = {
869
- id: item.group.groupId,
870
- name: item.group.groupName,
871
- children: []
872
- };
873
- }
874
-
875
- groupMap[item.group.groupId].children.push(item);
876
- });
877
- return Object.keys(groupMap).map(function (key) {
878
- return groupMap[key];
879
- });
880
- }
881
-
882
- return pageState.curPageList;
883
- });
884
- (0,external_vue_.watch)([function () {
885
- return flatList.value;
886
- }], function () {
887
- (0,external_vue_.nextTick)(function () {
888
- initData();
889
- });
890
- }, {
891
- deep: true
892
- });
893
- (0,external_vue_.watch)(function () {
894
- return props.modelValue;
895
- }, function (val) {
896
- var _a;
897
-
898
- if (!shallowCompareArray(tagList.value, val)) {
899
- (0,external_vue_.nextTick)(function () {
900
- initData();
901
- });
902
-
903
- if (props.withValidate) {
904
- (_a = formItem === null || formItem === void 0 ? void 0 : formItem.validate) === null || _a === void 0 ? void 0 : _a.call(formItem, 'change');
905
- }
906
- }
907
- });
908
- (0,external_vue_.watch)(curInputValue, (0,external_lodash_.debounce)(function () {
909
- var hasShowCount = pageState.curPageList.length !== 0;
910
- var value = curInputValue.value;
911
- /**
912
- * 1. value !== '' && hasShowCount => search value list.
913
- * 2. value === '' && props.trigger === 'focus' && hasShowCount => trigger is focus and show all list.
914
- */
915
-
916
- if (value !== '' && hasShowCount || value === '' && props.trigger === 'focus' && hasShowCount) {
917
- popoverProps.isShow = true;
918
- } else if (props.trigger !== 'focus' || !hasShowCount) {
919
- popoverProps.isShow = false;
920
- }
921
- }, 150));
922
- (0,external_vue_.watch)(function () {
923
- return popoverProps.isShow;
924
- }, function (show) {
925
- changePopoverOffset();
926
-
927
- if (show) {
928
- if (selectorListRef.value) {
929
- (0,external_vue_.nextTick)(function () {
930
- selectorListRef.value.scrollTop = 0;
931
- });
932
- selectorListRef.value.removeEventListener('scroll', scrollHandler);
933
- selectorListRef.value.addEventListener('scroll', scrollHandler);
934
- }
935
- }
936
- });
937
- (0,external_vue_.onMounted)(function () {
938
- initData();
939
- });
940
-
941
- var changePopoverOffset = function changePopoverOffset() {
942
- var _a; // 修改popover offset
943
-
944
-
945
- popoverProps.offset.crossAxis = isSingleSelect.value ? 0 : (_a = tagInputItemRef.value) === null || _a === void 0 ? void 0 : _a.offsetLeft;
946
- };
947
-
948
- var scrollHandler = function scrollHandler() {
949
- if (pageState.isPageLoading || selectorListRef.value.scrollTop === 0) {
950
- return;
951
- }
952
-
953
- var _selectorListRef$valu = selectorListRef.value,
954
- scrollTop = _selectorListRef$valu.scrollTop,
955
- offsetHeight = _selectorListRef$valu.offsetHeight,
956
- scrollHeight = _selectorListRef$valu.scrollHeight;
957
-
958
- if (scrollTop + offsetHeight >= scrollHeight) {
959
- var curPage = pageState.curPage + 1;
960
-
961
- if (curPage <= pageState.totalPage) {
962
- pageState.isPageLoading = true;
963
- setTimeout(function () {
964
- pageChange(curPage);
965
- }, 500);
966
- }
967
- }
968
- }; // 获取选中元素节点
969
-
970
-
971
- var getSelectedTagNodes = function getSelectedTagNodes() {
972
- var _a;
973
-
974
- var nodes = Array.from(((_a = tagListRef.value) === null || _a === void 0 ? void 0 : _a.childNodes) || []);
975
- return nodes.filter(function (node) {
976
- return ![Node.TEXT_NODE, Node.COMMENT_NODE].includes(node.nodeType);
977
- });
978
- };
979
- /**
980
- * 触发输入框聚焦
981
- * @param e
982
- */
983
-
984
-
985
- var focusInputTrigger = function focusInputTrigger(e) {
986
- if (props.disabled) return;
987
-
988
- if (e === null || e === void 0 ? void 0 : e.target) {
989
- var className = e.target.className;
990
-
991
- if (className.indexOf('bk-tag-input-trigger') > -1 || className.indexOf('tag-list') > -1) {
992
- // 如果没点在节点上,重置input位置(在最后插入input)
993
- tagListRef.value.appendChild(tagInputItemRef.value);
994
- }
995
- }
996
-
997
- clearTimeout(timer.value); // 如果是单选,在获取焦点时自动定位为当前值
998
-
999
- if (isSingleSelect.value && tagList.value.length) {
1000
- listState.tagListCache = _toConsumableArray(tagList.value);
1001
- listState.selectedTagListCache = _toConsumableArray(listState.selectedTagList);
1002
- curInputValue.value = listState.selectedTagListCache[0][props.saveKey];
1003
- removeTag(listState.selectedTagList[0], 0);
1004
- handleInput();
1005
- }
1006
-
1007
- state.isEdit = true;
1008
- (0,external_vue_.nextTick)(function () {
1009
- var _a;
1010
-
1011
- (_a = tagInputRef.value) === null || _a === void 0 ? void 0 : _a.focus();
1012
-
1013
- if (props.trigger === 'focus' && listState.localList.length !== 0) {
1014
- filterData();
1015
-
1016
- if (popoverProps.isShow) {
1017
- changePopoverOffset();
1018
- } else {
1019
- popoverProps.isShow = true;
1020
- }
1021
- }
1022
- });
1023
- };
1024
- /**
1025
- * 初始化列表数据
1026
- */
1027
-
1028
-
1029
- var initData = function initData() {
1030
- var saveKey = props.saveKey,
1031
- modelValue = props.modelValue,
1032
- displayKey = props.displayKey,
1033
- allowCreate = props.allowCreate,
1034
- trigger = props.trigger;
1035
- listState.selectedTagList = [];
1036
- listState.localList = flatList.value;
1037
-
1038
- if (modelValue.length) {
1039
- var modelValueMap = {};
1040
- listState.selectedTagList = modelValue.map(function (tag) {
1041
- var item = saveKeyMap.value[tag];
1042
- modelValueMap[tag] = 1;
1043
-
1044
- if (!item && allowCreate) {
1045
- var _ref2;
1046
-
1047
- return _ref2 = {}, _defineProperty(_ref2, saveKey, tag), _defineProperty(_ref2, displayKey, tag), _ref2;
1048
- }
1049
-
1050
- return item;
1051
- }).filter(function (item) {
1052
- return item;
1053
- }); // 如果不是单选时,需要将已选的过滤掉
1054
-
1055
- if (!isSingleSelect.value) {
1056
- listState.localList = listState.localList.filter(function (val) {
1057
- return !modelValueMap[val[saveKey]];
1058
- });
1059
- }
1060
- } // 如果需要首次展示列表,先初始化
1061
-
1062
-
1063
- if (trigger === 'focus') {
1064
- filterData();
1065
- }
1066
- }; // 过滤数据
1067
-
1068
-
1069
- var filterData = function filterData() {
1070
- var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1071
- var searchKey = props.searchKey,
1072
- filterCallback = props.filterCallback;
1073
- var lowerCaseValue = value.toLowerCase().trim();
1074
-
1075
- if (lowerCaseValue === '') {
1076
- initPage(listState.localList);
1077
- return;
1078
- }
1079
-
1080
- var filterData = [];
1081
-
1082
- if (typeof filterCallback === 'function') {
1083
- filterData = filterCallback(lowerCaseValue, searchKey, listState.localList) || [];
1084
- } else {
1085
- // 根据文本框输入的值筛选过来的数据
1086
- if (Array.isArray(searchKey)) {
1087
- // 数组,过滤多个关键字
1088
- filterData = listState.localList.filter(function (item) {
1089
- return searchKey.some(function (keyword) {
1090
- return item[keyword].toLowerCase().indexOf(lowerCaseValue) > -1;
1091
- });
1092
- });
1093
- } else {
1094
- filterData = listState.localList.filter(function (item) {
1095
- return item[searchKey].toLowerCase().indexOf(lowerCaseValue) > -1;
1096
- });
1097
- }
1098
- }
1099
-
1100
- initPage(filterData);
1101
- };
1102
-
1103
- var activeClass = function activeClass(data, index) {
1104
- var style = {
1105
- 'bk-selector-actived': false,
1106
- 'bk-selector-selected': tagList.value.includes(data[props.saveKey])
1107
- };
1108
-
1109
- if (props.useGroup) {
1110
- style['bk-selector-actived'] = data.__index__ === state.focusItemIndex;
1111
- } else {
1112
- style['bk-selector-actived'] = index === state.focusItemIndex;
1113
- }
1114
-
1115
- return style;
1116
- };
1117
-
1118
- function shallowCompareArray(arr1, arr2) {
1119
- if (arr1.length !== arr2.length) return false;
1120
- return arr2.every(function (item, index) {
1121
- return arr1[index] === item;
1122
- });
1123
- }
1124
-
1125
- var clearSingleCache = function clearSingleCache() {
1126
- listState.tagListCache = [];
1127
- listState.selectedTagListCache = [];
1128
- listState.selectedTagList = [];
1129
- };
1130
-
1131
- var clearInput = function clearInput() {
1132
- curInputValue.value = '';
1133
- };
1134
- /**
1135
- * 获取输入框元素位置
1136
- */
1137
-
1138
-
1139
- var getTagInputItemSite = function getTagInputItemSite() {
1140
- // 单选时,当前替换位置为第一个元素
1141
- if (isSingleSelect.value) {
1142
- return 0;
1143
- }
1144
-
1145
- var childNodes = getSelectedTagNodes();
1146
- var index = childNodes.findIndex(function (_ref3) {
1147
- var id = _ref3.id;
1148
- return id === 'tagInputItem';
1149
- });
1150
- return index >= 0 ? index : 0;
1151
- };
1152
- /**
1153
- * 交换元素位置
1154
- */
1155
-
1156
-
1157
- var swapElementPositions = function swapElementPositions(newNode, referenceNode) {
1158
- var isNextElementSibling = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1159
- if (!referenceNode || !newNode) return;
1160
- var swap = referenceNode;
1161
-
1162
- if (isNextElementSibling) {
1163
- swap = referenceNode.nextElementSibling || null;
1164
- }
1165
-
1166
- referenceNode.parentNode.insertBefore(newNode, swap);
1167
- };
1168
-
1169
- var handleInput = function handleInput(e) {
1170
- var maxData = props.maxData,
1171
- trigger = props.trigger,
1172
- allowCreate = props.allowCreate;
1173
-
1174
- if (maxData === -1 || maxData > tagList.value.length) {
1175
- var _ref4 = (e === null || e === void 0 ? void 0 : e.target) ? e.target : curInputValue,
1176
- value = _ref4.value;
1177
-
1178
- var charLen = getCharLength(value);
1179
-
1180
- if (charLen) {
1181
- filterData(value);
1182
- tagInputRef.value.style.width = "".concat(charLen * INPUT_MIN_WIDTH, "px");
1183
- } else {
1184
- if (trigger === 'focus') {
1185
- filterData();
1186
- }
1187
- }
1188
- } else {
1189
- handleBlur();
1190
- curInputValue.value = '';
1191
- popoverProps.isShow = false;
1192
- }
1193
-
1194
- state.isEdit = true; // 重置下拉菜单选中信息
1195
-
1196
- state.focusItemIndex = allowCreate ? -1 : 0;
1197
- emit('input', curInputValue.value);
1198
- };
1199
-
1200
- var handleFocus = function handleFocus() {
1201
- var _a; // this.dispatch('bk-form-item', 'form-focus')
1202
-
1203
-
1204
- popoverProps.width = isSingleSelect.value ? (_a = bkTagSelectorRef.value) === null || _a === void 0 ? void 0 : _a.clientWidth : props.contentWidth;
1205
- emit('focus'); // e.currentTarget.select();
1206
- };
1207
-
1208
- var handleBlur = function handleBlur() {
1209
- timer.value = setTimeout(function () {
1210
- var _a;
1211
-
1212
- var inputValue = curInputValue.value;
1213
- clearInput(); // 通知表单组件,可用于实时验证
1214
- // this.dispatch('bk-form-item', 'form-blur')
1215
-
1216
- state.isEdit = false;
1217
-
1218
- if (isSingleSelect.value) {
1219
- var _listState$tagListCac = _slicedToArray(listState.tagListCache, 1),
1220
- oldValue = _listState$tagListCac[0]; // 如果是单选,且input不为空,即保留了上次的结果则恢复
1221
-
1222
-
1223
- if (inputValue && inputValue === oldValue && listState.selectedTagListCache.length) {
1224
- addTag(listState.selectedTagListCache[0], 'select');
1225
- } else {
1226
- handleChange('remove');
1227
- }
1228
- } else if (props.allowAutoMatch && inputValue) {
1229
- // 如果匹配,则自动选则
1230
- var matchItem = pageState.curPageList.find(function (item) {
1231
- if (Array.isArray(props.searchKey)) {
1232
- var searchValue = props.searchKey.map(function (key) {
1233
- return item[key];
1234
- });
1235
- return searchValue.includes(inputValue);
1236
- }
1237
-
1238
- return item[props.searchKey] === inputValue;
1239
- });
1240
-
1241
- if (matchItem) {
1242
- handleTagSelected(matchItem, 'select');
1243
- } else if (props.allowCreate) {
1244
- // 支持自定义
1245
- handleTagSelected(inputValue, 'custom');
1246
- }
1247
- }
1248
-
1249
- popoverProps.isShow = false;
1250
- emit('blur', inputValue, tagList.value);
1251
- (_a = formItem === null || formItem === void 0 ? void 0 : formItem.validate) === null || _a === void 0 ? void 0 : _a.call(formItem, 'blur');
1252
- }, 200);
1253
- };
1254
- /**
1255
- * tag selected handler
1256
- * @param item tag data
1257
- * @param type emit type
1258
- */
1259
-
1260
-
1261
- var handleTagSelected = function handleTagSelected(item, type, e) {
1262
- e === null || e === void 0 ? void 0 : e.stopPropagation(); // 如果 item 不存在(备选项中没有包含输入的字母的情况即输入关键字没有备选项出现的情况)或者选中标签所在组是禁用状态,返回
1263
-
1264
- if (!item || item.disabled) {
1265
- return;
1266
- } // 如果是单选,清空上一次缓存结果
1267
-
1268
-
1269
- if (isSingleSelect.value) {
1270
- clearSingleCache();
1271
- }
1272
-
1273
- addTag(item, type);
1274
- handleChange('select');
1275
- clearInput();
1276
- popoverProps.isShow = false;
1277
- };
1278
- /**
1279
- * remove selected tag
1280
- * @param data tag data
1281
- * @param index tag index
1282
- * @param e mouse event
1283
- */
1284
-
1285
-
1286
- var handleTagRemove = function handleTagRemove(data, index, e) {
1287
- e === null || e === void 0 ? void 0 : e.stopPropagation();
1288
- removeTag(data, index);
1289
- clearInput();
1290
- handleChange('remove', data);
1291
- tagInputRef.value.style.width = "".concat(INPUT_MIN_WIDTH, "px");
1292
- };
1293
- /**
1294
- * emit trigger
1295
- * @param type emit type
1296
- */
1297
-
1298
-
1299
- var handleChange = function handleChange(type, data) {
1300
- // this.dispatch('bk-form-item', 'form-change')
1301
- emit(type, data);
1302
- emit('update:modelValue', tagList.value);
1303
- emit('change', tagList.value);
1304
- };
1305
- /**
1306
- * clear all selected tags
1307
- * @param e mouse event
1308
- */
1309
-
1310
-
1311
- var handleClear = function handleClear(e) {
1312
- e.stopPropagation();
1313
- var removeList = listState.selectedTagList;
1314
- listState.selectedTagList = []; // 将删除的项加入加列表
1315
-
1316
- var existList = removeList.filter(function (item) {
1317
- return saveKeyMap.value[item[props.saveKey]];
1318
- });
1319
-
1320
- if ((props.allowCreate && existList.length !== 0 || !props.allowCreate) && !isSingleSelect.value) {
1321
- var _listState$localList;
1322
-
1323
- (_listState$localList = listState.localList).push.apply(_listState$localList, _toConsumableArray(existList));
1324
- }
1325
-
1326
- handleChange('removeAll');
1327
- };
1328
-
1329
- var updateScrollTop = function updateScrollTop() {
1330
- // 获取下拉列表容器的位置信息,用于判断上下键选中的元素是否在可视区域,若不在则需滚动至可视区域
1331
- var panelInfo = {
1332
- height: selectorListRef.value.clientHeight,
1333
- yAxis: selectorListRef.value.getBoundingClientRect().y
1334
- };
1335
- (0,external_vue_.nextTick)(function () {
1336
- var activeObj = selectorListRef.value.querySelector('.bk-selector-actived');
1337
-
1338
- if (!activeObj) {
1339
- return;
1340
- }
1341
-
1342
- var activeInfo = {
1343
- height: activeObj.clientHeight,
1344
- yAxis: activeObj.getBoundingClientRect().y
1345
- }; // 选中元素顶部坐标大于容器顶部坐标时,则该元素有部分或者全部区域不在可视区域,执行滚动
1346
-
1347
- if (activeInfo.yAxis < panelInfo.yAxis) {
1348
- selectorListRef.value.scrollTop = selectorListRef.value.scrollTop - (panelInfo.yAxis - activeInfo.yAxis);
1349
- }
1350
-
1351
- var distanceToBottom = activeInfo.yAxis + activeInfo.height - panelInfo.yAxis; // 选中元素底部坐标大于容器顶部坐标,且超出容器的实际高度,则该元素有部分或者全部区域不在可视区域,执行滚动
1352
-
1353
- if (distanceToBottom > panelInfo.height) {
1354
- selectorListRef.value.scrollTop = selectorListRef.value.scrollTop + distanceToBottom - panelInfo.height;
1355
- }
1356
- });
1357
- };
1358
-
1359
- var backspaceHandler = function backspaceHandler(index, target) {
1360
- // 先交换输入框与被删除节点位置,再进行删除
1361
- var nodes = getSelectedTagNodes();
1362
- swapElementPositions(tagInputItemRef.value, nodes[index - 1]);
1363
- listState.selectedTagList.splice(index - 1, 1);
1364
- focusInputTrigger();
1365
- var isExistInit = saveKeyMap.value[target[props.saveKey]]; // 将删除的项加入加列表
1366
-
1367
- if ((props.allowCreate && isExistInit || !props.allowCreate) && !isSingleSelect.value) {
1368
- listState.localList.push(target);
1369
- }
1370
-
1371
- tagInputRef.value = "".concat(INPUT_MIN_WIDTH, "px");
1372
- handleChange('remove');
1373
- };
1374
-
1375
- var handleKeydown = function handleKeydown(e) {
1376
- if (pageState.isPageLoading) {
1377
- return;
1378
- }
1379
-
1380
- var target;
1381
- var val = e.target.value;
1382
- var valLen = getCharLength(val);
1383
- var tagInputItemIndex = getTagInputItemSite();
1384
- var nodes = getSelectedTagNodes();
1385
-
1386
- switch (e.code) {
1387
- case 'ArrowUp':
1388
- e.preventDefault();
1389
-
1390
- if (!popoverProps.isShow) {
1391
- return;
1392
- }
1393
-
1394
- state.focusItemIndex = state.focusItemIndex - 1;
1395
- state.focusItemIndex = state.focusItemIndex < 0 ? -1 : state.focusItemIndex;
1396
-
1397
- if (state.focusItemIndex === -1) {
1398
- state.focusItemIndex = pageState.curPageList.length - 1;
1399
- }
1400
-
1401
- updateScrollTop();
1402
- break;
1403
-
1404
- case 'ArrowDown':
1405
- e.preventDefault();
1406
-
1407
- if (!popoverProps.isShow) {
1408
- return;
1409
- }
1410
-
1411
- state.focusItemIndex = state.focusItemIndex + 1;
1412
- state.focusItemIndex = state.focusItemIndex > pageState.curPageList.length - 1 ? pageState.curPageList.length : state.focusItemIndex;
1413
-
1414
- if (state.focusItemIndex === pageState.curPageList.length) {
1415
- state.focusItemIndex = 0;
1416
- }
1417
-
1418
- updateScrollTop();
1419
- break;
1420
-
1421
- case 'ArrowLeft':
1422
- state.isEdit = true;
1423
-
1424
- if (!valLen) {
1425
- // 输入框已经是第一个节点,无法左移
1426
- if (tagInputItemIndex < 1) {
1427
- return;
1428
- }
1429
-
1430
- swapElementPositions(tagInputItemRef.value, nodes[tagInputItemIndex - 1]);
1431
- focusInputTrigger();
1432
- }
1433
-
1434
- break;
1435
-
1436
- case 'ArrowRight':
1437
- state.isEdit = true;
1438
-
1439
- if (!valLen) {
1440
- // 输入框已经是最后一个节点,无法右移
1441
- if (tagInputItemIndex === nodes.length - 1) {
1442
- return;
1443
- }
1444
-
1445
- swapElementPositions(nodes[tagInputItemIndex + 1], tagInputItemRef.value);
1446
- focusInputTrigger();
1447
- }
1448
-
1449
- break;
1450
-
1451
- case 'Enter':
1452
- case 'NumpadEnter':
1453
- if (!props.allowCreate && popoverProps.isShow || props.allowCreate && state.focusItemIndex >= 0 && popoverProps.isShow) {
1454
- handleTagSelected(pageState.curPageList[state.focusItemIndex], 'select', e);
1455
- } else if (props.allowCreate && curInputValue.value.trim()) {
1456
- handleTagSelected(curInputValue.value, 'custom', e);
1457
- } // 如果是enter, 防止触发form submit
1458
-
1459
-
1460
- e.preventDefault();
1461
- break;
1462
-
1463
- case 'Backspace':
1464
- if (tagInputItemIndex !== 0 && !curInputValue.value) {
1465
- target = listState.selectedTagList[tagInputItemIndex - 1];
1466
- backspaceHandler(tagInputItemIndex, target);
1467
- }
1468
-
1469
- break;
1470
-
1471
- default:
1472
- break;
1473
- }
1474
- };
1475
-
1476
- var defaultPasteFn = function defaultPasteFn(value) {
1477
- var target = [];
1478
- var textArr = value.split(';');
1479
- var regx = /^[a-zA-Z][a-zA-Z_]*/g;
1480
- textArr.forEach(function (item) {
1481
- var matchValue = item.match(regx);
1482
-
1483
- if (matchValue) {
1484
- var _target$push;
1485
-
1486
- var finalItem = matchValue.join('');
1487
- target.push((_target$push = {}, _defineProperty(_target$push, props.saveKey, finalItem), _defineProperty(_target$push, props.displayKey, finalItem), _target$push));
1488
- }
1489
- });
1490
- return target;
1491
- };
1492
-
1493
- var handlePaste = function handlePaste(e) {
1494
- e.preventDefault(); // 单选禁止复制粘贴,防止粘贴多个tag
1495
-
1496
- if (isSingleSelect.value) {
1497
- return false;
1498
- }
1499
-
1500
- var maxData = props.maxData,
1501
- saveKey = props.saveKey,
1502
- displayKey = props.displayKey,
1503
- pasteFn = props.pasteFn,
1504
- allowCreate = props.allowCreate;
1505
- var value = e.clipboardData.getData('text');
1506
- var valArr = pasteFn ? pasteFn(value) : defaultPasteFn(value);
1507
- var tags = valArr.map(function (value) {
1508
- return value[saveKey];
1509
- });
1510
-
1511
- if (tags.length) {
1512
- var nodes = getSelectedTagNodes();
1513
- var index = getTagInputItemSite();
1514
- var localInitData = listState.localList.map(function (data) {
1515
- return data[saveKey];
1516
- });
1517
- tags = tags.filter(function (tag) {
1518
- var canSelected = (tag === null || tag === void 0 ? void 0 : tag.trim()) && !tagList.value.includes(tag);
1519
- return allowCreate ? canSelected : canSelected && localInitData.includes(tag);
1520
- }); // 最大显示限制处理
1521
-
1522
- if (maxData !== -1) {
1523
- var selectedLength = listState.selectedTagList.length;
1524
-
1525
- if (selectedLength < maxData) {
1526
- var differ = maxData - selectedLength;
1527
-
1528
- if (tags.length > differ) {
1529
- tags = _toConsumableArray(tags.slice(0, differ));
1530
- }
1531
- } else {
1532
- tags = [];
1533
- }
1534
- }
1535
-
1536
- var localTags = allowCreate ? tags.map(function (tag) {
1537
- var _ref5;
1538
-
1539
- var localTag = listState.localList.find(function (localTag) {
1540
- return localTag[saveKey] === tag;
1541
- });
1542
- return localTag !== null && localTag !== void 0 ? localTag : (_ref5 = {}, _defineProperty(_ref5, saveKey, tag), _defineProperty(_ref5, displayKey, tag), _ref5);
1543
- }) : listState.localList.filter(function (tag) {
1544
- return tags.includes(tag[saveKey]);
1545
- });
1546
-
1547
- if (tags.length) {
1548
- var _listState$selectedTa;
1549
-
1550
- (_listState$selectedTa = listState.selectedTagList).splice.apply(_listState$selectedTa, [index, 0].concat(_toConsumableArray(localTags)));
1551
-
1552
- swapElementPositions(tagInputItemRef.value, nodes[index]);
1553
- tagInputRef.value.style.width = "".concat(INPUT_MIN_WIDTH, "px");
1554
- listState.localList = listState.localList.filter(function (val) {
1555
- return !tags.includes(val[saveKey]);
1556
- });
1557
- handleChange('select');
1558
- focusInputTrigger();
1559
- }
1560
- }
1561
- };
1562
- /**
1563
- * 已选中标签点击
1564
- * @param e mouse event
1565
- */
1566
-
1567
-
1568
- var tagFocus = function tagFocus(e) {
1569
- if (props.disabled) {
1570
- return;
1571
- }
1572
-
1573
- swapElementPositions(tagInputItemRef.value, e.currentTarget, true);
1574
- tagInputRef.value.style.width = "".concat(INPUT_MIN_WIDTH, "px");
1575
- popoverProps.isShow && changePopoverOffset();
1576
- };
1577
- /**
1578
- * add tag
1579
- * @param item current tag data
1580
- * @param type operation type
1581
- */
1582
-
1583
-
1584
- var addTag = function addTag(item, type) {
1585
- // 不允许超过最大可选数量
1586
- if (listState.selectedTagList.length >= props.maxData && props.maxData !== -1) return;
1587
- var separator = props.separator,
1588
- saveKey = props.saveKey,
1589
- displayKey = props.displayKey,
1590
- createTagValidator = props.createTagValidator;
1591
- var targetIndex = getTagInputItemSite();
1592
- var moveCount = 1;
1593
- var isSelected = false;
1594
- var newValue;
1595
-
1596
- var validateTag = function validateTag(value) {
1597
- if (typeof createTagValidator === 'function') {
1598
- return createTagValidator(value);
1599
- }
1600
-
1601
- return true;
1602
- }; // 自定义
1603
-
1604
-
1605
- if (type === 'custom') {
1606
- // 自定义时,如果配置分隔符可以一次性输入多个值
1607
- if (separator) {
1608
- var tags = item.split(separator);
1609
- tags = tags.filter(function (tag) {
1610
- return (tag === null || tag === void 0 ? void 0 : tag.trim()) && !tagList.value.includes(tag) && validateTag(tag);
1611
- });
1612
- var localTags = tags.map(function (tag) {
1613
- var _ref6;
1614
-
1615
- return saveKeyMap.value[tag] || (_ref6 = {}, _defineProperty(_ref6, saveKey, tag), _defineProperty(_ref6, displayKey, tag), _ref6);
1616
- });
1617
-
1618
- if (tags.length) {
1619
- var _listState$selectedTa2;
1620
-
1621
- (_listState$selectedTa2 = listState.selectedTagList).splice.apply(_listState$selectedTa2, [targetIndex, 0].concat(_toConsumableArray(localTags)));
1622
-
1623
- moveCount = localTags.length;
1624
- isSelected = true;
1625
- }
1626
- } else {
1627
- var isObject = _typeof(item) === 'object';
1628
- newValue = isObject ? item[saveKey] : item.trim();
1629
- newValue = newValue.replace(/\s+/g, '');
1630
-
1631
- if (newValue !== undefined && !tagList.value.includes(newValue) && validateTag(newValue)) {
1632
- var _ref7;
1633
-
1634
- var localItem = saveKeyMap.value[newValue] || (isObject ? item : (_ref7 = {}, _defineProperty(_ref7, saveKey, newValue), _defineProperty(_ref7, displayKey, newValue), _ref7));
1635
- listState.selectedTagList.splice(targetIndex, 0, localItem);
1636
- isSelected = true;
1637
- }
1638
- }
1639
- } else if (item) {
1640
- newValue = item[saveKey];
1641
-
1642
- if (newValue !== undefined && !tagList.value.includes(newValue)) {
1643
- listState.selectedTagList.splice(targetIndex, 0, item);
1644
- isSelected = true;
1645
- }
1646
- }
1647
-
1648
- if (isSelected) {
1649
- (0,external_vue_.nextTick)(function () {
1650
- for (var count = 1; count <= moveCount; count++) {
1651
- var nodes = getSelectedTagNodes();
1652
- var site = nodes[targetIndex + count];
1653
- swapElementPositions(site, tagInputItemRef.value);
1654
- }
1655
-
1656
- tagInputRef.value.style.width = "".concat(INPUT_MIN_WIDTH, "px"); // 非单选
1657
-
1658
- if (!isSingleSelect.value) {
1659
- // focus继续让用户进行下一个输入
1660
- props.allowNextFocus && focusInputTrigger(); // 将已经选中的项从数据列表中去除
1661
-
1662
- var selectedMap = tagList.value.reduce(function (acc, tag) {
1663
- acc[tag] = 1;
1664
- return acc;
1665
- }, {});
1666
- listState.localList = listState.localList.filter(function (val) {
1667
- return !selectedMap[val[saveKey]];
1668
- });
1669
- }
1670
- });
1671
- }
1672
- };
1673
- /**
1674
- * remove current tag
1675
- * @param data tag data
1676
- * @param index tag index
1677
- */
1678
-
1679
-
1680
- var removeTag = function removeTag(data, index) {
1681
- listState.selectedTagList.splice(index, 1);
1682
- var isExistInit = saveKeyMap.value[data[props.saveKey]]; // 将删除的项加入加列表
1683
-
1684
- if ((props.allowCreate && isExistInit || !props.allowCreate) && !isSingleSelect.value) {
1685
- listState.localList.push(data);
1686
- }
1687
- }; // 折叠 tags index
1688
-
1689
-
1690
- var localCollapseTags = (0,external_vue_.computed)(function () {
1691
- return props.collapseTags ? props.collapseTags && !state.isEdit : props.collapseTags;
1692
- });
1693
-
1694
- var _useTagsOverflow = useTagsOverflow(bkTagSelectorRef, localCollapseTags, tagList),
1695
- overflowTagIndex = _useTagsOverflow.overflowTagIndex;
1696
-
1697
- return Object.assign(Object.assign(Object.assign(Object.assign({
1698
- popoverProps: popoverProps
1699
- }, (0,external_vue_.toRefs)(state)), (0,external_vue_.toRefs)(listState)), (0,external_vue_.toRefs)(pageState)), {
1700
- isShowPlaceholder: isShowPlaceholder,
1701
- isShowClear: isShowClear,
1702
- curInputValue: curInputValue,
1703
- renderList: renderList,
1704
- showTagClose: showTagClose,
1705
- tagInputRef: tagInputRef,
1706
- bkTagSelectorRef: bkTagSelectorRef,
1707
- tagListRef: tagListRef,
1708
- tagInputItemRef: tagInputItemRef,
1709
- selectorListRef: selectorListRef,
1710
- triggerClass: triggerClass,
1711
- overflowTagIndex: overflowTagIndex,
1712
- localCollapseTags: localCollapseTags,
1713
- focusInputTrigger: focusInputTrigger,
1714
- activeClass: activeClass,
1715
- handleInput: handleInput,
1716
- handleFocus: handleFocus,
1717
- handleBlur: handleBlur,
1718
- handleTagSelected: handleTagSelected,
1719
- handleTagRemove: handleTagRemove,
1720
- handleClear: handleClear,
1721
- tagFocus: tagFocus,
1722
- handleKeydown: handleKeydown,
1723
- handlePaste: handlePaste
1724
- });
1725
- },
1726
- render: function render() {
1727
- var _this = this;
1728
-
1729
- return (0,external_vue_.createVNode)("div", {
1730
- "class": "bk-tag-input",
1731
- "ref": "bkTagSelectorRef",
1732
- "onClick": this.focusInputTrigger,
1733
- "onMouseenter": function onMouseenter() {
1734
- return _this.isHover = true;
1735
- },
1736
- "onMouseleave": function onMouseleave() {
1737
- return _this.isHover = false;
1738
- }
1739
- }, [(0,external_vue_.createVNode)((external_popover_default()), (0,external_vue_.mergeProps)({
1740
- "theme": "light bk-tag-input-popover-content",
1741
- "trigger": "manual",
1742
- "placement": "bottom-start",
1743
- "arrow": false
1744
- }, this.popoverProps), {
1745
- "default": function _default() {
1746
- var _a, _b, _c;
1747
-
1748
- return (0,external_vue_.createVNode)("div", {
1749
- "class": _this.triggerClass
1750
- }, [(0,external_vue_.createVNode)("ul", {
1751
- "class": "tag-list",
1752
- "ref": "tagListRef",
1753
- "style": {
1754
- marginLeft: "".concat(_this.leftSpace, "px")
1755
- }
1756
- }, [_this.selectedTagList.map(function (item, index) {
1757
- var tooltips = {
1758
- boundary: 'window',
1759
- theme: 'light',
1760
- distance: 12,
1761
- content: item[_this.tooltipKey],
1762
- disabled: !_this.tooltipKey
1763
- };
1764
- var isOverflow = _this.localCollapseTags && _this.overflowTagIndex && index >= _this.overflowTagIndex;
1765
- return (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("li", {
1766
- "class": "tag-item",
1767
- "style": {
1768
- display: isOverflow ? 'none' : ''
1769
- },
1770
- "onClick": _this.tagFocus
1771
- }, [(0,external_vue_.createVNode)(tag_render, {
1772
- "node": item,
1773
- "tpl": _this.tagTpl,
1774
- "displayKey": _this.displayKey,
1775
- "hasTips": !!_this.tooltipKey,
1776
- "tagOverflowTips": _this.tagOverflowTips
1777
- }, null), _this.showTagClose ? (0,external_vue_.createVNode)(external_icon_.Error, {
1778
- "class": "remove-tag",
1779
- "onClick": _this.handleTagRemove.bind(_this, item, index)
1780
- }, null) : null]), [[(0,external_vue_.resolveDirective)("bk-tooltips"), tooltips]]);
1781
- }), (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("li", {
1782
- "ref": "tagInputItemRef",
1783
- "id": "tagInputItem",
1784
- "class": "tag-input-item",
1785
- "role": "input"
1786
- }, [(0,external_vue_.withDirectives)((0,external_vue_.createVNode)("input", {
1787
- "type": "text",
1788
- "class": "tag-input",
1789
- "ref": "tagInputRef",
1790
- "onUpdate:modelValue": function onUpdateModelValue($event) {
1791
- return _this.curInputValue = $event;
1792
- },
1793
- "onInput": _this.handleInput,
1794
- "onFocus": _this.handleFocus,
1795
- "onBlur": _this.handleBlur,
1796
- "onKeydown": _this.handleKeydown,
1797
- "onPaste": _this.handlePaste
1798
- }, null), [[external_vue_.vModelText, _this.curInputValue]])]), [[external_vue_.vShow, _this.isEdit]]), !!_this.overflowTagIndex && _this.localCollapseTags && (0,external_vue_.createVNode)("li", {
1799
- "class": "tag-item"
1800
- }, [(0,external_vue_.createVNode)("div", {
1801
- "class": "tag"
1802
- }, [(0,external_vue_.createVNode)("span", {
1803
- "class": "text"
1804
- }, [(0,external_vue_.createTextVNode)("+"), _this.selectedTagList.length - _this.overflowTagIndex])])])]), (0,external_vue_.withDirectives)((0,external_vue_.createVNode)("p", {
1805
- "class": "placeholder"
1806
- }, [_this.placeholder]), [[external_vue_.vShow, _this.isShowPlaceholder]]), (_c = (_b = (_a = _this.$slots) === null || _a === void 0 ? void 0 : _a.suffix) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : _this.isShowClear && (0,external_vue_.createVNode)(external_icon_.Close, {
1807
- "class": "clear-icon",
1808
- "onClick": _this.handleClear
1809
- }, null)]);
1810
- },
1811
- content: function content() {
1812
- return (0,external_vue_.createVNode)("div", {
1813
- "class": "bk-selector-list"
1814
- }, [(0,external_vue_.createVNode)("ul", {
1815
- "ref": "selectorListRef",
1816
- "style": {
1817
- 'max-height': "".concat(_this.contentMaxHeight, "px")
1818
- },
1819
- "class": "outside-ul"
1820
- }, [_this.renderList.map(function (group, index) {
1821
- return _this.useGroup ? (0,external_vue_.createVNode)("li", {
1822
- "class": "bk-selector-group-item"
1823
- }, [(0,external_vue_.createVNode)("span", {
1824
- "class": "group-name"
1825
- }, [group.name, (0,external_vue_.createTextVNode)(" ("), group.children.length, (0,external_vue_.createTextVNode)(")")]), (0,external_vue_.createVNode)("ul", {
1826
- "class": "bk-selector-group-list-item"
1827
- }, [group.children.map(function (item, index) {
1828
- return (0,external_vue_.createVNode)("li", {
1829
- "class": ['bk-selector-list-item', {
1830
- disabled: item.disabled
1831
- }, _this.activeClass(item, index)],
1832
- "onClick": _this.handleTagSelected.bind(_this, item, 'select')
1833
- }, [(0,external_vue_.createVNode)(list_tag_render, {
1834
- "node": item,
1835
- "displayKey": _this.displayKey,
1836
- "tpl": _this.tpl,
1837
- "searchKey": _this.searchKey,
1838
- "searchKeyword": _this.curInputValue
1839
- }, null)]);
1840
- })])]) : (0,external_vue_.createVNode)("li", {
1841
- "class": ['bk-selector-list-item', {
1842
- disabled: group.disabled
1843
- }, _this.activeClass(group, index)],
1844
- "onClick": _this.handleTagSelected.bind(_this, group, 'select')
1845
- }, [(0,external_vue_.createVNode)(list_tag_render, {
1846
- "node": group,
1847
- "displayKey": _this.displayKey,
1848
- "tpl": _this.tpl,
1849
- "searchKey": _this.searchKey,
1850
- "searchKeyword": _this.curInputValue
1851
- }, null)]);
1852
- }), _this.isPageLoading ? (0,external_vue_.createVNode)("li", {
1853
- "class": "bk-selector-list-item loading"
1854
- }, [(0,external_vue_.createVNode)((external_loading_default()), {
1855
- "theme": "primary",
1856
- "size": external_loading_.BkLoadingSize.Small
1857
- }, null)]) : null])]);
1858
- }
1859
- })]);
1860
- }
1861
- }));
1862
- ;// CONCATENATED MODULE: ../../packages/tag-input/src/index.ts
1863
- /*
1864
- * Tencent is pleased to support the open source community by making
1865
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) available.
1866
- *
1867
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
1868
- *
1869
- * 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition) is licensed under the MIT License.
1870
- *
1871
- * License for 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community Edition):
1872
- *
1873
- * ---------------------------------------------------
1874
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
1875
- * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
1876
- * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
1877
- * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
1878
- *
1879
- * The above copyright notice and this permission notice shall be included in all copies or substantial portions of
1880
- * the Software.
1881
- *
1882
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
1883
- * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1884
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
1885
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
1886
- * IN THE SOFTWARE.
1887
- */
1888
-
1889
-
1890
- var TagInput = (0,external_shared_.withInstall)(tag_input);
1891
- /* harmony default export */ const src = (TagInput);
1892
- })();
1893
-
1894
- /******/ return __webpack_exports__;
1895
- /******/ })()
1896
- ;
1897
- });
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon"),require("../loading"),require("../popover"),require("vue-types"));else if("function"==typeof define&&define.amd)define(["../shared","vue","lodash","../directives","../icon","../loading","../popover","vue-types"],t);else{var r="object"==typeof exports?t(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon"),require("../loading"),require("../popover"),require("vue-types")):t(e["../shared"],e.vue,e.lodash,e["../directives"],e["../icon"],e["../loading"],e["../popover"],e["vue-types"]);for(var a in r)("object"==typeof exports?exports:e)[a]=r[a]}}(self,((e,t,r,a,o,n,l,i)=>(()=>{"use strict";var s={4061:e=>{e.exports=a},6870:e=>{e.exports=o},4870:e=>{e.exports=n},5537:e=>{e.exports=l},4212:t=>{t.exports=e},467:e=>{e.exports=r},748:e=>{e.exports=t},210:e=>{e.exports=i}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var r=u[e]={exports:{}};return s[e](r,r.exports,c),r.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var d={};return(()=>{c.r(d),c.d(d,{default:()=>L});var e=c(4212);function t(e){return t="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},t(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function a(e,t){if(e){if("string"==typeof e)return r(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?r(e,t):void 0}}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(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 l=c(748),i=c(467),s=c(4061),u=c(6870),p=c(4870),f=c.n(p),v=c(5537),g=c.n(v),h=12,y=function(e){for(var t=e.length,r=0,a=0;a<t;a++)0!=(65280&e.charCodeAt(a))&&(r+=1),r+=1;return r};const m=(0,l.defineComponent)({name:"ListTagRender",props:{node:e.PropTypes.object,searchKey:e.PropTypes.oneOfType([e.PropTypes.string,e.PropTypes.arrayOf(e.PropTypes.string)]),displayKey:e.PropTypes.string,searchKeyword:e.PropTypes.string,tpl:{type:Function}},render:function(){var e=this,t=function(t){if(e.searchKeyword){var r=new RegExp("(".concat(e.searchKeyword,")"),"i");return t.replace(r,'<strong class="highlight-text">$1</strong>')}return t};if(this.tpl)return this.tpl(this.node,t,l.h,this);var r=this.node[this.displayKey];return(0,l.createVNode)("div",{class:"bk-selector-node"},[(0,l.createVNode)("span",{class:"text",innerHTML:t(r)},[r])])}});var T,b=c(210);!function(e){e.FOCUS="focus",e.SEARCH="search"}(T||(T={}));const w=(0,l.defineComponent)({name:"TagRender",directives:{bkTooltips:s.bkTooltips},props:{node:e.PropTypes.object,displayKey:e.PropTypes.string,tpl:{type:Function},hasTips:{type:Boolean,default:!1},tagOverflowTips:{type:Object,default:function(){return{}}}},setup:function(t){var r=(0,l.ref)(),a=(0,l.ref)(!1),o=(0,l.computed)((function(){return Object.assign({boundary:"window",theme:"light",distance:12,content:t.node[t.displayKey],disabled:t.hasTips||!a.value},t.tagOverflowTips)}));return(0,l.onMounted)((function(){a.value=(0,e.checkOverflow)(r.value)})),{overflowTips:o,tagRef:r}},render:function(){return this.tpl?this.tpl(this.node,l.h,this):(0,l.withDirectives)((0,l.createVNode)("div",{class:"tag",ref:"tagRef"},[(0,l.createVNode)("span",{class:"text"},[this.node[this.displayKey]])]),[[(0,l.resolveDirective)("bk-tooltips"),this.overflowTips]])}}),x=(0,l.defineComponent)({name:"TagInput",directives:{bkTooltips:s.bkTooltips},props:{modelValue:e.PropTypes.arrayOf(e.PropTypes.string).def([]),placeholder:e.PropTypes.string.def("请输入并按 Enter 结束"),list:e.PropTypes.arrayOf(e.PropTypes.object).def([]),disabled:e.PropTypes.bool.def(!1),tooltipKey:e.PropTypes.string.def(""),saveKey:e.PropTypes.string.def("id"),displayKey:e.PropTypes.string.def("name"),hasDeleteIcon:e.PropTypes.bool.def(!1),clearable:e.PropTypes.bool.def(!0),trigger:(0,b.toType)("treeTriggerType",{}).def(T.SEARCH),searchKey:e.PropTypes.oneOfType([e.PropTypes.string,e.PropTypes.arrayOf(e.PropTypes.string)]).def("name"),useGroup:e.PropTypes.bool.def(!1),allowCreate:e.PropTypes.bool.def(!1),maxData:e.PropTypes.number.def(-1),maxResult:e.PropTypes.number.def(10),contentMaxHeight:e.PropTypes.number.def(300),contentWidth:e.PropTypes.number.def(190),separator:e.PropTypes.string.def(""),allowNextFocus:e.PropTypes.bool.def(!0),allowAutoMatch:e.PropTypes.bool.def(!1),showClearOnlyHover:e.PropTypes.bool.def(!1),leftSpace:e.PropTypes.number.def(0),createTagValidator:{type:Function},filterCallback:{type:Function},tagTpl:{type:Function},tpl:{type:Function},pasteFn:{type:Function},withValidate:{type:Boolean,default:!0},popoverProps:{type:Object,default:function(){return{}}},collapseTags:{type:Boolean,default:!1},tagOverflowTips:{type:Object,default:function(){return{}}}},emits:["update:modelValue","change","select","focus","blur","remove","removeAll","input"],setup:function(r,s){var u=s.emit,c=(0,e.useFormItem)(),d=(0,l.reactive)({isEdit:!1,isHover:!1,focusItemIndex:r.allowCreate?-1:0}),p=(0,l.reactive)(Object.assign({isShow:!1,width:190,offset:{mainAxis:4,crossAxis:0}},r.popoverProps)),f=function(e){var t=(0,l.reactive)({curPage:1,totalSize:0,totalPage:0,pageSize:e,isPageLoading:!1,curPageList:[],renderListPaged:[]});return{pageState:t,initPage:function(){var e,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t.curPage=1,t.totalSize=a.length,t.totalPage=Math.ceil(t.totalSize/t.pageSize)||1;var o=[];if(t.pageSize>0)for(var l=0;l<t.totalSize;l+=t.pageSize)o.push(a.slice(l,l+t.pageSize));(e=t.renderListPaged).splice.apply(e,[0,t.renderListPaged.length].concat(o)),(r=t.curPageList).splice.apply(r,[0,t.curPageList.length].concat(n(t.renderListPaged[t.curPage-1]||[])))},pageChange:function(e){var r;t.curPage=e,(r=t.curPageList).splice.apply(r,[t.curPageList.length,0].concat(n(t.renderListPaged[t.curPage-1]||[]))),t.isPageLoading=!1}}}((0,l.toRefs)(r).maxResult),v=f.pageState,g=f.initPage,m=f.pageChange,T=(0,l.ref)(""),b=(0,l.ref)(null),w=(0,l.ref)(null),x=(0,l.ref)(null),L=(0,l.ref)(null),P=(0,l.ref)(null),I=(0,l.ref)(null),C=(0,l.computed)((function(){return!r.disabled&&r.hasDeleteIcon})),S=(0,l.computed)((function(){return 1===r.maxData})),K=(0,l.computed)((function(){return 0===N.selectedTagList.length&&""===T.value&&!d.isEdit})),k=(0,l.computed)((function(){return r.clearable&&!r.disabled&&0!==N.selectedTagList.length&&(!r.showClearOnlyHover||d.isHover)})),V=(0,l.computed)((function(){return{"bk-tag-input-trigger":!0,active:d.isEdit,disabled:r.disabled}})),N=(0,l.reactive)({localList:[],tagListCache:[],selectedTagList:[],selectedTagListCache:[]}),O=(0,l.computed)((function(){return N.selectedTagList.map((function(e){return e[r.saveKey]}))})),A=function(e){var t=(0,l.toRefs)(e),r=t.useGroup,a=t.saveKey,o=t.displayKey,n=t.list,i=(0,l.ref)([]),s=(0,l.ref)({});return(0,l.watch)([r,a,o,n],(function(){i.value=[];var e=(0,l.markRaw)(n.value);r.value&&(e=e.reduce((function(e,t){var r=[];return t.children&&(r=t.children.map((function(e){return Object.assign({group:{groupId:t[a.value],groupName:t[o.value]}},e)}))),e.concat(r)}),[])),i.value=e,s.value=e.reduce((function(e,t){return e[t[a.value]]=t,e}),{})}),{immediate:!0,deep:!0}),{flatList:i,saveKeyMap:s}}(r),R=A.flatList,j=A.saveKeyMap,E=(0,l.computed)((function(){if(r.useGroup){var e={};return v.curPageList.forEach((function(t,r){t.__index__=r,e[t.group.groupId]||(e[t.group.groupId]={id:t.group.groupId,name:t.group.groupName,children:[]}),e[t.group.groupId].children.push(t)})),Object.keys(e).map((function(t){return e[t]}))}return v.curPageList}));(0,l.watch)([function(){return R.value}],(function(){(0,l.nextTick)((function(){H()}))}),{deep:!0}),(0,l.watch)((function(){return r.modelValue}),(function(e){var t,a,o;o=e,(a=O.value).length===o.length&&o.every((function(e,t){return a[t]===e}))||((0,l.nextTick)((function(){H()})),r.withValidate&&(null===(t=null==c?void 0:c.validate)||void 0===t||t.call(c,"change")))})),(0,l.watch)(T,(0,i.debounce)((function(){var e=0!==v.curPageList.length,t=T.value;""!==t&&e||""===t&&"focus"===r.trigger&&e?p.isShow=!0:"focus"===r.trigger&&e||(p.isShow=!1)}),150)),(0,l.watch)((function(){return p.isShow}),(function(e){D(),e&&P.value&&((0,l.nextTick)((function(){P.value.scrollTop=0})),P.value.removeEventListener("scroll",M),P.value.addEventListener("scroll",M))})),(0,l.onMounted)((function(){H()}));var D=function(){var e;p.offset.crossAxis=S.value?0:null===(e=L.value)||void 0===e?void 0:e.offsetLeft},M=function(){if(!v.isPageLoading&&0!==P.value.scrollTop){var e=P.value;if(e.scrollTop+e.offsetHeight>=e.scrollHeight){var t=v.curPage+1;t<=v.totalPage&&(v.isPageLoading=!0,setTimeout((function(){m(t)}),500))}}},q=function(){var e;return Array.from((null===(e=x.value)||void 0===e?void 0:e.childNodes)||[]).filter((function(e){return![Node.TEXT_NODE,Node.COMMENT_NODE].includes(e.nodeType)}))},F=function(e){if(!r.disabled){if(null==e?void 0:e.target){var t=e.target.className;(t.indexOf("bk-tag-input-trigger")>-1||t.indexOf("tag-list")>-1)&&x.value.appendChild(L.value)}clearTimeout(I.value),S.value&&O.value.length&&(N.tagListCache=n(O.value),N.selectedTagListCache=n(N.selectedTagList),T.value=N.selectedTagListCache[0][r.saveKey],Q(N.selectedTagList[0],0),U()),d.isEdit=!0,(0,l.nextTick)((function(){var e;null===(e=b.value)||void 0===e||e.focus(),"focus"===r.trigger&&0!==N.localList.length&&(_(),p.isShow?D():p.isShow=!0)}))}},H=function(){var e=r.saveKey,t=r.modelValue,a=r.displayKey,n=r.allowCreate,l=r.trigger;if(N.selectedTagList=[],N.localList=R.value,t.length){var i={};N.selectedTagList=t.map((function(t){var r,l=j.value[t];return i[t]=1,!l&&n?(o(r={},e,t),o(r,a,t),r):l})).filter((function(e){return e})),S.value||(N.localList=N.localList.filter((function(t){return!i[t[e]]})))}"focus"===l&&_()},_=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=r.searchKey,a=r.filterCallback,o=e.toLowerCase().trim();if(""!==o){var n=[];n="function"==typeof a?a(o,t,N.localList)||[]:Array.isArray(t)?N.localList.filter((function(e){return t.some((function(t){return e[t].toLowerCase().indexOf(o)>-1}))})):N.localList.filter((function(e){return e[t].toLowerCase().indexOf(o)>-1})),g(n)}else g(N.localList)},z=function(){T.value=""},B=function(){if(S.value)return 0;var e=q().findIndex((function(e){return"tagInputItem"===e.id}));return e>=0?e:0},G=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&e){var a=t;r&&(a=t.nextElementSibling||null),t.parentNode.insertBefore(e,a)}},U=function(e){var t=r.maxData,a=r.trigger,o=r.allowCreate;if(-1===t||t>O.value.length){var n=((null==e?void 0:e.target)?e.target:T).value,l=y(n);l?(_(n),b.value.style.width="".concat(l*h,"px")):"focus"===a&&_()}else W(),T.value="",p.isShow=!1;d.isEdit=!0,d.focusItemIndex=o?-1:0,u("input",T.value)},W=function(){I.value=setTimeout((function(){var e,t,o,n=T.value;if(z(),d.isEdit=!1,S.value){var l=(t=N.tagListCache,o=1,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a,o,n=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(a=r.next()).done)&&(n.push(a.value),!t||n.length!==t);l=!0);}catch(e){i=!0,o=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw o}}return n}}(t,o)||a(t,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];n&&n===l&&N.selectedTagListCache.length?J(N.selectedTagListCache[0],"select"):Z("remove")}else if(r.allowAutoMatch&&n){var i=v.curPageList.find((function(e){return Array.isArray(r.searchKey)?r.searchKey.map((function(t){return e[t]})).includes(n):e[r.searchKey]===n}));i?$(i,"select"):r.allowCreate&&$(n,"custom")}p.isShow=!1,u("blur",n,O.value),null===(e=null==c?void 0:c.validate)||void 0===e||e.call(c,"blur")}),200)},$=function(e,t,r){null==r||r.stopPropagation(),e&&!e.disabled&&(S.value&&(N.tagListCache=[],N.selectedTagListCache=[],N.selectedTagList=[]),J(e,t),Z("select"),z(),p.isShow=!1)},Z=function(e,t){u(e,t),u("update:modelValue",O.value),u("change",O.value)},X=function(){var e=P.value.clientHeight,t=P.value.getBoundingClientRect().y;(0,l.nextTick)((function(){var r=P.value.querySelector(".bk-selector-actived");if(r){var a=r.clientHeight,o=r.getBoundingClientRect().y;o<t&&(P.value.scrollTop=P.value.scrollTop-(t-o));var n=o+a-t;n>e&&(P.value.scrollTop=P.value.scrollTop+n-e)}}))},J=function(e,a){if(!(N.selectedTagList.length>=r.maxData&&-1!==r.maxData)){var i,s=r.separator,u=r.saveKey,c=r.displayKey,d=r.createTagValidator,p=B(),f=1,v=!1,g=function(e){return"function"!=typeof d||d(e)};if("custom"===a)if(s){var y,m=e.split(s),T=(m=m.filter((function(e){return(null==e?void 0:e.trim())&&!O.value.includes(e)&&g(e)}))).map((function(e){var t;return j.value[e]||(o(t={},u,e),o(t,c,e),t)}));m.length&&((y=N.selectedTagList).splice.apply(y,[p,0].concat(n(T))),f=T.length,v=!0)}else{var w="object"===t(e);if(void 0!==(i=(i=w?e[u]:e.trim()).replace(/\s+/g,""))&&!O.value.includes(i)&&g(i)){var x,P=j.value[i]||(w?e:(o(x={},u,i),o(x,c,i),x));N.selectedTagList.splice(p,0,P),v=!0}}else e&&(void 0===(i=e[u])||O.value.includes(i)||(N.selectedTagList.splice(p,0,e),v=!0));v&&(0,l.nextTick)((function(){for(var e=1;e<=f;e++){var t=q()[p+e];G(t,L.value)}if(b.value.style.width="".concat(h,"px"),!S.value){r.allowNextFocus&&F();var a=O.value.reduce((function(e,t){return e[t]=1,e}),{});N.localList=N.localList.filter((function(e){return!a[e[u]]}))}}))}},Q=function(e,t){N.selectedTagList.splice(t,1);var a=j.value[e[r.saveKey]];(r.allowCreate&&a||!r.allowCreate)&&!S.value&&N.localList.push(e)},Y=(0,l.computed)((function(){return r.collapseTags?r.collapseTags&&!d.isEdit:r.collapseTags})),ee=function(e,t,r){(0,l.watch)([r,t],(function(){o()}),{flush:"post"});var a=(0,l.ref)(null),o=function(){t.value&&(a.value=null,setTimeout((function(){var t=Array.from(e.value.querySelectorAll(".tag-item")),r=t.findIndex((function(e,r){return!!r&&t[r-1].offsetTop!==e.offsetTop}));a.value=r>0?r-1:null})))};return{overflowTagIndex:a}}(w,Y,O),te=ee.overflowTagIndex;return Object.assign(Object.assign(Object.assign(Object.assign({popoverProps:p},(0,l.toRefs)(d)),(0,l.toRefs)(N)),(0,l.toRefs)(v)),{isShowPlaceholder:K,isShowClear:k,curInputValue:T,renderList:E,showTagClose:C,tagInputRef:b,bkTagSelectorRef:w,tagListRef:x,tagInputItemRef:L,selectorListRef:P,triggerClass:V,overflowTagIndex:te,localCollapseTags:Y,focusInputTrigger:F,activeClass:function(e,t){var a={"bk-selector-actived":!1,"bk-selector-selected":O.value.includes(e[r.saveKey])};return r.useGroup?a["bk-selector-actived"]=e.__index__===d.focusItemIndex:a["bk-selector-actived"]=t===d.focusItemIndex,a},handleInput:U,handleFocus:function(){var e;p.width=S.value?null===(e=w.value)||void 0===e?void 0:e.clientWidth:r.contentWidth,u("focus")},handleBlur:W,handleTagSelected:$,handleTagRemove:function(e,t,r){null==r||r.stopPropagation(),Q(e,t),z(),Z("remove",e),b.value.style.width="".concat(h,"px")},handleClear:function(e){e.stopPropagation();var t=N.selectedTagList;N.selectedTagList=[];var a,o=t.filter((function(e){return j.value[e[r.saveKey]]}));(!r.allowCreate||0===o.length)&&r.allowCreate||S.value||(a=N.localList).push.apply(a,n(o)),Z("removeAll")},tagFocus:function(e){r.disabled||(G(L.value,e.currentTarget,!0),b.value.style.width="".concat(h,"px"),p.isShow&&D())},handleKeydown:function(e){if(!v.isPageLoading){var t=e.target.value,a=y(t),o=B(),n=q();switch(e.code){case"ArrowUp":if(e.preventDefault(),!p.isShow)return;d.focusItemIndex=d.focusItemIndex-1,d.focusItemIndex=d.focusItemIndex<0?-1:d.focusItemIndex,-1===d.focusItemIndex&&(d.focusItemIndex=v.curPageList.length-1),X();break;case"ArrowDown":if(e.preventDefault(),!p.isShow)return;d.focusItemIndex=d.focusItemIndex+1,d.focusItemIndex=d.focusItemIndex>v.curPageList.length-1?v.curPageList.length:d.focusItemIndex,d.focusItemIndex===v.curPageList.length&&(d.focusItemIndex=0),X();break;case"ArrowLeft":if(d.isEdit=!0,!a){if(o<1)return;G(L.value,n[o-1]),F()}break;case"ArrowRight":if(d.isEdit=!0,!a){if(o===n.length-1)return;G(n[o+1],L.value),F()}break;case"Enter":case"NumpadEnter":!r.allowCreate&&p.isShow||r.allowCreate&&d.focusItemIndex>=0&&p.isShow?$(v.curPageList[d.focusItemIndex],"select",e):r.allowCreate&&T.value.trim()&&$(T.value,"custom",e),e.preventDefault();break;case"Backspace":0===o||T.value||function(e,t){var a=q();G(L.value,a[e-1]),N.selectedTagList.splice(e-1,1),F();var o=j.value[t[r.saveKey]];(r.allowCreate&&o||!r.allowCreate)&&!S.value&&N.localList.push(t),b.value="".concat(h,"px"),Z("remove")}(o,N.selectedTagList[o-1])}}},handlePaste:function(e){if(e.preventDefault(),S.value)return!1;var t=r.maxData,a=r.saveKey,l=r.displayKey,i=r.pasteFn,s=r.allowCreate,u=e.clipboardData.getData("text"),c=i?i(u):function(e){var t=[],a=e.split(";"),n=/^[a-zA-Z][a-zA-Z_]*/g;return a.forEach((function(e){var a=e.match(n);if(a){var l,i=a.join("");t.push((o(l={},r.saveKey,i),o(l,r.displayKey,i),l))}})),t}(u),d=c.map((function(e){return e[a]}));if(d.length){var p=q(),f=B(),v=N.localList.map((function(e){return e[a]}));if(d=d.filter((function(e){var t=(null==e?void 0:e.trim())&&!O.value.includes(e);return s?t:t&&v.includes(e)})),-1!==t){var g=N.selectedTagList.length;if(g<t){var y=t-g;d.length>y&&(d=n(d.slice(0,y)))}else d=[]}var m,T=s?d.map((function(e){var t,r=N.localList.find((function(t){return t[a]===e}));return null!=r?r:(o(t={},a,e),o(t,l,e),t)})):N.localList.filter((function(e){return d.includes(e[a])}));d.length&&((m=N.selectedTagList).splice.apply(m,[f,0].concat(n(T))),G(L.value,p[f]),b.value.style.width="".concat(h,"px"),N.localList=N.localList.filter((function(e){return!d.includes(e[a])})),Z("select"),F())}}})},render:function(){var e=this;return(0,l.createVNode)("div",{class:"bk-tag-input",ref:"bkTagSelectorRef",onClick:this.focusInputTrigger,onMouseenter:function(){return e.isHover=!0},onMouseleave:function(){return e.isHover=!1}},[(0,l.createVNode)(g(),(0,l.mergeProps)({theme:"light bk-tag-input-popover-content",trigger:"manual",placement:"bottom-start",arrow:!1},this.popoverProps),{default:function(){var t,r,a;return(0,l.createVNode)("div",{class:e.triggerClass},[(0,l.createVNode)("ul",{class:"tag-list",ref:"tagListRef",style:{marginLeft:"".concat(e.leftSpace,"px")}},[e.selectedTagList.map((function(t,r){var a={boundary:"window",theme:"light",distance:12,content:t[e.tooltipKey],disabled:!e.tooltipKey},o=e.localCollapseTags&&e.overflowTagIndex&&r>=e.overflowTagIndex;return(0,l.withDirectives)((0,l.createVNode)("li",{class:"tag-item",style:{display:o?"none":""},onClick:e.tagFocus},[(0,l.createVNode)(w,{node:t,tpl:e.tagTpl,displayKey:e.displayKey,hasTips:!!e.tooltipKey,tagOverflowTips:e.tagOverflowTips},null),e.showTagClose?(0,l.createVNode)(u.Error,{class:"remove-tag",onClick:e.handleTagRemove.bind(e,t,r)},null):null]),[[(0,l.resolveDirective)("bk-tooltips"),a]])})),(0,l.withDirectives)((0,l.createVNode)("li",{ref:"tagInputItemRef",id:"tagInputItem",class:"tag-input-item",role:"input"},[(0,l.withDirectives)((0,l.createVNode)("input",{type:"text",class:"tag-input",ref:"tagInputRef","onUpdate:modelValue":function(t){return e.curInputValue=t},onInput:e.handleInput,onFocus:e.handleFocus,onBlur:e.handleBlur,onKeydown:e.handleKeydown,onPaste:e.handlePaste},null),[[l.vModelText,e.curInputValue]])]),[[l.vShow,e.isEdit]]),!!e.overflowTagIndex&&e.localCollapseTags&&(0,l.createVNode)("li",{class:"tag-item"},[(0,l.createVNode)("div",{class:"tag"},[(0,l.createVNode)("span",{class:"text"},[(0,l.createTextVNode)("+"),e.selectedTagList.length-e.overflowTagIndex])])])]),(0,l.withDirectives)((0,l.createVNode)("p",{class:"placeholder"},[e.placeholder]),[[l.vShow,e.isShowPlaceholder]]),null!==(a=null===(r=null===(t=e.$slots)||void 0===t?void 0:t.suffix)||void 0===r?void 0:r.call(t))&&void 0!==a?a:e.isShowClear&&(0,l.createVNode)(u.Close,{class:"clear-icon",onClick:e.handleClear},null)])},content:function(){return(0,l.createVNode)("div",{class:"bk-selector-list"},[(0,l.createVNode)("ul",{ref:"selectorListRef",style:{"max-height":"".concat(e.contentMaxHeight,"px")},class:"outside-ul"},[e.renderList.map((function(t,r){return e.useGroup?(0,l.createVNode)("li",{class:"bk-selector-group-item"},[(0,l.createVNode)("span",{class:"group-name"},[t.name,(0,l.createTextVNode)(" ("),t.children.length,(0,l.createTextVNode)(")")]),(0,l.createVNode)("ul",{class:"bk-selector-group-list-item"},[t.children.map((function(t,r){return(0,l.createVNode)("li",{class:["bk-selector-list-item",{disabled:t.disabled},e.activeClass(t,r)],onClick:e.handleTagSelected.bind(e,t,"select")},[(0,l.createVNode)(m,{node:t,displayKey:e.displayKey,tpl:e.tpl,searchKey:e.searchKey,searchKeyword:e.curInputValue},null)])}))])]):(0,l.createVNode)("li",{class:["bk-selector-list-item",{disabled:t.disabled},e.activeClass(t,r)],onClick:e.handleTagSelected.bind(e,t,"select")},[(0,l.createVNode)(m,{node:t,displayKey:e.displayKey,tpl:e.tpl,searchKey:e.searchKey,searchKeyword:e.curInputValue},null)])})),e.isPageLoading?(0,l.createVNode)("li",{class:"bk-selector-list-item loading"},[(0,l.createVNode)(f(),{theme:"primary",size:p.BkLoadingSize.Small},null)]):null])])}})])}}),L=(0,e.withInstall)(x)})(),d})()));