@jblehm/super-list 1.0.5

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.
@@ -0,0 +1,852 @@
1
+ import { defineComponent as Q, ref as f, computed as D, openBlock as w, createElementBlock as T, withKeys as m, normalizeClass as S, createElementVNode as H, useTemplateRef as ke, watch as F, Fragment as de, renderList as Ee, withModifiers as te, toDisplayString as ve, createBlock as ce, createCommentVNode as j, useCssVars as Ae, onMounted as ye, onUnmounted as Fe, renderSlot as Le, createVNode as W, nextTick as Ne, resolveDynamicComponent as Se, withCtx as me } from "vue";
2
+ import './index.css';class He {
3
+ eventsTypes = ["resize", "load", "scroll", "wheel", "touchmove"];
4
+ config = {
5
+ attributes: !0,
6
+ childList: !0,
7
+ subtree: !0
8
+ };
9
+ mutationObserver;
10
+ callbackFunction;
11
+ constructor(s, b = document.body) {
12
+ this.targetNode = b, this.callbackFunction = (h) => s(h), this.mutationObserver = new MutationObserver(() => s());
13
+ }
14
+ observe() {
15
+ this.mutationObserver.observe(this.targetNode, this.config);
16
+ for (const s of this.eventsTypes) this.addListener(s);
17
+ this.addResizeListener(), this.addTransitionEndListener();
18
+ }
19
+ pauseMutationObserver() {
20
+ this.mutationObserver.disconnect();
21
+ }
22
+ unpauseMutationObserver() {
23
+ this.mutationObserver.observe(this.targetNode, this.config);
24
+ }
25
+ unobserve() {
26
+ this.mutationObserver.disconnect();
27
+ for (const s of this.eventsTypes) this.removeListener(s);
28
+ this.removeResizeListener(), this.removeTransitionEndListener();
29
+ }
30
+ addListener(s) {
31
+ document.addEventListener(s, this.callbackFunction, !0);
32
+ }
33
+ removeListener(s) {
34
+ document.removeEventListener(s, this.callbackFunction, !0);
35
+ }
36
+ addTransitionEndListener() {
37
+ this.targetNode.addEventListener("transitionend", this.callbackFunction);
38
+ }
39
+ removeTransitionEndListener() {
40
+ this.targetNode.removeEventListener("transitionend", this.callbackFunction);
41
+ }
42
+ addResizeListener() {
43
+ window.addEventListener("resize", this.callbackFunction);
44
+ }
45
+ removeResizeListener() {
46
+ window.removeEventListener("resize", this.callbackFunction);
47
+ }
48
+ }
49
+ function Be(e, s, b, h) {
50
+ return e == null ? "" : typeof e == "object" ? e[b] : h ? Pe(e, h) : s ? s(e) : "" + e;
51
+ }
52
+ function Pe(e, s) {
53
+ return s.find((b) => b.type === e)?.label ?? "";
54
+ }
55
+ class Re {
56
+ constructor() {
57
+ this.abortController = new AbortController(), this.func = () => {
58
+ }, this.then = () => {
59
+ };
60
+ }
61
+ async abortablePromise(s, b, h) {
62
+ const o = await b();
63
+ if (!s.aborted)
64
+ return h(o);
65
+ }
66
+ setFunc(s) {
67
+ this.func = s;
68
+ }
69
+ setThen(s) {
70
+ this.then = s;
71
+ }
72
+ execute() {
73
+ return this.abortablePromise(this.abortController.signal, this.func, this.then);
74
+ }
75
+ abort(s) {
76
+ this.abortController.abort(s || "Aborted By Controller."), this.abortController = new AbortController();
77
+ }
78
+ resetAndExecute(s, b) {
79
+ return this.abort("New Request From Controller."), this.setFunc(s), this.setThen(b), this.execute();
80
+ }
81
+ }
82
+ const qe = ["tabindex", "placeholder", "size"], je = /* @__PURE__ */ Q({
83
+ __name: "ListTextInput",
84
+ props: {
85
+ enableTextFilter: {
86
+ type: Boolean,
87
+ required: !0
88
+ },
89
+ placeholder: {
90
+ type: String,
91
+ default: void 0
92
+ },
93
+ enableButtonClick: {
94
+ type: Boolean,
95
+ default: !0
96
+ },
97
+ parentMethods: {
98
+ type: Object,
99
+ required: !0
100
+ },
101
+ showDropDown: {
102
+ type: Boolean,
103
+ required: !0
104
+ }
105
+ },
106
+ emits: {
107
+ "update:selected": null,
108
+ "update:query": null,
109
+ "update:press": null
110
+ },
111
+ setup(e, { expose: s, emit: b }) {
112
+ const h = b, o = e, i = f(null);
113
+ function a(d) {
114
+ d?.target && d.target === i.value || o.parentMethods.unfocus(d);
115
+ }
116
+ function t(d) {
117
+ d.target && d.target.value != null && h("update:query", d.target.value);
118
+ }
119
+ const l = D(() => {
120
+ const d = i?.value ? i.value.length : 0, c = o.placeholder?.length || 0;
121
+ return d > 0 ? d : c > 0 ? c : 5;
122
+ }), g = D(() => o.enableButtonClick === !0 && o.enableTextFilter === !0 ? "" : "click-through"), p = D(() => o.showDropDown && !o.enableTextFilter || !o.showDropDown ? "dark-placeholder-text" : "light-placeholder-text");
123
+ function N() {
124
+ if (i?.value) {
125
+ const d = i.value;
126
+ d.blur(), d.value = "";
127
+ }
128
+ }
129
+ function k() {
130
+ i?.value && i.value.focus();
131
+ }
132
+ return s({ blurInput: N, focusInput: k, textInputRef: i }), (d, c) => (w(), T("input", {
133
+ ref_key: "textInputRef",
134
+ ref: i,
135
+ tabindex: e.enableTextFilter ? 0 : -1,
136
+ onKeydown: [
137
+ c[0] || (c[0] = m((L) => e.parentMethods.press(L), ["enter"])),
138
+ c[1] || (c[1] = m((L) => e.parentMethods.press(), ["space"])),
139
+ c[2] || (c[2] = m((L) => e.parentMethods.press(L), ["esc"])),
140
+ c[3] || (c[3] = m((L) => e.parentMethods.press(L), ["up"])),
141
+ c[4] || (c[4] = m((L) => e.parentMethods.press(L), ["down"]))
142
+ ],
143
+ onFocusin: c[5] || (c[5] = (L) => e.parentMethods.openList()),
144
+ onFocusout: c[6] || (c[6] = (L) => a(L)),
145
+ onClick: c[7] || (c[7] = (L) => e.parentMethods.openList()),
146
+ onInput: c[8] || (c[8] = (L) => t(L)),
147
+ type: "text",
148
+ "aria-autocomplete": "none",
149
+ autocomplete: "off",
150
+ placeholder: e.placeholder,
151
+ size: l.value,
152
+ class: S([[
153
+ g.value,
154
+ p.value,
155
+ { "text-filter-disabled": !e.enableTextFilter }
156
+ ], "list-filter-text-input"])
157
+ }, null, 42, qe));
158
+ }
159
+ }), $ = (e, s) => {
160
+ const b = e.__vccOpts || e;
161
+ for (const [h, o] of s)
162
+ b[h] = o;
163
+ return b;
164
+ }, be = /* @__PURE__ */ $(je, [["__scopeId", "data-v-18c89a96"]]), $e = {}, Ke = {
165
+ xmlns: "http://www.w3.org/2000/svg",
166
+ fill: "currentColor",
167
+ "aria-hidden": "true",
168
+ "data-slot": "icon",
169
+ viewBox: "0 -16 16 17"
170
+ };
171
+ function Ve(e, s) {
172
+ return w(), T("svg", Ke, s[0] || (s[0] = [
173
+ H("path", {
174
+ "shape-rendering": "geometricPrecision",
175
+ d: "M 6 -2.25 L 13.75 -14 A 0.5 0.5 90 0 1 15 -13 L 6.5 -0.5 A 2 1 90 0 1 5.5 -0.5 L 1 -6 A 0.5 0.5 90 0 1 2.25 -7 Z"
176
+ }, null, -1)
177
+ ]));
178
+ }
179
+ const ze = /* @__PURE__ */ $($e, [["render", Ve]]), Xe = ["onMousedown"], Ue = { class: "list-item-span" }, Je = /* @__PURE__ */ Q({
180
+ __name: "ListItem",
181
+ props: {
182
+ mouseHoveringOnList: {
183
+ type: Boolean,
184
+ default: !1
185
+ },
186
+ filteredListItems: {
187
+ type: Array,
188
+ default: () => []
189
+ },
190
+ focusedIndex: {
191
+ type: Number,
192
+ default: null
193
+ },
194
+ selectedIndex: {
195
+ type: Number,
196
+ default: null
197
+ },
198
+ listElementOpenAndVisible: {
199
+ type: Boolean,
200
+ default: !1
201
+ },
202
+ parentMethods: {
203
+ type: Object,
204
+ required: !0
205
+ },
206
+ showDropDown: {
207
+ type: Boolean,
208
+ default: !1
209
+ },
210
+ totalOptionsCount: {
211
+ type: Number,
212
+ default: 0
213
+ }
214
+ },
215
+ setup(e) {
216
+ const s = e, b = ke("items"), h = D(() => {
217
+ if (!b?.value) return null;
218
+ const t = (Array.isArray(b.value) ? b.value : [b.value])[s.focusedIndex];
219
+ return t && typeof t == "object" && "scrollIntoView" in t && typeof t.scrollIntoView == "function" ? t : null;
220
+ });
221
+ F(
222
+ () => s.showDropDown,
223
+ () => o()
224
+ ), F(
225
+ () => s.listElementOpenAndVisible,
226
+ () => i()
227
+ ), F(
228
+ () => h.value,
229
+ () => i()
230
+ );
231
+ function o() {
232
+ !s.showDropDown || !h?.value?.parentElement?.parentElement || (h.value.parentElement.parentElement.scrollTop = h.value.offsetTop);
233
+ }
234
+ function i() {
235
+ const a = h.value, t = a?.parentElement?.parentElement;
236
+ if (!s.showDropDown || !a || !t) return;
237
+ const l = a.offsetTop - t.scrollTop < 0, g = a.offsetTop + a.offsetHeight - t.scrollTop > t.clientHeight;
238
+ l && (t.scrollTop = a.offsetTop), g && (t.scrollTop = a.offsetTop + a.clientHeight - t.clientHeight);
239
+ }
240
+ return (a, t) => (w(), T(de, null, [
241
+ (w(!0), T(de, null, Ee(e.filteredListItems, (l, g) => (w(), T("li", {
242
+ key: g,
243
+ ref_for: !0,
244
+ ref: "items",
245
+ onKeyup: [
246
+ t[0] || (t[0] = m((p) => e.parentMethods.press(p), ["enter"])),
247
+ t[1] || (t[1] = m((p) => e.parentMethods.press(p), ["space"])),
248
+ t[2] || (t[2] = m((p) => e.parentMethods.press(p), ["esc"]))
249
+ ],
250
+ onKeydown: [
251
+ t[3] || (t[3] = m((p) => e.parentMethods.press(p), ["up"])),
252
+ t[4] || (t[4] = m((p) => e.parentMethods.press(p), ["down"]))
253
+ ],
254
+ onFocusout: t[5] || (t[5] = (p) => e.parentMethods.unfocus(p)),
255
+ tabindex: "-1",
256
+ onMousedown: te((p) => e.parentMethods.updatedSelected(l), ["left"]),
257
+ class: S([
258
+ { "list-option-selected": e.selectedIndex === g },
259
+ {
260
+ "list-option-active": e.filteredListItems.length === 1 || e.focusedIndex === g && !e.mouseHoveringOnList
261
+ },
262
+ "list-option"
263
+ ])
264
+ }, [
265
+ H("span", {
266
+ class: S(["list-item-span", { "list-item-extra-padding": e.selectedIndex === g }])
267
+ }, ve(e.parentMethods.getLabel(l)), 3),
268
+ e.selectedIndex === g ? (w(), ce(ze, {
269
+ key: 0,
270
+ class: "list-item-icon",
271
+ "aria-hidden": "true"
272
+ })) : j("", !0)
273
+ ], 42, Xe))), 128)),
274
+ e.filteredListItems.length === 0 ? (w(), T("li", {
275
+ key: 0,
276
+ onKeyup: [
277
+ t[6] || (t[6] = m((l) => e.parentMethods.press(l), ["enter"])),
278
+ t[7] || (t[7] = m((l) => e.parentMethods.press(l), ["space"])),
279
+ t[8] || (t[8] = m((l) => e.parentMethods.press(l), ["esc"]))
280
+ ],
281
+ onKeydown: [
282
+ t[9] || (t[9] = m((l) => e.parentMethods.press(l), ["up"])),
283
+ t[10] || (t[10] = m((l) => e.parentMethods.press(l), ["down"]))
284
+ ],
285
+ onFocusout: t[11] || (t[11] = (l) => e.parentMethods.unfocus(l)),
286
+ onMousedown: t[12] || (t[12] = te((l) => e.parentMethods.closeList(l), ["left"])),
287
+ tabindex: "-1",
288
+ class: "list-option-message"
289
+ }, t[20] || (t[20] = [
290
+ H("span", { class: "list-item-span" }, "No Items To Display.", -1)
291
+ ]), 32)) : j("", !0),
292
+ e.totalOptionsCount && e.totalOptionsCount > (e.filteredListItems?.length || 0) ? (w(), T("li", {
293
+ key: 1,
294
+ onKeyup: [
295
+ t[13] || (t[13] = m((l) => e.parentMethods.press(l), ["enter"])),
296
+ t[14] || (t[14] = m((l) => e.parentMethods.press(l), ["space"])),
297
+ t[15] || (t[15] = m((l) => e.parentMethods.press(l), ["esc"]))
298
+ ],
299
+ onKeydown: [
300
+ t[16] || (t[16] = m((l) => e.parentMethods.press(l), ["up"])),
301
+ t[17] || (t[17] = m((l) => e.parentMethods.press(l), ["down"]))
302
+ ],
303
+ onFocusout: t[18] || (t[18] = (l) => e.parentMethods.unfocus(l)),
304
+ onMousedown: t[19] || (t[19] = te((l) => e.parentMethods.closeList(l), ["left"])),
305
+ tabindex: "-1",
306
+ class: "list-option-message"
307
+ }, [
308
+ H("span", Ue, " +" + ve(e.totalOptionsCount - e.filteredListItems?.length || 0) + " More Items...", 1)
309
+ ], 32)) : j("", !0)
310
+ ], 64));
311
+ }
312
+ }), We = /* @__PURE__ */ $(Je, [["__scopeId", "data-v-9b370840"]]), Qe = /* @__PURE__ */ Q({
313
+ __name: "ItemList",
314
+ props: {
315
+ mouseHoveringOnList: {
316
+ type: Boolean,
317
+ default: !1
318
+ },
319
+ filteredListItems: {
320
+ type: Array,
321
+ default: () => []
322
+ },
323
+ focusedIndex: {
324
+ type: Number,
325
+ default: null
326
+ },
327
+ selectedIndex: {
328
+ type: Number,
329
+ default: null
330
+ },
331
+ parentMethods: {
332
+ type: Object,
333
+ required: !0
334
+ },
335
+ showDropDown: {
336
+ type: Boolean,
337
+ required: !0
338
+ },
339
+ maxListHeightPX: {
340
+ type: Number,
341
+ required: !0
342
+ },
343
+ listAnimationDurationMs: {
344
+ type: Number,
345
+ required: !0
346
+ },
347
+ blockListChange: {
348
+ type: Boolean,
349
+ required: !0
350
+ },
351
+ totalOptionsCount: {
352
+ type: Number,
353
+ default: 0
354
+ },
355
+ enableScrollClose: {
356
+ type: Boolean,
357
+ default: !0
358
+ }
359
+ },
360
+ emits: ["reverseDropDownList"],
361
+ setup(e, { expose: s, emit: b }) {
362
+ Ae((u) => ({
363
+ "1c26e35a": k.value,
364
+ "3a8b91f6": ne.value,
365
+ "3a8b8a74": P.value,
366
+ "3f1664b2": R.value,
367
+ c180c800: Y.value
368
+ }));
369
+ const h = b, o = e, i = f(null), a = f(null), t = f(null), l = f(0), g = f(0), p = f(0), N = f(0), k = f("0px"), d = f(!1), c = f([]), L = f(0), C = D(() => !d.value || window?.innerHeight == null ? !1 : z() && se()), E = D(() => o.maxListHeightPX >= L.value);
370
+ F(
371
+ () => C.value,
372
+ (u) => h("reverseDropDownList", u),
373
+ { immediate: !0 }
374
+ );
375
+ const ne = D(() => l.value + "px"), P = D(() => N.value + "px");
376
+ s({ listContainerRef: t });
377
+ const oe = (u) => {
378
+ u?.key && u.key === " " && u.preventDefault();
379
+ }, V = (u) => {
380
+ const y = t?.value, x = u.target;
381
+ (!(y && x && y.contains(x)) || y.isEqualNode(x)) && o.parentMethods.focusInput();
382
+ };
383
+ function M() {
384
+ return a?.value ? (a?.value).clientHeight : 0;
385
+ }
386
+ function Z() {
387
+ if (!o.showDropDown || M() === 0) return o.maxListHeightPX;
388
+ const u = M() === 0 ? o.maxListHeightPX : +M();
389
+ return o.maxListHeightPX && o.maxListHeightPX > u ? u : o.maxListHeightPX;
390
+ }
391
+ function z() {
392
+ return g.value > Z();
393
+ }
394
+ function se() {
395
+ return p.value < Z();
396
+ }
397
+ const Y = D(() => (o.maxListHeightPX || 0) + "px"), R = D(() => (o.listAnimationDurationMs || 0) + "ms"), G = D(() => o.blockListChange ? c.value : o.filteredListItems);
398
+ F(
399
+ () => G,
400
+ (u) => {
401
+ u && (c.value = u.value);
402
+ },
403
+ { immediate: !1, deep: !0 }
404
+ );
405
+ let O = setTimeout(() => {
406
+ }, 0), A = null;
407
+ function q() {
408
+ L.value = M(), clearTimeout(O), A && A.observe(), d.value = !0, K(void 0);
409
+ }
410
+ function ie() {
411
+ clearTimeout(O), O = setTimeout(() => {
412
+ o.showDropDown || (d.value = !1, A && A.unobserve());
413
+ }, o.listAnimationDurationMs + 50);
414
+ }
415
+ F(
416
+ () => o.showDropDown,
417
+ (u, y) => {
418
+ u !== y && (u ? q() : ie());
419
+ },
420
+ { immediate: !0 }
421
+ );
422
+ function K(u) {
423
+ X(), Ne(() => X()), _(u);
424
+ }
425
+ function _(u) {
426
+ if (!o.enableScrollClose || !u?.target || typeof t?.value?.contains != "function" || u?.target?.nodeType == null) return;
427
+ const y = ["scroll", "wheel", "touchmove"].includes(u?.type), x = !t.value.contains(u.target);
428
+ o.showDropDown && y && x && o.parentMethods.closeList();
429
+ }
430
+ function X() {
431
+ le(), U();
432
+ }
433
+ function le() {
434
+ if (i?.value == null) return;
435
+ const u = i.value.getBoundingClientRect();
436
+ g.value = u.top, p.value = window.innerHeight - u.bottom, k.value = u.width + "px";
437
+ }
438
+ function U() {
439
+ if (i?.value == null || t?.value == null) return;
440
+ const u = re().getBoundingClientRect(), y = t.value.getBoundingClientRect(), x = N.value, ee = l.value;
441
+ C.value ? N.value = x - (u.top - y.bottom) : N.value = x - (y.top - u.bottom), l.value = ee - (y.left - u.left);
442
+ }
443
+ function J() {
444
+ return (i?.value).getElementsByTagName("button")[0];
445
+ }
446
+ function re() {
447
+ return i?.value;
448
+ }
449
+ return ye(() => {
450
+ A = new He(K, J()), setTimeout(() => K(void 0), 250);
451
+ }), Fe(() => {
452
+ A?.unobserve();
453
+ }), (u, y) => (w(), T(de, null, [
454
+ H("div", {
455
+ ref_key: "dropDownButtonContainer",
456
+ ref: i,
457
+ class: "super-list-button-container"
458
+ }, [
459
+ Le(u.$slots, "default", {}, void 0, !0)
460
+ ], 512),
461
+ H("div", {
462
+ ref_key: "listContainerRef",
463
+ ref: t,
464
+ onMouseenter: y[0] || (y[0] = (x) => e.parentMethods.mouseOverList()),
465
+ tabindex: "-1",
466
+ class: S([
467
+ "select-list",
468
+ C.value ? "list-reverse" : "list-normal",
469
+ { "select-list-open": e.showDropDown },
470
+ { "no-scroll": E.value && d.value },
471
+ { "select-list-fixed": d.value },
472
+ { "select-list-scrollable": !E.value }
473
+ ]),
474
+ onKeydown: y[1] || (y[1] = m((x) => oe(x), ["space"])),
475
+ onMouseup: y[2] || (y[2] = te((x) => V(x), ["left"]))
476
+ }, [
477
+ H("ul", {
478
+ tabindex: "-1",
479
+ ref_key: "dropDownListUL",
480
+ ref: a,
481
+ class: "list-content"
482
+ }, [
483
+ W(We, {
484
+ filteredListItems: c.value,
485
+ mouseHoveringOnList: e.mouseHoveringOnList,
486
+ focusedIndex: e.focusedIndex,
487
+ selectedIndex: e.selectedIndex,
488
+ listElementOpenAndVisible: d.value,
489
+ "parent-methods": e.parentMethods,
490
+ "show-drop-down": e.showDropDown,
491
+ "total-options-count": e.totalOptionsCount
492
+ }, null, 8, ["filteredListItems", "mouseHoveringOnList", "focusedIndex", "selectedIndex", "listElementOpenAndVisible", "parent-methods", "show-drop-down", "total-options-count"])
493
+ ], 512)
494
+ ], 34)
495
+ ], 64));
496
+ }
497
+ }), he = /* @__PURE__ */ $(Qe, [["__scopeId", "data-v-02d0c000"]]), Ze = {}, Ye = {
498
+ xmlns: "http://www.w3.org/2000/svg",
499
+ fill: "currentColor",
500
+ "aria-hidden": "true",
501
+ "data-slot": "icon",
502
+ viewBox: "0 0 12 6"
503
+ };
504
+ function Ge(e, s) {
505
+ return w(), T("svg", Ye, s[0] || (s[0] = [
506
+ H("path", {
507
+ "shape-rendering": "geometricPrecision",
508
+ d: "M 6 4 L 10 0.25 A 0.5 0.5 90 0 1 11 1.25 L 6.5 5.75 A 15 3 90 0 1 5.5 5.75 L 1 1.25 A 0.5 0.5 90 0 1 2 0.25 Z"
509
+ }, null, -1)
510
+ ]));
511
+ }
512
+ const ge = /* @__PURE__ */ $(Ze, [["render", Ge]]), _e = ["tabindex"], et = {
513
+ key: 2,
514
+ class: "list-button-icon custom-icon"
515
+ }, tt = /* @__PURE__ */ Q({
516
+ __name: "ListButton",
517
+ props: {
518
+ // eslint-disable-line
519
+ parentMethods: {
520
+ type: Object,
521
+ required: !0
522
+ },
523
+ showDropDown: {
524
+ type: Boolean,
525
+ required: !0
526
+ },
527
+ enableTextFilter: {
528
+ type: Boolean,
529
+ required: !0
530
+ },
531
+ customIcon: {
532
+ default: null,
533
+ type: [Object, Function]
534
+ },
535
+ reverseDropDownList: {
536
+ type: Boolean,
537
+ required: !0
538
+ }
539
+ },
540
+ setup(e) {
541
+ const s = e;
542
+ function b() {
543
+ s.enableTextFilter || s.parentMethods.openList();
544
+ }
545
+ function h(o) {
546
+ s.enableTextFilter ? (s.parentMethods.focusInput(), o.stopPropagation(), o.preventDefault()) : s.parentMethods.press(o);
547
+ }
548
+ return (o, i) => (w(), T("button", {
549
+ tabindex: e.enableTextFilter ? -1 : 0,
550
+ onKeyup: [
551
+ i[0] || (i[0] = m((a) => h(a), ["enter"])),
552
+ i[1] || (i[1] = m((a) => e.parentMethods.press(a), ["space"])),
553
+ i[2] || (i[2] = m((a) => e.parentMethods.press(a), ["esc"]))
554
+ ],
555
+ onKeydown: [
556
+ i[3] || (i[3] = m((a) => e.parentMethods.press(a), ["up"])),
557
+ i[4] || (i[4] = m((a) => e.parentMethods.press(a), ["down"]))
558
+ ],
559
+ onFocusin: i[5] || (i[5] = (a) => e.parentMethods.openList()),
560
+ onFocusout: i[6] || (i[6] = (a) => e.parentMethods.unfocus(a)),
561
+ onClick: i[7] || (i[7] = (a) => b()),
562
+ type: "button",
563
+ class: S([[{ "click-through": s.enableTextFilter || s.showDropDown }], "list-button"])
564
+ }, [
565
+ Le(o.$slots, "default", {}, void 0, !0),
566
+ H("span", {
567
+ class: S(["list-button-icon-div", { "bigger-gap": s.showDropDown }])
568
+ }, [
569
+ e.customIcon ? j("", !0) : (w(), T("span", {
570
+ key: 0,
571
+ class: S(["list-button-icon", [{ "rotate-180": !s.showDropDown }]])
572
+ }, [
573
+ W(ge, { "aria-hidden": "true" })
574
+ ], 2)),
575
+ e.customIcon ? j("", !0) : (w(), T("span", {
576
+ key: 1,
577
+ class: S(["list-button-icon", [{ "rotate-180": s.showDropDown }]])
578
+ }, [
579
+ e.customIcon == null ? (w(), ce(ge, {
580
+ key: 0,
581
+ "aria-hidden": "true"
582
+ })) : j("", !0)
583
+ ], 2)),
584
+ e.customIcon ? (w(), T("span", et, [
585
+ (w(), ce(Se(e.customIcon), { "aria-hidden": "true" }))
586
+ ])) : j("", !0)
587
+ ], 2)
588
+ ], 42, _e));
589
+ }
590
+ }), nt = /* @__PURE__ */ $(tt, [["__scopeId", "data-v-f5167d40"]]), ot = /* @__PURE__ */ Q({
591
+ __name: "super-list",
592
+ props: {
593
+ selected: {
594
+ type: [String, Number, Object, null, void 0]
595
+ },
596
+ options: {
597
+ type: [Function, Array],
598
+ required: !0
599
+ },
600
+ maxListOptions: {
601
+ type: Number,
602
+ default: 50
603
+ },
604
+ maxListHeightPX: {
605
+ type: Number,
606
+ default: 200
607
+ },
608
+ tooltip: {
609
+ type: String,
610
+ required: !1
611
+ },
612
+ objectLabelKeyName: {
613
+ type: String,
614
+ default: ""
615
+ },
616
+ enumKeyToLabelObjectArray: {
617
+ type: Object,
618
+ default: void 0
619
+ },
620
+ listAnimationDurationMs: {
621
+ type: Number,
622
+ default: 300
623
+ },
624
+ customIcon: {
625
+ default: null,
626
+ type: [Object, Function]
627
+ },
628
+ forceTextFilterVisibilityTo: {
629
+ type: Boolean,
630
+ default: void 0
631
+ },
632
+ customPlaceHolderFunction: {
633
+ type: Function,
634
+ default: null
635
+ },
636
+ colour: {
637
+ type: String,
638
+ default: "black"
639
+ }
640
+ },
641
+ emits: { "update:selected": null },
642
+ setup(e, { expose: s, emit: b }) {
643
+ const h = b, o = e, i = f([]), a = new Re(), t = f(0), l = D(() => o.forceTextFilterVisibilityTo !== void 0 ? o.forceTextFilterVisibilityTo : t.value > o.maxListOptions), g = f(!1), p = f(!1), N = f(!1), k = f(!0), d = f(!1), c = f(!1), L = f(he), C = f(be), E = f("");
644
+ F(
645
+ () => E.value,
646
+ (n, r) => {
647
+ n !== r && typeof o.options == "function" && ee(n);
648
+ }
649
+ );
650
+ const ne = () => {
651
+ l.value && C?.value?.blurInput();
652
+ }, P = () => {
653
+ clearTimeout(J), ne(), E.value = "", g.value = !1, k.value = !0;
654
+ }, oe = D(() => c?.value === !0 ? "Error loading data" : d?.value === !0 ? "Loading..." : Z(o.selected)), V = (n) => {
655
+ n && h("update:selected", n), P();
656
+ }, M = (n, r = !1) => Be(
657
+ n,
658
+ r ? o.customPlaceHolderFunction : void 0,
659
+ o.objectLabelKeyName,
660
+ o.enumKeyToLabelObjectArray
661
+ );
662
+ function Z(n) {
663
+ return M(n, !0);
664
+ }
665
+ function z() {
666
+ throw d.value = !0, c.value = !0, new Error("Invalid options argument provided to ListInputComponent");
667
+ }
668
+ function se() {
669
+ throw d.value = !0, c.value = !0, new Error("Invalid response provided to ListInputComponent, no total count key found");
670
+ }
671
+ function Y() {
672
+ throw d.value = !0, c.value = !0, new Error("Invalid objectLabelKeyName for provided Dropdown list value.");
673
+ }
674
+ ye(() => {
675
+ typeof o.options != "function" && !Array.isArray(o.options) ? z() : y();
676
+ });
677
+ const R = f(!1), G = f(0), O = f(0), A = f(0);
678
+ F(
679
+ () => O.value,
680
+ (n, r) => {
681
+ n != r && !p.value && (A.value = n);
682
+ },
683
+ { immediate: !0 }
684
+ ), F(
685
+ () => p.value,
686
+ (n) => {
687
+ n || (A.value = O.value);
688
+ },
689
+ { immediate: !0 }
690
+ );
691
+ const q = D(() => {
692
+ if (typeof o.options == "function" && !Array.isArray(o.options)) return i.value;
693
+ const n = E.value, r = i.value;
694
+ return n === "" ? r : r.filter((v) => M(v).toLowerCase().includes(n.toLowerCase()));
695
+ });
696
+ F(
697
+ () => q.value,
698
+ (n, r) => {
699
+ JSON.stringify(n) !== JSON.stringify(r) && K();
700
+ },
701
+ { immediate: !1, deep: !0 }
702
+ );
703
+ const ie = () => {
704
+ R.value = !0;
705
+ }, K = () => {
706
+ const n = _();
707
+ G.value = n, O.value = n > -1 ? n : 0;
708
+ };
709
+ function _() {
710
+ if (o.selected == null) return -1;
711
+ const n = i.value.map((v) => M(v)), r = n.filter((v) => v === M(o.selected));
712
+ if (r.length > 1) {
713
+ const v = r.map((I) => n.indexOf(I));
714
+ for (let I = 0; I < v.length; I++) {
715
+ const B = JSON.stringify(i.value[v[I]]), ae = JSON.stringify(o.selected);
716
+ if (B === ae) return v[I];
717
+ }
718
+ return -1;
719
+ }
720
+ return n.indexOf(M(o.selected));
721
+ }
722
+ const X = () => {
723
+ d.value || (g.value || (p.value = !1, K(), le(), g.value = !0), R.value = !1, k.value = !1);
724
+ }, le = () => {
725
+ const n = window.innerWidth != null && window.innerWidth < 640, r = C.value.textInputRef;
726
+ n && l.value && (re(), r?.scrollIntoView({ block: "start" }));
727
+ }, U = f(!0);
728
+ let J = setTimeout(() => {
729
+ }, 0);
730
+ function re() {
731
+ C.value.textInputRef && (clearTimeout(J), U.value = !1, J = setTimeout(() => {
732
+ U.value = !0;
733
+ }, 300));
734
+ }
735
+ const u = () => C.value.focusInput();
736
+ async function y() {
737
+ typeof o.options == "function" ? await ee(E.value ? E.value : void 0, !0) : (pe(o.options), t.value = i.value.length), x();
738
+ }
739
+ s({ initializeOptions: y, getLabel: M });
740
+ function x() {
741
+ _() == -1 && i.value && !!i.value[0] && V(i.value[0]);
742
+ }
743
+ async function ee(n, r = !0) {
744
+ d.value = r;
745
+ const v = async () => o.options(o.maxListOptions, n || ""), I = (B) => {
746
+ (!B || !("data" in B)) && z(), pe(B.data), we(B?.data?.length ?? 0).then(() => {
747
+ d.value = !1;
748
+ });
749
+ };
750
+ await a.resetAndExecute(v, I);
751
+ }
752
+ async function we(n) {
753
+ const r = async () => o.options(1, ""), v = (I) => {
754
+ (!I || !("totalNum" in I)) && se(), t.value = I.totalNum ?? n;
755
+ };
756
+ await a.resetAndExecute(r, v);
757
+ }
758
+ const fe = () => C?.value?.textInputRef?.getElementsByTagName("li")[O.value] ?? null, xe = (n) => {
759
+ g.value == !1 ? X() : n && Ie(n);
760
+ }, Ie = (n) => {
761
+ const r = n.key || n.code;
762
+ (r === "Tab" || r === "Escape") && P(), r === "ArrowDown" && Te(n), r === "ArrowUp" && Oe(n), (r === "Enter" || r === " ") && De(), n.preventDefault(), n.stopPropagation();
763
+ }, De = () => {
764
+ q.value.length > 0 ? (p.value = !0, V(q.value[O.value])) : P();
765
+ }, Te = (n) => {
766
+ k.value = !0, O.value < q.value.length - 1 && (n.preventDefault(), R.value = !1, O.value++, fe()?.focus());
767
+ }, Oe = (n) => {
768
+ k.value = !0, O.value > 0 && (n.preventDefault(), R.value = !1, O.value--, fe()?.focus());
769
+ }, Me = (n) => {
770
+ if (g?.value === !1) return;
771
+ E.value.length > 0 && (p.value = !0);
772
+ const r = L?.value?.listContainerRef, v = C?.value?.textInputRef, I = n?.relatedTarget && v?.isEqualNode(n?.relatedTarget), B = n?.relatedTarget && r && r.contains(n?.relatedTarget), ae = n?.relatedTarget && r && r.isEqualNode(n?.relatedTarget);
773
+ if (!(B || I)) {
774
+ if (ae) {
775
+ u();
776
+ return;
777
+ }
778
+ P();
779
+ }
780
+ };
781
+ function pe(n) {
782
+ Array.isArray(n) || z(), n.length > 0 && typeof n[0] == "object" && Ce(n), i.value = n;
783
+ }
784
+ function Ce(n) {
785
+ (!o.objectLabelKeyName || o.objectLabelKeyName.length === 0) && Y();
786
+ const r = o.objectLabelKeyName;
787
+ for (let v = 0; v < n.length; v++)
788
+ (typeof n[v] != "object" || !(r in n[v])) && Y();
789
+ }
790
+ const ue = {
791
+ openList: X,
792
+ unfocus: Me,
793
+ press: xe,
794
+ mouseOverList: ie,
795
+ getLabel: M,
796
+ updatedSelected: V,
797
+ focusInput: u,
798
+ closeList: P
799
+ };
800
+ return (n, r) => (w(), T("div", {
801
+ style: { position: "relative" },
802
+ class: S(n.$attrs.class)
803
+ }, [
804
+ W(he, {
805
+ ref_key: "itemListRef",
806
+ ref: L,
807
+ "show-drop-down": g.value,
808
+ filteredListItems: q.value,
809
+ mouseHoveringOnList: R.value,
810
+ focusedIndex: A.value,
811
+ selectedIndex: G.value,
812
+ "max-list-height-p-x": e.maxListHeightPX,
813
+ "list-animation-duration-ms": e.listAnimationDurationMs,
814
+ "parent-methods": ue,
815
+ blockListChange: p.value,
816
+ "onUpdate:blockListChange": r[1] || (r[1] = (v) => p.value = v),
817
+ "total-options-count": t.value,
818
+ onReverseDropDownList: r[2] || (r[2] = (v) => N.value = v),
819
+ enableScrollClose: U.value
820
+ }, {
821
+ default: me(() => [
822
+ W(nt, {
823
+ "parent-methods": ue,
824
+ "show-drop-down": g.value,
825
+ "enable-text-filter": l.value,
826
+ "custom-icon": e.customIcon,
827
+ "reverse-drop-down-list": N.value
828
+ }, {
829
+ default: me(() => [
830
+ W(be, {
831
+ ref_key: "dropDownTextInput",
832
+ ref: C,
833
+ "enable-text-filter": l.value,
834
+ "show-drop-down": g.value,
835
+ placeholder: oe.value,
836
+ "enable-button-click": k.value,
837
+ "parent-methods": ue,
838
+ "onUpdate:query": r[0] || (r[0] = (v) => E.value = v)
839
+ }, null, 8, ["enable-text-filter", "show-drop-down", "placeholder", "enable-button-click"])
840
+ ]),
841
+ _: 1
842
+ }, 8, ["show-drop-down", "enable-text-filter", "custom-icon", "reverse-drop-down-list"])
843
+ ]),
844
+ _: 1
845
+ }, 8, ["show-drop-down", "filteredListItems", "mouseHoveringOnList", "focusedIndex", "selectedIndex", "max-list-height-p-x", "list-animation-duration-ms", "blockListChange", "total-options-count", "enableScrollClose"])
846
+ ], 2));
847
+ }
848
+ }), it = /* @__PURE__ */ $(ot, [["__scopeId", "data-v-f0f16320"]]);
849
+ export {
850
+ it as default
851
+ };
852
+ //# sourceMappingURL=super-list.js.map