@keenmate/web-multiselect 1.0.0-rc02
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/LICENSE +21 -0
- package/README.md +562 -0
- package/dist/index.d.ts +26 -0
- package/dist/multiselect.d.ts +117 -0
- package/dist/multiselect.js +2231 -0
- package/dist/multiselect.umd.js +46 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +187 -0
- package/dist/web-component.d.ts +103 -0
- package/package.json +75 -0
- package/src/scss/_base.scss +41 -0
- package/src/scss/_debug.scss +60 -0
- package/src/scss/_input-dropdown.scss +177 -0
- package/src/scss/_modifiers.scss +95 -0
- package/src/scss/_options.scss +175 -0
- package/src/scss/_pills-display.scss +218 -0
- package/src/scss/_tooltips-popover.scss +114 -0
- package/src/scss/_variables.scss +453 -0
- package/src/scss/main.scss +24 -0
|
@@ -0,0 +1,2231 @@
|
|
|
1
|
+
var Ue = Object.defineProperty;
|
|
2
|
+
var Ye = (i, e, t) => e in i ? Ue(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var u = (i, e, t) => Ye(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const te = Math.min, z = Math.max, ie = Math.round, J = Math.floor, P = (i) => ({
|
|
5
|
+
x: i,
|
|
6
|
+
y: i
|
|
7
|
+
}), Xe = {
|
|
8
|
+
left: "right",
|
|
9
|
+
right: "left",
|
|
10
|
+
bottom: "top",
|
|
11
|
+
top: "bottom"
|
|
12
|
+
}, Je = {
|
|
13
|
+
start: "end",
|
|
14
|
+
end: "start"
|
|
15
|
+
};
|
|
16
|
+
function ke(i, e, t) {
|
|
17
|
+
return z(i, te(e, t));
|
|
18
|
+
}
|
|
19
|
+
function le(i, e) {
|
|
20
|
+
return typeof i == "function" ? i(e) : i;
|
|
21
|
+
}
|
|
22
|
+
function N(i) {
|
|
23
|
+
return i.split("-")[0];
|
|
24
|
+
}
|
|
25
|
+
function ne(i) {
|
|
26
|
+
return i.split("-")[1];
|
|
27
|
+
}
|
|
28
|
+
function Ee(i) {
|
|
29
|
+
return i === "x" ? "y" : "x";
|
|
30
|
+
}
|
|
31
|
+
function Ve(i) {
|
|
32
|
+
return i === "y" ? "height" : "width";
|
|
33
|
+
}
|
|
34
|
+
const qe = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
35
|
+
function V(i) {
|
|
36
|
+
return qe.has(N(i)) ? "y" : "x";
|
|
37
|
+
}
|
|
38
|
+
function $e(i) {
|
|
39
|
+
return Ee(V(i));
|
|
40
|
+
}
|
|
41
|
+
function Ze(i, e, t) {
|
|
42
|
+
t === void 0 && (t = !1);
|
|
43
|
+
const o = ne(i), s = $e(i), l = Ve(s);
|
|
44
|
+
let n = s === "x" ? o === (t ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
|
|
45
|
+
return e.reference[l] > e.floating[l] && (n = oe(n)), [n, oe(n)];
|
|
46
|
+
}
|
|
47
|
+
function Qe(i) {
|
|
48
|
+
const e = oe(i);
|
|
49
|
+
return [fe(i), e, fe(e)];
|
|
50
|
+
}
|
|
51
|
+
function fe(i) {
|
|
52
|
+
return i.replace(/start|end/g, (e) => Je[e]);
|
|
53
|
+
}
|
|
54
|
+
const Ae = ["left", "right"], Se = ["right", "left"], et = ["top", "bottom"], tt = ["bottom", "top"];
|
|
55
|
+
function it(i, e, t) {
|
|
56
|
+
switch (i) {
|
|
57
|
+
case "top":
|
|
58
|
+
case "bottom":
|
|
59
|
+
return t ? e ? Se : Ae : e ? Ae : Se;
|
|
60
|
+
case "left":
|
|
61
|
+
case "right":
|
|
62
|
+
return e ? et : tt;
|
|
63
|
+
default:
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function ot(i, e, t, o) {
|
|
68
|
+
const s = ne(i);
|
|
69
|
+
let l = it(N(i), t === "start", o);
|
|
70
|
+
return s && (l = l.map((n) => n + "-" + s), e && (l = l.concat(l.map(fe)))), l;
|
|
71
|
+
}
|
|
72
|
+
function oe(i) {
|
|
73
|
+
return i.replace(/left|right|bottom|top/g, (e) => Xe[e]);
|
|
74
|
+
}
|
|
75
|
+
function st(i) {
|
|
76
|
+
return {
|
|
77
|
+
top: 0,
|
|
78
|
+
right: 0,
|
|
79
|
+
bottom: 0,
|
|
80
|
+
left: 0,
|
|
81
|
+
...i
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function lt(i) {
|
|
85
|
+
return typeof i != "number" ? st(i) : {
|
|
86
|
+
top: i,
|
|
87
|
+
right: i,
|
|
88
|
+
bottom: i,
|
|
89
|
+
left: i
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function se(i) {
|
|
93
|
+
const {
|
|
94
|
+
x: e,
|
|
95
|
+
y: t,
|
|
96
|
+
width: o,
|
|
97
|
+
height: s
|
|
98
|
+
} = i;
|
|
99
|
+
return {
|
|
100
|
+
width: o,
|
|
101
|
+
height: s,
|
|
102
|
+
top: t,
|
|
103
|
+
left: e,
|
|
104
|
+
right: e + o,
|
|
105
|
+
bottom: t + s,
|
|
106
|
+
x: e,
|
|
107
|
+
y: t
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function Oe(i, e, t) {
|
|
111
|
+
let {
|
|
112
|
+
reference: o,
|
|
113
|
+
floating: s
|
|
114
|
+
} = i;
|
|
115
|
+
const l = V(e), n = $e(e), r = Ve(n), a = N(e), c = l === "y", p = o.x + o.width / 2 - s.width / 2, d = o.y + o.height / 2 - s.height / 2, m = o[r] / 2 - s[r] / 2;
|
|
116
|
+
let h;
|
|
117
|
+
switch (a) {
|
|
118
|
+
case "top":
|
|
119
|
+
h = {
|
|
120
|
+
x: p,
|
|
121
|
+
y: o.y - s.height
|
|
122
|
+
};
|
|
123
|
+
break;
|
|
124
|
+
case "bottom":
|
|
125
|
+
h = {
|
|
126
|
+
x: p,
|
|
127
|
+
y: o.y + o.height
|
|
128
|
+
};
|
|
129
|
+
break;
|
|
130
|
+
case "right":
|
|
131
|
+
h = {
|
|
132
|
+
x: o.x + o.width,
|
|
133
|
+
y: d
|
|
134
|
+
};
|
|
135
|
+
break;
|
|
136
|
+
case "left":
|
|
137
|
+
h = {
|
|
138
|
+
x: o.x - s.width,
|
|
139
|
+
y: d
|
|
140
|
+
};
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
h = {
|
|
144
|
+
x: o.x,
|
|
145
|
+
y: o.y
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
switch (ne(e)) {
|
|
149
|
+
case "start":
|
|
150
|
+
h[n] -= m * (t && c ? -1 : 1);
|
|
151
|
+
break;
|
|
152
|
+
case "end":
|
|
153
|
+
h[n] += m * (t && c ? -1 : 1);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
return h;
|
|
157
|
+
}
|
|
158
|
+
const nt = async (i, e, t) => {
|
|
159
|
+
const {
|
|
160
|
+
placement: o = "bottom",
|
|
161
|
+
strategy: s = "absolute",
|
|
162
|
+
middleware: l = [],
|
|
163
|
+
platform: n
|
|
164
|
+
} = t, r = l.filter(Boolean), a = await (n.isRTL == null ? void 0 : n.isRTL(e));
|
|
165
|
+
let c = await n.getElementRects({
|
|
166
|
+
reference: i,
|
|
167
|
+
floating: e,
|
|
168
|
+
strategy: s
|
|
169
|
+
}), {
|
|
170
|
+
x: p,
|
|
171
|
+
y: d
|
|
172
|
+
} = Oe(c, o, a), m = o, h = {}, g = 0;
|
|
173
|
+
for (let v = 0; v < r.length; v++) {
|
|
174
|
+
const {
|
|
175
|
+
name: w,
|
|
176
|
+
fn: b
|
|
177
|
+
} = r[v], {
|
|
178
|
+
x: _,
|
|
179
|
+
y,
|
|
180
|
+
data: C,
|
|
181
|
+
reset: x
|
|
182
|
+
} = await b({
|
|
183
|
+
x: p,
|
|
184
|
+
y: d,
|
|
185
|
+
initialPlacement: o,
|
|
186
|
+
placement: m,
|
|
187
|
+
strategy: s,
|
|
188
|
+
middlewareData: h,
|
|
189
|
+
rects: c,
|
|
190
|
+
platform: n,
|
|
191
|
+
elements: {
|
|
192
|
+
reference: i,
|
|
193
|
+
floating: e
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
p = _ ?? p, d = y ?? d, h = {
|
|
197
|
+
...h,
|
|
198
|
+
[w]: {
|
|
199
|
+
...h[w],
|
|
200
|
+
...C
|
|
201
|
+
}
|
|
202
|
+
}, x && g <= 50 && (g++, typeof x == "object" && (x.placement && (m = x.placement), x.rects && (c = x.rects === !0 ? await n.getElementRects({
|
|
203
|
+
reference: i,
|
|
204
|
+
floating: e,
|
|
205
|
+
strategy: s
|
|
206
|
+
}) : x.rects), {
|
|
207
|
+
x: p,
|
|
208
|
+
y: d
|
|
209
|
+
} = Oe(c, m, a)), v = -1);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
x: p,
|
|
213
|
+
y: d,
|
|
214
|
+
placement: m,
|
|
215
|
+
strategy: s,
|
|
216
|
+
middlewareData: h
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
async function De(i, e) {
|
|
220
|
+
var t;
|
|
221
|
+
e === void 0 && (e = {});
|
|
222
|
+
const {
|
|
223
|
+
x: o,
|
|
224
|
+
y: s,
|
|
225
|
+
platform: l,
|
|
226
|
+
rects: n,
|
|
227
|
+
elements: r,
|
|
228
|
+
strategy: a
|
|
229
|
+
} = i, {
|
|
230
|
+
boundary: c = "clippingAncestors",
|
|
231
|
+
rootBoundary: p = "viewport",
|
|
232
|
+
elementContext: d = "floating",
|
|
233
|
+
altBoundary: m = !1,
|
|
234
|
+
padding: h = 0
|
|
235
|
+
} = le(e, i), g = lt(h), w = r[m ? d === "floating" ? "reference" : "floating" : d], b = se(await l.getClippingRect({
|
|
236
|
+
element: (t = await (l.isElement == null ? void 0 : l.isElement(w))) == null || t ? w : w.contextElement || await (l.getDocumentElement == null ? void 0 : l.getDocumentElement(r.floating)),
|
|
237
|
+
boundary: c,
|
|
238
|
+
rootBoundary: p,
|
|
239
|
+
strategy: a
|
|
240
|
+
})), _ = d === "floating" ? {
|
|
241
|
+
x: o,
|
|
242
|
+
y: s,
|
|
243
|
+
width: n.floating.width,
|
|
244
|
+
height: n.floating.height
|
|
245
|
+
} : n.reference, y = await (l.getOffsetParent == null ? void 0 : l.getOffsetParent(r.floating)), C = await (l.isElement == null ? void 0 : l.isElement(y)) ? await (l.getScale == null ? void 0 : l.getScale(y)) || {
|
|
246
|
+
x: 1,
|
|
247
|
+
y: 1
|
|
248
|
+
} : {
|
|
249
|
+
x: 1,
|
|
250
|
+
y: 1
|
|
251
|
+
}, x = se(l.convertOffsetParentRelativeRectToViewportRelativeRect ? await l.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
252
|
+
elements: r,
|
|
253
|
+
rect: _,
|
|
254
|
+
offsetParent: y,
|
|
255
|
+
strategy: a
|
|
256
|
+
}) : _);
|
|
257
|
+
return {
|
|
258
|
+
top: (b.top - x.top + g.top) / C.y,
|
|
259
|
+
bottom: (x.bottom - b.bottom + g.bottom) / C.y,
|
|
260
|
+
left: (b.left - x.left + g.left) / C.x,
|
|
261
|
+
right: (x.right - b.right + g.right) / C.x
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const rt = function(i) {
|
|
265
|
+
return i === void 0 && (i = {}), {
|
|
266
|
+
name: "flip",
|
|
267
|
+
options: i,
|
|
268
|
+
async fn(e) {
|
|
269
|
+
var t, o;
|
|
270
|
+
const {
|
|
271
|
+
placement: s,
|
|
272
|
+
middlewareData: l,
|
|
273
|
+
rects: n,
|
|
274
|
+
initialPlacement: r,
|
|
275
|
+
platform: a,
|
|
276
|
+
elements: c
|
|
277
|
+
} = e, {
|
|
278
|
+
mainAxis: p = !0,
|
|
279
|
+
crossAxis: d = !0,
|
|
280
|
+
fallbackPlacements: m,
|
|
281
|
+
fallbackStrategy: h = "bestFit",
|
|
282
|
+
fallbackAxisSideDirection: g = "none",
|
|
283
|
+
flipAlignment: v = !0,
|
|
284
|
+
...w
|
|
285
|
+
} = le(i, e);
|
|
286
|
+
if ((t = l.arrow) != null && t.alignmentOffset)
|
|
287
|
+
return {};
|
|
288
|
+
const b = N(s), _ = V(r), y = N(r) === r, C = await (a.isRTL == null ? void 0 : a.isRTL(c.floating)), x = m || (y || !v ? [oe(r)] : Qe(r)), G = g !== "none";
|
|
289
|
+
!m && G && x.push(...ot(r, v, g, C));
|
|
290
|
+
const F = [r, ...x], pe = await De(e, w), X = [];
|
|
291
|
+
let B = ((o = l.flip) == null ? void 0 : o.overflows) || [];
|
|
292
|
+
if (p && X.push(pe[b]), d) {
|
|
293
|
+
const D = Ze(s, n, C);
|
|
294
|
+
X.push(pe[D[0]], pe[D[1]]);
|
|
295
|
+
}
|
|
296
|
+
if (B = [...B, {
|
|
297
|
+
placement: s,
|
|
298
|
+
overflows: X
|
|
299
|
+
}], !X.every((D) => D <= 0)) {
|
|
300
|
+
var ye, xe;
|
|
301
|
+
const D = (((ye = l.flip) == null ? void 0 : ye.index) || 0) + 1, he = F[D];
|
|
302
|
+
if (he && (!(d === "alignment" ? _ !== V(he) : !1) || // We leave the current main axis only if every placement on that axis
|
|
303
|
+
// overflows the main axis.
|
|
304
|
+
B.every((A) => V(A.placement) === _ ? A.overflows[0] > 0 : !0)))
|
|
305
|
+
return {
|
|
306
|
+
data: {
|
|
307
|
+
index: D,
|
|
308
|
+
overflows: B
|
|
309
|
+
},
|
|
310
|
+
reset: {
|
|
311
|
+
placement: he
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
let K = (xe = B.filter((L) => L.overflows[0] <= 0).sort((L, A) => L.overflows[1] - A.overflows[1])[0]) == null ? void 0 : xe.placement;
|
|
315
|
+
if (!K)
|
|
316
|
+
switch (h) {
|
|
317
|
+
case "bestFit": {
|
|
318
|
+
var Ce;
|
|
319
|
+
const L = (Ce = B.filter((A) => {
|
|
320
|
+
if (G) {
|
|
321
|
+
const M = V(A.placement);
|
|
322
|
+
return M === _ || // Create a bias to the `y` side axis due to horizontal
|
|
323
|
+
// reading directions favoring greater width.
|
|
324
|
+
M === "y";
|
|
325
|
+
}
|
|
326
|
+
return !0;
|
|
327
|
+
}).map((A) => [A.placement, A.overflows.filter((M) => M > 0).reduce((M, Ke) => M + Ke, 0)]).sort((A, M) => A[1] - M[1])[0]) == null ? void 0 : Ce[0];
|
|
328
|
+
L && (K = L);
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
case "initialPlacement":
|
|
332
|
+
K = r;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
if (s !== K)
|
|
336
|
+
return {
|
|
337
|
+
reset: {
|
|
338
|
+
placement: K
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
return {};
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}, at = /* @__PURE__ */ new Set(["left", "top"]);
|
|
346
|
+
async function ct(i, e) {
|
|
347
|
+
const {
|
|
348
|
+
placement: t,
|
|
349
|
+
platform: o,
|
|
350
|
+
elements: s
|
|
351
|
+
} = i, l = await (o.isRTL == null ? void 0 : o.isRTL(s.floating)), n = N(t), r = ne(t), a = V(t) === "y", c = at.has(n) ? -1 : 1, p = l && a ? -1 : 1, d = le(e, i);
|
|
352
|
+
let {
|
|
353
|
+
mainAxis: m,
|
|
354
|
+
crossAxis: h,
|
|
355
|
+
alignmentAxis: g
|
|
356
|
+
} = typeof d == "number" ? {
|
|
357
|
+
mainAxis: d,
|
|
358
|
+
crossAxis: 0,
|
|
359
|
+
alignmentAxis: null
|
|
360
|
+
} : {
|
|
361
|
+
mainAxis: d.mainAxis || 0,
|
|
362
|
+
crossAxis: d.crossAxis || 0,
|
|
363
|
+
alignmentAxis: d.alignmentAxis
|
|
364
|
+
};
|
|
365
|
+
return r && typeof g == "number" && (h = r === "end" ? g * -1 : g), a ? {
|
|
366
|
+
x: h * p,
|
|
367
|
+
y: m * c
|
|
368
|
+
} : {
|
|
369
|
+
x: m * c,
|
|
370
|
+
y: h * p
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
const dt = function(i) {
|
|
374
|
+
return i === void 0 && (i = 0), {
|
|
375
|
+
name: "offset",
|
|
376
|
+
options: i,
|
|
377
|
+
async fn(e) {
|
|
378
|
+
var t, o;
|
|
379
|
+
const {
|
|
380
|
+
x: s,
|
|
381
|
+
y: l,
|
|
382
|
+
placement: n,
|
|
383
|
+
middlewareData: r
|
|
384
|
+
} = e, a = await ct(e, i);
|
|
385
|
+
return n === ((t = r.offset) == null ? void 0 : t.placement) && (o = r.arrow) != null && o.alignmentOffset ? {} : {
|
|
386
|
+
x: s + a.x,
|
|
387
|
+
y: l + a.y,
|
|
388
|
+
data: {
|
|
389
|
+
...a,
|
|
390
|
+
placement: n
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}, pt = function(i) {
|
|
396
|
+
return i === void 0 && (i = {}), {
|
|
397
|
+
name: "shift",
|
|
398
|
+
options: i,
|
|
399
|
+
async fn(e) {
|
|
400
|
+
const {
|
|
401
|
+
x: t,
|
|
402
|
+
y: o,
|
|
403
|
+
placement: s
|
|
404
|
+
} = e, {
|
|
405
|
+
mainAxis: l = !0,
|
|
406
|
+
crossAxis: n = !1,
|
|
407
|
+
limiter: r = {
|
|
408
|
+
fn: (w) => {
|
|
409
|
+
let {
|
|
410
|
+
x: b,
|
|
411
|
+
y: _
|
|
412
|
+
} = w;
|
|
413
|
+
return {
|
|
414
|
+
x: b,
|
|
415
|
+
y: _
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
...a
|
|
420
|
+
} = le(i, e), c = {
|
|
421
|
+
x: t,
|
|
422
|
+
y: o
|
|
423
|
+
}, p = await De(e, a), d = V(N(s)), m = Ee(d);
|
|
424
|
+
let h = c[m], g = c[d];
|
|
425
|
+
if (l) {
|
|
426
|
+
const w = m === "y" ? "top" : "left", b = m === "y" ? "bottom" : "right", _ = h + p[w], y = h - p[b];
|
|
427
|
+
h = ke(_, h, y);
|
|
428
|
+
}
|
|
429
|
+
if (n) {
|
|
430
|
+
const w = d === "y" ? "top" : "left", b = d === "y" ? "bottom" : "right", _ = g + p[w], y = g - p[b];
|
|
431
|
+
g = ke(_, g, y);
|
|
432
|
+
}
|
|
433
|
+
const v = r.fn({
|
|
434
|
+
...e,
|
|
435
|
+
[m]: h,
|
|
436
|
+
[d]: g
|
|
437
|
+
});
|
|
438
|
+
return {
|
|
439
|
+
...v,
|
|
440
|
+
data: {
|
|
441
|
+
x: v.x - t,
|
|
442
|
+
y: v.y - o,
|
|
443
|
+
enabled: {
|
|
444
|
+
[m]: l,
|
|
445
|
+
[d]: n
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
function re() {
|
|
453
|
+
return typeof window < "u";
|
|
454
|
+
}
|
|
455
|
+
function j(i) {
|
|
456
|
+
return Le(i) ? (i.nodeName || "").toLowerCase() : "#document";
|
|
457
|
+
}
|
|
458
|
+
function k(i) {
|
|
459
|
+
var e;
|
|
460
|
+
return (i == null || (e = i.ownerDocument) == null ? void 0 : e.defaultView) || window;
|
|
461
|
+
}
|
|
462
|
+
function I(i) {
|
|
463
|
+
var e;
|
|
464
|
+
return (e = (Le(i) ? i.ownerDocument : i.document) || window.document) == null ? void 0 : e.documentElement;
|
|
465
|
+
}
|
|
466
|
+
function Le(i) {
|
|
467
|
+
return re() ? i instanceof Node || i instanceof k(i).Node : !1;
|
|
468
|
+
}
|
|
469
|
+
function S(i) {
|
|
470
|
+
return re() ? i instanceof Element || i instanceof k(i).Element : !1;
|
|
471
|
+
}
|
|
472
|
+
function T(i) {
|
|
473
|
+
return re() ? i instanceof HTMLElement || i instanceof k(i).HTMLElement : !1;
|
|
474
|
+
}
|
|
475
|
+
function Pe(i) {
|
|
476
|
+
return !re() || typeof ShadowRoot > "u" ? !1 : i instanceof ShadowRoot || i instanceof k(i).ShadowRoot;
|
|
477
|
+
}
|
|
478
|
+
const ht = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
479
|
+
function Y(i) {
|
|
480
|
+
const {
|
|
481
|
+
overflow: e,
|
|
482
|
+
overflowX: t,
|
|
483
|
+
overflowY: o,
|
|
484
|
+
display: s
|
|
485
|
+
} = O(i);
|
|
486
|
+
return /auto|scroll|overlay|hidden|clip/.test(e + o + t) && !ht.has(s);
|
|
487
|
+
}
|
|
488
|
+
const ut = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
489
|
+
function mt(i) {
|
|
490
|
+
return ut.has(j(i));
|
|
491
|
+
}
|
|
492
|
+
const ft = [":popover-open", ":modal"];
|
|
493
|
+
function ae(i) {
|
|
494
|
+
return ft.some((e) => {
|
|
495
|
+
try {
|
|
496
|
+
return i.matches(e);
|
|
497
|
+
} catch {
|
|
498
|
+
return !1;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
const gt = ["transform", "translate", "scale", "rotate", "perspective"], bt = ["transform", "translate", "scale", "rotate", "perspective", "filter"], vt = ["paint", "layout", "strict", "content"];
|
|
503
|
+
function ve(i) {
|
|
504
|
+
const e = we(), t = S(i) ? O(i) : i;
|
|
505
|
+
return gt.some((o) => t[o] ? t[o] !== "none" : !1) || (t.containerType ? t.containerType !== "normal" : !1) || !e && (t.backdropFilter ? t.backdropFilter !== "none" : !1) || !e && (t.filter ? t.filter !== "none" : !1) || bt.some((o) => (t.willChange || "").includes(o)) || vt.some((o) => (t.contain || "").includes(o));
|
|
506
|
+
}
|
|
507
|
+
function wt(i) {
|
|
508
|
+
let e = $(i);
|
|
509
|
+
for (; T(e) && !W(e); ) {
|
|
510
|
+
if (ve(e))
|
|
511
|
+
return e;
|
|
512
|
+
if (ae(e))
|
|
513
|
+
return null;
|
|
514
|
+
e = $(e);
|
|
515
|
+
}
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
function we() {
|
|
519
|
+
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
|
|
520
|
+
}
|
|
521
|
+
const _t = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
522
|
+
function W(i) {
|
|
523
|
+
return _t.has(j(i));
|
|
524
|
+
}
|
|
525
|
+
function O(i) {
|
|
526
|
+
return k(i).getComputedStyle(i);
|
|
527
|
+
}
|
|
528
|
+
function ce(i) {
|
|
529
|
+
return S(i) ? {
|
|
530
|
+
scrollLeft: i.scrollLeft,
|
|
531
|
+
scrollTop: i.scrollTop
|
|
532
|
+
} : {
|
|
533
|
+
scrollLeft: i.scrollX,
|
|
534
|
+
scrollTop: i.scrollY
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function $(i) {
|
|
538
|
+
if (j(i) === "html")
|
|
539
|
+
return i;
|
|
540
|
+
const e = (
|
|
541
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
542
|
+
i.assignedSlot || // DOM Element detected.
|
|
543
|
+
i.parentNode || // ShadowRoot detected.
|
|
544
|
+
Pe(i) && i.host || // Fallback.
|
|
545
|
+
I(i)
|
|
546
|
+
);
|
|
547
|
+
return Pe(e) ? e.host : e;
|
|
548
|
+
}
|
|
549
|
+
function ze(i) {
|
|
550
|
+
const e = $(i);
|
|
551
|
+
return W(e) ? i.ownerDocument ? i.ownerDocument.body : i.body : T(e) && Y(e) ? e : ze(e);
|
|
552
|
+
}
|
|
553
|
+
function U(i, e, t) {
|
|
554
|
+
var o;
|
|
555
|
+
e === void 0 && (e = []), t === void 0 && (t = !0);
|
|
556
|
+
const s = ze(i), l = s === ((o = i.ownerDocument) == null ? void 0 : o.body), n = k(s);
|
|
557
|
+
if (l) {
|
|
558
|
+
const r = ge(n);
|
|
559
|
+
return e.concat(n, n.visualViewport || [], Y(s) ? s : [], r && t ? U(r) : []);
|
|
560
|
+
}
|
|
561
|
+
return e.concat(s, U(s, [], t));
|
|
562
|
+
}
|
|
563
|
+
function ge(i) {
|
|
564
|
+
return i.parent && Object.getPrototypeOf(i.parent) ? i.frameElement : null;
|
|
565
|
+
}
|
|
566
|
+
function Ne(i) {
|
|
567
|
+
const e = O(i);
|
|
568
|
+
let t = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0;
|
|
569
|
+
const s = T(i), l = s ? i.offsetWidth : t, n = s ? i.offsetHeight : o, r = ie(t) !== l || ie(o) !== n;
|
|
570
|
+
return r && (t = l, o = n), {
|
|
571
|
+
width: t,
|
|
572
|
+
height: o,
|
|
573
|
+
$: r
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
function _e(i) {
|
|
577
|
+
return S(i) ? i : i.contextElement;
|
|
578
|
+
}
|
|
579
|
+
function H(i) {
|
|
580
|
+
const e = _e(i);
|
|
581
|
+
if (!T(e))
|
|
582
|
+
return P(1);
|
|
583
|
+
const t = e.getBoundingClientRect(), {
|
|
584
|
+
width: o,
|
|
585
|
+
height: s,
|
|
586
|
+
$: l
|
|
587
|
+
} = Ne(e);
|
|
588
|
+
let n = (l ? ie(t.width) : t.width) / o, r = (l ? ie(t.height) : t.height) / s;
|
|
589
|
+
return (!n || !Number.isFinite(n)) && (n = 1), (!r || !Number.isFinite(r)) && (r = 1), {
|
|
590
|
+
x: n,
|
|
591
|
+
y: r
|
|
592
|
+
};
|
|
593
|
+
}
|
|
594
|
+
const yt = /* @__PURE__ */ P(0);
|
|
595
|
+
function Re(i) {
|
|
596
|
+
const e = k(i);
|
|
597
|
+
return !we() || !e.visualViewport ? yt : {
|
|
598
|
+
x: e.visualViewport.offsetLeft,
|
|
599
|
+
y: e.visualViewport.offsetTop
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
function xt(i, e, t) {
|
|
603
|
+
return e === void 0 && (e = !1), !t || e && t !== k(i) ? !1 : e;
|
|
604
|
+
}
|
|
605
|
+
function R(i, e, t, o) {
|
|
606
|
+
e === void 0 && (e = !1), t === void 0 && (t = !1);
|
|
607
|
+
const s = i.getBoundingClientRect(), l = _e(i);
|
|
608
|
+
let n = P(1);
|
|
609
|
+
e && (o ? S(o) && (n = H(o)) : n = H(i));
|
|
610
|
+
const r = xt(l, t, o) ? Re(l) : P(0);
|
|
611
|
+
let a = (s.left + r.x) / n.x, c = (s.top + r.y) / n.y, p = s.width / n.x, d = s.height / n.y;
|
|
612
|
+
if (l) {
|
|
613
|
+
const m = k(l), h = o && S(o) ? k(o) : o;
|
|
614
|
+
let g = m, v = ge(g);
|
|
615
|
+
for (; v && o && h !== g; ) {
|
|
616
|
+
const w = H(v), b = v.getBoundingClientRect(), _ = O(v), y = b.left + (v.clientLeft + parseFloat(_.paddingLeft)) * w.x, C = b.top + (v.clientTop + parseFloat(_.paddingTop)) * w.y;
|
|
617
|
+
a *= w.x, c *= w.y, p *= w.x, d *= w.y, a += y, c += C, g = k(v), v = ge(g);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
return se({
|
|
621
|
+
width: p,
|
|
622
|
+
height: d,
|
|
623
|
+
x: a,
|
|
624
|
+
y: c
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
function de(i, e) {
|
|
628
|
+
const t = ce(i).scrollLeft;
|
|
629
|
+
return e ? e.left + t : R(I(i)).left + t;
|
|
630
|
+
}
|
|
631
|
+
function Fe(i, e) {
|
|
632
|
+
const t = i.getBoundingClientRect(), o = t.left + e.scrollLeft - de(i, t), s = t.top + e.scrollTop;
|
|
633
|
+
return {
|
|
634
|
+
x: o,
|
|
635
|
+
y: s
|
|
636
|
+
};
|
|
637
|
+
}
|
|
638
|
+
function Ct(i) {
|
|
639
|
+
let {
|
|
640
|
+
elements: e,
|
|
641
|
+
rect: t,
|
|
642
|
+
offsetParent: o,
|
|
643
|
+
strategy: s
|
|
644
|
+
} = i;
|
|
645
|
+
const l = s === "fixed", n = I(o), r = e ? ae(e.floating) : !1;
|
|
646
|
+
if (o === n || r && l)
|
|
647
|
+
return t;
|
|
648
|
+
let a = {
|
|
649
|
+
scrollLeft: 0,
|
|
650
|
+
scrollTop: 0
|
|
651
|
+
}, c = P(1);
|
|
652
|
+
const p = P(0), d = T(o);
|
|
653
|
+
if ((d || !d && !l) && ((j(o) !== "body" || Y(n)) && (a = ce(o)), T(o))) {
|
|
654
|
+
const h = R(o);
|
|
655
|
+
c = H(o), p.x = h.x + o.clientLeft, p.y = h.y + o.clientTop;
|
|
656
|
+
}
|
|
657
|
+
const m = n && !d && !l ? Fe(n, a) : P(0);
|
|
658
|
+
return {
|
|
659
|
+
width: t.width * c.x,
|
|
660
|
+
height: t.height * c.y,
|
|
661
|
+
x: t.x * c.x - a.scrollLeft * c.x + p.x + m.x,
|
|
662
|
+
y: t.y * c.y - a.scrollTop * c.y + p.y + m.y
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
function kt(i) {
|
|
666
|
+
return Array.from(i.getClientRects());
|
|
667
|
+
}
|
|
668
|
+
function At(i) {
|
|
669
|
+
const e = I(i), t = ce(i), o = i.ownerDocument.body, s = z(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), l = z(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight);
|
|
670
|
+
let n = -t.scrollLeft + de(i);
|
|
671
|
+
const r = -t.scrollTop;
|
|
672
|
+
return O(o).direction === "rtl" && (n += z(e.clientWidth, o.clientWidth) - s), {
|
|
673
|
+
width: s,
|
|
674
|
+
height: l,
|
|
675
|
+
x: n,
|
|
676
|
+
y: r
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
const Te = 25;
|
|
680
|
+
function St(i, e) {
|
|
681
|
+
const t = k(i), o = I(i), s = t.visualViewport;
|
|
682
|
+
let l = o.clientWidth, n = o.clientHeight, r = 0, a = 0;
|
|
683
|
+
if (s) {
|
|
684
|
+
l = s.width, n = s.height;
|
|
685
|
+
const p = we();
|
|
686
|
+
(!p || p && e === "fixed") && (r = s.offsetLeft, a = s.offsetTop);
|
|
687
|
+
}
|
|
688
|
+
const c = de(o);
|
|
689
|
+
if (c <= 0) {
|
|
690
|
+
const p = o.ownerDocument, d = p.body, m = getComputedStyle(d), h = p.compatMode === "CSS1Compat" && parseFloat(m.marginLeft) + parseFloat(m.marginRight) || 0, g = Math.abs(o.clientWidth - d.clientWidth - h);
|
|
691
|
+
g <= Te && (l -= g);
|
|
692
|
+
} else c <= Te && (l += c);
|
|
693
|
+
return {
|
|
694
|
+
width: l,
|
|
695
|
+
height: n,
|
|
696
|
+
x: r,
|
|
697
|
+
y: a
|
|
698
|
+
};
|
|
699
|
+
}
|
|
700
|
+
const Ot = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
701
|
+
function Pt(i, e) {
|
|
702
|
+
const t = R(i, !0, e === "fixed"), o = t.top + i.clientTop, s = t.left + i.clientLeft, l = T(i) ? H(i) : P(1), n = i.clientWidth * l.x, r = i.clientHeight * l.y, a = s * l.x, c = o * l.y;
|
|
703
|
+
return {
|
|
704
|
+
width: n,
|
|
705
|
+
height: r,
|
|
706
|
+
x: a,
|
|
707
|
+
y: c
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
function Ie(i, e, t) {
|
|
711
|
+
let o;
|
|
712
|
+
if (e === "viewport")
|
|
713
|
+
o = St(i, t);
|
|
714
|
+
else if (e === "document")
|
|
715
|
+
o = At(I(i));
|
|
716
|
+
else if (S(e))
|
|
717
|
+
o = Pt(e, t);
|
|
718
|
+
else {
|
|
719
|
+
const s = Re(i);
|
|
720
|
+
o = {
|
|
721
|
+
x: e.x - s.x,
|
|
722
|
+
y: e.y - s.y,
|
|
723
|
+
width: e.width,
|
|
724
|
+
height: e.height
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
return se(o);
|
|
728
|
+
}
|
|
729
|
+
function Be(i, e) {
|
|
730
|
+
const t = $(i);
|
|
731
|
+
return t === e || !S(t) || W(t) ? !1 : O(t).position === "fixed" || Be(t, e);
|
|
732
|
+
}
|
|
733
|
+
function Tt(i, e) {
|
|
734
|
+
const t = e.get(i);
|
|
735
|
+
if (t)
|
|
736
|
+
return t;
|
|
737
|
+
let o = U(i, [], !1).filter((r) => S(r) && j(r) !== "body"), s = null;
|
|
738
|
+
const l = O(i).position === "fixed";
|
|
739
|
+
let n = l ? $(i) : i;
|
|
740
|
+
for (; S(n) && !W(n); ) {
|
|
741
|
+
const r = O(n), a = ve(n);
|
|
742
|
+
!a && r.position === "fixed" && (s = null), (l ? !a && !s : !a && r.position === "static" && !!s && Ot.has(s.position) || Y(n) && !a && Be(i, n)) ? o = o.filter((p) => p !== n) : s = r, n = $(n);
|
|
743
|
+
}
|
|
744
|
+
return e.set(i, o), o;
|
|
745
|
+
}
|
|
746
|
+
function It(i) {
|
|
747
|
+
let {
|
|
748
|
+
element: e,
|
|
749
|
+
boundary: t,
|
|
750
|
+
rootBoundary: o,
|
|
751
|
+
strategy: s
|
|
752
|
+
} = i;
|
|
753
|
+
const n = [...t === "clippingAncestors" ? ae(e) ? [] : Tt(e, this._c) : [].concat(t), o], r = n[0], a = n.reduce((c, p) => {
|
|
754
|
+
const d = Ie(e, p, s);
|
|
755
|
+
return c.top = z(d.top, c.top), c.right = te(d.right, c.right), c.bottom = te(d.bottom, c.bottom), c.left = z(d.left, c.left), c;
|
|
756
|
+
}, Ie(e, r, s));
|
|
757
|
+
return {
|
|
758
|
+
width: a.right - a.left,
|
|
759
|
+
height: a.bottom - a.top,
|
|
760
|
+
x: a.left,
|
|
761
|
+
y: a.top
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
function Mt(i) {
|
|
765
|
+
const {
|
|
766
|
+
width: e,
|
|
767
|
+
height: t
|
|
768
|
+
} = Ne(i);
|
|
769
|
+
return {
|
|
770
|
+
width: e,
|
|
771
|
+
height: t
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
function Et(i, e, t) {
|
|
775
|
+
const o = T(e), s = I(e), l = t === "fixed", n = R(i, !0, l, e);
|
|
776
|
+
let r = {
|
|
777
|
+
scrollLeft: 0,
|
|
778
|
+
scrollTop: 0
|
|
779
|
+
};
|
|
780
|
+
const a = P(0);
|
|
781
|
+
function c() {
|
|
782
|
+
a.x = de(s);
|
|
783
|
+
}
|
|
784
|
+
if (o || !o && !l)
|
|
785
|
+
if ((j(e) !== "body" || Y(s)) && (r = ce(e)), o) {
|
|
786
|
+
const h = R(e, !0, l, e);
|
|
787
|
+
a.x = h.x + e.clientLeft, a.y = h.y + e.clientTop;
|
|
788
|
+
} else s && c();
|
|
789
|
+
l && !o && s && c();
|
|
790
|
+
const p = s && !o && !l ? Fe(s, r) : P(0), d = n.left + r.scrollLeft - a.x - p.x, m = n.top + r.scrollTop - a.y - p.y;
|
|
791
|
+
return {
|
|
792
|
+
x: d,
|
|
793
|
+
y: m,
|
|
794
|
+
width: n.width,
|
|
795
|
+
height: n.height
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function ue(i) {
|
|
799
|
+
return O(i).position === "static";
|
|
800
|
+
}
|
|
801
|
+
function Me(i, e) {
|
|
802
|
+
if (!T(i) || O(i).position === "fixed")
|
|
803
|
+
return null;
|
|
804
|
+
if (e)
|
|
805
|
+
return e(i);
|
|
806
|
+
let t = i.offsetParent;
|
|
807
|
+
return I(i) === t && (t = t.ownerDocument.body), t;
|
|
808
|
+
}
|
|
809
|
+
function He(i, e) {
|
|
810
|
+
const t = k(i);
|
|
811
|
+
if (ae(i))
|
|
812
|
+
return t;
|
|
813
|
+
if (!T(i)) {
|
|
814
|
+
let s = $(i);
|
|
815
|
+
for (; s && !W(s); ) {
|
|
816
|
+
if (S(s) && !ue(s))
|
|
817
|
+
return s;
|
|
818
|
+
s = $(s);
|
|
819
|
+
}
|
|
820
|
+
return t;
|
|
821
|
+
}
|
|
822
|
+
let o = Me(i, e);
|
|
823
|
+
for (; o && mt(o) && ue(o); )
|
|
824
|
+
o = Me(o, e);
|
|
825
|
+
return o && W(o) && ue(o) && !ve(o) ? t : o || wt(i) || t;
|
|
826
|
+
}
|
|
827
|
+
const Vt = async function(i) {
|
|
828
|
+
const e = this.getOffsetParent || He, t = this.getDimensions, o = await t(i.floating);
|
|
829
|
+
return {
|
|
830
|
+
reference: Et(i.reference, await e(i.floating), i.strategy),
|
|
831
|
+
floating: {
|
|
832
|
+
x: 0,
|
|
833
|
+
y: 0,
|
|
834
|
+
width: o.width,
|
|
835
|
+
height: o.height
|
|
836
|
+
}
|
|
837
|
+
};
|
|
838
|
+
};
|
|
839
|
+
function $t(i) {
|
|
840
|
+
return O(i).direction === "rtl";
|
|
841
|
+
}
|
|
842
|
+
const Dt = {
|
|
843
|
+
convertOffsetParentRelativeRectToViewportRelativeRect: Ct,
|
|
844
|
+
getDocumentElement: I,
|
|
845
|
+
getClippingRect: It,
|
|
846
|
+
getOffsetParent: He,
|
|
847
|
+
getElementRects: Vt,
|
|
848
|
+
getClientRects: kt,
|
|
849
|
+
getDimensions: Mt,
|
|
850
|
+
getScale: H,
|
|
851
|
+
isElement: S,
|
|
852
|
+
isRTL: $t
|
|
853
|
+
};
|
|
854
|
+
function We(i, e) {
|
|
855
|
+
return i.x === e.x && i.y === e.y && i.width === e.width && i.height === e.height;
|
|
856
|
+
}
|
|
857
|
+
function Lt(i, e) {
|
|
858
|
+
let t = null, o;
|
|
859
|
+
const s = I(i);
|
|
860
|
+
function l() {
|
|
861
|
+
var r;
|
|
862
|
+
clearTimeout(o), (r = t) == null || r.disconnect(), t = null;
|
|
863
|
+
}
|
|
864
|
+
function n(r, a) {
|
|
865
|
+
r === void 0 && (r = !1), a === void 0 && (a = 1), l();
|
|
866
|
+
const c = i.getBoundingClientRect(), {
|
|
867
|
+
left: p,
|
|
868
|
+
top: d,
|
|
869
|
+
width: m,
|
|
870
|
+
height: h
|
|
871
|
+
} = c;
|
|
872
|
+
if (r || e(), !m || !h)
|
|
873
|
+
return;
|
|
874
|
+
const g = J(d), v = J(s.clientWidth - (p + m)), w = J(s.clientHeight - (d + h)), b = J(p), y = {
|
|
875
|
+
rootMargin: -g + "px " + -v + "px " + -w + "px " + -b + "px",
|
|
876
|
+
threshold: z(0, te(1, a)) || 1
|
|
877
|
+
};
|
|
878
|
+
let C = !0;
|
|
879
|
+
function x(G) {
|
|
880
|
+
const F = G[0].intersectionRatio;
|
|
881
|
+
if (F !== a) {
|
|
882
|
+
if (!C)
|
|
883
|
+
return n();
|
|
884
|
+
F ? n(!1, F) : o = setTimeout(() => {
|
|
885
|
+
n(!1, 1e-7);
|
|
886
|
+
}, 1e3);
|
|
887
|
+
}
|
|
888
|
+
F === 1 && !We(c, i.getBoundingClientRect()) && n(), C = !1;
|
|
889
|
+
}
|
|
890
|
+
try {
|
|
891
|
+
t = new IntersectionObserver(x, {
|
|
892
|
+
...y,
|
|
893
|
+
// Handle <iframe>s
|
|
894
|
+
root: s.ownerDocument
|
|
895
|
+
});
|
|
896
|
+
} catch {
|
|
897
|
+
t = new IntersectionObserver(x, y);
|
|
898
|
+
}
|
|
899
|
+
t.observe(i);
|
|
900
|
+
}
|
|
901
|
+
return n(!0), l;
|
|
902
|
+
}
|
|
903
|
+
function q(i, e, t, o) {
|
|
904
|
+
o === void 0 && (o = {});
|
|
905
|
+
const {
|
|
906
|
+
ancestorScroll: s = !0,
|
|
907
|
+
ancestorResize: l = !0,
|
|
908
|
+
elementResize: n = typeof ResizeObserver == "function",
|
|
909
|
+
layoutShift: r = typeof IntersectionObserver == "function",
|
|
910
|
+
animationFrame: a = !1
|
|
911
|
+
} = o, c = _e(i), p = s || l ? [...c ? U(c) : [], ...U(e)] : [];
|
|
912
|
+
p.forEach((b) => {
|
|
913
|
+
s && b.addEventListener("scroll", t, {
|
|
914
|
+
passive: !0
|
|
915
|
+
}), l && b.addEventListener("resize", t);
|
|
916
|
+
});
|
|
917
|
+
const d = c && r ? Lt(c, t) : null;
|
|
918
|
+
let m = -1, h = null;
|
|
919
|
+
n && (h = new ResizeObserver((b) => {
|
|
920
|
+
let [_] = b;
|
|
921
|
+
_ && _.target === c && h && (h.unobserve(e), cancelAnimationFrame(m), m = requestAnimationFrame(() => {
|
|
922
|
+
var y;
|
|
923
|
+
(y = h) == null || y.observe(e);
|
|
924
|
+
})), t();
|
|
925
|
+
}), c && !a && h.observe(c), h.observe(e));
|
|
926
|
+
let g, v = a ? R(i) : null;
|
|
927
|
+
a && w();
|
|
928
|
+
function w() {
|
|
929
|
+
const b = R(i);
|
|
930
|
+
v && !We(v, b) && t(), v = b, g = requestAnimationFrame(w);
|
|
931
|
+
}
|
|
932
|
+
return t(), () => {
|
|
933
|
+
var b;
|
|
934
|
+
p.forEach((_) => {
|
|
935
|
+
s && _.removeEventListener("scroll", t), l && _.removeEventListener("resize", t);
|
|
936
|
+
}), d == null || d(), (b = h) == null || b.disconnect(), h = null, a && cancelAnimationFrame(g);
|
|
937
|
+
};
|
|
938
|
+
}
|
|
939
|
+
const Z = dt, Q = pt, me = rt, ee = (i, e, t) => {
|
|
940
|
+
const o = /* @__PURE__ */ new Map(), s = {
|
|
941
|
+
platform: Dt,
|
|
942
|
+
...t
|
|
943
|
+
}, l = {
|
|
944
|
+
...s.platform,
|
|
945
|
+
_c: o
|
|
946
|
+
};
|
|
947
|
+
return nt(i, e, {
|
|
948
|
+
...s,
|
|
949
|
+
platform: l
|
|
950
|
+
});
|
|
951
|
+
};
|
|
952
|
+
let E = 0;
|
|
953
|
+
const f = {
|
|
954
|
+
debug: (i, ...e) => {
|
|
955
|
+
E++, console.log(
|
|
956
|
+
`%c[MultiSelect ${E}]%c ${i}`,
|
|
957
|
+
"color: #0ea5e9; font-weight: bold;",
|
|
958
|
+
"color: inherit;",
|
|
959
|
+
...e
|
|
960
|
+
);
|
|
961
|
+
},
|
|
962
|
+
info: (i, ...e) => {
|
|
963
|
+
E++, console.info(
|
|
964
|
+
`%c[MultiSelect ${E}]%c ${i}`,
|
|
965
|
+
"color: #10b981; font-weight: bold;",
|
|
966
|
+
"color: inherit;",
|
|
967
|
+
...e
|
|
968
|
+
);
|
|
969
|
+
},
|
|
970
|
+
warn: (i, ...e) => {
|
|
971
|
+
E++, console.warn(
|
|
972
|
+
`%c[MultiSelect ${E}]%c ${i}`,
|
|
973
|
+
"color: #f59e0b; font-weight: bold;",
|
|
974
|
+
"color: inherit;",
|
|
975
|
+
...e
|
|
976
|
+
);
|
|
977
|
+
},
|
|
978
|
+
error: (i, ...e) => {
|
|
979
|
+
E++, console.error(
|
|
980
|
+
`%c[MultiSelect ${E}]%c ${i}`,
|
|
981
|
+
"color: #ef4444; font-weight: bold;",
|
|
982
|
+
"color: inherit;",
|
|
983
|
+
...e
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
};
|
|
987
|
+
class zt {
|
|
988
|
+
constructor(e, t = {}) {
|
|
989
|
+
u(this, "element");
|
|
990
|
+
u(this, "instanceId");
|
|
991
|
+
u(this, "options");
|
|
992
|
+
u(this, "isOpen", !1);
|
|
993
|
+
u(this, "selectedValues", /* @__PURE__ */ new Set());
|
|
994
|
+
u(this, "selectedOptions", /* @__PURE__ */ new Map());
|
|
995
|
+
u(this, "allOptions", []);
|
|
996
|
+
u(this, "filteredOptions", []);
|
|
997
|
+
u(this, "hiddenInputs", []);
|
|
998
|
+
u(this, "focusedIndex", -1);
|
|
999
|
+
u(this, "searchTerm", "");
|
|
1000
|
+
u(this, "isLoading", !1);
|
|
1001
|
+
u(this, "showSelectedPopover", !1);
|
|
1002
|
+
u(this, "selectedPopoverPlacement", null);
|
|
1003
|
+
u(this, "dropdownPlacement", null);
|
|
1004
|
+
// Floating UI cleanup functions
|
|
1005
|
+
u(this, "dropdownCleanup", null);
|
|
1006
|
+
u(this, "hintCleanup", null);
|
|
1007
|
+
u(this, "selectedPopoverCleanup", null);
|
|
1008
|
+
// Pill tooltip storage
|
|
1009
|
+
u(this, "pillTooltips", /* @__PURE__ */ new Map());
|
|
1010
|
+
u(this, "pillTooltipCleanups", /* @__PURE__ */ new Map());
|
|
1011
|
+
// DOM elements
|
|
1012
|
+
u(this, "input");
|
|
1013
|
+
u(this, "dropdown");
|
|
1014
|
+
u(this, "pillsContainer");
|
|
1015
|
+
u(this, "countBadge");
|
|
1016
|
+
u(this, "hint");
|
|
1017
|
+
u(this, "selectedPopover");
|
|
1018
|
+
this.element = e, this.instanceId = `MS-${Math.random().toString(36).substr(2, 9)}`, this.options = {
|
|
1019
|
+
// String options
|
|
1020
|
+
searchHint: e.dataset.searchHint || "",
|
|
1021
|
+
searchPlaceholder: e.dataset.searchPlaceholder || "Search...",
|
|
1022
|
+
dropdownMinWidth: e.dataset.dropdownMinWidth || void 0,
|
|
1023
|
+
pillsDisplayMode: e.dataset.pillsDisplayMode || "pills",
|
|
1024
|
+
pillsPosition: e.dataset.pillsPosition || "bottom",
|
|
1025
|
+
pillsThresholdMode: e.dataset.pillsThresholdMode || "count",
|
|
1026
|
+
maxHeight: e.dataset.maxHeight || "20rem",
|
|
1027
|
+
emptyMessage: e.dataset.emptyMessage || "No results found",
|
|
1028
|
+
loadingMessage: e.dataset.loadingMessage || "Loading...",
|
|
1029
|
+
searchInputMode: e.dataset.searchInputMode || "normal",
|
|
1030
|
+
// Number options
|
|
1031
|
+
pillsThreshold: e.dataset.pillsThreshold ? parseInt(e.dataset.pillsThreshold) : void 0,
|
|
1032
|
+
minSearchLength: parseInt(e.dataset.minSearchLength || "0") || 0,
|
|
1033
|
+
// Boolean options (internal names with 'is' prefix)
|
|
1034
|
+
isMultipleEnabled: e.dataset.multiple !== "false",
|
|
1035
|
+
isGroupsAllowed: e.dataset.allowGroups !== "false",
|
|
1036
|
+
isSelectAllAllowed: e.dataset.allowSelectAll !== "false",
|
|
1037
|
+
isClearAllAllowed: e.dataset.allowClearAll !== "false",
|
|
1038
|
+
isCheckboxesShown: e.dataset.showCheckboxes !== "false",
|
|
1039
|
+
isActionsSticky: e.dataset.stickyActions !== "false",
|
|
1040
|
+
isCloseOnSelect: e.dataset.closeOnSelect === "true",
|
|
1041
|
+
isPlacementLocked: e.dataset.lockPlacement !== "false",
|
|
1042
|
+
isSearchEnabled: e.dataset.enableSearch !== "false",
|
|
1043
|
+
isAddNewAllowed: e.dataset.allowAddNew === "true",
|
|
1044
|
+
isCountBadgeShown: e.dataset.showCountBadge === "true",
|
|
1045
|
+
// Data and callbacks
|
|
1046
|
+
options: [],
|
|
1047
|
+
container: void 0,
|
|
1048
|
+
// Override with provided options
|
|
1049
|
+
...t
|
|
1050
|
+
}, this.init();
|
|
1051
|
+
}
|
|
1052
|
+
// ========================================================================
|
|
1053
|
+
// DATA EXTRACTION METHODS (following svelte-treeview pattern)
|
|
1054
|
+
// ========================================================================
|
|
1055
|
+
/**
|
|
1056
|
+
* Extract value/ID from item
|
|
1057
|
+
* Precedence: tuple[0] -> valueMember -> getValueCallback -> '[N/A]'
|
|
1058
|
+
*/
|
|
1059
|
+
getItemValue(e) {
|
|
1060
|
+
return Array.isArray(e) && e.length === 2 ? e[0] : this.options.valueMember && e[this.options.valueMember] !== void 0 ? e[this.options.valueMember] : this.options.getValueCallback ? this.options.getValueCallback(e) : "[N/A]";
|
|
1061
|
+
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Extract display value from item
|
|
1064
|
+
* Precedence: tuple[1] -> displayValueMember -> getDisplayValueCallback -> '[N/A]'
|
|
1065
|
+
*/
|
|
1066
|
+
getItemDisplayValue(e) {
|
|
1067
|
+
return Array.isArray(e) && e.length === 2 ? String(e[1]) : this.options.displayValueMember && e[this.options.displayValueMember] !== void 0 ? String(e[this.options.displayValueMember]) : this.options.getDisplayValueCallback ? this.options.getDisplayValueCallback(e) : "[N/A]";
|
|
1068
|
+
}
|
|
1069
|
+
/**
|
|
1070
|
+
* Extract search value from item
|
|
1071
|
+
* Precedence: searchValueMember -> getSearchValueCallback -> displayValue
|
|
1072
|
+
*/
|
|
1073
|
+
getItemSearchValue(e) {
|
|
1074
|
+
return this.options.searchValueMember && e[this.options.searchValueMember] !== void 0 ? String(e[this.options.searchValueMember]) : this.options.getSearchValueCallback ? this.options.getSearchValueCallback(e) : this.getItemDisplayValue(e);
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Extract icon from item
|
|
1078
|
+
*/
|
|
1079
|
+
getItemIcon(e) {
|
|
1080
|
+
if (!Array.isArray(e)) {
|
|
1081
|
+
if (this.options.iconMember && e[this.options.iconMember] !== void 0)
|
|
1082
|
+
return String(e[this.options.iconMember]);
|
|
1083
|
+
if (this.options.getIconCallback)
|
|
1084
|
+
return this.options.getIconCallback(e);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
/**
|
|
1088
|
+
* Extract subtitle from item
|
|
1089
|
+
*/
|
|
1090
|
+
getItemSubtitle(e) {
|
|
1091
|
+
if (!Array.isArray(e)) {
|
|
1092
|
+
if (this.options.subtitleMember && e[this.options.subtitleMember] !== void 0)
|
|
1093
|
+
return String(e[this.options.subtitleMember]);
|
|
1094
|
+
if (this.options.getSubtitleCallback)
|
|
1095
|
+
return this.options.getSubtitleCallback(e);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Extract group from item
|
|
1100
|
+
*/
|
|
1101
|
+
getItemGroup(e) {
|
|
1102
|
+
if (!Array.isArray(e)) {
|
|
1103
|
+
if (this.options.groupMember && e[this.options.groupMember] !== void 0)
|
|
1104
|
+
return String(e[this.options.groupMember]);
|
|
1105
|
+
if (this.options.getGroupCallback)
|
|
1106
|
+
return this.options.getGroupCallback(e);
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Extract disabled state from item
|
|
1111
|
+
*/
|
|
1112
|
+
getItemDisabled(e) {
|
|
1113
|
+
return Array.isArray(e) ? !1 : this.options.disabledMember && e[this.options.disabledMember] !== void 0 ? !!e[this.options.disabledMember] : this.options.getDisabledCallback ? this.options.getDisabledCallback(e) : !1;
|
|
1114
|
+
}
|
|
1115
|
+
init() {
|
|
1116
|
+
this.parseOptions(), this.buildHTML(), this.attachEvents(), this.parseInitialSelection(), f.debug(`Initialized [${this.instanceId}] with options:`, {
|
|
1117
|
+
placeholder: this.options.searchPlaceholder,
|
|
1118
|
+
totalOptions: this.allOptions.length,
|
|
1119
|
+
isCloseOnSelect: this.options.isCloseOnSelect,
|
|
1120
|
+
dataAttribute: this.element.dataset.closeOnSelect,
|
|
1121
|
+
isSelectAllAllowed: this.options.isSelectAllAllowed,
|
|
1122
|
+
isClearAllAllowed: this.options.isClearAllAllowed
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
parseOptions() {
|
|
1126
|
+
const e = this.element.dataset.options;
|
|
1127
|
+
if (e)
|
|
1128
|
+
try {
|
|
1129
|
+
this.allOptions = JSON.parse(e);
|
|
1130
|
+
} catch (t) {
|
|
1131
|
+
console.error("[MultiSelect] Failed to parse data-options:", t), this.allOptions = [];
|
|
1132
|
+
}
|
|
1133
|
+
else this.options.options && (this.allOptions = this.options.options);
|
|
1134
|
+
this.filteredOptions = [...this.allOptions];
|
|
1135
|
+
}
|
|
1136
|
+
buildHTML() {
|
|
1137
|
+
const e = this.options.container || document.body;
|
|
1138
|
+
this.element.classList.add("ml"), (!this.options.isCheckboxesShown || !this.options.isMultipleEnabled) && this.element.classList.add("ml--no-checkboxes");
|
|
1139
|
+
const t = document.createElement("div");
|
|
1140
|
+
t.className = "ml__input-wrapper", this.input = document.createElement("input"), this.input.type = "text", this.input.className = "ml__input", this.input.placeholder = this.options.searchPlaceholder, this.input.autocomplete = "off", this.options.searchInputMode === "readonly" ? this.input.readOnly = !0 : this.options.searchInputMode === "hidden" && (this.input.style.display = "none");
|
|
1141
|
+
const o = document.createElement("span");
|
|
1142
|
+
o.className = "ml__toggle", o.innerHTML = "▼", this.countBadge = document.createElement("span"), this.countBadge.className = "ml__count-badge", this.countBadge.style.display = "none", t.appendChild(this.input), t.appendChild(this.countBadge), t.appendChild(o), this.pillsContainer = document.createElement("div"), this.pillsContainer.className = "ml__pills", this.element.appendChild(t), this.element.appendChild(this.pillsContainer), this.dropdown = document.createElement("div"), this.dropdown.className = "ml__dropdown", e.appendChild(this.dropdown), this.options.searchHint && (this.hint = document.createElement("div"), this.hint.className = "ml__hint", this.hint.textContent = this.options.searchHint, e.appendChild(this.hint)), this.selectedPopover = document.createElement("div"), this.selectedPopover.className = "ml__selected-popover", e.appendChild(this.selectedPopover), this.renderDropdown();
|
|
1143
|
+
}
|
|
1144
|
+
renderDropdown() {
|
|
1145
|
+
let e = "";
|
|
1146
|
+
if (this.isLoading) {
|
|
1147
|
+
e += '<div class="ml__loader">', e += '<div class="pa-loader pa-loader--sm"></div>', e += `<div class="ml__loading-text">${this.options.loadingMessage}</div>`, e += "</div>", this.dropdown.innerHTML = e;
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
if (this.options.isMultipleEnabled && (this.options.isSelectAllAllowed || this.options.isClearAllAllowed)) {
|
|
1151
|
+
const t = this.options.isActionsSticky ? " ml__actions--sticky" : "";
|
|
1152
|
+
e += `<div class="ml__actions${t}">`, this.options.isSelectAllAllowed && (e += '<button type="button" class="ml__action-btn" data-action="select-all">Select All</button>'), this.options.isClearAllAllowed && (e += '<button type="button" class="ml__action-btn" data-action="clear-all">Clear All</button>'), e += "</div>";
|
|
1153
|
+
}
|
|
1154
|
+
if (e += '<div class="ml__options">', this.filteredOptions.length === 0)
|
|
1155
|
+
e += `<div class="ml__empty">${this.options.emptyMessage}</div>`;
|
|
1156
|
+
else if (this.options.isGroupsAllowed) {
|
|
1157
|
+
const t = this.groupOptions(this.filteredOptions);
|
|
1158
|
+
Object.keys(t).forEach((o) => {
|
|
1159
|
+
e += '<div class="ml__group">', o !== "__ungrouped__" && (e += `<div class="ml__group-label">${o}</div>`), t[o].forEach((s, l) => {
|
|
1160
|
+
e += this.renderOption(s, l);
|
|
1161
|
+
}), e += "</div>";
|
|
1162
|
+
});
|
|
1163
|
+
} else
|
|
1164
|
+
this.filteredOptions.forEach((t, o) => {
|
|
1165
|
+
e += this.renderOption(t, o);
|
|
1166
|
+
});
|
|
1167
|
+
e += "</div>", this.dropdown.innerHTML = e;
|
|
1168
|
+
}
|
|
1169
|
+
renderOption(e, t) {
|
|
1170
|
+
const o = this.getItemValue(e), s = this.getItemDisplayValue(e), l = this.getItemIcon(e), n = this.getItemSubtitle(e), r = this.getItemDisabled(e), a = this.selectedValues.has(String(o)), c = t === this.focusedIndex, p = ["ml__option"];
|
|
1171
|
+
a && p.push("ml__option--selected"), c && p.push("ml__option--focused"), r && p.push("ml__option--disabled");
|
|
1172
|
+
let d = `<div class="${p.join(" ")}" data-value="${o}" data-index="${t}">`;
|
|
1173
|
+
return this.options.isCheckboxesShown && this.options.isMultipleEnabled && (d += `<input type="checkbox" class="ml__checkbox" ${a ? "checked" : ""} ${r ? "disabled" : ""}>`), d += '<div class="ml__option-content">', l && (d += `<span class="ml__option-icon">${l}</span>`), d += '<div class="ml__option-text">', d += `<div class="ml__option-title">${this.highlightMatch(s, this.searchTerm)}</div>`, n && (d += `<div class="ml__option-subtitle">${n}</div>`), d += "</div>", d += "</div>", d += "</div>", d;
|
|
1174
|
+
}
|
|
1175
|
+
highlightMatch(e, t) {
|
|
1176
|
+
if (!t) return e;
|
|
1177
|
+
const o = new RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi");
|
|
1178
|
+
return e.replace(o, "<mark>$1</mark>");
|
|
1179
|
+
}
|
|
1180
|
+
groupOptions(e) {
|
|
1181
|
+
const t = {};
|
|
1182
|
+
return e.forEach((o) => {
|
|
1183
|
+
const s = this.getItemGroup(o) || "__ungrouped__";
|
|
1184
|
+
t[s] || (t[s] = []), t[s].push(o);
|
|
1185
|
+
}), t;
|
|
1186
|
+
}
|
|
1187
|
+
renderPills() {
|
|
1188
|
+
this.destroyAllPillTooltips();
|
|
1189
|
+
const e = Array.from(this.selectedOptions.values()), t = this.selectedValues.size;
|
|
1190
|
+
if (!this.options.isMultipleEnabled) {
|
|
1191
|
+
this.pillsContainer.innerHTML = "", this.countBadge.style.display = "none";
|
|
1192
|
+
const l = e[0] ? this.getItemDisplayValue(e[0]) : void 0;
|
|
1193
|
+
f.warn(`[${this.instanceId}] renderPills() single-select mode`, {
|
|
1194
|
+
isOpen: this.isOpen,
|
|
1195
|
+
count: t,
|
|
1196
|
+
selectedOptionsLength: e.length,
|
|
1197
|
+
willSetValue: !this.isOpen && t > 0 && e.length > 0,
|
|
1198
|
+
selectedLabel: l
|
|
1199
|
+
}), !this.isOpen && t > 0 && e.length > 0 ? (f.info(`[${this.instanceId}] ✅ SETTING input.value = "${l}"`), this.input.value = l, f.info(`[${this.instanceId}] 🔍 VERIFY input.value = "${this.input.value}"`)) : this.isOpen ? f.info(`[${this.instanceId}] ⏭️ SKIPPING input update (dropdown is open)`) : (f.info(`[${this.instanceId}] ❌ CLEARING input.value (no selection)`), this.input.value = "");
|
|
1200
|
+
return;
|
|
1201
|
+
}
|
|
1202
|
+
let o = this.options.pillsDisplayMode;
|
|
1203
|
+
if (this.options.pillsThreshold !== null && t > this.options.pillsThreshold && (o = this.options.pillsThresholdMode || "count"), !this.isOpen)
|
|
1204
|
+
if (t > 0 && o === "count") {
|
|
1205
|
+
const l = this.options.getCountPillCallback ? this.options.getCountPillCallback(t) : `${t} selected`;
|
|
1206
|
+
this.input.placeholder = l;
|
|
1207
|
+
} else
|
|
1208
|
+
this.input.placeholder = this.options.searchPlaceholder;
|
|
1209
|
+
if (this.options.isCountBadgeShown && t > 0 ? (this.countBadge.textContent = `[${t}]`, this.countBadge.style.display = "") : this.countBadge.style.display = "none", o === "pills")
|
|
1210
|
+
this.pillsContainer.className = `ml__pills ml__pills--${this.options.pillsPosition}`, this.pillsContainer.innerHTML = e.map((l) => {
|
|
1211
|
+
const n = this.getItemValue(l), r = this.getItemDisplayValue(l);
|
|
1212
|
+
return `
|
|
1213
|
+
<div class="ml__pill">
|
|
1214
|
+
<span class="ml__pill-text">${r}</span>
|
|
1215
|
+
<button type="button" class="ml__pill-remove" data-value="${n}" aria-label="Remove ${r}"></button>
|
|
1216
|
+
</div>
|
|
1217
|
+
`;
|
|
1218
|
+
}).join("");
|
|
1219
|
+
else if (o === "partial") {
|
|
1220
|
+
this.pillsContainer.className = `ml__pills ml__pills--${this.options.pillsPosition}`;
|
|
1221
|
+
const l = this.options.pillsMaxVisible || 3, n = e.slice(0, l), r = t - l, a = n.map((p) => {
|
|
1222
|
+
const d = this.getItemValue(p), m = this.getItemDisplayValue(p);
|
|
1223
|
+
return `
|
|
1224
|
+
<div class="ml__pill">
|
|
1225
|
+
<span class="ml__pill-text">${m}</span>
|
|
1226
|
+
<button type="button" class="ml__pill-remove" data-value="${d}" aria-label="Remove ${m}"></button>
|
|
1227
|
+
</div>
|
|
1228
|
+
`;
|
|
1229
|
+
}).join("");
|
|
1230
|
+
let c = "";
|
|
1231
|
+
r > 0 && (c = `
|
|
1232
|
+
<div class="ml__pill ml__pill--more" data-action="show-selected">
|
|
1233
|
+
<span class="ml__pill-text">${this.options.getCountPillCallback ? this.options.getCountPillCallback(t, r) : `+${r} more`}</span>
|
|
1234
|
+
<button type="button" class="ml__pill-remove" data-action="remove-hidden" aria-label="Remove ${r} hidden items"></button>
|
|
1235
|
+
</div>
|
|
1236
|
+
`), this.pillsContainer.innerHTML = a + c;
|
|
1237
|
+
} else if (this.pillsContainer.className = `ml__count-display ml__count-display--${this.options.pillsPosition}`, t > 0) {
|
|
1238
|
+
const l = this.options.getCountPillCallback ? this.options.getCountPillCallback(t) : `${t} selected`;
|
|
1239
|
+
this.pillsContainer.innerHTML = `
|
|
1240
|
+
<div class="ml__count-badge-wrapper">
|
|
1241
|
+
<button type="button" class="ml__count-text" data-action="show-selected">
|
|
1242
|
+
${l}
|
|
1243
|
+
</button>
|
|
1244
|
+
<button type="button" class="ml__count-clear" data-action="clear-count" aria-label="Clear all selections"></button>
|
|
1245
|
+
</div>
|
|
1246
|
+
`;
|
|
1247
|
+
} else
|
|
1248
|
+
this.pillsContainer.innerHTML = "";
|
|
1249
|
+
this.attachPillTooltips();
|
|
1250
|
+
}
|
|
1251
|
+
attachEvents() {
|
|
1252
|
+
this.input.addEventListener("mousedown", (e) => {
|
|
1253
|
+
this.isOpen || e.stopPropagation();
|
|
1254
|
+
}), this.input.addEventListener("focus", () => this.open()), this.input.addEventListener("input", (e) => {
|
|
1255
|
+
const t = e.target.value;
|
|
1256
|
+
this.options.isSearchEnabled && !this.isOpen && this.open(), this.handleSearch(t);
|
|
1257
|
+
}), this.input.addEventListener("keydown", (e) => this.handleKeydown(e)), setTimeout(() => {
|
|
1258
|
+
document.addEventListener("click", (e) => this.handleClickOutside(e));
|
|
1259
|
+
}, 0), this.dropdown.addEventListener("click", (e) => this.handleDropdownClick(e)), this.pillsContainer.addEventListener("mousedown", (e) => {
|
|
1260
|
+
e.target.closest(".ml__count-text") && !this.showSelectedPopover && e.stopPropagation();
|
|
1261
|
+
}), this.pillsContainer.addEventListener("click", (e) => this.handlePillClick(e)), this.countBadge.addEventListener("mousedown", (e) => {
|
|
1262
|
+
this.showSelectedPopover || e.stopPropagation();
|
|
1263
|
+
}), this.countBadge.addEventListener("click", (e) => {
|
|
1264
|
+
e.stopPropagation(), this.toggleSelectedPopover();
|
|
1265
|
+
}), this.selectedPopover.addEventListener("click", (e) => this.handleSelectedPopoverClick(e));
|
|
1266
|
+
}
|
|
1267
|
+
async handleSearch(e) {
|
|
1268
|
+
if (this.searchTerm = e, !!this.options.isSearchEnabled)
|
|
1269
|
+
if (this.options.searchCallback) {
|
|
1270
|
+
if (e.length < this.options.minSearchLength) {
|
|
1271
|
+
this.filteredOptions = [], this.allOptions = [], this.renderDropdown();
|
|
1272
|
+
return;
|
|
1273
|
+
}
|
|
1274
|
+
this.isLoading = !0, this.renderDropdown(), f.debug(`[${this.instanceId}] Loading data for search term:`, e);
|
|
1275
|
+
try {
|
|
1276
|
+
const t = await this.options.searchCallback(e);
|
|
1277
|
+
this.searchTerm === e && (this.allOptions = t || [], this.filteredOptions = [...this.allOptions], this.isLoading = !1, this.focusedIndex = this.options.isSearchEnabled && this.filteredOptions.length > 0 ? 0 : -1, this.renderDropdown(), f.debug(`[${this.instanceId}] Loaded ${this.allOptions.length} results`));
|
|
1278
|
+
} catch (t) {
|
|
1279
|
+
f.error(`[${this.instanceId}] Error loading data:`, t), this.isLoading = !1, this.filteredOptions = [], this.allOptions = [], this.renderDropdown();
|
|
1280
|
+
}
|
|
1281
|
+
} else
|
|
1282
|
+
e ? this.filteredOptions = this.allOptions.filter((t) => this.getItemSearchValue(t).toLowerCase().includes(e.toLowerCase())) : this.filteredOptions = [...this.allOptions], this.focusedIndex = this.options.isSearchEnabled && this.filteredOptions.length > 0 ? 0 : -1, this.renderDropdown();
|
|
1283
|
+
}
|
|
1284
|
+
handleKeydown(e) {
|
|
1285
|
+
if (!this.isOpen) {
|
|
1286
|
+
(e.key === "Enter" || e.key === "ArrowDown") && (e.preventDefault(), this.open());
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
if (!this.options.isSearchEnabled) {
|
|
1290
|
+
const t = e.key.length === 1 || e.key === "Backspace" || e.key === "Delete", o = ["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End", "Enter", "Escape", "Tab"].includes(e.key);
|
|
1291
|
+
if (t && !o) {
|
|
1292
|
+
e.preventDefault();
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
switch (e.key) {
|
|
1297
|
+
case "ArrowDown":
|
|
1298
|
+
e.preventDefault(), this.focusNext();
|
|
1299
|
+
break;
|
|
1300
|
+
case "ArrowUp":
|
|
1301
|
+
e.preventDefault(), this.focusPrevious();
|
|
1302
|
+
break;
|
|
1303
|
+
case "Enter":
|
|
1304
|
+
e.preventDefault(), this.focusedIndex >= 0 ? this.toggleOption(this.filteredOptions[this.focusedIndex]) : this.options.isAddNewAllowed && this.options.addNewCallback && this.input.value.trim() && this.handleAddNew(this.input.value.trim());
|
|
1305
|
+
break;
|
|
1306
|
+
case "Escape":
|
|
1307
|
+
e.preventDefault(), this.close();
|
|
1308
|
+
break;
|
|
1309
|
+
case "Tab":
|
|
1310
|
+
this.close();
|
|
1311
|
+
break;
|
|
1312
|
+
case "PageUp":
|
|
1313
|
+
e.preventDefault(), this.focusPageUp();
|
|
1314
|
+
break;
|
|
1315
|
+
case "PageDown":
|
|
1316
|
+
e.preventDefault(), this.focusPageDown();
|
|
1317
|
+
break;
|
|
1318
|
+
case "Home":
|
|
1319
|
+
e.preventDefault(), this.focusFirst();
|
|
1320
|
+
break;
|
|
1321
|
+
case "End":
|
|
1322
|
+
e.preventDefault(), this.focusLast();
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
handleDropdownClick(e) {
|
|
1327
|
+
f.debug(`[${this.instanceId}] Dropdown clicked`, { target: e.target.className }), e.stopPropagation();
|
|
1328
|
+
const t = e.target.closest("[data-action]");
|
|
1329
|
+
if (t) {
|
|
1330
|
+
e.preventDefault();
|
|
1331
|
+
const s = t.dataset.action;
|
|
1332
|
+
f.debug(`[${this.instanceId}] Action button clicked:`, s), s === "select-all" ? this.selectAll() : s === "clear-all" && this.clearAll();
|
|
1333
|
+
return;
|
|
1334
|
+
}
|
|
1335
|
+
const o = e.target.closest(".ml__option");
|
|
1336
|
+
if (o && !o.classList.contains("ml__option--disabled")) {
|
|
1337
|
+
e.preventDefault();
|
|
1338
|
+
const s = o.dataset.value, l = this.filteredOptions.find((n) => String(this.getItemValue(n)) === s);
|
|
1339
|
+
f.debug(`[${this.instanceId}] Option clicked:`, {
|
|
1340
|
+
value: s,
|
|
1341
|
+
closeOnSelect: this.options.isCloseOnSelect,
|
|
1342
|
+
placeholder: this.options.searchPlaceholder
|
|
1343
|
+
}), l && this.toggleOption(l);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
handlePillClick(e) {
|
|
1347
|
+
if (e.target.closest(".ml__count-clear")) {
|
|
1348
|
+
e.preventDefault(), e.stopPropagation(), f.debug(`[${this.instanceId}] Count clear button clicked`), this.clearAll();
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
if (e.target.closest(".ml__count-text")) {
|
|
1352
|
+
e.preventDefault(), e.stopPropagation(), this.toggleSelectedPopover();
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
const s = e.target.closest(".ml__pill-remove");
|
|
1356
|
+
if (s) {
|
|
1357
|
+
if (e.preventDefault(), e.stopPropagation(), s.dataset.action === "remove-hidden") {
|
|
1358
|
+
f.debug(`[${this.instanceId}] Remove hidden items button clicked`);
|
|
1359
|
+
const a = this.options.pillsMaxVisible || 3;
|
|
1360
|
+
Array.from(this.selectedOptions.values()).slice(a).forEach((d) => this.deselectOption(d));
|
|
1361
|
+
return;
|
|
1362
|
+
}
|
|
1363
|
+
const n = s.dataset.value, r = this.selectedOptions.get(n);
|
|
1364
|
+
r && this.deselectOption(r);
|
|
1365
|
+
return;
|
|
1366
|
+
}
|
|
1367
|
+
if (e.target.closest(".ml__pill--more") && !e.target.closest(".ml__pill-remove")) {
|
|
1368
|
+
e.preventDefault(), e.stopPropagation(), f.debug(`[${this.instanceId}] '+X more' badge clicked, showing popover`), this.toggleSelectedPopover();
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
handleClickOutside(e) {
|
|
1373
|
+
var s;
|
|
1374
|
+
const t = e.composedPath();
|
|
1375
|
+
if (this.showSelectedPopover && !t.some(
|
|
1376
|
+
(n) => n instanceof Node && (this.selectedPopover.contains(n) || this.countBadge.contains(n) || n.closest && n.closest(".ml__count-text"))
|
|
1377
|
+
)) {
|
|
1378
|
+
f.debug(`[${this.instanceId}] Closing selected popover due to click outside`), this.hideSelectedPopover();
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
if (!this.isOpen) return;
|
|
1382
|
+
const o = t.some(
|
|
1383
|
+
(l) => l instanceof Node && (this.element.contains(l) || this.dropdown.contains(l) || this.hint && this.hint.contains(l))
|
|
1384
|
+
);
|
|
1385
|
+
f.debug(`[${this.instanceId}] handleClickOutside`, {
|
|
1386
|
+
target: e.target.className,
|
|
1387
|
+
targetTag: e.target.tagName,
|
|
1388
|
+
clickedInside: o,
|
|
1389
|
+
pathLength: t.length,
|
|
1390
|
+
firstInPath: (s = t[0]) == null ? void 0 : s.tagName,
|
|
1391
|
+
elementContains: t.some((l) => l instanceof Node && this.element.contains(l)),
|
|
1392
|
+
dropdownContains: t.some((l) => l instanceof Node && this.dropdown.contains(l)),
|
|
1393
|
+
isConnected: this.dropdown.isConnected
|
|
1394
|
+
}), o || (f.warn(`[${this.instanceId}] Closing dropdown due to click outside`), this.close());
|
|
1395
|
+
}
|
|
1396
|
+
focusNext() {
|
|
1397
|
+
this.filteredOptions.length !== 0 && (this.focusedIndex = (this.focusedIndex + 1) % this.filteredOptions.length, this.renderDropdown(), this.scrollToFocused());
|
|
1398
|
+
}
|
|
1399
|
+
focusPrevious() {
|
|
1400
|
+
this.filteredOptions.length !== 0 && (this.focusedIndex = this.focusedIndex <= 0 ? this.filteredOptions.length - 1 : this.focusedIndex - 1, this.renderDropdown(), this.scrollToFocused());
|
|
1401
|
+
}
|
|
1402
|
+
focusFirst() {
|
|
1403
|
+
this.filteredOptions.length !== 0 && (this.focusedIndex = 0, this.renderDropdown(), this.scrollToFocused());
|
|
1404
|
+
}
|
|
1405
|
+
focusLast() {
|
|
1406
|
+
this.filteredOptions.length !== 0 && (this.focusedIndex = this.filteredOptions.length - 1, this.renderDropdown(), this.scrollToFocused());
|
|
1407
|
+
}
|
|
1408
|
+
focusPageUp() {
|
|
1409
|
+
this.filteredOptions.length !== 0 && (this.focusedIndex = Math.max(0, this.focusedIndex - 10), this.renderDropdown(), this.scrollToFocused());
|
|
1410
|
+
}
|
|
1411
|
+
focusPageDown() {
|
|
1412
|
+
this.filteredOptions.length !== 0 && (this.focusedIndex = Math.min(this.filteredOptions.length - 1, this.focusedIndex + 10), this.renderDropdown(), this.scrollToFocused());
|
|
1413
|
+
}
|
|
1414
|
+
scrollToFocused() {
|
|
1415
|
+
const e = this.dropdown.querySelector(".ml__option--focused");
|
|
1416
|
+
e && e.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
|
1417
|
+
}
|
|
1418
|
+
toggleOption(e) {
|
|
1419
|
+
const t = this.getItemValue(e), o = String(t);
|
|
1420
|
+
if (f.debug(`[${this.instanceId}] toggleOption called`, { value: t, multiple: this.options.isMultipleEnabled }), !this.options.isMultipleEnabled) {
|
|
1421
|
+
this.selectedValues.has(o) ? (f.debug(`[${this.instanceId}] Deselecting option in single-select mode`, { value: t }), this.deselectOption(e)) : (f.debug(`[${this.instanceId}] Clearing previous selections and selecting new option`, { value: t }), this.selectedValues.clear(), this.selectedOptions.clear(), this.selectOption(e)), f.info(`[${this.instanceId}] ❌ Closing dropdown (single-select mode)`), this.close();
|
|
1422
|
+
return;
|
|
1423
|
+
}
|
|
1424
|
+
this.selectedValues.has(o) ? (f.debug(`[${this.instanceId}] Deselecting option`, { value: t }), this.deselectOption(e)) : (f.debug(`[${this.instanceId}] Selecting option`, { value: t }), this.selectOption(e)), f.debug(`[${this.instanceId}] Checking closeOnSelect`, {
|
|
1425
|
+
closeOnSelect: this.options.isCloseOnSelect,
|
|
1426
|
+
willClose: this.options.isCloseOnSelect === !0,
|
|
1427
|
+
placeholder: this.options.searchPlaceholder
|
|
1428
|
+
}), this.options.isCloseOnSelect ? (f.info(`[${this.instanceId}] ❌ Closing dropdown (closeOnSelect=true)`), this.close()) : f.info(`[${this.instanceId}] ✅ Keeping dropdown open (closeOnSelect=false)`);
|
|
1429
|
+
}
|
|
1430
|
+
async handleAddNew(e) {
|
|
1431
|
+
if (this.options.addNewCallback)
|
|
1432
|
+
try {
|
|
1433
|
+
f.debug(`[${this.instanceId}] Adding new option:`, e);
|
|
1434
|
+
const t = await this.options.addNewCallback(e);
|
|
1435
|
+
this.allOptions.push(t), this.filteredOptions.push(t), this.selectOption(t), this.input.value = "", this.renderDropdown(), this.renderPills(), this.options.isCloseOnSelect && this.close();
|
|
1436
|
+
} catch (t) {
|
|
1437
|
+
f.error(`[${this.instanceId}] Error adding new option:`, t);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
selectOption(e) {
|
|
1441
|
+
const t = this.getItemValue(e), o = String(t);
|
|
1442
|
+
this.selectedValues.add(o), this.selectedOptions.set(o, e), this.renderDropdown(), this.renderPills(), this.updateHiddenInput(), this.options.selectCallback && this.options.selectCallback(e), this.options.changeCallback && this.options.changeCallback(this.getSelected());
|
|
1443
|
+
}
|
|
1444
|
+
deselectOption(e) {
|
|
1445
|
+
const t = this.getItemValue(e), o = String(t);
|
|
1446
|
+
this.selectedValues.delete(o), this.selectedOptions.delete(o), this.renderDropdown(), this.renderPills(), this.updateHiddenInput(), this.options.deselectCallback && this.options.deselectCallback(e), this.options.changeCallback && this.options.changeCallback(this.getSelected());
|
|
1447
|
+
}
|
|
1448
|
+
selectAll() {
|
|
1449
|
+
this.filteredOptions.forEach((e) => {
|
|
1450
|
+
if (!this.getItemDisabled(e)) {
|
|
1451
|
+
const t = this.getItemValue(e), o = String(t);
|
|
1452
|
+
this.selectedValues.add(o), this.selectedOptions.set(o, e);
|
|
1453
|
+
}
|
|
1454
|
+
}), this.renderDropdown(), this.renderPills(), this.updateHiddenInput(), this.options.changeCallback && this.options.changeCallback(this.getSelected());
|
|
1455
|
+
}
|
|
1456
|
+
clearAll() {
|
|
1457
|
+
this.selectedValues.clear(), this.selectedOptions.clear(), this.renderDropdown(), this.renderPills(), this.updateHiddenInput(), this.options.changeCallback && this.options.changeCallback(this.getSelected());
|
|
1458
|
+
}
|
|
1459
|
+
open() {
|
|
1460
|
+
f.debug(`[${this.instanceId}] open() called`, { isOpen: this.isOpen }), !this.isOpen && (this.isOpen = !0, this.element.classList.add("ml--open"), this.dropdown.classList.add("ml__dropdown--visible"), f.info(`[${this.instanceId}] Dropdown opened`), this.input.placeholder = this.options.searchPlaceholder, !this.options.isMultipleEnabled && this.options.isSearchEnabled && (this.input.value = ""), this.renderDropdown(), this.positionDropdown(), this.hint && (this.hint.classList.add("ml__hint--visible"), this.positionHint()));
|
|
1461
|
+
}
|
|
1462
|
+
close() {
|
|
1463
|
+
if (f.debug(`[${this.instanceId}] close() called`, { isOpen: this.isOpen }), !this.isOpen) return;
|
|
1464
|
+
this.isOpen = !1, this.element.classList.remove("ml--open"), this.dropdown.classList.remove("ml__dropdown--visible"), this.hint && this.hint.classList.remove("ml__hint--visible"), this.searchTerm = "";
|
|
1465
|
+
const e = this.options.isMultipleEnabled || this.options.isSearchEnabled;
|
|
1466
|
+
f.warn(`[${this.instanceId}] close() - input clearing decision`, {
|
|
1467
|
+
multiple: this.options.isMultipleEnabled,
|
|
1468
|
+
enableSearch: this.options.isSearchEnabled,
|
|
1469
|
+
willClearInput: e,
|
|
1470
|
+
currentInputValue: this.input.value
|
|
1471
|
+
}), e ? (f.info(`[${this.instanceId}] 🧹 close() CLEARING input.value`), this.input.value = "") : f.info(`[${this.instanceId}] 🔒 close() KEEPING input.value = "${this.input.value}"`), this.filteredOptions = [...this.allOptions], this.focusedIndex = -1, f.info(`[${this.instanceId}] 📞 close() CALLING renderPills()`), this.renderPills(), f.info(`[${this.instanceId}] ✅ close() AFTER renderPills(), input.value = "${this.input.value}"`), this.dropdownCleanup && (this.dropdownCleanup(), this.dropdownCleanup = null), this.hintCleanup && (this.hintCleanup(), this.hintCleanup = null), this.dropdownPlacement = null, f.info(`[${this.instanceId}] Dropdown closed. Stack trace:`), console.trace();
|
|
1472
|
+
}
|
|
1473
|
+
positionDropdown() {
|
|
1474
|
+
this.dropdownCleanup = q(
|
|
1475
|
+
this.input,
|
|
1476
|
+
this.dropdown,
|
|
1477
|
+
() => {
|
|
1478
|
+
const e = this.options.isPlacementLocked && this.dropdownPlacement ? this.dropdownPlacement : "bottom-start", t = [
|
|
1479
|
+
Z(4),
|
|
1480
|
+
...this.options.isPlacementLocked && this.dropdownPlacement ? [] : [me()],
|
|
1481
|
+
Q({ padding: 8 })
|
|
1482
|
+
];
|
|
1483
|
+
ee(this.input, this.dropdown, {
|
|
1484
|
+
placement: e,
|
|
1485
|
+
middleware: t
|
|
1486
|
+
}).then(({ x: o, y: s, placement: l }) => {
|
|
1487
|
+
this.options.isPlacementLocked && !this.dropdownPlacement && (this.dropdownPlacement = l, f.debug(`[${this.instanceId}] Locked dropdown placement:`, l));
|
|
1488
|
+
const n = {
|
|
1489
|
+
left: `${o}px`,
|
|
1490
|
+
top: `${s}px`,
|
|
1491
|
+
width: `${this.input.offsetWidth}px`
|
|
1492
|
+
};
|
|
1493
|
+
this.options.dropdownMinWidth && (n.minWidth = this.options.dropdownMinWidth), Object.assign(this.dropdown.style, n), this.hint && this.isOpen && this.positionHint();
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
);
|
|
1497
|
+
}
|
|
1498
|
+
positionHint() {
|
|
1499
|
+
this.hint && (this.hintCleanup && this.hintCleanup(), this.hintCleanup = q(
|
|
1500
|
+
this.input,
|
|
1501
|
+
this.hint,
|
|
1502
|
+
() => {
|
|
1503
|
+
let e = "top-start";
|
|
1504
|
+
this.dropdownPlacement && (this.dropdownPlacement.startsWith("bottom") ? e = this.dropdownPlacement.replace("bottom", "top") : this.dropdownPlacement.startsWith("top") && (e = this.dropdownPlacement.replace("top", "bottom"))), ee(this.input, this.hint, {
|
|
1505
|
+
placement: e,
|
|
1506
|
+
middleware: [
|
|
1507
|
+
Z(4),
|
|
1508
|
+
// Don't use flip() - we want hint to stay opposite of dropdown
|
|
1509
|
+
Q({ padding: 8 })
|
|
1510
|
+
]
|
|
1511
|
+
}).then(({ x: t, y: o }) => {
|
|
1512
|
+
Object.assign(this.hint.style, {
|
|
1513
|
+
left: `${t}px`,
|
|
1514
|
+
top: `${o}px`
|
|
1515
|
+
});
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
));
|
|
1519
|
+
}
|
|
1520
|
+
parseInitialSelection() {
|
|
1521
|
+
const e = this.element.dataset.initialValues;
|
|
1522
|
+
if (e)
|
|
1523
|
+
try {
|
|
1524
|
+
JSON.parse(e).forEach((o) => {
|
|
1525
|
+
const s = String(o);
|
|
1526
|
+
this.selectedValues.add(s);
|
|
1527
|
+
const l = this.allOptions.find((n) => String(this.getItemValue(n)) === s);
|
|
1528
|
+
l && this.selectedOptions.set(s, l);
|
|
1529
|
+
}), this.renderPills();
|
|
1530
|
+
} catch (t) {
|
|
1531
|
+
console.error("[MultiSelect] Failed to parse initial values:", t);
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
toggleSelectedPopover() {
|
|
1535
|
+
this.showSelectedPopover ? this.hideSelectedPopover() : this.showPopover();
|
|
1536
|
+
}
|
|
1537
|
+
showPopover() {
|
|
1538
|
+
f.debug(`[${this.instanceId}] showPopover() called`), this.isOpen && this.close(), this.showSelectedPopover = !0, this.renderSelectedPopover(), this.selectedPopover.classList.add("ml__selected-popover--visible"), this.positionSelectedPopover();
|
|
1539
|
+
}
|
|
1540
|
+
hideSelectedPopover() {
|
|
1541
|
+
f.debug(`[${this.instanceId}] hideSelectedPopover() called`), this.showSelectedPopover = !1, this.selectedPopover.classList.remove("ml__selected-popover--visible"), this.selectedPopoverPlacement = null, this.selectedPopoverCleanup && (this.selectedPopoverCleanup(), this.selectedPopoverCleanup = null);
|
|
1542
|
+
}
|
|
1543
|
+
renderSelectedPopover() {
|
|
1544
|
+
const e = Array.from(this.selectedOptions.values()), t = this.selectedValues.size;
|
|
1545
|
+
this.selectedPopover.innerHTML = `
|
|
1546
|
+
<div class="ml__selected-popover-header">
|
|
1547
|
+
<span>Selected Items (${t})</span>
|
|
1548
|
+
<button type="button" class="ml__selected-popover-close" aria-label="Close">×</button>
|
|
1549
|
+
</div>
|
|
1550
|
+
<div class="ml__selected-popover-body">
|
|
1551
|
+
${e.map((o) => {
|
|
1552
|
+
const s = this.getItemValue(o), l = this.getItemDisplayValue(o);
|
|
1553
|
+
return `
|
|
1554
|
+
<div class="ml__pill">
|
|
1555
|
+
<span class="ml__pill-text">${l}</span>
|
|
1556
|
+
<button type="button" class="ml__pill-remove" data-value="${s}" aria-label="Remove ${l}"></button>
|
|
1557
|
+
</div>
|
|
1558
|
+
`;
|
|
1559
|
+
}).join("")}
|
|
1560
|
+
</div>
|
|
1561
|
+
`;
|
|
1562
|
+
}
|
|
1563
|
+
handleSelectedPopoverClick(e) {
|
|
1564
|
+
if (e.stopPropagation(), e.target.closest(".ml__selected-popover-close")) {
|
|
1565
|
+
e.preventDefault(), this.hideSelectedPopover();
|
|
1566
|
+
return;
|
|
1567
|
+
}
|
|
1568
|
+
const o = e.target.closest(".ml__pill-remove");
|
|
1569
|
+
if (o) {
|
|
1570
|
+
e.preventDefault();
|
|
1571
|
+
const s = o.dataset.value, l = this.selectedOptions.get(s);
|
|
1572
|
+
l && (this.deselectOption(l), this.renderSelectedPopover(), this.selectedValues.size === 0 && this.hideSelectedPopover());
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
positionSelectedPopover() {
|
|
1576
|
+
this.selectedPopoverCleanup = q(
|
|
1577
|
+
this.input,
|
|
1578
|
+
this.selectedPopover,
|
|
1579
|
+
() => {
|
|
1580
|
+
const e = this.selectedPopoverPlacement || "bottom-start";
|
|
1581
|
+
ee(this.input, this.selectedPopover, {
|
|
1582
|
+
placement: e,
|
|
1583
|
+
middleware: [
|
|
1584
|
+
Z(4),
|
|
1585
|
+
...this.selectedPopoverPlacement ? [] : [me()],
|
|
1586
|
+
Q({ padding: 8 })
|
|
1587
|
+
]
|
|
1588
|
+
}).then(({ x: t, y: o, placement: s }) => {
|
|
1589
|
+
this.selectedPopoverPlacement || (this.selectedPopoverPlacement = s, f.debug(`[${this.instanceId}] Locked popover placement:`, s));
|
|
1590
|
+
const l = {
|
|
1591
|
+
left: `${t}px`,
|
|
1592
|
+
top: `${o}px`,
|
|
1593
|
+
width: `${this.input.offsetWidth}px`
|
|
1594
|
+
};
|
|
1595
|
+
this.options.dropdownMinWidth && (l.minWidth = this.options.dropdownMinWidth), Object.assign(this.selectedPopover.style, l);
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
);
|
|
1599
|
+
}
|
|
1600
|
+
// ========================================================================
|
|
1601
|
+
// FORM INTEGRATION
|
|
1602
|
+
// ========================================================================
|
|
1603
|
+
updateHiddenInput() {
|
|
1604
|
+
if (!this.options.formFieldId) return;
|
|
1605
|
+
this.hiddenInputs.forEach((s) => s.remove()), this.hiddenInputs = [];
|
|
1606
|
+
const e = this.options.valueFormat || "json", t = Array.from(this.selectedOptions.values()).map((s) => this.getItemValue(s)), o = this.options.hostElement || this.element;
|
|
1607
|
+
if (e === "array")
|
|
1608
|
+
t.forEach((s) => {
|
|
1609
|
+
const l = document.createElement("input");
|
|
1610
|
+
l.type = "hidden", l.name = `${this.options.formFieldId}[]`, l.value = String(s), o.appendChild(l), this.hiddenInputs.push(l);
|
|
1611
|
+
});
|
|
1612
|
+
else {
|
|
1613
|
+
const s = document.createElement("input");
|
|
1614
|
+
s.type = "hidden", s.name = this.options.formFieldId, s.id = this.options.formFieldId, s.value = this.getFormValue(), o.appendChild(s), this.hiddenInputs.push(s);
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
getFormValue() {
|
|
1618
|
+
const e = Array.from(this.selectedOptions.values()).map((o) => this.getItemValue(o));
|
|
1619
|
+
return this.options.getValueFormatCallback ? this.options.getValueFormatCallback(e) : (this.options.valueFormat || "json") === "csv" ? e.join(",") : JSON.stringify(e);
|
|
1620
|
+
}
|
|
1621
|
+
// ========================================================================
|
|
1622
|
+
// PUBLIC API
|
|
1623
|
+
// ========================================================================
|
|
1624
|
+
getSelected() {
|
|
1625
|
+
return Array.from(this.selectedOptions.values());
|
|
1626
|
+
}
|
|
1627
|
+
setSelected(e) {
|
|
1628
|
+
this.selectedValues = new Set(e.map((t) => String(t))), this.selectedOptions.clear(), e.forEach((t) => {
|
|
1629
|
+
const o = String(t), s = this.allOptions.find((l) => String(this.getItemValue(l)) === o);
|
|
1630
|
+
s && this.selectedOptions.set(o, s);
|
|
1631
|
+
}), this.renderDropdown(), this.renderPills(), this.updateHiddenInput();
|
|
1632
|
+
}
|
|
1633
|
+
get selectedItem() {
|
|
1634
|
+
return this.selectedOptions.size === 0 ? null : Array.from(this.selectedOptions.values())[0];
|
|
1635
|
+
}
|
|
1636
|
+
get selectedValue() {
|
|
1637
|
+
if (!this.options.valueMember && !this.options.getValueCallback)
|
|
1638
|
+
return null;
|
|
1639
|
+
if (this.selectedOptions.size === 0)
|
|
1640
|
+
return this.options.isMultipleEnabled ? [] : null;
|
|
1641
|
+
const e = Array.from(this.selectedOptions.values()).map((t) => this.getItemValue(t));
|
|
1642
|
+
return this.options.isMultipleEnabled ? e : e[0] ?? null;
|
|
1643
|
+
}
|
|
1644
|
+
getValue() {
|
|
1645
|
+
if (this.selectedOptions.size === 0)
|
|
1646
|
+
return this.options.isMultipleEnabled ? [] : null;
|
|
1647
|
+
const e = Array.from(this.selectedOptions.values()).map((t) => this.getItemValue(t));
|
|
1648
|
+
return this.options.isMultipleEnabled ? e : e[0] ?? null;
|
|
1649
|
+
}
|
|
1650
|
+
// ========================================================================
|
|
1651
|
+
// PILL TOOLTIP METHODS
|
|
1652
|
+
// ========================================================================
|
|
1653
|
+
attachPillTooltips() {
|
|
1654
|
+
if (!this.options.isPillTooltipsEnabled) {
|
|
1655
|
+
console.log("[Tooltips] Disabled - isPillTooltipsEnabled is false");
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
const e = this.pillsContainer.querySelectorAll(".ml__pill:not(.ml__pill--more)");
|
|
1659
|
+
console.log(`[Tooltips] Found ${e.length} pills to attach tooltips to`), e.forEach((o) => {
|
|
1660
|
+
const s = o, l = s.querySelector(".ml__pill-remove");
|
|
1661
|
+
if (!l) return;
|
|
1662
|
+
const n = l.dataset.value, r = this.selectedOptions.get(n);
|
|
1663
|
+
if (!r) return;
|
|
1664
|
+
const a = s.querySelector(".ml__pill-text");
|
|
1665
|
+
a && this.createTooltipForElement(a, r, n);
|
|
1666
|
+
const c = this.getItemDisplayValue(r);
|
|
1667
|
+
this.createRemoveButtonTooltip(l, c, n);
|
|
1668
|
+
});
|
|
1669
|
+
const t = this.pillsContainer.querySelector(".ml__pill--more");
|
|
1670
|
+
if (t) {
|
|
1671
|
+
const o = t.querySelector(".ml__pill-remove");
|
|
1672
|
+
if (o && o.dataset.action === "remove-hidden") {
|
|
1673
|
+
const s = this.options.pillsMaxVisible || 3, n = Array.from(this.selectedOptions.values()).length - s;
|
|
1674
|
+
this.createRemoveButtonTooltip(o, `${n} hidden items`, "more-badge-remove");
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
createTooltipForElement(e, t, o) {
|
|
1679
|
+
const s = document.createElement("div");
|
|
1680
|
+
s.className = "ml__pill-tooltip";
|
|
1681
|
+
let l;
|
|
1682
|
+
if (this.options.getPillTooltipCallback)
|
|
1683
|
+
l = this.options.getPillTooltipCallback(t), console.log("[Tooltips] Using custom callback for tooltip content");
|
|
1684
|
+
else {
|
|
1685
|
+
const d = this.getItemDisplayValue(t), m = this.getItemSubtitle(t);
|
|
1686
|
+
l = m ? `${d}
|
|
1687
|
+
${m}` : d, console.log(`[Tooltips] Using default content: "${l}"`);
|
|
1688
|
+
}
|
|
1689
|
+
typeof l == "string" ? s.textContent = l : s.appendChild(l), (this.options.container || document.body).appendChild(s), console.log(`[Tooltips] Tooltip element created and appended for "${o}"`), this.pillTooltips.set(o, s);
|
|
1690
|
+
let r, a;
|
|
1691
|
+
const c = () => {
|
|
1692
|
+
clearTimeout(a), console.log(`[Tooltips] Mouse entered pill "${o}", will show tooltip in ${this.options.pillTooltipDelay || 300}ms`), r = window.setTimeout(() => {
|
|
1693
|
+
console.log(`[Tooltips] Showing tooltip for "${o}"`), s.classList.add("ml__pill-tooltip--visible"), this.positionPillTooltip(e, s, o);
|
|
1694
|
+
}, this.options.pillTooltipDelay || 300);
|
|
1695
|
+
}, p = () => {
|
|
1696
|
+
clearTimeout(r), a = window.setTimeout(() => {
|
|
1697
|
+
s.classList.remove("ml__pill-tooltip--visible"), this.cleanupPillTooltip(o);
|
|
1698
|
+
}, 100);
|
|
1699
|
+
};
|
|
1700
|
+
e.addEventListener("mouseenter", c), e.addEventListener("mouseleave", p);
|
|
1701
|
+
}
|
|
1702
|
+
createRemoveButtonTooltip(e, t, o) {
|
|
1703
|
+
const s = document.createElement("div");
|
|
1704
|
+
s.className = "ml__pill-tooltip", s.textContent = `Remove ${t}`, (this.options.container || document.body).appendChild(s);
|
|
1705
|
+
const n = `${o}-remove`;
|
|
1706
|
+
this.pillTooltips.set(n, s);
|
|
1707
|
+
let r, a;
|
|
1708
|
+
const c = () => {
|
|
1709
|
+
clearTimeout(a);
|
|
1710
|
+
const d = this.pillTooltips.get(o);
|
|
1711
|
+
d && d.classList.remove("ml__pill-tooltip--visible"), r = window.setTimeout(() => {
|
|
1712
|
+
s.classList.add("ml__pill-tooltip--visible"), this.positionPillTooltip(e, s, n);
|
|
1713
|
+
}, this.options.pillTooltipDelay || 300);
|
|
1714
|
+
}, p = () => {
|
|
1715
|
+
clearTimeout(r), a = window.setTimeout(() => {
|
|
1716
|
+
s.classList.remove("ml__pill-tooltip--visible"), this.cleanupPillTooltip(n);
|
|
1717
|
+
}, 100);
|
|
1718
|
+
};
|
|
1719
|
+
e.addEventListener("mouseenter", c), e.addEventListener("mouseleave", p);
|
|
1720
|
+
}
|
|
1721
|
+
positionPillTooltip(e, t, o) {
|
|
1722
|
+
const s = q(e, t, () => {
|
|
1723
|
+
ee(e, t, {
|
|
1724
|
+
placement: this.options.pillTooltipPlacement || "top",
|
|
1725
|
+
strategy: "fixed",
|
|
1726
|
+
middleware: [
|
|
1727
|
+
Z(this.options.pillTooltipOffset || 8),
|
|
1728
|
+
me(),
|
|
1729
|
+
Q({ padding: 8 })
|
|
1730
|
+
]
|
|
1731
|
+
}).then(({ x: l, y: n }) => {
|
|
1732
|
+
Object.assign(t.style, {
|
|
1733
|
+
left: `${l}px`,
|
|
1734
|
+
top: `${n}px`
|
|
1735
|
+
}), console.log(`[Tooltips] Positioned tooltip "${o}" at x:${l}, y:${n}`, {
|
|
1736
|
+
placement: this.options.pillTooltipPlacement || "top",
|
|
1737
|
+
tooltipClasses: t.className,
|
|
1738
|
+
tooltipDisplay: window.getComputedStyle(t).display,
|
|
1739
|
+
tooltipOpacity: window.getComputedStyle(t).opacity,
|
|
1740
|
+
tooltipVisibility: window.getComputedStyle(t).visibility,
|
|
1741
|
+
tooltipZIndex: window.getComputedStyle(t).zIndex,
|
|
1742
|
+
tooltipPosition: window.getComputedStyle(t).position
|
|
1743
|
+
});
|
|
1744
|
+
});
|
|
1745
|
+
});
|
|
1746
|
+
this.pillTooltipCleanups.set(o, s);
|
|
1747
|
+
}
|
|
1748
|
+
cleanupPillTooltip(e) {
|
|
1749
|
+
const t = this.pillTooltipCleanups.get(e);
|
|
1750
|
+
t && (t(), this.pillTooltipCleanups.delete(e));
|
|
1751
|
+
}
|
|
1752
|
+
destroyAllPillTooltips() {
|
|
1753
|
+
this.pillTooltipCleanups.forEach((e) => e()), this.pillTooltipCleanups.clear(), this.pillTooltips.forEach((e) => e.remove()), this.pillTooltips.clear();
|
|
1754
|
+
}
|
|
1755
|
+
// ========================================================================
|
|
1756
|
+
// PUBLIC API
|
|
1757
|
+
// ========================================================================
|
|
1758
|
+
destroy() {
|
|
1759
|
+
this.destroyAllPillTooltips(), this.dropdownCleanup && this.dropdownCleanup(), this.hintCleanup && this.hintCleanup(), this.selectedPopoverCleanup && this.selectedPopoverCleanup(), this.dropdown && this.dropdown.remove(), this.hint && this.hint.remove(), this.selectedPopover && this.selectedPopover.remove(), this.element.innerHTML = "", this.element.classList.remove("ml", "ml--open", "ml--no-checkboxes"), console.log("[MultiSelect] Destroyed");
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
const Nt = '@charset "UTF-8";multi-select:not(:defined){display:block;min-height:2.5rem;color:transparent!important;background:transparent}.ml-wrapper{display:flex;flex-direction:column;align-items:stretch}.ml-wrapper--inline{flex-direction:row;align-items:flex-start}.ml{position:relative;width:100%}.ml__input-wrapper{position:relative;display:flex;align-items:center}.ml__input{width:100%;padding:var(--ml-input-padding, .5rem .75rem);padding-right:var(--ml-input-padding-right, 2.5rem);font-size:var(--ml-input-font-size, .875rem);border:var(--ml-input-border-style, 1px solid #d1d5db);border-radius:var(--ml-input-border-radius, .375rem);background:var(--ml-input-bg, #ffffff);color:var(--ml-input-text, #111827);transition:border-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__input:focus{outline:none;border-color:var(--ml-input-focus-border-color, #3b82f6)}.ml__input::placeholder{color:var(--ml-input-placeholder-color, #6b7280);opacity:0;transition:opacity var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}:host([data-ready]) .ml__input::placeholder{opacity:var(--ml-placeholder-opacity, .6)}.ml__toggle{position:absolute;right:var(--ml-toggle-right, .75rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));pointer-events:none;color:var(--ml-toggle-color, #6b7280);transition:transform var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml--open .ml__toggle{transform:var(--ml-transform-center-y, translateY(-50%)) rotate(var(--ml-transform-rotate-180, 180deg))}.ml__count-badge{position:absolute;right:var(--ml-count-badge-offset, 2rem);top:50%;transform:var(--ml-transform-center-y, translateY(-50%));padding:var(--ml-count-badge-padding, .125rem .25rem);background:var(--ml-count-badge-bg, #3b82f6);color:var(--ml-count-badge-color, #ffffff);font-size:var(--ml-count-badge-font-size, .75rem);font-weight:var(--ml-count-badge-font-weight, 600);border-radius:var(--ml-count-badge-border-radius, .25rem);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-badge:hover{background:var(--ml-count-badge-bg-hover, #2563eb);transform:var(--ml-transform-center-y, translateY(-50%)) scale(var(--ml-transform-scale-hover, 1.1))}.ml__hint{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);padding:var(--ml-hint-padding, .5rem .75rem);background:var(--ml-hint-bg, #ffffff);border:var(--ml-hint-border, 1px solid #e5e7eb);border-radius:var(--ml-hint-border-radius, .375rem);box-shadow:var(--ml-hint-box-shadow, 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1));font-size:var(--ml-hint-font-size, .75rem);color:var(--ml-hint-color, #6b7280);line-height:var(--ml-line-height-relaxed, 1.4);max-width:100%}.ml__hint--visible{display:block}.ml__dropdown{display:none;position:absolute;z-index:var(--ml-z-index-dropdown, 9999);background:var(--ml-dropdown-bg, #ffffff);border:var(--ml-dropdown-border, 1px solid #e5e7eb);border-radius:var(--ml-dropdown-border-radius, .375rem);box-shadow:var(--ml-dropdown-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));max-height:var(--ml-dropdown-max-height, 20rem);overflow-y:auto;color:var(--ml-dropdown-color, #111827)}.ml__dropdown--visible{display:block}.ml__actions{display:flex;gap:var(--ml-actions-gap, .25rem);padding:var(--ml-actions-padding, .5rem);border-bottom:var(--ml-actions-border-bottom, 1px solid #e5e7eb)}.ml__actions--sticky{position:sticky;top:0;z-index:var(--ml-z-index-sticky, 1);background:var(--ml-actions-bg, #ffffff)}.ml__action-btn{flex:1;padding:var(--ml-action-btn-padding, .25rem .5rem);font-size:var(--ml-action-btn-font-size, .75rem);border:var(--ml-action-btn-border, 1px solid #e5e7eb);border-radius:var(--ml-action-btn-border-radius, .25rem);background:var(--ml-action-btn-bg, transparent);color:var(--ml-action-btn-color, inherit);cursor:pointer;transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__action-btn:hover{background:var(--ml-action-btn-bg-hover, #f3f4f6);border-color:var(--ml-action-btn-border-color-hover, #3b82f6)}.ml__action-btn:active{transform:scale(var(--ml-transform-scale-active, .98))}.ml__options{padding:var(--ml-options-padding, .25rem 0)}.ml__group+.ml__group{border-top:var(--ml-group-border-top, 1px solid #e5e7eb);margin-top:var(--ml-group-margin-top, .25rem);padding-top:var(--ml-group-padding-top, .25rem)}.ml__group-label{padding:var(--ml-group-label-padding, .25rem .75rem);font-size:var(--ml-group-label-font-size, .75rem);font-weight:var(--ml-group-label-font-weight, 600);color:var(--ml-group-label-color, #6b7280);text-transform:var(--ml-group-label-transform, uppercase);letter-spacing:var(--ml-group-label-letter-spacing, .05em)}.ml__option{display:flex;align-items:flex-start;gap:var(--ml-option-gap, .5rem);padding:var(--ml-option-padding, .5rem .75rem);cursor:pointer;transition:background-color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__option:hover{background:var(--ml-option-bg-hover, #f9fafb)}.ml__option--focused{background:var(--ml-option-bg-focused, #f9fafb);outline:var(--ml-option-outline-focused, 2px solid #3b82f6);outline-offset:var(--ml-option-focus-outline-offset, -2px)}.ml__option--selected{background:var(--ml-option-bg-selected, rgba(59, 130, 246, .1))}.ml__option--disabled{opacity:var(--ml-disabled-opacity, .5);cursor:not-allowed}.ml__option--disabled:hover{background:var(--ml-option-bg, transparent)}.ml__checkbox{flex-shrink:0;margin-top:var(--ml-checkbox-margin-top, .125rem);cursor:pointer}.ml__option--disabled .ml__checkbox{cursor:not-allowed}.ml__option-content{flex:1;display:flex;align-items:flex-start;gap:var(--ml-option-content-gap, .5rem);min-width:0}.ml__option-icon{flex-shrink:0;width:var(--ml-option-icon-size, 1.25rem);height:var(--ml-option-icon-size, 1.25rem);display:flex;align-items:center;justify-content:center;font-size:var(--ml-option-icon-font-size, 1rem)}.ml__option-icon svg{width:100%;height:100%;fill:currentColor}.ml__option-text{flex:1;min-width:0}.ml__option-title{font-size:var(--ml-option-title-font-size, .875rem);color:var(--ml-option-title-color, inherit);line-height:var(--ml-line-height-relaxed, 1.4)}.ml__option-title mark{background:var(--ml-option-mark-bg, rgba(59, 130, 246, .2));color:var(--ml-option-mark-color, inherit);font-weight:var(--ml-option-mark-font-weight, 600)}.ml__option-subtitle{margin-top:var(--ml-option-subtitle-margin-top, .25rem);font-size:var(--ml-option-subtitle-font-size, .75rem);color:var(--ml-option-subtitle-color, #6b7280);line-height:var(--ml-option-subtitle-line-height, 1.3)}.ml__empty{padding:var(--ml-empty-padding, 1rem .75rem);text-align:center;font-size:var(--ml-empty-font-size, .875rem);color:var(--ml-empty-color, #6b7280)}.ml__loader{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:var(--ml-loader-padding, 1rem);gap:var(--ml-loader-gap, .5rem)}.ml__loading-text{font-size:var(--ml-loading-text-font-size, .875rem);color:var(--ml-loading-text-color, #6b7280)}.ml__pills{display:flex;flex-wrap:wrap;gap:var(--ml-pills-gap, .5rem);padding:0}.ml__pills:empty{display:none}.ml__pills--bottom{margin-top:var(--ml-pills-margin-bottom, .5rem)}.ml__pills--top{margin-bottom:var(--ml-pills-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__pills--left{order:var(--ml-order-first, -1);margin-right:var(--ml-pills-margin-left, .5rem);justify-content:flex-start}.ml__pills--right{margin-left:var(--ml-pills-margin-right, .5rem);justify-content:flex-end}.ml__count-display{display:flex;align-items:center}.ml__count-display:empty{display:none}.ml__count-display--bottom{margin-top:var(--ml-count-display-margin-bottom, .5rem)}.ml__count-display--top{margin-bottom:var(--ml-count-display-margin-top, .5rem);order:var(--ml-order-first, -1)}.ml__count-display--left{order:var(--ml-order-first, -1);margin-right:var(--ml-count-display-margin-left, .5rem);justify-content:flex-start}.ml__count-display--right{margin-left:var(--ml-count-display-margin-right, .5rem);justify-content:flex-end}.ml__count-badge-wrapper{display:inline-flex;align-items:center;gap:var(--ml-count-badge-wrapper-gap, .25rem);background:var(--ml-count-badge-wrapper-bg, transparent);border:var(--ml-count-badge-wrapper-border, 1px solid #e5e7eb);border-radius:var(--ml-count-badge-wrapper-border-radius, .25rem);padding:var(--ml-count-badge-wrapper-padding, .25rem .5rem);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-badge-wrapper:hover{background:var(--ml-count-badge-wrapper-bg-hover, #f9fafb);border-color:var(--ml-count-badge-wrapper-border-color-hover, #3b82f6)}.ml__count-text{display:inline-flex;align-items:center;background:var(--ml-count-text-bg, transparent);border:var(--ml-count-text-border, none);padding:0;font-size:var(--ml-count-text-font-size, .875rem);color:var(--ml-count-text-color, #111827);cursor:pointer;transition:color var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:var(--ml-count-clear-size, 1rem);height:var(--ml-count-clear-size, 1rem);padding:0;border:none;background:var(--ml-count-clear-bg, transparent);color:var(--ml-count-clear-color, #6b7280);font-size:var(--ml-count-clear-font-size, 1.125rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-count-clear-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__count-clear:hover{background:var(--ml-count-clear-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-count-clear-color-hover, #3b82f6)}.ml__count-clear:before{content:var(--ml-icon-clear, "×")}.ml__pill{display:inline-flex;align-items:center;height:var(--ml-pill-height, 1.5rem);font-size:var(--ml-pill-font-size, .75rem);font-weight:var(--ml-pill-font-weight, 600);line-height:var(--ml-line-height-none, 1);border-radius:var(--ml-pill-border-radius, .375rem);overflow:hidden;max-width:100%}.ml__pill-text{display:flex;align-items:center;height:100%;padding:var(--ml-pill-text-padding, 0 .5rem);background:var(--ml-pill-text-bg, #eff6ff);color:var(--ml-pill-text-color, #3b82f6);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;transition:background-color var(--ml-transition-normal, .2s) ease}.ml__pill-remove{display:flex;align-items:center;justify-content:center;width:var(--ml-pill-remove-width, 1.5rem);height:100%;flex-shrink:0;background:var(--ml-pill-remove-bg, #3b82f6);color:var(--ml-pill-remove-color, #ffffff);border:var(--ml-pill-remove-border, none);cursor:pointer;transition:background-color var(--ml-transition-normal, .2s) ease;font-size:var(--ml-pill-remove-font-size, .75rem)}.ml__pill-remove:hover{background:var(--ml-pill-remove-bg-hover, #2563eb)}.ml__pill-remove:focus{outline:none;box-shadow:var(--ml-pill-remove-box-shadow-focus, 0 0 0 2px rgba(59, 130, 246, .5))}.ml__pill-remove:before{content:var(--ml-icon-remove, "×");font-size:var(--ml-font-size-base, 1rem);line-height:var(--ml-line-height-none, 1)}.ml__pill--more{cursor:pointer}.ml__pill--more .ml__pill-text{background:var(--ml-more-badge-bg, #eff6ff);font-weight:var(--ml-pill-font-weight, 600)}.ml__pill--more:hover .ml__pill-text{background:var(--ml-more-badge-hover-bg, #ffffff)}.ml__pill--more:active .ml__pill-text{background:var(--ml-more-badge-active-bg, #e0f2fe)}.ml__pill-tooltip{position:fixed;z-index:var(--ml-tooltip-z-index, 10000);opacity:0;visibility:hidden;transition:opacity var(--ml-transition-normal, .2s) ease,visibility var(--ml-transition-normal, .2s) ease;background:var(--ml-tooltip-bg, #333);color:var(--ml-tooltip-color, #fff);padding:var(--ml-tooltip-padding, .5rem .75rem);border-radius:var(--ml-tooltip-border-radius, .375rem);font-size:var(--ml-tooltip-font-size, .875rem);line-height:var(--ml-line-height-relaxed, 1.4);max-width:var(--ml-tooltip-max-width, 20rem);word-wrap:break-word;white-space:pre-wrap;box-shadow:var(--ml-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, .15));pointer-events:none}.ml__pill-tooltip--visible{opacity:1;visibility:visible}.ml__selected-popover{display:none;position:absolute;z-index:var(--ml-z-index-popover, 10000);background:var(--ml-selected-popover-bg, #ffffff);border:var(--ml-selected-popover-border, 1px solid #e5e7eb);border-radius:var(--ml-selected-popover-border-radius, .375rem);box-shadow:var(--ml-selected-popover-box-shadow, 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .1));width:var(--ml-selected-popover-width, 20rem);max-height:var(--ml-selected-popover-max-height, 20rem);overflow:hidden}.ml__selected-popover--visible{display:flex;flex-direction:column}.ml__selected-popover-header{display:flex;align-items:center;justify-content:space-between;padding:var(--ml-selected-popover-header-padding, .5rem .75rem);background:var(--ml-selected-popover-header-bg, rgba(59, 130, 246, .1));border-bottom:var(--ml-selected-popover-header-border-bottom, 1px solid #e5e7eb);font-size:var(--ml-selected-popover-header-font-size, .875rem);font-weight:var(--ml-selected-popover-header-font-weight, 600);color:var(--ml-selected-popover-header-color, #111827)}.ml__selected-popover-close{display:flex;align-items:center;justify-content:center;width:var(--ml-popover-close-size, 1.5rem);height:var(--ml-popover-close-size, 1.5rem);padding:0;border:none;background:var(--ml-selected-popover-close-bg, transparent);color:var(--ml-selected-popover-close-color, #6b7280);font-size:var(--ml-selected-popover-close-font-size, 1.25rem);line-height:var(--ml-line-height-none, 1);cursor:pointer;border-radius:var(--ml-selected-popover-close-border-radius, 50%);transition:all var(--ml-transition-fast, .15s) var(--ml-easing-snappy, cubic-bezier(.4, 0, .2, 1))}.ml__selected-popover-close:hover{background:var(--ml-selected-popover-close-bg-hover, rgba(59, 130, 246, .2));color:var(--ml-selected-popover-close-color-hover, #3b82f6)}.ml__selected-popover-body{display:flex;flex-direction:column;gap:var(--ml-selected-popover-body-gap, .25rem);padding:var(--ml-selected-popover-body-padding, .5rem);overflow-y:auto;max-height:var(--ml-selected-popover-body-max-height, 18rem)}.ml__selected-popover-body .ml__pill{width:100%}.ml__selected-popover-body .ml__pill-text{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.ml--xs .ml__input{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__option{padding:var(--ml-spacing-xs, .25rem) var(--ml-spacing-sm, .5rem)}.ml--xs .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--xs .ml__pill{font-size:var(--ml-font-size-2xs, .625rem)}.ml--sm .ml__input,.ml--sm .ml__option-title{font-size:var(--ml-font-size-xs, .75rem)}.ml--lg .ml__input,.ml--lg .ml__option-title{font-size:var(--ml-font-size-base, 1rem)}.ml--lg .ml__pill{font-size:var(--ml-font-size-sm, .875rem)}.ml--xl .ml__input,.ml--xl .ml__option-title{font-size:var(--ml-font-size-lg, 1.125rem)}.ml--xl .ml__pill{font-size:var(--ml-font-size-base, 1rem)}.ml--disabled .ml__input{opacity:var(--ml-disabled-input-opacity, .6);cursor:not-allowed;background:var(--ml-input-bg-disabled, rgba(107, 114, 128, .05))}.ml--disabled .ml__toggle{opacity:var(--ml-disabled-input-opacity, .6)}.ml--no-checkboxes .ml__option{gap:0;padding-left:var(--ml-option-padding-h, .75rem)}.ml--no-checkboxes .ml__option-content{padding-left:0}.ml-debug-info{margin-top:.25rem;padding:.25rem;background-color:#f9fafb;border:1px solid #e5e7eb;border-radius:.375rem;font-size:.75rem;color:#111827}.ml-debug-info details summary{cursor:pointer;font-weight:600;color:#2563eb;-webkit-user-select:none;user-select:none;padding:.25rem;border-radius:.25rem}.ml-debug-info details summary:hover{background-color:#f3f4f6}.ml-debug-info details summary:focus{outline:2px solid #3b82f6;outline-offset:2px}.ml-debug-info .ml-debug-stats{display:flex;flex-direction:column;gap:.25rem;margin-top:.25rem;padding:.25rem;background-color:#fff;border-radius:.25rem}.ml-debug-info .ml-debug-stats span{display:flex;justify-content:space-between;padding:2px 4px;font-family:monospace;font-size:.625rem}.ml-debug-info .ml-debug-stats span:before{content:"•";margin-right:.25rem;color:#3b82f6}', be = /* @__PURE__ */ new Set();
|
|
1763
|
+
function je() {
|
|
1764
|
+
return Array.from(be);
|
|
1765
|
+
}
|
|
1766
|
+
class Ge extends HTMLElement {
|
|
1767
|
+
constructor() {
|
|
1768
|
+
super();
|
|
1769
|
+
u(this, "picker");
|
|
1770
|
+
u(this, "containerElement");
|
|
1771
|
+
u(this, "shadow");
|
|
1772
|
+
// Properties for complex data (not attributes)
|
|
1773
|
+
u(this, "_options");
|
|
1774
|
+
// Member/Callback properties
|
|
1775
|
+
u(this, "_valueMember");
|
|
1776
|
+
u(this, "_getValueCallback");
|
|
1777
|
+
u(this, "_displayValueMember");
|
|
1778
|
+
u(this, "_getDisplayValueCallback");
|
|
1779
|
+
u(this, "_searchValueMember");
|
|
1780
|
+
u(this, "_getSearchValueCallback");
|
|
1781
|
+
u(this, "_iconMember");
|
|
1782
|
+
u(this, "_getIconCallback");
|
|
1783
|
+
u(this, "_subtitleMember");
|
|
1784
|
+
u(this, "_getSubtitleCallback");
|
|
1785
|
+
u(this, "_groupMember");
|
|
1786
|
+
u(this, "_getGroupCallback");
|
|
1787
|
+
u(this, "_disabledMember");
|
|
1788
|
+
u(this, "_getDisabledCallback");
|
|
1789
|
+
// Value formatting callbacks
|
|
1790
|
+
u(this, "_getValueFormatCallback");
|
|
1791
|
+
// Tooltip callbacks
|
|
1792
|
+
u(this, "_getPillTooltipCallback");
|
|
1793
|
+
// Count pill callback
|
|
1794
|
+
u(this, "_getCountPillCallback");
|
|
1795
|
+
// Event callbacks
|
|
1796
|
+
u(this, "_searchCallback");
|
|
1797
|
+
u(this, "_addNewCallback");
|
|
1798
|
+
u(this, "_selectCallback");
|
|
1799
|
+
u(this, "_deselectCallback");
|
|
1800
|
+
u(this, "_changeCallback");
|
|
1801
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
1802
|
+
const t = document.createElement("style");
|
|
1803
|
+
t.textContent = Nt, this.shadow.appendChild(t), requestAnimationFrame(() => {
|
|
1804
|
+
this.setAttribute("data-ready", "");
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
static get observedAttributes() {
|
|
1808
|
+
return [
|
|
1809
|
+
// Existing attributes (external names - standard/familiar)
|
|
1810
|
+
"search-hint",
|
|
1811
|
+
"search-placeholder",
|
|
1812
|
+
"multiple",
|
|
1813
|
+
"allow-groups",
|
|
1814
|
+
"allow-select-all",
|
|
1815
|
+
"allow-clear-all",
|
|
1816
|
+
"show-checkboxes",
|
|
1817
|
+
"sticky-actions",
|
|
1818
|
+
"close-on-select",
|
|
1819
|
+
"lock-placement",
|
|
1820
|
+
"dropdown-min-width",
|
|
1821
|
+
"pills-display-mode",
|
|
1822
|
+
"pills-threshold",
|
|
1823
|
+
"pills-max-visible",
|
|
1824
|
+
"pills-threshold-mode",
|
|
1825
|
+
"pills-position",
|
|
1826
|
+
"show-count-badge",
|
|
1827
|
+
"max-height",
|
|
1828
|
+
"empty-message",
|
|
1829
|
+
"loading-message",
|
|
1830
|
+
"min-search-length",
|
|
1831
|
+
"enable-search",
|
|
1832
|
+
"search-input-mode",
|
|
1833
|
+
"allow-add-new",
|
|
1834
|
+
"initial-values",
|
|
1835
|
+
// New member properties
|
|
1836
|
+
"value-member",
|
|
1837
|
+
"display-value-member",
|
|
1838
|
+
"search-value-member",
|
|
1839
|
+
"icon-member",
|
|
1840
|
+
"subtitle-member",
|
|
1841
|
+
"group-member",
|
|
1842
|
+
"disabled-member",
|
|
1843
|
+
// Form integration
|
|
1844
|
+
"name",
|
|
1845
|
+
"value-format",
|
|
1846
|
+
// Tooltip options
|
|
1847
|
+
"enable-pill-tooltips",
|
|
1848
|
+
"pill-tooltip-placement",
|
|
1849
|
+
// Debug
|
|
1850
|
+
"show-debug-info"
|
|
1851
|
+
];
|
|
1852
|
+
}
|
|
1853
|
+
connectedCallback() {
|
|
1854
|
+
be.add(this), this.render(), this.initializePicker();
|
|
1855
|
+
}
|
|
1856
|
+
disconnectedCallback() {
|
|
1857
|
+
be.delete(this), this.picker && this.picker.destroy();
|
|
1858
|
+
}
|
|
1859
|
+
attributeChangedCallback(t, o, s) {
|
|
1860
|
+
o !== s && this.picker && t !== "initial-values" && (this.picker.destroy(), this.initializePicker());
|
|
1861
|
+
}
|
|
1862
|
+
render() {
|
|
1863
|
+
this.containerElement = document.createElement("div"), this.containerElement.setAttribute("data-multiselect", ""), this.className && (this.containerElement.className = this.className), this.shadow.appendChild(this.containerElement), this.getAttribute("show-debug-info") === "true" && this.renderDebugInfo();
|
|
1864
|
+
}
|
|
1865
|
+
renderDebugInfo() {
|
|
1866
|
+
const t = this.shadow.querySelector(".ml-debug-info");
|
|
1867
|
+
t && t.remove();
|
|
1868
|
+
const o = document.createElement("div");
|
|
1869
|
+
o.className = "ml-debug-info";
|
|
1870
|
+
const s = document.createElement("details"), l = document.createElement("summary");
|
|
1871
|
+
l.textContent = "Debug Info";
|
|
1872
|
+
const n = document.createElement("div");
|
|
1873
|
+
n.className = "ml-debug-stats", s.appendChild(l), s.appendChild(n), o.appendChild(s), this.shadow.appendChild(o), this.updateDebugInfo();
|
|
1874
|
+
}
|
|
1875
|
+
updateDebugInfo() {
|
|
1876
|
+
var h, g;
|
|
1877
|
+
const t = this.shadow.querySelector(".ml-debug-stats");
|
|
1878
|
+
if (!t || !this.picker) return;
|
|
1879
|
+
const o = "1.0.0-rc02", s = je().length, n = this.picker.getSelected().length, r = ((h = this._options) == null ? void 0 : h.length) || 0, a = this.picker, c = a.isOpen || !1, p = a.searchTerm || "", d = a.isLoading || !1, m = ((g = a.filteredOptions) == null ? void 0 : g.length) || 0;
|
|
1880
|
+
t.innerHTML = `
|
|
1881
|
+
<span>Version: ${o}</span>
|
|
1882
|
+
<span>Total Instances: ${s}</span>
|
|
1883
|
+
<span>Options: ${r}</span>
|
|
1884
|
+
<span>Filtered: ${m}</span>
|
|
1885
|
+
<span>Selected: ${n}</span>
|
|
1886
|
+
<span>Dropdown: ${c ? "Open" : "Closed"}</span>
|
|
1887
|
+
<span>Search: ${p || "none"}</span>
|
|
1888
|
+
<span>Loading: ${d ? "Yes" : "No"}</span>
|
|
1889
|
+
`, setTimeout(() => {
|
|
1890
|
+
this.getAttribute("show-debug-info") === "true" && this.updateDebugInfo();
|
|
1891
|
+
}, 500);
|
|
1892
|
+
}
|
|
1893
|
+
initializePicker() {
|
|
1894
|
+
if (!this.containerElement) return;
|
|
1895
|
+
let t;
|
|
1896
|
+
const o = this.getAttribute("initial-values");
|
|
1897
|
+
if (o)
|
|
1898
|
+
try {
|
|
1899
|
+
t = JSON.parse(o);
|
|
1900
|
+
} catch (l) {
|
|
1901
|
+
console.error("[MultiSelectElement] Failed to parse initial-values:", l);
|
|
1902
|
+
}
|
|
1903
|
+
const s = {
|
|
1904
|
+
// String options
|
|
1905
|
+
searchHint: this.getAttribute("search-hint") || void 0,
|
|
1906
|
+
searchPlaceholder: this.getAttribute("search-placeholder") || "Search...",
|
|
1907
|
+
dropdownMinWidth: this.getAttribute("dropdown-min-width") || void 0,
|
|
1908
|
+
pillsDisplayMode: this.getAttribute("pills-display-mode") || "pills",
|
|
1909
|
+
pillsPosition: this.getAttribute("pills-position") || "bottom",
|
|
1910
|
+
pillsThresholdMode: this.getAttribute("pills-threshold-mode") || "count",
|
|
1911
|
+
maxHeight: this.getAttribute("max-height") || "20rem",
|
|
1912
|
+
emptyMessage: this.getAttribute("empty-message") || "No results found",
|
|
1913
|
+
loadingMessage: this.getAttribute("loading-message") || "Loading...",
|
|
1914
|
+
searchInputMode: this.getAttribute("search-input-mode") || "normal",
|
|
1915
|
+
// Number options
|
|
1916
|
+
pillsThreshold: this.getAttribute("pills-threshold") ? parseInt(this.getAttribute("pills-threshold")) : void 0,
|
|
1917
|
+
pillsMaxVisible: this.getAttribute("pills-max-visible") ? parseInt(this.getAttribute("pills-max-visible")) : void 0,
|
|
1918
|
+
minSearchLength: this.getAttribute("min-search-length") ? parseInt(this.getAttribute("min-search-length")) : 0,
|
|
1919
|
+
// Boolean options (map external to internal with 'is' prefix)
|
|
1920
|
+
isMultipleEnabled: this.getAttribute("multiple") !== "false",
|
|
1921
|
+
isGroupsAllowed: this.getAttribute("allow-groups") !== "false",
|
|
1922
|
+
isSelectAllAllowed: this.getAttribute("allow-select-all") !== "false",
|
|
1923
|
+
isClearAllAllowed: this.getAttribute("allow-clear-all") !== "false",
|
|
1924
|
+
isCheckboxesShown: this.getAttribute("show-checkboxes") !== "false",
|
|
1925
|
+
isActionsSticky: this.getAttribute("sticky-actions") !== "false",
|
|
1926
|
+
isCloseOnSelect: this.getAttribute("close-on-select") === "true",
|
|
1927
|
+
isPlacementLocked: this.getAttribute("lock-placement") !== "false",
|
|
1928
|
+
isSearchEnabled: this.getAttribute("enable-search") !== "false",
|
|
1929
|
+
isAddNewAllowed: this.getAttribute("allow-add-new") === "true",
|
|
1930
|
+
isCountBadgeShown: this.getAttribute("show-count-badge") === "true",
|
|
1931
|
+
// Member properties
|
|
1932
|
+
valueMember: this.getAttribute("value-member") || this._valueMember,
|
|
1933
|
+
displayValueMember: this.getAttribute("display-value-member") || this._displayValueMember,
|
|
1934
|
+
searchValueMember: this.getAttribute("search-value-member") || this._searchValueMember,
|
|
1935
|
+
iconMember: this.getAttribute("icon-member") || this._iconMember,
|
|
1936
|
+
subtitleMember: this.getAttribute("subtitle-member") || this._subtitleMember,
|
|
1937
|
+
groupMember: this.getAttribute("group-member") || this._groupMember,
|
|
1938
|
+
disabledMember: this.getAttribute("disabled-member") || this._disabledMember,
|
|
1939
|
+
// Callback properties (JavaScript only)
|
|
1940
|
+
getValueCallback: this._getValueCallback,
|
|
1941
|
+
getDisplayValueCallback: this._getDisplayValueCallback,
|
|
1942
|
+
getSearchValueCallback: this._getSearchValueCallback,
|
|
1943
|
+
getIconCallback: this._getIconCallback,
|
|
1944
|
+
getSubtitleCallback: this._getSubtitleCallback,
|
|
1945
|
+
getGroupCallback: this._getGroupCallback,
|
|
1946
|
+
getDisabledCallback: this._getDisabledCallback,
|
|
1947
|
+
// Form integration & value formatting
|
|
1948
|
+
formFieldId: this.getAttribute("name") || void 0,
|
|
1949
|
+
valueFormat: this.getAttribute("value-format") || "json",
|
|
1950
|
+
getValueFormatCallback: this._getValueFormatCallback,
|
|
1951
|
+
// Tooltip options
|
|
1952
|
+
isPillTooltipsEnabled: this.getAttribute("enable-pill-tooltips") === "true",
|
|
1953
|
+
getPillTooltipCallback: this._getPillTooltipCallback,
|
|
1954
|
+
pillTooltipPlacement: this.getAttribute("pill-tooltip-placement") || "top",
|
|
1955
|
+
pillTooltipDelay: parseInt(this.getAttribute("pill-tooltip-delay") || "300"),
|
|
1956
|
+
pillTooltipOffset: parseInt(this.getAttribute("pill-tooltip-offset") || "8"),
|
|
1957
|
+
// Count pill callback
|
|
1958
|
+
getCountPillCallback: this._getCountPillCallback || ((l, n) => n !== void 0 ? `+${n} more` : `${l} selected`),
|
|
1959
|
+
// Data and callbacks
|
|
1960
|
+
options: this._options,
|
|
1961
|
+
searchCallback: this._searchCallback,
|
|
1962
|
+
addNewCallback: this._addNewCallback,
|
|
1963
|
+
selectCallback: (l) => {
|
|
1964
|
+
var n, r;
|
|
1965
|
+
this._selectCallback && this._selectCallback(l), this.dispatchEvent(new CustomEvent("select", {
|
|
1966
|
+
detail: {
|
|
1967
|
+
option: l,
|
|
1968
|
+
selectedOptions: (n = this.picker) == null ? void 0 : n.getSelected(),
|
|
1969
|
+
selectedValues: Array.from(((r = this.picker) == null ? void 0 : r.getValue()) || [])
|
|
1970
|
+
}
|
|
1971
|
+
}));
|
|
1972
|
+
},
|
|
1973
|
+
deselectCallback: (l) => {
|
|
1974
|
+
var n, r;
|
|
1975
|
+
this._deselectCallback && this._deselectCallback(l), this.dispatchEvent(new CustomEvent("deselect", {
|
|
1976
|
+
detail: {
|
|
1977
|
+
option: l,
|
|
1978
|
+
selectedOptions: (n = this.picker) == null ? void 0 : n.getSelected(),
|
|
1979
|
+
selectedValues: Array.from(((r = this.picker) == null ? void 0 : r.getValue()) || [])
|
|
1980
|
+
}
|
|
1981
|
+
}));
|
|
1982
|
+
},
|
|
1983
|
+
changeCallback: (l) => {
|
|
1984
|
+
var n;
|
|
1985
|
+
this._changeCallback && this._changeCallback(l), this.dispatchEvent(new CustomEvent("change", {
|
|
1986
|
+
detail: {
|
|
1987
|
+
selectedOptions: l,
|
|
1988
|
+
selectedValues: Array.from(((n = this.picker) == null ? void 0 : n.getValue()) || [])
|
|
1989
|
+
}
|
|
1990
|
+
}));
|
|
1991
|
+
},
|
|
1992
|
+
// Pass shadow root as container for dropdown/hint/popover
|
|
1993
|
+
container: this.shadow,
|
|
1994
|
+
// Pass host element (this) for hidden inputs in light DOM
|
|
1995
|
+
hostElement: this
|
|
1996
|
+
};
|
|
1997
|
+
t && (this.containerElement.dataset.initialValues = JSON.stringify(t)), this.picker = new zt(this.containerElement, s);
|
|
1998
|
+
}
|
|
1999
|
+
reinitialize() {
|
|
2000
|
+
this.picker && (this.picker.destroy(), this.initializePicker());
|
|
2001
|
+
}
|
|
2002
|
+
// ========================================================================
|
|
2003
|
+
// PUBLIC API - PROPERTIES
|
|
2004
|
+
// ========================================================================
|
|
2005
|
+
// Data options
|
|
2006
|
+
get options() {
|
|
2007
|
+
return this._options;
|
|
2008
|
+
}
|
|
2009
|
+
set options(t) {
|
|
2010
|
+
this._options = t, this.reinitialize();
|
|
2011
|
+
}
|
|
2012
|
+
// Member properties (can also be set via attributes)
|
|
2013
|
+
set valueMember(t) {
|
|
2014
|
+
this._valueMember = t || void 0, t ? this.setAttribute("value-member", t) : this.removeAttribute("value-member");
|
|
2015
|
+
}
|
|
2016
|
+
get valueMember() {
|
|
2017
|
+
return this.getAttribute("value-member");
|
|
2018
|
+
}
|
|
2019
|
+
set displayValueMember(t) {
|
|
2020
|
+
this._displayValueMember = t || void 0, t ? this.setAttribute("display-value-member", t) : this.removeAttribute("display-value-member");
|
|
2021
|
+
}
|
|
2022
|
+
get displayValueMember() {
|
|
2023
|
+
return this.getAttribute("display-value-member");
|
|
2024
|
+
}
|
|
2025
|
+
set searchValueMember(t) {
|
|
2026
|
+
this._searchValueMember = t || void 0, t ? this.setAttribute("search-value-member", t) : this.removeAttribute("search-value-member");
|
|
2027
|
+
}
|
|
2028
|
+
get searchValueMember() {
|
|
2029
|
+
return this.getAttribute("search-value-member");
|
|
2030
|
+
}
|
|
2031
|
+
set iconMember(t) {
|
|
2032
|
+
this._iconMember = t || void 0, t ? this.setAttribute("icon-member", t) : this.removeAttribute("icon-member");
|
|
2033
|
+
}
|
|
2034
|
+
get iconMember() {
|
|
2035
|
+
return this.getAttribute("icon-member");
|
|
2036
|
+
}
|
|
2037
|
+
set subtitleMember(t) {
|
|
2038
|
+
this._subtitleMember = t || void 0, t ? this.setAttribute("subtitle-member", t) : this.removeAttribute("subtitle-member");
|
|
2039
|
+
}
|
|
2040
|
+
get subtitleMember() {
|
|
2041
|
+
return this.getAttribute("subtitle-member");
|
|
2042
|
+
}
|
|
2043
|
+
set groupMember(t) {
|
|
2044
|
+
this._groupMember = t || void 0, t ? this.setAttribute("group-member", t) : this.removeAttribute("group-member");
|
|
2045
|
+
}
|
|
2046
|
+
get groupMember() {
|
|
2047
|
+
return this.getAttribute("group-member");
|
|
2048
|
+
}
|
|
2049
|
+
set disabledMember(t) {
|
|
2050
|
+
this._disabledMember = t || void 0, t ? this.setAttribute("disabled-member", t) : this.removeAttribute("disabled-member");
|
|
2051
|
+
}
|
|
2052
|
+
get disabledMember() {
|
|
2053
|
+
return this.getAttribute("disabled-member");
|
|
2054
|
+
}
|
|
2055
|
+
// Callback properties (JavaScript only - no attributes)
|
|
2056
|
+
set getValueCallback(t) {
|
|
2057
|
+
this._getValueCallback = t, this.reinitialize();
|
|
2058
|
+
}
|
|
2059
|
+
get getValueCallback() {
|
|
2060
|
+
return this._getValueCallback;
|
|
2061
|
+
}
|
|
2062
|
+
set getDisplayValueCallback(t) {
|
|
2063
|
+
this._getDisplayValueCallback = t, this.reinitialize();
|
|
2064
|
+
}
|
|
2065
|
+
get getDisplayValueCallback() {
|
|
2066
|
+
return this._getDisplayValueCallback;
|
|
2067
|
+
}
|
|
2068
|
+
set getSearchValueCallback(t) {
|
|
2069
|
+
this._getSearchValueCallback = t, this.reinitialize();
|
|
2070
|
+
}
|
|
2071
|
+
get getSearchValueCallback() {
|
|
2072
|
+
return this._getSearchValueCallback;
|
|
2073
|
+
}
|
|
2074
|
+
set getIconCallback(t) {
|
|
2075
|
+
this._getIconCallback = t, this.reinitialize();
|
|
2076
|
+
}
|
|
2077
|
+
get getIconCallback() {
|
|
2078
|
+
return this._getIconCallback;
|
|
2079
|
+
}
|
|
2080
|
+
set getSubtitleCallback(t) {
|
|
2081
|
+
this._getSubtitleCallback = t, this.reinitialize();
|
|
2082
|
+
}
|
|
2083
|
+
get getSubtitleCallback() {
|
|
2084
|
+
return this._getSubtitleCallback;
|
|
2085
|
+
}
|
|
2086
|
+
set getGroupCallback(t) {
|
|
2087
|
+
this._getGroupCallback = t, this.reinitialize();
|
|
2088
|
+
}
|
|
2089
|
+
get getGroupCallback() {
|
|
2090
|
+
return this._getGroupCallback;
|
|
2091
|
+
}
|
|
2092
|
+
set getDisabledCallback(t) {
|
|
2093
|
+
this._getDisabledCallback = t, this.reinitialize();
|
|
2094
|
+
}
|
|
2095
|
+
get getDisabledCallback() {
|
|
2096
|
+
return this._getDisabledCallback;
|
|
2097
|
+
}
|
|
2098
|
+
// Form integration
|
|
2099
|
+
set name(t) {
|
|
2100
|
+
t ? this.setAttribute("name", t) : this.removeAttribute("name");
|
|
2101
|
+
}
|
|
2102
|
+
get name() {
|
|
2103
|
+
return this.getAttribute("name");
|
|
2104
|
+
}
|
|
2105
|
+
set valueFormat(t) {
|
|
2106
|
+
t ? this.setAttribute("value-format", t) : this.removeAttribute("value-format");
|
|
2107
|
+
}
|
|
2108
|
+
get valueFormat() {
|
|
2109
|
+
return this.getAttribute("value-format");
|
|
2110
|
+
}
|
|
2111
|
+
set getValueFormatCallback(t) {
|
|
2112
|
+
this._getValueFormatCallback = t, this.reinitialize();
|
|
2113
|
+
}
|
|
2114
|
+
get getValueFormatCallback() {
|
|
2115
|
+
return this._getValueFormatCallback;
|
|
2116
|
+
}
|
|
2117
|
+
// Pills display options
|
|
2118
|
+
set thresholdMode(t) {
|
|
2119
|
+
t ? this.setAttribute("threshold-mode", t) : this.removeAttribute("threshold-mode");
|
|
2120
|
+
}
|
|
2121
|
+
get thresholdMode() {
|
|
2122
|
+
return this.getAttribute("threshold-mode");
|
|
2123
|
+
}
|
|
2124
|
+
set pillsMaxVisible(t) {
|
|
2125
|
+
t !== null ? this.setAttribute("pills-max-visible", String(t)) : this.removeAttribute("pills-max-visible");
|
|
2126
|
+
}
|
|
2127
|
+
get pillsMaxVisible() {
|
|
2128
|
+
const t = this.getAttribute("pills-max-visible");
|
|
2129
|
+
return t ? parseInt(t) : null;
|
|
2130
|
+
}
|
|
2131
|
+
// Tooltip options
|
|
2132
|
+
set enablePillTooltips(t) {
|
|
2133
|
+
t ? this.setAttribute("enable-pill-tooltips", "true") : this.removeAttribute("enable-pill-tooltips");
|
|
2134
|
+
}
|
|
2135
|
+
get enablePillTooltips() {
|
|
2136
|
+
return this.getAttribute("enable-pill-tooltips") === "true";
|
|
2137
|
+
}
|
|
2138
|
+
set pillTooltipPlacement(t) {
|
|
2139
|
+
t ? this.setAttribute("pill-tooltip-placement", t) : this.removeAttribute("pill-tooltip-placement");
|
|
2140
|
+
}
|
|
2141
|
+
get pillTooltipPlacement() {
|
|
2142
|
+
return this.getAttribute("pill-tooltip-placement");
|
|
2143
|
+
}
|
|
2144
|
+
set getPillTooltipCallback(t) {
|
|
2145
|
+
this._getPillTooltipCallback = t, this.reinitialize();
|
|
2146
|
+
}
|
|
2147
|
+
get getPillTooltipCallback() {
|
|
2148
|
+
return this._getPillTooltipCallback;
|
|
2149
|
+
}
|
|
2150
|
+
set getCountPillCallback(t) {
|
|
2151
|
+
this._getCountPillCallback = t, this.reinitialize();
|
|
2152
|
+
}
|
|
2153
|
+
get getCountPillCallback() {
|
|
2154
|
+
return this._getCountPillCallback;
|
|
2155
|
+
}
|
|
2156
|
+
// Event callbacks
|
|
2157
|
+
get searchCallback() {
|
|
2158
|
+
return this._searchCallback;
|
|
2159
|
+
}
|
|
2160
|
+
set searchCallback(t) {
|
|
2161
|
+
this._searchCallback = t, this.reinitialize();
|
|
2162
|
+
}
|
|
2163
|
+
get addNewCallback() {
|
|
2164
|
+
return this._addNewCallback;
|
|
2165
|
+
}
|
|
2166
|
+
set addNewCallback(t) {
|
|
2167
|
+
this._addNewCallback = t, this.reinitialize();
|
|
2168
|
+
}
|
|
2169
|
+
get selectCallback() {
|
|
2170
|
+
return this._selectCallback;
|
|
2171
|
+
}
|
|
2172
|
+
set selectCallback(t) {
|
|
2173
|
+
this._selectCallback = t;
|
|
2174
|
+
}
|
|
2175
|
+
get deselectCallback() {
|
|
2176
|
+
return this._deselectCallback;
|
|
2177
|
+
}
|
|
2178
|
+
set deselectCallback(t) {
|
|
2179
|
+
this._deselectCallback = t;
|
|
2180
|
+
}
|
|
2181
|
+
get changeCallback() {
|
|
2182
|
+
return this._changeCallback;
|
|
2183
|
+
}
|
|
2184
|
+
set changeCallback(t) {
|
|
2185
|
+
this._changeCallback = t;
|
|
2186
|
+
}
|
|
2187
|
+
// New public properties
|
|
2188
|
+
get selectedValue() {
|
|
2189
|
+
var t;
|
|
2190
|
+
return ((t = this.picker) == null ? void 0 : t.selectedValue) ?? null;
|
|
2191
|
+
}
|
|
2192
|
+
get selectedItem() {
|
|
2193
|
+
var t;
|
|
2194
|
+
return ((t = this.picker) == null ? void 0 : t.selectedItem) ?? null;
|
|
2195
|
+
}
|
|
2196
|
+
// ========================================================================
|
|
2197
|
+
// PUBLIC API - METHODS
|
|
2198
|
+
// ========================================================================
|
|
2199
|
+
getSelected() {
|
|
2200
|
+
return this.picker ? this.picker.getSelected() : [];
|
|
2201
|
+
}
|
|
2202
|
+
setSelected(t) {
|
|
2203
|
+
this.picker && this.picker.setSelected(t);
|
|
2204
|
+
}
|
|
2205
|
+
getValue() {
|
|
2206
|
+
return this.picker ? this.picker.getValue() : null;
|
|
2207
|
+
}
|
|
2208
|
+
destroy() {
|
|
2209
|
+
this.picker && this.picker.destroy();
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
customElements.get("multi-select") || customElements.define("multi-select", Ge);
|
|
2213
|
+
typeof window < "u" && (window.keenmate = window.keenmate || {}, window.keenmate.multiselect = {
|
|
2214
|
+
version: () => "1.0.0-rc02",
|
|
2215
|
+
config: {
|
|
2216
|
+
name: "@keenmate/web-multiselect",
|
|
2217
|
+
version: "1.0.0-rc02",
|
|
2218
|
+
author: "Keenmate",
|
|
2219
|
+
license: "MIT",
|
|
2220
|
+
repository: "git+https://github.com/keenmate/web-multiselect.git",
|
|
2221
|
+
homepage: "https://github.com/keenmate/web-multiselect#readme"
|
|
2222
|
+
},
|
|
2223
|
+
register: () => {
|
|
2224
|
+
customElements.get("multi-select") || customElements.define("multi-select", Ge);
|
|
2225
|
+
},
|
|
2226
|
+
getInstances: () => je()
|
|
2227
|
+
});
|
|
2228
|
+
export {
|
|
2229
|
+
Ge as MultiSelectElement,
|
|
2230
|
+
zt as PureMultiSelect
|
|
2231
|
+
};
|