@blueking/bk-user-selector 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -34
- package/package.json +7 -3
- package/typings/components/selection-popover.vue.d.ts +8 -2
- package/typings/components/user-selector.vue.d.ts +9 -1
- package/typings/hooks/use-api-config.d.ts +33 -0
- package/typings/locale/en-us.d.ts +1 -0
- package/typings/locale/zh-cn.d.ts +1 -0
- package/typings/types/index.d.ts +45 -0
- package/typings/utils/logger.d.ts +9 -1
- package/vue2/index.es.min.js +5477 -2516
- package/vue2/index.iife.min.js +6232 -3173
- package/vue2/index.umd.min.js +5655 -2693
- package/vue2/vue2.css +53 -8
- package/vue3/index.es.min.js +1200 -277
- package/vue3/index.iife.min.js +5460 -2506
- package/vue3/index.umd.min.js +1200 -277
- package/vue3/vue3.css +53 -8
package/vue3/index.es.min.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, h, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeMount, onMounted, onUnmounted, openBlock, ref, renderList, renderSlot, toDisplayString, toRef, unref, vModelText, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
|
|
1
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, h, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeMount, onMounted, onUnmounted, openBlock, provide, ref, renderList, renderSlot, toDisplayString, toRef, unref, vModelText, vShow, watch, withCtx, withDirectives, withModifiers } from "vue";
|
|
2
2
|
import { Loading, Popover, Tag, provideGlobalConfig } from "bkui-vue";
|
|
3
|
+
//#region \0rolldown/runtime.js
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -21,6 +22,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
22
|
value: mod,
|
|
22
23
|
enumerable: true
|
|
23
24
|
}) : target, mod));
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/constants/index.ts
|
|
24
27
|
var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
25
28
|
/**!
|
|
26
29
|
* Sortable 1.15.6
|
|
@@ -58,11 +61,11 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
58
61
|
}
|
|
59
62
|
function _typeof(obj) {
|
|
60
63
|
"@babel/helpers - typeof";
|
|
61
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") _typeof = function(obj
|
|
62
|
-
return typeof obj
|
|
64
|
+
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") _typeof = function(obj) {
|
|
65
|
+
return typeof obj;
|
|
63
66
|
};
|
|
64
|
-
else _typeof = function(obj
|
|
65
|
-
return obj
|
|
67
|
+
else _typeof = function(obj) {
|
|
68
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
66
69
|
};
|
|
67
70
|
return _typeof(obj);
|
|
68
71
|
}
|
|
@@ -222,6 +225,15 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
222
225
|
if (scrollingElement) return scrollingElement;
|
|
223
226
|
else return document.documentElement;
|
|
224
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Returns the "bounding client rect" of given element
|
|
230
|
+
* @param {HTMLElement} el The element whose boundingClientRect is wanted
|
|
231
|
+
* @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
|
|
232
|
+
* @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
|
|
233
|
+
* @param {[Boolean]} undoScale Whether the container's scale() should be undone
|
|
234
|
+
* @param {[HTMLElement]} container The parent the element will be placed in
|
|
235
|
+
* @return {Object} The boundingClientRect of el, with specified adjustments
|
|
236
|
+
*/
|
|
225
237
|
function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
|
|
226
238
|
if (!el.getBoundingClientRect && el !== window) return;
|
|
227
239
|
var elRect, top, left, bottom, right, height, width;
|
|
@@ -274,6 +286,13 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
274
286
|
height
|
|
275
287
|
};
|
|
276
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Checks if a side of an element is scrolled past a side of its parents
|
|
291
|
+
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
|
|
292
|
+
* @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
|
|
293
|
+
* @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
|
|
294
|
+
* @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
|
|
295
|
+
*/
|
|
277
296
|
function isScrolledPast(el, elSide, parentSide) {
|
|
278
297
|
var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
|
|
279
298
|
while (parent) {
|
|
@@ -286,10 +305,18 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
286
305
|
}
|
|
287
306
|
return false;
|
|
288
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
* Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
|
|
310
|
+
* and non-draggable elements
|
|
311
|
+
* @param {HTMLElement} el The parent element
|
|
312
|
+
* @param {Number} childNum The index of the child
|
|
313
|
+
* @param {Object} options Parent Sortable's options
|
|
314
|
+
* @return {HTMLElement} The child at index childNum, or null if not found
|
|
315
|
+
*/
|
|
289
316
|
function getChild(el, childNum, options, includeDragEl) {
|
|
290
317
|
var currentChild = 0, i = 0, children = el.children;
|
|
291
318
|
while (i < children.length) {
|
|
292
|
-
if (children[i].style.display !== "none" && children[i] !== Sortable
|
|
319
|
+
if (children[i].style.display !== "none" && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
|
|
293
320
|
if (currentChild === childNum) return children[i];
|
|
294
321
|
currentChild++;
|
|
295
322
|
}
|
|
@@ -297,17 +324,36 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
297
324
|
}
|
|
298
325
|
return null;
|
|
299
326
|
}
|
|
327
|
+
/**
|
|
328
|
+
* Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
|
|
329
|
+
* @param {HTMLElement} el Parent element
|
|
330
|
+
* @param {selector} selector Any other elements that should be ignored
|
|
331
|
+
* @return {HTMLElement} The last child, ignoring ghostEl
|
|
332
|
+
*/
|
|
300
333
|
function lastChild(el, selector) {
|
|
301
334
|
var last = el.lastElementChild;
|
|
302
|
-
while (last && (last === Sortable
|
|
335
|
+
while (last && (last === Sortable.ghost || css(last, "display") === "none" || selector && !matches(last, selector))) last = last.previousElementSibling;
|
|
303
336
|
return last || null;
|
|
304
337
|
}
|
|
338
|
+
/**
|
|
339
|
+
* Returns the index of an element within its parent for a selected set of
|
|
340
|
+
* elements
|
|
341
|
+
* @param {HTMLElement} el
|
|
342
|
+
* @param {selector} selector
|
|
343
|
+
* @return {number}
|
|
344
|
+
*/
|
|
305
345
|
function index(el, selector) {
|
|
306
|
-
var index
|
|
346
|
+
var index = 0;
|
|
307
347
|
if (!el || !el.parentNode) return -1;
|
|
308
|
-
while (el = el.previousElementSibling) if (el.nodeName.toUpperCase() !== "TEMPLATE" && el !== Sortable
|
|
309
|
-
return index
|
|
348
|
+
while (el = el.previousElementSibling) if (el.nodeName.toUpperCase() !== "TEMPLATE" && el !== Sortable.clone && (!selector || matches(el, selector))) index++;
|
|
349
|
+
return index;
|
|
310
350
|
}
|
|
351
|
+
/**
|
|
352
|
+
* Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
|
|
353
|
+
* The value is returned in real pixels.
|
|
354
|
+
* @param {HTMLElement} el
|
|
355
|
+
* @return {Array} Offsets in the format of [left, top]
|
|
356
|
+
*/
|
|
311
357
|
function getRelativeScrollOffset(el) {
|
|
312
358
|
var offsetLeft = 0, offsetTop = 0, winScroller = getWindowScrollingElement();
|
|
313
359
|
if (el) do {
|
|
@@ -317,6 +363,12 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
317
363
|
} while (el !== winScroller && (el = el.parentNode));
|
|
318
364
|
return [offsetLeft, offsetTop];
|
|
319
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Returns the index of the object within the given array
|
|
368
|
+
* @param {Array} arr Array that may or may not hold the object
|
|
369
|
+
* @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
|
|
370
|
+
* @return {Number} The index of the object in the array, or -1
|
|
371
|
+
*/
|
|
320
372
|
function indexOfObject(arr, obj) {
|
|
321
373
|
for (var i in arr) {
|
|
322
374
|
if (!arr.hasOwnProperty(i)) continue;
|
|
@@ -391,11 +443,11 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
391
443
|
css(el, "width", "");
|
|
392
444
|
css(el, "height", "");
|
|
393
445
|
}
|
|
394
|
-
function getChildContainingRectFromElement(container, options, ghostEl
|
|
446
|
+
function getChildContainingRectFromElement(container, options, ghostEl) {
|
|
395
447
|
var rect = {};
|
|
396
448
|
Array.from(container.children).forEach(function(child) {
|
|
397
449
|
var _rect$left, _rect$top, _rect$right, _rect$bottom;
|
|
398
|
-
if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl
|
|
450
|
+
if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
|
|
399
451
|
var childRect = getRect(child);
|
|
400
452
|
rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
|
|
401
453
|
rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
|
|
@@ -416,7 +468,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
416
468
|
animationStates = [];
|
|
417
469
|
if (!this.options.animation) return;
|
|
418
470
|
[].slice.call(this.el.children).forEach(function(child) {
|
|
419
|
-
if (css(child, "display") === "none" || child === Sortable
|
|
471
|
+
if (css(child, "display") === "none" || child === Sortable.ghost) return;
|
|
420
472
|
animationStates.push({
|
|
421
473
|
target: child,
|
|
422
474
|
rect: getRect(child)
|
|
@@ -523,7 +575,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
523
575
|
});
|
|
524
576
|
plugins.push(plugin);
|
|
525
577
|
},
|
|
526
|
-
pluginEvent: function pluginEvent
|
|
578
|
+
pluginEvent: function pluginEvent(eventName, sortable, evt) {
|
|
527
579
|
var _this = this;
|
|
528
580
|
this.eventCanceled = false;
|
|
529
581
|
evt.cancel = function() {
|
|
@@ -536,7 +588,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
536
588
|
if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) sortable[plugin.pluginName][eventName](_objectSpread2({ sortable }, evt));
|
|
537
589
|
});
|
|
538
590
|
},
|
|
539
|
-
initializePlugins: function initializePlugins(sortable, el, defaults
|
|
591
|
+
initializePlugins: function initializePlugins(sortable, el, defaults, options) {
|
|
540
592
|
plugins.forEach(function(plugin) {
|
|
541
593
|
var pluginName = plugin.pluginName;
|
|
542
594
|
if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
|
|
@@ -544,7 +596,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
544
596
|
initialized.sortable = sortable;
|
|
545
597
|
initialized.options = sortable.options;
|
|
546
598
|
sortable[pluginName] = initialized;
|
|
547
|
-
_extends(defaults
|
|
599
|
+
_extends(defaults, initialized.defaults);
|
|
548
600
|
});
|
|
549
601
|
for (var option in sortable.options) {
|
|
550
602
|
if (!sortable.options.hasOwnProperty(option)) continue;
|
|
@@ -570,8 +622,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
570
622
|
}
|
|
571
623
|
};
|
|
572
624
|
function dispatchEvent(_ref) {
|
|
573
|
-
var sortable = _ref.sortable, rootEl
|
|
574
|
-
sortable = sortable || rootEl
|
|
625
|
+
var sortable = _ref.sortable, rootEl = _ref.rootEl, name = _ref.name, targetEl = _ref.targetEl, cloneEl = _ref.cloneEl, toEl = _ref.toEl, fromEl = _ref.fromEl, oldIndex = _ref.oldIndex, newIndex = _ref.newIndex, oldDraggableIndex = _ref.oldDraggableIndex, newDraggableIndex = _ref.newDraggableIndex, originalEvent = _ref.originalEvent, putSortable = _ref.putSortable, extraEventProperties = _ref.extraEventProperties;
|
|
626
|
+
sortable = sortable || rootEl && rootEl[expando];
|
|
575
627
|
if (!sortable) return;
|
|
576
628
|
var evt, options = sortable.options, onName = "on" + name.charAt(0).toUpperCase() + name.substr(1);
|
|
577
629
|
if (window.CustomEvent && !IE11OrLess && !Edge) evt = new CustomEvent(name, {
|
|
@@ -582,25 +634,25 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
582
634
|
evt = document.createEvent("Event");
|
|
583
635
|
evt.initEvent(name, true, true);
|
|
584
636
|
}
|
|
585
|
-
evt.to = toEl || rootEl
|
|
586
|
-
evt.from = fromEl || rootEl
|
|
587
|
-
evt.item = targetEl || rootEl
|
|
588
|
-
evt.clone = cloneEl
|
|
589
|
-
evt.oldIndex = oldIndex
|
|
590
|
-
evt.newIndex = newIndex
|
|
591
|
-
evt.oldDraggableIndex = oldDraggableIndex
|
|
592
|
-
evt.newDraggableIndex = newDraggableIndex
|
|
637
|
+
evt.to = toEl || rootEl;
|
|
638
|
+
evt.from = fromEl || rootEl;
|
|
639
|
+
evt.item = targetEl || rootEl;
|
|
640
|
+
evt.clone = cloneEl;
|
|
641
|
+
evt.oldIndex = oldIndex;
|
|
642
|
+
evt.newIndex = newIndex;
|
|
643
|
+
evt.oldDraggableIndex = oldDraggableIndex;
|
|
644
|
+
evt.newDraggableIndex = newDraggableIndex;
|
|
593
645
|
evt.originalEvent = originalEvent;
|
|
594
|
-
evt.pullMode = putSortable
|
|
646
|
+
evt.pullMode = putSortable ? putSortable.lastPutMode : void 0;
|
|
595
647
|
var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
|
|
596
648
|
for (var option in allEventProperties) evt[option] = allEventProperties[option];
|
|
597
|
-
if (rootEl
|
|
649
|
+
if (rootEl) rootEl.dispatchEvent(evt);
|
|
598
650
|
if (options[onName]) options[onName].call(sortable, evt);
|
|
599
651
|
}
|
|
600
652
|
var _excluded = ["evt"];
|
|
601
|
-
var pluginEvent = function pluginEvent
|
|
653
|
+
var pluginEvent = function pluginEvent(eventName, sortable) {
|
|
602
654
|
var _ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, originalEvent = _ref.evt, data = _objectWithoutProperties(_ref, _excluded);
|
|
603
|
-
PluginManager.pluginEvent.bind(Sortable
|
|
655
|
+
PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
|
|
604
656
|
dragEl,
|
|
605
657
|
parentEl,
|
|
606
658
|
ghostEl,
|
|
@@ -611,7 +663,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
611
663
|
cloneHidden,
|
|
612
664
|
dragStarted: moved,
|
|
613
665
|
putSortable,
|
|
614
|
-
activeSortable: Sortable
|
|
666
|
+
activeSortable: Sortable.active,
|
|
615
667
|
originalEvent,
|
|
616
668
|
oldIndex,
|
|
617
669
|
oldDraggableIndex,
|
|
@@ -647,13 +699,14 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
647
699
|
}, info));
|
|
648
700
|
}
|
|
649
701
|
var dragEl, parentEl, ghostEl, rootEl, nextEl, lastDownEl, cloneEl, cloneHidden, oldIndex, newIndex, oldDraggableIndex, newDraggableIndex, activeGroup, putSortable, awaitingDragStarted = false, ignoreNextClick = false, sortables = [], tapEvt, touchEvt, lastDx, lastDy, tapDistanceLeft, tapDistanceTop, moved, lastTarget, lastDirection, pastFirstInvertThresh = false, isCircumstantialInvert = false, targetMoveDistance, ghostRelativeParent, ghostRelativeParentInitialScroll = [], _silent = false, savedInputChecked = [];
|
|
702
|
+
/** @const */
|
|
650
703
|
var documentExists = typeof document !== "undefined", PositionGhostAbsolutely = IOS, CSSFloatProperty = Edge || IE11OrLess ? "cssFloat" : "float", supportDraggable = documentExists && !ChromeForAndroid && !IOS && "draggable" in document.createElement("div"), supportCssPointerEvents = function() {
|
|
651
704
|
if (!documentExists) return;
|
|
652
705
|
if (IE11OrLess) return false;
|
|
653
706
|
var el = document.createElement("x");
|
|
654
707
|
el.style.cssText = "pointer-events:auto";
|
|
655
708
|
return el.style.pointerEvents === "auto";
|
|
656
|
-
}(), _detectDirection = function _detectDirection
|
|
709
|
+
}(), _detectDirection = function _detectDirection(el, options) {
|
|
657
710
|
var elCSS = css(el), elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth), child1 = getChild(el, 0, options), child2 = getChild(el, 1, options), firstChildCSS = child1 && css(child1), secondChildCSS = child2 && css(child2), firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width, secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
|
|
658
711
|
if (elCSS.display === "flex") return elCSS.flexDirection === "column" || elCSS.flexDirection === "column-reverse" ? "vertical" : "horizontal";
|
|
659
712
|
if (elCSS.display === "grid") return elCSS.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
|
|
@@ -662,10 +715,10 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
662
715
|
return child2 && (secondChildCSS.clear === "both" || secondChildCSS.clear === touchingSideChild2) ? "vertical" : "horizontal";
|
|
663
716
|
}
|
|
664
717
|
return child1 && (firstChildCSS.display === "block" || firstChildCSS.display === "flex" || firstChildCSS.display === "table" || firstChildCSS.display === "grid" || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === "none" || child2 && elCSS[CSSFloatProperty] === "none" && firstChildWidth + secondChildWidth > elWidth) ? "vertical" : "horizontal";
|
|
665
|
-
}, _dragElInRowColumn = function _dragElInRowColumn
|
|
718
|
+
}, _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
|
|
666
719
|
var dragElS1Opp = vertical ? dragRect.left : dragRect.top, dragElS2Opp = vertical ? dragRect.right : dragRect.bottom, dragElOppLength = vertical ? dragRect.width : dragRect.height, targetS1Opp = vertical ? targetRect.left : targetRect.top, targetS2Opp = vertical ? targetRect.right : targetRect.bottom, targetOppLength = vertical ? targetRect.width : targetRect.height;
|
|
667
720
|
return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
|
|
668
|
-
}, _detectNearestEmptySortable = function _detectNearestEmptySortable
|
|
721
|
+
}, _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
|
|
669
722
|
var ret;
|
|
670
723
|
sortables.some(function(sortable) {
|
|
671
724
|
var threshold = sortable[expando].options.emptyInsertThreshold;
|
|
@@ -674,14 +727,14 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
674
727
|
if (insideHorizontally && insideVertically) return ret = sortable;
|
|
675
728
|
});
|
|
676
729
|
return ret;
|
|
677
|
-
}, _prepareGroup = function _prepareGroup
|
|
730
|
+
}, _prepareGroup = function _prepareGroup(options) {
|
|
678
731
|
function toFn(value, pull) {
|
|
679
|
-
return function(to, from, dragEl
|
|
732
|
+
return function(to, from, dragEl, evt) {
|
|
680
733
|
var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
|
|
681
734
|
if (value == null && (pull || sameGroup)) return true;
|
|
682
735
|
else if (value == null || value === false) return false;
|
|
683
736
|
else if (pull && value === "clone") return value;
|
|
684
|
-
else if (typeof value === "function") return toFn(value(to, from, dragEl
|
|
737
|
+
else if (typeof value === "function") return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
|
|
685
738
|
else {
|
|
686
739
|
var otherGroup = (pull ? to : from).options.group.name;
|
|
687
740
|
return value === true || typeof value === "string" && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
|
|
@@ -696,9 +749,9 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
696
749
|
group.checkPut = toFn(originalGroup.put);
|
|
697
750
|
group.revertClone = originalGroup.revertClone;
|
|
698
751
|
options.group = group;
|
|
699
|
-
}, _hideGhostForTarget = function _hideGhostForTarget
|
|
752
|
+
}, _hideGhostForTarget = function _hideGhostForTarget() {
|
|
700
753
|
if (!supportCssPointerEvents && ghostEl) css(ghostEl, "display", "none");
|
|
701
|
-
}, _unhideGhostForTarget = function _unhideGhostForTarget
|
|
754
|
+
}, _unhideGhostForTarget = function _unhideGhostForTarget() {
|
|
702
755
|
if (!supportCssPointerEvents && ghostEl) css(ghostEl, "display", "");
|
|
703
756
|
};
|
|
704
757
|
if (documentExists && !ChromeForAndroid) document.addEventListener("click", function(evt) {
|
|
@@ -710,7 +763,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
710
763
|
return false;
|
|
711
764
|
}
|
|
712
765
|
}, true);
|
|
713
|
-
var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent
|
|
766
|
+
var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
|
|
714
767
|
if (dragEl) {
|
|
715
768
|
evt = evt.touches ? evt.touches[0] : evt;
|
|
716
769
|
var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
|
|
@@ -724,15 +777,20 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
724
777
|
}
|
|
725
778
|
}
|
|
726
779
|
};
|
|
727
|
-
var _checkOutsideTargetEl = function _checkOutsideTargetEl
|
|
780
|
+
var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
|
|
728
781
|
if (dragEl) dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
|
|
729
782
|
};
|
|
730
|
-
|
|
783
|
+
/**
|
|
784
|
+
* @class Sortable
|
|
785
|
+
* @param {HTMLElement} el
|
|
786
|
+
* @param {Object} [options]
|
|
787
|
+
*/
|
|
788
|
+
function Sortable(el, options) {
|
|
731
789
|
if (!(el && el.nodeType && el.nodeType === 1)) throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
|
|
732
790
|
this.el = el;
|
|
733
791
|
this.options = options = _extends({}, options);
|
|
734
792
|
el[expando] = this;
|
|
735
|
-
var defaults
|
|
793
|
+
var defaults = {
|
|
736
794
|
group: null,
|
|
737
795
|
sort: true,
|
|
738
796
|
disabled: false,
|
|
@@ -754,8 +812,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
754
812
|
preventOnFilter: true,
|
|
755
813
|
animation: 0,
|
|
756
814
|
easing: null,
|
|
757
|
-
setData: function setData(dataTransfer, dragEl
|
|
758
|
-
dataTransfer.setData("Text", dragEl
|
|
815
|
+
setData: function setData(dataTransfer, dragEl) {
|
|
816
|
+
dataTransfer.setData("Text", dragEl.textContent);
|
|
759
817
|
},
|
|
760
818
|
dropBubble: false,
|
|
761
819
|
dragoverBubble: false,
|
|
@@ -771,11 +829,11 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
771
829
|
x: 0,
|
|
772
830
|
y: 0
|
|
773
831
|
},
|
|
774
|
-
supportPointer: Sortable
|
|
832
|
+
supportPointer: Sortable.supportPointer !== false && "PointerEvent" in window && (!Safari || IOS),
|
|
775
833
|
emptyInsertThreshold: 5
|
|
776
834
|
};
|
|
777
|
-
PluginManager.initializePlugins(this, el, defaults
|
|
778
|
-
for (var name in defaults
|
|
835
|
+
PluginManager.initializePlugins(this, el, defaults);
|
|
836
|
+
for (var name in defaults) !(name in options) && (options[name] = defaults[name]);
|
|
779
837
|
_prepareGroup(options);
|
|
780
838
|
for (var fn in this) if (fn.charAt(0) === "_" && typeof this[fn] === "function") this[fn] = this[fn].bind(this);
|
|
781
839
|
this.nativeDraggable = options.forceFallback ? false : supportDraggable;
|
|
@@ -793,8 +851,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
793
851
|
options.store && options.store.get && this.sort(options.store.get(this) || []);
|
|
794
852
|
_extends(this, AnimationStateManager());
|
|
795
853
|
}
|
|
796
|
-
Sortable
|
|
797
|
-
constructor: Sortable
|
|
854
|
+
Sortable.prototype = ( /** @lends Sortable.prototype */ {
|
|
855
|
+
constructor: Sortable,
|
|
798
856
|
_isOutsideThisEl: function _isOutsideThisEl(target) {
|
|
799
857
|
if (!this.el.contains(target) && target !== this.el) lastTarget = null;
|
|
800
858
|
},
|
|
@@ -862,7 +920,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
862
920
|
nextEl = dragEl.nextSibling;
|
|
863
921
|
lastDownEl = target;
|
|
864
922
|
activeGroup = options.group;
|
|
865
|
-
Sortable
|
|
923
|
+
Sortable.dragged = dragEl;
|
|
866
924
|
tapEvt = {
|
|
867
925
|
target: dragEl,
|
|
868
926
|
clientX: (touch || evt).clientX,
|
|
@@ -873,9 +931,9 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
873
931
|
this._lastX = (touch || evt).clientX;
|
|
874
932
|
this._lastY = (touch || evt).clientY;
|
|
875
933
|
dragEl.style["will-change"] = "all";
|
|
876
|
-
dragStartFn = function dragStartFn
|
|
934
|
+
dragStartFn = function dragStartFn() {
|
|
877
935
|
pluginEvent("delayEnded", _this, { evt });
|
|
878
|
-
if (Sortable
|
|
936
|
+
if (Sortable.eventCanceled) {
|
|
879
937
|
_this._onDrop();
|
|
880
938
|
return;
|
|
881
939
|
}
|
|
@@ -909,7 +967,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
909
967
|
}
|
|
910
968
|
pluginEvent("delayStart", this, { evt });
|
|
911
969
|
if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
|
|
912
|
-
if (Sortable
|
|
970
|
+
if (Sortable.eventCanceled) {
|
|
913
971
|
this._onDrop();
|
|
914
972
|
return;
|
|
915
973
|
}
|
|
@@ -972,7 +1030,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
972
1030
|
var options = this.options;
|
|
973
1031
|
!fallback && toggleClass(dragEl, options.dragClass, false);
|
|
974
1032
|
toggleClass(dragEl, options.ghostClass, true);
|
|
975
|
-
Sortable
|
|
1033
|
+
Sortable.active = this;
|
|
976
1034
|
fallback && this._appendGhost();
|
|
977
1035
|
_dispatchEvent({
|
|
978
1036
|
sortable: this,
|
|
@@ -1013,7 +1071,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1013
1071
|
_onTouchMove: function _onTouchMove(evt) {
|
|
1014
1072
|
if (tapEvt) {
|
|
1015
1073
|
var options = this.options, fallbackTolerance = options.fallbackTolerance, fallbackOffset = options.fallbackOffset, touch = evt.touches ? evt.touches[0] : evt, ghostMatrix = ghostEl && matrix(ghostEl, true), scaleX = ghostEl && ghostMatrix && ghostMatrix.a, scaleY = ghostEl && ghostMatrix && ghostMatrix.d, relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent), dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1), dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
|
|
1016
|
-
if (!Sortable
|
|
1074
|
+
if (!Sortable.active && !awaitingDragStarted) {
|
|
1017
1075
|
if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) return;
|
|
1018
1076
|
this._onDragStart(evt, true);
|
|
1019
1077
|
}
|
|
@@ -1070,7 +1128,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1070
1128
|
css(ghostEl, "position", PositionGhostAbsolutely ? "absolute" : "fixed");
|
|
1071
1129
|
css(ghostEl, "zIndex", "100000");
|
|
1072
1130
|
css(ghostEl, "pointerEvents", "none");
|
|
1073
|
-
Sortable
|
|
1131
|
+
Sortable.ghost = ghostEl;
|
|
1074
1132
|
container.appendChild(ghostEl);
|
|
1075
1133
|
css(ghostEl, "transform-origin", tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + "% " + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + "%");
|
|
1076
1134
|
}
|
|
@@ -1080,23 +1138,23 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1080
1138
|
var dataTransfer = evt.dataTransfer;
|
|
1081
1139
|
var options = _this.options;
|
|
1082
1140
|
pluginEvent("dragStart", this, { evt });
|
|
1083
|
-
if (Sortable
|
|
1141
|
+
if (Sortable.eventCanceled) {
|
|
1084
1142
|
this._onDrop();
|
|
1085
1143
|
return;
|
|
1086
1144
|
}
|
|
1087
1145
|
pluginEvent("setupClone", this);
|
|
1088
|
-
if (!Sortable
|
|
1146
|
+
if (!Sortable.eventCanceled) {
|
|
1089
1147
|
cloneEl = clone(dragEl);
|
|
1090
1148
|
cloneEl.removeAttribute("id");
|
|
1091
1149
|
cloneEl.draggable = false;
|
|
1092
1150
|
cloneEl.style["will-change"] = "";
|
|
1093
1151
|
this._hideClone();
|
|
1094
1152
|
toggleClass(cloneEl, this.options.chosenClass, false);
|
|
1095
|
-
Sortable
|
|
1153
|
+
Sortable.clone = cloneEl;
|
|
1096
1154
|
}
|
|
1097
1155
|
_this.cloneId = _nextTick(function() {
|
|
1098
1156
|
pluginEvent("clone", _this);
|
|
1099
|
-
if (Sortable
|
|
1157
|
+
if (Sortable.eventCanceled) return;
|
|
1100
1158
|
if (!_this.options.removeCloneOnHide) rootEl.insertBefore(cloneEl, dragEl);
|
|
1101
1159
|
_this._hideClone();
|
|
1102
1160
|
_dispatchEvent({
|
|
@@ -1127,7 +1185,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1127
1185
|
if (Safari) css(document.body, "user-select", "none");
|
|
1128
1186
|
},
|
|
1129
1187
|
_onDragOver: function _onDragOver(evt) {
|
|
1130
|
-
var el = this.el, target = evt.target, dragRect, targetRect, revert, options = this.options, group = options.group, activeSortable = Sortable
|
|
1188
|
+
var el = this.el, target = evt.target, dragRect, targetRect, revert, options = this.options, group = options.group, activeSortable = Sortable.active, isOwner = activeGroup === group, canSort = options.sort, fromSortable = putSortable || activeSortable, vertical, _this = this, completedFired = false;
|
|
1131
1189
|
if (_silent) return;
|
|
1132
1190
|
function dragOverEvent(name, extra) {
|
|
1133
1191
|
pluginEvent(name, _this, _objectSpread2({
|
|
@@ -1141,8 +1199,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1141
1199
|
fromSortable,
|
|
1142
1200
|
target,
|
|
1143
1201
|
completed,
|
|
1144
|
-
onMove: function onMove(target
|
|
1145
|
-
return _onMove(rootEl, el, dragEl, dragRect, target
|
|
1202
|
+
onMove: function onMove(target, after) {
|
|
1203
|
+
return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
|
|
1146
1204
|
},
|
|
1147
1205
|
changed
|
|
1148
1206
|
}, extra));
|
|
@@ -1161,8 +1219,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1161
1219
|
toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
|
|
1162
1220
|
toggleClass(dragEl, options.ghostClass, true);
|
|
1163
1221
|
}
|
|
1164
|
-
if (putSortable !== _this && _this !== Sortable
|
|
1165
|
-
else if (_this === Sortable
|
|
1222
|
+
if (putSortable !== _this && _this !== Sortable.active) putSortable = _this;
|
|
1223
|
+
else if (_this === Sortable.active && putSortable) putSortable = null;
|
|
1166
1224
|
if (fromSortable === _this) _this._ignoreWhileAnimating = target;
|
|
1167
1225
|
_this.animateAll(function() {
|
|
1168
1226
|
dragOverEvent("dragOverAnimationComplete");
|
|
@@ -1196,20 +1254,20 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1196
1254
|
if (evt.preventDefault !== void 0) evt.cancelable && evt.preventDefault();
|
|
1197
1255
|
target = closest(target, options.draggable, el, true);
|
|
1198
1256
|
dragOverEvent("dragOver");
|
|
1199
|
-
if (Sortable
|
|
1257
|
+
if (Sortable.eventCanceled) return completedFired;
|
|
1200
1258
|
if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) return completed(false);
|
|
1201
1259
|
ignoreNextClick = false;
|
|
1202
1260
|
if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
|
|
1203
1261
|
vertical = this._getDirection(evt, target) === "vertical";
|
|
1204
1262
|
dragRect = getRect(dragEl);
|
|
1205
1263
|
dragOverEvent("dragOverValid");
|
|
1206
|
-
if (Sortable
|
|
1264
|
+
if (Sortable.eventCanceled) return completedFired;
|
|
1207
1265
|
if (revert) {
|
|
1208
1266
|
parentEl = rootEl;
|
|
1209
1267
|
capture();
|
|
1210
1268
|
this._hideClone();
|
|
1211
1269
|
dragOverEvent("revert");
|
|
1212
|
-
if (!Sortable
|
|
1270
|
+
if (!Sortable.eventCanceled) if (nextEl) rootEl.insertBefore(dragEl, nextEl);
|
|
1213
1271
|
else rootEl.appendChild(dragEl);
|
|
1214
1272
|
return completed(true);
|
|
1215
1273
|
}
|
|
@@ -1305,7 +1363,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1305
1363
|
parentEl = dragEl && dragEl.parentNode;
|
|
1306
1364
|
newIndex = index(dragEl);
|
|
1307
1365
|
newDraggableIndex = index(dragEl, options.draggable);
|
|
1308
|
-
if (Sortable
|
|
1366
|
+
if (Sortable.eventCanceled) {
|
|
1309
1367
|
this._nulling();
|
|
1310
1368
|
return;
|
|
1311
1369
|
}
|
|
@@ -1391,7 +1449,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1391
1449
|
});
|
|
1392
1450
|
}
|
|
1393
1451
|
}
|
|
1394
|
-
if (Sortable
|
|
1452
|
+
if (Sortable.active) {
|
|
1395
1453
|
if (newIndex == null || newIndex === -1) {
|
|
1396
1454
|
newIndex = oldIndex;
|
|
1397
1455
|
newDraggableIndex = oldDraggableIndex;
|
|
@@ -1410,7 +1468,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1410
1468
|
},
|
|
1411
1469
|
_nulling: function _nulling() {
|
|
1412
1470
|
pluginEvent("nulling", this);
|
|
1413
|
-
rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable
|
|
1471
|
+
rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
|
|
1414
1472
|
savedInputChecked.forEach(function(el) {
|
|
1415
1473
|
el.checked = true;
|
|
1416
1474
|
});
|
|
@@ -1443,16 +1501,16 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1443
1501
|
return order;
|
|
1444
1502
|
},
|
|
1445
1503
|
sort: function sort(order, useAnimation) {
|
|
1446
|
-
var items = {}, rootEl
|
|
1504
|
+
var items = {}, rootEl = this.el;
|
|
1447
1505
|
this.toArray().forEach(function(id, i) {
|
|
1448
|
-
var el = rootEl
|
|
1449
|
-
if (closest(el, this.options.draggable, rootEl
|
|
1506
|
+
var el = rootEl.children[i];
|
|
1507
|
+
if (closest(el, this.options.draggable, rootEl, false)) items[id] = el;
|
|
1450
1508
|
}, this);
|
|
1451
1509
|
useAnimation && this.captureAnimationState();
|
|
1452
1510
|
order.forEach(function(id) {
|
|
1453
1511
|
if (items[id]) {
|
|
1454
|
-
rootEl
|
|
1455
|
-
rootEl
|
|
1512
|
+
rootEl.removeChild(items[id]);
|
|
1513
|
+
rootEl.appendChild(items[id]);
|
|
1456
1514
|
}
|
|
1457
1515
|
});
|
|
1458
1516
|
useAnimation && this.animateAll();
|
|
@@ -1485,8 +1543,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1485
1543
|
off(el, "dragover", this);
|
|
1486
1544
|
off(el, "dragenter", this);
|
|
1487
1545
|
}
|
|
1488
|
-
Array.prototype.forEach.call(el.querySelectorAll("[draggable]"), function(el
|
|
1489
|
-
el
|
|
1546
|
+
Array.prototype.forEach.call(el.querySelectorAll("[draggable]"), function(el) {
|
|
1547
|
+
el.removeAttribute("draggable");
|
|
1490
1548
|
});
|
|
1491
1549
|
this._onDrop();
|
|
1492
1550
|
this._disableDelayedDragEvents();
|
|
@@ -1496,20 +1554,20 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1496
1554
|
_hideClone: function _hideClone() {
|
|
1497
1555
|
if (!cloneHidden) {
|
|
1498
1556
|
pluginEvent("hideClone", this);
|
|
1499
|
-
if (Sortable
|
|
1557
|
+
if (Sortable.eventCanceled) return;
|
|
1500
1558
|
css(cloneEl, "display", "none");
|
|
1501
1559
|
if (this.options.removeCloneOnHide && cloneEl.parentNode) cloneEl.parentNode.removeChild(cloneEl);
|
|
1502
1560
|
cloneHidden = true;
|
|
1503
1561
|
}
|
|
1504
1562
|
},
|
|
1505
|
-
_showClone: function _showClone(putSortable
|
|
1506
|
-
if (putSortable
|
|
1563
|
+
_showClone: function _showClone(putSortable) {
|
|
1564
|
+
if (putSortable.lastPutMode !== "clone") {
|
|
1507
1565
|
this._hideClone();
|
|
1508
1566
|
return;
|
|
1509
1567
|
}
|
|
1510
1568
|
if (cloneHidden) {
|
|
1511
1569
|
pluginEvent("showClone", this);
|
|
1512
|
-
if (Sortable
|
|
1570
|
+
if (Sortable.eventCanceled) return;
|
|
1513
1571
|
if (dragEl.parentNode == rootEl && !this.options.group.revertClone) rootEl.insertBefore(cloneEl, dragEl);
|
|
1514
1572
|
else if (nextEl) rootEl.insertBefore(cloneEl, nextEl);
|
|
1515
1573
|
else rootEl.appendChild(cloneEl);
|
|
@@ -1518,12 +1576,12 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1518
1576
|
cloneHidden = false;
|
|
1519
1577
|
}
|
|
1520
1578
|
}
|
|
1521
|
-
};
|
|
1579
|
+
});
|
|
1522
1580
|
function _globalDragOver(evt) {
|
|
1523
1581
|
if (evt.dataTransfer) evt.dataTransfer.dropEffect = "move";
|
|
1524
1582
|
evt.cancelable && evt.preventDefault();
|
|
1525
1583
|
}
|
|
1526
|
-
function _onMove(fromEl, toEl, dragEl
|
|
1584
|
+
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
|
|
1527
1585
|
var evt, sortable = fromEl[expando], onMoveFn = sortable.options.onMove, retVal;
|
|
1528
1586
|
if (window.CustomEvent && !IE11OrLess && !Edge) evt = new CustomEvent("move", {
|
|
1529
1587
|
bubbles: true,
|
|
@@ -1535,7 +1593,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1535
1593
|
}
|
|
1536
1594
|
evt.to = toEl;
|
|
1537
1595
|
evt.from = fromEl;
|
|
1538
|
-
evt.dragged = dragEl
|
|
1596
|
+
evt.dragged = dragEl;
|
|
1539
1597
|
evt.draggedRect = dragRect;
|
|
1540
1598
|
evt.related = targetEl || toEl;
|
|
1541
1599
|
evt.relatedRect = targetRect || getRect(toEl);
|
|
@@ -1579,10 +1637,22 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1579
1637
|
}
|
|
1580
1638
|
return 0;
|
|
1581
1639
|
}
|
|
1640
|
+
/**
|
|
1641
|
+
* Gets the direction dragEl must be swapped relative to target in order to make it
|
|
1642
|
+
* seem that dragEl has been "inserted" into that element's position
|
|
1643
|
+
* @param {HTMLElement} target The target whose position dragEl is being inserted at
|
|
1644
|
+
* @return {Number} Direction dragEl must be swapped
|
|
1645
|
+
*/
|
|
1582
1646
|
function _getInsertDirection(target) {
|
|
1583
1647
|
if (index(dragEl) < index(target)) return 1;
|
|
1584
1648
|
else return -1;
|
|
1585
1649
|
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Generate id
|
|
1652
|
+
* @param {HTMLElement} el
|
|
1653
|
+
* @returns {String}
|
|
1654
|
+
* @private
|
|
1655
|
+
*/
|
|
1586
1656
|
function _generateId(el) {
|
|
1587
1657
|
var str = el.tagName + el.className + el.src + el.href + el.textContent, i = str.length, sum = 0;
|
|
1588
1658
|
while (i--) sum += str.charCodeAt(i);
|
|
@@ -1604,9 +1674,9 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1604
1674
|
return clearTimeout(id);
|
|
1605
1675
|
}
|
|
1606
1676
|
if (documentExists) on(document, "touchmove", function(evt) {
|
|
1607
|
-
if ((Sortable
|
|
1677
|
+
if ((Sortable.active || awaitingDragStarted) && evt.cancelable) evt.preventDefault();
|
|
1608
1678
|
});
|
|
1609
|
-
Sortable
|
|
1679
|
+
Sortable.utils = {
|
|
1610
1680
|
on,
|
|
1611
1681
|
off,
|
|
1612
1682
|
css,
|
|
@@ -1626,22 +1696,36 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1626
1696
|
getChild,
|
|
1627
1697
|
expando
|
|
1628
1698
|
};
|
|
1629
|
-
|
|
1699
|
+
/**
|
|
1700
|
+
* Get the Sortable instance of an element
|
|
1701
|
+
* @param {HTMLElement} element The element
|
|
1702
|
+
* @return {Sortable|undefined} The instance of Sortable
|
|
1703
|
+
*/
|
|
1704
|
+
Sortable.get = function(element) {
|
|
1630
1705
|
return element[expando];
|
|
1631
1706
|
};
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1707
|
+
/**
|
|
1708
|
+
* Mount a plugin to Sortable
|
|
1709
|
+
* @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
|
|
1710
|
+
*/
|
|
1711
|
+
Sortable.mount = function() {
|
|
1712
|
+
for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) plugins[_key] = arguments[_key];
|
|
1713
|
+
if (plugins[0].constructor === Array) plugins = plugins[0];
|
|
1714
|
+
plugins.forEach(function(plugin) {
|
|
1636
1715
|
if (!plugin.prototype || !plugin.prototype.constructor) throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
|
|
1637
|
-
if (plugin.utils) Sortable
|
|
1716
|
+
if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
|
|
1638
1717
|
PluginManager.mount(plugin);
|
|
1639
1718
|
});
|
|
1640
1719
|
};
|
|
1641
|
-
|
|
1642
|
-
|
|
1720
|
+
/**
|
|
1721
|
+
* Create sortable instance
|
|
1722
|
+
* @param {HTMLElement} el
|
|
1723
|
+
* @param {Object} [options]
|
|
1724
|
+
*/
|
|
1725
|
+
Sortable.create = function(el, options) {
|
|
1726
|
+
return new Sortable(el, options);
|
|
1643
1727
|
};
|
|
1644
|
-
Sortable
|
|
1728
|
+
Sortable.version = version;
|
|
1645
1729
|
var autoScrolls = [], scrollEl, scrollRootEl, scrolling = false, lastAutoScrollX, lastAutoScrollY, touchEvt$1, pointerElemChangedInterval;
|
|
1646
1730
|
function AutoScrollPlugin() {
|
|
1647
1731
|
function AutoScroll() {
|
|
@@ -1655,7 +1739,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1655
1739
|
for (var fn in this) if (fn.charAt(0) === "_" && typeof this[fn] === "function") this[fn] = this[fn].bind(this);
|
|
1656
1740
|
}
|
|
1657
1741
|
AutoScroll.prototype = {
|
|
1658
|
-
dragStarted: function dragStarted
|
|
1742
|
+
dragStarted: function dragStarted(_ref) {
|
|
1659
1743
|
var originalEvent = _ref.originalEvent;
|
|
1660
1744
|
if (this.sortable.nativeDraggable) on(document, "dragover", this._handleAutoScroll);
|
|
1661
1745
|
else if (this.options.supportPointer) on(document, "pointermove", this._handleFallbackAutoScroll);
|
|
@@ -1666,7 +1750,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1666
1750
|
var originalEvent = _ref2.originalEvent;
|
|
1667
1751
|
if (!this.options.dragOverBubble && !originalEvent.rootEl) this._handleAutoScroll(originalEvent);
|
|
1668
1752
|
},
|
|
1669
|
-
drop: function drop
|
|
1753
|
+
drop: function drop() {
|
|
1670
1754
|
if (this.sortable.nativeDraggable) off(document, "dragover", this._handleAutoScroll);
|
|
1671
1755
|
else {
|
|
1672
1756
|
off(document, "pointermove", this._handleFallbackAutoScroll);
|
|
@@ -1719,24 +1803,24 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1719
1803
|
});
|
|
1720
1804
|
}
|
|
1721
1805
|
function clearAutoScrolls() {
|
|
1722
|
-
autoScrolls.forEach(function(autoScroll
|
|
1723
|
-
clearInterval(autoScroll
|
|
1806
|
+
autoScrolls.forEach(function(autoScroll) {
|
|
1807
|
+
clearInterval(autoScroll.pid);
|
|
1724
1808
|
});
|
|
1725
1809
|
autoScrolls = [];
|
|
1726
1810
|
}
|
|
1727
1811
|
function clearPointerElemChangedInterval() {
|
|
1728
1812
|
clearInterval(pointerElemChangedInterval);
|
|
1729
1813
|
}
|
|
1730
|
-
var autoScroll = throttle(function(evt, options, rootEl
|
|
1814
|
+
var autoScroll = throttle(function(evt, options, rootEl, isFallback) {
|
|
1731
1815
|
if (!options.scroll) return;
|
|
1732
1816
|
var x = (evt.touches ? evt.touches[0] : evt).clientX, y = (evt.touches ? evt.touches[0] : evt).clientY, sens = options.scrollSensitivity, speed = options.scrollSpeed, winScroller = getWindowScrollingElement();
|
|
1733
1817
|
var scrollThisInstance = false, scrollCustomFn;
|
|
1734
|
-
if (scrollRootEl !== rootEl
|
|
1735
|
-
scrollRootEl = rootEl
|
|
1818
|
+
if (scrollRootEl !== rootEl) {
|
|
1819
|
+
scrollRootEl = rootEl;
|
|
1736
1820
|
clearAutoScrolls();
|
|
1737
1821
|
scrollEl = options.scroll;
|
|
1738
1822
|
scrollCustomFn = options.scrollFn;
|
|
1739
|
-
if (scrollEl === true) scrollEl = getParentAutoScrollElement(rootEl
|
|
1823
|
+
if (scrollEl === true) scrollEl = getParentAutoScrollElement(rootEl, true);
|
|
1740
1824
|
}
|
|
1741
1825
|
var layersOut = 0;
|
|
1742
1826
|
var currentParent = scrollEl;
|
|
@@ -1762,11 +1846,11 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1762
1846
|
if (vx != 0 || vy != 0) {
|
|
1763
1847
|
scrollThisInstance = true;
|
|
1764
1848
|
autoScrolls[layersOut].pid = setInterval(function() {
|
|
1765
|
-
if (isFallback && this.layer === 0) Sortable
|
|
1849
|
+
if (isFallback && this.layer === 0) Sortable.active._onTouchMove(touchEvt$1);
|
|
1766
1850
|
var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
|
|
1767
1851
|
var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
|
|
1768
1852
|
if (typeof scrollCustomFn === "function") {
|
|
1769
|
-
if (scrollCustomFn.call(Sortable
|
|
1853
|
+
if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== "continue") return;
|
|
1770
1854
|
}
|
|
1771
1855
|
scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
|
|
1772
1856
|
}.bind({ layer: layersOut }), 24);
|
|
@@ -1776,10 +1860,10 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1776
1860
|
} while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
|
|
1777
1861
|
scrolling = scrollThisInstance;
|
|
1778
1862
|
}, 30);
|
|
1779
|
-
var drop = function drop
|
|
1780
|
-
var originalEvent = _ref.originalEvent, putSortable
|
|
1863
|
+
var drop = function drop(_ref) {
|
|
1864
|
+
var originalEvent = _ref.originalEvent, putSortable = _ref.putSortable, dragEl = _ref.dragEl, activeSortable = _ref.activeSortable, dispatchSortableEvent = _ref.dispatchSortableEvent, hideGhostForTarget = _ref.hideGhostForTarget, unhideGhostForTarget = _ref.unhideGhostForTarget;
|
|
1781
1865
|
if (!originalEvent) return;
|
|
1782
|
-
var toSortable = putSortable
|
|
1866
|
+
var toSortable = putSortable || activeSortable;
|
|
1783
1867
|
hideGhostForTarget();
|
|
1784
1868
|
var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
|
|
1785
1869
|
var target = document.elementFromPoint(touch.clientX, touch.clientY);
|
|
@@ -1787,8 +1871,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1787
1871
|
if (toSortable && !toSortable.el.contains(target)) {
|
|
1788
1872
|
dispatchSortableEvent("spill");
|
|
1789
1873
|
this.onSpill({
|
|
1790
|
-
dragEl
|
|
1791
|
-
putSortable
|
|
1874
|
+
dragEl,
|
|
1875
|
+
putSortable
|
|
1792
1876
|
});
|
|
1793
1877
|
}
|
|
1794
1878
|
};
|
|
@@ -1799,14 +1883,14 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1799
1883
|
this.startIndex = _ref2.oldDraggableIndex;
|
|
1800
1884
|
},
|
|
1801
1885
|
onSpill: function onSpill(_ref3) {
|
|
1802
|
-
var dragEl
|
|
1886
|
+
var dragEl = _ref3.dragEl, putSortable = _ref3.putSortable;
|
|
1803
1887
|
this.sortable.captureAnimationState();
|
|
1804
|
-
if (putSortable
|
|
1888
|
+
if (putSortable) putSortable.captureAnimationState();
|
|
1805
1889
|
var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
|
|
1806
|
-
if (nextSibling) this.sortable.el.insertBefore(dragEl
|
|
1807
|
-
else this.sortable.el.appendChild(dragEl
|
|
1890
|
+
if (nextSibling) this.sortable.el.insertBefore(dragEl, nextSibling);
|
|
1891
|
+
else this.sortable.el.appendChild(dragEl);
|
|
1808
1892
|
this.sortable.animateAll();
|
|
1809
|
-
if (putSortable
|
|
1893
|
+
if (putSortable) putSortable.animateAll();
|
|
1810
1894
|
},
|
|
1811
1895
|
drop
|
|
1812
1896
|
};
|
|
@@ -1814,10 +1898,10 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1814
1898
|
function Remove() {}
|
|
1815
1899
|
Remove.prototype = {
|
|
1816
1900
|
onSpill: function onSpill(_ref4) {
|
|
1817
|
-
var dragEl
|
|
1901
|
+
var dragEl = _ref4.dragEl;
|
|
1818
1902
|
var parentSortable = _ref4.putSortable || this.sortable;
|
|
1819
1903
|
parentSortable.captureAnimationState();
|
|
1820
|
-
dragEl
|
|
1904
|
+
dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
|
|
1821
1905
|
parentSortable.animateAll();
|
|
1822
1906
|
},
|
|
1823
1907
|
drop
|
|
@@ -1848,16 +1932,16 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1848
1932
|
completed(true);
|
|
1849
1933
|
cancel();
|
|
1850
1934
|
},
|
|
1851
|
-
drop: function drop
|
|
1852
|
-
var activeSortable = _ref3.activeSortable, putSortable
|
|
1853
|
-
var toSortable = putSortable
|
|
1935
|
+
drop: function drop(_ref3) {
|
|
1936
|
+
var activeSortable = _ref3.activeSortable, putSortable = _ref3.putSortable, dragEl = _ref3.dragEl;
|
|
1937
|
+
var toSortable = putSortable || this.sortable;
|
|
1854
1938
|
var options = this.options;
|
|
1855
1939
|
lastSwapEl && toggleClass(lastSwapEl, options.swapClass, false);
|
|
1856
|
-
if (lastSwapEl && (options.swap || putSortable
|
|
1857
|
-
if (dragEl
|
|
1940
|
+
if (lastSwapEl && (options.swap || putSortable && putSortable.options.swap)) {
|
|
1941
|
+
if (dragEl !== lastSwapEl) {
|
|
1858
1942
|
toSortable.captureAnimationState();
|
|
1859
1943
|
if (toSortable !== activeSortable) activeSortable.captureAnimationState();
|
|
1860
|
-
swapNodes(dragEl
|
|
1944
|
+
swapNodes(dragEl, lastSwapEl);
|
|
1861
1945
|
toSortable.animateAll();
|
|
1862
1946
|
if (toSortable !== activeSortable) activeSortable.animateAll();
|
|
1863
1947
|
}
|
|
@@ -1898,12 +1982,12 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1898
1982
|
selectedClass: "sortable-selected",
|
|
1899
1983
|
multiDragKey: null,
|
|
1900
1984
|
avoidImplicitDeselect: false,
|
|
1901
|
-
setData: function setData(dataTransfer, dragEl
|
|
1985
|
+
setData: function setData(dataTransfer, dragEl) {
|
|
1902
1986
|
var data = "";
|
|
1903
1987
|
if (multiDragElements.length && multiDragSortable === sortable) multiDragElements.forEach(function(multiDragElement, i) {
|
|
1904
1988
|
data += (!i ? "" : ", ") + multiDragElement.textContent;
|
|
1905
1989
|
});
|
|
1906
|
-
else data = dragEl
|
|
1990
|
+
else data = dragEl.textContent;
|
|
1907
1991
|
dataTransfer.setData("Text", data);
|
|
1908
1992
|
}
|
|
1909
1993
|
};
|
|
@@ -1931,23 +2015,23 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1931
2015
|
sortable._hideClone();
|
|
1932
2016
|
cancel();
|
|
1933
2017
|
},
|
|
1934
|
-
clone: function clone
|
|
1935
|
-
var sortable = _ref3.sortable, rootEl
|
|
2018
|
+
clone: function clone(_ref3) {
|
|
2019
|
+
var sortable = _ref3.sortable, rootEl = _ref3.rootEl, dispatchSortableEvent = _ref3.dispatchSortableEvent, cancel = _ref3.cancel;
|
|
1936
2020
|
if (!this.isMultiDrag) return;
|
|
1937
2021
|
if (!this.options.removeCloneOnHide) {
|
|
1938
2022
|
if (multiDragElements.length && multiDragSortable === sortable) {
|
|
1939
|
-
insertMultiDragClones(true, rootEl
|
|
2023
|
+
insertMultiDragClones(true, rootEl);
|
|
1940
2024
|
dispatchSortableEvent("clone");
|
|
1941
2025
|
cancel();
|
|
1942
2026
|
}
|
|
1943
2027
|
}
|
|
1944
2028
|
},
|
|
1945
2029
|
showClone: function showClone(_ref4) {
|
|
1946
|
-
var cloneNowShown = _ref4.cloneNowShown, rootEl
|
|
2030
|
+
var cloneNowShown = _ref4.cloneNowShown, rootEl = _ref4.rootEl, cancel = _ref4.cancel;
|
|
1947
2031
|
if (!this.isMultiDrag) return;
|
|
1948
|
-
insertMultiDragClones(false, rootEl
|
|
1949
|
-
multiDragClones.forEach(function(clone
|
|
1950
|
-
css(clone
|
|
2032
|
+
insertMultiDragClones(false, rootEl);
|
|
2033
|
+
multiDragClones.forEach(function(clone) {
|
|
2034
|
+
css(clone, "display", "");
|
|
1951
2035
|
});
|
|
1952
2036
|
cloneNowShown();
|
|
1953
2037
|
clonesHidden = false;
|
|
@@ -1958,9 +2042,9 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1958
2042
|
_ref5.sortable;
|
|
1959
2043
|
var cloneNowHidden = _ref5.cloneNowHidden, cancel = _ref5.cancel;
|
|
1960
2044
|
if (!this.isMultiDrag) return;
|
|
1961
|
-
multiDragClones.forEach(function(clone
|
|
1962
|
-
css(clone
|
|
1963
|
-
if (_this.options.removeCloneOnHide && clone
|
|
2045
|
+
multiDragClones.forEach(function(clone) {
|
|
2046
|
+
css(clone, "display", "none");
|
|
2047
|
+
if (_this.options.removeCloneOnHide && clone.parentNode) clone.parentNode.removeChild(clone);
|
|
1964
2048
|
});
|
|
1965
2049
|
cloneNowHidden();
|
|
1966
2050
|
clonesHidden = true;
|
|
@@ -1977,7 +2061,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
1977
2061
|
});
|
|
1978
2062
|
dragStarted = true;
|
|
1979
2063
|
},
|
|
1980
|
-
dragStarted: function dragStarted
|
|
2064
|
+
dragStarted: function dragStarted(_ref7) {
|
|
1981
2065
|
var _this2 = this;
|
|
1982
2066
|
var sortable = _ref7.sortable;
|
|
1983
2067
|
if (!this.isMultiDrag) return;
|
|
@@ -2014,7 +2098,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2014
2098
|
}
|
|
2015
2099
|
},
|
|
2016
2100
|
revert: function revert(_ref9) {
|
|
2017
|
-
var fromSortable = _ref9.fromSortable, rootEl
|
|
2101
|
+
var fromSortable = _ref9.fromSortable, rootEl = _ref9.rootEl, sortable = _ref9.sortable, dragRect = _ref9.dragRect;
|
|
2018
2102
|
if (multiDragElements.length > 1) {
|
|
2019
2103
|
multiDragElements.forEach(function(multiDragElement) {
|
|
2020
2104
|
sortable.addAnimationState({
|
|
@@ -2026,21 +2110,21 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2026
2110
|
fromSortable.removeAnimationState(multiDragElement);
|
|
2027
2111
|
});
|
|
2028
2112
|
folding = false;
|
|
2029
|
-
insertMultiDragElements(!this.options.removeCloneOnHide, rootEl
|
|
2113
|
+
insertMultiDragElements(!this.options.removeCloneOnHide, rootEl);
|
|
2030
2114
|
}
|
|
2031
2115
|
},
|
|
2032
2116
|
dragOverCompleted: function dragOverCompleted(_ref10) {
|
|
2033
|
-
var sortable = _ref10.sortable, isOwner = _ref10.isOwner, insertion = _ref10.insertion, activeSortable = _ref10.activeSortable, parentEl
|
|
2117
|
+
var sortable = _ref10.sortable, isOwner = _ref10.isOwner, insertion = _ref10.insertion, activeSortable = _ref10.activeSortable, parentEl = _ref10.parentEl, putSortable = _ref10.putSortable;
|
|
2034
2118
|
var options = this.options;
|
|
2035
2119
|
if (insertion) {
|
|
2036
2120
|
if (isOwner) activeSortable._hideClone();
|
|
2037
2121
|
initialFolding = false;
|
|
2038
|
-
if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable
|
|
2122
|
+
if (options.animation && multiDragElements.length > 1 && (folding || !isOwner && !activeSortable.options.sort && !putSortable)) {
|
|
2039
2123
|
var dragRectAbsolute = getRect(dragEl$1, false, true, true);
|
|
2040
2124
|
multiDragElements.forEach(function(multiDragElement) {
|
|
2041
2125
|
if (multiDragElement === dragEl$1) return;
|
|
2042
2126
|
setRect(multiDragElement, dragRectAbsolute);
|
|
2043
|
-
parentEl
|
|
2127
|
+
parentEl.appendChild(multiDragElement);
|
|
2044
2128
|
});
|
|
2045
2129
|
folding = true;
|
|
2046
2130
|
}
|
|
@@ -2049,13 +2133,13 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2049
2133
|
if (multiDragElements.length > 1) {
|
|
2050
2134
|
var clonesHiddenBefore = clonesHidden;
|
|
2051
2135
|
activeSortable._showClone(sortable);
|
|
2052
|
-
if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) multiDragClones.forEach(function(clone
|
|
2136
|
+
if (activeSortable.options.animation && !clonesHidden && clonesHiddenBefore) multiDragClones.forEach(function(clone) {
|
|
2053
2137
|
activeSortable.addAnimationState({
|
|
2054
|
-
target: clone
|
|
2138
|
+
target: clone,
|
|
2055
2139
|
rect: clonesFromRect
|
|
2056
2140
|
});
|
|
2057
|
-
clone
|
|
2058
|
-
clone
|
|
2141
|
+
clone.fromRect = clonesFromRect;
|
|
2142
|
+
clone.thisAnimationDuration = null;
|
|
2059
2143
|
});
|
|
2060
2144
|
} else activeSortable._showClone(sortable);
|
|
2061
2145
|
}
|
|
@@ -2079,11 +2163,11 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2079
2163
|
removeMultiDragElements();
|
|
2080
2164
|
}
|
|
2081
2165
|
},
|
|
2082
|
-
drop: function drop
|
|
2083
|
-
var evt = _ref12.originalEvent, rootEl
|
|
2084
|
-
var toSortable = putSortable
|
|
2166
|
+
drop: function drop(_ref12) {
|
|
2167
|
+
var evt = _ref12.originalEvent, rootEl = _ref12.rootEl, parentEl = _ref12.parentEl, sortable = _ref12.sortable, dispatchSortableEvent = _ref12.dispatchSortableEvent, oldIndex = _ref12.oldIndex, putSortable = _ref12.putSortable;
|
|
2168
|
+
var toSortable = putSortable || this.sortable;
|
|
2085
2169
|
if (!evt) return;
|
|
2086
|
-
var options = this.options, children = parentEl
|
|
2170
|
+
var options = this.options, children = parentEl.children;
|
|
2087
2171
|
if (!dragStarted) {
|
|
2088
2172
|
if (options.multiDragKey && !this.multiDragKeyDown) this._deselectMultiDrag();
|
|
2089
2173
|
toggleClass(dragEl$1, options.selectedClass, !~multiDragElements.indexOf(dragEl$1));
|
|
@@ -2091,7 +2175,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2091
2175
|
multiDragElements.push(dragEl$1);
|
|
2092
2176
|
dispatchEvent({
|
|
2093
2177
|
sortable,
|
|
2094
|
-
rootEl
|
|
2178
|
+
rootEl,
|
|
2095
2179
|
name: "select",
|
|
2096
2180
|
targetEl: dragEl$1,
|
|
2097
2181
|
originalEvent: evt
|
|
@@ -2110,15 +2194,15 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2110
2194
|
var filter = options.filter;
|
|
2111
2195
|
for (; i < n; i++) {
|
|
2112
2196
|
if (~multiDragElements.indexOf(children[i])) continue;
|
|
2113
|
-
if (!closest(children[i], options.draggable, parentEl
|
|
2197
|
+
if (!closest(children[i], options.draggable, parentEl, false)) continue;
|
|
2114
2198
|
if (filter && (typeof filter === "function" ? filter.call(sortable, evt, children[i], sortable) : filter.split(",").some(function(criteria) {
|
|
2115
|
-
return closest(children[i], criteria.trim(), parentEl
|
|
2199
|
+
return closest(children[i], criteria.trim(), parentEl, false);
|
|
2116
2200
|
}))) continue;
|
|
2117
2201
|
toggleClass(children[i], options.selectedClass, true);
|
|
2118
2202
|
multiDragElements.push(children[i]);
|
|
2119
2203
|
dispatchEvent({
|
|
2120
2204
|
sortable,
|
|
2121
|
-
rootEl
|
|
2205
|
+
rootEl,
|
|
2122
2206
|
name: "select",
|
|
2123
2207
|
targetEl: children[i],
|
|
2124
2208
|
originalEvent: evt
|
|
@@ -2132,7 +2216,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2132
2216
|
lastMultiDragSelect = null;
|
|
2133
2217
|
dispatchEvent({
|
|
2134
2218
|
sortable,
|
|
2135
|
-
rootEl
|
|
2219
|
+
rootEl,
|
|
2136
2220
|
name: "deselect",
|
|
2137
2221
|
targetEl: dragEl$1,
|
|
2138
2222
|
originalEvent: evt
|
|
@@ -2141,7 +2225,7 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2141
2225
|
}
|
|
2142
2226
|
if (dragStarted && this.isMultiDrag) {
|
|
2143
2227
|
folding = false;
|
|
2144
|
-
if ((parentEl
|
|
2228
|
+
if ((parentEl[expando].options.sort || parentEl !== rootEl) && multiDragElements.length > 1) {
|
|
2145
2229
|
var dragRect = getRect(dragEl$1), multiDragIndex = index(dragEl$1, ":not(." + this.options.selectedClass + ")");
|
|
2146
2230
|
if (!initialFolding && options.animation) dragEl$1.thisAnimationDuration = null;
|
|
2147
2231
|
toSortable.captureAnimationState();
|
|
@@ -2162,11 +2246,11 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2162
2246
|
}
|
|
2163
2247
|
removeMultiDragElements();
|
|
2164
2248
|
multiDragElements.forEach(function(multiDragElement) {
|
|
2165
|
-
if (children[multiDragIndex]) parentEl
|
|
2166
|
-
else parentEl
|
|
2249
|
+
if (children[multiDragIndex]) parentEl.insertBefore(multiDragElement, children[multiDragIndex]);
|
|
2250
|
+
else parentEl.appendChild(multiDragElement);
|
|
2167
2251
|
multiDragIndex++;
|
|
2168
2252
|
});
|
|
2169
|
-
if (oldIndex
|
|
2253
|
+
if (oldIndex === index(dragEl$1)) {
|
|
2170
2254
|
var update = false;
|
|
2171
2255
|
multiDragElements.forEach(function(multiDragElement) {
|
|
2172
2256
|
if (multiDragElement.sortableIndex !== index(multiDragElement)) {
|
|
@@ -2187,8 +2271,8 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2187
2271
|
}
|
|
2188
2272
|
multiDragSortable = toSortable;
|
|
2189
2273
|
}
|
|
2190
|
-
if (rootEl
|
|
2191
|
-
clone
|
|
2274
|
+
if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== "clone") multiDragClones.forEach(function(clone) {
|
|
2275
|
+
clone.parentNode && clone.parentNode.removeChild(clone);
|
|
2192
2276
|
});
|
|
2193
2277
|
},
|
|
2194
2278
|
nullingGlobal: function nullingGlobal() {
|
|
@@ -2242,10 +2326,10 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2242
2326
|
multiDragElements.push(el);
|
|
2243
2327
|
},
|
|
2244
2328
|
deselect: function deselect(el) {
|
|
2245
|
-
var sortable = el.parentNode[expando], index
|
|
2246
|
-
if (!sortable || !sortable.options.multiDrag || !~index
|
|
2329
|
+
var sortable = el.parentNode[expando], index = multiDragElements.indexOf(el);
|
|
2330
|
+
if (!sortable || !sortable.options.multiDrag || !~index) return;
|
|
2247
2331
|
toggleClass(el, sortable.options.selectedClass, false);
|
|
2248
|
-
multiDragElements.splice(index
|
|
2332
|
+
multiDragElements.splice(index, 1);
|
|
2249
2333
|
}
|
|
2250
2334
|
},
|
|
2251
2335
|
eventProperties: function eventProperties() {
|
|
@@ -2256,13 +2340,13 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2256
2340
|
multiDragElement,
|
|
2257
2341
|
index: multiDragElement.sortableIndex
|
|
2258
2342
|
});
|
|
2259
|
-
var newIndex
|
|
2260
|
-
if (folding && multiDragElement !== dragEl$1) newIndex
|
|
2261
|
-
else if (folding) newIndex
|
|
2262
|
-
else newIndex
|
|
2343
|
+
var newIndex;
|
|
2344
|
+
if (folding && multiDragElement !== dragEl$1) newIndex = -1;
|
|
2345
|
+
else if (folding) newIndex = index(multiDragElement, ":not(." + _this3.options.selectedClass + ")");
|
|
2346
|
+
else newIndex = index(multiDragElement);
|
|
2263
2347
|
newIndicies.push({
|
|
2264
2348
|
multiDragElement,
|
|
2265
|
-
index: newIndex
|
|
2349
|
+
index: newIndex
|
|
2266
2350
|
});
|
|
2267
2351
|
});
|
|
2268
2352
|
return {
|
|
@@ -2280,18 +2364,23 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2280
2364
|
} }
|
|
2281
2365
|
});
|
|
2282
2366
|
}
|
|
2283
|
-
function insertMultiDragElements(clonesInserted, rootEl
|
|
2367
|
+
function insertMultiDragElements(clonesInserted, rootEl) {
|
|
2284
2368
|
multiDragElements.forEach(function(multiDragElement, i) {
|
|
2285
|
-
var target = rootEl
|
|
2286
|
-
if (target) rootEl
|
|
2287
|
-
else rootEl
|
|
2369
|
+
var target = rootEl.children[multiDragElement.sortableIndex + (clonesInserted ? Number(i) : 0)];
|
|
2370
|
+
if (target) rootEl.insertBefore(multiDragElement, target);
|
|
2371
|
+
else rootEl.appendChild(multiDragElement);
|
|
2288
2372
|
});
|
|
2289
2373
|
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2374
|
+
/**
|
|
2375
|
+
* Insert multi-drag clones
|
|
2376
|
+
* @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted
|
|
2377
|
+
* @param {HTMLElement} rootEl
|
|
2378
|
+
*/
|
|
2379
|
+
function insertMultiDragClones(elementsInserted, rootEl) {
|
|
2380
|
+
multiDragClones.forEach(function(clone, i) {
|
|
2381
|
+
var target = rootEl.children[clone.sortableIndex + (elementsInserted ? Number(i) : 0)];
|
|
2382
|
+
if (target) rootEl.insertBefore(clone, target);
|
|
2383
|
+
else rootEl.appendChild(clone);
|
|
2295
2384
|
});
|
|
2296
2385
|
}
|
|
2297
2386
|
function removeMultiDragElements() {
|
|
@@ -2300,24 +2389,128 @@ var import_Sortable = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((e
|
|
|
2300
2389
|
multiDragElement.parentNode && multiDragElement.parentNode.removeChild(multiDragElement);
|
|
2301
2390
|
});
|
|
2302
2391
|
}
|
|
2303
|
-
Sortable
|
|
2304
|
-
Sortable
|
|
2305
|
-
Sortable
|
|
2306
|
-
Sortable
|
|
2307
|
-
return Sortable
|
|
2392
|
+
Sortable.mount(new AutoScrollPlugin());
|
|
2393
|
+
Sortable.mount(Remove, Revert);
|
|
2394
|
+
Sortable.mount(new SwapPlugin());
|
|
2395
|
+
Sortable.mount(new MultiDragPlugin());
|
|
2396
|
+
return Sortable;
|
|
2308
2397
|
}));
|
|
2309
2398
|
})))());
|
|
2310
|
-
|
|
2311
|
-
|
|
2399
|
+
/** 默认精确搜索字段 */
|
|
2400
|
+
var DEFAULT_EXACT_SEARCH_KEY = "bk_username";
|
|
2401
|
+
/** 用户类型 */
|
|
2402
|
+
var USER_TYPE = {
|
|
2312
2403
|
USER: "user",
|
|
2313
2404
|
VIRTUAL: "virtual",
|
|
2314
2405
|
CUSTOM: "custom",
|
|
2315
2406
|
USER_GROUP: "userGroup"
|
|
2316
2407
|
};
|
|
2408
|
+
//#endregion
|
|
2409
|
+
//#region src/hooks/use-api-config.ts
|
|
2410
|
+
var API_CONFIG_KEY = Symbol("bkUserSelectorApiConfig");
|
|
2411
|
+
var TENANT_ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
2412
|
+
var globalApiConfig = {
|
|
2413
|
+
apiBaseUrl: "",
|
|
2414
|
+
tenantId: "",
|
|
2415
|
+
allowedApiOrigins: [],
|
|
2416
|
+
allowPrivateApiHost: false,
|
|
2417
|
+
allowCrossOriginCredentials: false
|
|
2418
|
+
};
|
|
2419
|
+
var getCurrentOrigin = () => {
|
|
2420
|
+
if (typeof window === "undefined" || !window.location?.origin) return "http://localhost";
|
|
2421
|
+
return window.location.origin;
|
|
2422
|
+
};
|
|
2423
|
+
var isPrivateIpv4 = (hostname) => {
|
|
2424
|
+
const segments = hostname.split(".").map(Number);
|
|
2425
|
+
if (segments.length !== 4 || segments.some(Number.isNaN)) return false;
|
|
2426
|
+
const [a, b] = segments;
|
|
2427
|
+
if (a === 10 || a === 127) return true;
|
|
2428
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
2429
|
+
if (a === 192 && b === 168) return true;
|
|
2430
|
+
if (a === 169 && b === 254) return true;
|
|
2431
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
2432
|
+
return false;
|
|
2433
|
+
};
|
|
2434
|
+
var isPrivateHost = (hostname) => {
|
|
2435
|
+
const normalizedHost = hostname.toLowerCase();
|
|
2436
|
+
if (normalizedHost === "localhost" || normalizedHost === "[::1]" || normalizedHost === "::1") return true;
|
|
2437
|
+
if (isPrivateIpv4(normalizedHost)) return true;
|
|
2438
|
+
if (normalizedHost.startsWith("fc") || normalizedHost.startsWith("fd")) return true;
|
|
2439
|
+
return false;
|
|
2440
|
+
};
|
|
2441
|
+
var normalizeAllowedOrigins = (allowedApiOrigins = []) => {
|
|
2442
|
+
const currentOrigin = getCurrentOrigin();
|
|
2443
|
+
return Array.from(new Set(allowedApiOrigins.map((origin) => {
|
|
2444
|
+
try {
|
|
2445
|
+
const parsed = new URL(origin, currentOrigin);
|
|
2446
|
+
if (!["http:", "https:"].includes(parsed.protocol)) return "";
|
|
2447
|
+
return parsed.origin;
|
|
2448
|
+
} catch {
|
|
2449
|
+
return "";
|
|
2450
|
+
}
|
|
2451
|
+
}).filter(Boolean)));
|
|
2452
|
+
};
|
|
2453
|
+
var sanitizeApiBaseUrl = (apiBaseUrl, allowedApiOrigins = [], allowPrivateApiHost = false) => {
|
|
2454
|
+
if (!apiBaseUrl) return "";
|
|
2455
|
+
try {
|
|
2456
|
+
const parsed = new URL(apiBaseUrl, getCurrentOrigin());
|
|
2457
|
+
if (!["http:", "https:"].includes(parsed.protocol)) {
|
|
2458
|
+
console.warn("[bk-user-selector] apiBaseUrl 仅支持 http/https 协议");
|
|
2459
|
+
return "";
|
|
2460
|
+
}
|
|
2461
|
+
if (!allowPrivateApiHost && isPrivateHost(parsed.hostname)) {
|
|
2462
|
+
console.warn("[bk-user-selector] apiBaseUrl 指向私网或 localhost,已被安全策略拦截");
|
|
2463
|
+
return "";
|
|
2464
|
+
}
|
|
2465
|
+
const normalizedAllowedOrigins = normalizeAllowedOrigins(allowedApiOrigins);
|
|
2466
|
+
if (normalizedAllowedOrigins.length > 0 && !normalizedAllowedOrigins.includes(parsed.origin)) {
|
|
2467
|
+
console.warn("[bk-user-selector] apiBaseUrl 未命中 allowedApiOrigins 白名单,已被安全策略拦截");
|
|
2468
|
+
return "";
|
|
2469
|
+
}
|
|
2470
|
+
const normalizedPath = parsed.pathname.replace(/\/+$/, "");
|
|
2471
|
+
return `${parsed.origin}${normalizedPath}`;
|
|
2472
|
+
} catch {
|
|
2473
|
+
console.warn("[bk-user-selector] apiBaseUrl 格式非法,已被安全策略拦截");
|
|
2474
|
+
return "";
|
|
2475
|
+
}
|
|
2476
|
+
};
|
|
2477
|
+
var sanitizeTenantId = (tenantId) => {
|
|
2478
|
+
const normalizedTenantId = String(tenantId || "").trim();
|
|
2479
|
+
if (!normalizedTenantId) return "";
|
|
2480
|
+
if (!TENANT_ID_PATTERN.test(normalizedTenantId)) {
|
|
2481
|
+
console.warn("[bk-user-selector] tenantId 格式非法,已被安全策略拦截");
|
|
2482
|
+
return "";
|
|
2483
|
+
}
|
|
2484
|
+
return normalizedTenantId;
|
|
2485
|
+
};
|
|
2486
|
+
var getApiConfig = () => {
|
|
2487
|
+
return globalApiConfig;
|
|
2488
|
+
};
|
|
2489
|
+
var provideApiConfig = (apiBaseUrl, tenantId, allowedApiOrigins = [], allowPrivateApiHost = false, allowCrossOriginCredentials = false, callbacks = {}) => {
|
|
2490
|
+
const normalizedAllowedOrigins = normalizeAllowedOrigins(allowedApiOrigins);
|
|
2491
|
+
globalApiConfig = {
|
|
2492
|
+
apiBaseUrl: sanitizeApiBaseUrl(apiBaseUrl, normalizedAllowedOrigins, allowPrivateApiHost),
|
|
2493
|
+
tenantId: sanitizeTenantId(tenantId),
|
|
2494
|
+
allowedApiOrigins: normalizedAllowedOrigins,
|
|
2495
|
+
allowPrivateApiHost,
|
|
2496
|
+
allowCrossOriginCredentials,
|
|
2497
|
+
onError: callbacks.onError,
|
|
2498
|
+
onUnauthorized: callbacks.onUnauthorized
|
|
2499
|
+
};
|
|
2500
|
+
provide(API_CONFIG_KEY, globalApiConfig);
|
|
2501
|
+
};
|
|
2502
|
+
//#endregion
|
|
2503
|
+
//#region src/hooks/use-jsonp.ts
|
|
2504
|
+
/**
|
|
2505
|
+
* 生成回调函数名
|
|
2506
|
+
*/
|
|
2317
2507
|
var generateCallbackName = () => {
|
|
2318
2508
|
return `__jsonp_callback_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
2319
2509
|
};
|
|
2320
|
-
|
|
2510
|
+
/**
|
|
2511
|
+
* JSONP 请求函数
|
|
2512
|
+
*/
|
|
2513
|
+
var jsonpRequest = (requestUrl, options = {}) => {
|
|
2321
2514
|
return new Promise((resolve, reject) => {
|
|
2322
2515
|
const url = unref(requestUrl);
|
|
2323
2516
|
const { timeout = 1e3 * 60 * 2, params } = options;
|
|
@@ -2346,6 +2539,8 @@ const jsonpRequest = (requestUrl, options = {}) => {
|
|
|
2346
2539
|
document.head.appendChild(script);
|
|
2347
2540
|
});
|
|
2348
2541
|
};
|
|
2542
|
+
//#endregion
|
|
2543
|
+
//#region src/utils/logger.ts
|
|
2349
2544
|
var PREFIX = "[BkUserSelector]";
|
|
2350
2545
|
var LOG_LEVELS = {
|
|
2351
2546
|
debug: 0,
|
|
@@ -2357,10 +2552,16 @@ var config = {
|
|
|
2357
2552
|
enabled: true,
|
|
2358
2553
|
level: "warn"
|
|
2359
2554
|
};
|
|
2555
|
+
/**
|
|
2556
|
+
* 检查是否应该输出日志
|
|
2557
|
+
*/
|
|
2360
2558
|
var shouldLog = (level) => {
|
|
2361
2559
|
return config.enabled && LOG_LEVELS[level] >= LOG_LEVELS[config.level];
|
|
2362
2560
|
};
|
|
2363
|
-
|
|
2561
|
+
/**
|
|
2562
|
+
* 日志工具
|
|
2563
|
+
*/
|
|
2564
|
+
var logger = {
|
|
2364
2565
|
debug: (message, ...args) => {
|
|
2365
2566
|
if (shouldLog("debug")) console.debug(`${PREFIX} ${message}`, ...args);
|
|
2366
2567
|
},
|
|
@@ -2374,32 +2575,132 @@ const logger = {
|
|
|
2374
2575
|
if (shouldLog("error")) console.error(`${PREFIX} ${message}`, error);
|
|
2375
2576
|
}
|
|
2376
2577
|
};
|
|
2377
|
-
|
|
2378
|
-
|
|
2578
|
+
/**
|
|
2579
|
+
* 安全调用用户回调
|
|
2580
|
+
* 用户回调如果抛错不应影响组件正常流程
|
|
2581
|
+
*/
|
|
2582
|
+
var safeInvoke = (handler, error) => {
|
|
2583
|
+
if (!handler) return;
|
|
2584
|
+
try {
|
|
2585
|
+
handler(error);
|
|
2586
|
+
} catch (err) {
|
|
2587
|
+
console.error(`${PREFIX} error handler threw:`, err);
|
|
2588
|
+
}
|
|
2589
|
+
};
|
|
2590
|
+
/**
|
|
2591
|
+
* 构造 ApiError 对象
|
|
2592
|
+
*/
|
|
2593
|
+
var buildApiError = (scene, cause, status, isUnauthorized = false) => ({
|
|
2594
|
+
scene,
|
|
2595
|
+
cause,
|
|
2596
|
+
status,
|
|
2597
|
+
isUnauthorized
|
|
2598
|
+
});
|
|
2599
|
+
/**
|
|
2600
|
+
* API 错误处理
|
|
2601
|
+
* - 打印错误日志(兜底)
|
|
2602
|
+
* - 触发 apiConfig.onError 回调
|
|
2603
|
+
* - 如果是 401,额外触发 apiConfig.onUnauthorized 回调
|
|
2604
|
+
*/
|
|
2605
|
+
var handleApiError = (operation, error, apiConfig, status, isUnauthorized = false) => {
|
|
2606
|
+
if (isUnauthorized) logger.warn(`${operation}: 登录态已失效,请重新登录`);
|
|
2607
|
+
else logger.error(`${operation}失败:`, error);
|
|
2608
|
+
const apiError = buildApiError(operation, error, status, isUnauthorized);
|
|
2609
|
+
if (isUnauthorized) safeInvoke(apiConfig?.onUnauthorized, apiError);
|
|
2610
|
+
safeInvoke(apiConfig?.onError, apiError);
|
|
2379
2611
|
};
|
|
2380
|
-
|
|
2612
|
+
/**
|
|
2613
|
+
* 参数校验警告
|
|
2614
|
+
*/
|
|
2615
|
+
var warnMissingParams = (operation, params) => {
|
|
2381
2616
|
logger.warn(`${operation}需要提供有效的参数: ${params.join(", ")}`);
|
|
2382
2617
|
};
|
|
2383
|
-
|
|
2384
|
-
|
|
2618
|
+
//#endregion
|
|
2619
|
+
//#region src/api/user.ts
|
|
2620
|
+
/**
|
|
2621
|
+
* 用户选择器相关API
|
|
2622
|
+
* @module api/user
|
|
2623
|
+
*/
|
|
2624
|
+
var UNAUTHORIZED_STATUS = 401;
|
|
2625
|
+
var resolveRequestCredentials = (url, allowCrossOriginCredentials) => {
|
|
2626
|
+
if (typeof window === "undefined" || !window.location?.origin) return "same-origin";
|
|
2627
|
+
try {
|
|
2628
|
+
if (new URL(url, window.location.origin).origin === window.location.origin) return "include";
|
|
2629
|
+
return allowCrossOriginCredentials ? "include" : "omit";
|
|
2630
|
+
} catch {
|
|
2631
|
+
return "same-origin";
|
|
2632
|
+
}
|
|
2633
|
+
};
|
|
2634
|
+
var resolveApiSecurityConfig = (apiBaseUrl, tenantId) => {
|
|
2635
|
+
const globalConfig = getApiConfig();
|
|
2636
|
+
const resolvedAllowPrivateApiHost = globalConfig.allowPrivateApiHost;
|
|
2637
|
+
const resolvedAllowedApiOrigins = globalConfig.allowedApiOrigins;
|
|
2638
|
+
return {
|
|
2639
|
+
allowCrossOriginCredentials: globalConfig.allowCrossOriginCredentials,
|
|
2640
|
+
apiBaseUrl: sanitizeApiBaseUrl(globalConfig.apiBaseUrl || apiBaseUrl, resolvedAllowedApiOrigins, resolvedAllowPrivateApiHost),
|
|
2641
|
+
tenantId: sanitizeTenantId(globalConfig.tenantId || tenantId),
|
|
2642
|
+
apiConfig: globalConfig
|
|
2643
|
+
};
|
|
2644
|
+
};
|
|
2645
|
+
/**
|
|
2646
|
+
* 统一处理响应状态码,401 时构造 ApiError 并触发回调,然后抛出错误
|
|
2647
|
+
*/
|
|
2648
|
+
var ensureResponseOk = (response, scene, apiConfig) => {
|
|
2649
|
+
if (response.ok) return;
|
|
2650
|
+
if (response.status === UNAUTHORIZED_STATUS) {
|
|
2651
|
+
const error = /* @__PURE__ */ new Error(`${scene}失败: 登录态已失效`);
|
|
2652
|
+
handleApiError(scene, error, apiConfig, response.status, true);
|
|
2653
|
+
throw error;
|
|
2654
|
+
}
|
|
2655
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
2656
|
+
};
|
|
2657
|
+
/**
|
|
2658
|
+
* 从抛出的错误中尽力提取 HTTP 状态码
|
|
2659
|
+
*/
|
|
2660
|
+
var extractStatus = (error) => {
|
|
2661
|
+
if (typeof error === "object" && error !== null && "status" in error) {
|
|
2662
|
+
const status = error.status;
|
|
2663
|
+
return typeof status === "number" ? status : void 0;
|
|
2664
|
+
}
|
|
2665
|
+
if (error instanceof Error) {
|
|
2666
|
+
const match = /^(\d{3})\s/.exec(error.message);
|
|
2667
|
+
if (match) return Number(match[1]);
|
|
2668
|
+
}
|
|
2669
|
+
};
|
|
2670
|
+
/**
|
|
2671
|
+
* 获取本租户所有数据来源的租户信息
|
|
2672
|
+
* @param apiBaseUrl - API基础URL
|
|
2673
|
+
* @param tenantId - 租户ID
|
|
2674
|
+
* @returns 租户列表Promise
|
|
2675
|
+
*/
|
|
2676
|
+
var getTenants = async (apiBaseUrl, tenantId) => {
|
|
2677
|
+
const resolvedConfig = resolveApiSecurityConfig(apiBaseUrl, tenantId);
|
|
2678
|
+
if (!resolvedConfig.apiBaseUrl || !resolvedConfig.tenantId) {
|
|
2385
2679
|
warnMissingParams("获取租户信息", ["apiBaseUrl", "tenantId"]);
|
|
2386
2680
|
return [];
|
|
2387
2681
|
}
|
|
2388
2682
|
try {
|
|
2389
|
-
const url = `${apiBaseUrl}/api/v3/open-web/tenant/data-source-owner-tenants/`;
|
|
2683
|
+
const url = `${resolvedConfig.apiBaseUrl}/api/v3/open-web/tenant/data-source-owner-tenants/`;
|
|
2684
|
+
const requestCredentials = resolveRequestCredentials(url, resolvedConfig.allowCrossOriginCredentials);
|
|
2390
2685
|
const response = await fetch(url, {
|
|
2391
2686
|
method: "GET",
|
|
2392
|
-
headers: { "x-bk-tenant-id": tenantId },
|
|
2393
|
-
credentials:
|
|
2687
|
+
headers: { "x-bk-tenant-id": resolvedConfig.tenantId },
|
|
2688
|
+
credentials: requestCredentials
|
|
2394
2689
|
});
|
|
2395
|
-
|
|
2690
|
+
ensureResponseOk(response, "获取租户信息", resolvedConfig.apiConfig);
|
|
2396
2691
|
return (await response.json()).data || [];
|
|
2397
2692
|
} catch (error) {
|
|
2398
|
-
|
|
2693
|
+
const status = extractStatus(error);
|
|
2694
|
+
if (status !== UNAUTHORIZED_STATUS) handleApiError("获取租户信息", error, resolvedConfig.apiConfig, status, false);
|
|
2399
2695
|
return [];
|
|
2400
2696
|
}
|
|
2401
2697
|
};
|
|
2402
|
-
|
|
2698
|
+
/**
|
|
2699
|
+
* 模糊搜索用户
|
|
2700
|
+
* @param params - 搜索参数
|
|
2701
|
+
* @returns 用户列表Promise
|
|
2702
|
+
*/
|
|
2703
|
+
var searchUsers = async (params) => {
|
|
2403
2704
|
const { apiBaseUrl, tenantId, keyword, enableMultiTenantMode = true } = params;
|
|
2404
2705
|
if (!enableMultiTenantMode) try {
|
|
2405
2706
|
return await getUserList(apiBaseUrl, {
|
|
@@ -2410,7 +2711,8 @@ const searchUsers = async (params) => {
|
|
|
2410
2711
|
} catch {
|
|
2411
2712
|
return [];
|
|
2412
2713
|
}
|
|
2413
|
-
|
|
2714
|
+
const resolvedConfig = resolveApiSecurityConfig(apiBaseUrl, tenantId);
|
|
2715
|
+
if (!keyword || !resolvedConfig.apiBaseUrl || !resolvedConfig.tenantId) {
|
|
2414
2716
|
warnMissingParams("搜索用户", [
|
|
2415
2717
|
"apiBaseUrl",
|
|
2416
2718
|
"tenantId",
|
|
@@ -2419,20 +2721,27 @@ const searchUsers = async (params) => {
|
|
|
2419
2721
|
return [];
|
|
2420
2722
|
}
|
|
2421
2723
|
try {
|
|
2422
|
-
const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/search/?keyword=${encodeURIComponent(keyword)}`;
|
|
2724
|
+
const url = `${resolvedConfig.apiBaseUrl}/api/v3/open-web/tenant/users/-/search/?keyword=${encodeURIComponent(keyword)}`;
|
|
2725
|
+
const requestCredentials = resolveRequestCredentials(url, resolvedConfig.allowCrossOriginCredentials);
|
|
2423
2726
|
const response = await fetch(url, {
|
|
2424
2727
|
method: "GET",
|
|
2425
|
-
headers: { "x-bk-tenant-id": tenantId },
|
|
2426
|
-
credentials:
|
|
2728
|
+
headers: { "x-bk-tenant-id": resolvedConfig.tenantId },
|
|
2729
|
+
credentials: requestCredentials
|
|
2427
2730
|
});
|
|
2428
|
-
|
|
2731
|
+
ensureResponseOk(response, "搜索用户", resolvedConfig.apiConfig);
|
|
2429
2732
|
return (await response.json()).data || [];
|
|
2430
2733
|
} catch (error) {
|
|
2431
|
-
|
|
2734
|
+
const status = extractStatus(error);
|
|
2735
|
+
if (status !== UNAUTHORIZED_STATUS) handleApiError("搜索用户", error, resolvedConfig.apiConfig, status, false);
|
|
2432
2736
|
return [];
|
|
2433
2737
|
}
|
|
2434
2738
|
};
|
|
2435
|
-
|
|
2739
|
+
/**
|
|
2740
|
+
* 批量精准查找用户
|
|
2741
|
+
* @param params - 查找参数
|
|
2742
|
+
* @returns 查找到的用户列表Promise
|
|
2743
|
+
*/
|
|
2744
|
+
var lookupUsers = async (params) => {
|
|
2436
2745
|
const { apiBaseUrl, tenantId, exactSearchKey = "bk_username", usersList = [], enableMultiTenantMode = true } = params;
|
|
2437
2746
|
const users = usersList.filter(Boolean).map((user) => typeof user === "string" ? user.trim() : String(user).trim());
|
|
2438
2747
|
if (!enableMultiTenantMode) try {
|
|
@@ -2441,7 +2750,8 @@ const lookupUsers = async (params) => {
|
|
|
2441
2750
|
} catch {
|
|
2442
2751
|
return [];
|
|
2443
2752
|
}
|
|
2444
|
-
|
|
2753
|
+
const resolvedConfig = resolveApiSecurityConfig(apiBaseUrl, tenantId);
|
|
2754
|
+
if (users.length === 0 || !resolvedConfig.apiBaseUrl || !resolvedConfig.tenantId) {
|
|
2445
2755
|
warnMissingParams("批量查找用户", [
|
|
2446
2756
|
"apiBaseUrl",
|
|
2447
2757
|
"tenantId",
|
|
@@ -2450,20 +2760,27 @@ const lookupUsers = async (params) => {
|
|
|
2450
2760
|
return [];
|
|
2451
2761
|
}
|
|
2452
2762
|
try {
|
|
2453
|
-
const url = `${apiBaseUrl}/api/v3/open-web/tenant/users/-/lookup/?lookups=${users.join(",")}&lookup_fields=${exactSearchKey}`;
|
|
2763
|
+
const url = `${resolvedConfig.apiBaseUrl}/api/v3/open-web/tenant/users/-/lookup/?lookups=${users.join(",")}&lookup_fields=${exactSearchKey}`;
|
|
2764
|
+
const requestCredentials = resolveRequestCredentials(url, resolvedConfig.allowCrossOriginCredentials);
|
|
2454
2765
|
const response = await fetch(url, {
|
|
2455
2766
|
method: "GET",
|
|
2456
|
-
headers: { "x-bk-tenant-id": tenantId },
|
|
2457
|
-
credentials:
|
|
2767
|
+
headers: { "x-bk-tenant-id": resolvedConfig.tenantId },
|
|
2768
|
+
credentials: requestCredentials
|
|
2458
2769
|
});
|
|
2459
|
-
|
|
2770
|
+
ensureResponseOk(response, "批量查找用户", resolvedConfig.apiConfig);
|
|
2460
2771
|
return (await response.json()).data || [];
|
|
2461
2772
|
} catch (error) {
|
|
2462
|
-
|
|
2773
|
+
const status = extractStatus(error);
|
|
2774
|
+
if (status !== UNAUTHORIZED_STATUS) handleApiError("批量查找用户", error, resolvedConfig.apiConfig, status, false);
|
|
2463
2775
|
return [];
|
|
2464
2776
|
}
|
|
2465
2777
|
};
|
|
2466
|
-
|
|
2778
|
+
/**
|
|
2779
|
+
* 将API返回的用户数据格式化为组件所需格式
|
|
2780
|
+
* @param users - API返回的用户列表
|
|
2781
|
+
* @returns 格式化后的用户列表
|
|
2782
|
+
*/
|
|
2783
|
+
var formatUsers = (users, enableMultiTenantMode = true) => {
|
|
2467
2784
|
if (!users || !Array.isArray(users)) return [];
|
|
2468
2785
|
if (!enableMultiTenantMode) return users.map((user) => ({
|
|
2469
2786
|
...user,
|
|
@@ -2480,7 +2797,13 @@ const formatUsers = (users, enableMultiTenantMode = true) => {
|
|
|
2480
2797
|
...user
|
|
2481
2798
|
}));
|
|
2482
2799
|
};
|
|
2483
|
-
|
|
2800
|
+
/**
|
|
2801
|
+
* 获取用户列表(兼容旧版本的人员选择器)
|
|
2802
|
+
* @param url - 请求的 URL
|
|
2803
|
+
* @param params - 请求参数
|
|
2804
|
+
* @returns 用户列表
|
|
2805
|
+
*/
|
|
2806
|
+
var getUserList = async (url, params) => {
|
|
2484
2807
|
const { userIds, keyword, pageSize = 20, page = 1, appCode = "bk-magicbox" } = params;
|
|
2485
2808
|
return (await jsonpRequest(url, { params: {
|
|
2486
2809
|
exact_lookups: userIds?.join(",") || void 0,
|
|
@@ -2490,9 +2813,23 @@ const getUserList = async (url, params) => {
|
|
|
2490
2813
|
app_code: appCode
|
|
2491
2814
|
} }))?.results || [];
|
|
2492
2815
|
};
|
|
2493
|
-
|
|
2816
|
+
//#endregion
|
|
2817
|
+
//#region src/hooks/use-current-user.ts
|
|
2818
|
+
/**
|
|
2819
|
+
* 当前用户处理 Hook
|
|
2820
|
+
* @module hooks/useCurrentUser
|
|
2821
|
+
*/
|
|
2822
|
+
/**
|
|
2823
|
+
* 当前用户处理 Hook
|
|
2824
|
+
* @param options - 配置选项
|
|
2825
|
+
* @returns 当前用户相关方法
|
|
2826
|
+
*/
|
|
2827
|
+
var useCurrentUser = (options) => {
|
|
2494
2828
|
const { apiBaseUrl, tenantId, currentUserId, exactSearchKey = DEFAULT_EXACT_SEARCH_KEY, enableMultiTenantMode = true } = options;
|
|
2495
2829
|
const loading = ref(false);
|
|
2830
|
+
/**
|
|
2831
|
+
* 获取当前用户信息
|
|
2832
|
+
*/
|
|
2496
2833
|
const fetchCurrentUser = async () => {
|
|
2497
2834
|
if (!currentUserId) return null;
|
|
2498
2835
|
loading.value = true;
|
|
@@ -2517,6 +2854,9 @@ const useCurrentUser = (options) => {
|
|
|
2517
2854
|
fetchCurrentUser
|
|
2518
2855
|
};
|
|
2519
2856
|
};
|
|
2857
|
+
//#endregion
|
|
2858
|
+
//#region ../../node_modules/.pnpm/js-cookie@3.0.5/node_modules/js-cookie/dist/js.cookie.mjs
|
|
2859
|
+
/*! js-cookie v3.0.5 | MIT */
|
|
2520
2860
|
function assign(target) {
|
|
2521
2861
|
for (var i = 1; i < arguments.length; i++) {
|
|
2522
2862
|
var source = arguments[i];
|
|
@@ -2573,8 +2913,8 @@ function init(converter, defaultAttributes) {
|
|
|
2573
2913
|
withAttributes: function(attributes) {
|
|
2574
2914
|
return init(this.converter, assign({}, this.attributes, attributes));
|
|
2575
2915
|
},
|
|
2576
|
-
withConverter: function(converter
|
|
2577
|
-
return init(assign({}, this.converter, converter
|
|
2916
|
+
withConverter: function(converter) {
|
|
2917
|
+
return init(assign({}, this.converter, converter), this.attributes);
|
|
2578
2918
|
}
|
|
2579
2919
|
}, {
|
|
2580
2920
|
attributes: { value: Object.freeze(defaultAttributes) },
|
|
@@ -2582,22 +2922,30 @@ function init(converter, defaultAttributes) {
|
|
|
2582
2922
|
});
|
|
2583
2923
|
}
|
|
2584
2924
|
var api = init(defaultConverter, { path: "/" });
|
|
2925
|
+
//#endregion
|
|
2926
|
+
//#region src/locale/en-us.ts
|
|
2585
2927
|
var en_us_default = {
|
|
2586
2928
|
我: "Me",
|
|
2587
2929
|
请输入人员名称搜索: "Please enter the name of the user to search",
|
|
2930
|
+
最近选择: "Recent selections",
|
|
2588
2931
|
用户群组: "User Group",
|
|
2589
2932
|
无匹配人员: "No matching users",
|
|
2590
2933
|
虚拟账号: "Virtual Account",
|
|
2591
2934
|
用户: "User"
|
|
2592
2935
|
};
|
|
2936
|
+
//#endregion
|
|
2937
|
+
//#region src/locale/zh-cn.ts
|
|
2593
2938
|
var zh_cn_default = {
|
|
2594
2939
|
我: "我",
|
|
2595
2940
|
请输入人员名称搜索: "请输入人员名称搜索",
|
|
2941
|
+
最近选择: "最近选择",
|
|
2596
2942
|
用户群组: "用户群组",
|
|
2597
2943
|
无匹配人员: "无匹配人员",
|
|
2598
2944
|
虚拟账号: "虚拟账号",
|
|
2599
2945
|
用户: "用户"
|
|
2600
2946
|
};
|
|
2947
|
+
//#endregion
|
|
2948
|
+
//#region src/hooks/use-i18n.ts
|
|
2601
2949
|
var BLUEKINNG_LANGUAGE = "blueking_language";
|
|
2602
2950
|
var languageMap = {
|
|
2603
2951
|
"en-US": en_us_default,
|
|
@@ -2636,9 +2984,28 @@ var use_i18n_default = () => {
|
|
|
2636
2984
|
t
|
|
2637
2985
|
};
|
|
2638
2986
|
};
|
|
2639
|
-
|
|
2987
|
+
//#endregion
|
|
2988
|
+
//#region src/hooks/use-input-handler.ts
|
|
2989
|
+
/**
|
|
2990
|
+
* 输入处理公共逻辑 Hook
|
|
2991
|
+
* @module hooks/useInputHandler
|
|
2992
|
+
*/
|
|
2993
|
+
/**
|
|
2994
|
+
* 输入处理公共逻辑 Hook
|
|
2995
|
+
* @param options - 配置选项
|
|
2996
|
+
* @returns 输入处理相关方法
|
|
2997
|
+
*/
|
|
2998
|
+
var useInputHandler = (options) => {
|
|
2640
2999
|
const { apiBaseUrl, tenantId, searchQuery, selectedUsers, allowCreate = false, freePaste = false, enableMultiTenantMode = true, maxCount = 0, onAddUser, onBatchAddUsers } = options;
|
|
2641
3000
|
const isPasting = ref(false);
|
|
3001
|
+
/** 单次粘贴最多处理数量(后端限制) */
|
|
3002
|
+
const MAX_PASTE_USERS = 100;
|
|
3003
|
+
/** 批量查询每批数量(不超过后端限制) */
|
|
3004
|
+
const LOOKUP_BATCH_SIZE = 100;
|
|
3005
|
+
/**
|
|
3006
|
+
* 创建自定义用户对象
|
|
3007
|
+
* @param loginName - 用户登录名
|
|
3008
|
+
*/
|
|
2642
3009
|
const createCustomUser = (loginName) => ({
|
|
2643
3010
|
id: loginName,
|
|
2644
3011
|
name: loginName,
|
|
@@ -2646,19 +3013,47 @@ const useInputHandler = (options) => {
|
|
|
2646
3013
|
tenantId: "",
|
|
2647
3014
|
login_name: loginName
|
|
2648
3015
|
});
|
|
3016
|
+
/**
|
|
3017
|
+
* 解析粘贴文本为用户列表
|
|
3018
|
+
* @param text - 粘贴的文本
|
|
3019
|
+
*/
|
|
2649
3020
|
const parsePastedText = (text) => {
|
|
2650
|
-
|
|
3021
|
+
const normalizedUsers = text.split(/[,,;\n\s]+/).filter(Boolean).map((user) => user.trim().replace(/\s*\(.*?\)\s*/, "")).filter(Boolean);
|
|
3022
|
+
return Array.from(new Set(normalizedUsers)).slice(0, MAX_PASTE_USERS);
|
|
2651
3023
|
};
|
|
3024
|
+
/**
|
|
3025
|
+
* 将用户列表按指定大小分批
|
|
3026
|
+
* @param usersList - 用户列表
|
|
3027
|
+
* @param batchSize - 每批大小
|
|
3028
|
+
*/
|
|
3029
|
+
const chunkUsersList = (usersList, batchSize) => {
|
|
3030
|
+
const chunks = [];
|
|
3031
|
+
for (let i = 0; i < usersList.length; i += batchSize) chunks.push(usersList.slice(i, i + batchSize));
|
|
3032
|
+
return chunks;
|
|
3033
|
+
};
|
|
3034
|
+
/**
|
|
3035
|
+
* 合并用户列表并去重
|
|
3036
|
+
* @param existingUsers - 现有用户列表
|
|
3037
|
+
* @param newUsers - 新用户列表
|
|
3038
|
+
*/
|
|
2652
3039
|
const mergeUsers = (existingUsers, newUsers) => {
|
|
2653
3040
|
const userMap = /* @__PURE__ */ new Map();
|
|
2654
3041
|
for (const user of [...existingUsers, ...newUsers]) if (!userMap.has(user.id)) userMap.set(user.id, user);
|
|
2655
3042
|
return Array.from(userMap.values());
|
|
2656
3043
|
};
|
|
3044
|
+
/**
|
|
3045
|
+
* 处理 Enter 键创建自定义用户
|
|
3046
|
+
* @param event - 键盘事件
|
|
3047
|
+
*/
|
|
2657
3048
|
const handleEnterCreate = (event) => {
|
|
2658
3049
|
if (event.key !== "Enter" || !allowCreate || !searchQuery.value.trim()) return;
|
|
2659
3050
|
const customUser = createCustomUser(searchQuery.value.trim());
|
|
2660
3051
|
if (!selectedUsers.value.some((user) => user.id === customUser.id)) onAddUser(customUser);
|
|
2661
3052
|
};
|
|
3053
|
+
/**
|
|
3054
|
+
* 处理粘贴事件
|
|
3055
|
+
* @param event - 粘贴事件
|
|
3056
|
+
*/
|
|
2662
3057
|
const handlePaste = async (event) => {
|
|
2663
3058
|
event.preventDefault();
|
|
2664
3059
|
const pastedText = event.clipboardData?.getData("text")?.trim();
|
|
@@ -2667,13 +3062,19 @@ const useInputHandler = (options) => {
|
|
|
2667
3062
|
try {
|
|
2668
3063
|
const usersList = parsePastedText(pastedText);
|
|
2669
3064
|
if (usersList.length === 0) return;
|
|
2670
|
-
const
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
3065
|
+
const lookupBatches = chunkUsersList(usersList, LOOKUP_BATCH_SIZE);
|
|
3066
|
+
const lookupResults = [];
|
|
3067
|
+
for (const batch of lookupBatches) {
|
|
3068
|
+
const result = await lookupUsers({
|
|
3069
|
+
apiBaseUrl,
|
|
3070
|
+
tenantId,
|
|
3071
|
+
exactSearchKey: "login_name",
|
|
3072
|
+
usersList: batch,
|
|
3073
|
+
enableMultiTenantMode
|
|
3074
|
+
});
|
|
3075
|
+
lookupResults.push(...result);
|
|
3076
|
+
}
|
|
3077
|
+
const formattedUsers = formatUsers(lookupResults, enableMultiTenantMode);
|
|
2677
3078
|
if (onBatchAddUsers) {
|
|
2678
3079
|
let mergedUsers = mergeUsers(selectedUsers.value, formattedUsers);
|
|
2679
3080
|
if (freePaste) {
|
|
@@ -2696,7 +3097,20 @@ const useInputHandler = (options) => {
|
|
|
2696
3097
|
handlePaste
|
|
2697
3098
|
};
|
|
2698
3099
|
};
|
|
2699
|
-
|
|
3100
|
+
//#endregion
|
|
3101
|
+
//#region src/hooks/use-resize-observer.ts
|
|
3102
|
+
/**
|
|
3103
|
+
* ResizeObserver Hook
|
|
3104
|
+
* @module hooks/useResizeObserver
|
|
3105
|
+
*/
|
|
3106
|
+
/**
|
|
3107
|
+
* 监听元素大小变化的 Hook
|
|
3108
|
+
* @param target - 目标元素引用
|
|
3109
|
+
* @param callback - 大小变化时的回调函数
|
|
3110
|
+
* @param options - 配置选项
|
|
3111
|
+
* @returns 停止观察的函数
|
|
3112
|
+
*/
|
|
3113
|
+
var useResizeObserver = (target, callback, options = {}) => {
|
|
2700
3114
|
const { immediate = true } = options;
|
|
2701
3115
|
let observer = null;
|
|
2702
3116
|
const cleanup = () => {
|
|
@@ -2736,9 +3150,25 @@ const useResizeObserver = (target, callback, options = {}) => {
|
|
|
2736
3150
|
onUnmounted(cleanup);
|
|
2737
3151
|
return cleanup;
|
|
2738
3152
|
};
|
|
2739
|
-
|
|
3153
|
+
//#endregion
|
|
3154
|
+
//#region src/hooks/use-tenant-data.ts
|
|
3155
|
+
/**
|
|
3156
|
+
* 租户数据处理 Hook
|
|
3157
|
+
* @module hooks/useTenantData
|
|
3158
|
+
*/
|
|
3159
|
+
/**
|
|
3160
|
+
* 使用租户数据的Hook
|
|
3161
|
+
* @param apiBaseUrl - API基础URL
|
|
3162
|
+
* @param tenantId - 租户ID
|
|
3163
|
+
* @param enableMultiTenantMode - 是否启用多租户模式
|
|
3164
|
+
* @returns 租户数据和加载状态
|
|
3165
|
+
*/
|
|
3166
|
+
var useTenantData = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
2740
3167
|
const tenants = ref({});
|
|
2741
3168
|
const loading = ref(false);
|
|
3169
|
+
/**
|
|
3170
|
+
* 获取租户数据
|
|
3171
|
+
*/
|
|
2742
3172
|
const fetchTenants = async () => {
|
|
2743
3173
|
if (!apiBaseUrl || !tenantId) {
|
|
2744
3174
|
console.warn("获取租户需要提供有效的API基础URL和租户ID");
|
|
@@ -2767,7 +3197,15 @@ const useTenantData = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
|
2767
3197
|
fetchTenants
|
|
2768
3198
|
};
|
|
2769
3199
|
};
|
|
2770
|
-
|
|
3200
|
+
//#endregion
|
|
3201
|
+
//#region src/utils/common.ts
|
|
3202
|
+
/**
|
|
3203
|
+
* 防抖函数
|
|
3204
|
+
* @param fn - 需要防抖的函数
|
|
3205
|
+
* @param delay - 延迟时间(毫秒)
|
|
3206
|
+
* @returns 防抖后的函数
|
|
3207
|
+
*/
|
|
3208
|
+
var debounce = (fn, delay) => {
|
|
2771
3209
|
let timer = null;
|
|
2772
3210
|
return function(...args) {
|
|
2773
3211
|
if (timer) clearTimeout(timer);
|
|
@@ -2777,7 +3215,14 @@ const debounce = (fn, delay) => {
|
|
|
2777
3215
|
}, delay);
|
|
2778
3216
|
};
|
|
2779
3217
|
};
|
|
2780
|
-
|
|
3218
|
+
/**
|
|
3219
|
+
* 计算标签容器可见数量
|
|
3220
|
+
* @param container - 容器元素
|
|
3221
|
+
* @param items - 项目元素列表
|
|
3222
|
+
* @param containerWidth - 容器宽度
|
|
3223
|
+
* @returns 可见项目数量
|
|
3224
|
+
*/
|
|
3225
|
+
var calculateVisibleTags = (container, items, containerWidth) => {
|
|
2781
3226
|
if (!container || !items.length) return 0;
|
|
2782
3227
|
let totalWidth = 0;
|
|
2783
3228
|
let visibleCount = 0;
|
|
@@ -2794,10 +3239,27 @@ const calculateVisibleTags = (container, items, containerWidth) => {
|
|
|
2794
3239
|
}
|
|
2795
3240
|
return Math.max(1, visibleCount);
|
|
2796
3241
|
};
|
|
2797
|
-
|
|
3242
|
+
//#endregion
|
|
3243
|
+
//#region src/hooks/use-user-search.ts
|
|
3244
|
+
/**
|
|
3245
|
+
* 用户搜索 Hook
|
|
3246
|
+
* @module hooks/useUserSearch
|
|
3247
|
+
*/
|
|
3248
|
+
/**
|
|
3249
|
+
* 使用用户搜索的Hook
|
|
3250
|
+
* @param apiBaseUrl - API基础URL
|
|
3251
|
+
* @param tenantId - 租户ID
|
|
3252
|
+
* @param enableMultiTenantMode - 是否启用多租户模式
|
|
3253
|
+
* @returns 用户搜索相关状态和方法
|
|
3254
|
+
*/
|
|
3255
|
+
var useUserSearch = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
2798
3256
|
const searchResults = ref([]);
|
|
2799
3257
|
const loading = ref(false);
|
|
2800
3258
|
const searchQuery = ref("");
|
|
3259
|
+
/**
|
|
3260
|
+
* 执行用户搜索
|
|
3261
|
+
* @param keyword - 搜索关键词
|
|
3262
|
+
*/
|
|
2801
3263
|
const performSearch = async (keyword) => {
|
|
2802
3264
|
if (!keyword?.length) {
|
|
2803
3265
|
searchResults.value = [];
|
|
@@ -2825,11 +3287,18 @@ const useUserSearch = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
|
2825
3287
|
}
|
|
2826
3288
|
};
|
|
2827
3289
|
const debouncedSearch = debounce(performSearch, 300);
|
|
3290
|
+
/**
|
|
3291
|
+
* 处理输入变化
|
|
3292
|
+
* @param value - 输入值
|
|
3293
|
+
*/
|
|
2828
3294
|
const handleSearchInput = (value) => {
|
|
2829
3295
|
loading.value = true;
|
|
2830
3296
|
searchQuery.value = value.trim();
|
|
2831
3297
|
debouncedSearch(searchQuery.value);
|
|
2832
3298
|
};
|
|
3299
|
+
/**
|
|
3300
|
+
* 清空搜索
|
|
3301
|
+
*/
|
|
2833
3302
|
const clearSearch = () => {
|
|
2834
3303
|
searchQuery.value = "";
|
|
2835
3304
|
searchResults.value = [];
|
|
@@ -2844,8 +3313,23 @@ const useUserSearch = (apiBaseUrl, tenantId, enableMultiTenantMode = true) => {
|
|
|
2844
3313
|
clearSearch
|
|
2845
3314
|
};
|
|
2846
3315
|
};
|
|
2847
|
-
|
|
3316
|
+
//#endregion
|
|
3317
|
+
//#region src/hooks/use-user-selection.ts
|
|
3318
|
+
/**
|
|
3319
|
+
* 用户选择公共逻辑 Hook
|
|
3320
|
+
* @module hooks/useUserSelection
|
|
3321
|
+
*/
|
|
3322
|
+
/**
|
|
3323
|
+
* 用户选择公共逻辑 Hook
|
|
3324
|
+
* @param options - 配置选项
|
|
3325
|
+
* @returns 用户选择相关方法
|
|
3326
|
+
*/
|
|
3327
|
+
var useUserSelection = (options) => {
|
|
2848
3328
|
const { selectedUserIds, excludeUserIds, userGroup, searchQuery } = options;
|
|
3329
|
+
/**
|
|
3330
|
+
* 创建自定义用户对象
|
|
3331
|
+
* @param loginName - 用户登录名
|
|
3332
|
+
*/
|
|
2849
3333
|
const createCustomUser = (loginName) => ({
|
|
2850
3334
|
id: loginName,
|
|
2851
3335
|
name: loginName,
|
|
@@ -2853,11 +3337,19 @@ const useUserSelection = (options) => {
|
|
|
2853
3337
|
tenantId: "",
|
|
2854
3338
|
login_name: loginName
|
|
2855
3339
|
});
|
|
3340
|
+
/**
|
|
3341
|
+
* 检查用户是否已选中
|
|
3342
|
+
* @param userId - 用户ID
|
|
3343
|
+
*/
|
|
2856
3344
|
const isUserSelected = (userId) => {
|
|
2857
3345
|
return selectedUserIds.value.includes(userId);
|
|
2858
3346
|
};
|
|
2859
|
-
|
|
2860
|
-
|
|
3347
|
+
/**
|
|
3348
|
+
* 过滤选项(排除已选和排除列表)
|
|
3349
|
+
* @param options - 原始选项列表
|
|
3350
|
+
*/
|
|
3351
|
+
const filterOptions = (options) => {
|
|
3352
|
+
return options.filter((user) => !isUserSelected(user.id)).filter((user) => !excludeUserIds?.value?.includes(user.id));
|
|
2861
3353
|
};
|
|
2862
3354
|
return {
|
|
2863
3355
|
createCustomUser,
|
|
@@ -2874,6 +3366,8 @@ const useUserSelection = (options) => {
|
|
|
2874
3366
|
})
|
|
2875
3367
|
};
|
|
2876
3368
|
};
|
|
3369
|
+
//#endregion
|
|
3370
|
+
//#region src/components/me-tag.vue?vue&type=script&setup=true&lang.ts
|
|
2877
3371
|
var me_tag_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
2878
3372
|
name: "MeTag",
|
|
2879
3373
|
__name: "me-tag",
|
|
@@ -2892,9 +3386,21 @@ var me_tag_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
2892
3386
|
emits: ["click"],
|
|
2893
3387
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2894
3388
|
__expose();
|
|
3389
|
+
/**
|
|
3390
|
+
* "我"标签组件
|
|
3391
|
+
*/
|
|
2895
3392
|
const { t } = use_i18n_default();
|
|
3393
|
+
/**
|
|
3394
|
+
* 组件属性
|
|
3395
|
+
*/
|
|
2896
3396
|
const props = __props;
|
|
3397
|
+
/**
|
|
3398
|
+
* 组件事件
|
|
3399
|
+
*/
|
|
2897
3400
|
const emit = __emit;
|
|
3401
|
+
/**
|
|
3402
|
+
* 处理点击事件
|
|
3403
|
+
*/
|
|
2898
3404
|
const handleClick = () => {
|
|
2899
3405
|
if (props.isDisabled) return;
|
|
2900
3406
|
emit("click");
|
|
@@ -2912,11 +3418,15 @@ var me_tag_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineC
|
|
|
2912
3418
|
return __returned__;
|
|
2913
3419
|
}
|
|
2914
3420
|
});
|
|
2915
|
-
|
|
3421
|
+
//#endregion
|
|
3422
|
+
//#region \0plugin-vue:export-helper
|
|
3423
|
+
var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
2916
3424
|
const target = sfc.__vccOpts || sfc;
|
|
2917
3425
|
for (const [key, val] of props) target[key] = val;
|
|
2918
3426
|
return target;
|
|
2919
3427
|
};
|
|
3428
|
+
//#endregion
|
|
3429
|
+
//#region src/components/me-tag.vue
|
|
2920
3430
|
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
2921
3431
|
return $props.currentUserId ? (openBlock(), createElementBlock("div", {
|
|
2922
3432
|
key: 0,
|
|
@@ -2924,14 +3434,22 @@ function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
2924
3434
|
onClick: withModifiers($setup.handleClick, ["stop"])
|
|
2925
3435
|
}, toDisplayString($setup.t("我")), 3)) : createCommentVNode("v-if", true);
|
|
2926
3436
|
}
|
|
2927
|
-
var me_tag_default = /* @__PURE__ */
|
|
3437
|
+
var me_tag_default = /* @__PURE__ */ _plugin_vue_export_helper_default(me_tag_vue_vue_type_script_setup_true_lang_default, [
|
|
2928
3438
|
["render", _sfc_render$3],
|
|
2929
3439
|
["__scopeId", "data-v-a1054364"],
|
|
2930
3440
|
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/me-tag.vue"]
|
|
2931
3441
|
]);
|
|
3442
|
+
//#endregion
|
|
3443
|
+
//#region src/assets/user-group.svg
|
|
2932
3444
|
var user_group_default = "data:image/svg+xml,%3csvg%20viewBox='0%200%201024%201024'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20style='fill:%20%23A3C5FD;'%3e%3cpath%20fill-rule='evenodd'%20d='M405.7858816%20162.66256256C416.4461344%20160.6535248%20439.8986944%20159.44810208%20457.3815104%20160.25171712%20484.2453504%20161.05533248%20494.052784%20163.4661776%20516.226112%20174.7167888%20567.8217376%20200.43247136%20597.670448%20242.22045568%20606.6250624%20301.28616416%20617.711728%20374.415136%20593.4063488%20443.5260352%20535.8409792%20500.180896%20509.8299584%20525.8965792%20505.565856%20537.5489984%20514.0940608%20557.237568%20521.3430336%20572.9080608%20546.0748224%20586.5695168%20629.2248%20620.3213504%20691.054272%20645.2334208%20760.985536%20687.4232096%20767.8080992%20703.8973216%20774.6306624%20720.3714304%20784.8645056%20752.114224%20791.6870688%20777.4280992%20799.7888608%20807.1618592%20793.3927072%20818.8142784%20761.8383584%20832.4757344%20720.4765728%20850.155264%20669.3073536%20857.3878016%20546.9276416%20862.2094912%20392.9935776%20868.2366048%20227.12002944%20858.5932224%20162.30568672%20840.1100768%20134.5890272%20832.4757344%20108.15159776%20815.1980096%20100.47621504%20799.5275136%2093.6536528%20786.2678656%2094.08006304%20784.2588288%20105.59313696%20746.4889184%20116.67980096%20709.924432%20119.23826176%20705.5045504%20141.41158944%20685.4141728%20143.84821888%20683.2001312%20146.05397248%20681.2036448%20148.2232096%20679.3252416L152.13038144%20676.0501632C159.5946992%20670.0236288%20167.98497088%20664.6722176%20184.94031712%20656.0863296L191.29263904%20652.915344C215.97973152%20640.7492736%20256.51622304%20622.3959904%20329.458464%20589.3821696%20359.7335872%20575.3189056%20371.2466592%20563.6664896%20375.084352%20542.772496%20377.2164032%20530.316464%20374.6579424%20526.7001952%20345.2356416%20496.9664352%20295.34565344%20446.338688%20274.02514592%20396.9163584%20273.59873568%20331.0199232%20273.59873568%20291.24097568%20282.12693888%20265.52529312%20307.71154784%20228.15719168%20332.8697472%20191.19089792%20365.703328%20169.49329056%20405.7858816%20162.66256256ZM668.7713728%20226.60405184C756.683056%20211.50282816%20820.4190272%20263.09867616%20827.0124032%20354.9644544%20831.8475456%20416.6277856%20815.1443264%20461.931456%20770.3093664%20510.1714752%20752.287472%20529.4674848%20747.891888%20536.5986176%20748.3314464%20548.344016%20748.7710048%20555.8946272%20751.4083552%20565.123152%20754.485264%20568.8984576%20757.5621728%20572.2542848%20788.331264%20588.1944672%20823.0563776%20604.1346464%20944.3745024%20659.92528%20966.791984%20682.996592%20958.4403712%20744.6599232%20954.923904%20771.9260224%20956.6821376%20771.0870656%20890.308816%20787.0272448%20867.4517792%20792.8999456%20845.0343008%20798.3531648%20841.0782752%20799.6116%20835.3640128%20801.2895136%20833.1662208%20797.9336864%20830.5288704%20781.5740256%20824.3750528%20739.6261824%20812.0674176%20710.6821696%20790.0894976%20687.6108576%20752.287472%20647.3409248%20703.9360448%20619.6553504%20624.3759712%20593.6476864%20597.5629088%20584.4191616%20560.64%20550.8608864%20560.64%20534.920704%20560.64%20527.7895712%20569.8707264%20514.7857408%20589.6508544%20494.6507744%20620.859504%20461.931456%20639.7605152%20429.631616%20648.5516832%20394.8149056%20655.5846208%20366.7098496%20652.0681504%20283.23364096%20642.837424%20254.7091072%20635.3649312%20231.63779328%20634.4858144%20232.47675008%20668.7713728%20226.60405184Z'%3e%3c/path%3e%3c/svg%3e";
|
|
3445
|
+
//#endregion
|
|
3446
|
+
//#region src/assets/user.svg
|
|
2933
3447
|
var user_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='32px'%20height='32px'%20viewBox='0%200%2032%2032'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eIcon/用户%3c/title%3e%3cg%20id='Icon/用户'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='user-(1)'%20transform='translate(3,%202)'%20fill='%23A3C5FD'%20fill-rule='nonzero'%3e%3cpath%20d='M13.0077612,27.9989067%20C10.3002732,27.9989067%207.59285518,28.0018792%204.88515705,27.997455%20C3.95018807,27.9959342%203.05044678,27.8282323%202.22816433,27.3628696%20C0.998627601,26.6672451%200.29953695,25.6114692%200.0864200465,24.2387462%20C-0.0656962495,23.259079%200.0147040645,22.4675755%200.0874005263,21.4879775%20C0.187970957,20.13461%200.423078914,19.3321844%200.863249688,18.0430358%20C1.22365046,16.9873982%201.73014453,16.0067633%202.49702917,15.175719%20C3.42254341,14.1726178%204.6014447,13.7297906%205.9255989,13.6440041%20C6.33292322,13.6073668%206.66741099,13.712025%206.9979768,13.9263185%20C7.58886318,14.3094892%208.17393665,14.7060014%208.79220674,15.0421658%20C10.1097776,15.758321%2011.5447274,16.1099698%2013.0616182,16.0930337%20C14.6806203,16.0750607%2016.2142496,15.63963%2017.592821,14.8169502%20C18.0555431,14.5407189%2018.5150436,14.256538%2018.9569652,13.9491996%20C19.3610679,13.6681294%2019.7808585,13.5749462%2020.274326,13.6337733%20C21.462472,13.7340074%2022.3872158,14.1103345%2023.2340106,14.8851094%20C23.902636,15.496952%2024.3685096,16.2520257%2024.7518119,17.0611566%20C25.272453,18.1598604%2025.5462904,18.7976948%2025.7441396,19.9861253%20C25.9499728,21.2233595%2026.0256808,22.2792045%2025.9924842,23.5308171%20C25.9627193,24.6543374%2025.6405577,25.6840525%2024.8535729,26.5307194%20C24.1686994,27.2671979%2023.3129402,27.7090574%2022.3211027,27.8808379%20C21.9232331,27.9495501%2021.5154185,27.9922014%2021.1120162,27.9935148%20C18.4104811,28.0036073%2015.7090862,27.9989067%2013.0077612,27.9989067%20L13.0077612,27.9989067%20Z%20M5.91775495,6.98479749%20C5.84814002,3.25685016%209.08684454,-0.00255470186%2013.0162355,1.5025268e-06%20C16.9117994,0.00256071584%2020.1304739,3.23452217%2020.1095656,7.04113598%20C20.0884528,10.8082092%2016.8998935,14.015354%2013.0058002,14.0149393%20C9.10134181,14.0145245%205.83322254,10.7695672%205.91775495,6.98479749%20Z'%20id='形状'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e";
|
|
3448
|
+
//#endregion
|
|
3449
|
+
//#region src/assets/virtual.svg
|
|
2934
3450
|
var virtual_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='32px'%20height='32px'%20viewBox='0%200%2032%2032'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eIcon/虚拟icon%3c/title%3e%3cg%20id='Icon/虚拟icon'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cpath%20d='M27.4705882,3%20C28.315259,3%2029,3.68474098%2029,4.52941178%20L29,22.4623054%20C29,23.3069762%2028.315259,23.9917172%2027.4705882,23.9917172%20L20.5882353,23.9917172%20L20.5882353,27.0244081%20L24.0294118,27.0244081%20C24.2405794,27.0244081%2024.4117647,27.1955933%2024.4117647,27.406761%20L24.4117647,28.617647%20C24.4117647,28.8288148%2024.2405795,29%2024.0294118,29%20L7.97058824,29%20C7.75942054,29%207.58823529,28.8288148%207.58823529,28.617647%20L7.58823529,27.406761%20C7.58823531,27.1955933%207.75942055,27.0244081%207.97058824,27.0244081%20L11.4117647,27.0244081%20L11.4117647,23.9917172%20L4.52941178,23.9917172%20C3.68474098,23.9917172%203,23.3069762%203,22.4623054%20L3,4.52941178%20C3,3.68474098%203.68474098,3%204.52941178,3%20L27.4705882,3%20Z%20M19,24%20L13,24%20L13,27%20L19,27%20L19,24%20Z%20M23.4117647,7%20L8.58823529,7%20C8.03595054,7%207.58823529,7.44771525%207.58823529,8%20L7.58823529,19%20C7.58823529,19.5522847%208.03595054,20%208.58823529,20%20L23.4117647,20%20C23.9640495,20%2024.4117647,19.5522847%2024.4117647,19%20L24.4117647,8%20C24.4117647,7.44771525%2023.9640495,7%2023.4117647,7%20Z%20M12,10%20C12.5522847,10%2013,10.4477153%2013,11%20L13,13%20C13,13.5522847%2012.5522847,14%2012,14%20C11.4477153,14%2011,13.5522847%2011,13%20L11,11%20C11,10.4477153%2011.4477153,10%2012,10%20Z%20M20,10%20C20.5522847,10%2021,10.4477153%2021,11%20L21,13%20C21,13.5522847%2020.5522847,14%2020,14%20C19.4477153,14%2019,13.5522847%2019,13%20L19,11%20C19,10.4477153%2019.4477153,10%2020,10%20Z%20M26,5%20C25.4477153,5%2025,5.44771525%2025,6%20C25,6.55228475%2025.4477153,7%2026,7%20C26.5522847,7%2027,6.55228475%2027,6%20C27,5.44771525%2026.5522847,5%2026,5%20Z'%20id='蒙版'%20fill='%23A3C5FD'%20fill-rule='nonzero'%3e%3c/path%3e%3c/g%3e%3c/svg%3e";
|
|
3451
|
+
//#endregion
|
|
3452
|
+
//#region src/components/user-render.ts
|
|
2935
3453
|
var user_render_default = defineComponent({
|
|
2936
3454
|
name: "UserRender",
|
|
2937
3455
|
props: {
|
|
@@ -2968,13 +3486,13 @@ var user_render_default = defineComponent({
|
|
|
2968
3486
|
const loginName = user.login_name || user.bk_username || user.id;
|
|
2969
3487
|
return `${props.avatarBaseUrl}${loginName}.png?default_when_absent=true`;
|
|
2970
3488
|
};
|
|
2971
|
-
const defaultRender = (h
|
|
2972
|
-
return h
|
|
3489
|
+
const defaultRender = (h, props) => {
|
|
3490
|
+
return h("div", { style: {
|
|
2973
3491
|
display: "flex",
|
|
2974
3492
|
alignItems: "center"
|
|
2975
3493
|
} }, [
|
|
2976
|
-
props
|
|
2977
|
-
src: getAvatarUrl(props
|
|
3494
|
+
props.hasAvatar ? h("img", {
|
|
3495
|
+
src: getAvatarUrl(props.user),
|
|
2978
3496
|
style: {
|
|
2979
3497
|
width: "20px",
|
|
2980
3498
|
height: "20px",
|
|
@@ -2983,11 +3501,11 @@ var user_render_default = defineComponent({
|
|
|
2983
3501
|
flexShrink: 0
|
|
2984
3502
|
}
|
|
2985
3503
|
}) : null,
|
|
2986
|
-
h
|
|
2987
|
-
props
|
|
3504
|
+
h("span", props.user.name),
|
|
3505
|
+
props.user.tenantId !== props.tenantId && props.user.tenantId ? h("span", { style: {
|
|
2988
3506
|
color: "#f59500",
|
|
2989
3507
|
marginLeft: "4px"
|
|
2990
|
-
} }, `@${props
|
|
3508
|
+
} }, `@${props.tenants[props.user.tenantId] || props.user.tenantId}`) : null
|
|
2991
3509
|
]);
|
|
2992
3510
|
};
|
|
2993
3511
|
return () => {
|
|
@@ -3000,6 +3518,8 @@ var user_render_default = defineComponent({
|
|
|
3000
3518
|
};
|
|
3001
3519
|
}
|
|
3002
3520
|
});
|
|
3521
|
+
//#endregion
|
|
3522
|
+
//#region src/components/selection-popover.vue?vue&type=script&setup=true&lang.ts
|
|
3003
3523
|
var selection_popover_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3004
3524
|
name: "SelectionPopover",
|
|
3005
3525
|
__name: "selection-popover",
|
|
@@ -3049,6 +3569,16 @@ var selection_popover_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
3049
3569
|
required: false,
|
|
3050
3570
|
default: () => []
|
|
3051
3571
|
},
|
|
3572
|
+
recentUsers: {
|
|
3573
|
+
type: Array,
|
|
3574
|
+
required: false,
|
|
3575
|
+
default: () => []
|
|
3576
|
+
},
|
|
3577
|
+
recentUsersName: {
|
|
3578
|
+
type: String,
|
|
3579
|
+
required: false,
|
|
3580
|
+
default: ""
|
|
3581
|
+
},
|
|
3052
3582
|
renderListItem: {
|
|
3053
3583
|
type: Function,
|
|
3054
3584
|
required: false
|
|
@@ -3082,11 +3612,23 @@ var selection_popover_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
3082
3612
|
emits: ["click-outside", "select-user"],
|
|
3083
3613
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
3084
3614
|
__expose();
|
|
3615
|
+
/**
|
|
3616
|
+
* 用户选择器下拉菜单组件
|
|
3617
|
+
*/
|
|
3085
3618
|
const { t } = use_i18n_default();
|
|
3086
3619
|
const slotContainerRef = ref(null);
|
|
3087
3620
|
const contentContainerRef = ref(null);
|
|
3621
|
+
/**
|
|
3622
|
+
* 组件属性
|
|
3623
|
+
*/
|
|
3088
3624
|
const props = __props;
|
|
3625
|
+
/**
|
|
3626
|
+
* 组件事件
|
|
3627
|
+
*/
|
|
3089
3628
|
const emit = __emit;
|
|
3629
|
+
/**
|
|
3630
|
+
* 按分组整理用户列表,如果有 userGroup, 则在最前面增加用户群组 userGroup
|
|
3631
|
+
*/
|
|
3090
3632
|
const groupedUsers = computed(() => {
|
|
3091
3633
|
const groups = {};
|
|
3092
3634
|
if (Array.isArray(props.userGroup) && props.userGroup.length > 0) groups[props.userGroupName] = props.userGroup.map((group) => ({
|
|
@@ -3101,25 +3643,41 @@ var selection_popover_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
3101
3643
|
});
|
|
3102
3644
|
return groups;
|
|
3103
3645
|
});
|
|
3646
|
+
const hasMainOptions = computed(() => Object.values(groupedUsers.value).some((group) => group.length > 0));
|
|
3647
|
+
const hasRecentUsers = computed(() => props.recentUsers.length > 0);
|
|
3648
|
+
const hasDropdownOptions = computed(() => hasMainOptions.value || hasRecentUsers.value);
|
|
3649
|
+
/**
|
|
3650
|
+
* 判断用户是否为当前高亮项
|
|
3651
|
+
*/
|
|
3104
3652
|
const isHighlighted = (user) => {
|
|
3105
3653
|
if (props.highlightedIndex < 0 || !props.flatOptions.length) return false;
|
|
3106
|
-
return props.flatOptions[props.highlightedIndex]
|
|
3654
|
+
return props.flatOptions[props.highlightedIndex] === user;
|
|
3107
3655
|
};
|
|
3656
|
+
/**
|
|
3657
|
+
* 选择用户
|
|
3658
|
+
*/
|
|
3108
3659
|
const selectUser = (user) => {
|
|
3109
3660
|
emit("select-user", user);
|
|
3110
3661
|
};
|
|
3662
|
+
/**
|
|
3663
|
+
* 点击外部
|
|
3664
|
+
*/
|
|
3111
3665
|
const handleClickOutside = ({ event }) => {
|
|
3112
3666
|
const target = event.target;
|
|
3113
3667
|
if (slotContainerRef.value?.contains(target)) return;
|
|
3114
3668
|
if (contentContainerRef.value?.contains(target)) return;
|
|
3115
3669
|
emit("click-outside", event);
|
|
3116
3670
|
};
|
|
3671
|
+
/**
|
|
3672
|
+
* 监听高亮索引变化,自动滚动到高亮项
|
|
3673
|
+
*/
|
|
3117
3674
|
watch(() => props.highlightedIndex, (newIndex) => {
|
|
3118
3675
|
if (newIndex < 0 || !contentContainerRef.value) return;
|
|
3119
3676
|
nextTick(() => {
|
|
3120
3677
|
const highlightedElement = contentContainerRef.value?.querySelector(".user-option.is-highlighted");
|
|
3121
3678
|
if (highlightedElement) highlightedElement.scrollIntoView({
|
|
3122
3679
|
block: "nearest",
|
|
3680
|
+
inline: "nearest",
|
|
3123
3681
|
behavior: "auto"
|
|
3124
3682
|
});
|
|
3125
3683
|
});
|
|
@@ -3131,6 +3689,9 @@ var selection_popover_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
3131
3689
|
props,
|
|
3132
3690
|
emit,
|
|
3133
3691
|
groupedUsers,
|
|
3692
|
+
hasMainOptions,
|
|
3693
|
+
hasRecentUsers,
|
|
3694
|
+
hasDropdownOptions,
|
|
3134
3695
|
isHighlighted,
|
|
3135
3696
|
selectUser,
|
|
3136
3697
|
handleClickOutside,
|
|
@@ -3151,15 +3712,28 @@ var selection_popover_vue_vue_type_script_setup_true_lang_default = /* @__PURE__
|
|
|
3151
3712
|
return __returned__;
|
|
3152
3713
|
}
|
|
3153
3714
|
});
|
|
3715
|
+
//#endregion
|
|
3716
|
+
//#region src/components/selection-popover.vue
|
|
3154
3717
|
var _hoisted_1$1 = { ref: "contentContainerRef" };
|
|
3155
3718
|
var _hoisted_2$1 = {
|
|
3156
3719
|
key: 0,
|
|
3157
3720
|
class: "no-data"
|
|
3158
3721
|
};
|
|
3159
|
-
var _hoisted_3$1 = {
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3722
|
+
var _hoisted_3$1 = {
|
|
3723
|
+
key: 0,
|
|
3724
|
+
class: "dropdown-panel dropdown-panel-main"
|
|
3725
|
+
};
|
|
3726
|
+
var _hoisted_4$1 = { class: "group-name" };
|
|
3727
|
+
var _hoisted_5 = { class: "group-count" };
|
|
3728
|
+
var _hoisted_6 = ["onClick"];
|
|
3729
|
+
var _hoisted_7 = {
|
|
3730
|
+
key: 1,
|
|
3731
|
+
class: "dropdown-panel dropdown-panel-recent"
|
|
3732
|
+
};
|
|
3733
|
+
var _hoisted_8 = { class: "group-name" };
|
|
3734
|
+
var _hoisted_9 = { class: "group-count" };
|
|
3735
|
+
var _hoisted_10 = ["onClick"];
|
|
3736
|
+
var _hoisted_11 = { ref: "slotContainerRef" };
|
|
3163
3737
|
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3164
3738
|
return openBlock(), createBlock($setup["Popover"], {
|
|
3165
3739
|
arrow: false,
|
|
@@ -3178,7 +3752,10 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3178
3752
|
mode: "spin",
|
|
3179
3753
|
size: "mini"
|
|
3180
3754
|
}, {
|
|
3181
|
-
default: withCtx(() => [
|
|
3755
|
+
default: withCtx(() => [!$setup.hasDropdownOptions ? (openBlock(), createElementBlock("div", _hoisted_2$1, [createElementVNode("span", null, toDisplayString($props.emptyText), 1)])) : (openBlock(), createElementBlock("div", {
|
|
3756
|
+
key: 1,
|
|
3757
|
+
class: normalizeClass(["dropdown-panels", { "is-two-column": $setup.hasMainOptions && $setup.hasRecentUsers }])
|
|
3758
|
+
}, [$setup.hasMainOptions ? (openBlock(), createElementBlock("div", _hoisted_3$1, [(openBlock(true), createElementBlock(Fragment, null, renderList($setup.groupedUsers, (group, groupName) => {
|
|
3182
3759
|
return openBlock(), createElementBlock("div", {
|
|
3183
3760
|
key: groupName,
|
|
3184
3761
|
class: "user-group"
|
|
@@ -3186,7 +3763,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3186
3763
|
key: 0,
|
|
3187
3764
|
class: "group-header",
|
|
3188
3765
|
onClick: _cache[0] || (_cache[0] = withModifiers(() => {}, ["prevent"]))
|
|
3189
|
-
}, [createElementVNode("span",
|
|
3766
|
+
}, [createElementVNode("span", _hoisted_4$1, toDisplayString(groupName), 1), createElementVNode("span", _hoisted_5, "(" + toDisplayString(group.length) + ")", 1)])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList(group, (user) => {
|
|
3190
3767
|
return openBlock(), createElementBlock("div", {
|
|
3191
3768
|
key: user.id,
|
|
3192
3769
|
class: normalizeClass(["user-option", { "is-highlighted": $setup.isHighlighted(user) }]),
|
|
@@ -3206,20 +3783,50 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3206
3783
|
"tenant-id",
|
|
3207
3784
|
"tenants",
|
|
3208
3785
|
"user"
|
|
3209
|
-
])], 42,
|
|
3786
|
+
])], 42, _hoisted_6);
|
|
3210
3787
|
}), 128))]);
|
|
3211
|
-
}), 128))]),
|
|
3788
|
+
}), 128))])) : createCommentVNode("v-if", true), $setup.hasRecentUsers ? (openBlock(), createElementBlock("div", _hoisted_7, [$props.recentUsersName ? (openBlock(), createElementBlock("div", {
|
|
3789
|
+
key: 0,
|
|
3790
|
+
class: "group-header",
|
|
3791
|
+
onClick: _cache[2] || (_cache[2] = withModifiers(() => {}, ["prevent"]))
|
|
3792
|
+
}, [createElementVNode("span", _hoisted_8, toDisplayString($props.recentUsersName), 1), createElementVNode("span", _hoisted_9, "(" + toDisplayString($props.recentUsers.length) + ")", 1)])) : createCommentVNode("v-if", true), (openBlock(true), createElementBlock(Fragment, null, renderList($props.recentUsers, (user) => {
|
|
3793
|
+
return openBlock(), createElementBlock("div", {
|
|
3794
|
+
key: user.id,
|
|
3795
|
+
class: normalizeClass(["user-option", { "is-highlighted": $setup.isHighlighted(user) }]),
|
|
3796
|
+
onClick: withModifiers(($event) => $setup.selectUser(user), ["prevent"]),
|
|
3797
|
+
onMousedown: _cache[3] || (_cache[3] = withModifiers(() => {}, ["prevent"]))
|
|
3798
|
+
}, [createVNode($setup["UserRender"], {
|
|
3799
|
+
"avatar-base-url": $props.avatarBaseUrl,
|
|
3800
|
+
"has-avatar": $props.hasAvatar,
|
|
3801
|
+
render: $props.renderListItem,
|
|
3802
|
+
"tenant-id": $props.tenantId,
|
|
3803
|
+
tenants: $props.tenants,
|
|
3804
|
+
user
|
|
3805
|
+
}, null, 8, [
|
|
3806
|
+
"avatar-base-url",
|
|
3807
|
+
"has-avatar",
|
|
3808
|
+
"render",
|
|
3809
|
+
"tenant-id",
|
|
3810
|
+
"tenants",
|
|
3811
|
+
"user"
|
|
3812
|
+
])], 42, _hoisted_10);
|
|
3813
|
+
}), 128))])) : createCommentVNode("v-if", true)], 2))]),
|
|
3212
3814
|
_: 1
|
|
3213
3815
|
}, 8, ["loading"])], 512)]),
|
|
3214
|
-
default: withCtx(() => [createElementVNode("div",
|
|
3816
|
+
default: withCtx(() => [createElementVNode("div", _hoisted_11, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 512)]),
|
|
3215
3817
|
_: 3
|
|
3216
3818
|
}, 8, ["is-show", "width"]);
|
|
3217
3819
|
}
|
|
3218
|
-
var selection_popover_default = /* @__PURE__ */
|
|
3820
|
+
var selection_popover_default = /* @__PURE__ */ _plugin_vue_export_helper_default(selection_popover_vue_vue_type_script_setup_true_lang_default, [
|
|
3219
3821
|
["render", _sfc_render$2],
|
|
3220
3822
|
["__scopeId", "data-v-9173accf"],
|
|
3221
3823
|
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/selection-popover.vue"]
|
|
3222
3824
|
]);
|
|
3825
|
+
//#endregion
|
|
3826
|
+
//#region src/components/user-tag.vue?vue&type=script&setup=true&lang.ts
|
|
3827
|
+
/**
|
|
3828
|
+
* 用户标签组件
|
|
3829
|
+
*/
|
|
3223
3830
|
var user_tag_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3224
3831
|
name: "UserTag",
|
|
3225
3832
|
__name: "user-tag",
|
|
@@ -3264,10 +3871,22 @@ var user_tag_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
|
|
|
3264
3871
|
emits: ["click", "close"],
|
|
3265
3872
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
3266
3873
|
__expose();
|
|
3874
|
+
/**
|
|
3875
|
+
* 组件属性
|
|
3876
|
+
*/
|
|
3877
|
+
/**
|
|
3878
|
+
* 组件事件
|
|
3879
|
+
*/
|
|
3267
3880
|
const emit = __emit;
|
|
3881
|
+
/**
|
|
3882
|
+
* 处理点击事件
|
|
3883
|
+
*/
|
|
3268
3884
|
const handleClick = () => {
|
|
3269
3885
|
emit("click");
|
|
3270
3886
|
};
|
|
3887
|
+
/**
|
|
3888
|
+
* 处理关闭事件
|
|
3889
|
+
*/
|
|
3271
3890
|
const handleClose = () => {
|
|
3272
3891
|
emit("close");
|
|
3273
3892
|
};
|
|
@@ -3289,6 +3908,8 @@ var user_tag_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defin
|
|
|
3289
3908
|
return __returned__;
|
|
3290
3909
|
}
|
|
3291
3910
|
});
|
|
3911
|
+
//#endregion
|
|
3912
|
+
//#region src/components/user-tag.vue
|
|
3292
3913
|
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3293
3914
|
return openBlock(), createBlock($setup["Tag"], {
|
|
3294
3915
|
class: normalizeClass(["user-tag", {
|
|
@@ -3319,11 +3940,13 @@ function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3319
3940
|
_: 1
|
|
3320
3941
|
}, 8, ["class"]);
|
|
3321
3942
|
}
|
|
3322
|
-
var user_tag_default = /* @__PURE__ */
|
|
3943
|
+
var user_tag_default = /* @__PURE__ */ _plugin_vue_export_helper_default(user_tag_vue_vue_type_script_setup_true_lang_default, [
|
|
3323
3944
|
["render", _sfc_render$1],
|
|
3324
3945
|
["__scopeId", "data-v-d1173d20"],
|
|
3325
3946
|
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/user-tag.vue"]
|
|
3326
3947
|
]);
|
|
3948
|
+
//#endregion
|
|
3949
|
+
//#region src/components/user-selector.vue?vue&type=script&setup=true&lang.ts
|
|
3327
3950
|
var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3328
3951
|
name: "BkUserSelector",
|
|
3329
3952
|
__name: "user-selector",
|
|
@@ -3373,6 +3996,21 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3373
3996
|
required: false,
|
|
3374
3997
|
default: false
|
|
3375
3998
|
},
|
|
3999
|
+
allowCrossOriginCredentials: {
|
|
4000
|
+
type: Boolean,
|
|
4001
|
+
required: false,
|
|
4002
|
+
default: true
|
|
4003
|
+
},
|
|
4004
|
+
allowedApiOrigins: {
|
|
4005
|
+
type: Array,
|
|
4006
|
+
required: false,
|
|
4007
|
+
default: () => []
|
|
4008
|
+
},
|
|
4009
|
+
allowPrivateApiHost: {
|
|
4010
|
+
type: Boolean,
|
|
4011
|
+
required: false,
|
|
4012
|
+
default: true
|
|
4013
|
+
},
|
|
3376
4014
|
apiBaseUrl: {
|
|
3377
4015
|
type: String,
|
|
3378
4016
|
required: true,
|
|
@@ -3428,6 +4066,11 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3428
4066
|
required: false,
|
|
3429
4067
|
default: ""
|
|
3430
4068
|
},
|
|
4069
|
+
recentUserIds: {
|
|
4070
|
+
type: Array,
|
|
4071
|
+
required: false,
|
|
4072
|
+
default: () => []
|
|
4073
|
+
},
|
|
3431
4074
|
renderListItem: {
|
|
3432
4075
|
type: Function,
|
|
3433
4076
|
required: false
|
|
@@ -3457,16 +4100,47 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3457
4100
|
"change",
|
|
3458
4101
|
"dragEnd",
|
|
3459
4102
|
"dragStart",
|
|
4103
|
+
"error",
|
|
3460
4104
|
"focus",
|
|
4105
|
+
"unauthorized",
|
|
3461
4106
|
"update:modelValue"
|
|
3462
4107
|
],
|
|
3463
4108
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
4109
|
+
/**
|
|
4110
|
+
* 蓝鲸用户选择器组件
|
|
4111
|
+
* @module components/UserSelector
|
|
4112
|
+
*/
|
|
3464
4113
|
const { t } = use_i18n_default();
|
|
3465
4114
|
provideGlobalConfig({ prefix: "bk" });
|
|
4115
|
+
/**
|
|
4116
|
+
* 组件属性
|
|
4117
|
+
*/
|
|
3466
4118
|
const props = __props;
|
|
4119
|
+
/**
|
|
4120
|
+
* 组件事件
|
|
4121
|
+
*/
|
|
3467
4122
|
const emit = __emit;
|
|
4123
|
+
const handleApiError = (error) => {
|
|
4124
|
+
emit("error", error);
|
|
4125
|
+
};
|
|
4126
|
+
const handleApiUnauthorized = (error) => {
|
|
4127
|
+
emit("unauthorized", error);
|
|
4128
|
+
};
|
|
4129
|
+
provideApiConfig(props.apiBaseUrl, props.tenantId, props.allowedApiOrigins, props.allowPrivateApiHost, props.allowCrossOriginCredentials, {
|
|
4130
|
+
onError: handleApiError,
|
|
4131
|
+
onUnauthorized: handleApiUnauthorized
|
|
4132
|
+
});
|
|
4133
|
+
/**
|
|
4134
|
+
* 获取租户数据
|
|
4135
|
+
*/
|
|
3468
4136
|
const { tenants } = useTenantData(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
|
|
4137
|
+
/**
|
|
4138
|
+
* 用户搜索
|
|
4139
|
+
*/
|
|
3469
4140
|
const { searchResults, loading: searchLoading, searchQuery, clearSearch, handleSearchInput } = useUserSearch(props.apiBaseUrl, props.tenantId, props.enableMultiTenantMode);
|
|
4141
|
+
/**
|
|
4142
|
+
* 当前用户处理
|
|
4143
|
+
*/
|
|
3470
4144
|
const { fetchCurrentUser } = useCurrentUser({
|
|
3471
4145
|
apiBaseUrl: props.apiBaseUrl,
|
|
3472
4146
|
tenantId: props.tenantId,
|
|
@@ -3474,18 +4148,30 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3474
4148
|
exactSearchKey: props.exactSearchKey,
|
|
3475
4149
|
enableMultiTenantMode: props.enableMultiTenantMode
|
|
3476
4150
|
});
|
|
4151
|
+
/**
|
|
4152
|
+
* DOM 引用
|
|
4153
|
+
*/
|
|
3477
4154
|
const containerRef = ref(null);
|
|
3478
4155
|
const sortableContainerRef = ref(null);
|
|
3479
4156
|
const collapsedContainerRef = ref(null);
|
|
3480
4157
|
const frontInputRef = ref(null);
|
|
3481
4158
|
const inlineInputRef = ref(null);
|
|
3482
4159
|
const lastInputRef = ref(null);
|
|
4160
|
+
/**
|
|
4161
|
+
* 组件状态
|
|
4162
|
+
*/
|
|
3483
4163
|
const isFocused = ref(false);
|
|
3484
4164
|
const activeTagIndex = ref(-1);
|
|
3485
4165
|
const sortableInstance = ref(null);
|
|
3486
4166
|
const visibleUsers = ref([]);
|
|
3487
4167
|
const hiddenCount = ref(0);
|
|
3488
4168
|
const highlightedIndex = ref(-1);
|
|
4169
|
+
const recentUsers = ref([]);
|
|
4170
|
+
let recentUsersRequestId = 0;
|
|
4171
|
+
let recentUserIdsSnapshot = [];
|
|
4172
|
+
/**
|
|
4173
|
+
* 已选用户列表 (内部状态)
|
|
4174
|
+
*/
|
|
3489
4175
|
const selectedUsers = ref([]);
|
|
3490
4176
|
const isTextareaMode = computed(() => props.type === "textarea");
|
|
3491
4177
|
const textareaHeight = ref(props.rows * 32);
|
|
@@ -3497,25 +4183,93 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3497
4183
|
overflowY: "auto"
|
|
3498
4184
|
};
|
|
3499
4185
|
});
|
|
4186
|
+
/**
|
|
4187
|
+
* 未聚焦状态下展示的用户列表:textarea 模式展示全部,input 模式展示折叠后的
|
|
4188
|
+
*/
|
|
3500
4189
|
const collapsedDisplayUsers = computed(() => {
|
|
3501
4190
|
return isTextareaMode.value ? selectedUsers.value : visibleUsers.value;
|
|
3502
4191
|
});
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
4192
|
+
/**
|
|
4193
|
+
* 模型值 ID 列表
|
|
4194
|
+
*/
|
|
3506
4195
|
const modelValueIds = computed(() => {
|
|
3507
4196
|
if (props.multiple) return Array.isArray(props.modelValue) ? props.modelValue : [];
|
|
3508
4197
|
return props.modelValue ? [props.modelValue] : [];
|
|
3509
4198
|
});
|
|
4199
|
+
/**
|
|
4200
|
+
* 用 computed 处理国际化
|
|
4201
|
+
*/
|
|
3510
4202
|
const computedPlaceholder = computed(() => props.placeholder || t("请输入人员名称搜索"));
|
|
3511
4203
|
const computedUserGroupName = computed(() => props.userGroupName || t("用户群组"));
|
|
3512
4204
|
const computedEmptyText = computed(() => props.emptyText || t("无匹配人员"));
|
|
4205
|
+
const computedRecentUsersName = computed(() => t("最近选择"));
|
|
4206
|
+
/**
|
|
4207
|
+
* 已选用户ID列表
|
|
4208
|
+
*/
|
|
3513
4209
|
const selectedUserIds = computed(() => selectedUsers.value.map((user) => user.id));
|
|
4210
|
+
const isUserMatchedByQuery = (user, query) => {
|
|
4211
|
+
if (!query) return true;
|
|
4212
|
+
return [
|
|
4213
|
+
user.id,
|
|
4214
|
+
user.name,
|
|
4215
|
+
user.bk_username,
|
|
4216
|
+
user.username,
|
|
4217
|
+
user.login_name,
|
|
4218
|
+
user.display_name,
|
|
4219
|
+
user.full_name
|
|
4220
|
+
].some((field) => String(field || "").includes(query));
|
|
4221
|
+
};
|
|
4222
|
+
const getLookupFields = (exactSearchKey) => {
|
|
4223
|
+
return exactSearchKey.split(",").map((field) => field.trim()).filter(Boolean);
|
|
4224
|
+
};
|
|
4225
|
+
const findUserByLookupId = (users, lookupId, lookupFields) => {
|
|
4226
|
+
return users.find((user) => {
|
|
4227
|
+
if (user.id === lookupId) return true;
|
|
4228
|
+
const indexedUser = user;
|
|
4229
|
+
return lookupFields.some((field) => String(indexedUser[field] || "") === lookupId);
|
|
4230
|
+
});
|
|
4231
|
+
};
|
|
4232
|
+
const sortUsersByLookupIds = (users, lookupIds, lookupFields) => {
|
|
4233
|
+
return lookupIds.map((lookupId) => findUserByLookupId(users, lookupId, lookupFields)).filter(Boolean);
|
|
4234
|
+
};
|
|
4235
|
+
const lookupFormattedUsersByIds = async (lookupIds) => {
|
|
4236
|
+
const primaryLookupFields = getLookupFields(props.exactSearchKey);
|
|
4237
|
+
const formattedUsers = formatUsers(await lookupUsers({
|
|
4238
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
4239
|
+
tenantId: props.tenantId,
|
|
4240
|
+
exactSearchKey: props.exactSearchKey,
|
|
4241
|
+
usersList: lookupIds,
|
|
4242
|
+
enableMultiTenantMode: props.enableMultiTenantMode
|
|
4243
|
+
}), props.enableMultiTenantMode);
|
|
4244
|
+
const unresolvedIds = lookupIds.filter((lookupId) => !findUserByLookupId(formattedUsers, lookupId, primaryLookupFields));
|
|
4245
|
+
if (unresolvedIds.length === 0 || props.exactSearchKey === "bk_username") return sortUsersByLookupIds(formattedUsers, lookupIds, primaryLookupFields);
|
|
4246
|
+
const fallbackUsers = formatUsers(await lookupUsers({
|
|
4247
|
+
apiBaseUrl: props.apiBaseUrl,
|
|
4248
|
+
tenantId: props.tenantId,
|
|
4249
|
+
exactSearchKey: DEFAULT_EXACT_SEARCH_KEY,
|
|
4250
|
+
usersList: unresolvedIds,
|
|
4251
|
+
enableMultiTenantMode: props.enableMultiTenantMode
|
|
4252
|
+
}), props.enableMultiTenantMode);
|
|
4253
|
+
const mergedUsers = [...formattedUsers];
|
|
4254
|
+
fallbackUsers.forEach((user) => {
|
|
4255
|
+
if (!mergedUsers.some((item) => item.id === user.id)) mergedUsers.push(user);
|
|
4256
|
+
});
|
|
4257
|
+
return sortUsersByLookupIds(mergedUsers, lookupIds, [...new Set([...primaryLookupFields, DEFAULT_EXACT_SEARCH_KEY])]);
|
|
4258
|
+
};
|
|
4259
|
+
/**
|
|
4260
|
+
* 是否已达到最大选择数量
|
|
4261
|
+
*/
|
|
3514
4262
|
const isMaxCountReached = computed(() => {
|
|
3515
4263
|
if (!props.maxCount || props.maxCount <= 0) return false;
|
|
3516
4264
|
return selectedUsers.value.length >= props.maxCount;
|
|
3517
4265
|
});
|
|
4266
|
+
/**
|
|
4267
|
+
* "我"标签是否禁用(已选中当前用户时禁用,或已达到最大数量)
|
|
4268
|
+
*/
|
|
3518
4269
|
const isMeTagDisabled = computed(() => isMaxCountReached.value || !!props.currentUserId && selectedUsers.value.some((user) => user[props.exactSearchKey] === props.currentUserId));
|
|
4270
|
+
/**
|
|
4271
|
+
* UserTag 公共属性
|
|
4272
|
+
*/
|
|
3519
4273
|
const userTagCommonProps = computed(() => ({
|
|
3520
4274
|
avatarBaseUrl: props.avatarBaseUrl,
|
|
3521
4275
|
currentTenantId: props.tenantId,
|
|
@@ -3523,12 +4277,18 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3523
4277
|
renderTag: props.renderTag,
|
|
3524
4278
|
tenants: tenants.value
|
|
3525
4279
|
}));
|
|
4280
|
+
/**
|
|
4281
|
+
* 使用用户选择公共逻辑 hook
|
|
4282
|
+
*/
|
|
3526
4283
|
const { filteredUserGroup, filterOptions, createCustomUser } = useUserSelection({
|
|
3527
4284
|
selectedUserIds,
|
|
3528
4285
|
excludeUserIds: toRef(props, "excludeUserIds"),
|
|
3529
4286
|
userGroup: toRef(props, "userGroup"),
|
|
3530
4287
|
searchQuery
|
|
3531
4288
|
});
|
|
4289
|
+
/**
|
|
4290
|
+
* 使用输入处理公共逻辑 hook
|
|
4291
|
+
*/
|
|
3532
4292
|
const { handlePaste } = useInputHandler({
|
|
3533
4293
|
apiBaseUrl: props.apiBaseUrl,
|
|
3534
4294
|
tenantId: props.tenantId,
|
|
@@ -3541,8 +4301,11 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3541
4301
|
onAddUser: addUser,
|
|
3542
4302
|
onBatchAddUsers: props.multiple ? updateSelectedUsers : void 0
|
|
3543
4303
|
});
|
|
4304
|
+
/**
|
|
4305
|
+
* 显示的选项(过滤后的搜索结果)
|
|
4306
|
+
*/
|
|
3544
4307
|
const displayOptions = computed(() => filterOptions(searchResults.value));
|
|
3545
|
-
const
|
|
4308
|
+
const mainNavigableUsers = computed(() => {
|
|
3546
4309
|
const userGroupOptions = filteredUserGroup.value.map((group) => ({
|
|
3547
4310
|
...group,
|
|
3548
4311
|
tenantId: "",
|
|
@@ -3556,6 +4319,27 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3556
4319
|
...virtualUsers
|
|
3557
4320
|
];
|
|
3558
4321
|
});
|
|
4322
|
+
const filteredRecentUsers = computed(() => {
|
|
4323
|
+
const query = searchQuery.value.trim();
|
|
4324
|
+
return recentUsers.value.filter((user) => !selectedUserIds.value.includes(user.id)).filter((user) => !props.excludeUserIds.includes(user.id)).filter((user) => isUserMatchedByQuery(user, query));
|
|
4325
|
+
});
|
|
4326
|
+
/**
|
|
4327
|
+
* 下拉框显示状态
|
|
4328
|
+
*/
|
|
4329
|
+
const showDropdown = computed(() => {
|
|
4330
|
+
return isFocused.value && (filteredUserGroup.value.length > 0 || filteredRecentUsers.value.length > 0 || searchQuery.value.trim() !== "");
|
|
4331
|
+
});
|
|
4332
|
+
/**
|
|
4333
|
+
* 扁平化的选项列表(合并 userGroup 和 displayOptions,用于键盘导航)
|
|
4334
|
+
* 顺序与 selection-popover.vue 中 groupedUsers 的渲染顺序保持一致:
|
|
4335
|
+
* 用户群组 → 普通用户 → 虚拟账号 → 最近选择
|
|
4336
|
+
*/
|
|
4337
|
+
const flatOptions = computed(() => {
|
|
4338
|
+
return [...mainNavigableUsers.value, ...filteredRecentUsers.value];
|
|
4339
|
+
});
|
|
4340
|
+
/**
|
|
4341
|
+
* 输入框宽度(根据输入内容动态计算)
|
|
4342
|
+
*/
|
|
3559
4343
|
const inputWidth = computed(() => {
|
|
3560
4344
|
const query = searchQuery.value;
|
|
3561
4345
|
if (!query) return "20px";
|
|
@@ -3564,6 +4348,9 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3564
4348
|
}, 0);
|
|
3565
4349
|
return `${Math.max(20, charWidth + 4)}px`;
|
|
3566
4350
|
});
|
|
4351
|
+
/**
|
|
4352
|
+
* 初始化已选用户数据
|
|
4353
|
+
*/
|
|
3567
4354
|
const initSelectedUsers = async () => {
|
|
3568
4355
|
const ids = modelValueIds.value;
|
|
3569
4356
|
if (ids.length === 0) {
|
|
@@ -3577,26 +4364,43 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3577
4364
|
type: USER_TYPE.USER_GROUP
|
|
3578
4365
|
}));
|
|
3579
4366
|
try {
|
|
3580
|
-
const
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
type: USER_TYPE.CUSTOM,
|
|
3592
|
-
tenantId: ""
|
|
3593
|
-
})));
|
|
3594
|
-
selectedUsers.value = ids.map((id) => selectedList.find((user) => user.id === id)).filter(Boolean);
|
|
4367
|
+
const selectedList = [...userGroupSelected, ...await lookupFormattedUsersByIds(ids)];
|
|
4368
|
+
if (props.allowCreate) {
|
|
4369
|
+
const lookupFields = [...new Set([...getLookupFields(props.exactSearchKey), DEFAULT_EXACT_SEARCH_KEY])];
|
|
4370
|
+
selectedList.push(...ids.filter((id) => !findUserByLookupId(selectedList, id, lookupFields)).map((id) => ({
|
|
4371
|
+
id,
|
|
4372
|
+
name: id,
|
|
4373
|
+
type: USER_TYPE.CUSTOM,
|
|
4374
|
+
tenantId: ""
|
|
4375
|
+
})));
|
|
4376
|
+
}
|
|
4377
|
+
selectedUsers.value = sortUsersByLookupIds(selectedList, ids, [...new Set([...getLookupFields(props.exactSearchKey), DEFAULT_EXACT_SEARCH_KEY])]);
|
|
3595
4378
|
} catch (error) {
|
|
3596
4379
|
console.error("获取选中用户信息失败:", error);
|
|
3597
4380
|
selectedUsers.value = [];
|
|
3598
4381
|
}
|
|
3599
4382
|
};
|
|
4383
|
+
const initRecentUsers = async () => {
|
|
4384
|
+
const ids = props.recentUserIds.filter(Boolean);
|
|
4385
|
+
const requestId = ++recentUsersRequestId;
|
|
4386
|
+
recentUserIdsSnapshot = [...ids];
|
|
4387
|
+
if (ids.length === 0) {
|
|
4388
|
+
recentUsers.value = [];
|
|
4389
|
+
return;
|
|
4390
|
+
}
|
|
4391
|
+
try {
|
|
4392
|
+
const formattedUsers = (await lookupFormattedUsersByIds(ids)).filter((user) => user.data_source_type !== USER_TYPE.VIRTUAL && user.type !== USER_TYPE.USER_GROUP);
|
|
4393
|
+
if (requestId !== recentUsersRequestId) return;
|
|
4394
|
+
recentUsers.value = formattedUsers;
|
|
4395
|
+
} catch (error) {
|
|
4396
|
+
if (requestId !== recentUsersRequestId) return;
|
|
4397
|
+
console.error("获取最近选择用户信息失败:", error);
|
|
4398
|
+
recentUsers.value = [];
|
|
4399
|
+
}
|
|
4400
|
+
};
|
|
4401
|
+
/**
|
|
4402
|
+
* 更新选中用户并触发事件
|
|
4403
|
+
*/
|
|
3600
4404
|
function updateSelectedUsers(users) {
|
|
3601
4405
|
selectedUsers.value = users;
|
|
3602
4406
|
if (props.multiple) {
|
|
@@ -3608,6 +4412,9 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3608
4412
|
emit("change", user);
|
|
3609
4413
|
}
|
|
3610
4414
|
}
|
|
4415
|
+
/**
|
|
4416
|
+
* 初始化排序功能
|
|
4417
|
+
*/
|
|
3611
4418
|
const initSortable = () => {
|
|
3612
4419
|
if (!props.draggable || !props.multiple || !sortableContainerRef.value) return;
|
|
3613
4420
|
if (sortableInstance.value) sortableInstance.value.destroy();
|
|
@@ -3628,6 +4435,9 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3628
4435
|
}
|
|
3629
4436
|
});
|
|
3630
4437
|
};
|
|
4438
|
+
/**
|
|
4439
|
+
* 计算可见用户
|
|
4440
|
+
*/
|
|
3631
4441
|
const calculateVisibleUsers = () => {
|
|
3632
4442
|
if (!selectedUsers.value.length) {
|
|
3633
4443
|
visibleUsers.value = [];
|
|
@@ -3651,14 +4461,23 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3651
4461
|
visibleUsers.value = selectedUsers.value.slice(0, visibleCount);
|
|
3652
4462
|
hiddenCount.value = Math.max(0, selectedUsers.value.length - visibleCount);
|
|
3653
4463
|
};
|
|
4464
|
+
/**
|
|
4465
|
+
* 处理聚焦
|
|
4466
|
+
*/
|
|
3654
4467
|
const handleFocus = () => {
|
|
3655
4468
|
isFocused.value = true;
|
|
3656
4469
|
activeTagIndex.value = selectedUsers.value.length - 1;
|
|
3657
4470
|
nextTick(() => focusCurrentInput());
|
|
3658
4471
|
};
|
|
4472
|
+
/**
|
|
4473
|
+
* 延迟计算可见用户
|
|
4474
|
+
*/
|
|
3659
4475
|
const scheduleVisibleUsersCalculation = () => {
|
|
3660
4476
|
if (!isFocused.value) nextTick(calculateVisibleUsers);
|
|
3661
4477
|
};
|
|
4478
|
+
/**
|
|
4479
|
+
* 主动失焦(供外部调用或内部复用)
|
|
4480
|
+
*/
|
|
3662
4481
|
const blur = () => {
|
|
3663
4482
|
if (isFocused.value) emit("blur");
|
|
3664
4483
|
isFocused.value = false;
|
|
@@ -3667,32 +4486,56 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3667
4486
|
highlightedIndex.value = -1;
|
|
3668
4487
|
scheduleVisibleUsersCalculation();
|
|
3669
4488
|
};
|
|
4489
|
+
/**
|
|
4490
|
+
* 处理失焦
|
|
4491
|
+
*/
|
|
3670
4492
|
const handleClickOutside = (event) => {
|
|
3671
4493
|
const target = event.target;
|
|
3672
4494
|
const container = containerRef.value;
|
|
3673
4495
|
if (container?.contains(target) || container === target) return;
|
|
3674
4496
|
blur();
|
|
3675
4497
|
};
|
|
4498
|
+
/**
|
|
4499
|
+
* 处理容器点击
|
|
4500
|
+
*/
|
|
3676
4501
|
const handleContainerClick = () => {
|
|
3677
4502
|
activeTagIndex.value = selectedUsers.value.length - 1;
|
|
3678
4503
|
nextTick(() => focusCurrentInput());
|
|
3679
4504
|
};
|
|
4505
|
+
/**
|
|
4506
|
+
* 聚焦当前光标位置的输入框
|
|
4507
|
+
* activeTagIndex 语义:
|
|
4508
|
+
* -1 = 最前面(第一个标签之前)
|
|
4509
|
+
* 0 ~ length-1 = 对应标签后面
|
|
4510
|
+
*/
|
|
3680
4511
|
const focusCurrentInput = () => {
|
|
3681
4512
|
if (activeTagIndex.value === -1 && selectedUsers.value.length > 0) frontInputRef.value?.focus();
|
|
3682
4513
|
else if (activeTagIndex.value >= selectedUsers.value.length - 1) lastInputRef.value?.focus();
|
|
3683
4514
|
else inlineInputRef.value?.[0]?.focus();
|
|
3684
4515
|
};
|
|
4516
|
+
/**
|
|
4517
|
+
* 处理标签点击
|
|
4518
|
+
*/
|
|
3685
4519
|
const handleTagClick = (index) => {
|
|
3686
4520
|
activeTagIndex.value = index;
|
|
3687
4521
|
nextTick(() => focusCurrentInput());
|
|
3688
4522
|
};
|
|
4523
|
+
/**
|
|
4524
|
+
* 处理输入框聚焦
|
|
4525
|
+
*/
|
|
3689
4526
|
const handleInputFocus = () => {
|
|
3690
4527
|
emit("focus");
|
|
3691
4528
|
isFocused.value = true;
|
|
3692
4529
|
};
|
|
4530
|
+
/**
|
|
4531
|
+
* 处理输入变化
|
|
4532
|
+
*/
|
|
3693
4533
|
const handleInput = () => {
|
|
3694
4534
|
handleSearchInput(searchQuery.value);
|
|
3695
4535
|
};
|
|
4536
|
+
/**
|
|
4537
|
+
* 添加当前用户("我")
|
|
4538
|
+
*/
|
|
3696
4539
|
const addCurrentUser = async () => {
|
|
3697
4540
|
if (!props.currentUserId || selectedUsers.value.some((user) => user[props.exactSearchKey] === props.currentUserId)) return;
|
|
3698
4541
|
if (props.multiple && isMaxCountReached.value) return;
|
|
@@ -3707,11 +4550,17 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3707
4550
|
nextTick(() => focusCurrentInput());
|
|
3708
4551
|
}
|
|
3709
4552
|
};
|
|
4553
|
+
/**
|
|
4554
|
+
* 处理粘贴事件
|
|
4555
|
+
*/
|
|
3710
4556
|
const onPaste = async (event) => {
|
|
3711
4557
|
await handlePaste(event);
|
|
3712
4558
|
activeTagIndex.value = selectedUsers.value.length - 1;
|
|
3713
4559
|
nextTick(() => focusCurrentInput());
|
|
3714
4560
|
};
|
|
4561
|
+
/**
|
|
4562
|
+
* 处理键盘事件
|
|
4563
|
+
*/
|
|
3715
4564
|
const handleKeyDown = (event) => {
|
|
3716
4565
|
if (event.key === "Backspace" && !searchQuery.value && selectedUsers.value.length > 0) {
|
|
3717
4566
|
if (activeTagIndex.value >= 0) {
|
|
@@ -3755,6 +4604,12 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3755
4604
|
return;
|
|
3756
4605
|
}
|
|
3757
4606
|
};
|
|
4607
|
+
/**
|
|
4608
|
+
* 添加用户
|
|
4609
|
+
* activeTagIndex 语义:
|
|
4610
|
+
* -1 = 在最前面插入
|
|
4611
|
+
* 0 ~ length-1 = 在对应标签后面插入
|
|
4612
|
+
*/
|
|
3758
4613
|
function addUser(user) {
|
|
3759
4614
|
if (!user?.id) return;
|
|
3760
4615
|
if (props.multiple && isMaxCountReached.value) {
|
|
@@ -3787,6 +4642,9 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3787
4642
|
isFocused.value = true;
|
|
3788
4643
|
nextTick(() => focusCurrentInput());
|
|
3789
4644
|
}
|
|
4645
|
+
/**
|
|
4646
|
+
* 移除用户(通过 x 按钮删除)
|
|
4647
|
+
*/
|
|
3790
4648
|
const removeUser = (user) => {
|
|
3791
4649
|
if (!user?.id) return;
|
|
3792
4650
|
const removedIndex = selectedUsers.value.findIndex((item) => item.id === user.id);
|
|
@@ -3797,9 +4655,15 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3797
4655
|
else if (activeTagIndex.value >= updatedUsers.length) activeTagIndex.value = updatedUsers.length - 1;
|
|
3798
4656
|
scheduleVisibleUsersCalculation();
|
|
3799
4657
|
};
|
|
4658
|
+
/**
|
|
4659
|
+
* 监听选中用户变化
|
|
4660
|
+
*/
|
|
3800
4661
|
watch(selectedUsers, () => {
|
|
3801
4662
|
scheduleVisibleUsersCalculation();
|
|
3802
4663
|
}, { deep: true });
|
|
4664
|
+
/**
|
|
4665
|
+
* 监听聚焦状态变化
|
|
4666
|
+
*/
|
|
3803
4667
|
watch(isFocused, (newVal) => {
|
|
3804
4668
|
if (isTextareaMode.value) {
|
|
3805
4669
|
const prevContainer = newVal ? collapsedContainerRef.value : containerRef.value?.querySelector(".tags-container.focused");
|
|
@@ -3807,25 +4671,48 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3807
4671
|
}
|
|
3808
4672
|
if (newVal) nextTick(() => initSortable());
|
|
3809
4673
|
});
|
|
4674
|
+
/**
|
|
4675
|
+
* 监听 flatOptions 变化,重置高亮索引到第一项
|
|
4676
|
+
*/
|
|
3810
4677
|
watch(flatOptions, (newOptions) => {
|
|
3811
4678
|
if (newOptions.length > 0 && showDropdown.value) highlightedIndex.value = 0;
|
|
3812
4679
|
else highlightedIndex.value = -1;
|
|
3813
4680
|
});
|
|
4681
|
+
/**
|
|
4682
|
+
* 监听用户群组变化
|
|
4683
|
+
*/
|
|
3814
4684
|
watch(() => props.userGroup, () => {
|
|
3815
4685
|
initSelectedUsers();
|
|
3816
4686
|
});
|
|
4687
|
+
watch(() => props.recentUserIds, () => {
|
|
4688
|
+
const newIds = props.recentUserIds.filter(Boolean);
|
|
4689
|
+
if (recentUserIdsSnapshot.length === newIds.length && recentUserIdsSnapshot.every((id, index) => id === newIds[index])) return;
|
|
4690
|
+
initRecentUsers();
|
|
4691
|
+
}, { deep: true });
|
|
4692
|
+
/**
|
|
4693
|
+
* 监听 modelValue 变化
|
|
4694
|
+
*/
|
|
3817
4695
|
watch(() => props.modelValue, () => {
|
|
3818
4696
|
const currentIds = selectedUsers.value.map((u) => u.id);
|
|
3819
4697
|
const newIds = modelValueIds.value;
|
|
3820
4698
|
if (currentIds.length !== newIds.length || !currentIds.every((id, index) => id === newIds[index])) initSelectedUsers();
|
|
3821
4699
|
}, { deep: true });
|
|
4700
|
+
/**
|
|
4701
|
+
* 使用 ResizeObserver 监听容器大小变化
|
|
4702
|
+
*/
|
|
3822
4703
|
useResizeObserver(containerRef, () => {
|
|
3823
4704
|
scheduleVisibleUsersCalculation();
|
|
3824
4705
|
});
|
|
3825
4706
|
let initPromise;
|
|
4707
|
+
/**
|
|
4708
|
+
* 组件挂载前初始化
|
|
4709
|
+
*/
|
|
3826
4710
|
onBeforeMount(() => {
|
|
3827
|
-
initPromise = initSelectedUsers();
|
|
4711
|
+
initPromise = Promise.all([initSelectedUsers(), initRecentUsers()]).then(() => void 0);
|
|
3828
4712
|
});
|
|
4713
|
+
/**
|
|
4714
|
+
* 组件挂载后初始化
|
|
4715
|
+
*/
|
|
3829
4716
|
onMounted(async () => {
|
|
3830
4717
|
initSortable();
|
|
3831
4718
|
nextTick(calculateVisibleUsers);
|
|
@@ -3835,6 +4722,9 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3835
4722
|
handleFocus();
|
|
3836
4723
|
}
|
|
3837
4724
|
});
|
|
4725
|
+
/**
|
|
4726
|
+
* 组件卸载前清理
|
|
4727
|
+
*/
|
|
3838
4728
|
onUnmounted(() => {
|
|
3839
4729
|
sortableInstance.value?.destroy();
|
|
3840
4730
|
});
|
|
@@ -3846,6 +4736,8 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3846
4736
|
t,
|
|
3847
4737
|
props,
|
|
3848
4738
|
emit,
|
|
4739
|
+
handleApiError,
|
|
4740
|
+
handleApiUnauthorized,
|
|
3849
4741
|
tenants,
|
|
3850
4742
|
searchResults,
|
|
3851
4743
|
searchLoading,
|
|
@@ -3865,17 +4757,35 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3865
4757
|
visibleUsers,
|
|
3866
4758
|
hiddenCount,
|
|
3867
4759
|
highlightedIndex,
|
|
4760
|
+
recentUsers,
|
|
4761
|
+
get recentUsersRequestId() {
|
|
4762
|
+
return recentUsersRequestId;
|
|
4763
|
+
},
|
|
4764
|
+
set recentUsersRequestId(v) {
|
|
4765
|
+
recentUsersRequestId = v;
|
|
4766
|
+
},
|
|
4767
|
+
get recentUserIdsSnapshot() {
|
|
4768
|
+
return recentUserIdsSnapshot;
|
|
4769
|
+
},
|
|
4770
|
+
set recentUserIdsSnapshot(v) {
|
|
4771
|
+
recentUserIdsSnapshot = v;
|
|
4772
|
+
},
|
|
3868
4773
|
selectedUsers,
|
|
3869
4774
|
isTextareaMode,
|
|
3870
4775
|
textareaHeight,
|
|
3871
4776
|
textareaStyle,
|
|
3872
4777
|
collapsedDisplayUsers,
|
|
3873
|
-
showDropdown,
|
|
3874
4778
|
modelValueIds,
|
|
3875
4779
|
computedPlaceholder,
|
|
3876
4780
|
computedUserGroupName,
|
|
3877
4781
|
computedEmptyText,
|
|
4782
|
+
computedRecentUsersName,
|
|
3878
4783
|
selectedUserIds,
|
|
4784
|
+
isUserMatchedByQuery,
|
|
4785
|
+
getLookupFields,
|
|
4786
|
+
findUserByLookupId,
|
|
4787
|
+
sortUsersByLookupIds,
|
|
4788
|
+
lookupFormattedUsersByIds,
|
|
3879
4789
|
isMaxCountReached,
|
|
3880
4790
|
isMeTagDisabled,
|
|
3881
4791
|
userTagCommonProps,
|
|
@@ -3884,9 +4794,13 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3884
4794
|
createCustomUser,
|
|
3885
4795
|
handlePaste,
|
|
3886
4796
|
displayOptions,
|
|
4797
|
+
mainNavigableUsers,
|
|
4798
|
+
filteredRecentUsers,
|
|
4799
|
+
showDropdown,
|
|
3887
4800
|
flatOptions,
|
|
3888
4801
|
inputWidth,
|
|
3889
4802
|
initSelectedUsers,
|
|
4803
|
+
initRecentUsers,
|
|
3890
4804
|
updateSelectedUsers,
|
|
3891
4805
|
initSortable,
|
|
3892
4806
|
calculateVisibleUsers,
|
|
@@ -3930,6 +4844,8 @@ var user_selector_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */
|
|
|
3930
4844
|
return __returned__;
|
|
3931
4845
|
}
|
|
3932
4846
|
});
|
|
4847
|
+
//#endregion
|
|
4848
|
+
//#region src/components/user-selector.vue
|
|
3933
4849
|
var _hoisted_1 = {
|
|
3934
4850
|
ref: "sortableContainerRef",
|
|
3935
4851
|
class: "tag-list"
|
|
@@ -3954,6 +4870,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3954
4870
|
"is-show": $setup.showDropdown,
|
|
3955
4871
|
loading: $setup.searchLoading,
|
|
3956
4872
|
options: $setup.displayOptions,
|
|
4873
|
+
"recent-users": $setup.filteredRecentUsers,
|
|
4874
|
+
"recent-users-name": $setup.computedRecentUsersName,
|
|
3957
4875
|
"render-list-item": $props.renderListItem,
|
|
3958
4876
|
"search-query": $setup.searchQuery,
|
|
3959
4877
|
"tenant-id": $props.tenantId,
|
|
@@ -4105,6 +5023,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4105
5023
|
"is-show",
|
|
4106
5024
|
"loading",
|
|
4107
5025
|
"options",
|
|
5026
|
+
"recent-users",
|
|
5027
|
+
"recent-users-name",
|
|
4108
5028
|
"render-list-item",
|
|
4109
5029
|
"search-query",
|
|
4110
5030
|
"tenant-id",
|
|
@@ -4113,10 +5033,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
4113
5033
|
"user-group-name"
|
|
4114
5034
|
])], 2);
|
|
4115
5035
|
}
|
|
4116
|
-
var user_selector_default = /* @__PURE__ */
|
|
5036
|
+
var user_selector_default = /* @__PURE__ */ _plugin_vue_export_helper_default(user_selector_vue_vue_type_script_setup_true_lang_default, [
|
|
4117
5037
|
["render", _sfc_render],
|
|
4118
5038
|
["__scopeId", "data-v-089550be"],
|
|
4119
5039
|
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/user-selector.vue"]
|
|
4120
5040
|
]);
|
|
5041
|
+
//#endregion
|
|
5042
|
+
//#region src/vue3.ts
|
|
4121
5043
|
var vue3_default = user_selector_default;
|
|
5044
|
+
//#endregion
|
|
4122
5045
|
export { user_selector_default as BkUserSelector, vue3_default as default };
|