@signal24/vue-foundation 4.13.8 → 4.14.0
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.
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { Writable } from 'type-fest';
|
|
2
2
|
import { type AllowedComponentProps, type ComponentInternalInstance, type ComponentPublicInstance, type ComputedOptions, type MethodOptions, type Raw, type VNode, type VNodeProps } from 'vue';
|
|
3
3
|
import type { OverlayAnchorOptions } from './overlay-types';
|
|
4
|
-
interface OverlayOptions {
|
|
4
|
+
interface OverlayOptions<C extends OverlayComponent, R extends ComponentReturn<C>> {
|
|
5
5
|
anchor?: OverlayAnchorOptions;
|
|
6
|
+
onCallback?: (result: R) => void | Promise<boolean>;
|
|
6
7
|
}
|
|
7
|
-
export interface OverlayInjection<C extends OverlayComponent
|
|
8
|
+
export interface OverlayInjection<C extends OverlayComponent, R extends ComponentReturn<C>> {
|
|
8
9
|
id: string;
|
|
9
10
|
component: OverlayComponentUnwrapped<C>;
|
|
10
11
|
props: OverlayComponentProps<C>;
|
|
11
|
-
options: OverlayOptions
|
|
12
|
+
options: OverlayOptions<C, R>;
|
|
12
13
|
vnode: VNode;
|
|
13
14
|
wrapperVnode?: VNode;
|
|
14
15
|
}
|
|
@@ -41,11 +42,11 @@ type ComponentReturn<M extends OverlayComponent> = OverlayComponentProps<M> exte
|
|
|
41
42
|
export type AnyComponentPublicInstance = {
|
|
42
43
|
$?: ComponentInternalInstance;
|
|
43
44
|
};
|
|
44
|
-
export declare function createOverlayInjection<C extends OverlayComponent
|
|
45
|
+
export declare function createOverlayInjection<C extends OverlayComponent, R extends ComponentReturn<C>>(component: C, props: OverlayComponentProps<C>, options?: OverlayOptions<C, R>): OverlayInjection<C, R>;
|
|
45
46
|
export declare function dismissOverlayInjectionByInstance(instance: AnyComponentPublicInstance): void;
|
|
46
47
|
export declare function dismissOverlayInjectionByInternalInstance(instance: ComponentInternalInstance): void;
|
|
47
48
|
export declare function dismissOverlayInjectionByVnode(vnode: VNode): boolean;
|
|
48
49
|
export declare function dismissOverlayInjectionById(id: string): boolean;
|
|
49
|
-
export declare function removeOverlayInjection(injection: OverlayInjection<any>): void;
|
|
50
|
-
export declare function presentOverlay<C extends OverlayComponent, R extends ComponentReturn<C>>(component: C, props: Omit<OverlayComponentProps<C>, 'callback'>, options?: OverlayOptions): Promise<R | undefined>;
|
|
50
|
+
export declare function removeOverlayInjection(injection: OverlayInjection<any, any>): void;
|
|
51
|
+
export declare function presentOverlay<C extends OverlayComponent, R extends ComponentReturn<C>>(component: C, props: Omit<OverlayComponentProps<C>, 'callback'>, options?: OverlayOptions<C, R>): Promise<R | undefined>;
|
|
51
52
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
var Ve = Object.defineProperty;
|
|
2
2
|
var Fe = (e, t, n) => t in e ? Ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var E = (e, t, n) => (Fe(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
import { compact as ze, debounce as Xe, isEqual as
|
|
4
|
+
import { defineComponent as C, defineProps as _e, defineEmits as Re, ref as O, computed as _, openBlock as d, createElementBlock as h, createElementVNode as w, toDisplayString as x, withDirectives as j, createCommentVNode as b, Fragment as U, renderList as J, vModelSelect as Ne, getCurrentInstance as ee, onMounted as L, normalizeClass as k, normalizeStyle as Ke, withModifiers as te, renderSlot as K, reactive as je, h as W, Teleport as Ue, markRaw as We, onBeforeUnmount as ne, resolveDirective as Oe, createBlock as be, createSlots as Pe, withCtx as Y, createTextVNode as ae, vModelText as qe, watch as ce, onActivated as ke, onDeactivated as Se } from "vue";
|
|
5
|
+
import { compact as ze, debounce as Xe, isEqual as Ce, upperFirst as Ye, startCase as Ze, cloneDeep as Ge, remove as Qe } from "lodash";
|
|
6
6
|
import { escapeHtml as Je } from "@vue/shared";
|
|
7
7
|
import { escapeHtml as ni } from "@vue/shared";
|
|
8
8
|
import { installOpenApiClientInterceptors as et, isOpenApiError as tt } from "@signal24/openapi-client-codegen/browser";
|
|
9
9
|
import { format as G } from "date-fns";
|
|
10
|
-
const nt =
|
|
10
|
+
const nt = C({
|
|
11
11
|
setup() {
|
|
12
12
|
const e = _e();
|
|
13
|
-
|
|
13
|
+
Re(["update:modelValue"]);
|
|
14
14
|
const t = O(null), n = _(() => t.value ? t.value.map((o) => e.preprocesor ? e.preprocesor(o) : o[e.displayKey ?? ""]) : null), i = O(e.modelValue ?? null);
|
|
15
15
|
return { props: e, options: t, renderOptions: n, selectedItem: i };
|
|
16
16
|
},
|
|
@@ -33,7 +33,7 @@ const nt = x({
|
|
|
33
33
|
this.options = await this.props.loadFn();
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
}),
|
|
36
|
+
}), xe = (e, t) => {
|
|
37
37
|
const n = e.__vccOpts || e;
|
|
38
38
|
for (const [i, s] of t)
|
|
39
39
|
n[i] = s;
|
|
@@ -45,26 +45,26 @@ const nt = x({
|
|
|
45
45
|
key: 0,
|
|
46
46
|
value: null
|
|
47
47
|
}, ot = ["value"];
|
|
48
|
-
function
|
|
48
|
+
function lt(e, t, n, i, s, o) {
|
|
49
49
|
return e.renderOptions ? j((d(), h("select", {
|
|
50
50
|
key: 1,
|
|
51
|
-
"onUpdate:modelValue": t[0] || (t[0] = (
|
|
51
|
+
"onUpdate:modelValue": t[0] || (t[0] = (r) => e.selectedItem = r)
|
|
52
52
|
}, [
|
|
53
|
-
e.props.nullText ? (d(), h("option", st,
|
|
54
|
-
(d(!0), h(U, null, J(e.renderOptions, (
|
|
53
|
+
e.props.nullText ? (d(), h("option", st, x(e.props.nullText), 1)) : b("", !0),
|
|
54
|
+
(d(!0), h(U, null, J(e.renderOptions, (r, l) => {
|
|
55
55
|
var a;
|
|
56
56
|
return d(), h("option", {
|
|
57
|
-
key:
|
|
58
|
-
value: (a = e.options) == null ? void 0 : a[
|
|
59
|
-
},
|
|
57
|
+
key: l,
|
|
58
|
+
value: (a = e.options) == null ? void 0 : a[l]
|
|
59
|
+
}, x(r), 9, ot);
|
|
60
60
|
}), 128))
|
|
61
61
|
], 512)), [
|
|
62
|
-
[
|
|
62
|
+
[Ne, e.selectedItem]
|
|
63
63
|
]) : (d(), h("select", it, [
|
|
64
|
-
w("option", null,
|
|
64
|
+
w("option", null, x(e.props.loadingText || "Loading..."), 1)
|
|
65
65
|
]));
|
|
66
66
|
}
|
|
67
|
-
const Mn = /* @__PURE__ */
|
|
67
|
+
const Mn = /* @__PURE__ */ xe(nt, [["render", lt]]), rt = /* @__PURE__ */ C({
|
|
68
68
|
__name: "overlay-anchor",
|
|
69
69
|
props: {
|
|
70
70
|
overlayId: {},
|
|
@@ -72,14 +72,14 @@ const Mn = /* @__PURE__ */ Ce(nt, [["render", rt]]), lt = /* @__PURE__ */ x({
|
|
|
72
72
|
},
|
|
73
73
|
setup(e) {
|
|
74
74
|
const t = e, n = t.anchor instanceof HTMLElement ? t.anchor : t.anchor.el, i = O({ visibility: "hidden", top: "0", left: "0" }), s = O([]), o = ee();
|
|
75
|
-
L(
|
|
76
|
-
function
|
|
75
|
+
L(r);
|
|
76
|
+
function r() {
|
|
77
77
|
if (!o)
|
|
78
78
|
return;
|
|
79
|
-
const p = o.vnode.el, { styles: g, classes: m } =
|
|
79
|
+
const p = o.vnode.el, { styles: g, classes: m } = l(p, n);
|
|
80
80
|
i.value = g, s.value = m;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function l(p, g) {
|
|
83
83
|
const m = t.anchor instanceof HTMLElement ? {} : t.anchor, v = g.getBoundingClientRect(), f = p.getBoundingClientRect();
|
|
84
84
|
m.matchWidth && (f.width = v.width), m.matchHeight && (f.height = v.height);
|
|
85
85
|
const u = m.class ? Array.isArray(m.class) ? m.class : [m.class] : [];
|
|
@@ -123,7 +123,7 @@ const Mn = /* @__PURE__ */ Ce(nt, [["render", rt]]), lt = /* @__PURE__ */ x({
|
|
|
123
123
|
}
|
|
124
124
|
});
|
|
125
125
|
let at = 0;
|
|
126
|
-
const S = je([]), In =
|
|
126
|
+
const S = je([]), In = C({
|
|
127
127
|
setup() {
|
|
128
128
|
return () => W("div", [
|
|
129
129
|
J(S, (e) => W(Ue, { key: e.id, to: "#vf-overlay-target" }, [e.wrapperVnode ?? e.vnode]))
|
|
@@ -133,13 +133,13 @@ const S = je([]), In = x({
|
|
|
133
133
|
function ie(e, t, n) {
|
|
134
134
|
const i = document.getElementById("vf-overlay-target") ?? document.createElement("div");
|
|
135
135
|
i.id = "vf-overlay-target", i.removeAttribute("inert"), document.body.appendChild(i);
|
|
136
|
-
const s = String(++at), o = We(e),
|
|
136
|
+
const s = String(++at), o = We(e), r = W(o, t), l = n != null && n.anchor ? W(rt, { overlayId: s, anchor: n.anchor }, () => [r]) : void 0, a = {
|
|
137
137
|
id: s,
|
|
138
138
|
component: o,
|
|
139
139
|
props: t,
|
|
140
140
|
options: n ?? {},
|
|
141
|
-
vnode:
|
|
142
|
-
wrapperVnode:
|
|
141
|
+
vnode: r,
|
|
142
|
+
wrapperVnode: l
|
|
143
143
|
};
|
|
144
144
|
return S.push(a), a;
|
|
145
145
|
}
|
|
@@ -166,10 +166,15 @@ function P(e) {
|
|
|
166
166
|
async function se(e, t, n) {
|
|
167
167
|
return new Promise((i) => {
|
|
168
168
|
let s = null;
|
|
169
|
-
const
|
|
170
|
-
|
|
169
|
+
const r = { ...t, callback: async (l) => {
|
|
170
|
+
if (n != null && n.onCallback) {
|
|
171
|
+
const a = n.onCallback(l);
|
|
172
|
+
if (typeof a == "object" && "then" in a && typeof a.then == "function" && await a === !1)
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
P(s), i(l);
|
|
171
176
|
} };
|
|
172
|
-
s = ie(e,
|
|
177
|
+
s = ie(e, r, n);
|
|
173
178
|
});
|
|
174
179
|
}
|
|
175
180
|
function q(e, t) {
|
|
@@ -239,7 +244,7 @@ function _n(e, t) {
|
|
|
239
244
|
const n = (s = e.$) == null ? void 0 : s.vnode.el, i = n.closest(".vf-modal");
|
|
240
245
|
return ht(i ?? n, t);
|
|
241
246
|
}
|
|
242
|
-
function
|
|
247
|
+
function Rn(e) {
|
|
243
248
|
var i;
|
|
244
249
|
const t = (i = e.$) == null ? void 0 : i.vnode.el, n = t.closest(".vf-modal");
|
|
245
250
|
return Me(n ?? t);
|
|
@@ -264,9 +269,9 @@ function ft(e, t, n) {
|
|
|
264
269
|
const s = t instanceof Element ? t : i.querySelectorAll(t ?? 'button:not([disabled]):not([type="button"])')[0];
|
|
265
270
|
let o;
|
|
266
271
|
s && (o = s.tagName === "INPUT" ? s.value : s.innerHTML, s.setAttribute("disabled", "disabled"), s.innerText = n ?? "Please wait...");
|
|
267
|
-
const
|
|
268
|
-
return
|
|
269
|
-
disabledElements:
|
|
272
|
+
const l = [...i.querySelectorAll("input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])")];
|
|
273
|
+
return l.forEach((a) => a.setAttribute("disabled", "disabled")), i[Q] = {
|
|
274
|
+
disabledElements: l,
|
|
270
275
|
waitButton: s,
|
|
271
276
|
buttonHtml: o
|
|
272
277
|
}, () => Ie(i);
|
|
@@ -289,7 +294,7 @@ const pt = ["id"], mt = {
|
|
|
289
294
|
}, vt = { class: "vf-modal-content" }, yt = {
|
|
290
295
|
key: 1,
|
|
291
296
|
class: "vf-modal-footer"
|
|
292
|
-
}, gt = /* @__PURE__ */
|
|
297
|
+
}, gt = /* @__PURE__ */ C({
|
|
293
298
|
__name: "modal",
|
|
294
299
|
props: {
|
|
295
300
|
id: {},
|
|
@@ -302,7 +307,7 @@ const pt = ["id"], mt = {
|
|
|
302
307
|
setup(e, { expose: t }) {
|
|
303
308
|
const n = ee(), i = e;
|
|
304
309
|
t({ mask: m, unmask: v, hide: f, unhide: u });
|
|
305
|
-
const s = O(), o = O(),
|
|
310
|
+
const s = O(), o = O(), r = O(!1), l = _(() => ze([i.class, r.value && "hidden"]));
|
|
306
311
|
L(() => {
|
|
307
312
|
var c;
|
|
308
313
|
document.body.classList.add("vf-modal-open"), i.closeOnMaskClick && (window.addEventListener("keydown", p), (c = s.value) == null || c.addEventListener("click", a));
|
|
@@ -328,14 +333,14 @@ const pt = ["id"], mt = {
|
|
|
328
333
|
Ie(o.value);
|
|
329
334
|
}
|
|
330
335
|
function f() {
|
|
331
|
-
return
|
|
336
|
+
return r.value = !0, () => u();
|
|
332
337
|
}
|
|
333
338
|
function u() {
|
|
334
|
-
|
|
339
|
+
r.value = !1;
|
|
335
340
|
}
|
|
336
341
|
return (c, T) => (d(), h("div", {
|
|
337
342
|
id: c.id,
|
|
338
|
-
class: k(["vf-overlay vf-modal-wrap",
|
|
343
|
+
class: k(["vf-overlay vf-modal-wrap", l.value]),
|
|
339
344
|
ref_key: "overlay",
|
|
340
345
|
ref: s
|
|
341
346
|
}, [
|
|
@@ -363,7 +368,7 @@ const pt = ["id"], mt = {
|
|
|
363
368
|
], 34)
|
|
364
369
|
], 10, pt));
|
|
365
370
|
}
|
|
366
|
-
}), Et = ["innerHtml"], Tt = ["innerText"], X = /* @__PURE__ */
|
|
371
|
+
}), Et = ["innerHtml"], Tt = ["innerText"], X = /* @__PURE__ */ C({
|
|
367
372
|
__name: "alert-modal",
|
|
368
373
|
props: {
|
|
369
374
|
isBare: { type: Boolean },
|
|
@@ -396,7 +401,7 @@ const pt = ["id"], mt = {
|
|
|
396
401
|
i.title ? {
|
|
397
402
|
name: "header",
|
|
398
403
|
fn: Y(() => [
|
|
399
|
-
w("h1", null,
|
|
404
|
+
w("h1", null, x(i.title), 1)
|
|
400
405
|
]),
|
|
401
406
|
key: "0"
|
|
402
407
|
} : void 0,
|
|
@@ -432,12 +437,12 @@ const pt = ["id"], mt = {
|
|
|
432
437
|
};
|
|
433
438
|
}
|
|
434
439
|
});
|
|
435
|
-
let
|
|
440
|
+
let N;
|
|
436
441
|
const wt = new Uint8Array(16);
|
|
437
442
|
function Ot() {
|
|
438
|
-
if (!
|
|
443
|
+
if (!N && (N = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !N))
|
|
439
444
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
440
|
-
return
|
|
445
|
+
return N(wt);
|
|
441
446
|
}
|
|
442
447
|
const y = [];
|
|
443
448
|
for (let e = 0; e < 256; ++e)
|
|
@@ -461,13 +466,13 @@ function St(e, t, n) {
|
|
|
461
466
|
}
|
|
462
467
|
return bt(i);
|
|
463
468
|
}
|
|
464
|
-
function
|
|
469
|
+
function Nn(e) {
|
|
465
470
|
return e.replace(/\n/g, "<br>");
|
|
466
471
|
}
|
|
467
|
-
function
|
|
472
|
+
function Ct(e) {
|
|
468
473
|
return e.replace(/_/g, " ");
|
|
469
474
|
}
|
|
470
|
-
function
|
|
475
|
+
function xt(e) {
|
|
471
476
|
const t = e.replace(/\D/g, "").replace(/^1/, "");
|
|
472
477
|
return t.length != 10 ? e : "(" + t.substring(0, 3) + ") " + t.substring(3, 6) + "-" + t.substring(6);
|
|
473
478
|
}
|
|
@@ -554,16 +559,16 @@ const D = Symbol("null"), he = Symbol("create"), Mt = "`1234567890-=[]\\;',./~!@
|
|
|
554
559
|
},
|
|
555
560
|
optionsDescriptors() {
|
|
556
561
|
return this.allOptions.map((e, t) => {
|
|
557
|
-
var
|
|
558
|
-
const n = this.formatter(e), i = (
|
|
562
|
+
var l, a;
|
|
563
|
+
const n = this.formatter(e), i = (l = this.subtitleFormatter) == null ? void 0 : l.call(this, e), s = n ? n.trim().toLowerCase() : "", o = i ? i.trim().toLowerCase() : "", r = [];
|
|
559
564
|
return this.searchFields ? this.searchFields.forEach((p) => {
|
|
560
|
-
e[p] &&
|
|
561
|
-
}) : (
|
|
565
|
+
e[p] && r.push(String(e[p]).toLowerCase());
|
|
566
|
+
}) : (r.push(s), o && r.push(o)), {
|
|
562
567
|
// eslint-disable-next-line vue/no-use-computed-property-like-method
|
|
563
568
|
key: ((a = this.effectiveKeyExtractor) == null ? void 0 : a.call(this, e)) ?? String(t),
|
|
564
569
|
title: n,
|
|
565
570
|
subtitle: i,
|
|
566
|
-
searchContent:
|
|
571
|
+
searchContent: r.join(""),
|
|
567
572
|
ref: e
|
|
568
573
|
};
|
|
569
574
|
});
|
|
@@ -682,7 +687,7 @@ const D = Symbol("null"), he = Symbol("create"), Mt = "`1234567890-=[]\\;',./~!@
|
|
|
682
687
|
const t = this.effectiveOptions.find((s) => s.ref === e);
|
|
683
688
|
if (t)
|
|
684
689
|
return t;
|
|
685
|
-
const n = this.keyExtractor ? (s, o) => this.keyExtractor(s) === this.keyExtractor(o) :
|
|
690
|
+
const n = this.keyExtractor ? (s, o) => this.keyExtractor(s) === this.keyExtractor(o) : Ce, i = this.effectiveOptions.find((s) => n(s.ref, e));
|
|
686
691
|
return i || null;
|
|
687
692
|
},
|
|
688
693
|
handleInputBlurred() {
|
|
@@ -751,50 +756,51 @@ const D = Symbol("null"), he = Symbol("create"), Mt = "`1234567890-=[]\\;',./~!@
|
|
|
751
756
|
class: "no-results"
|
|
752
757
|
};
|
|
753
758
|
function _t(e, t, n, i, s, o) {
|
|
754
|
-
const
|
|
759
|
+
const r = Oe("disabled");
|
|
755
760
|
return d(), h("div", {
|
|
756
761
|
class: k(["vf-smart-select", { disabled: o.effectiveDisabled, open: e.shouldDisplayOptions }])
|
|
757
762
|
}, [
|
|
758
763
|
j(w("input", {
|
|
759
|
-
"onUpdate:modelValue": t[0] || (t[0] = (
|
|
764
|
+
"onUpdate:modelValue": t[0] || (t[0] = (l) => e.searchText = l),
|
|
760
765
|
ref: "searchField",
|
|
761
766
|
type: "text",
|
|
762
767
|
class: k({ nullable: !!n.nullTitle }),
|
|
763
|
-
onKeydown: t[1] || (t[1] = (...
|
|
768
|
+
onKeydown: t[1] || (t[1] = (...l) => o.handleKeyDown && o.handleKeyDown(...l)),
|
|
764
769
|
placeholder: o.effectivePlaceholder,
|
|
765
|
-
onFocus: t[2] || (t[2] = (...
|
|
766
|
-
onBlur: t[3] || (t[3] = (...
|
|
767
|
-
required: n.required
|
|
770
|
+
onFocus: t[2] || (t[2] = (...l) => o.handleInputFocused && o.handleInputFocused(...l)),
|
|
771
|
+
onBlur: t[3] || (t[3] = (...l) => o.handleInputBlurred && o.handleInputBlurred(...l)),
|
|
772
|
+
required: n.required,
|
|
773
|
+
"data-1p-ignore": ""
|
|
768
774
|
}, null, 42, Ht), [
|
|
769
775
|
[qe, e.searchText],
|
|
770
|
-
[
|
|
776
|
+
[r, o.effectiveDisabled]
|
|
771
777
|
]),
|
|
772
778
|
e.shouldDisplayOptions ? (d(), h("div", Dt, [
|
|
773
779
|
e.isLoaded ? (d(), h(U, { key: 1 }, [
|
|
774
|
-
(d(!0), h(U, null, J(o.effectiveOptions, (
|
|
775
|
-
key: String(
|
|
780
|
+
(d(!0), h(U, null, J(o.effectiveOptions, (l) => (d(), h("div", {
|
|
781
|
+
key: String(l.key),
|
|
776
782
|
class: k(["option", {
|
|
777
|
-
highlighted: e.highlightedOptionKey ===
|
|
783
|
+
highlighted: e.highlightedOptionKey === l.key
|
|
778
784
|
}]),
|
|
779
|
-
onMousemove: (a) => o.handleOptionHover(
|
|
780
|
-
onMousedown: (a) => o.selectOption(
|
|
785
|
+
onMousemove: (a) => o.handleOptionHover(l),
|
|
786
|
+
onMousedown: (a) => o.selectOption(l)
|
|
781
787
|
}, [
|
|
782
788
|
w("div", {
|
|
783
789
|
class: "title",
|
|
784
|
-
innerHTML:
|
|
790
|
+
innerHTML: l.title
|
|
785
791
|
}, null, 8, Bt),
|
|
786
|
-
|
|
792
|
+
l.subtitle ? (d(), h("div", {
|
|
787
793
|
key: 0,
|
|
788
794
|
class: "subtitle",
|
|
789
|
-
innerHTML:
|
|
795
|
+
innerHTML: l.subtitle
|
|
790
796
|
}, null, 8, Vt)) : b("", !0)
|
|
791
797
|
], 42, $t))), 128)),
|
|
792
|
-
!o.effectiveOptions.length && e.searchText ? (d(), h("div", Ft,
|
|
798
|
+
!o.effectiveOptions.length && e.searchText ? (d(), h("div", Ft, x(o.effectiveNoResultsText), 1)) : b("", !0)
|
|
793
799
|
], 64)) : (d(), h("div", At, "Loading..."))
|
|
794
800
|
], 512)) : b("", !0)
|
|
795
801
|
], 2);
|
|
796
802
|
}
|
|
797
|
-
const
|
|
803
|
+
const Rt = /* @__PURE__ */ xe(It, [["render", _t]]), jn = /* @__PURE__ */ C({
|
|
798
804
|
__name: "ez-smart-select",
|
|
799
805
|
props: {
|
|
800
806
|
modelValue: {},
|
|
@@ -805,36 +811,36 @@ const Nt = /* @__PURE__ */ Ce(It, [["render", _t]]), jn = /* @__PURE__ */ x({
|
|
|
805
811
|
},
|
|
806
812
|
emits: ["update:modelValue"],
|
|
807
813
|
setup(e, { emit: t }) {
|
|
808
|
-
const n = e, i = _(() => Array.isArray(n.options) ? n.options.map((
|
|
809
|
-
value:
|
|
814
|
+
const n = e, i = _(() => Array.isArray(n.options) ? n.options.map((l) => ({ value: l, label: l })) : Object.entries(n.options).map(([l, a]) => ({
|
|
815
|
+
value: l,
|
|
810
816
|
label: a
|
|
811
|
-
}))), s = _(() => n.formatter ? (
|
|
817
|
+
}))), s = _(() => n.formatter ? (l) => {
|
|
812
818
|
var a;
|
|
813
|
-
return (a = n.formatter) == null ? void 0 : a.call(n,
|
|
814
|
-
} : (
|
|
819
|
+
return (a = n.formatter) == null ? void 0 : a.call(n, l.label);
|
|
820
|
+
} : (l) => l.label), o = t, r = O(i.value.find((l) => l.value === n.modelValue) ?? null);
|
|
815
821
|
return ce(
|
|
816
822
|
() => n.modelValue,
|
|
817
|
-
(
|
|
818
|
-
|
|
823
|
+
(l) => {
|
|
824
|
+
r.value = i.value.find((a) => a.value === l) ?? null;
|
|
819
825
|
}
|
|
820
|
-
), ce(
|
|
826
|
+
), ce(r, (l) => {
|
|
821
827
|
var a;
|
|
822
|
-
o("update:modelValue",
|
|
823
|
-
}), (
|
|
824
|
-
modelValue:
|
|
825
|
-
"onUpdate:modelValue": a[0] || (a[0] = (p) =>
|
|
828
|
+
o("update:modelValue", l ? ((a = i.value.find((p) => Ce(p, l))) == null ? void 0 : a.value) ?? null : null);
|
|
829
|
+
}), (l, a) => (d(), be(Rt, {
|
|
830
|
+
modelValue: r.value,
|
|
831
|
+
"onUpdate:modelValue": a[0] || (a[0] = (p) => r.value = p),
|
|
826
832
|
options: i.value,
|
|
827
833
|
formatter: s.value,
|
|
828
|
-
"null-title":
|
|
834
|
+
"null-title": l.nullTitle
|
|
829
835
|
}, null, 8, ["modelValue", "options", "formatter", "null-title"]));
|
|
830
836
|
}
|
|
831
|
-
}),
|
|
837
|
+
}), Nt = { class: "content" }, Kt = { class: "message" }, jt = {
|
|
832
838
|
key: 0,
|
|
833
839
|
class: "close"
|
|
834
840
|
}, Ut = {
|
|
835
841
|
key: 0,
|
|
836
842
|
class: "progress-bar"
|
|
837
|
-
}, Wt = /* @__PURE__ */
|
|
843
|
+
}, Wt = /* @__PURE__ */ C({
|
|
838
844
|
__name: "toast",
|
|
839
845
|
props: {
|
|
840
846
|
message: {},
|
|
@@ -861,8 +867,8 @@ const Nt = /* @__PURE__ */ Ce(It, [["render", _t]]), jn = /* @__PURE__ */ x({
|
|
|
861
867
|
class: k(["vf-toast", s.className]),
|
|
862
868
|
onClick: te(n, ["stop"])
|
|
863
869
|
}, [
|
|
864
|
-
w("div",
|
|
865
|
-
w("div", Kt,
|
|
870
|
+
w("div", Nt, [
|
|
871
|
+
w("div", Kt, x(s.message), 1),
|
|
866
872
|
s.disableClose ? b("", !0) : (d(), h("div", jt, "x"))
|
|
867
873
|
]),
|
|
868
874
|
s.durationSecs !== null ? (d(), h("div", Ut, [
|
|
@@ -896,7 +902,7 @@ function Xt(e) {
|
|
|
896
902
|
return e === null || typeof e == "string" && !/^\d+$/.test(e) ? e : nn(Number(e));
|
|
897
903
|
}
|
|
898
904
|
function Yt(e) {
|
|
899
|
-
return e &&
|
|
905
|
+
return e && xt(e);
|
|
900
906
|
}
|
|
901
907
|
function Zt(e) {
|
|
902
908
|
return e ? Ye(e) : null;
|
|
@@ -908,7 +914,7 @@ function Qt(e) {
|
|
|
908
914
|
return e ? e.toUpperCase() : null;
|
|
909
915
|
}
|
|
910
916
|
function Jt(e) {
|
|
911
|
-
return e ?
|
|
917
|
+
return e ? Ct(e) : null;
|
|
912
918
|
}
|
|
913
919
|
function en(e, t = 1) {
|
|
914
920
|
return Lt(e, t);
|
|
@@ -947,7 +953,7 @@ function qn(e, t) {
|
|
|
947
953
|
const u = document.createElement("div");
|
|
948
954
|
u.classList.add("item"), u.style.userSelect = "none", u.innerText = f.title, i.appendChild(u), f.class && u.classList.add(f.class), f.shouldConfirm ? u.addEventListener("click", (c) => v(c, u, f.handler)) : u.addEventListener("click", () => f.handler());
|
|
949
955
|
});
|
|
950
|
-
const o = window.innerWidth - e.clientX,
|
|
956
|
+
const o = window.innerWidth - e.clientX, r = window.innerHeight - e.clientY, l = i.offsetHeight, a = i.offsetWidth, p = o < a ? e.clientX - a - 1 : e.clientX + 1, g = r < l ? e.clientY - l - 1 : e.clientY + 1;
|
|
951
957
|
i.style.left = p + "px", i.style.top = g + "px", setTimeout(() => {
|
|
952
958
|
i.style.width = i.offsetWidth + "px";
|
|
953
959
|
}, 50);
|
|
@@ -989,7 +995,7 @@ function Zn(e) {
|
|
|
989
995
|
}
|
|
990
996
|
});
|
|
991
997
|
}
|
|
992
|
-
const
|
|
998
|
+
const le = Symbol("HookState");
|
|
993
999
|
function Gn(e, t) {
|
|
994
1000
|
const n = t ?? ee();
|
|
995
1001
|
L(() => sn(n, e), n), ke(() => on(n), n), Se(() => pe(n), n), ne(() => pe(n), n);
|
|
@@ -1000,16 +1006,16 @@ function sn(e, t) {
|
|
|
1000
1006
|
const i = De(e.vnode.el);
|
|
1001
1007
|
i ? n.ancestor = new V(i, t.ancestorScrolledToBottom) : console.warn("[VueFoundation] No scollable ancestor found for component:", e);
|
|
1002
1008
|
}
|
|
1003
|
-
t.windowScrolledToBottom && (n.window = new V(window, t.windowScrolledToBottom)), e[
|
|
1009
|
+
t.windowScrolledToBottom && (n.window = new V(window, t.windowScrolledToBottom)), e[le] = n;
|
|
1004
1010
|
}
|
|
1005
1011
|
function on(e) {
|
|
1006
1012
|
var n, i, s;
|
|
1007
|
-
const t = e[
|
|
1013
|
+
const t = e[le];
|
|
1008
1014
|
(n = t == null ? void 0 : t.el) == null || n.install(), (i = t == null ? void 0 : t.ancestor) == null || i.install(), (s = t == null ? void 0 : t.window) == null || s.install();
|
|
1009
1015
|
}
|
|
1010
1016
|
function pe(e) {
|
|
1011
1017
|
var n, i, s;
|
|
1012
|
-
const t = e[
|
|
1018
|
+
const t = e[le];
|
|
1013
1019
|
(n = t == null ? void 0 : t.el) == null || n.uninstall(), (i = t == null ? void 0 : t.ancestor) == null || i.uninstall(), (s = t == null ? void 0 : t.window) == null || s.uninstall();
|
|
1014
1020
|
}
|
|
1015
1021
|
const Z = ["auto", "scroll"];
|
|
@@ -1039,7 +1045,7 @@ class V {
|
|
|
1039
1045
|
function Qn(e) {
|
|
1040
1046
|
L(() => window.addEventListener("resize", e)), ke(() => window.addEventListener("resize", e)), Se(() => window.removeEventListener("resize", e)), ne(() => window.removeEventListener("resize", e));
|
|
1041
1047
|
}
|
|
1042
|
-
const
|
|
1048
|
+
const ln = {
|
|
1043
1049
|
mounted: ve,
|
|
1044
1050
|
updated: ve
|
|
1045
1051
|
}, me = Symbol("HasAutoFocused");
|
|
@@ -1050,13 +1056,13 @@ function ve(e, t) {
|
|
|
1050
1056
|
const n = ["BUTTON", "INPUT", "TEXTAREA", "SELECT"].indexOf(e.tagName) > -1 ? e : e.querySelectorAll("input")[0];
|
|
1051
1057
|
setTimeout(() => n.focus(), 10);
|
|
1052
1058
|
}
|
|
1053
|
-
const
|
|
1059
|
+
const rn = {
|
|
1054
1060
|
mounted: an
|
|
1055
1061
|
}, A = Symbol("ConfirmState");
|
|
1056
1062
|
function an(e, t) {
|
|
1057
1063
|
e.addEventListener("click", (n) => {
|
|
1058
|
-
var
|
|
1059
|
-
const i = Date.now(), s = ((
|
|
1064
|
+
var r, l;
|
|
1065
|
+
const i = Date.now(), s = ((r = t.value) == null ? void 0 : r.text) !== void 0 ? t.value.text : "Confirm";
|
|
1060
1066
|
if (e[A]) {
|
|
1061
1067
|
if (i - e[A].initTime < 300)
|
|
1062
1068
|
return;
|
|
@@ -1072,7 +1078,7 @@ function an(e, t) {
|
|
|
1072
1078
|
s && (e.innerHTML = o.preconfirmHtml), (a = t.value) != null && a.class && e.classList.remove(t.value.class), e.blur(), e.removeEventListener("mouseout", o.resetHandler), delete e[A];
|
|
1073
1079
|
}
|
|
1074
1080
|
};
|
|
1075
|
-
e[A] = o, s && (e.innerHTML = s), (
|
|
1081
|
+
e[A] = o, s && (e.innerHTML = s), (l = t.value) != null && l.class && e.classList.add(t.value.class), e.addEventListener("mouseout", o.resetHandler);
|
|
1076
1082
|
});
|
|
1077
1083
|
}
|
|
1078
1084
|
const cn = {
|
|
@@ -1100,14 +1106,14 @@ function hn(e, t) {
|
|
|
1100
1106
|
let n = "";
|
|
1101
1107
|
const i = t.value.replace(/ /g, "T").replace(/\.\d+Z$/, "Z"), s = e.attributes.getNamedItem("local") !== null ? i.replace(/Z$/, "") : i.replace(/(Z|\+00:00)?$/, "Z"), o = new Date(s);
|
|
1102
1108
|
e.attributes.getNamedItem("display-utc") !== null && o.setMinutes(o.getMinutes() - o.getTimezoneOffset());
|
|
1103
|
-
let
|
|
1104
|
-
if (!
|
|
1109
|
+
let r = (p = e.attributes.getNamedItem("format")) == null ? void 0 : p.value;
|
|
1110
|
+
if (!r && e.attributes.getNamedItem("relative-date") !== null) {
|
|
1105
1111
|
const g = /* @__PURE__ */ new Date();
|
|
1106
|
-
g.getFullYear() == o.getFullYear() && g.getMonth() == o.getMonth() && g.getDate() == o.getDate() && (n = "at",
|
|
1112
|
+
g.getFullYear() == o.getFullYear() && g.getMonth() == o.getMonth() && g.getDate() == o.getDate() && (n = "at", r = "HH:mm");
|
|
1107
1113
|
}
|
|
1108
|
-
|
|
1109
|
-
let
|
|
1110
|
-
return n && (
|
|
1114
|
+
r || (e.attributes.getNamedItem("date-only") !== null ? r = M.defaultDateFormat : r = M.defaultDateTimeFormat);
|
|
1115
|
+
let l = G(o, r);
|
|
1116
|
+
return n && (l = n + " " + l), l;
|
|
1111
1117
|
}
|
|
1112
1118
|
const fn = {
|
|
1113
1119
|
beforeMount: ge,
|
|
@@ -1124,29 +1130,29 @@ const mn = {
|
|
|
1124
1130
|
beforeMount: Ee,
|
|
1125
1131
|
updated: Ee,
|
|
1126
1132
|
unmounted: $e
|
|
1127
|
-
},
|
|
1133
|
+
}, R = Symbol("HasAutoFocused"), re = [];
|
|
1128
1134
|
function vn() {
|
|
1129
|
-
|
|
1135
|
+
re.forEach(Ae);
|
|
1130
1136
|
}
|
|
1131
1137
|
setInterval(vn, 1e3);
|
|
1132
1138
|
function Ee(e, t) {
|
|
1133
|
-
var
|
|
1139
|
+
var r;
|
|
1134
1140
|
if (t.value == t.oldValue)
|
|
1135
1141
|
return;
|
|
1136
1142
|
if (!t.value)
|
|
1137
1143
|
return $e(e);
|
|
1138
|
-
const n = new Date(t.value), i = (
|
|
1139
|
-
e[
|
|
1144
|
+
const n = new Date(t.value), i = (r = e.attributes.getNamedItem("base-time")) == null ? void 0 : r.value, s = n.getTime() - (i ? new Date(i).getTime() - t.value * 1e3 : 0), o = e.getAttribute("no-seconds") === null;
|
|
1145
|
+
e[R] || re.push(e), e[R] = {
|
|
1140
1146
|
startTs: s,
|
|
1141
1147
|
includeSeconds: o
|
|
1142
1148
|
}, Ae(e);
|
|
1143
1149
|
}
|
|
1144
1150
|
function Ae(e) {
|
|
1145
|
-
const t = e[
|
|
1151
|
+
const t = e[R], n = Math.round((Date.now() - t.startTs) / 1e3);
|
|
1146
1152
|
e.innerText = yn(n, t.includeSeconds);
|
|
1147
1153
|
}
|
|
1148
1154
|
function $e(e) {
|
|
1149
|
-
e[
|
|
1155
|
+
e[R] && (Qe(re, e), delete e[R]), e.innerText = "-";
|
|
1150
1156
|
}
|
|
1151
1157
|
function yn(e, t) {
|
|
1152
1158
|
const n = [], i = Math.floor(e / 86400);
|
|
@@ -1233,8 +1239,8 @@ class wn {
|
|
|
1233
1239
|
}
|
|
1234
1240
|
handleMouseMove(t) {
|
|
1235
1241
|
const n = this.tipEl.offsetWidth, i = this.tipEl.offsetHeight, s = window.innerWidth, o = window.innerHeight;
|
|
1236
|
-
let
|
|
1237
|
-
|
|
1242
|
+
let r = t.pageX + 10, l = t.pageY + 20;
|
|
1243
|
+
r + n > s && (r = t.pageX - 5 - n), l + i > o && (l = t.pageY - 5 - i), this.tipEl.style.left = r + "px", this.tipEl.style.top = l + "px", this.lastMoveEvt = t;
|
|
1238
1244
|
}
|
|
1239
1245
|
checkMoveEvent() {
|
|
1240
1246
|
var t;
|
|
@@ -1245,7 +1251,7 @@ class wn {
|
|
|
1245
1251
|
}
|
|
1246
1252
|
}
|
|
1247
1253
|
function On(e) {
|
|
1248
|
-
e.directive("autofocus",
|
|
1254
|
+
e.directive("autofocus", ln), e.directive("confirm-button", rn), e.directive("date-input", cn), e.directive("datetime", un), e.directive("disabled", fn), e.directive("duration", mn), e.directive("infinite-scroll", gn), e.directive("readonly", En), e.directive("tooltip", Tn);
|
|
1249
1255
|
}
|
|
1250
1256
|
function Jn(e) {
|
|
1251
1257
|
On(e);
|
|
@@ -1257,12 +1263,12 @@ export {
|
|
|
1257
1263
|
X as VfAlertModal,
|
|
1258
1264
|
jn as VfEzSmartSelect,
|
|
1259
1265
|
gt as VfModal,
|
|
1260
|
-
|
|
1266
|
+
Rt as VfSmartSelect,
|
|
1261
1267
|
Xn as cloneProp,
|
|
1262
1268
|
Bn as configureVf,
|
|
1263
1269
|
Wn as createFilters,
|
|
1264
1270
|
ie as createOverlayInjection,
|
|
1265
|
-
|
|
1271
|
+
Ct as desnakeCase,
|
|
1266
1272
|
dt as dismissOverlayInjectionById,
|
|
1267
1273
|
Hn as dismissOverlayInjectionByInstance,
|
|
1268
1274
|
Le as dismissOverlayInjectionByInternalInstance,
|
|
@@ -1270,7 +1276,7 @@ export {
|
|
|
1270
1276
|
ni as escapeHtml,
|
|
1271
1277
|
ut as formatError,
|
|
1272
1278
|
nn as formatNumber,
|
|
1273
|
-
|
|
1279
|
+
xt as formatPhone,
|
|
1274
1280
|
Lt as formatUSCurrency,
|
|
1275
1281
|
Fn as handleError,
|
|
1276
1282
|
Vn as handleErrorAndAlert,
|
|
@@ -1279,7 +1285,7 @@ export {
|
|
|
1279
1285
|
_n as maskComponent,
|
|
1280
1286
|
ht as maskEl,
|
|
1281
1287
|
ft as maskForm,
|
|
1282
|
-
|
|
1288
|
+
Nn as nl2br,
|
|
1283
1289
|
Yn as nullifyEmptyInputs,
|
|
1284
1290
|
se as presentOverlay,
|
|
1285
1291
|
P as removeOverlayInjection,
|
|
@@ -1293,7 +1299,7 @@ export {
|
|
|
1293
1299
|
tn as sleep,
|
|
1294
1300
|
zn as sleepSecs,
|
|
1295
1301
|
oe as toError,
|
|
1296
|
-
|
|
1302
|
+
Rn as unmaskComponent,
|
|
1297
1303
|
Me as unmaskEl,
|
|
1298
1304
|
Ie as unmaskForm,
|
|
1299
1305
|
Gn as useInfiniteScroll,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signal24/vue-foundation",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.14.0",
|
|
5
5
|
"description": "Common components, directives, and helpers for Vue 3 apps",
|
|
6
6
|
"module": "./dist/vue-foundation.es.js",
|
|
7
7
|
"exports": {
|
|
@@ -52,16 +52,16 @@
|
|
|
52
52
|
"@types/node": "^20.10.5",
|
|
53
53
|
"@types/uuid": "^9.0.7",
|
|
54
54
|
"@vitejs/plugin-vue": "^5.0.0",
|
|
55
|
-
"@vue/eslint-config-prettier": "^
|
|
56
|
-
"@vue/eslint-config-typescript": "^
|
|
55
|
+
"@vue/eslint-config-prettier": "^9.0.0",
|
|
56
|
+
"@vue/eslint-config-typescript": "^13.0.0",
|
|
57
57
|
"@vue/test-utils": "^2.4.3",
|
|
58
58
|
"@vue/tsconfig": "^0.5.1",
|
|
59
59
|
"cypress": "^13.6.2",
|
|
60
60
|
"date-fns": "^3.0.6",
|
|
61
61
|
"eslint": "^8.56.0",
|
|
62
|
-
"eslint-plugin-cypress": "^
|
|
63
|
-
"eslint-plugin-simple-import-sort": "^
|
|
64
|
-
"eslint-plugin-unused-imports": "^
|
|
62
|
+
"eslint-plugin-cypress": "^3.3.0",
|
|
63
|
+
"eslint-plugin-simple-import-sort": "^12.1.0",
|
|
64
|
+
"eslint-plugin-unused-imports": "^4.0.0",
|
|
65
65
|
"eslint-plugin-vue": "^9.19.2",
|
|
66
66
|
"jsdom": "^23.0.1",
|
|
67
67
|
"lodash": "^4.17.21",
|
|
@@ -19,21 +19,22 @@ import {
|
|
|
19
19
|
import OverlayAnchor from './overlay-anchor.vue';
|
|
20
20
|
import type { OverlayAnchorOptions } from './overlay-types';
|
|
21
21
|
|
|
22
|
-
interface OverlayOptions {
|
|
22
|
+
interface OverlayOptions<C extends OverlayComponent, R extends ComponentReturn<C>> {
|
|
23
23
|
anchor?: OverlayAnchorOptions;
|
|
24
|
+
onCallback?: (result: R) => void | Promise<boolean>;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export interface OverlayInjection<C extends OverlayComponent
|
|
27
|
+
export interface OverlayInjection<C extends OverlayComponent, R extends ComponentReturn<C>> {
|
|
27
28
|
id: string;
|
|
28
29
|
component: OverlayComponentUnwrapped<C>;
|
|
29
30
|
props: OverlayComponentProps<C>;
|
|
30
|
-
options: OverlayOptions
|
|
31
|
+
options: OverlayOptions<C, R>;
|
|
31
32
|
vnode: VNode;
|
|
32
33
|
wrapperVnode?: VNode;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
let overlayCount = 0;
|
|
36
|
-
const OverlayInjections: OverlayInjection<any>[] = reactive([]);
|
|
37
|
+
const OverlayInjections: OverlayInjection<any, any>[] = reactive([]);
|
|
37
38
|
|
|
38
39
|
export const OverlayContainer = defineComponent({
|
|
39
40
|
setup() {
|
|
@@ -92,11 +93,11 @@ type ComponentReturn<M extends OverlayComponent> = OverlayComponentProps<M> exte
|
|
|
92
93
|
|
|
93
94
|
export type AnyComponentPublicInstance = { $?: ComponentInternalInstance };
|
|
94
95
|
|
|
95
|
-
export function createOverlayInjection<C extends OverlayComponent
|
|
96
|
+
export function createOverlayInjection<C extends OverlayComponent, R extends ComponentReturn<C>>(
|
|
96
97
|
component: C,
|
|
97
98
|
props: OverlayComponentProps<C>,
|
|
98
|
-
options?: OverlayOptions
|
|
99
|
-
): OverlayInjection<C> {
|
|
99
|
+
options?: OverlayOptions<C, R>
|
|
100
|
+
): OverlayInjection<C, R> {
|
|
100
101
|
// create or reconfigure the existing overlay target
|
|
101
102
|
// re-injecting every time keeps the overlay container at the very end of the DOM
|
|
102
103
|
const targetEl = document.getElementById('vf-overlay-target') ?? document.createElement('div');
|
|
@@ -110,7 +111,7 @@ export function createOverlayInjection<C extends OverlayComponent>(
|
|
|
110
111
|
const wrapperVnode = options?.anchor ? h(OverlayAnchor, { overlayId, anchor: options.anchor }, () => [vnode]) : undefined;
|
|
111
112
|
|
|
112
113
|
// todo: dunno what's going on with types here
|
|
113
|
-
const injection: OverlayInjection<C> = {
|
|
114
|
+
const injection: OverlayInjection<C, R> = {
|
|
114
115
|
id: overlayId,
|
|
115
116
|
component: rawComponent as any,
|
|
116
117
|
props,
|
|
@@ -152,7 +153,7 @@ export function dismissOverlayInjectionById(id: string) {
|
|
|
152
153
|
return false;
|
|
153
154
|
}
|
|
154
155
|
|
|
155
|
-
export function removeOverlayInjection(injection: OverlayInjection<any>) {
|
|
156
|
+
export function removeOverlayInjection(injection: OverlayInjection<any, any>) {
|
|
156
157
|
const index = OverlayInjections.indexOf(injection);
|
|
157
158
|
if (index >= 0) {
|
|
158
159
|
OverlayInjections.splice(index, 1);
|
|
@@ -162,11 +163,22 @@ export function removeOverlayInjection(injection: OverlayInjection<any>) {
|
|
|
162
163
|
export async function presentOverlay<C extends OverlayComponent, R extends ComponentReturn<C>>(
|
|
163
164
|
component: C,
|
|
164
165
|
props: Omit<OverlayComponentProps<C>, 'callback'>,
|
|
165
|
-
options?: OverlayOptions
|
|
166
|
+
options?: OverlayOptions<C, R>
|
|
166
167
|
): Promise<R | undefined> {
|
|
167
168
|
return new Promise<R>(resolve => {
|
|
168
|
-
let overlayInjection: OverlayInjection<C> | null = null;
|
|
169
|
-
const callback = (result: R) => {
|
|
169
|
+
let overlayInjection: OverlayInjection<C, R> | null = null;
|
|
170
|
+
const callback = async (result: R) => {
|
|
171
|
+
if (options?.onCallback) {
|
|
172
|
+
const hookResult = options.onCallback(result);
|
|
173
|
+
if (typeof hookResult === 'object' && 'then' in hookResult && typeof hookResult.then === 'function') {
|
|
174
|
+
// ^ hack for ZoneAwarePromise
|
|
175
|
+
const hookResultValue = await hookResult;
|
|
176
|
+
if (hookResultValue === false) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
170
182
|
removeOverlayInjection(overlayInjection!);
|
|
171
183
|
resolve(result);
|
|
172
184
|
};
|
|
@@ -2,7 +2,7 @@ import { createOverlayInjection, type OverlayInjection, removeOverlayInjection }
|
|
|
2
2
|
import Toast, { type IToastOptions } from './toast.vue';
|
|
3
3
|
|
|
4
4
|
export function showToast(options: IToastOptions) {
|
|
5
|
-
const injection: OverlayInjection<typeof Toast> = createOverlayInjection(Toast, {
|
|
5
|
+
const injection: OverlayInjection<typeof Toast, unknown> = createOverlayInjection(Toast, {
|
|
6
6
|
...options,
|
|
7
7
|
callback: () => removeOverlayInjection(injection)
|
|
8
8
|
});
|