@blueking/bkflow-canvas-editor 0.0.37 → 0.0.39
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 +69 -2
- package/dist/index.cjs.js +36 -36
- package/dist/index.es.min-BBOgAuB2.js +3214 -0
- package/dist/index.es.min-DQIH7mAl.cjs +2 -0
- package/dist/index.esm.js +15617 -15213
- package/dist/style.css +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,3214 @@
|
|
|
1
|
+
import { defineComponent as Wt, h as Mn, createElementBlock as oe, openBlock as Z, normalizeClass as It, createCommentVNode as se, createVNode as Qe, withCtx as ot, withDirectives as St, createElementVNode as Ae, withModifiers as je, normalizeStyle as hn, vModelText as pn, Fragment as Ut, renderList as Dt, mergeProps as er, vShow as tr, createBlock as Yt, createTextVNode as Pr, toDisplayString as gt, ref as te, computed as re, toRef as nr, watch as at, nextTick as me, onBeforeMount as or, onMounted as Rr, onUnmounted as ir, provide as Br, renderSlot as Nr, unref as Lr } from "vue";
|
|
2
|
+
import { provideGlobalConfig as Fr, Tag as lr, Popover as sr, Loading as qr } from "bkui-vue";
|
|
3
|
+
var Gr = Object.create, ur = Object.defineProperty, zr = Object.getOwnPropertyDescriptor, jr = Object.getOwnPropertyNames, Kr = Object.getPrototypeOf, Hr = Object.prototype.hasOwnProperty, Yr = (c, d) => () => (d || c((d = { exports: {} }).exports, d), d.exports), Xr = (c, d, u, o) => {
|
|
4
|
+
if (d && typeof d == "object" || typeof d == "function") for (var l = jr(d), v = 0, f = l.length, w; v < f; v++)
|
|
5
|
+
w = l[v], !Hr.call(c, w) && w !== u && ur(c, w, {
|
|
6
|
+
get: ((b) => d[b]).bind(null, w),
|
|
7
|
+
enumerable: !(o = zr(d, w)) || o.enumerable
|
|
8
|
+
});
|
|
9
|
+
return c;
|
|
10
|
+
}, Wr = (c, d, u) => (u = c != null ? Gr(Kr(c)) : {}, Xr(!c || !c.__esModule ? ur(u, "default", {
|
|
11
|
+
value: c,
|
|
12
|
+
enumerable: !0
|
|
13
|
+
}) : u, c)), Vr = /* @__PURE__ */ Wr((/* @__PURE__ */ Yr(((c, d) => {
|
|
14
|
+
(function(u, o) {
|
|
15
|
+
typeof c == "object" && typeof d < "u" ? d.exports = o() : typeof define == "function" && define.amd ? define(o) : (u = u || self, u.Sortable = o());
|
|
16
|
+
})(c, (function() {
|
|
17
|
+
function u(r, e) {
|
|
18
|
+
var t = Object.keys(r);
|
|
19
|
+
if (Object.getOwnPropertySymbols) {
|
|
20
|
+
var n = Object.getOwnPropertySymbols(r);
|
|
21
|
+
e && (n = n.filter(function(a) {
|
|
22
|
+
return Object.getOwnPropertyDescriptor(r, a).enumerable;
|
|
23
|
+
})), t.push.apply(t, n);
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
}
|
|
27
|
+
function o(r) {
|
|
28
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
29
|
+
var t = arguments[e] != null ? arguments[e] : {};
|
|
30
|
+
e % 2 ? u(Object(t), !0).forEach(function(n) {
|
|
31
|
+
v(r, n, t[n]);
|
|
32
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(r, Object.getOwnPropertyDescriptors(t)) : u(Object(t)).forEach(function(n) {
|
|
33
|
+
Object.defineProperty(r, n, Object.getOwnPropertyDescriptor(t, n));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return r;
|
|
37
|
+
}
|
|
38
|
+
function l(r) {
|
|
39
|
+
"@babel/helpers - typeof";
|
|
40
|
+
return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? l = function(e) {
|
|
41
|
+
return typeof e;
|
|
42
|
+
} : l = function(e) {
|
|
43
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
44
|
+
}, l(r);
|
|
45
|
+
}
|
|
46
|
+
function v(r, e, t) {
|
|
47
|
+
return e in r ? Object.defineProperty(r, e, {
|
|
48
|
+
value: t,
|
|
49
|
+
enumerable: !0,
|
|
50
|
+
configurable: !0,
|
|
51
|
+
writable: !0
|
|
52
|
+
}) : r[e] = t, r;
|
|
53
|
+
}
|
|
54
|
+
function f() {
|
|
55
|
+
return f = Object.assign || function(r) {
|
|
56
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
57
|
+
var t = arguments[e];
|
|
58
|
+
for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (r[n] = t[n]);
|
|
59
|
+
}
|
|
60
|
+
return r;
|
|
61
|
+
}, f.apply(this, arguments);
|
|
62
|
+
}
|
|
63
|
+
function w(r, e) {
|
|
64
|
+
if (r == null) return {};
|
|
65
|
+
var t = {}, n = Object.keys(r), a, i;
|
|
66
|
+
for (i = 0; i < n.length; i++)
|
|
67
|
+
a = n[i], !(e.indexOf(a) >= 0) && (t[a] = r[a]);
|
|
68
|
+
return t;
|
|
69
|
+
}
|
|
70
|
+
function b(r, e) {
|
|
71
|
+
if (r == null) return {};
|
|
72
|
+
var t = w(r, e), n, a;
|
|
73
|
+
if (Object.getOwnPropertySymbols) {
|
|
74
|
+
var i = Object.getOwnPropertySymbols(r);
|
|
75
|
+
for (a = 0; a < i.length; a++)
|
|
76
|
+
n = i[a], !(e.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(r, n) && (t[n] = r[n]);
|
|
77
|
+
}
|
|
78
|
+
return t;
|
|
79
|
+
}
|
|
80
|
+
function B(r) {
|
|
81
|
+
return G(r) || H(r) || ye(r) || Le();
|
|
82
|
+
}
|
|
83
|
+
function G(r) {
|
|
84
|
+
if (Array.isArray(r)) return Ne(r);
|
|
85
|
+
}
|
|
86
|
+
function H(r) {
|
|
87
|
+
if (typeof Symbol < "u" && r[Symbol.iterator] != null || r["@@iterator"] != null) return Array.from(r);
|
|
88
|
+
}
|
|
89
|
+
function ye(r, e) {
|
|
90
|
+
if (r) {
|
|
91
|
+
if (typeof r == "string") return Ne(r, e);
|
|
92
|
+
var t = Object.prototype.toString.call(r).slice(8, -1);
|
|
93
|
+
if (t === "Object" && r.constructor && (t = r.constructor.name), t === "Map" || t === "Set") return Array.from(r);
|
|
94
|
+
if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return Ne(r, e);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function Ne(r, e) {
|
|
98
|
+
(e == null || e > r.length) && (e = r.length);
|
|
99
|
+
for (var t = 0, n = new Array(e); t < e; t++) n[t] = r[t];
|
|
100
|
+
return n;
|
|
101
|
+
}
|
|
102
|
+
function Le() {
|
|
103
|
+
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
104
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
105
|
+
}
|
|
106
|
+
var De = "1.15.6";
|
|
107
|
+
function F(r) {
|
|
108
|
+
if (typeof window < "u" && window.navigator) return !!/* @__PURE__ */ navigator.userAgent.match(r);
|
|
109
|
+
}
|
|
110
|
+
var z = F(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i), Se = F(/Edge/i), vt = F(/firefox/i), $ = F(/safari/i) && !F(/chrome/i) && !F(/android/i), X = F(/iP(ad|od|hone)/i), D = F(/chrome/i) && F(/android/i), ue = {
|
|
111
|
+
capture: !1,
|
|
112
|
+
passive: !1
|
|
113
|
+
};
|
|
114
|
+
function x(r, e, t) {
|
|
115
|
+
r.addEventListener(e, t, !z && ue);
|
|
116
|
+
}
|
|
117
|
+
function O(r, e, t) {
|
|
118
|
+
r.removeEventListener(e, t, !z && ue);
|
|
119
|
+
}
|
|
120
|
+
function Y(r, e) {
|
|
121
|
+
if (e) {
|
|
122
|
+
if (e[0] === ">" && (e = e.substring(1)), r) try {
|
|
123
|
+
if (r.matches) return r.matches(e);
|
|
124
|
+
if (r.msMatchesSelector) return r.msMatchesSelector(e);
|
|
125
|
+
if (r.webkitMatchesSelector) return r.webkitMatchesSelector(e);
|
|
126
|
+
} catch {
|
|
127
|
+
return !1;
|
|
128
|
+
}
|
|
129
|
+
return !1;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function be(r) {
|
|
133
|
+
return r.host && r !== document && r.host.nodeType ? r.host : r.parentNode;
|
|
134
|
+
}
|
|
135
|
+
function ne(r, e, t, n) {
|
|
136
|
+
if (r) {
|
|
137
|
+
t = t || document;
|
|
138
|
+
do {
|
|
139
|
+
if (e != null && (e[0] === ">" ? r.parentNode === t && Y(r, e) : Y(r, e)) || n && r === t) return r;
|
|
140
|
+
if (r === t) break;
|
|
141
|
+
} while (r = be(r));
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
var Ze = /\s+/g;
|
|
146
|
+
function U(r, e, t) {
|
|
147
|
+
r && e && (r.classList ? r.classList[t ? "add" : "remove"](e) : r.className = ((" " + r.className + " ").replace(Ze, " ").replace(" " + e + " ", " ") + (t ? " " + e : "")).replace(Ze, " "));
|
|
148
|
+
}
|
|
149
|
+
function S(r, e, t) {
|
|
150
|
+
var n = r && r.style;
|
|
151
|
+
if (n) {
|
|
152
|
+
if (t === void 0)
|
|
153
|
+
return document.defaultView && document.defaultView.getComputedStyle ? t = document.defaultView.getComputedStyle(r, "") : r.currentStyle && (t = r.currentStyle), e === void 0 ? t : t[e];
|
|
154
|
+
!(e in n) && e.indexOf("webkit") === -1 && (e = "-webkit-" + e), n[e] = t + (typeof t == "string" ? "" : "px");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function ke(r, e) {
|
|
158
|
+
var t = "";
|
|
159
|
+
if (typeof r == "string") t = r;
|
|
160
|
+
else do {
|
|
161
|
+
var n = S(r, "transform");
|
|
162
|
+
n && n !== "none" && (t = n + " " + t);
|
|
163
|
+
} while (!e && (r = r.parentNode));
|
|
164
|
+
var a = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
|
|
165
|
+
return a && new a(t);
|
|
166
|
+
}
|
|
167
|
+
function Vt(r, e, t) {
|
|
168
|
+
if (r) {
|
|
169
|
+
var n = r.getElementsByTagName(e), a = 0, i = n.length;
|
|
170
|
+
if (t) for (; a < i; a++) t(n[a], a);
|
|
171
|
+
return n;
|
|
172
|
+
}
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
function Te() {
|
|
176
|
+
var r = document.scrollingElement;
|
|
177
|
+
return r || document.documentElement;
|
|
178
|
+
}
|
|
179
|
+
function j(r, e, t, n, a) {
|
|
180
|
+
if (!(!r.getBoundingClientRect && r !== window)) {
|
|
181
|
+
var i, s, h, g, m, I, C;
|
|
182
|
+
if (r !== window && r.parentNode && r !== Te() ? (i = r.getBoundingClientRect(), s = i.top, h = i.left, g = i.bottom, m = i.right, I = i.height, C = i.width) : (s = 0, h = 0, g = window.innerHeight, m = window.innerWidth, I = window.innerHeight, C = window.innerWidth), (e || t) && r !== window && (a = a || r.parentNode, !z))
|
|
183
|
+
do
|
|
184
|
+
if (a && a.getBoundingClientRect && (S(a, "transform") !== "none" || t && S(a, "position") !== "static")) {
|
|
185
|
+
var T = a.getBoundingClientRect();
|
|
186
|
+
s -= T.top + parseInt(S(a, "border-top-width")), h -= T.left + parseInt(S(a, "border-left-width")), g = s + i.height, m = h + i.width;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
while (a = a.parentNode);
|
|
190
|
+
if (n && r !== window) {
|
|
191
|
+
var L = ke(a || r), P = L && L.a, q = L && L.d;
|
|
192
|
+
L && (s /= q, h /= P, C /= P, I /= q, g = s + I, m = h + C);
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
top: s,
|
|
196
|
+
left: h,
|
|
197
|
+
bottom: g,
|
|
198
|
+
right: m,
|
|
199
|
+
width: C,
|
|
200
|
+
height: I
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
function Qt(r, e, t) {
|
|
205
|
+
for (var n = Ee(r, !0), a = j(r)[e]; n; ) {
|
|
206
|
+
var i = j(n)[t], s = void 0;
|
|
207
|
+
if (s = a >= i, !s) return n;
|
|
208
|
+
if (n === Te()) break;
|
|
209
|
+
n = Ee(n, !1);
|
|
210
|
+
}
|
|
211
|
+
return !1;
|
|
212
|
+
}
|
|
213
|
+
function Je(r, e, t, n) {
|
|
214
|
+
for (var a = 0, i = 0, s = r.children; i < s.length; ) {
|
|
215
|
+
if (s[i].style.display !== "none" && s[i] !== A.ghost && (n || s[i] !== A.dragged) && ne(s[i], t.draggable, r, !1)) {
|
|
216
|
+
if (a === e) return s[i];
|
|
217
|
+
a++;
|
|
218
|
+
}
|
|
219
|
+
i++;
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
function Tt(r, e) {
|
|
224
|
+
for (var t = r.lastElementChild; t && (t === A.ghost || S(t, "display") === "none" || e && !Y(t, e)); ) t = t.previousElementSibling;
|
|
225
|
+
return t || null;
|
|
226
|
+
}
|
|
227
|
+
function ee(r, e) {
|
|
228
|
+
var t = 0;
|
|
229
|
+
if (!r || !r.parentNode) return -1;
|
|
230
|
+
for (; r = r.previousElementSibling; ) r.nodeName.toUpperCase() !== "TEMPLATE" && r !== A.clone && (!e || Y(r, e)) && t++;
|
|
231
|
+
return t;
|
|
232
|
+
}
|
|
233
|
+
function mt(r) {
|
|
234
|
+
var e = 0, t = 0, n = Te();
|
|
235
|
+
if (r) do {
|
|
236
|
+
var a = ke(r), i = a.a, s = a.d;
|
|
237
|
+
e += r.scrollLeft * i, t += r.scrollTop * s;
|
|
238
|
+
} while (r !== n && (r = r.parentNode));
|
|
239
|
+
return [e, t];
|
|
240
|
+
}
|
|
241
|
+
function Zt(r, e) {
|
|
242
|
+
for (var t in r)
|
|
243
|
+
if (r.hasOwnProperty(t)) {
|
|
244
|
+
for (var n in e) if (e.hasOwnProperty(n) && e[n] === r[t][n]) return Number(t);
|
|
245
|
+
}
|
|
246
|
+
return -1;
|
|
247
|
+
}
|
|
248
|
+
function Ee(r, e) {
|
|
249
|
+
if (!r || !r.getBoundingClientRect) return Te();
|
|
250
|
+
var t = r, n = !1;
|
|
251
|
+
do
|
|
252
|
+
if (t.clientWidth < t.scrollWidth || t.clientHeight < t.scrollHeight) {
|
|
253
|
+
var a = S(t);
|
|
254
|
+
if (t.clientWidth < t.scrollWidth && (a.overflowX == "auto" || a.overflowX == "scroll") || t.clientHeight < t.scrollHeight && (a.overflowY == "auto" || a.overflowY == "scroll")) {
|
|
255
|
+
if (!t.getBoundingClientRect || t === document.body) return Te();
|
|
256
|
+
if (n || e) return t;
|
|
257
|
+
n = !0;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
while (t = t.parentNode);
|
|
261
|
+
return Te();
|
|
262
|
+
}
|
|
263
|
+
function yt(r, e) {
|
|
264
|
+
if (r && e)
|
|
265
|
+
for (var t in e) e.hasOwnProperty(t) && (r[t] = e[t]);
|
|
266
|
+
return r;
|
|
267
|
+
}
|
|
268
|
+
function $e(r, e) {
|
|
269
|
+
return Math.round(r.top) === Math.round(e.top) && Math.round(r.left) === Math.round(e.left) && Math.round(r.height) === Math.round(e.height) && Math.round(r.width) === Math.round(e.width);
|
|
270
|
+
}
|
|
271
|
+
var Ke;
|
|
272
|
+
function it(r, e) {
|
|
273
|
+
return function() {
|
|
274
|
+
if (!Ke) {
|
|
275
|
+
var t = arguments, n = this;
|
|
276
|
+
t.length === 1 ? r.call(n, t[0]) : r.apply(n, t), Ke = setTimeout(function() {
|
|
277
|
+
Ke = void 0;
|
|
278
|
+
}, e);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function _n() {
|
|
283
|
+
clearTimeout(Ke), Ke = void 0;
|
|
284
|
+
}
|
|
285
|
+
function Jt(r, e, t) {
|
|
286
|
+
r.scrollLeft += e, r.scrollTop += t;
|
|
287
|
+
}
|
|
288
|
+
function lt(r) {
|
|
289
|
+
var e = window.Polymer, t = window.jQuery || window.Zepto;
|
|
290
|
+
return e && e.dom ? e.dom(r).cloneNode(!0) : t ? t(r).clone(!0)[0] : r.cloneNode(!0);
|
|
291
|
+
}
|
|
292
|
+
function Ot(r, e) {
|
|
293
|
+
S(r, "position", "absolute"), S(r, "top", e.top), S(r, "left", e.left), S(r, "width", e.width), S(r, "height", e.height);
|
|
294
|
+
}
|
|
295
|
+
function bt(r) {
|
|
296
|
+
S(r, "position", ""), S(r, "top", ""), S(r, "left", ""), S(r, "width", ""), S(r, "height", "");
|
|
297
|
+
}
|
|
298
|
+
function xt(r, e, t) {
|
|
299
|
+
var n = {};
|
|
300
|
+
return Array.from(r.children).forEach(function(a) {
|
|
301
|
+
var i, s, h, g;
|
|
302
|
+
if (!(!ne(a, e.draggable, r, !1) || a.animated || a === t)) {
|
|
303
|
+
var m = j(a);
|
|
304
|
+
n.left = Math.min((i = n.left) !== null && i !== void 0 ? i : 1 / 0, m.left), n.top = Math.min((s = n.top) !== null && s !== void 0 ? s : 1 / 0, m.top), n.right = Math.max((h = n.right) !== null && h !== void 0 ? h : -1 / 0, m.right), n.bottom = Math.max((g = n.bottom) !== null && g !== void 0 ? g : -1 / 0, m.bottom);
|
|
305
|
+
}
|
|
306
|
+
}), n.width = n.right - n.left, n.height = n.bottom - n.top, n.x = n.left, n.y = n.top, n;
|
|
307
|
+
}
|
|
308
|
+
var ae = "Sortable" + (/* @__PURE__ */ new Date()).getTime();
|
|
309
|
+
function $t() {
|
|
310
|
+
var r = [], e;
|
|
311
|
+
return {
|
|
312
|
+
captureAnimationState: function() {
|
|
313
|
+
r = [], this.options.animation && [].slice.call(this.el.children).forEach(function(n) {
|
|
314
|
+
if (!(S(n, "display") === "none" || n === A.ghost)) {
|
|
315
|
+
r.push({
|
|
316
|
+
target: n,
|
|
317
|
+
rect: j(n)
|
|
318
|
+
});
|
|
319
|
+
var a = o({}, r[r.length - 1].rect);
|
|
320
|
+
if (n.thisAnimationDuration) {
|
|
321
|
+
var i = ke(n, !0);
|
|
322
|
+
i && (a.top -= i.f, a.left -= i.e);
|
|
323
|
+
}
|
|
324
|
+
n.fromRect = a;
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
addAnimationState: function(n) {
|
|
329
|
+
r.push(n);
|
|
330
|
+
},
|
|
331
|
+
removeAnimationState: function(n) {
|
|
332
|
+
r.splice(Zt(r, { target: n }), 1);
|
|
333
|
+
},
|
|
334
|
+
animateAll: function(n) {
|
|
335
|
+
var a = this;
|
|
336
|
+
if (!this.options.animation) {
|
|
337
|
+
clearTimeout(e), typeof n == "function" && n();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
var i = !1, s = 0;
|
|
341
|
+
r.forEach(function(h) {
|
|
342
|
+
var g = 0, m = h.target, I = m.fromRect, C = j(m), T = m.prevFromRect, L = m.prevToRect, P = h.rect, q = ke(m, !0);
|
|
343
|
+
q && (C.top -= q.f, C.left -= q.e), m.toRect = C, m.thisAnimationDuration && $e(T, C) && !$e(I, C) && (P.top - C.top) / (P.left - C.left) === (I.top - C.top) / (I.left - C.left) && (g = wt(P, T, L, a.options)), $e(C, I) || (m.prevFromRect = I, m.prevToRect = C, g || (g = a.options.animation), a.animate(m, P, C, g)), g && (i = !0, s = Math.max(s, g), clearTimeout(m.animationResetTimer), m.animationResetTimer = setTimeout(function() {
|
|
344
|
+
m.animationTime = 0, m.prevFromRect = null, m.fromRect = null, m.prevToRect = null, m.thisAnimationDuration = null;
|
|
345
|
+
}, g), m.thisAnimationDuration = g);
|
|
346
|
+
}), clearTimeout(e), i ? e = setTimeout(function() {
|
|
347
|
+
typeof n == "function" && n();
|
|
348
|
+
}, s) : typeof n == "function" && n(), r = [];
|
|
349
|
+
},
|
|
350
|
+
animate: function(n, a, i, s) {
|
|
351
|
+
if (s) {
|
|
352
|
+
S(n, "transition", ""), S(n, "transform", "");
|
|
353
|
+
var h = ke(this.el), g = h && h.a, m = h && h.d, I = (a.left - i.left) / (g || 1), C = (a.top - i.top) / (m || 1);
|
|
354
|
+
n.animatingX = !!I, n.animatingY = !!C, S(n, "transform", "translate3d(" + I + "px," + C + "px,0)"), this.forRepaintDummy = At(n), S(n, "transition", "transform " + s + "ms" + (this.options.easing ? " " + this.options.easing : "")), S(n, "transform", "translate3d(0,0,0)"), typeof n.animated == "number" && clearTimeout(n.animated), n.animated = setTimeout(function() {
|
|
355
|
+
S(n, "transition", ""), S(n, "transform", ""), n.animated = !1, n.animatingX = !1, n.animatingY = !1;
|
|
356
|
+
}, s);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
function At(r) {
|
|
362
|
+
return r.offsetWidth;
|
|
363
|
+
}
|
|
364
|
+
function wt(r, e, t, n) {
|
|
365
|
+
return Math.sqrt(Math.pow(e.top - r.top, 2) + Math.pow(e.left - r.left, 2)) / Math.sqrt(Math.pow(e.top - t.top, 2) + Math.pow(e.left - t.left, 2)) * n.animation;
|
|
366
|
+
}
|
|
367
|
+
var we = [], kt = { initializeByDefault: !0 }, Fe = {
|
|
368
|
+
mount: function(e) {
|
|
369
|
+
for (var t in kt) kt.hasOwnProperty(t) && !(t in e) && (e[t] = kt[t]);
|
|
370
|
+
we.forEach(function(n) {
|
|
371
|
+
if (n.pluginName === e.pluginName) throw "Sortable: Cannot mount plugin ".concat(e.pluginName, " more than once");
|
|
372
|
+
}), we.push(e);
|
|
373
|
+
},
|
|
374
|
+
pluginEvent: function(e, t, n) {
|
|
375
|
+
var a = this;
|
|
376
|
+
this.eventCanceled = !1, n.cancel = function() {
|
|
377
|
+
a.eventCanceled = !0;
|
|
378
|
+
};
|
|
379
|
+
var i = e + "Global";
|
|
380
|
+
we.forEach(function(s) {
|
|
381
|
+
t[s.pluginName] && (t[s.pluginName][i] && t[s.pluginName][i](o({ sortable: t }, n)), t.options[s.pluginName] && t[s.pluginName][e] && t[s.pluginName][e](o({ sortable: t }, n)));
|
|
382
|
+
});
|
|
383
|
+
},
|
|
384
|
+
initializePlugins: function(e, t, n, a) {
|
|
385
|
+
we.forEach(function(h) {
|
|
386
|
+
var g = h.pluginName;
|
|
387
|
+
if (!(!e.options[g] && !h.initializeByDefault)) {
|
|
388
|
+
var m = new h(e, t, e.options);
|
|
389
|
+
m.sortable = e, m.options = e.options, e[g] = m, f(n, m.defaults);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
for (var i in e.options)
|
|
393
|
+
if (e.options.hasOwnProperty(i)) {
|
|
394
|
+
var s = this.modifyOption(e, i, e.options[i]);
|
|
395
|
+
typeof s < "u" && (e.options[i] = s);
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
getEventProperties: function(e, t) {
|
|
399
|
+
var n = {};
|
|
400
|
+
return we.forEach(function(a) {
|
|
401
|
+
typeof a.eventProperties == "function" && f(n, a.eventProperties.call(t[a.pluginName], e));
|
|
402
|
+
}), n;
|
|
403
|
+
},
|
|
404
|
+
modifyOption: function(e, t, n) {
|
|
405
|
+
var a;
|
|
406
|
+
return we.forEach(function(i) {
|
|
407
|
+
e[i.pluginName] && i.optionListeners && typeof i.optionListeners[t] == "function" && (a = i.optionListeners[t].call(e[i.pluginName], n));
|
|
408
|
+
}), a;
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
function He(r) {
|
|
412
|
+
var e = r.sortable, t = r.rootEl, n = r.name, a = r.targetEl, i = r.cloneEl, s = r.toEl, h = r.fromEl, g = r.oldIndex, m = r.newIndex, I = r.oldDraggableIndex, C = r.newDraggableIndex, T = r.originalEvent, L = r.putSortable, P = r.extraEventProperties;
|
|
413
|
+
if (e = e || t && t[ae], !!e) {
|
|
414
|
+
var q, ve = e.options, xe = "on" + n.charAt(0).toUpperCase() + n.substr(1);
|
|
415
|
+
window.CustomEvent && !z && !Se ? q = new CustomEvent(n, {
|
|
416
|
+
bubbles: !0,
|
|
417
|
+
cancelable: !0
|
|
418
|
+
}) : (q = document.createEvent("Event"), q.initEvent(n, !0, !0)), q.to = s || t, q.from = h || t, q.item = a || t, q.clone = i, q.oldIndex = g, q.newIndex = m, q.oldDraggableIndex = I, q.newDraggableIndex = C, q.originalEvent = T, q.pullMode = L ? L.lastPutMode : void 0;
|
|
419
|
+
var R = o(o({}, P), Fe.getEventProperties(n, e));
|
|
420
|
+
for (var Q in R) q[Q] = R[Q];
|
|
421
|
+
t && t.dispatchEvent(q), ve[xe] && ve[xe].call(e, q);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
var Me = ["evt"], de = function(e, t) {
|
|
425
|
+
var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, a = n.evt, i = b(n, Me);
|
|
426
|
+
Fe.pluginEvent.bind(A)(e, t, o({
|
|
427
|
+
dragEl: y,
|
|
428
|
+
parentEl: K,
|
|
429
|
+
ghostEl: k,
|
|
430
|
+
rootEl: W,
|
|
431
|
+
nextEl: Ye,
|
|
432
|
+
lastDownEl: pe,
|
|
433
|
+
cloneEl: J,
|
|
434
|
+
cloneHidden: qe,
|
|
435
|
+
dragStarted: dt,
|
|
436
|
+
putSortable: ce,
|
|
437
|
+
activeSortable: A.active,
|
|
438
|
+
originalEvent: a,
|
|
439
|
+
oldIndex: et,
|
|
440
|
+
oldDraggableIndex: st,
|
|
441
|
+
newIndex: ge,
|
|
442
|
+
newDraggableIndex: Ge,
|
|
443
|
+
hideGhostForTarget: Wn,
|
|
444
|
+
unhideGhostForTarget: Vn,
|
|
445
|
+
cloneNowHidden: function() {
|
|
446
|
+
qe = !0;
|
|
447
|
+
},
|
|
448
|
+
cloneNowShown: function() {
|
|
449
|
+
qe = !1;
|
|
450
|
+
},
|
|
451
|
+
dispatchSortableEvent: function(h) {
|
|
452
|
+
ie({
|
|
453
|
+
sortable: t,
|
|
454
|
+
name: h,
|
|
455
|
+
originalEvent: a
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}, i));
|
|
459
|
+
};
|
|
460
|
+
function ie(r) {
|
|
461
|
+
He(o({
|
|
462
|
+
putSortable: ce,
|
|
463
|
+
cloneEl: J,
|
|
464
|
+
targetEl: y,
|
|
465
|
+
rootEl: W,
|
|
466
|
+
oldIndex: et,
|
|
467
|
+
oldDraggableIndex: st,
|
|
468
|
+
newIndex: ge,
|
|
469
|
+
newDraggableIndex: Ge
|
|
470
|
+
}, r));
|
|
471
|
+
}
|
|
472
|
+
var y, K, k, W, Ye, pe, J, qe, et, ge, st, Ge, Xe, ce, Pe = !1, ut = !1, p = [], _, E, N, _e, tt, ct, dt, _t, Mt, Pt = !1, en = !1, tn, he, Cn = [], Sn = !1, nn = [], rn = typeof document < "u", an = X, Kn = Se || z ? "cssFloat" : "float", gr = rn && !D && !X && "draggable" in document.createElement("div"), Hn = (function() {
|
|
473
|
+
if (rn) {
|
|
474
|
+
if (z) return !1;
|
|
475
|
+
var r = document.createElement("x");
|
|
476
|
+
return r.style.cssText = "pointer-events:auto", r.style.pointerEvents === "auto";
|
|
477
|
+
}
|
|
478
|
+
})(), Yn = function(e, t) {
|
|
479
|
+
var n = S(e), a = parseInt(n.width) - parseInt(n.paddingLeft) - parseInt(n.paddingRight) - parseInt(n.borderLeftWidth) - parseInt(n.borderRightWidth), i = Je(e, 0, t), s = Je(e, 1, t), h = i && S(i), g = s && S(s), m = h && parseInt(h.marginLeft) + parseInt(h.marginRight) + j(i).width, I = g && parseInt(g.marginLeft) + parseInt(g.marginRight) + j(s).width;
|
|
480
|
+
if (n.display === "flex") return n.flexDirection === "column" || n.flexDirection === "column-reverse" ? "vertical" : "horizontal";
|
|
481
|
+
if (n.display === "grid") return n.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
|
|
482
|
+
if (i && h.float && h.float !== "none") {
|
|
483
|
+
var C = h.float === "left" ? "left" : "right";
|
|
484
|
+
return s && (g.clear === "both" || g.clear === C) ? "vertical" : "horizontal";
|
|
485
|
+
}
|
|
486
|
+
return i && (h.display === "block" || h.display === "flex" || h.display === "table" || h.display === "grid" || m >= a && n[Kn] === "none" || s && n[Kn] === "none" && m + I > a) ? "vertical" : "horizontal";
|
|
487
|
+
}, vr = function(e, t, n) {
|
|
488
|
+
var a = n ? e.left : e.top, i = n ? e.right : e.bottom, s = n ? e.width : e.height, h = n ? t.left : t.top, g = n ? t.right : t.bottom, m = n ? t.width : t.height;
|
|
489
|
+
return a === h || i === g || a + s / 2 === h + m / 2;
|
|
490
|
+
}, mr = function(e, t) {
|
|
491
|
+
var n;
|
|
492
|
+
return p.some(function(a) {
|
|
493
|
+
var i = a[ae].options.emptyInsertThreshold;
|
|
494
|
+
if (!(!i || Tt(a))) {
|
|
495
|
+
var s = j(a), h = e >= s.left - i && e <= s.right + i, g = t >= s.top - i && t <= s.bottom + i;
|
|
496
|
+
if (h && g) return n = a;
|
|
497
|
+
}
|
|
498
|
+
}), n;
|
|
499
|
+
}, Xn = function(e) {
|
|
500
|
+
function t(i, s) {
|
|
501
|
+
return function(h, g, m, I) {
|
|
502
|
+
var C = h.options.group.name && g.options.group.name && h.options.group.name === g.options.group.name;
|
|
503
|
+
if (i == null && (s || C)) return !0;
|
|
504
|
+
if (i == null || i === !1) return !1;
|
|
505
|
+
if (s && i === "clone") return i;
|
|
506
|
+
if (typeof i == "function") return t(i(h, g, m, I), s)(h, g, m, I);
|
|
507
|
+
var T = (s ? h : g).options.group.name;
|
|
508
|
+
return i === !0 || typeof i == "string" && i === T || i.join && i.indexOf(T) > -1;
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
var n = {}, a = e.group;
|
|
512
|
+
(!a || l(a) != "object") && (a = { name: a }), n.name = a.name, n.checkPull = t(a.pull, !0), n.checkPut = t(a.put), n.revertClone = a.revertClone, e.group = n;
|
|
513
|
+
}, Wn = function() {
|
|
514
|
+
!Hn && k && S(k, "display", "none");
|
|
515
|
+
}, Vn = function() {
|
|
516
|
+
!Hn && k && S(k, "display", "");
|
|
517
|
+
};
|
|
518
|
+
rn && !D && document.addEventListener("click", function(r) {
|
|
519
|
+
if (ut)
|
|
520
|
+
return r.preventDefault(), r.stopPropagation && r.stopPropagation(), r.stopImmediatePropagation && r.stopImmediatePropagation(), ut = !1, !1;
|
|
521
|
+
}, !0);
|
|
522
|
+
var ft = function(e) {
|
|
523
|
+
if (y) {
|
|
524
|
+
e = e.touches ? e.touches[0] : e;
|
|
525
|
+
var t = mr(e.clientX, e.clientY);
|
|
526
|
+
if (t) {
|
|
527
|
+
var n = {};
|
|
528
|
+
for (var a in e) e.hasOwnProperty(a) && (n[a] = e[a]);
|
|
529
|
+
n.target = n.rootEl = t, n.preventDefault = void 0, n.stopPropagation = void 0, t[ae]._onDragOver(n);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}, yr = function(e) {
|
|
533
|
+
y && y.parentNode[ae]._isOutsideThisEl(e.target);
|
|
534
|
+
};
|
|
535
|
+
function A(r, e) {
|
|
536
|
+
if (!(r && r.nodeType && r.nodeType === 1)) throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(r));
|
|
537
|
+
this.el = r, this.options = e = f({}, e), r[ae] = this;
|
|
538
|
+
var t = {
|
|
539
|
+
group: null,
|
|
540
|
+
sort: !0,
|
|
541
|
+
disabled: !1,
|
|
542
|
+
store: null,
|
|
543
|
+
handle: null,
|
|
544
|
+
draggable: /^[uo]l$/i.test(r.nodeName) ? ">li" : ">*",
|
|
545
|
+
swapThreshold: 1,
|
|
546
|
+
invertSwap: !1,
|
|
547
|
+
invertedSwapThreshold: null,
|
|
548
|
+
removeCloneOnHide: !0,
|
|
549
|
+
direction: function() {
|
|
550
|
+
return Yn(r, this.options);
|
|
551
|
+
},
|
|
552
|
+
ghostClass: "sortable-ghost",
|
|
553
|
+
chosenClass: "sortable-chosen",
|
|
554
|
+
dragClass: "sortable-drag",
|
|
555
|
+
ignore: "a, img",
|
|
556
|
+
filter: null,
|
|
557
|
+
preventOnFilter: !0,
|
|
558
|
+
animation: 0,
|
|
559
|
+
easing: null,
|
|
560
|
+
setData: function(s, h) {
|
|
561
|
+
s.setData("Text", h.textContent);
|
|
562
|
+
},
|
|
563
|
+
dropBubble: !1,
|
|
564
|
+
dragoverBubble: !1,
|
|
565
|
+
dataIdAttr: "data-id",
|
|
566
|
+
delay: 0,
|
|
567
|
+
delayOnTouchOnly: !1,
|
|
568
|
+
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
|
|
569
|
+
forceFallback: !1,
|
|
570
|
+
fallbackClass: "sortable-fallback",
|
|
571
|
+
fallbackOnBody: !1,
|
|
572
|
+
fallbackTolerance: 0,
|
|
573
|
+
fallbackOffset: {
|
|
574
|
+
x: 0,
|
|
575
|
+
y: 0
|
|
576
|
+
},
|
|
577
|
+
supportPointer: A.supportPointer !== !1 && "PointerEvent" in window && (!$ || X),
|
|
578
|
+
emptyInsertThreshold: 5
|
|
579
|
+
};
|
|
580
|
+
Fe.initializePlugins(this, r, t);
|
|
581
|
+
for (var n in t) !(n in e) && (e[n] = t[n]);
|
|
582
|
+
Xn(e);
|
|
583
|
+
for (var a in this) a.charAt(0) === "_" && typeof this[a] == "function" && (this[a] = this[a].bind(this));
|
|
584
|
+
this.nativeDraggable = e.forceFallback ? !1 : gr, this.nativeDraggable && (this.options.touchStartThreshold = 1), e.supportPointer ? x(r, "pointerdown", this._onTapStart) : (x(r, "mousedown", this._onTapStart), x(r, "touchstart", this._onTapStart)), this.nativeDraggable && (x(r, "dragover", this), x(r, "dragenter", this)), p.push(this.el), e.store && e.store.get && this.sort(e.store.get(this) || []), f(this, $t());
|
|
585
|
+
}
|
|
586
|
+
A.prototype = /** @lends Sortable.prototype */
|
|
587
|
+
{
|
|
588
|
+
constructor: A,
|
|
589
|
+
_isOutsideThisEl: function(e) {
|
|
590
|
+
!this.el.contains(e) && e !== this.el && (_t = null);
|
|
591
|
+
},
|
|
592
|
+
_getDirection: function(e, t) {
|
|
593
|
+
return typeof this.options.direction == "function" ? this.options.direction.call(this, e, t, y) : this.options.direction;
|
|
594
|
+
},
|
|
595
|
+
_onTapStart: function(e) {
|
|
596
|
+
if (e.cancelable) {
|
|
597
|
+
var t = this, n = this.el, a = this.options, i = a.preventOnFilter, s = e.type, h = e.touches && e.touches[0] || e.pointerType && e.pointerType === "touch" && e, g = (h || e).target, m = e.target.shadowRoot && (e.path && e.path[0] || e.composedPath && e.composedPath()[0]) || g, I = a.filter;
|
|
598
|
+
if (Ur(n), !y && !(/mousedown|pointerdown/.test(s) && e.button !== 0 || a.disabled) && !m.isContentEditable && !(!this.nativeDraggable && $ && g && g.tagName.toUpperCase() === "SELECT") && (g = ne(g, a.draggable, n, !1), !(g && g.animated) && pe !== g)) {
|
|
599
|
+
if (et = ee(g), st = ee(g, a.draggable), typeof I == "function") {
|
|
600
|
+
if (I.call(this, e, g, this)) {
|
|
601
|
+
ie({
|
|
602
|
+
sortable: t,
|
|
603
|
+
rootEl: m,
|
|
604
|
+
name: "filter",
|
|
605
|
+
targetEl: g,
|
|
606
|
+
toEl: n,
|
|
607
|
+
fromEl: n
|
|
608
|
+
}), de("filter", t, { evt: e }), i && e.preventDefault();
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
} else if (I && (I = I.split(",").some(function(C) {
|
|
612
|
+
if (C = ne(m, C.trim(), n, !1), C)
|
|
613
|
+
return ie({
|
|
614
|
+
sortable: t,
|
|
615
|
+
rootEl: C,
|
|
616
|
+
name: "filter",
|
|
617
|
+
targetEl: g,
|
|
618
|
+
fromEl: n,
|
|
619
|
+
toEl: n
|
|
620
|
+
}), de("filter", t, { evt: e }), !0;
|
|
621
|
+
}), I)) {
|
|
622
|
+
i && e.preventDefault();
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
a.handle && !ne(m, a.handle, n, !1) || this._prepareDragStart(e, h, g);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
},
|
|
629
|
+
_prepareDragStart: function(e, t, n) {
|
|
630
|
+
var a = this, i = a.el, s = a.options, h = i.ownerDocument, g;
|
|
631
|
+
if (n && !y && n.parentNode === i) {
|
|
632
|
+
var m = j(n);
|
|
633
|
+
if (W = i, y = n, K = y.parentNode, Ye = y.nextSibling, pe = n, Xe = s.group, A.dragged = y, _ = {
|
|
634
|
+
target: y,
|
|
635
|
+
clientX: (t || e).clientX,
|
|
636
|
+
clientY: (t || e).clientY
|
|
637
|
+
}, tt = _.clientX - m.left, ct = _.clientY - m.top, this._lastX = (t || e).clientX, this._lastY = (t || e).clientY, y.style["will-change"] = "all", g = function() {
|
|
638
|
+
if (de("delayEnded", a, { evt: e }), A.eventCanceled) {
|
|
639
|
+
a._onDrop();
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
a._disableDelayedDragEvents(), !vt && a.nativeDraggable && (y.draggable = !0), a._triggerDragStart(e, t), ie({
|
|
643
|
+
sortable: a,
|
|
644
|
+
name: "choose",
|
|
645
|
+
originalEvent: e
|
|
646
|
+
}), U(y, s.chosenClass, !0);
|
|
647
|
+
}, s.ignore.split(",").forEach(function(I) {
|
|
648
|
+
Vt(y, I.trim(), En);
|
|
649
|
+
}), x(h, "dragover", ft), x(h, "mousemove", ft), x(h, "touchmove", ft), s.supportPointer ? (x(h, "pointerup", a._onDrop), !this.nativeDraggable && x(h, "pointercancel", a._onDrop)) : (x(h, "mouseup", a._onDrop), x(h, "touchend", a._onDrop), x(h, "touchcancel", a._onDrop)), vt && this.nativeDraggable && (this.options.touchStartThreshold = 4, y.draggable = !0), de("delayStart", this, { evt: e }), s.delay && (!s.delayOnTouchOnly || t) && (!this.nativeDraggable || !(Se || z))) {
|
|
650
|
+
if (A.eventCanceled) {
|
|
651
|
+
this._onDrop();
|
|
652
|
+
return;
|
|
653
|
+
}
|
|
654
|
+
s.supportPointer ? (x(h, "pointerup", a._disableDelayedDrag), x(h, "pointercancel", a._disableDelayedDrag)) : (x(h, "mouseup", a._disableDelayedDrag), x(h, "touchend", a._disableDelayedDrag), x(h, "touchcancel", a._disableDelayedDrag)), x(h, "mousemove", a._delayedDragTouchMoveHandler), x(h, "touchmove", a._delayedDragTouchMoveHandler), s.supportPointer && x(h, "pointermove", a._delayedDragTouchMoveHandler), a._dragStartTimer = setTimeout(g, s.delay);
|
|
655
|
+
} else g();
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
_delayedDragTouchMoveHandler: function(e) {
|
|
659
|
+
var t = e.touches ? e.touches[0] : e;
|
|
660
|
+
Math.max(Math.abs(t.clientX - this._lastX), Math.abs(t.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1)) && this._disableDelayedDrag();
|
|
661
|
+
},
|
|
662
|
+
_disableDelayedDrag: function() {
|
|
663
|
+
y && En(y), clearTimeout(this._dragStartTimer), this._disableDelayedDragEvents();
|
|
664
|
+
},
|
|
665
|
+
_disableDelayedDragEvents: function() {
|
|
666
|
+
var e = this.el.ownerDocument;
|
|
667
|
+
O(e, "mouseup", this._disableDelayedDrag), O(e, "touchend", this._disableDelayedDrag), O(e, "touchcancel", this._disableDelayedDrag), O(e, "pointerup", this._disableDelayedDrag), O(e, "pointercancel", this._disableDelayedDrag), O(e, "mousemove", this._delayedDragTouchMoveHandler), O(e, "touchmove", this._delayedDragTouchMoveHandler), O(e, "pointermove", this._delayedDragTouchMoveHandler);
|
|
668
|
+
},
|
|
669
|
+
_triggerDragStart: function(e, t) {
|
|
670
|
+
t = t || e.pointerType == "touch" && e, !this.nativeDraggable || t ? this.options.supportPointer ? x(document, "pointermove", this._onTouchMove) : t ? x(document, "touchmove", this._onTouchMove) : x(document, "mousemove", this._onTouchMove) : (x(y, "dragend", this), x(W, "dragstart", this._onDragStart));
|
|
671
|
+
try {
|
|
672
|
+
document.selection ? ln(function() {
|
|
673
|
+
document.selection.empty();
|
|
674
|
+
}) : window.getSelection().removeAllRanges();
|
|
675
|
+
} catch {
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
_dragStarted: function(e, t) {
|
|
679
|
+
if (Pe = !1, W && y) {
|
|
680
|
+
de("dragStarted", this, { evt: t }), this.nativeDraggable && x(document, "dragover", yr);
|
|
681
|
+
var n = this.options;
|
|
682
|
+
!e && U(y, n.dragClass, !1), U(y, n.ghostClass, !0), A.active = this, e && this._appendGhost(), ie({
|
|
683
|
+
sortable: this,
|
|
684
|
+
name: "start",
|
|
685
|
+
originalEvent: t
|
|
686
|
+
});
|
|
687
|
+
} else this._nulling();
|
|
688
|
+
},
|
|
689
|
+
_emulateDragOver: function() {
|
|
690
|
+
if (E) {
|
|
691
|
+
this._lastX = E.clientX, this._lastY = E.clientY, Wn();
|
|
692
|
+
for (var e = document.elementFromPoint(E.clientX, E.clientY), t = e; e && e.shadowRoot && (e = e.shadowRoot.elementFromPoint(E.clientX, E.clientY), e !== t); )
|
|
693
|
+
t = e;
|
|
694
|
+
if (y.parentNode[ae]._isOutsideThisEl(e), t) do {
|
|
695
|
+
if (t[ae]) {
|
|
696
|
+
var n = void 0;
|
|
697
|
+
if (n = t[ae]._onDragOver({
|
|
698
|
+
clientX: E.clientX,
|
|
699
|
+
clientY: E.clientY,
|
|
700
|
+
target: e,
|
|
701
|
+
rootEl: t
|
|
702
|
+
}), n && !this.options.dragoverBubble) break;
|
|
703
|
+
}
|
|
704
|
+
e = t;
|
|
705
|
+
} while (t = be(t));
|
|
706
|
+
Vn();
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
_onTouchMove: function(e) {
|
|
710
|
+
if (_) {
|
|
711
|
+
var t = this.options, n = t.fallbackTolerance, a = t.fallbackOffset, i = e.touches ? e.touches[0] : e, s = k && ke(k, !0), h = k && s && s.a, g = k && s && s.d, m = an && he && mt(he), I = (i.clientX - _.clientX + a.x) / (h || 1) + (m ? m[0] - Cn[0] : 0) / (h || 1), C = (i.clientY - _.clientY + a.y) / (g || 1) + (m ? m[1] - Cn[1] : 0) / (g || 1);
|
|
712
|
+
if (!A.active && !Pe) {
|
|
713
|
+
if (n && Math.max(Math.abs(i.clientX - this._lastX), Math.abs(i.clientY - this._lastY)) < n) return;
|
|
714
|
+
this._onDragStart(e, !0);
|
|
715
|
+
}
|
|
716
|
+
if (k) {
|
|
717
|
+
s ? (s.e += I - (N || 0), s.f += C - (_e || 0)) : s = {
|
|
718
|
+
a: 1,
|
|
719
|
+
b: 0,
|
|
720
|
+
c: 0,
|
|
721
|
+
d: 1,
|
|
722
|
+
e: I,
|
|
723
|
+
f: C
|
|
724
|
+
};
|
|
725
|
+
var T = "matrix(".concat(s.a, ",").concat(s.b, ",").concat(s.c, ",").concat(s.d, ",").concat(s.e, ",").concat(s.f, ")");
|
|
726
|
+
S(k, "webkitTransform", T), S(k, "mozTransform", T), S(k, "msTransform", T), S(k, "transform", T), N = I, _e = C, E = i;
|
|
727
|
+
}
|
|
728
|
+
e.cancelable && e.preventDefault();
|
|
729
|
+
}
|
|
730
|
+
},
|
|
731
|
+
_appendGhost: function() {
|
|
732
|
+
if (!k) {
|
|
733
|
+
var e = this.options.fallbackOnBody ? document.body : W, t = j(y, !0, an, !0, e), n = this.options;
|
|
734
|
+
if (an) {
|
|
735
|
+
for (he = e; S(he, "position") === "static" && S(he, "transform") === "none" && he !== document; ) he = he.parentNode;
|
|
736
|
+
he !== document.body && he !== document.documentElement ? (he === document && (he = Te()), t.top += he.scrollTop, t.left += he.scrollLeft) : he = Te(), Cn = mt(he);
|
|
737
|
+
}
|
|
738
|
+
k = y.cloneNode(!0), U(k, n.ghostClass, !1), U(k, n.fallbackClass, !0), U(k, n.dragClass, !0), S(k, "transition", ""), S(k, "transform", ""), S(k, "box-sizing", "border-box"), S(k, "margin", 0), S(k, "top", t.top), S(k, "left", t.left), S(k, "width", t.width), S(k, "height", t.height), S(k, "opacity", "0.8"), S(k, "position", an ? "absolute" : "fixed"), S(k, "zIndex", "100000"), S(k, "pointerEvents", "none"), A.ghost = k, e.appendChild(k), S(k, "transform-origin", tt / parseInt(k.style.width) * 100 + "% " + ct / parseInt(k.style.height) * 100 + "%");
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
_onDragStart: function(e, t) {
|
|
742
|
+
var n = this, a = e.dataTransfer, i = n.options;
|
|
743
|
+
if (de("dragStart", this, { evt: e }), A.eventCanceled) {
|
|
744
|
+
this._onDrop();
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
de("setupClone", this), A.eventCanceled || (J = lt(y), J.removeAttribute("id"), J.draggable = !1, J.style["will-change"] = "", this._hideClone(), U(J, this.options.chosenClass, !1), A.clone = J), n.cloneId = ln(function() {
|
|
748
|
+
de("clone", n), !A.eventCanceled && (n.options.removeCloneOnHide || W.insertBefore(J, y), n._hideClone(), ie({
|
|
749
|
+
sortable: n,
|
|
750
|
+
name: "clone"
|
|
751
|
+
}));
|
|
752
|
+
}), !t && U(y, i.dragClass, !0), t ? (ut = !0, n._loopId = setInterval(n._emulateDragOver, 50)) : (O(document, "mouseup", n._onDrop), O(document, "touchend", n._onDrop), O(document, "touchcancel", n._onDrop), a && (a.effectAllowed = "move", i.setData && i.setData.call(n, a, y)), x(document, "drop", n), S(y, "transform", "translateZ(0)")), Pe = !0, n._dragStartId = ln(n._dragStarted.bind(n, t, e)), x(document, "selectstart", n), dt = !0, window.getSelection().removeAllRanges(), $ && S(document.body, "user-select", "none");
|
|
753
|
+
},
|
|
754
|
+
_onDragOver: function(e) {
|
|
755
|
+
var t = this.el, n = e.target, a, i, s, h = this.options, g = h.group, m = A.active, I = Xe === g, C = h.sort, T = ce || m, L, P = this, q = !1;
|
|
756
|
+
if (Sn) return;
|
|
757
|
+
function ve(Kt, kr) {
|
|
758
|
+
de(Kt, P, o({
|
|
759
|
+
evt: e,
|
|
760
|
+
isOwner: I,
|
|
761
|
+
axis: L ? "vertical" : "horizontal",
|
|
762
|
+
revert: s,
|
|
763
|
+
dragRect: a,
|
|
764
|
+
targetRect: i,
|
|
765
|
+
canSort: C,
|
|
766
|
+
fromSortable: T,
|
|
767
|
+
target: n,
|
|
768
|
+
completed: R,
|
|
769
|
+
onMove: function($n, Mr) {
|
|
770
|
+
return on(W, t, y, a, $n, j($n), e, Mr);
|
|
771
|
+
},
|
|
772
|
+
changed: Q
|
|
773
|
+
}, kr));
|
|
774
|
+
}
|
|
775
|
+
function xe() {
|
|
776
|
+
ve("dragOverAnimationCapture"), P.captureAnimationState(), P !== T && T.captureAnimationState();
|
|
777
|
+
}
|
|
778
|
+
function R(Kt) {
|
|
779
|
+
return ve("dragOverCompleted", { insertion: Kt }), Kt && (I ? m._hideClone() : m._showClone(P), P !== T && (U(y, ce ? ce.options.ghostClass : m.options.ghostClass, !1), U(y, h.ghostClass, !0)), ce !== P && P !== A.active ? ce = P : P === A.active && ce && (ce = null), T === P && (P._ignoreWhileAnimating = n), P.animateAll(function() {
|
|
780
|
+
ve("dragOverAnimationComplete"), P._ignoreWhileAnimating = null;
|
|
781
|
+
}), P !== T && (T.animateAll(), T._ignoreWhileAnimating = null)), (n === y && !y.animated || n === t && !n.animated) && (_t = null), !h.dragoverBubble && !e.rootEl && n !== document && (y.parentNode[ae]._isOutsideThisEl(e.target), !Kt && ft(e)), !h.dragoverBubble && e.stopPropagation && e.stopPropagation(), q = !0;
|
|
782
|
+
}
|
|
783
|
+
function Q() {
|
|
784
|
+
ge = ee(y), Ge = ee(y, h.draggable), ie({
|
|
785
|
+
sortable: P,
|
|
786
|
+
name: "change",
|
|
787
|
+
toEl: t,
|
|
788
|
+
newIndex: ge,
|
|
789
|
+
newDraggableIndex: Ge,
|
|
790
|
+
originalEvent: e
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
if (e.preventDefault !== void 0 && e.cancelable && e.preventDefault(), n = ne(n, h.draggable, t, !0), ve("dragOver"), A.eventCanceled) return q;
|
|
794
|
+
if (y.contains(e.target) || n.animated && n.animatingX && n.animatingY || P._ignoreWhileAnimating === n) return R(!1);
|
|
795
|
+
if (ut = !1, m && !h.disabled && (I ? C || (s = K !== W) : ce === this || (this.lastPutMode = Xe.checkPull(this, m, y, e)) && g.checkPut(this, m, y, e))) {
|
|
796
|
+
if (L = this._getDirection(e, n) === "vertical", a = j(y), ve("dragOverValid"), A.eventCanceled) return q;
|
|
797
|
+
if (s)
|
|
798
|
+
return K = W, xe(), this._hideClone(), ve("revert"), A.eventCanceled || (Ye ? W.insertBefore(y, Ye) : W.appendChild(y)), R(!0);
|
|
799
|
+
var fe = Tt(t, h.draggable);
|
|
800
|
+
if (!fe || Cr(e, L, this) && !fe.animated) {
|
|
801
|
+
if (fe === y) return R(!1);
|
|
802
|
+
if (fe && t === e.target && (n = fe), n && (i = j(n)), on(W, t, y, a, n, i, e, !!n) !== !1)
|
|
803
|
+
return xe(), fe && fe.nextSibling ? t.insertBefore(y, fe.nextSibling) : t.appendChild(y), K = t, Q(), R(!0);
|
|
804
|
+
} else if (fe && _r(e, L, this)) {
|
|
805
|
+
var We = Je(t, 0, h, !0);
|
|
806
|
+
if (We === y) return R(!1);
|
|
807
|
+
if (n = We, i = j(n), on(W, t, y, a, n, i, e, !1) !== !1)
|
|
808
|
+
return xe(), t.insertBefore(y, We), K = t, Q(), R(!0);
|
|
809
|
+
} else if (n.parentNode === t) {
|
|
810
|
+
i = j(n);
|
|
811
|
+
var ze = 0, ht, qt = y.parentNode !== t, Ue = !vr(y.animated && y.toRect || a, n.animated && n.toRect || i, L), Gt = L ? "top" : "left", nt = Qt(n, "top", "top") || Qt(y, "top", "top"), zt = nt ? nt.scrollTop : void 0;
|
|
812
|
+
_t !== n && (ht = i[Gt], Pt = !1, en = !Ue && h.invertSwap || qt), ze = Sr(e, n, i, L, Ue ? 1 : h.swapThreshold, h.invertedSwapThreshold == null ? h.swapThreshold : h.invertedSwapThreshold, en, _t === n);
|
|
813
|
+
var Ve;
|
|
814
|
+
if (ze !== 0) {
|
|
815
|
+
var pt = ee(y);
|
|
816
|
+
do
|
|
817
|
+
pt -= ze, Ve = K.children[pt];
|
|
818
|
+
while (Ve && (S(Ve, "display") === "none" || Ve === k));
|
|
819
|
+
}
|
|
820
|
+
if (ze === 0 || Ve === n) return R(!1);
|
|
821
|
+
_t = n, Mt = ze;
|
|
822
|
+
var jt = n.nextElementSibling, rt = !1;
|
|
823
|
+
rt = ze === 1;
|
|
824
|
+
var fn = on(W, t, y, a, n, i, e, rt);
|
|
825
|
+
if (fn !== !1)
|
|
826
|
+
return (fn === 1 || fn === -1) && (rt = fn === 1), Sn = !0, setTimeout(wr, 30), xe(), rt && !jt ? t.appendChild(y) : n.parentNode.insertBefore(y, rt ? jt : n), nt && Jt(nt, 0, zt - nt.scrollTop), K = y.parentNode, ht !== void 0 && !en && (tn = Math.abs(ht - j(n)[Gt])), Q(), R(!0);
|
|
827
|
+
}
|
|
828
|
+
if (t.contains(y)) return R(!1);
|
|
829
|
+
}
|
|
830
|
+
return !1;
|
|
831
|
+
},
|
|
832
|
+
_ignoreWhileAnimating: null,
|
|
833
|
+
_offMoveEvents: function() {
|
|
834
|
+
O(document, "mousemove", this._onTouchMove), O(document, "touchmove", this._onTouchMove), O(document, "pointermove", this._onTouchMove), O(document, "dragover", ft), O(document, "mousemove", ft), O(document, "touchmove", ft);
|
|
835
|
+
},
|
|
836
|
+
_offUpEvents: function() {
|
|
837
|
+
var e = this.el.ownerDocument;
|
|
838
|
+
O(e, "mouseup", this._onDrop), O(e, "touchend", this._onDrop), O(e, "pointerup", this._onDrop), O(e, "pointercancel", this._onDrop), O(e, "touchcancel", this._onDrop), O(document, "selectstart", this);
|
|
839
|
+
},
|
|
840
|
+
_onDrop: function(e) {
|
|
841
|
+
var t = this.el, n = this.options;
|
|
842
|
+
if (ge = ee(y), Ge = ee(y, n.draggable), de("drop", this, { evt: e }), K = y && y.parentNode, ge = ee(y), Ge = ee(y, n.draggable), A.eventCanceled) {
|
|
843
|
+
this._nulling();
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
Pe = !1, en = !1, Pt = !1, clearInterval(this._loopId), clearTimeout(this._dragStartTimer), In(this.cloneId), In(this._dragStartId), this.nativeDraggable && (O(document, "drop", this), O(t, "dragstart", this._onDragStart)), this._offMoveEvents(), this._offUpEvents(), $ && S(document.body, "user-select", ""), S(y, "transform", ""), e && (dt && (e.cancelable && e.preventDefault(), !n.dropBubble && e.stopPropagation()), k && k.parentNode && k.parentNode.removeChild(k), (W === K || ce && ce.lastPutMode !== "clone") && J && J.parentNode && J.parentNode.removeChild(J), y && (this.nativeDraggable && O(y, "dragend", this), En(y), y.style["will-change"] = "", dt && !Pe && U(y, ce ? ce.options.ghostClass : this.options.ghostClass, !1), U(y, this.options.chosenClass, !1), ie({
|
|
847
|
+
sortable: this,
|
|
848
|
+
name: "unchoose",
|
|
849
|
+
toEl: K,
|
|
850
|
+
newIndex: null,
|
|
851
|
+
newDraggableIndex: null,
|
|
852
|
+
originalEvent: e
|
|
853
|
+
}), W !== K ? (ge >= 0 && (ie({
|
|
854
|
+
rootEl: K,
|
|
855
|
+
name: "add",
|
|
856
|
+
toEl: K,
|
|
857
|
+
fromEl: W,
|
|
858
|
+
originalEvent: e
|
|
859
|
+
}), ie({
|
|
860
|
+
sortable: this,
|
|
861
|
+
name: "remove",
|
|
862
|
+
toEl: K,
|
|
863
|
+
originalEvent: e
|
|
864
|
+
}), ie({
|
|
865
|
+
rootEl: K,
|
|
866
|
+
name: "sort",
|
|
867
|
+
toEl: K,
|
|
868
|
+
fromEl: W,
|
|
869
|
+
originalEvent: e
|
|
870
|
+
}), ie({
|
|
871
|
+
sortable: this,
|
|
872
|
+
name: "sort",
|
|
873
|
+
toEl: K,
|
|
874
|
+
originalEvent: e
|
|
875
|
+
})), ce && ce.save()) : ge !== et && ge >= 0 && (ie({
|
|
876
|
+
sortable: this,
|
|
877
|
+
name: "update",
|
|
878
|
+
toEl: K,
|
|
879
|
+
originalEvent: e
|
|
880
|
+
}), ie({
|
|
881
|
+
sortable: this,
|
|
882
|
+
name: "sort",
|
|
883
|
+
toEl: K,
|
|
884
|
+
originalEvent: e
|
|
885
|
+
})), A.active && ((ge == null || ge === -1) && (ge = et, Ge = st), ie({
|
|
886
|
+
sortable: this,
|
|
887
|
+
name: "end",
|
|
888
|
+
toEl: K,
|
|
889
|
+
originalEvent: e
|
|
890
|
+
}), this.save()))), this._nulling();
|
|
891
|
+
},
|
|
892
|
+
_nulling: function() {
|
|
893
|
+
de("nulling", this), W = y = K = k = Ye = J = pe = qe = _ = E = dt = ge = Ge = et = st = _t = Mt = ce = Xe = A.dragged = A.ghost = A.clone = A.active = null, nn.forEach(function(e) {
|
|
894
|
+
e.checked = !0;
|
|
895
|
+
}), nn.length = N = _e = 0;
|
|
896
|
+
},
|
|
897
|
+
handleEvent: function(e) {
|
|
898
|
+
switch (e.type) {
|
|
899
|
+
case "drop":
|
|
900
|
+
case "dragend":
|
|
901
|
+
this._onDrop(e);
|
|
902
|
+
break;
|
|
903
|
+
case "dragenter":
|
|
904
|
+
case "dragover":
|
|
905
|
+
y && (this._onDragOver(e), br(e));
|
|
906
|
+
break;
|
|
907
|
+
case "selectstart":
|
|
908
|
+
e.preventDefault();
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
},
|
|
912
|
+
toArray: function() {
|
|
913
|
+
for (var e = [], t, n = this.el.children, a = 0, i = n.length, s = this.options; a < i; a++)
|
|
914
|
+
t = n[a], ne(t, s.draggable, this.el, !1) && e.push(t.getAttribute(s.dataIdAttr) || Ir(t));
|
|
915
|
+
return e;
|
|
916
|
+
},
|
|
917
|
+
sort: function(e, t) {
|
|
918
|
+
var n = {}, a = this.el;
|
|
919
|
+
this.toArray().forEach(function(i, s) {
|
|
920
|
+
var h = a.children[s];
|
|
921
|
+
ne(h, this.options.draggable, a, !1) && (n[i] = h);
|
|
922
|
+
}, this), t && this.captureAnimationState(), e.forEach(function(i) {
|
|
923
|
+
n[i] && (a.removeChild(n[i]), a.appendChild(n[i]));
|
|
924
|
+
}), t && this.animateAll();
|
|
925
|
+
},
|
|
926
|
+
save: function() {
|
|
927
|
+
var e = this.options.store;
|
|
928
|
+
e && e.set && e.set(this);
|
|
929
|
+
},
|
|
930
|
+
closest: function(e, t) {
|
|
931
|
+
return ne(e, t || this.options.draggable, this.el, !1);
|
|
932
|
+
},
|
|
933
|
+
option: function(e, t) {
|
|
934
|
+
var n = this.options;
|
|
935
|
+
if (t === void 0) return n[e];
|
|
936
|
+
var a = Fe.modifyOption(this, e, t);
|
|
937
|
+
typeof a < "u" ? n[e] = a : n[e] = t, e === "group" && Xn(n);
|
|
938
|
+
},
|
|
939
|
+
destroy: function() {
|
|
940
|
+
de("destroy", this);
|
|
941
|
+
var e = this.el;
|
|
942
|
+
e[ae] = null, O(e, "mousedown", this._onTapStart), O(e, "touchstart", this._onTapStart), O(e, "pointerdown", this._onTapStart), this.nativeDraggable && (O(e, "dragover", this), O(e, "dragenter", this)), Array.prototype.forEach.call(e.querySelectorAll("[draggable]"), function(t) {
|
|
943
|
+
t.removeAttribute("draggable");
|
|
944
|
+
}), this._onDrop(), this._disableDelayedDragEvents(), p.splice(p.indexOf(this.el), 1), this.el = e = null;
|
|
945
|
+
},
|
|
946
|
+
_hideClone: function() {
|
|
947
|
+
if (!qe) {
|
|
948
|
+
if (de("hideClone", this), A.eventCanceled) return;
|
|
949
|
+
S(J, "display", "none"), this.options.removeCloneOnHide && J.parentNode && J.parentNode.removeChild(J), qe = !0;
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
_showClone: function(e) {
|
|
953
|
+
if (e.lastPutMode !== "clone") {
|
|
954
|
+
this._hideClone();
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
if (qe) {
|
|
958
|
+
if (de("showClone", this), A.eventCanceled) return;
|
|
959
|
+
y.parentNode == W && !this.options.group.revertClone ? W.insertBefore(J, y) : Ye ? W.insertBefore(J, Ye) : W.appendChild(J), this.options.group.revertClone && this.animate(y, J), S(J, "display", ""), qe = !1;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
function br(r) {
|
|
964
|
+
r.dataTransfer && (r.dataTransfer.dropEffect = "move"), r.cancelable && r.preventDefault();
|
|
965
|
+
}
|
|
966
|
+
function on(r, e, t, n, a, i, s, h) {
|
|
967
|
+
var g, m = r[ae], I = m.options.onMove, C;
|
|
968
|
+
return window.CustomEvent && !z && !Se ? g = new CustomEvent("move", {
|
|
969
|
+
bubbles: !0,
|
|
970
|
+
cancelable: !0
|
|
971
|
+
}) : (g = document.createEvent("Event"), g.initEvent("move", !0, !0)), g.to = e, g.from = r, g.dragged = t, g.draggedRect = n, g.related = a || e, g.relatedRect = i || j(e), g.willInsertAfter = h, g.originalEvent = s, r.dispatchEvent(g), I && (C = I.call(m, g, s)), C;
|
|
972
|
+
}
|
|
973
|
+
function En(r) {
|
|
974
|
+
r.draggable = !1;
|
|
975
|
+
}
|
|
976
|
+
function wr() {
|
|
977
|
+
Sn = !1;
|
|
978
|
+
}
|
|
979
|
+
function _r(r, e, t) {
|
|
980
|
+
var n = j(Je(t.el, 0, t.options, !0)), a = xt(t.el, t.options, k), i = 10;
|
|
981
|
+
return e ? r.clientX < a.left - i || r.clientY < n.top && r.clientX < n.right : r.clientY < a.top - i || r.clientY < n.bottom && r.clientX < n.left;
|
|
982
|
+
}
|
|
983
|
+
function Cr(r, e, t) {
|
|
984
|
+
var n = j(Tt(t.el, t.options.draggable)), a = xt(t.el, t.options, k), i = 10;
|
|
985
|
+
return e ? r.clientX > a.right + i || r.clientY > n.bottom && r.clientX > n.left : r.clientY > a.bottom + i || r.clientX > n.right && r.clientY > n.top;
|
|
986
|
+
}
|
|
987
|
+
function Sr(r, e, t, n, a, i, s, h) {
|
|
988
|
+
var g = n ? r.clientY : r.clientX, m = n ? t.height : t.width, I = n ? t.top : t.left, C = n ? t.bottom : t.right, T = !1;
|
|
989
|
+
if (!s) {
|
|
990
|
+
if (h && tn < m * a) {
|
|
991
|
+
if (!Pt && (Mt === 1 ? g > I + m * i / 2 : g < C - m * i / 2) && (Pt = !0), Pt)
|
|
992
|
+
T = !0;
|
|
993
|
+
else if (Mt === 1 ? g < I + tn : g > C - tn) return -Mt;
|
|
994
|
+
} else if (g > I + m * (1 - a) / 2 && g < C - m * (1 - a) / 2) return Er(e);
|
|
995
|
+
}
|
|
996
|
+
return T = T || s, T && (g < I + m * i / 2 || g > C - m * i / 2) ? g > I + m / 2 ? 1 : -1 : 0;
|
|
997
|
+
}
|
|
998
|
+
function Er(r) {
|
|
999
|
+
return ee(y) < ee(r) ? 1 : -1;
|
|
1000
|
+
}
|
|
1001
|
+
function Ir(r) {
|
|
1002
|
+
for (var e = r.tagName + r.className + r.src + r.href + r.textContent, t = e.length, n = 0; t--; ) n += e.charCodeAt(t);
|
|
1003
|
+
return n.toString(36);
|
|
1004
|
+
}
|
|
1005
|
+
function Ur(r) {
|
|
1006
|
+
nn.length = 0;
|
|
1007
|
+
for (var e = r.getElementsByTagName("input"), t = e.length; t--; ) {
|
|
1008
|
+
var n = e[t];
|
|
1009
|
+
n.checked && nn.push(n);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
function ln(r) {
|
|
1013
|
+
return setTimeout(r, 0);
|
|
1014
|
+
}
|
|
1015
|
+
function In(r) {
|
|
1016
|
+
return clearTimeout(r);
|
|
1017
|
+
}
|
|
1018
|
+
rn && x(document, "touchmove", function(r) {
|
|
1019
|
+
(A.active || Pe) && r.cancelable && r.preventDefault();
|
|
1020
|
+
}), A.utils = {
|
|
1021
|
+
on: x,
|
|
1022
|
+
off: O,
|
|
1023
|
+
css: S,
|
|
1024
|
+
find: Vt,
|
|
1025
|
+
is: function(e, t) {
|
|
1026
|
+
return !!ne(e, t, e, !1);
|
|
1027
|
+
},
|
|
1028
|
+
extend: yt,
|
|
1029
|
+
throttle: it,
|
|
1030
|
+
closest: ne,
|
|
1031
|
+
toggleClass: U,
|
|
1032
|
+
clone: lt,
|
|
1033
|
+
index: ee,
|
|
1034
|
+
nextTick: ln,
|
|
1035
|
+
cancelNextTick: In,
|
|
1036
|
+
detectDirection: Yn,
|
|
1037
|
+
getChild: Je,
|
|
1038
|
+
expando: ae
|
|
1039
|
+
}, A.get = function(r) {
|
|
1040
|
+
return r[ae];
|
|
1041
|
+
}, A.mount = function() {
|
|
1042
|
+
for (var r = arguments.length, e = new Array(r), t = 0; t < r; t++) e[t] = arguments[t];
|
|
1043
|
+
e[0].constructor === Array && (e = e[0]), e.forEach(function(n) {
|
|
1044
|
+
if (!n.prototype || !n.prototype.constructor) throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(n));
|
|
1045
|
+
n.utils && (A.utils = o(o({}, A.utils), n.utils)), Fe.mount(n);
|
|
1046
|
+
});
|
|
1047
|
+
}, A.create = function(r, e) {
|
|
1048
|
+
return new A(r, e);
|
|
1049
|
+
}, A.version = De;
|
|
1050
|
+
var le = [], Rt, Un, Dn = !1, Tn, On, sn, Bt;
|
|
1051
|
+
function Dr() {
|
|
1052
|
+
function r() {
|
|
1053
|
+
this.defaults = {
|
|
1054
|
+
scroll: !0,
|
|
1055
|
+
forceAutoScrollFallback: !1,
|
|
1056
|
+
scrollSensitivity: 30,
|
|
1057
|
+
scrollSpeed: 10,
|
|
1058
|
+
bubbleScroll: !0
|
|
1059
|
+
};
|
|
1060
|
+
for (var e in this) e.charAt(0) === "_" && typeof this[e] == "function" && (this[e] = this[e].bind(this));
|
|
1061
|
+
}
|
|
1062
|
+
return r.prototype = {
|
|
1063
|
+
dragStarted: function(t) {
|
|
1064
|
+
var n = t.originalEvent;
|
|
1065
|
+
this.sortable.nativeDraggable ? x(document, "dragover", this._handleAutoScroll) : this.options.supportPointer ? x(document, "pointermove", this._handleFallbackAutoScroll) : n.touches ? x(document, "touchmove", this._handleFallbackAutoScroll) : x(document, "mousemove", this._handleFallbackAutoScroll);
|
|
1066
|
+
},
|
|
1067
|
+
dragOverCompleted: function(t) {
|
|
1068
|
+
var n = t.originalEvent;
|
|
1069
|
+
!this.options.dragOverBubble && !n.rootEl && this._handleAutoScroll(n);
|
|
1070
|
+
},
|
|
1071
|
+
drop: function() {
|
|
1072
|
+
this.sortable.nativeDraggable ? O(document, "dragover", this._handleAutoScroll) : (O(document, "pointermove", this._handleFallbackAutoScroll), O(document, "touchmove", this._handleFallbackAutoScroll), O(document, "mousemove", this._handleFallbackAutoScroll)), Qn(), un(), _n();
|
|
1073
|
+
},
|
|
1074
|
+
nulling: function() {
|
|
1075
|
+
sn = Un = Rt = Dn = Bt = Tn = On = null, le.length = 0;
|
|
1076
|
+
},
|
|
1077
|
+
_handleFallbackAutoScroll: function(t) {
|
|
1078
|
+
this._handleAutoScroll(t, !0);
|
|
1079
|
+
},
|
|
1080
|
+
_handleAutoScroll: function(t, n) {
|
|
1081
|
+
var a = this, i = (t.touches ? t.touches[0] : t).clientX, s = (t.touches ? t.touches[0] : t).clientY, h = document.elementFromPoint(i, s);
|
|
1082
|
+
if (sn = t, n || this.options.forceAutoScrollFallback || Se || z || $) {
|
|
1083
|
+
xn(t, this.options, h, n);
|
|
1084
|
+
var g = Ee(h, !0);
|
|
1085
|
+
Dn && (!Bt || i !== Tn || s !== On) && (Bt && Qn(), Bt = setInterval(function() {
|
|
1086
|
+
var m = Ee(document.elementFromPoint(i, s), !0);
|
|
1087
|
+
m !== g && (g = m, un()), xn(t, a.options, m, n);
|
|
1088
|
+
}, 10), Tn = i, On = s);
|
|
1089
|
+
} else {
|
|
1090
|
+
if (!this.options.bubbleScroll || Ee(h, !0) === Te()) {
|
|
1091
|
+
un();
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
1094
|
+
xn(t, this.options, Ee(h, !1), !1);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}, f(r, {
|
|
1098
|
+
pluginName: "scroll",
|
|
1099
|
+
initializeByDefault: !0
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
function un() {
|
|
1103
|
+
le.forEach(function(r) {
|
|
1104
|
+
clearInterval(r.pid);
|
|
1105
|
+
}), le = [];
|
|
1106
|
+
}
|
|
1107
|
+
function Qn() {
|
|
1108
|
+
clearInterval(Bt);
|
|
1109
|
+
}
|
|
1110
|
+
var xn = it(function(r, e, t, n) {
|
|
1111
|
+
if (e.scroll) {
|
|
1112
|
+
var a = (r.touches ? r.touches[0] : r).clientX, i = (r.touches ? r.touches[0] : r).clientY, s = e.scrollSensitivity, h = e.scrollSpeed, g = Te(), m = !1, I;
|
|
1113
|
+
Un !== t && (Un = t, un(), Rt = e.scroll, I = e.scrollFn, Rt === !0 && (Rt = Ee(t, !0)));
|
|
1114
|
+
var C = 0, T = Rt;
|
|
1115
|
+
do {
|
|
1116
|
+
var L = T, P = j(L), q = P.top, ve = P.bottom, xe = P.left, R = P.right, Q = P.width, fe = P.height, We = void 0, ze = void 0, ht = L.scrollWidth, qt = L.scrollHeight, Ue = S(L), Gt = L.scrollLeft, nt = L.scrollTop;
|
|
1117
|
+
L === g ? (We = Q < ht && (Ue.overflowX === "auto" || Ue.overflowX === "scroll" || Ue.overflowX === "visible"), ze = fe < qt && (Ue.overflowY === "auto" || Ue.overflowY === "scroll" || Ue.overflowY === "visible")) : (We = Q < ht && (Ue.overflowX === "auto" || Ue.overflowX === "scroll"), ze = fe < qt && (Ue.overflowY === "auto" || Ue.overflowY === "scroll"));
|
|
1118
|
+
var zt = We && (Math.abs(R - a) <= s && Gt + Q < ht) - (Math.abs(xe - a) <= s && !!Gt), Ve = ze && (Math.abs(ve - i) <= s && nt + fe < qt) - (Math.abs(q - i) <= s && !!nt);
|
|
1119
|
+
if (!le[C])
|
|
1120
|
+
for (var pt = 0; pt <= C; pt++) le[pt] || (le[pt] = {});
|
|
1121
|
+
(le[C].vx != zt || le[C].vy != Ve || le[C].el !== L) && (le[C].el = L, le[C].vx = zt, le[C].vy = Ve, clearInterval(le[C].pid), (zt != 0 || Ve != 0) && (m = !0, le[C].pid = setInterval((function() {
|
|
1122
|
+
n && this.layer === 0 && A.active._onTouchMove(sn);
|
|
1123
|
+
var jt = le[this.layer].vy ? le[this.layer].vy * h : 0, rt = le[this.layer].vx ? le[this.layer].vx * h : 0;
|
|
1124
|
+
typeof I == "function" && I.call(A.dragged.parentNode[ae], rt, jt, r, sn, le[this.layer].el) !== "continue" || Jt(le[this.layer].el, rt, jt);
|
|
1125
|
+
}).bind({ layer: C }), 24))), C++;
|
|
1126
|
+
} while (e.bubbleScroll && T !== g && (T = Ee(T, !1)));
|
|
1127
|
+
Dn = m;
|
|
1128
|
+
}
|
|
1129
|
+
}, 30), Zn = function(e) {
|
|
1130
|
+
var t = e.originalEvent, n = e.putSortable, a = e.dragEl, i = e.activeSortable, s = e.dispatchSortableEvent, h = e.hideGhostForTarget, g = e.unhideGhostForTarget;
|
|
1131
|
+
if (t) {
|
|
1132
|
+
var m = n || i;
|
|
1133
|
+
h();
|
|
1134
|
+
var I = t.changedTouches && t.changedTouches.length ? t.changedTouches[0] : t, C = document.elementFromPoint(I.clientX, I.clientY);
|
|
1135
|
+
g(), m && !m.el.contains(C) && (s("spill"), this.onSpill({
|
|
1136
|
+
dragEl: a,
|
|
1137
|
+
putSortable: n
|
|
1138
|
+
}));
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
function An() {
|
|
1142
|
+
}
|
|
1143
|
+
An.prototype = {
|
|
1144
|
+
startIndex: null,
|
|
1145
|
+
dragStart: function(e) {
|
|
1146
|
+
this.startIndex = e.oldDraggableIndex;
|
|
1147
|
+
},
|
|
1148
|
+
onSpill: function(e) {
|
|
1149
|
+
var t = e.dragEl, n = e.putSortable;
|
|
1150
|
+
this.sortable.captureAnimationState(), n && n.captureAnimationState();
|
|
1151
|
+
var a = Je(this.sortable.el, this.startIndex, this.options);
|
|
1152
|
+
a ? this.sortable.el.insertBefore(t, a) : this.sortable.el.appendChild(t), this.sortable.animateAll(), n && n.animateAll();
|
|
1153
|
+
},
|
|
1154
|
+
drop: Zn
|
|
1155
|
+
}, f(An, { pluginName: "revertOnSpill" });
|
|
1156
|
+
function kn() {
|
|
1157
|
+
}
|
|
1158
|
+
kn.prototype = {
|
|
1159
|
+
onSpill: function(e) {
|
|
1160
|
+
var t = e.dragEl, n = e.putSortable || this.sortable;
|
|
1161
|
+
n.captureAnimationState(), t.parentNode && t.parentNode.removeChild(t), n.animateAll();
|
|
1162
|
+
},
|
|
1163
|
+
drop: Zn
|
|
1164
|
+
}, f(kn, { pluginName: "removeOnSpill" });
|
|
1165
|
+
var Oe;
|
|
1166
|
+
function Tr() {
|
|
1167
|
+
function r() {
|
|
1168
|
+
this.defaults = { swapClass: "sortable-swap-highlight" };
|
|
1169
|
+
}
|
|
1170
|
+
return r.prototype = {
|
|
1171
|
+
dragStart: function(t) {
|
|
1172
|
+
Oe = t.dragEl;
|
|
1173
|
+
},
|
|
1174
|
+
dragOverValid: function(t) {
|
|
1175
|
+
var n = t.completed, a = t.target, i = t.onMove, s = t.activeSortable, h = t.changed, g = t.cancel;
|
|
1176
|
+
if (s.options.swap) {
|
|
1177
|
+
var m = this.sortable.el, I = this.options;
|
|
1178
|
+
if (a && a !== m) {
|
|
1179
|
+
var C = Oe;
|
|
1180
|
+
i(a) !== !1 ? (U(a, I.swapClass, !0), Oe = a) : Oe = null, C && C !== Oe && U(C, I.swapClass, !1);
|
|
1181
|
+
}
|
|
1182
|
+
h(), n(!0), g();
|
|
1183
|
+
}
|
|
1184
|
+
},
|
|
1185
|
+
drop: function(t) {
|
|
1186
|
+
var n = t.activeSortable, a = t.putSortable, i = t.dragEl, s = a || this.sortable, h = this.options;
|
|
1187
|
+
Oe && U(Oe, h.swapClass, !1), Oe && (h.swap || a && a.options.swap) && i !== Oe && (s.captureAnimationState(), s !== n && n.captureAnimationState(), Or(i, Oe), s.animateAll(), s !== n && n.animateAll());
|
|
1188
|
+
},
|
|
1189
|
+
nulling: function() {
|
|
1190
|
+
Oe = null;
|
|
1191
|
+
}
|
|
1192
|
+
}, f(r, {
|
|
1193
|
+
pluginName: "swap",
|
|
1194
|
+
eventProperties: function() {
|
|
1195
|
+
return { swapItem: Oe };
|
|
1196
|
+
}
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
function Or(r, e) {
|
|
1200
|
+
var t = r.parentNode, n = e.parentNode, a, i;
|
|
1201
|
+
!t || !n || t.isEqualNode(e) || n.isEqualNode(r) || (a = ee(r), i = ee(e), t.isEqualNode(n) && a < i && i++, t.insertBefore(e, t.children[a]), n.insertBefore(r, n.children[i]));
|
|
1202
|
+
}
|
|
1203
|
+
var M = [], Ie = [], Nt, Re, Lt = !1, Ce = !1, Ct = !1, V, Ft, cn;
|
|
1204
|
+
function xr() {
|
|
1205
|
+
function r(e) {
|
|
1206
|
+
for (var t in this) t.charAt(0) === "_" && typeof this[t] == "function" && (this[t] = this[t].bind(this));
|
|
1207
|
+
e.options.avoidImplicitDeselect || (e.options.supportPointer ? x(document, "pointerup", this._deselectMultiDrag) : (x(document, "mouseup", this._deselectMultiDrag), x(document, "touchend", this._deselectMultiDrag))), x(document, "keydown", this._checkKeyDown), x(document, "keyup", this._checkKeyUp), this.defaults = {
|
|
1208
|
+
selectedClass: "sortable-selected",
|
|
1209
|
+
multiDragKey: null,
|
|
1210
|
+
avoidImplicitDeselect: !1,
|
|
1211
|
+
setData: function(a, i) {
|
|
1212
|
+
var s = "";
|
|
1213
|
+
M.length && Re === e ? M.forEach(function(h, g) {
|
|
1214
|
+
s += (g ? ", " : "") + h.textContent;
|
|
1215
|
+
}) : s = i.textContent, a.setData("Text", s);
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
return r.prototype = {
|
|
1220
|
+
multiDragKeyDown: !1,
|
|
1221
|
+
isMultiDrag: !1,
|
|
1222
|
+
delayStartGlobal: function(t) {
|
|
1223
|
+
V = t.dragEl;
|
|
1224
|
+
},
|
|
1225
|
+
delayEnded: function() {
|
|
1226
|
+
this.isMultiDrag = ~M.indexOf(V);
|
|
1227
|
+
},
|
|
1228
|
+
setupClone: function(t) {
|
|
1229
|
+
var n = t.sortable, a = t.cancel;
|
|
1230
|
+
if (this.isMultiDrag) {
|
|
1231
|
+
for (var i = 0; i < M.length; i++)
|
|
1232
|
+
Ie.push(lt(M[i])), Ie[i].sortableIndex = M[i].sortableIndex, Ie[i].draggable = !1, Ie[i].style["will-change"] = "", U(Ie[i], this.options.selectedClass, !1), M[i] === V && U(Ie[i], this.options.chosenClass, !1);
|
|
1233
|
+
n._hideClone(), a();
|
|
1234
|
+
}
|
|
1235
|
+
},
|
|
1236
|
+
clone: function(t) {
|
|
1237
|
+
var n = t.sortable, a = t.rootEl, i = t.dispatchSortableEvent, s = t.cancel;
|
|
1238
|
+
this.isMultiDrag && (this.options.removeCloneOnHide || M.length && Re === n && (Jn(!0, a), i("clone"), s()));
|
|
1239
|
+
},
|
|
1240
|
+
showClone: function(t) {
|
|
1241
|
+
var n = t.cloneNowShown, a = t.rootEl, i = t.cancel;
|
|
1242
|
+
this.isMultiDrag && (Jn(!1, a), Ie.forEach(function(s) {
|
|
1243
|
+
S(s, "display", "");
|
|
1244
|
+
}), n(), cn = !1, i());
|
|
1245
|
+
},
|
|
1246
|
+
hideClone: function(t) {
|
|
1247
|
+
var n = this;
|
|
1248
|
+
t.sortable;
|
|
1249
|
+
var a = t.cloneNowHidden, i = t.cancel;
|
|
1250
|
+
this.isMultiDrag && (Ie.forEach(function(s) {
|
|
1251
|
+
S(s, "display", "none"), n.options.removeCloneOnHide && s.parentNode && s.parentNode.removeChild(s);
|
|
1252
|
+
}), a(), cn = !0, i());
|
|
1253
|
+
},
|
|
1254
|
+
dragStartGlobal: function(t) {
|
|
1255
|
+
t.sortable, !this.isMultiDrag && Re && Re.multiDrag._deselectMultiDrag(), M.forEach(function(n) {
|
|
1256
|
+
n.sortableIndex = ee(n);
|
|
1257
|
+
}), M = M.sort(function(n, a) {
|
|
1258
|
+
return n.sortableIndex - a.sortableIndex;
|
|
1259
|
+
}), Ct = !0;
|
|
1260
|
+
},
|
|
1261
|
+
dragStarted: function(t) {
|
|
1262
|
+
var n = this, a = t.sortable;
|
|
1263
|
+
if (this.isMultiDrag) {
|
|
1264
|
+
if (this.options.sort && (a.captureAnimationState(), this.options.animation)) {
|
|
1265
|
+
M.forEach(function(s) {
|
|
1266
|
+
s !== V && S(s, "position", "absolute");
|
|
1267
|
+
});
|
|
1268
|
+
var i = j(V, !1, !0, !0);
|
|
1269
|
+
M.forEach(function(s) {
|
|
1270
|
+
s !== V && Ot(s, i);
|
|
1271
|
+
}), Ce = !0, Lt = !0;
|
|
1272
|
+
}
|
|
1273
|
+
a.animateAll(function() {
|
|
1274
|
+
Ce = !1, Lt = !1, n.options.animation && M.forEach(function(s) {
|
|
1275
|
+
bt(s);
|
|
1276
|
+
}), n.options.sort && dn();
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
},
|
|
1280
|
+
dragOver: function(t) {
|
|
1281
|
+
var n = t.target, a = t.completed, i = t.cancel;
|
|
1282
|
+
Ce && ~M.indexOf(n) && (a(!1), i());
|
|
1283
|
+
},
|
|
1284
|
+
revert: function(t) {
|
|
1285
|
+
var n = t.fromSortable, a = t.rootEl, i = t.sortable, s = t.dragRect;
|
|
1286
|
+
M.length > 1 && (M.forEach(function(h) {
|
|
1287
|
+
i.addAnimationState({
|
|
1288
|
+
target: h,
|
|
1289
|
+
rect: Ce ? j(h) : s
|
|
1290
|
+
}), bt(h), h.fromRect = s, n.removeAnimationState(h);
|
|
1291
|
+
}), Ce = !1, Ar(!this.options.removeCloneOnHide, a));
|
|
1292
|
+
},
|
|
1293
|
+
dragOverCompleted: function(t) {
|
|
1294
|
+
var n = t.sortable, a = t.isOwner, i = t.insertion, s = t.activeSortable, h = t.parentEl, g = t.putSortable, m = this.options;
|
|
1295
|
+
if (i) {
|
|
1296
|
+
if (a && s._hideClone(), Lt = !1, m.animation && M.length > 1 && (Ce || !a && !s.options.sort && !g)) {
|
|
1297
|
+
var I = j(V, !1, !0, !0);
|
|
1298
|
+
M.forEach(function(T) {
|
|
1299
|
+
T !== V && (Ot(T, I), h.appendChild(T));
|
|
1300
|
+
}), Ce = !0;
|
|
1301
|
+
}
|
|
1302
|
+
if (!a)
|
|
1303
|
+
if (Ce || dn(), M.length > 1) {
|
|
1304
|
+
var C = cn;
|
|
1305
|
+
s._showClone(n), s.options.animation && !cn && C && Ie.forEach(function(T) {
|
|
1306
|
+
s.addAnimationState({
|
|
1307
|
+
target: T,
|
|
1308
|
+
rect: Ft
|
|
1309
|
+
}), T.fromRect = Ft, T.thisAnimationDuration = null;
|
|
1310
|
+
});
|
|
1311
|
+
} else s._showClone(n);
|
|
1312
|
+
}
|
|
1313
|
+
},
|
|
1314
|
+
dragOverAnimationCapture: function(t) {
|
|
1315
|
+
var n = t.dragRect, a = t.isOwner, i = t.activeSortable;
|
|
1316
|
+
if (M.forEach(function(h) {
|
|
1317
|
+
h.thisAnimationDuration = null;
|
|
1318
|
+
}), i.options.animation && !a && i.multiDrag.isMultiDrag) {
|
|
1319
|
+
Ft = f({}, n);
|
|
1320
|
+
var s = ke(V, !0);
|
|
1321
|
+
Ft.top -= s.f, Ft.left -= s.e;
|
|
1322
|
+
}
|
|
1323
|
+
},
|
|
1324
|
+
dragOverAnimationComplete: function() {
|
|
1325
|
+
Ce && (Ce = !1, dn());
|
|
1326
|
+
},
|
|
1327
|
+
drop: function(t) {
|
|
1328
|
+
var n = t.originalEvent, a = t.rootEl, i = t.parentEl, s = t.sortable, h = t.dispatchSortableEvent, g = t.oldIndex, m = t.putSortable, I = m || this.sortable;
|
|
1329
|
+
if (n) {
|
|
1330
|
+
var C = this.options, T = i.children;
|
|
1331
|
+
if (!Ct)
|
|
1332
|
+
if (C.multiDragKey && !this.multiDragKeyDown && this._deselectMultiDrag(), U(V, C.selectedClass, !~M.indexOf(V)), ~M.indexOf(V))
|
|
1333
|
+
M.splice(M.indexOf(V), 1), Nt = null, He({
|
|
1334
|
+
sortable: s,
|
|
1335
|
+
rootEl: a,
|
|
1336
|
+
name: "deselect",
|
|
1337
|
+
targetEl: V,
|
|
1338
|
+
originalEvent: n
|
|
1339
|
+
});
|
|
1340
|
+
else {
|
|
1341
|
+
if (M.push(V), He({
|
|
1342
|
+
sortable: s,
|
|
1343
|
+
rootEl: a,
|
|
1344
|
+
name: "select",
|
|
1345
|
+
targetEl: V,
|
|
1346
|
+
originalEvent: n
|
|
1347
|
+
}), n.shiftKey && Nt && s.el.contains(Nt)) {
|
|
1348
|
+
var L = ee(Nt), P = ee(V);
|
|
1349
|
+
~L && ~P && L !== P && (function() {
|
|
1350
|
+
var R, Q;
|
|
1351
|
+
P > L ? (Q = L, R = P) : (Q = P, R = L + 1);
|
|
1352
|
+
for (var fe = C.filter; Q < R; Q++)
|
|
1353
|
+
~M.indexOf(T[Q]) || ne(T[Q], C.draggable, i, !1) && (fe && (typeof fe == "function" ? fe.call(s, n, T[Q], s) : fe.split(",").some(function(We) {
|
|
1354
|
+
return ne(T[Q], We.trim(), i, !1);
|
|
1355
|
+
})) || (U(T[Q], C.selectedClass, !0), M.push(T[Q]), He({
|
|
1356
|
+
sortable: s,
|
|
1357
|
+
rootEl: a,
|
|
1358
|
+
name: "select",
|
|
1359
|
+
targetEl: T[Q],
|
|
1360
|
+
originalEvent: n
|
|
1361
|
+
})));
|
|
1362
|
+
})();
|
|
1363
|
+
} else Nt = V;
|
|
1364
|
+
Re = I;
|
|
1365
|
+
}
|
|
1366
|
+
if (Ct && this.isMultiDrag) {
|
|
1367
|
+
if (Ce = !1, (i[ae].options.sort || i !== a) && M.length > 1) {
|
|
1368
|
+
var q = j(V), ve = ee(V, ":not(." + this.options.selectedClass + ")");
|
|
1369
|
+
if (!Lt && C.animation && (V.thisAnimationDuration = null), I.captureAnimationState(), !Lt && (C.animation && (V.fromRect = q, M.forEach(function(R) {
|
|
1370
|
+
if (R.thisAnimationDuration = null, R !== V) {
|
|
1371
|
+
var Q = Ce ? j(R) : q;
|
|
1372
|
+
R.fromRect = Q, I.addAnimationState({
|
|
1373
|
+
target: R,
|
|
1374
|
+
rect: Q
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
})), dn(), M.forEach(function(R) {
|
|
1378
|
+
T[ve] ? i.insertBefore(R, T[ve]) : i.appendChild(R), ve++;
|
|
1379
|
+
}), g === ee(V))) {
|
|
1380
|
+
var xe = !1;
|
|
1381
|
+
M.forEach(function(R) {
|
|
1382
|
+
if (R.sortableIndex !== ee(R)) {
|
|
1383
|
+
xe = !0;
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
}), xe && (h("update"), h("sort"));
|
|
1387
|
+
}
|
|
1388
|
+
M.forEach(function(R) {
|
|
1389
|
+
bt(R);
|
|
1390
|
+
}), I.animateAll();
|
|
1391
|
+
}
|
|
1392
|
+
Re = I;
|
|
1393
|
+
}
|
|
1394
|
+
(a === i || m && m.lastPutMode !== "clone") && Ie.forEach(function(R) {
|
|
1395
|
+
R.parentNode && R.parentNode.removeChild(R);
|
|
1396
|
+
});
|
|
1397
|
+
}
|
|
1398
|
+
},
|
|
1399
|
+
nullingGlobal: function() {
|
|
1400
|
+
this.isMultiDrag = Ct = !1, Ie.length = 0;
|
|
1401
|
+
},
|
|
1402
|
+
destroyGlobal: function() {
|
|
1403
|
+
this._deselectMultiDrag(), O(document, "pointerup", this._deselectMultiDrag), O(document, "mouseup", this._deselectMultiDrag), O(document, "touchend", this._deselectMultiDrag), O(document, "keydown", this._checkKeyDown), O(document, "keyup", this._checkKeyUp);
|
|
1404
|
+
},
|
|
1405
|
+
_deselectMultiDrag: function(t) {
|
|
1406
|
+
if (!(typeof Ct < "u" && Ct) && Re === this.sortable && !(t && ne(t.target, this.options.draggable, this.sortable.el, !1)) && !(t && t.button !== 0))
|
|
1407
|
+
for (; M.length; ) {
|
|
1408
|
+
var n = M[0];
|
|
1409
|
+
U(n, this.options.selectedClass, !1), M.shift(), He({
|
|
1410
|
+
sortable: this.sortable,
|
|
1411
|
+
rootEl: this.sortable.el,
|
|
1412
|
+
name: "deselect",
|
|
1413
|
+
targetEl: n,
|
|
1414
|
+
originalEvent: t
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
},
|
|
1418
|
+
_checkKeyDown: function(t) {
|
|
1419
|
+
t.key === this.options.multiDragKey && (this.multiDragKeyDown = !0);
|
|
1420
|
+
},
|
|
1421
|
+
_checkKeyUp: function(t) {
|
|
1422
|
+
t.key === this.options.multiDragKey && (this.multiDragKeyDown = !1);
|
|
1423
|
+
}
|
|
1424
|
+
}, f(r, {
|
|
1425
|
+
pluginName: "multiDrag",
|
|
1426
|
+
utils: {
|
|
1427
|
+
select: function(t) {
|
|
1428
|
+
var n = t.parentNode[ae];
|
|
1429
|
+
!n || !n.options.multiDrag || ~M.indexOf(t) || (Re && Re !== n && (Re.multiDrag._deselectMultiDrag(), Re = n), U(t, n.options.selectedClass, !0), M.push(t));
|
|
1430
|
+
},
|
|
1431
|
+
deselect: function(t) {
|
|
1432
|
+
var n = t.parentNode[ae], a = M.indexOf(t);
|
|
1433
|
+
!n || !n.options.multiDrag || !~a || (U(t, n.options.selectedClass, !1), M.splice(a, 1));
|
|
1434
|
+
}
|
|
1435
|
+
},
|
|
1436
|
+
eventProperties: function() {
|
|
1437
|
+
var t = this, n = [], a = [];
|
|
1438
|
+
return M.forEach(function(i) {
|
|
1439
|
+
n.push({
|
|
1440
|
+
multiDragElement: i,
|
|
1441
|
+
index: i.sortableIndex
|
|
1442
|
+
});
|
|
1443
|
+
var s;
|
|
1444
|
+
Ce && i !== V ? s = -1 : Ce ? s = ee(i, ":not(." + t.options.selectedClass + ")") : s = ee(i), a.push({
|
|
1445
|
+
multiDragElement: i,
|
|
1446
|
+
index: s
|
|
1447
|
+
});
|
|
1448
|
+
}), {
|
|
1449
|
+
items: B(M),
|
|
1450
|
+
clones: [].concat(Ie),
|
|
1451
|
+
oldIndicies: n,
|
|
1452
|
+
newIndicies: a
|
|
1453
|
+
};
|
|
1454
|
+
},
|
|
1455
|
+
optionListeners: { multiDragKey: function(t) {
|
|
1456
|
+
return t = t.toLowerCase(), t === "ctrl" ? t = "Control" : t.length > 1 && (t = t.charAt(0).toUpperCase() + t.substr(1)), t;
|
|
1457
|
+
} }
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
function Ar(r, e) {
|
|
1461
|
+
M.forEach(function(t, n) {
|
|
1462
|
+
var a = e.children[t.sortableIndex + (r ? Number(n) : 0)];
|
|
1463
|
+
a ? e.insertBefore(t, a) : e.appendChild(t);
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1466
|
+
function Jn(r, e) {
|
|
1467
|
+
Ie.forEach(function(t, n) {
|
|
1468
|
+
var a = e.children[t.sortableIndex + (r ? Number(n) : 0)];
|
|
1469
|
+
a ? e.insertBefore(t, a) : e.appendChild(t);
|
|
1470
|
+
});
|
|
1471
|
+
}
|
|
1472
|
+
function dn() {
|
|
1473
|
+
M.forEach(function(r) {
|
|
1474
|
+
r !== V && r.parentNode && r.parentNode.removeChild(r);
|
|
1475
|
+
});
|
|
1476
|
+
}
|
|
1477
|
+
return A.mount(new Dr()), A.mount(kn, An), A.mount(new Tr()), A.mount(new xr()), A;
|
|
1478
|
+
}));
|
|
1479
|
+
})))()), Et = "bk_username", Be = {
|
|
1480
|
+
USER: "user",
|
|
1481
|
+
VIRTUAL: "virtual",
|
|
1482
|
+
CUSTOM: "custom",
|
|
1483
|
+
USER_GROUP: "userGroup"
|
|
1484
|
+
}, Qr = /* @__PURE__ */ Symbol("bkUserSelectorApiConfig"), Zr = /^[A-Za-z0-9_-]{1,64}$/, Pn = {
|
|
1485
|
+
apiBaseUrl: "",
|
|
1486
|
+
tenantId: "",
|
|
1487
|
+
allowedApiOrigins: [],
|
|
1488
|
+
allowPrivateApiHost: !1,
|
|
1489
|
+
allowCrossOriginCredentials: !1
|
|
1490
|
+
}, cr = () => typeof window > "u" || !window.location?.origin ? "http://localhost" : window.location.origin, Jr = (c) => {
|
|
1491
|
+
const d = c.split(".").map(Number);
|
|
1492
|
+
if (d.length !== 4 || d.some(Number.isNaN)) return !1;
|
|
1493
|
+
const [u, o] = d;
|
|
1494
|
+
return u === 10 || u === 127 || u === 172 && o >= 16 && o <= 31 || u === 192 && o === 168 || u === 169 && o === 254 || u === 100 && o >= 64 && o <= 127;
|
|
1495
|
+
}, $r = (c) => {
|
|
1496
|
+
const d = c.toLowerCase();
|
|
1497
|
+
return !!(d === "localhost" || d === "[::1]" || d === "::1" || Jr(d) || d.startsWith("fc") || d.startsWith("fd"));
|
|
1498
|
+
}, dr = (c = []) => {
|
|
1499
|
+
const d = cr();
|
|
1500
|
+
return Array.from(new Set(c.map((u) => {
|
|
1501
|
+
try {
|
|
1502
|
+
const o = new URL(u, d);
|
|
1503
|
+
return ["http:", "https:"].includes(o.protocol) ? o.origin : "";
|
|
1504
|
+
} catch {
|
|
1505
|
+
return "";
|
|
1506
|
+
}
|
|
1507
|
+
}).filter(Boolean)));
|
|
1508
|
+
}, fr = (c, d = [], u = !1) => {
|
|
1509
|
+
if (!c) return "";
|
|
1510
|
+
try {
|
|
1511
|
+
const o = new URL(c, cr());
|
|
1512
|
+
if (!["http:", "https:"].includes(o.protocol))
|
|
1513
|
+
return console.warn("[bk-user-selector] apiBaseUrl 仅支持 http/https 协议"), "";
|
|
1514
|
+
if (!u && $r(o.hostname))
|
|
1515
|
+
return console.warn("[bk-user-selector] apiBaseUrl 指向私网或 localhost,已被安全策略拦截"), "";
|
|
1516
|
+
const l = dr(d);
|
|
1517
|
+
if (l.length > 0 && !l.includes(o.origin))
|
|
1518
|
+
return console.warn("[bk-user-selector] apiBaseUrl 未命中 allowedApiOrigins 白名单,已被安全策略拦截"), "";
|
|
1519
|
+
const v = o.pathname.replace(/\/+$/, "");
|
|
1520
|
+
return `${o.origin}${v}`;
|
|
1521
|
+
} catch {
|
|
1522
|
+
return console.warn("[bk-user-selector] apiBaseUrl 格式非法,已被安全策略拦截"), "";
|
|
1523
|
+
}
|
|
1524
|
+
}, hr = (c) => {
|
|
1525
|
+
const d = String(c || "").trim();
|
|
1526
|
+
return d ? Zr.test(d) ? d : (console.warn("[bk-user-selector] tenantId 格式非法,已被安全策略拦截"), "") : "";
|
|
1527
|
+
}, ea = () => Pn, ta = (c, d, u = [], o = !1, l = !1, v = {}) => {
|
|
1528
|
+
const f = dr(u);
|
|
1529
|
+
Pn = {
|
|
1530
|
+
apiBaseUrl: fr(c, f, o),
|
|
1531
|
+
tenantId: hr(d),
|
|
1532
|
+
allowedApiOrigins: f,
|
|
1533
|
+
allowPrivateApiHost: o,
|
|
1534
|
+
allowCrossOriginCredentials: l,
|
|
1535
|
+
onError: v.onError,
|
|
1536
|
+
onUnauthorized: v.onUnauthorized
|
|
1537
|
+
}, Br(Qr, Pn);
|
|
1538
|
+
}, na = () => `__jsonp_callback_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`, ra = (c, d = {}) => new Promise((u, o) => {
|
|
1539
|
+
const l = Lr(c), { timeout: v = 1e3 * 60 * 2, params: f } = d, w = na(), b = document.createElement("script");
|
|
1540
|
+
let B = null;
|
|
1541
|
+
b.setAttribute("type", "text/javascript");
|
|
1542
|
+
const G = () => {
|
|
1543
|
+
B && clearTimeout(B), b.parentNode && b.parentNode.removeChild(b), window[w] && delete window[w];
|
|
1544
|
+
};
|
|
1545
|
+
window[w] = (H) => {
|
|
1546
|
+
G(), u(H.data || H);
|
|
1547
|
+
}, B = setTimeout(() => {
|
|
1548
|
+
G(), o(/* @__PURE__ */ new Error(`JSONP request timeout: ${l}`));
|
|
1549
|
+
}, v), b.onerror = () => {
|
|
1550
|
+
G(), o(/* @__PURE__ */ new Error(`JSONP request failed: ${l}`));
|
|
1551
|
+
}, b.src = `${l}${l.includes("?") ? "&" : "?"}callback=${w}${f ? `&${Object.entries(f).map(([H, ye]) => ye ? `${H}=${ye}` : "").filter(Boolean).join("&")}` : ""}`, document.head.appendChild(b);
|
|
1552
|
+
}), Ht = "[BkUserSelector]", rr = {
|
|
1553
|
+
debug: 0,
|
|
1554
|
+
info: 1,
|
|
1555
|
+
warn: 2,
|
|
1556
|
+
error: 3
|
|
1557
|
+
}, aa = {
|
|
1558
|
+
level: "warn"
|
|
1559
|
+
}, gn = (c) => rr[c] >= rr[aa.level], Rn = {
|
|
1560
|
+
debug: (c, ...d) => {
|
|
1561
|
+
gn("debug") && console.debug(`${Ht} ${c}`, ...d);
|
|
1562
|
+
},
|
|
1563
|
+
info: (c, ...d) => {
|
|
1564
|
+
gn("info") && console.info(`${Ht} ${c}`, ...d);
|
|
1565
|
+
},
|
|
1566
|
+
warn: (c, ...d) => {
|
|
1567
|
+
gn("warn") && console.warn(`${Ht} ${c}`, ...d);
|
|
1568
|
+
},
|
|
1569
|
+
error: (c, d) => {
|
|
1570
|
+
gn("error") && console.error(`${Ht} ${c}`, d);
|
|
1571
|
+
}
|
|
1572
|
+
}, ar = (c, d) => {
|
|
1573
|
+
if (c)
|
|
1574
|
+
try {
|
|
1575
|
+
c(d);
|
|
1576
|
+
} catch (u) {
|
|
1577
|
+
console.error(`${Ht} error handler threw:`, u);
|
|
1578
|
+
}
|
|
1579
|
+
}, oa = (c, d, u, o = !1) => ({
|
|
1580
|
+
scene: c,
|
|
1581
|
+
cause: d,
|
|
1582
|
+
status: u,
|
|
1583
|
+
isUnauthorized: o
|
|
1584
|
+
}), yn = (c, d, u, o, l = !1) => {
|
|
1585
|
+
l ? Rn.warn(`${c}: 登录态已失效,请重新登录`) : Rn.error(`${c}失败:`, d);
|
|
1586
|
+
const v = oa(c, d, o, l);
|
|
1587
|
+
l && ar(u?.onUnauthorized, v), ar(u?.onError, v);
|
|
1588
|
+
}, Nn = (c, d) => {
|
|
1589
|
+
Rn.warn(`${c}需要提供有效的参数: ${d.join(", ")}`);
|
|
1590
|
+
}, bn = 401, Ln = (c, d) => {
|
|
1591
|
+
if (typeof window > "u" || !window.location?.origin) return "same-origin";
|
|
1592
|
+
try {
|
|
1593
|
+
return new URL(c, window.location.origin).origin === window.location.origin || d ? "include" : "omit";
|
|
1594
|
+
} catch {
|
|
1595
|
+
return "same-origin";
|
|
1596
|
+
}
|
|
1597
|
+
}, Fn = (c, d) => {
|
|
1598
|
+
const u = ea(), o = u.allowPrivateApiHost, l = u.allowedApiOrigins;
|
|
1599
|
+
return {
|
|
1600
|
+
allowCrossOriginCredentials: u.allowCrossOriginCredentials,
|
|
1601
|
+
apiBaseUrl: fr(u.apiBaseUrl || c, l, o),
|
|
1602
|
+
tenantId: hr(u.tenantId || d),
|
|
1603
|
+
apiConfig: u
|
|
1604
|
+
};
|
|
1605
|
+
}, qn = (c, d, u) => {
|
|
1606
|
+
if (!c.ok) {
|
|
1607
|
+
if (c.status === bn) {
|
|
1608
|
+
const o = /* @__PURE__ */ new Error(`${d}失败: 登录态已失效`);
|
|
1609
|
+
throw yn(d, o, u, c.status, !0), o;
|
|
1610
|
+
}
|
|
1611
|
+
throw new Error(`${c.status} ${c.statusText}`);
|
|
1612
|
+
}
|
|
1613
|
+
}, Gn = (c) => {
|
|
1614
|
+
if (typeof c == "object" && c !== null && "status" in c) {
|
|
1615
|
+
const d = c.status;
|
|
1616
|
+
return typeof d == "number" ? d : void 0;
|
|
1617
|
+
}
|
|
1618
|
+
if (c instanceof Error) {
|
|
1619
|
+
const d = /^(\d{3})\s/.exec(c.message);
|
|
1620
|
+
if (d) return Number(d[1]);
|
|
1621
|
+
}
|
|
1622
|
+
}, ia = async (c, d) => {
|
|
1623
|
+
const u = Fn(c, d);
|
|
1624
|
+
if (!u.apiBaseUrl || !u.tenantId)
|
|
1625
|
+
return Nn("获取租户信息", ["apiBaseUrl", "tenantId"]), [];
|
|
1626
|
+
try {
|
|
1627
|
+
const o = `${u.apiBaseUrl}/api/v3/open-web/tenant/data-source-owner-tenants/`, l = Ln(o, u.allowCrossOriginCredentials), v = await fetch(o, {
|
|
1628
|
+
method: "GET",
|
|
1629
|
+
headers: { "x-bk-tenant-id": u.tenantId },
|
|
1630
|
+
credentials: l
|
|
1631
|
+
});
|
|
1632
|
+
return qn(v, "获取租户信息", u.apiConfig), (await v.json()).data || [];
|
|
1633
|
+
} catch (o) {
|
|
1634
|
+
const l = Gn(o);
|
|
1635
|
+
return l !== bn && yn("获取租户信息", o, u.apiConfig, l, !1), [];
|
|
1636
|
+
}
|
|
1637
|
+
}, la = async (c) => {
|
|
1638
|
+
const { apiBaseUrl: d, tenantId: u, keyword: o, enableMultiTenantMode: l = !0 } = c;
|
|
1639
|
+
if (!l) try {
|
|
1640
|
+
return await pr(d, {
|
|
1641
|
+
keyword: o,
|
|
1642
|
+
pageSize: 100,
|
|
1643
|
+
page: 1
|
|
1644
|
+
});
|
|
1645
|
+
} catch {
|
|
1646
|
+
return [];
|
|
1647
|
+
}
|
|
1648
|
+
const v = Fn(d, u);
|
|
1649
|
+
if (!o || !v.apiBaseUrl || !v.tenantId)
|
|
1650
|
+
return Nn("搜索用户", [
|
|
1651
|
+
"apiBaseUrl",
|
|
1652
|
+
"tenantId",
|
|
1653
|
+
"keyword"
|
|
1654
|
+
]), [];
|
|
1655
|
+
try {
|
|
1656
|
+
const f = `${v.apiBaseUrl}/api/v3/open-web/tenant/users/-/search/?keyword=${encodeURIComponent(o)}`, w = Ln(f, v.allowCrossOriginCredentials), b = await fetch(f, {
|
|
1657
|
+
method: "GET",
|
|
1658
|
+
headers: { "x-bk-tenant-id": v.tenantId },
|
|
1659
|
+
credentials: w
|
|
1660
|
+
});
|
|
1661
|
+
return qn(b, "搜索用户", v.apiConfig), (await b.json()).data || [];
|
|
1662
|
+
} catch (f) {
|
|
1663
|
+
const w = Gn(f);
|
|
1664
|
+
return w !== bn && yn("搜索用户", f, v.apiConfig, w, !1), [];
|
|
1665
|
+
}
|
|
1666
|
+
}, mn = async (c) => {
|
|
1667
|
+
const { apiBaseUrl: d, tenantId: u, exactSearchKey: o = "bk_username", usersList: l = [], enableMultiTenantMode: v = !0 } = c, f = l.filter(Boolean).map((b) => typeof b == "string" ? b.trim() : String(b).trim());
|
|
1668
|
+
if (!v) try {
|
|
1669
|
+
const b = await pr(d, { userIds: f });
|
|
1670
|
+
return f.map((B) => b.find((G) => G.username === B)).filter(Boolean);
|
|
1671
|
+
} catch {
|
|
1672
|
+
return [];
|
|
1673
|
+
}
|
|
1674
|
+
const w = Fn(d, u);
|
|
1675
|
+
if (f.length === 0 || !w.apiBaseUrl || !w.tenantId)
|
|
1676
|
+
return Nn("批量查找用户", [
|
|
1677
|
+
"apiBaseUrl",
|
|
1678
|
+
"tenantId",
|
|
1679
|
+
"usersList"
|
|
1680
|
+
]), [];
|
|
1681
|
+
try {
|
|
1682
|
+
const b = `${w.apiBaseUrl}/api/v3/open-web/tenant/users/-/lookup/?lookups=${f.join(",")}&lookup_fields=${o}`, B = Ln(b, w.allowCrossOriginCredentials), G = await fetch(b, {
|
|
1683
|
+
method: "GET",
|
|
1684
|
+
headers: { "x-bk-tenant-id": w.tenantId },
|
|
1685
|
+
credentials: B
|
|
1686
|
+
});
|
|
1687
|
+
return qn(G, "批量查找用户", w.apiConfig), (await G.json()).data || [];
|
|
1688
|
+
} catch (b) {
|
|
1689
|
+
const B = Gn(b);
|
|
1690
|
+
return B !== bn && yn("批量查找用户", b, w.apiConfig, B, !1), [];
|
|
1691
|
+
}
|
|
1692
|
+
}, Xt = (c, d = !0) => !c || !Array.isArray(c) ? [] : d ? c.map((u) => ({
|
|
1693
|
+
id: u.bk_username,
|
|
1694
|
+
name: u.display_name,
|
|
1695
|
+
type: u.data_source_type,
|
|
1696
|
+
tenantId: u.owner_tenant_id,
|
|
1697
|
+
...u
|
|
1698
|
+
})) : c.map((u) => ({
|
|
1699
|
+
...u,
|
|
1700
|
+
id: u.username,
|
|
1701
|
+
name: `${u.display_name}(${u.username})`,
|
|
1702
|
+
type: u.data_source_type,
|
|
1703
|
+
tenantId: u.owner_tenant_id
|
|
1704
|
+
})), pr = async (c, d) => {
|
|
1705
|
+
const { userIds: u, keyword: o, pageSize: l = 20, page: v = 1, appCode: f = "bk-magicbox" } = d;
|
|
1706
|
+
return (await ra(c, { params: {
|
|
1707
|
+
exact_lookups: u?.join(",") || void 0,
|
|
1708
|
+
fuzzy_lookups: o || void 0,
|
|
1709
|
+
page_size: Math.max(u?.length || 0, 20, Number(l)).toString(),
|
|
1710
|
+
page: v.toString(),
|
|
1711
|
+
app_code: f
|
|
1712
|
+
} }))?.results || [];
|
|
1713
|
+
}, sa = (c) => {
|
|
1714
|
+
const { apiBaseUrl: d, tenantId: u, currentUserId: o, exactSearchKey: l = Et, enableMultiTenantMode: v = !0 } = c, f = te(!1);
|
|
1715
|
+
return {
|
|
1716
|
+
loading: f,
|
|
1717
|
+
fetchCurrentUser: async () => {
|
|
1718
|
+
if (!o) return null;
|
|
1719
|
+
f.value = !0;
|
|
1720
|
+
try {
|
|
1721
|
+
const b = Xt(await mn({
|
|
1722
|
+
apiBaseUrl: d,
|
|
1723
|
+
tenantId: u,
|
|
1724
|
+
exactSearchKey: l,
|
|
1725
|
+
usersList: [o],
|
|
1726
|
+
enableMultiTenantMode: v
|
|
1727
|
+
}), v);
|
|
1728
|
+
return b.length > 0 ? b[0] : null;
|
|
1729
|
+
} catch (b) {
|
|
1730
|
+
return console.error("获取当前用户信息失败:", b), null;
|
|
1731
|
+
} finally {
|
|
1732
|
+
f.value = !1;
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
};
|
|
1736
|
+
};
|
|
1737
|
+
function vn(c) {
|
|
1738
|
+
for (var d = 1; d < arguments.length; d++) {
|
|
1739
|
+
var u = arguments[d];
|
|
1740
|
+
for (var o in u) c[o] = u[o];
|
|
1741
|
+
}
|
|
1742
|
+
return c;
|
|
1743
|
+
}
|
|
1744
|
+
var ua = {
|
|
1745
|
+
read: function(c) {
|
|
1746
|
+
return c[0] === '"' && (c = c.slice(1, -1)), c.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
1747
|
+
},
|
|
1748
|
+
write: function(c) {
|
|
1749
|
+
return encodeURIComponent(c).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
function Bn(c, d) {
|
|
1753
|
+
function u(l, v, f) {
|
|
1754
|
+
if (!(typeof document > "u")) {
|
|
1755
|
+
f = vn({}, d, f), typeof f.expires == "number" && (f.expires = new Date(Date.now() + f.expires * 864e5)), f.expires && (f.expires = f.expires.toUTCString()), l = encodeURIComponent(l).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
1756
|
+
var w = "";
|
|
1757
|
+
for (var b in f)
|
|
1758
|
+
f[b] && (w += "; " + b, f[b] !== !0 && (w += "=" + f[b].split(";")[0]));
|
|
1759
|
+
return document.cookie = l + "=" + c.write(v, l) + w;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
function o(l) {
|
|
1763
|
+
if (!(typeof document > "u" || arguments.length && !l)) {
|
|
1764
|
+
for (var v = document.cookie ? document.cookie.split("; ") : [], f = {}, w = 0; w < v.length; w++) {
|
|
1765
|
+
var b = v[w].split("="), B = b.slice(1).join("=");
|
|
1766
|
+
try {
|
|
1767
|
+
var G = decodeURIComponent(b[0]);
|
|
1768
|
+
if (f[G] = c.read(B, G), l === G) break;
|
|
1769
|
+
} catch {
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
return l ? f[l] : f;
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
return Object.create({
|
|
1776
|
+
set: u,
|
|
1777
|
+
get: o,
|
|
1778
|
+
remove: function(l, v) {
|
|
1779
|
+
u(l, "", vn({}, v, { expires: -1 }));
|
|
1780
|
+
},
|
|
1781
|
+
withAttributes: function(l) {
|
|
1782
|
+
return Bn(this.converter, vn({}, this.attributes, l));
|
|
1783
|
+
},
|
|
1784
|
+
withConverter: function(l) {
|
|
1785
|
+
return Bn(vn({}, this.converter, l), this.attributes);
|
|
1786
|
+
}
|
|
1787
|
+
}, {
|
|
1788
|
+
attributes: { value: Object.freeze(d) },
|
|
1789
|
+
converter: { value: Object.freeze(c) }
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
var ca = Bn(ua, { path: "/" }), da = {
|
|
1793
|
+
我: "Me",
|
|
1794
|
+
请输入人员名称搜索: "Please enter the name of the user to search",
|
|
1795
|
+
最近选择: "Recent selections",
|
|
1796
|
+
用户群组: "User Group",
|
|
1797
|
+
无匹配人员: "No matching users",
|
|
1798
|
+
虚拟账号: "Virtual Account",
|
|
1799
|
+
用户: "User"
|
|
1800
|
+
}, fa = {
|
|
1801
|
+
我: "我",
|
|
1802
|
+
请输入人员名称搜索: "请输入人员名称搜索",
|
|
1803
|
+
最近选择: "最近选择",
|
|
1804
|
+
用户群组: "用户群组",
|
|
1805
|
+
无匹配人员: "无匹配人员",
|
|
1806
|
+
虚拟账号: "虚拟账号",
|
|
1807
|
+
用户: "用户"
|
|
1808
|
+
}, ha = "blueking_language", pa = {
|
|
1809
|
+
"en-US": da,
|
|
1810
|
+
"zh-CN": fa
|
|
1811
|
+
}, ga = (c, d, u) => {
|
|
1812
|
+
const o = /^\w/.test(d) ? d.split(".") : [d], { length: l } = o;
|
|
1813
|
+
let v = c, f = 0;
|
|
1814
|
+
for (; f <= l && v; )
|
|
1815
|
+
if (typeof v == "string" || (u ? (v = v[o[f]], typeof v == "string" && Object.keys(u).forEach((w) => {
|
|
1816
|
+
v = v.replace(`{${w}}`, u[w]);
|
|
1817
|
+
})) : v = v[o[f]], f = f + 1, !v)) return v;
|
|
1818
|
+
return v;
|
|
1819
|
+
}, zn = () => {
|
|
1820
|
+
let c = "zh-CN";
|
|
1821
|
+
const d = ca.get(ha);
|
|
1822
|
+
d && d.toLowerCase() === "en" && (c = "en-US");
|
|
1823
|
+
const u = pa[c];
|
|
1824
|
+
return {
|
|
1825
|
+
local: c,
|
|
1826
|
+
t: (l, v) => {
|
|
1827
|
+
const f = ga(u, l, v);
|
|
1828
|
+
return f === void 0 && console.warn(`缺少索引 * ${l} *`), f;
|
|
1829
|
+
}
|
|
1830
|
+
};
|
|
1831
|
+
}, va = (c) => {
|
|
1832
|
+
const { apiBaseUrl: d, tenantId: u, searchQuery: o, selectedUsers: l, allowCreate: v = !1, freePaste: f = !1, enableMultiTenantMode: w = !0, maxCount: b = 0, onAddUser: B, onBatchAddUsers: G } = c, H = te(!1), ye = 100, Ne = 100, Le = ($) => ({
|
|
1833
|
+
id: $,
|
|
1834
|
+
name: $,
|
|
1835
|
+
type: Be.CUSTOM,
|
|
1836
|
+
tenantId: "",
|
|
1837
|
+
login_name: $
|
|
1838
|
+
}), De = ($) => {
|
|
1839
|
+
const X = $.split(/[,,;\n\s]+/).filter(Boolean).map((D) => D.trim().replace(/\s*\(.*?\)\s*/, "")).filter(Boolean);
|
|
1840
|
+
return Array.from(new Set(X)).slice(0, ye);
|
|
1841
|
+
}, F = ($, X) => {
|
|
1842
|
+
const D = [];
|
|
1843
|
+
for (let ue = 0; ue < $.length; ue += X) D.push($.slice(ue, ue + X));
|
|
1844
|
+
return D;
|
|
1845
|
+
}, z = ($, X) => {
|
|
1846
|
+
const D = /* @__PURE__ */ new Map();
|
|
1847
|
+
for (const ue of [...$, ...X]) D.has(ue.id) || D.set(ue.id, ue);
|
|
1848
|
+
return Array.from(D.values());
|
|
1849
|
+
};
|
|
1850
|
+
return {
|
|
1851
|
+
isPasting: H,
|
|
1852
|
+
parsePastedText: De,
|
|
1853
|
+
handleEnterCreate: ($) => {
|
|
1854
|
+
if ($.key !== "Enter" || !v || !o.value.trim()) return;
|
|
1855
|
+
const X = Le(o.value.trim());
|
|
1856
|
+
l.value.some((D) => D.id === X.id) || B(X);
|
|
1857
|
+
},
|
|
1858
|
+
handlePaste: async ($) => {
|
|
1859
|
+
$.preventDefault();
|
|
1860
|
+
const X = $.clipboardData?.getData("text")?.trim();
|
|
1861
|
+
if (X) {
|
|
1862
|
+
H.value = !0;
|
|
1863
|
+
try {
|
|
1864
|
+
const D = De(X);
|
|
1865
|
+
if (D.length === 0) return;
|
|
1866
|
+
const ue = F(D, Ne), x = [];
|
|
1867
|
+
for (const Y of ue) {
|
|
1868
|
+
const be = await mn({
|
|
1869
|
+
apiBaseUrl: d,
|
|
1870
|
+
tenantId: u,
|
|
1871
|
+
exactSearchKey: "login_name",
|
|
1872
|
+
usersList: Y,
|
|
1873
|
+
enableMultiTenantMode: w
|
|
1874
|
+
});
|
|
1875
|
+
x.push(...be);
|
|
1876
|
+
}
|
|
1877
|
+
const O = Xt(x, w);
|
|
1878
|
+
if (G) {
|
|
1879
|
+
let Y = z(l.value, O);
|
|
1880
|
+
if (f)
|
|
1881
|
+
for (const be of D) Y.some((ne) => ne.login_name === be || ne.id === be) || Y.push(Le(be));
|
|
1882
|
+
b > 0 && Y.length > b && (Y = Y.slice(0, b)), G(Y);
|
|
1883
|
+
} else O.length > 0 ? B(O[0]) : f && D.length > 0 && B(Le(D[0]));
|
|
1884
|
+
} catch (D) {
|
|
1885
|
+
console.error("精准查找用户失败:", D);
|
|
1886
|
+
} finally {
|
|
1887
|
+
H.value = !1;
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
}, ma = (c, d, u = {}) => {
|
|
1893
|
+
const { immediate: o = !0 } = u;
|
|
1894
|
+
let l = null;
|
|
1895
|
+
const v = () => {
|
|
1896
|
+
l && (l.disconnect(), l = null);
|
|
1897
|
+
};
|
|
1898
|
+
return at(c, () => {
|
|
1899
|
+
if (v(), !!c.value && (l = new ResizeObserver((w) => {
|
|
1900
|
+
for (const b of w) d(b);
|
|
1901
|
+
}), l.observe(c.value), o && c.value)) {
|
|
1902
|
+
const w = c.value.getBoundingClientRect();
|
|
1903
|
+
d({
|
|
1904
|
+
target: c.value,
|
|
1905
|
+
contentRect: w,
|
|
1906
|
+
borderBoxSize: [{
|
|
1907
|
+
blockSize: w.height,
|
|
1908
|
+
inlineSize: w.width
|
|
1909
|
+
}],
|
|
1910
|
+
contentBoxSize: [{
|
|
1911
|
+
blockSize: w.height,
|
|
1912
|
+
inlineSize: w.width
|
|
1913
|
+
}],
|
|
1914
|
+
devicePixelContentBoxSize: [{
|
|
1915
|
+
blockSize: w.height,
|
|
1916
|
+
inlineSize: w.width
|
|
1917
|
+
}]
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
}, { immediate: !0 }), ir(v), v;
|
|
1921
|
+
}, ya = (c, d, u = !0) => {
|
|
1922
|
+
const o = te({}), l = te(!1), v = async () => {
|
|
1923
|
+
if (!c || !d) {
|
|
1924
|
+
console.warn("获取租户需要提供有效的API基础URL和租户ID");
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
l.value = !0;
|
|
1928
|
+
try {
|
|
1929
|
+
const f = await ia(c, d), w = {};
|
|
1930
|
+
f.forEach((b) => {
|
|
1931
|
+
b.id && b.name && (w[b.id] = b.name);
|
|
1932
|
+
}), o.value = w;
|
|
1933
|
+
} catch (f) {
|
|
1934
|
+
console.error("获取租户数据失败:", f);
|
|
1935
|
+
} finally {
|
|
1936
|
+
l.value = !1;
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
return or(() => {
|
|
1940
|
+
u && v();
|
|
1941
|
+
}), {
|
|
1942
|
+
tenants: o,
|
|
1943
|
+
loading: l,
|
|
1944
|
+
fetchTenants: v
|
|
1945
|
+
};
|
|
1946
|
+
}, ba = (c, d) => {
|
|
1947
|
+
let u = null;
|
|
1948
|
+
return function(...o) {
|
|
1949
|
+
u && clearTimeout(u), u = window.setTimeout(() => {
|
|
1950
|
+
c(...o), u = null;
|
|
1951
|
+
}, d);
|
|
1952
|
+
};
|
|
1953
|
+
}, wa = (c, d, u) => {
|
|
1954
|
+
if (!c || !d.length) return 0;
|
|
1955
|
+
let o = 0, l = 0;
|
|
1956
|
+
for (const v of Array.from(d)) {
|
|
1957
|
+
const f = v;
|
|
1958
|
+
if (!f) continue;
|
|
1959
|
+
const w = window.getComputedStyle(f), b = f.offsetWidth, B = parseInt(w.marginLeft, 10) || 0, G = parseInt(w.marginRight, 10) || 0;
|
|
1960
|
+
if (o += b + B + G, o > u) break;
|
|
1961
|
+
l++;
|
|
1962
|
+
}
|
|
1963
|
+
return Math.max(1, l);
|
|
1964
|
+
}, _a = (c, d, u = !0) => {
|
|
1965
|
+
const o = te([]), l = te(!1), v = te(""), f = async (G) => {
|
|
1966
|
+
if (!G?.length) {
|
|
1967
|
+
o.value = [], l.value = !1;
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
if (u && (!c || !d)) {
|
|
1971
|
+
console.warn("执行用户搜索需要提供有效的API基础URL和租户ID"), l.value = !1;
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
l.value = !0;
|
|
1975
|
+
try {
|
|
1976
|
+
o.value = Xt(await la({
|
|
1977
|
+
apiBaseUrl: c,
|
|
1978
|
+
tenantId: d,
|
|
1979
|
+
keyword: G,
|
|
1980
|
+
enableMultiTenantMode: u
|
|
1981
|
+
}), u);
|
|
1982
|
+
} catch (H) {
|
|
1983
|
+
console.error("用户搜索失败:", H), o.value = [];
|
|
1984
|
+
} finally {
|
|
1985
|
+
l.value = !1;
|
|
1986
|
+
}
|
|
1987
|
+
}, w = ba(f, 300);
|
|
1988
|
+
return {
|
|
1989
|
+
searchResults: o,
|
|
1990
|
+
loading: l,
|
|
1991
|
+
searchQuery: v,
|
|
1992
|
+
performSearch: f,
|
|
1993
|
+
handleSearchInput: (G) => {
|
|
1994
|
+
l.value = !0, v.value = G.trim(), w(v.value);
|
|
1995
|
+
},
|
|
1996
|
+
clearSearch: () => {
|
|
1997
|
+
v.value = "", o.value = [], l.value = !1;
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
}, Ca = (c) => {
|
|
2001
|
+
const { selectedUserIds: d, excludeUserIds: u, userGroup: o, searchQuery: l } = c, v = (b) => ({
|
|
2002
|
+
id: b,
|
|
2003
|
+
name: b,
|
|
2004
|
+
type: Be.CUSTOM,
|
|
2005
|
+
tenantId: "",
|
|
2006
|
+
login_name: b
|
|
2007
|
+
}), f = (b) => d.value.includes(b);
|
|
2008
|
+
return {
|
|
2009
|
+
createCustomUser: v,
|
|
2010
|
+
isUserSelected: f,
|
|
2011
|
+
filterOptions: (b) => b.filter((B) => !f(B.id)).filter((B) => !u?.value?.includes(B.id)),
|
|
2012
|
+
filteredUserGroup: re(() => o?.value?.length ? o.value.filter((b) => {
|
|
2013
|
+
if (!(!f(b.id) && !b.hidden)) return !1;
|
|
2014
|
+
const B = l.value.trim();
|
|
2015
|
+
return B ? b.id?.includes(B) || b.name?.includes(B) : !0;
|
|
2016
|
+
}) : [])
|
|
2017
|
+
};
|
|
2018
|
+
}, Sa = /* @__PURE__ */ Wt({
|
|
2019
|
+
name: "MeTag",
|
|
2020
|
+
__name: "me-tag",
|
|
2021
|
+
props: {
|
|
2022
|
+
currentUserId: {
|
|
2023
|
+
type: String,
|
|
2024
|
+
required: !1,
|
|
2025
|
+
default: ""
|
|
2026
|
+
},
|
|
2027
|
+
isDisabled: {
|
|
2028
|
+
type: Boolean,
|
|
2029
|
+
required: !1,
|
|
2030
|
+
default: !1
|
|
2031
|
+
}
|
|
2032
|
+
},
|
|
2033
|
+
emits: ["click"],
|
|
2034
|
+
setup(c, { expose: d, emit: u }) {
|
|
2035
|
+
d();
|
|
2036
|
+
const { t: o } = zn(), l = c, v = u, w = {
|
|
2037
|
+
t: o,
|
|
2038
|
+
props: l,
|
|
2039
|
+
emit: v,
|
|
2040
|
+
handleClick: () => {
|
|
2041
|
+
l.isDisabled || v("click");
|
|
2042
|
+
}
|
|
2043
|
+
};
|
|
2044
|
+
return Object.defineProperty(w, "__isScriptSetup", {
|
|
2045
|
+
enumerable: !1,
|
|
2046
|
+
value: !0
|
|
2047
|
+
}), w;
|
|
2048
|
+
}
|
|
2049
|
+
}), wn = (c, d) => {
|
|
2050
|
+
const u = c.__vccOpts || c;
|
|
2051
|
+
for (const [o, l] of d) u[o] = l;
|
|
2052
|
+
return u;
|
|
2053
|
+
};
|
|
2054
|
+
function Ea(c, d, u, o, l, v) {
|
|
2055
|
+
return u.currentUserId ? (Z(), oe("div", {
|
|
2056
|
+
key: 0,
|
|
2057
|
+
class: It(["me-tag", { disabled: u.isDisabled }]),
|
|
2058
|
+
onClick: je(o.handleClick, ["stop"])
|
|
2059
|
+
}, gt(o.t("我")), 3)) : se("v-if", !0);
|
|
2060
|
+
}
|
|
2061
|
+
var Ia = /* @__PURE__ */ wn(Sa, [
|
|
2062
|
+
["render", Ea],
|
|
2063
|
+
["__scopeId", "data-v-a1054364"],
|
|
2064
|
+
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/me-tag.vue"]
|
|
2065
|
+
]), Ua = "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", Da = "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", Ta = "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", jn = Wt({
|
|
2066
|
+
name: "UserRender",
|
|
2067
|
+
props: {
|
|
2068
|
+
user: {
|
|
2069
|
+
type: Object,
|
|
2070
|
+
required: !0
|
|
2071
|
+
},
|
|
2072
|
+
tenantId: {
|
|
2073
|
+
type: String,
|
|
2074
|
+
default: "default"
|
|
2075
|
+
},
|
|
2076
|
+
tenants: {
|
|
2077
|
+
type: Object,
|
|
2078
|
+
required: !0
|
|
2079
|
+
},
|
|
2080
|
+
render: {
|
|
2081
|
+
type: Function,
|
|
2082
|
+
required: !1
|
|
2083
|
+
},
|
|
2084
|
+
hasAvatar: {
|
|
2085
|
+
type: Boolean,
|
|
2086
|
+
default: !1
|
|
2087
|
+
},
|
|
2088
|
+
avatarBaseUrl: {
|
|
2089
|
+
type: String,
|
|
2090
|
+
default: ""
|
|
2091
|
+
}
|
|
2092
|
+
},
|
|
2093
|
+
setup(c) {
|
|
2094
|
+
const d = (o) => {
|
|
2095
|
+
if (o.type === "virtual") return Ta;
|
|
2096
|
+
if (o.type === "userGroup") return Ua;
|
|
2097
|
+
if (!c.avatarBaseUrl) return Da;
|
|
2098
|
+
const l = o.login_name || o.bk_username || o.id;
|
|
2099
|
+
return `${c.avatarBaseUrl}${l}.png?default_when_absent=true`;
|
|
2100
|
+
}, u = (o, l) => o("div", { style: {
|
|
2101
|
+
display: "flex",
|
|
2102
|
+
alignItems: "center"
|
|
2103
|
+
} }, [
|
|
2104
|
+
l.hasAvatar ? o("img", {
|
|
2105
|
+
src: d(l.user),
|
|
2106
|
+
style: {
|
|
2107
|
+
width: "20px",
|
|
2108
|
+
height: "20px",
|
|
2109
|
+
borderRadius: "50%",
|
|
2110
|
+
marginRight: "6px",
|
|
2111
|
+
flexShrink: 0
|
|
2112
|
+
}
|
|
2113
|
+
}) : null,
|
|
2114
|
+
o("span", l.user.name),
|
|
2115
|
+
l.user.tenantId !== l.tenantId && l.user.tenantId ? o("span", { style: {
|
|
2116
|
+
color: "#f59500",
|
|
2117
|
+
marginLeft: "4px"
|
|
2118
|
+
} }, `@${l.tenants[l.user.tenantId] || l.user.tenantId}`) : null
|
|
2119
|
+
]);
|
|
2120
|
+
return () => {
|
|
2121
|
+
try {
|
|
2122
|
+
return c.render ? c.render(Mn, c.user) : u(Mn, c);
|
|
2123
|
+
} catch (o) {
|
|
2124
|
+
return console.error("Error rendering tag:", o), u(Mn, c);
|
|
2125
|
+
}
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
}), Oa = /* @__PURE__ */ Wt({
|
|
2129
|
+
name: "SelectionPopover",
|
|
2130
|
+
__name: "selection-popover",
|
|
2131
|
+
props: {
|
|
2132
|
+
avatarBaseUrl: {
|
|
2133
|
+
type: String,
|
|
2134
|
+
required: !1,
|
|
2135
|
+
default: ""
|
|
2136
|
+
},
|
|
2137
|
+
containerWidth: {
|
|
2138
|
+
type: [Number, String],
|
|
2139
|
+
required: !1,
|
|
2140
|
+
default: "auto"
|
|
2141
|
+
},
|
|
2142
|
+
emptyText: {
|
|
2143
|
+
type: String,
|
|
2144
|
+
required: !1,
|
|
2145
|
+
default: ""
|
|
2146
|
+
},
|
|
2147
|
+
flatOptions: {
|
|
2148
|
+
type: Array,
|
|
2149
|
+
required: !1,
|
|
2150
|
+
default: () => []
|
|
2151
|
+
},
|
|
2152
|
+
hasAvatar: {
|
|
2153
|
+
type: Boolean,
|
|
2154
|
+
required: !1,
|
|
2155
|
+
default: !1
|
|
2156
|
+
},
|
|
2157
|
+
highlightedIndex: {
|
|
2158
|
+
type: Number,
|
|
2159
|
+
required: !1,
|
|
2160
|
+
default: -1
|
|
2161
|
+
},
|
|
2162
|
+
isShow: {
|
|
2163
|
+
type: Boolean,
|
|
2164
|
+
required: !1,
|
|
2165
|
+
default: !1
|
|
2166
|
+
},
|
|
2167
|
+
loading: {
|
|
2168
|
+
type: Boolean,
|
|
2169
|
+
required: !1,
|
|
2170
|
+
default: !1
|
|
2171
|
+
},
|
|
2172
|
+
options: {
|
|
2173
|
+
type: Array,
|
|
2174
|
+
required: !1,
|
|
2175
|
+
default: () => []
|
|
2176
|
+
},
|
|
2177
|
+
recentUsers: {
|
|
2178
|
+
type: Array,
|
|
2179
|
+
required: !1,
|
|
2180
|
+
default: () => []
|
|
2181
|
+
},
|
|
2182
|
+
recentUsersName: {
|
|
2183
|
+
type: String,
|
|
2184
|
+
required: !1,
|
|
2185
|
+
default: ""
|
|
2186
|
+
},
|
|
2187
|
+
renderListItem: {
|
|
2188
|
+
type: Function,
|
|
2189
|
+
required: !1
|
|
2190
|
+
},
|
|
2191
|
+
searchQuery: {
|
|
2192
|
+
type: String,
|
|
2193
|
+
required: !1,
|
|
2194
|
+
default: ""
|
|
2195
|
+
},
|
|
2196
|
+
tenantId: {
|
|
2197
|
+
type: String,
|
|
2198
|
+
required: !1,
|
|
2199
|
+
default: "default"
|
|
2200
|
+
},
|
|
2201
|
+
tenants: {
|
|
2202
|
+
type: Object,
|
|
2203
|
+
required: !1,
|
|
2204
|
+
default: () => ({})
|
|
2205
|
+
},
|
|
2206
|
+
userGroup: {
|
|
2207
|
+
type: Array,
|
|
2208
|
+
required: !1,
|
|
2209
|
+
default: () => []
|
|
2210
|
+
},
|
|
2211
|
+
userGroupName: {
|
|
2212
|
+
type: String,
|
|
2213
|
+
required: !1,
|
|
2214
|
+
default: ""
|
|
2215
|
+
}
|
|
2216
|
+
},
|
|
2217
|
+
emits: ["click-outside", "select-user"],
|
|
2218
|
+
setup(c, { expose: d, emit: u }) {
|
|
2219
|
+
d();
|
|
2220
|
+
const { t: o } = zn(), l = te(null), v = te(null), f = c, w = u, b = re(() => {
|
|
2221
|
+
const F = {};
|
|
2222
|
+
return Array.isArray(f.userGroup) && f.userGroup.length > 0 && (F[f.userGroupName] = f.userGroup.map((z) => ({
|
|
2223
|
+
...z,
|
|
2224
|
+
tenantId: "",
|
|
2225
|
+
type: Be.USER_GROUP
|
|
2226
|
+
}))), f.options.forEach((z) => {
|
|
2227
|
+
const Se = z.data_source_type === Be.VIRTUAL ? o("虚拟账号") : o("用户");
|
|
2228
|
+
F[Se] || (F[Se] = []), F[Se].push(z);
|
|
2229
|
+
}), F;
|
|
2230
|
+
}), B = re(() => Object.values(b.value).some((F) => F.length > 0)), G = re(() => f.recentUsers.length > 0), H = re(() => B.value || G.value), ye = (F) => f.highlightedIndex < 0 || !f.flatOptions.length ? !1 : f.flatOptions[f.highlightedIndex] === F, Ne = (F) => {
|
|
2231
|
+
w("select-user", F);
|
|
2232
|
+
}, Le = ({ event: F }) => {
|
|
2233
|
+
const z = F.target;
|
|
2234
|
+
l.value?.contains(z) || v.value?.contains(z) || w("click-outside", F);
|
|
2235
|
+
};
|
|
2236
|
+
at(() => f.highlightedIndex, (F) => {
|
|
2237
|
+
F < 0 || !v.value || me(() => {
|
|
2238
|
+
const z = v.value?.querySelector(".user-option.is-highlighted");
|
|
2239
|
+
z && z.scrollIntoView({
|
|
2240
|
+
block: "nearest",
|
|
2241
|
+
inline: "nearest",
|
|
2242
|
+
behavior: "auto"
|
|
2243
|
+
});
|
|
2244
|
+
});
|
|
2245
|
+
});
|
|
2246
|
+
const De = {
|
|
2247
|
+
t: o,
|
|
2248
|
+
slotContainerRef: l,
|
|
2249
|
+
contentContainerRef: v,
|
|
2250
|
+
props: f,
|
|
2251
|
+
emit: w,
|
|
2252
|
+
groupedUsers: b,
|
|
2253
|
+
hasMainOptions: B,
|
|
2254
|
+
hasRecentUsers: G,
|
|
2255
|
+
hasDropdownOptions: H,
|
|
2256
|
+
isHighlighted: ye,
|
|
2257
|
+
selectUser: Ne,
|
|
2258
|
+
handleClickOutside: Le,
|
|
2259
|
+
get Loading() {
|
|
2260
|
+
return qr;
|
|
2261
|
+
},
|
|
2262
|
+
get Popover() {
|
|
2263
|
+
return sr;
|
|
2264
|
+
},
|
|
2265
|
+
get UserRender() {
|
|
2266
|
+
return jn;
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
return Object.defineProperty(De, "__isScriptSetup", {
|
|
2270
|
+
enumerable: !1,
|
|
2271
|
+
value: !0
|
|
2272
|
+
}), De;
|
|
2273
|
+
}
|
|
2274
|
+
}), xa = { ref: "contentContainerRef" }, Aa = {
|
|
2275
|
+
key: 0,
|
|
2276
|
+
class: "no-data"
|
|
2277
|
+
}, ka = {
|
|
2278
|
+
key: 0,
|
|
2279
|
+
class: "dropdown-panel dropdown-panel-main"
|
|
2280
|
+
}, Ma = { class: "group-name" }, Pa = { class: "group-count" }, Ra = ["onClick"], Ba = {
|
|
2281
|
+
key: 1,
|
|
2282
|
+
class: "dropdown-panel dropdown-panel-recent"
|
|
2283
|
+
}, Na = { class: "group-name" }, La = { class: "group-count" }, Fa = ["onClick"], qa = { ref: "slotContainerRef" };
|
|
2284
|
+
function Ga(c, d, u, o, l, v) {
|
|
2285
|
+
return Z(), Yt(o.Popover, {
|
|
2286
|
+
arrow: !1,
|
|
2287
|
+
"ext-cls": "bk-user-selector-popover",
|
|
2288
|
+
"is-show": u.isShow,
|
|
2289
|
+
offset: { mainAxis: 4 },
|
|
2290
|
+
placement: "bottom-start",
|
|
2291
|
+
theme: "light",
|
|
2292
|
+
trigger: "manual",
|
|
2293
|
+
width: u.containerWidth,
|
|
2294
|
+
onClickoutside: o.handleClickOutside
|
|
2295
|
+
}, {
|
|
2296
|
+
content: ot(() => [Ae("div", xa, [Qe(o.Loading, {
|
|
2297
|
+
class: "dropdown-content",
|
|
2298
|
+
loading: u.loading,
|
|
2299
|
+
mode: "spin",
|
|
2300
|
+
size: "mini"
|
|
2301
|
+
}, {
|
|
2302
|
+
default: ot(() => [o.hasDropdownOptions ? (Z(), oe("div", {
|
|
2303
|
+
key: 1,
|
|
2304
|
+
class: It(["dropdown-panels", { "is-two-column": o.hasMainOptions && o.hasRecentUsers }])
|
|
2305
|
+
}, [o.hasMainOptions ? (Z(), oe("div", ka, [(Z(!0), oe(Ut, null, Dt(o.groupedUsers, (f, w) => (Z(), oe("div", {
|
|
2306
|
+
key: w,
|
|
2307
|
+
class: "user-group"
|
|
2308
|
+
}, [Object.keys(o.groupedUsers).length > 1 || f.some((b) => b.type === "userGroup") ? (Z(), oe("div", {
|
|
2309
|
+
key: 0,
|
|
2310
|
+
class: "group-header",
|
|
2311
|
+
onClick: d[0] || (d[0] = je(() => {
|
|
2312
|
+
}, ["prevent"]))
|
|
2313
|
+
}, [Ae("span", Ma, gt(w), 1), Ae("span", Pa, "(" + gt(f.length) + ")", 1)])) : se("v-if", !0), (Z(!0), oe(Ut, null, Dt(f, (b) => (Z(), oe("div", {
|
|
2314
|
+
key: b.id,
|
|
2315
|
+
class: It(["user-option", { "is-highlighted": o.isHighlighted(b) }]),
|
|
2316
|
+
onClick: je((B) => o.selectUser(b), ["prevent"]),
|
|
2317
|
+
onMousedown: d[1] || (d[1] = je(() => {
|
|
2318
|
+
}, ["prevent"]))
|
|
2319
|
+
}, [Qe(o.UserRender, {
|
|
2320
|
+
"avatar-base-url": u.avatarBaseUrl,
|
|
2321
|
+
"has-avatar": u.hasAvatar,
|
|
2322
|
+
render: u.renderListItem,
|
|
2323
|
+
"tenant-id": u.tenantId,
|
|
2324
|
+
tenants: u.tenants,
|
|
2325
|
+
user: b
|
|
2326
|
+
}, null, 8, [
|
|
2327
|
+
"avatar-base-url",
|
|
2328
|
+
"has-avatar",
|
|
2329
|
+
"render",
|
|
2330
|
+
"tenant-id",
|
|
2331
|
+
"tenants",
|
|
2332
|
+
"user"
|
|
2333
|
+
])], 42, Ra))), 128))]))), 128))])) : se("v-if", !0), o.hasRecentUsers ? (Z(), oe("div", Ba, [u.recentUsersName ? (Z(), oe("div", {
|
|
2334
|
+
key: 0,
|
|
2335
|
+
class: "group-header",
|
|
2336
|
+
onClick: d[2] || (d[2] = je(() => {
|
|
2337
|
+
}, ["prevent"]))
|
|
2338
|
+
}, [Ae("span", Na, gt(u.recentUsersName), 1), Ae("span", La, "(" + gt(u.recentUsers.length) + ")", 1)])) : se("v-if", !0), (Z(!0), oe(Ut, null, Dt(u.recentUsers, (f) => (Z(), oe("div", {
|
|
2339
|
+
key: f.id,
|
|
2340
|
+
class: It(["user-option", { "is-highlighted": o.isHighlighted(f) }]),
|
|
2341
|
+
onClick: je((w) => o.selectUser(f), ["prevent"]),
|
|
2342
|
+
onMousedown: d[3] || (d[3] = je(() => {
|
|
2343
|
+
}, ["prevent"]))
|
|
2344
|
+
}, [Qe(o.UserRender, {
|
|
2345
|
+
"avatar-base-url": u.avatarBaseUrl,
|
|
2346
|
+
"has-avatar": u.hasAvatar,
|
|
2347
|
+
render: u.renderListItem,
|
|
2348
|
+
"tenant-id": u.tenantId,
|
|
2349
|
+
tenants: u.tenants,
|
|
2350
|
+
user: f
|
|
2351
|
+
}, null, 8, [
|
|
2352
|
+
"avatar-base-url",
|
|
2353
|
+
"has-avatar",
|
|
2354
|
+
"render",
|
|
2355
|
+
"tenant-id",
|
|
2356
|
+
"tenants",
|
|
2357
|
+
"user"
|
|
2358
|
+
])], 42, Fa))), 128))])) : se("v-if", !0)], 2)) : (Z(), oe("div", Aa, [Ae("span", null, gt(u.emptyText), 1)]))]),
|
|
2359
|
+
_: 1
|
|
2360
|
+
}, 8, ["loading"])], 512)]),
|
|
2361
|
+
default: ot(() => [Ae("div", qa, [Nr(c.$slots, "default", {}, void 0, !0)], 512)]),
|
|
2362
|
+
_: 3
|
|
2363
|
+
}, 8, ["is-show", "width"]);
|
|
2364
|
+
}
|
|
2365
|
+
var za = /* @__PURE__ */ wn(Oa, [
|
|
2366
|
+
["render", Ga],
|
|
2367
|
+
["__scopeId", "data-v-9173accf"],
|
|
2368
|
+
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/selection-popover.vue"]
|
|
2369
|
+
]), ja = /* @__PURE__ */ Wt({
|
|
2370
|
+
name: "UserTag",
|
|
2371
|
+
__name: "user-tag",
|
|
2372
|
+
props: {
|
|
2373
|
+
active: {
|
|
2374
|
+
type: Boolean,
|
|
2375
|
+
required: !1
|
|
2376
|
+
},
|
|
2377
|
+
avatarBaseUrl: {
|
|
2378
|
+
type: String,
|
|
2379
|
+
required: !1
|
|
2380
|
+
},
|
|
2381
|
+
currentTenantId: {
|
|
2382
|
+
type: String,
|
|
2383
|
+
required: !0
|
|
2384
|
+
},
|
|
2385
|
+
draggable: {
|
|
2386
|
+
type: Boolean,
|
|
2387
|
+
required: !1
|
|
2388
|
+
},
|
|
2389
|
+
hasAvatar: {
|
|
2390
|
+
type: Boolean,
|
|
2391
|
+
required: !1
|
|
2392
|
+
},
|
|
2393
|
+
renderTag: {
|
|
2394
|
+
type: Function,
|
|
2395
|
+
required: !1
|
|
2396
|
+
},
|
|
2397
|
+
showTenant: {
|
|
2398
|
+
type: Boolean,
|
|
2399
|
+
required: !1
|
|
2400
|
+
},
|
|
2401
|
+
tenants: {
|
|
2402
|
+
type: Object,
|
|
2403
|
+
required: !0
|
|
2404
|
+
},
|
|
2405
|
+
user: {
|
|
2406
|
+
type: Object,
|
|
2407
|
+
required: !0
|
|
2408
|
+
}
|
|
2409
|
+
},
|
|
2410
|
+
emits: ["click", "close"],
|
|
2411
|
+
setup(c, { expose: d, emit: u }) {
|
|
2412
|
+
d();
|
|
2413
|
+
const o = u, f = {
|
|
2414
|
+
emit: o,
|
|
2415
|
+
handleClick: () => {
|
|
2416
|
+
o("click");
|
|
2417
|
+
},
|
|
2418
|
+
handleClose: () => {
|
|
2419
|
+
o("close");
|
|
2420
|
+
},
|
|
2421
|
+
get Tag() {
|
|
2422
|
+
return lr;
|
|
2423
|
+
},
|
|
2424
|
+
get UserRender() {
|
|
2425
|
+
return jn;
|
|
2426
|
+
}
|
|
2427
|
+
};
|
|
2428
|
+
return Object.defineProperty(f, "__isScriptSetup", {
|
|
2429
|
+
enumerable: !1,
|
|
2430
|
+
value: !0
|
|
2431
|
+
}), f;
|
|
2432
|
+
}
|
|
2433
|
+
});
|
|
2434
|
+
function Ka(c, d, u, o, l, v) {
|
|
2435
|
+
return Z(), Yt(o.Tag, {
|
|
2436
|
+
class: It(["user-tag", {
|
|
2437
|
+
draggable: u.draggable,
|
|
2438
|
+
active: u.active,
|
|
2439
|
+
"is-custom": u.user.type === "custom"
|
|
2440
|
+
}]),
|
|
2441
|
+
closable: "",
|
|
2442
|
+
disabled: "",
|
|
2443
|
+
onClick: je(o.handleClick, ["stop"]),
|
|
2444
|
+
onClose: o.handleClose
|
|
2445
|
+
}, {
|
|
2446
|
+
default: ot(() => [Qe(o.UserRender, {
|
|
2447
|
+
"avatar-base-url": u.avatarBaseUrl,
|
|
2448
|
+
"has-avatar": u.hasAvatar,
|
|
2449
|
+
render: u.renderTag,
|
|
2450
|
+
"tenant-id": u.currentTenantId,
|
|
2451
|
+
tenants: u.tenants,
|
|
2452
|
+
user: u.user
|
|
2453
|
+
}, null, 8, [
|
|
2454
|
+
"avatar-base-url",
|
|
2455
|
+
"has-avatar",
|
|
2456
|
+
"render",
|
|
2457
|
+
"tenant-id",
|
|
2458
|
+
"tenants",
|
|
2459
|
+
"user"
|
|
2460
|
+
])]),
|
|
2461
|
+
_: 1
|
|
2462
|
+
}, 8, ["class"]);
|
|
2463
|
+
}
|
|
2464
|
+
var Ha = /* @__PURE__ */ wn(ja, [
|
|
2465
|
+
["render", Ka],
|
|
2466
|
+
["__scopeId", "data-v-d1173d20"],
|
|
2467
|
+
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/user-tag.vue"]
|
|
2468
|
+
]), Ya = /* @__PURE__ */ Wt({
|
|
2469
|
+
name: "BkUserSelector",
|
|
2470
|
+
__name: "user-selector",
|
|
2471
|
+
props: {
|
|
2472
|
+
autoFocus: {
|
|
2473
|
+
type: Boolean,
|
|
2474
|
+
required: !1,
|
|
2475
|
+
default: !1
|
|
2476
|
+
},
|
|
2477
|
+
draggable: {
|
|
2478
|
+
type: Boolean,
|
|
2479
|
+
required: !1,
|
|
2480
|
+
default: !1
|
|
2481
|
+
},
|
|
2482
|
+
maxCount: {
|
|
2483
|
+
type: Number,
|
|
2484
|
+
required: !1,
|
|
2485
|
+
default: 0
|
|
2486
|
+
},
|
|
2487
|
+
modelValue: {
|
|
2488
|
+
type: [String, Array],
|
|
2489
|
+
required: !1,
|
|
2490
|
+
default: ""
|
|
2491
|
+
},
|
|
2492
|
+
multiple: {
|
|
2493
|
+
type: Boolean,
|
|
2494
|
+
required: !1,
|
|
2495
|
+
default: !1
|
|
2496
|
+
},
|
|
2497
|
+
resize: {
|
|
2498
|
+
type: Boolean,
|
|
2499
|
+
required: !1,
|
|
2500
|
+
default: !0
|
|
2501
|
+
},
|
|
2502
|
+
rows: {
|
|
2503
|
+
type: Number,
|
|
2504
|
+
required: !1,
|
|
2505
|
+
default: 4
|
|
2506
|
+
},
|
|
2507
|
+
type: {
|
|
2508
|
+
type: String,
|
|
2509
|
+
required: !1,
|
|
2510
|
+
default: "input"
|
|
2511
|
+
},
|
|
2512
|
+
allowCreate: {
|
|
2513
|
+
type: Boolean,
|
|
2514
|
+
required: !1,
|
|
2515
|
+
default: !1
|
|
2516
|
+
},
|
|
2517
|
+
allowCrossOriginCredentials: {
|
|
2518
|
+
type: Boolean,
|
|
2519
|
+
required: !1,
|
|
2520
|
+
default: !0
|
|
2521
|
+
},
|
|
2522
|
+
allowedApiOrigins: {
|
|
2523
|
+
type: Array,
|
|
2524
|
+
required: !1,
|
|
2525
|
+
default: () => []
|
|
2526
|
+
},
|
|
2527
|
+
allowPrivateApiHost: {
|
|
2528
|
+
type: Boolean,
|
|
2529
|
+
required: !1,
|
|
2530
|
+
default: !0
|
|
2531
|
+
},
|
|
2532
|
+
apiBaseUrl: {
|
|
2533
|
+
type: String,
|
|
2534
|
+
required: !0,
|
|
2535
|
+
default: ""
|
|
2536
|
+
},
|
|
2537
|
+
avatarBaseUrl: {
|
|
2538
|
+
type: String,
|
|
2539
|
+
required: !1,
|
|
2540
|
+
default: ""
|
|
2541
|
+
},
|
|
2542
|
+
currentUserId: {
|
|
2543
|
+
type: String,
|
|
2544
|
+
required: !1,
|
|
2545
|
+
default: ""
|
|
2546
|
+
},
|
|
2547
|
+
disabled: {
|
|
2548
|
+
type: Boolean,
|
|
2549
|
+
required: !1,
|
|
2550
|
+
default: !1
|
|
2551
|
+
},
|
|
2552
|
+
emptyText: {
|
|
2553
|
+
type: String,
|
|
2554
|
+
required: !1,
|
|
2555
|
+
default: ""
|
|
2556
|
+
},
|
|
2557
|
+
enableMultiTenantMode: {
|
|
2558
|
+
type: Boolean,
|
|
2559
|
+
required: !1,
|
|
2560
|
+
default: !0
|
|
2561
|
+
},
|
|
2562
|
+
exactSearchKey: {
|
|
2563
|
+
type: String,
|
|
2564
|
+
required: !1,
|
|
2565
|
+
default: Et
|
|
2566
|
+
},
|
|
2567
|
+
excludeUserIds: {
|
|
2568
|
+
type: Array,
|
|
2569
|
+
required: !1,
|
|
2570
|
+
default: () => []
|
|
2571
|
+
},
|
|
2572
|
+
freePaste: {
|
|
2573
|
+
type: Boolean,
|
|
2574
|
+
required: !1,
|
|
2575
|
+
default: !1
|
|
2576
|
+
},
|
|
2577
|
+
hasAvatar: {
|
|
2578
|
+
type: Boolean,
|
|
2579
|
+
required: !1,
|
|
2580
|
+
default: !1
|
|
2581
|
+
},
|
|
2582
|
+
placeholder: {
|
|
2583
|
+
type: String,
|
|
2584
|
+
required: !1,
|
|
2585
|
+
default: ""
|
|
2586
|
+
},
|
|
2587
|
+
recentUserIds: {
|
|
2588
|
+
type: Array,
|
|
2589
|
+
required: !1,
|
|
2590
|
+
default: () => []
|
|
2591
|
+
},
|
|
2592
|
+
renderListItem: {
|
|
2593
|
+
type: Function,
|
|
2594
|
+
required: !1
|
|
2595
|
+
},
|
|
2596
|
+
renderTag: {
|
|
2597
|
+
type: Function,
|
|
2598
|
+
required: !1
|
|
2599
|
+
},
|
|
2600
|
+
tenantId: {
|
|
2601
|
+
type: String,
|
|
2602
|
+
required: !1,
|
|
2603
|
+
default: "default"
|
|
2604
|
+
},
|
|
2605
|
+
userGroup: {
|
|
2606
|
+
type: Array,
|
|
2607
|
+
required: !1,
|
|
2608
|
+
default: () => []
|
|
2609
|
+
},
|
|
2610
|
+
userGroupName: {
|
|
2611
|
+
type: String,
|
|
2612
|
+
required: !1,
|
|
2613
|
+
default: ""
|
|
2614
|
+
}
|
|
2615
|
+
},
|
|
2616
|
+
emits: [
|
|
2617
|
+
"blur",
|
|
2618
|
+
"change",
|
|
2619
|
+
"dragEnd",
|
|
2620
|
+
"dragStart",
|
|
2621
|
+
"error",
|
|
2622
|
+
"focus",
|
|
2623
|
+
"unauthorized",
|
|
2624
|
+
"update:modelValue"
|
|
2625
|
+
],
|
|
2626
|
+
setup(c, { expose: d, emit: u }) {
|
|
2627
|
+
const { t: o } = zn();
|
|
2628
|
+
Fr({ prefix: "bk" });
|
|
2629
|
+
const l = c, v = u, f = (p) => {
|
|
2630
|
+
v("error", p);
|
|
2631
|
+
}, w = (p) => {
|
|
2632
|
+
v("unauthorized", p);
|
|
2633
|
+
};
|
|
2634
|
+
ta(l.apiBaseUrl, l.tenantId, l.allowedApiOrigins, l.allowPrivateApiHost, l.allowCrossOriginCredentials, {
|
|
2635
|
+
onError: f,
|
|
2636
|
+
onUnauthorized: w
|
|
2637
|
+
});
|
|
2638
|
+
const { tenants: b } = ya(l.apiBaseUrl, l.tenantId, l.enableMultiTenantMode), { searchResults: B, loading: G, searchQuery: H, clearSearch: ye, handleSearchInput: Ne } = _a(l.apiBaseUrl, l.tenantId, l.enableMultiTenantMode), { fetchCurrentUser: Le } = sa({
|
|
2639
|
+
apiBaseUrl: l.apiBaseUrl,
|
|
2640
|
+
tenantId: l.tenantId,
|
|
2641
|
+
currentUserId: l.currentUserId || "",
|
|
2642
|
+
exactSearchKey: l.exactSearchKey,
|
|
2643
|
+
enableMultiTenantMode: l.enableMultiTenantMode
|
|
2644
|
+
}), De = te(null), F = te(null), z = te(null), Se = te(null), vt = te(null), $ = te(null), X = te(!1), D = te(-1), ue = te(null), x = te([]), O = te(0), Y = te(-1), be = te([]);
|
|
2645
|
+
let ne = 0, Ze = [];
|
|
2646
|
+
const U = te([]), S = re(() => l.type === "textarea"), ke = te(l.rows * 32), Vt = re(() => {
|
|
2647
|
+
if (S.value)
|
|
2648
|
+
return {
|
|
2649
|
+
height: `${ke.value}px`,
|
|
2650
|
+
resize: l.resize ? "vertical" : "none",
|
|
2651
|
+
overflowY: "auto"
|
|
2652
|
+
};
|
|
2653
|
+
}), Te = re(() => S.value ? U.value : x.value), j = re(() => l.multiple ? Array.isArray(l.modelValue) ? l.modelValue : [] : l.modelValue ? [l.modelValue] : []), Qt = re(() => l.placeholder || o("请输入人员名称搜索")), Je = re(() => l.userGroupName || o("用户群组")), Tt = re(() => l.emptyText || o("无匹配人员")), ee = re(() => o("最近选择")), mt = re(() => U.value.map((p) => p.id)), Zt = (p, _) => _ ? [
|
|
2654
|
+
p.id,
|
|
2655
|
+
p.name,
|
|
2656
|
+
p.bk_username,
|
|
2657
|
+
p.username,
|
|
2658
|
+
p.login_name,
|
|
2659
|
+
p.display_name,
|
|
2660
|
+
p.full_name
|
|
2661
|
+
].some((E) => String(E || "").includes(_)) : !0, Ee = (p) => p.split(",").map((_) => _.trim()).filter(Boolean), yt = (p, _, E) => p.find((N) => {
|
|
2662
|
+
if (N.id === _) return !0;
|
|
2663
|
+
const _e = N;
|
|
2664
|
+
return E.some((tt) => String(_e[tt] || "") === _);
|
|
2665
|
+
}), $e = (p, _, E) => _.map((N) => yt(p, N, E)).filter(Boolean), Ke = async (p) => {
|
|
2666
|
+
const _ = Ee(l.exactSearchKey), E = Xt(await mn({
|
|
2667
|
+
apiBaseUrl: l.apiBaseUrl,
|
|
2668
|
+
tenantId: l.tenantId,
|
|
2669
|
+
exactSearchKey: l.exactSearchKey,
|
|
2670
|
+
usersList: p,
|
|
2671
|
+
enableMultiTenantMode: l.enableMultiTenantMode
|
|
2672
|
+
}), l.enableMultiTenantMode), N = p.filter((ct) => !yt(E, ct, _));
|
|
2673
|
+
if (N.length === 0 || l.exactSearchKey === "bk_username") return $e(E, p, _);
|
|
2674
|
+
const _e = Xt(await mn({
|
|
2675
|
+
apiBaseUrl: l.apiBaseUrl,
|
|
2676
|
+
tenantId: l.tenantId,
|
|
2677
|
+
exactSearchKey: Et,
|
|
2678
|
+
usersList: N,
|
|
2679
|
+
enableMultiTenantMode: l.enableMultiTenantMode
|
|
2680
|
+
}), l.enableMultiTenantMode), tt = [...E];
|
|
2681
|
+
return _e.forEach((ct) => {
|
|
2682
|
+
tt.some((dt) => dt.id === ct.id) || tt.push(ct);
|
|
2683
|
+
}), $e(tt, p, [.../* @__PURE__ */ new Set([..._, Et])]);
|
|
2684
|
+
}, it = re(() => !l.maxCount || l.maxCount <= 0 ? !1 : U.value.length >= l.maxCount), _n = re(() => it.value || !!l.currentUserId && U.value.some((p) => p[l.exactSearchKey] === l.currentUserId)), Jt = re(() => ({
|
|
2685
|
+
avatarBaseUrl: l.avatarBaseUrl,
|
|
2686
|
+
currentTenantId: l.tenantId,
|
|
2687
|
+
hasAvatar: l.hasAvatar,
|
|
2688
|
+
renderTag: l.renderTag,
|
|
2689
|
+
tenants: b.value
|
|
2690
|
+
})), { filteredUserGroup: lt, filterOptions: Ot, createCustomUser: bt } = Ca({
|
|
2691
|
+
selectedUserIds: mt,
|
|
2692
|
+
excludeUserIds: nr(l, "excludeUserIds"),
|
|
2693
|
+
userGroup: nr(l, "userGroup"),
|
|
2694
|
+
searchQuery: H
|
|
2695
|
+
}), { handlePaste: xt } = va({
|
|
2696
|
+
apiBaseUrl: l.apiBaseUrl,
|
|
2697
|
+
tenantId: l.tenantId,
|
|
2698
|
+
searchQuery: H,
|
|
2699
|
+
selectedUsers: U,
|
|
2700
|
+
allowCreate: l.allowCreate,
|
|
2701
|
+
freePaste: l.freePaste,
|
|
2702
|
+
enableMultiTenantMode: l.enableMultiTenantMode,
|
|
2703
|
+
maxCount: l.maxCount,
|
|
2704
|
+
onAddUser: Xe,
|
|
2705
|
+
onBatchAddUsers: l.multiple ? Me : void 0
|
|
2706
|
+
}), ae = re(() => Ot(B.value)), $t = re(() => {
|
|
2707
|
+
const p = lt.value.map((N) => ({
|
|
2708
|
+
...N,
|
|
2709
|
+
tenantId: "",
|
|
2710
|
+
type: Be.USER_GROUP
|
|
2711
|
+
})), _ = ae.value.filter((N) => N.data_source_type !== Be.VIRTUAL), E = ae.value.filter((N) => N.data_source_type === Be.VIRTUAL);
|
|
2712
|
+
return [
|
|
2713
|
+
...p,
|
|
2714
|
+
..._,
|
|
2715
|
+
...E
|
|
2716
|
+
];
|
|
2717
|
+
}), At = re(() => {
|
|
2718
|
+
const p = H.value.trim();
|
|
2719
|
+
return be.value.filter((_) => !mt.value.includes(_.id)).filter((_) => !l.excludeUserIds.includes(_.id)).filter((_) => Zt(_, p));
|
|
2720
|
+
}), wt = re(() => X.value && (lt.value.length > 0 || At.value.length > 0 || H.value.trim() !== "")), we = re(() => [...$t.value, ...At.value]), kt = re(() => {
|
|
2721
|
+
const p = H.value;
|
|
2722
|
+
if (!p) return "20px";
|
|
2723
|
+
const _ = p.split("").reduce((E, N) => E + (/[\u4e00-\u9fa5]/.test(N) ? 12 : 8), 0);
|
|
2724
|
+
return `${Math.max(20, _ + 4)}px`;
|
|
2725
|
+
}), Fe = async () => {
|
|
2726
|
+
const p = j.value;
|
|
2727
|
+
if (p.length === 0) {
|
|
2728
|
+
U.value = [];
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
let _ = [];
|
|
2732
|
+
l.userGroup.length > 0 && (_ = l.userGroup.filter((E) => p.includes(E.id)).map((E) => ({
|
|
2733
|
+
...E,
|
|
2734
|
+
tenantId: "",
|
|
2735
|
+
type: Be.USER_GROUP
|
|
2736
|
+
})));
|
|
2737
|
+
try {
|
|
2738
|
+
const E = [..._, ...await Ke(p)];
|
|
2739
|
+
if (l.allowCreate) {
|
|
2740
|
+
const N = [.../* @__PURE__ */ new Set([...Ee(l.exactSearchKey), Et])];
|
|
2741
|
+
E.push(...p.filter((_e) => !yt(E, _e, N)).map((_e) => ({
|
|
2742
|
+
id: _e,
|
|
2743
|
+
name: _e,
|
|
2744
|
+
type: Be.CUSTOM,
|
|
2745
|
+
tenantId: ""
|
|
2746
|
+
})));
|
|
2747
|
+
}
|
|
2748
|
+
U.value = $e(E, p, [.../* @__PURE__ */ new Set([...Ee(l.exactSearchKey), Et])]);
|
|
2749
|
+
} catch (E) {
|
|
2750
|
+
console.error("获取选中用户信息失败:", E), U.value = [];
|
|
2751
|
+
}
|
|
2752
|
+
}, He = async () => {
|
|
2753
|
+
const p = l.recentUserIds.filter(Boolean), _ = ++ne;
|
|
2754
|
+
if (Ze = [...p], p.length === 0) {
|
|
2755
|
+
be.value = [];
|
|
2756
|
+
return;
|
|
2757
|
+
}
|
|
2758
|
+
try {
|
|
2759
|
+
const E = (await Ke(p)).filter((N) => N.data_source_type !== Be.VIRTUAL && N.type !== Be.USER_GROUP);
|
|
2760
|
+
if (_ !== ne) return;
|
|
2761
|
+
be.value = E;
|
|
2762
|
+
} catch (E) {
|
|
2763
|
+
if (_ !== ne) return;
|
|
2764
|
+
console.error("获取最近选择用户信息失败:", E), be.value = [];
|
|
2765
|
+
}
|
|
2766
|
+
};
|
|
2767
|
+
function Me(p) {
|
|
2768
|
+
if (U.value = p, l.multiple)
|
|
2769
|
+
v("update:modelValue", p.map((_) => _.id)), v("change", p);
|
|
2770
|
+
else {
|
|
2771
|
+
const _ = p.length > 0 ? p[0] : null;
|
|
2772
|
+
v("update:modelValue", _ ? _.id : ""), v("change", _);
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
const de = () => {
|
|
2776
|
+
!l.draggable || !l.multiple || !F.value || (ue.value && ue.value.destroy(), ue.value = new Vr.default(F.value, {
|
|
2777
|
+
animation: 150,
|
|
2778
|
+
draggable: ".tag-wrapper",
|
|
2779
|
+
onStart: (p) => {
|
|
2780
|
+
v("dragStart", p);
|
|
2781
|
+
},
|
|
2782
|
+
onEnd: (p) => {
|
|
2783
|
+
const { oldIndex: _, newIndex: E } = p;
|
|
2784
|
+
if (_ === E || _ === void 0 || E === void 0) return;
|
|
2785
|
+
const N = [...U.value], [_e] = N.splice(_, 1);
|
|
2786
|
+
N.splice(E, 0, _e), Me(N), v("dragEnd", p);
|
|
2787
|
+
}
|
|
2788
|
+
}));
|
|
2789
|
+
}, ie = () => {
|
|
2790
|
+
if (!U.value.length) {
|
|
2791
|
+
x.value = [], O.value = 0;
|
|
2792
|
+
return;
|
|
2793
|
+
}
|
|
2794
|
+
if (!z.value) {
|
|
2795
|
+
x.value = [...U.value], O.value = 0;
|
|
2796
|
+
return;
|
|
2797
|
+
}
|
|
2798
|
+
const p = z.value.offsetWidth, _ = z.value.querySelectorAll(".user-tag");
|
|
2799
|
+
if (_.length !== U.value.length) {
|
|
2800
|
+
x.value = [...U.value], O.value = 0, me(ie);
|
|
2801
|
+
return;
|
|
2802
|
+
}
|
|
2803
|
+
const E = wa(z.value, _, p - 100);
|
|
2804
|
+
x.value = U.value.slice(0, E), O.value = Math.max(0, U.value.length - E);
|
|
2805
|
+
}, y = () => {
|
|
2806
|
+
X.value = !0, D.value = U.value.length - 1, me(() => pe());
|
|
2807
|
+
}, K = () => {
|
|
2808
|
+
X.value || me(ie);
|
|
2809
|
+
}, k = () => {
|
|
2810
|
+
X.value && v("blur"), X.value = !1, D.value = U.value.length - 1, ye(), Y.value = -1, K();
|
|
2811
|
+
}, W = (p) => {
|
|
2812
|
+
const _ = p.target, E = De.value;
|
|
2813
|
+
E?.contains(_) || E === _ || k();
|
|
2814
|
+
}, Ye = () => {
|
|
2815
|
+
D.value = U.value.length - 1, me(() => pe());
|
|
2816
|
+
}, pe = () => {
|
|
2817
|
+
D.value === -1 && U.value.length > 0 ? Se.value?.focus() : D.value >= U.value.length - 1 ? $.value?.focus() : vt.value?.[0]?.focus();
|
|
2818
|
+
}, J = (p) => {
|
|
2819
|
+
D.value = p, me(() => pe());
|
|
2820
|
+
}, qe = () => {
|
|
2821
|
+
v("focus"), X.value = !0;
|
|
2822
|
+
}, et = () => {
|
|
2823
|
+
Ne(H.value);
|
|
2824
|
+
}, ge = async () => {
|
|
2825
|
+
if (!l.currentUserId || U.value.some((_) => _[l.exactSearchKey] === l.currentUserId) || l.multiple && it.value) return;
|
|
2826
|
+
const p = await Le();
|
|
2827
|
+
p && (l.multiple ? U.value.some((_) => _.id === p.id) || Me([...U.value, p]) : Me([p]), ye(), Y.value = -1, X.value = !0, D.value = U.value.length - 1, me(() => pe()));
|
|
2828
|
+
}, st = async (p) => {
|
|
2829
|
+
await xt(p), D.value = U.value.length - 1, me(() => pe());
|
|
2830
|
+
}, Ge = (p) => {
|
|
2831
|
+
if (p.key === "Backspace" && !H.value && U.value.length > 0) {
|
|
2832
|
+
if (D.value >= 0) {
|
|
2833
|
+
const _ = U.value[D.value], E = D.value > 0 ? D.value - 1 : -1;
|
|
2834
|
+
Me(U.value.filter((N) => N.id !== _.id)), D.value = E, K(), me(() => pe());
|
|
2835
|
+
}
|
|
2836
|
+
return;
|
|
2837
|
+
}
|
|
2838
|
+
if (p.key === "ArrowDown" && wt.value && we.value.length > 0) {
|
|
2839
|
+
p.preventDefault();
|
|
2840
|
+
const _ = we.value.length - 1;
|
|
2841
|
+
Y.value = Math.min(Y.value + 1, _);
|
|
2842
|
+
return;
|
|
2843
|
+
}
|
|
2844
|
+
if (p.key === "ArrowUp" && wt.value && we.value.length > 0) {
|
|
2845
|
+
p.preventDefault(), Y.value = Math.max(Y.value - 1, 0);
|
|
2846
|
+
return;
|
|
2847
|
+
}
|
|
2848
|
+
if (p.key === "Enter") {
|
|
2849
|
+
l.allowCreate && H.value ? Xe(bt(H.value)) : Y.value >= 0 && we.value[Y.value] && Xe(we.value[Y.value]);
|
|
2850
|
+
return;
|
|
2851
|
+
}
|
|
2852
|
+
if (p.key === "ArrowLeft" && !H.value && U.value.length > 0) {
|
|
2853
|
+
p.preventDefault(), D.value === 0 ? D.value = -1 : D.value > 0 && D.value--, me(() => pe());
|
|
2854
|
+
return;
|
|
2855
|
+
}
|
|
2856
|
+
if (p.key === "ArrowRight" && !H.value && U.value.length > 0) {
|
|
2857
|
+
p.preventDefault(), D.value === -1 ? D.value = 0 : D.value < U.value.length - 1 && D.value++, me(() => pe());
|
|
2858
|
+
return;
|
|
2859
|
+
}
|
|
2860
|
+
};
|
|
2861
|
+
function Xe(p) {
|
|
2862
|
+
if (p?.id) {
|
|
2863
|
+
if (l.multiple && it.value) {
|
|
2864
|
+
ye(), Y.value = -1;
|
|
2865
|
+
return;
|
|
2866
|
+
}
|
|
2867
|
+
if (!l.multiple)
|
|
2868
|
+
Me([p]), D.value = 0;
|
|
2869
|
+
else if (!U.value.some((_) => _.id === p.id)) {
|
|
2870
|
+
let _, E;
|
|
2871
|
+
D.value === -1 ? (_ = [p, ...U.value], E = 0) : (_ = [
|
|
2872
|
+
...U.value.slice(0, D.value + 1),
|
|
2873
|
+
p,
|
|
2874
|
+
...U.value.slice(D.value + 1)
|
|
2875
|
+
], E = D.value + 1), Me(_), D.value = E;
|
|
2876
|
+
}
|
|
2877
|
+
ye(), Y.value = -1, X.value = !0, me(() => pe());
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
const ce = (p) => {
|
|
2881
|
+
if (!p?.id) return;
|
|
2882
|
+
const _ = U.value.findIndex((N) => N.id === p.id), E = U.value.filter((N) => N.id !== p.id);
|
|
2883
|
+
Me(E), E.length === 0 ? D.value = -1 : D.value > _ ? D.value-- : D.value >= E.length && (D.value = E.length - 1), K();
|
|
2884
|
+
};
|
|
2885
|
+
at(U, () => {
|
|
2886
|
+
K();
|
|
2887
|
+
}, { deep: !0 }), at(X, (p) => {
|
|
2888
|
+
if (S.value) {
|
|
2889
|
+
const _ = p ? z.value : De.value?.querySelector(".tags-container.focused");
|
|
2890
|
+
_ && _.offsetHeight > 0 && (ke.value = _.offsetHeight);
|
|
2891
|
+
}
|
|
2892
|
+
p && me(() => de());
|
|
2893
|
+
}), at(we, (p) => {
|
|
2894
|
+
p.length > 0 && wt.value ? Y.value = 0 : Y.value = -1;
|
|
2895
|
+
}), at(() => l.userGroup, () => {
|
|
2896
|
+
Fe();
|
|
2897
|
+
}), at(() => l.recentUserIds, () => {
|
|
2898
|
+
const p = l.recentUserIds.filter(Boolean);
|
|
2899
|
+
Ze.length === p.length && Ze.every((_, E) => _ === p[E]) || He();
|
|
2900
|
+
}, { deep: !0 }), at(() => l.modelValue, () => {
|
|
2901
|
+
const p = U.value.map((E) => E.id), _ = j.value;
|
|
2902
|
+
(p.length !== _.length || !p.every((E, N) => E === _[N])) && Fe();
|
|
2903
|
+
}, { deep: !0 }), ma(De, () => {
|
|
2904
|
+
K();
|
|
2905
|
+
});
|
|
2906
|
+
let Pe;
|
|
2907
|
+
or(() => {
|
|
2908
|
+
Pe = Promise.all([Fe(), He()]).then(() => {
|
|
2909
|
+
});
|
|
2910
|
+
}), Rr(async () => {
|
|
2911
|
+
de(), me(ie), l.autoFocus && !l.disabled && (await Pe, await me(), y());
|
|
2912
|
+
}), ir(() => {
|
|
2913
|
+
ue.value?.destroy();
|
|
2914
|
+
}), d({
|
|
2915
|
+
focus: y,
|
|
2916
|
+
blur: k
|
|
2917
|
+
});
|
|
2918
|
+
const ut = {
|
|
2919
|
+
t: o,
|
|
2920
|
+
props: l,
|
|
2921
|
+
emit: v,
|
|
2922
|
+
handleApiError: f,
|
|
2923
|
+
handleApiUnauthorized: w,
|
|
2924
|
+
tenants: b,
|
|
2925
|
+
searchResults: B,
|
|
2926
|
+
searchLoading: G,
|
|
2927
|
+
searchQuery: H,
|
|
2928
|
+
clearSearch: ye,
|
|
2929
|
+
handleSearchInput: Ne,
|
|
2930
|
+
fetchCurrentUser: Le,
|
|
2931
|
+
containerRef: De,
|
|
2932
|
+
sortableContainerRef: F,
|
|
2933
|
+
collapsedContainerRef: z,
|
|
2934
|
+
frontInputRef: Se,
|
|
2935
|
+
inlineInputRef: vt,
|
|
2936
|
+
lastInputRef: $,
|
|
2937
|
+
isFocused: X,
|
|
2938
|
+
activeTagIndex: D,
|
|
2939
|
+
sortableInstance: ue,
|
|
2940
|
+
visibleUsers: x,
|
|
2941
|
+
hiddenCount: O,
|
|
2942
|
+
highlightedIndex: Y,
|
|
2943
|
+
recentUsers: be,
|
|
2944
|
+
get recentUsersRequestId() {
|
|
2945
|
+
return ne;
|
|
2946
|
+
},
|
|
2947
|
+
set recentUsersRequestId(p) {
|
|
2948
|
+
ne = p;
|
|
2949
|
+
},
|
|
2950
|
+
get recentUserIdsSnapshot() {
|
|
2951
|
+
return Ze;
|
|
2952
|
+
},
|
|
2953
|
+
set recentUserIdsSnapshot(p) {
|
|
2954
|
+
Ze = p;
|
|
2955
|
+
},
|
|
2956
|
+
selectedUsers: U,
|
|
2957
|
+
isTextareaMode: S,
|
|
2958
|
+
textareaHeight: ke,
|
|
2959
|
+
textareaStyle: Vt,
|
|
2960
|
+
collapsedDisplayUsers: Te,
|
|
2961
|
+
modelValueIds: j,
|
|
2962
|
+
computedPlaceholder: Qt,
|
|
2963
|
+
computedUserGroupName: Je,
|
|
2964
|
+
computedEmptyText: Tt,
|
|
2965
|
+
computedRecentUsersName: ee,
|
|
2966
|
+
selectedUserIds: mt,
|
|
2967
|
+
isUserMatchedByQuery: Zt,
|
|
2968
|
+
getLookupFields: Ee,
|
|
2969
|
+
findUserByLookupId: yt,
|
|
2970
|
+
sortUsersByLookupIds: $e,
|
|
2971
|
+
lookupFormattedUsersByIds: Ke,
|
|
2972
|
+
isMaxCountReached: it,
|
|
2973
|
+
isMeTagDisabled: _n,
|
|
2974
|
+
userTagCommonProps: Jt,
|
|
2975
|
+
filteredUserGroup: lt,
|
|
2976
|
+
filterOptions: Ot,
|
|
2977
|
+
createCustomUser: bt,
|
|
2978
|
+
handlePaste: xt,
|
|
2979
|
+
displayOptions: ae,
|
|
2980
|
+
mainNavigableUsers: $t,
|
|
2981
|
+
filteredRecentUsers: At,
|
|
2982
|
+
showDropdown: wt,
|
|
2983
|
+
flatOptions: we,
|
|
2984
|
+
inputWidth: kt,
|
|
2985
|
+
initSelectedUsers: Fe,
|
|
2986
|
+
initRecentUsers: He,
|
|
2987
|
+
updateSelectedUsers: Me,
|
|
2988
|
+
initSortable: de,
|
|
2989
|
+
calculateVisibleUsers: ie,
|
|
2990
|
+
handleFocus: y,
|
|
2991
|
+
scheduleVisibleUsersCalculation: K,
|
|
2992
|
+
blur: k,
|
|
2993
|
+
handleClickOutside: W,
|
|
2994
|
+
handleContainerClick: Ye,
|
|
2995
|
+
focusCurrentInput: pe,
|
|
2996
|
+
handleTagClick: J,
|
|
2997
|
+
handleInputFocus: qe,
|
|
2998
|
+
handleInput: et,
|
|
2999
|
+
addCurrentUser: ge,
|
|
3000
|
+
onPaste: st,
|
|
3001
|
+
handleKeyDown: Ge,
|
|
3002
|
+
addUser: Xe,
|
|
3003
|
+
removeUser: ce,
|
|
3004
|
+
get initPromise() {
|
|
3005
|
+
return Pe;
|
|
3006
|
+
},
|
|
3007
|
+
set initPromise(p) {
|
|
3008
|
+
Pe = p;
|
|
3009
|
+
},
|
|
3010
|
+
get Popover() {
|
|
3011
|
+
return sr;
|
|
3012
|
+
},
|
|
3013
|
+
get Tag() {
|
|
3014
|
+
return lr;
|
|
3015
|
+
},
|
|
3016
|
+
MeTag: Ia,
|
|
3017
|
+
SelectionPopover: za,
|
|
3018
|
+
get UserRender() {
|
|
3019
|
+
return jn;
|
|
3020
|
+
},
|
|
3021
|
+
UserTag: Ha
|
|
3022
|
+
};
|
|
3023
|
+
return Object.defineProperty(ut, "__isScriptSetup", {
|
|
3024
|
+
enumerable: !1,
|
|
3025
|
+
value: !0
|
|
3026
|
+
}), ut;
|
|
3027
|
+
}
|
|
3028
|
+
}), Xa = {
|
|
3029
|
+
ref: "sortableContainerRef",
|
|
3030
|
+
class: "tag-list"
|
|
3031
|
+
}, Wa = ["placeholder"], Va = { class: "hidden-users" }, Qa = ["placeholder"];
|
|
3032
|
+
function Za(c, d, u, o, l, v) {
|
|
3033
|
+
return Z(), oe("div", {
|
|
3034
|
+
ref: "containerRef",
|
|
3035
|
+
class: It(["bk-user-selector", {
|
|
3036
|
+
"is-disabled": u.disabled,
|
|
3037
|
+
"is-textarea": o.isTextareaMode
|
|
3038
|
+
}])
|
|
3039
|
+
}, [se(" 下拉选项列表 "), Qe(o.SelectionPopover, {
|
|
3040
|
+
"avatar-base-url": u.avatarBaseUrl,
|
|
3041
|
+
"container-width": o.containerRef ? o.containerRef.offsetWidth : "auto",
|
|
3042
|
+
"empty-text": o.computedEmptyText,
|
|
3043
|
+
"flat-options": o.flatOptions,
|
|
3044
|
+
"has-avatar": u.hasAvatar,
|
|
3045
|
+
"highlighted-index": o.highlightedIndex,
|
|
3046
|
+
"is-show": o.showDropdown,
|
|
3047
|
+
loading: o.searchLoading,
|
|
3048
|
+
options: o.displayOptions,
|
|
3049
|
+
"recent-users": o.filteredRecentUsers,
|
|
3050
|
+
"recent-users-name": o.computedRecentUsersName,
|
|
3051
|
+
"render-list-item": u.renderListItem,
|
|
3052
|
+
"search-query": o.searchQuery,
|
|
3053
|
+
"tenant-id": u.tenantId,
|
|
3054
|
+
tenants: o.tenants,
|
|
3055
|
+
"user-group": o.filteredUserGroup,
|
|
3056
|
+
"user-group-name": o.computedUserGroupName,
|
|
3057
|
+
onClickOutside: o.handleClickOutside,
|
|
3058
|
+
onSelectUser: o.addUser
|
|
3059
|
+
}, {
|
|
3060
|
+
default: ot(() => [
|
|
3061
|
+
se(" 聚焦状态 - 可编辑模式 "),
|
|
3062
|
+
St(Ae("div", {
|
|
3063
|
+
class: "tags-container focused",
|
|
3064
|
+
style: hn(o.textareaStyle),
|
|
3065
|
+
onClick: je(o.handleContainerClick, ["stop"])
|
|
3066
|
+
}, [se(" 用户标签列表 "), Ae("div", Xa, [
|
|
3067
|
+
se(" 在第一个标签之前的输入框 "),
|
|
3068
|
+
o.activeTagIndex === -1 && o.selectedUsers.length > 0 ? St((Z(), oe("input", {
|
|
3069
|
+
key: 0,
|
|
3070
|
+
ref: "frontInputRef",
|
|
3071
|
+
"onUpdate:modelValue": d[0] || (d[0] = (f) => o.searchQuery = f),
|
|
3072
|
+
autofocus: "",
|
|
3073
|
+
class: "search-input input-inline",
|
|
3074
|
+
style: hn({ width: o.inputWidth }),
|
|
3075
|
+
onFocus: o.handleInputFocus,
|
|
3076
|
+
onInput: o.handleInput,
|
|
3077
|
+
onKeydown: o.handleKeyDown,
|
|
3078
|
+
onPaste: o.onPaste
|
|
3079
|
+
}, null, 36)), [[pn, o.searchQuery]]) : se("v-if", !0),
|
|
3080
|
+
(Z(!0), oe(Ut, null, Dt(o.selectedUsers, (f, w) => (Z(), oe("div", {
|
|
3081
|
+
key: f.id,
|
|
3082
|
+
class: "tag-wrapper"
|
|
3083
|
+
}, [
|
|
3084
|
+
Qe(o.UserTag, er({ ref_for: !0 }, o.userTagCommonProps, {
|
|
3085
|
+
active: w === o.activeTagIndex,
|
|
3086
|
+
draggable: u.draggable && u.multiple,
|
|
3087
|
+
user: f,
|
|
3088
|
+
onClick: (b) => o.handleTagClick(w),
|
|
3089
|
+
onClose: (b) => o.removeUser(f)
|
|
3090
|
+
}), null, 16, [
|
|
3091
|
+
"active",
|
|
3092
|
+
"draggable",
|
|
3093
|
+
"user",
|
|
3094
|
+
"onClick",
|
|
3095
|
+
"onClose"
|
|
3096
|
+
]),
|
|
3097
|
+
se(" 在当前激活标签后插入输入框 "),
|
|
3098
|
+
w === o.activeTagIndex && o.activeTagIndex !== o.selectedUsers.length - 1 ? St((Z(), oe("input", {
|
|
3099
|
+
key: 0,
|
|
3100
|
+
ref_for: !0,
|
|
3101
|
+
ref: "inlineInputRef",
|
|
3102
|
+
"onUpdate:modelValue": d[1] || (d[1] = (b) => o.searchQuery = b),
|
|
3103
|
+
autofocus: "",
|
|
3104
|
+
class: "search-input input-inline",
|
|
3105
|
+
style: hn({ width: o.inputWidth }),
|
|
3106
|
+
onFocus: o.handleInputFocus,
|
|
3107
|
+
onInput: o.handleInput,
|
|
3108
|
+
onKeydown: o.handleKeyDown,
|
|
3109
|
+
onPaste: o.onPaste
|
|
3110
|
+
}, null, 36)), [[pn, o.searchQuery]]) : se("v-if", !0)
|
|
3111
|
+
]))), 128)),
|
|
3112
|
+
se(" 最后一个输入框(末尾位置或无用户时显示) "),
|
|
3113
|
+
o.activeTagIndex >= o.selectedUsers.length - 1 ? St((Z(), oe("input", {
|
|
3114
|
+
key: 1,
|
|
3115
|
+
ref: "lastInputRef",
|
|
3116
|
+
"onUpdate:modelValue": d[2] || (d[2] = (f) => o.searchQuery = f),
|
|
3117
|
+
autofocus: "",
|
|
3118
|
+
class: "search-input input-last",
|
|
3119
|
+
placeholder: o.selectedUsers.length ? "" : o.computedPlaceholder,
|
|
3120
|
+
onFocus: o.handleInputFocus,
|
|
3121
|
+
onInput: o.handleInput,
|
|
3122
|
+
onKeydown: o.handleKeyDown,
|
|
3123
|
+
onPaste: o.onPaste
|
|
3124
|
+
}, null, 40, Wa)), [[pn, o.searchQuery]]) : se("v-if", !0),
|
|
3125
|
+
se(' "我"标签 '),
|
|
3126
|
+
Qe(o.MeTag, {
|
|
3127
|
+
"current-user-id": u.currentUserId,
|
|
3128
|
+
"is-disabled": o.isMeTagDisabled,
|
|
3129
|
+
onClick: o.addCurrentUser
|
|
3130
|
+
}, null, 8, ["current-user-id", "is-disabled"])
|
|
3131
|
+
], 512)], 4), [[tr, o.isFocused]]),
|
|
3132
|
+
se(" 未聚焦状态 - 只读展示模式 "),
|
|
3133
|
+
St(Ae("div", {
|
|
3134
|
+
ref: "collapsedContainerRef",
|
|
3135
|
+
class: "tags-container tags-container-collapsed",
|
|
3136
|
+
style: hn(o.textareaStyle),
|
|
3137
|
+
onClick: je(o.handleFocus, ["stop"])
|
|
3138
|
+
}, [
|
|
3139
|
+
(Z(!0), oe(Ut, null, Dt(o.collapsedDisplayUsers, (f) => (Z(), Yt(o.UserTag, er({ key: f.id }, { ref_for: !0 }, o.userTagCommonProps, {
|
|
3140
|
+
"show-tenant": !0,
|
|
3141
|
+
user: f,
|
|
3142
|
+
onClick: o.handleFocus,
|
|
3143
|
+
onClose: (w) => o.removeUser(f)
|
|
3144
|
+
}), null, 16, ["user", "onClose"]))), 128)),
|
|
3145
|
+
se(" 显示折叠标签数量(textarea 模式下不折叠) "),
|
|
3146
|
+
o.hiddenCount > 0 && !o.isTextareaMode ? (Z(), Yt(o.Popover, {
|
|
3147
|
+
key: 0,
|
|
3148
|
+
placement: "top"
|
|
3149
|
+
}, {
|
|
3150
|
+
content: ot(() => [Ae("div", Va, [(Z(!0), oe(Ut, null, Dt(o.selectedUsers.slice(o.visibleUsers.length), (f) => (Z(), Yt(o.UserRender, {
|
|
3151
|
+
key: f.id,
|
|
3152
|
+
"avatar-base-url": u.avatarBaseUrl,
|
|
3153
|
+
"has-avatar": u.hasAvatar,
|
|
3154
|
+
"tenant-id": u.tenantId,
|
|
3155
|
+
tenants: o.tenants,
|
|
3156
|
+
user: f
|
|
3157
|
+
}, null, 8, [
|
|
3158
|
+
"avatar-base-url",
|
|
3159
|
+
"has-avatar",
|
|
3160
|
+
"tenant-id",
|
|
3161
|
+
"tenants",
|
|
3162
|
+
"user"
|
|
3163
|
+
]))), 128))])]),
|
|
3164
|
+
default: ot(() => [Qe(o.Tag, null, {
|
|
3165
|
+
default: ot(() => [Pr(" +" + gt(o.hiddenCount), 1)]),
|
|
3166
|
+
_: 1
|
|
3167
|
+
})]),
|
|
3168
|
+
_: 1
|
|
3169
|
+
})) : se("v-if", !0),
|
|
3170
|
+
se(" 搜索输入框 "),
|
|
3171
|
+
St(Ae("input", {
|
|
3172
|
+
"onUpdate:modelValue": d[3] || (d[3] = (f) => o.searchQuery = f),
|
|
3173
|
+
class: "search-input search-input-collapsed",
|
|
3174
|
+
placeholder: o.selectedUsers.length ? "" : o.computedPlaceholder,
|
|
3175
|
+
onFocus: o.handleFocus
|
|
3176
|
+
}, null, 40, Qa), [[pn, o.searchQuery]]),
|
|
3177
|
+
se(' 未聚焦状态下的"我"标签 '),
|
|
3178
|
+
Qe(o.MeTag, {
|
|
3179
|
+
"current-user-id": u.currentUserId,
|
|
3180
|
+
"is-disabled": o.isMeTagDisabled,
|
|
3181
|
+
onClick: o.addCurrentUser
|
|
3182
|
+
}, null, 8, ["current-user-id", "is-disabled"])
|
|
3183
|
+
], 4), [[tr, !o.isFocused]])
|
|
3184
|
+
]),
|
|
3185
|
+
_: 1
|
|
3186
|
+
}, 8, [
|
|
3187
|
+
"avatar-base-url",
|
|
3188
|
+
"container-width",
|
|
3189
|
+
"empty-text",
|
|
3190
|
+
"flat-options",
|
|
3191
|
+
"has-avatar",
|
|
3192
|
+
"highlighted-index",
|
|
3193
|
+
"is-show",
|
|
3194
|
+
"loading",
|
|
3195
|
+
"options",
|
|
3196
|
+
"recent-users",
|
|
3197
|
+
"recent-users-name",
|
|
3198
|
+
"render-list-item",
|
|
3199
|
+
"search-query",
|
|
3200
|
+
"tenant-id",
|
|
3201
|
+
"tenants",
|
|
3202
|
+
"user-group",
|
|
3203
|
+
"user-group-name"
|
|
3204
|
+
])], 2);
|
|
3205
|
+
}
|
|
3206
|
+
var Ja = /* @__PURE__ */ wn(Ya, [
|
|
3207
|
+
["render", Za],
|
|
3208
|
+
["__scopeId", "data-v-089550be"],
|
|
3209
|
+
["__file", "/Users/brooklin/project/bkui-monorepo/packages/bk-user-selector/src/components/user-selector.vue"]
|
|
3210
|
+
]), no = Ja;
|
|
3211
|
+
export {
|
|
3212
|
+
Ja as BkUserSelector,
|
|
3213
|
+
no as default
|
|
3214
|
+
};
|