@signal24/vue-foundation 4.13.9 → 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>(component: C, props: OverlayComponentProps<C>, options?: OverlayOptions): OverlayInjection<C>;
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 x, defineProps as _e, defineEmits as Ne, ref as O, computed as _, openBlock as d, createElementBlock as h, createElementVNode as w, toDisplayString as C, withDirectives as j, createCommentVNode as b, Fragment as U, renderList as J, vModelSelect as Re, 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 xe, upperFirst as Ye, startCase as Ze, cloneDeep as Ge, remove as Qe } from "lodash";
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 = x({
10
+ const nt = C({
11
11
  setup() {
12
12
  const e = _e();
13
- Ne(["update:modelValue"]);
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
- }), Ce = (e, t) => {
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 rt(e, t, n, i, s, o) {
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] = (l) => e.selectedItem = l)
51
+ "onUpdate:modelValue": t[0] || (t[0] = (r) => e.selectedItem = r)
52
52
  }, [
53
- e.props.nullText ? (d(), h("option", st, C(e.props.nullText), 1)) : b("", !0),
54
- (d(!0), h(U, null, J(e.renderOptions, (l, r) => {
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: r,
58
- value: (a = e.options) == null ? void 0 : a[r]
59
- }, C(l), 9, ot);
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
- [Re, e.selectedItem]
62
+ [Ne, e.selectedItem]
63
63
  ]) : (d(), h("select", it, [
64
- w("option", null, C(e.props.loadingText || "Loading..."), 1)
64
+ w("option", null, x(e.props.loadingText || "Loading..."), 1)
65
65
  ]));
66
66
  }
67
- const Mn = /* @__PURE__ */ Ce(nt, [["render", rt]]), lt = /* @__PURE__ */ x({
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(l);
76
- function l() {
75
+ L(r);
76
+ function r() {
77
77
  if (!o)
78
78
  return;
79
- const p = o.vnode.el, { styles: g, classes: m } = r(p, n);
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 r(p, g) {
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 = x({
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), l = W(o, t), r = n != null && n.anchor ? W(lt, { overlayId: s, anchor: n.anchor }, () => [l]) : void 0, a = {
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: l,
142
- wrapperVnode: r
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 l = { ...t, callback: (r) => {
170
- P(s), i(r);
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, l, n);
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 Nn(e) {
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 r = [...i.querySelectorAll("input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])")];
268
- return r.forEach((a) => a.setAttribute("disabled", "disabled")), i[Q] = {
269
- disabledElements: r,
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__ */ x({
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(), l = O(!1), r = _(() => ze([i.class, l.value && "hidden"]));
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 l.value = !0, () => u();
336
+ return r.value = !0, () => u();
332
337
  }
333
338
  function u() {
334
- l.value = !1;
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", r.value]),
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__ */ x({
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, C(i.title), 1)
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 R;
440
+ let N;
436
441
  const wt = new Uint8Array(16);
437
442
  function Ot() {
438
- if (!R && (R = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !R))
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 R(wt);
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 Rn(e) {
469
+ function Nn(e) {
465
470
  return e.replace(/\n/g, "<br>");
466
471
  }
467
- function xt(e) {
472
+ function Ct(e) {
468
473
  return e.replace(/_/g, " ");
469
474
  }
470
- function Ct(e) {
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 r, a;
558
- const n = this.formatter(e), i = (r = this.subtitleFormatter) == null ? void 0 : r.call(this, e), s = n ? n.trim().toLowerCase() : "", o = i ? i.trim().toLowerCase() : "", l = [];
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] && l.push(String(e[p]).toLowerCase());
561
- }) : (l.push(s), o && l.push(o)), {
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: l.join(""),
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) : xe, i = this.effectiveOptions.find((s) => n(s.ref, e));
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,51 +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 l = Oe("disabled");
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] = (r) => e.searchText = r),
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] = (...r) => o.handleKeyDown && o.handleKeyDown(...r)),
768
+ onKeydown: t[1] || (t[1] = (...l) => o.handleKeyDown && o.handleKeyDown(...l)),
764
769
  placeholder: o.effectivePlaceholder,
765
- onFocus: t[2] || (t[2] = (...r) => o.handleInputFocused && o.handleInputFocused(...r)),
766
- onBlur: t[3] || (t[3] = (...r) => o.handleInputBlurred && o.handleInputBlurred(...r)),
770
+ onFocus: t[2] || (t[2] = (...l) => o.handleInputFocused && o.handleInputFocused(...l)),
771
+ onBlur: t[3] || (t[3] = (...l) => o.handleInputBlurred && o.handleInputBlurred(...l)),
767
772
  required: n.required,
768
773
  "data-1p-ignore": ""
769
774
  }, null, 42, Ht), [
770
775
  [qe, e.searchText],
771
- [l, o.effectiveDisabled]
776
+ [r, o.effectiveDisabled]
772
777
  ]),
773
778
  e.shouldDisplayOptions ? (d(), h("div", Dt, [
774
779
  e.isLoaded ? (d(), h(U, { key: 1 }, [
775
- (d(!0), h(U, null, J(o.effectiveOptions, (r) => (d(), h("div", {
776
- key: String(r.key),
780
+ (d(!0), h(U, null, J(o.effectiveOptions, (l) => (d(), h("div", {
781
+ key: String(l.key),
777
782
  class: k(["option", {
778
- highlighted: e.highlightedOptionKey === r.key
783
+ highlighted: e.highlightedOptionKey === l.key
779
784
  }]),
780
- onMousemove: (a) => o.handleOptionHover(r),
781
- onMousedown: (a) => o.selectOption(r)
785
+ onMousemove: (a) => o.handleOptionHover(l),
786
+ onMousedown: (a) => o.selectOption(l)
782
787
  }, [
783
788
  w("div", {
784
789
  class: "title",
785
- innerHTML: r.title
790
+ innerHTML: l.title
786
791
  }, null, 8, Bt),
787
- r.subtitle ? (d(), h("div", {
792
+ l.subtitle ? (d(), h("div", {
788
793
  key: 0,
789
794
  class: "subtitle",
790
- innerHTML: r.subtitle
795
+ innerHTML: l.subtitle
791
796
  }, null, 8, Vt)) : b("", !0)
792
797
  ], 42, $t))), 128)),
793
- !o.effectiveOptions.length && e.searchText ? (d(), h("div", Ft, C(o.effectiveNoResultsText), 1)) : b("", !0)
798
+ !o.effectiveOptions.length && e.searchText ? (d(), h("div", Ft, x(o.effectiveNoResultsText), 1)) : b("", !0)
794
799
  ], 64)) : (d(), h("div", At, "Loading..."))
795
800
  ], 512)) : b("", !0)
796
801
  ], 2);
797
802
  }
798
- const Nt = /* @__PURE__ */ Ce(It, [["render", _t]]), jn = /* @__PURE__ */ x({
803
+ const Rt = /* @__PURE__ */ xe(It, [["render", _t]]), jn = /* @__PURE__ */ C({
799
804
  __name: "ez-smart-select",
800
805
  props: {
801
806
  modelValue: {},
@@ -806,36 +811,36 @@ const Nt = /* @__PURE__ */ Ce(It, [["render", _t]]), jn = /* @__PURE__ */ x({
806
811
  },
807
812
  emits: ["update:modelValue"],
808
813
  setup(e, { emit: t }) {
809
- const n = e, i = _(() => Array.isArray(n.options) ? n.options.map((r) => ({ value: r, label: r })) : Object.entries(n.options).map(([r, a]) => ({
810
- value: r,
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,
811
816
  label: a
812
- }))), s = _(() => n.formatter ? (r) => {
817
+ }))), s = _(() => n.formatter ? (l) => {
813
818
  var a;
814
- return (a = n.formatter) == null ? void 0 : a.call(n, r.label);
815
- } : (r) => r.label), o = t, l = O(i.value.find((r) => r.value === n.modelValue) ?? null);
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);
816
821
  return ce(
817
822
  () => n.modelValue,
818
- (r) => {
819
- l.value = i.value.find((a) => a.value === r) ?? null;
823
+ (l) => {
824
+ r.value = i.value.find((a) => a.value === l) ?? null;
820
825
  }
821
- ), ce(l, (r) => {
826
+ ), ce(r, (l) => {
822
827
  var a;
823
- o("update:modelValue", r ? ((a = i.value.find((p) => xe(p, r))) == null ? void 0 : a.value) ?? null : null);
824
- }), (r, a) => (d(), be(Nt, {
825
- modelValue: l.value,
826
- "onUpdate:modelValue": a[0] || (a[0] = (p) => l.value = 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),
827
832
  options: i.value,
828
833
  formatter: s.value,
829
- "null-title": r.nullTitle
834
+ "null-title": l.nullTitle
830
835
  }, null, 8, ["modelValue", "options", "formatter", "null-title"]));
831
836
  }
832
- }), Rt = { class: "content" }, Kt = { class: "message" }, jt = {
837
+ }), Nt = { class: "content" }, Kt = { class: "message" }, jt = {
833
838
  key: 0,
834
839
  class: "close"
835
840
  }, Ut = {
836
841
  key: 0,
837
842
  class: "progress-bar"
838
- }, Wt = /* @__PURE__ */ x({
843
+ }, Wt = /* @__PURE__ */ C({
839
844
  __name: "toast",
840
845
  props: {
841
846
  message: {},
@@ -862,8 +867,8 @@ const Nt = /* @__PURE__ */ Ce(It, [["render", _t]]), jn = /* @__PURE__ */ x({
862
867
  class: k(["vf-toast", s.className]),
863
868
  onClick: te(n, ["stop"])
864
869
  }, [
865
- w("div", Rt, [
866
- w("div", Kt, C(s.message), 1),
870
+ w("div", Nt, [
871
+ w("div", Kt, x(s.message), 1),
867
872
  s.disableClose ? b("", !0) : (d(), h("div", jt, "x"))
868
873
  ]),
869
874
  s.durationSecs !== null ? (d(), h("div", Ut, [
@@ -897,7 +902,7 @@ function Xt(e) {
897
902
  return e === null || typeof e == "string" && !/^\d+$/.test(e) ? e : nn(Number(e));
898
903
  }
899
904
  function Yt(e) {
900
- return e && Ct(e);
905
+ return e && xt(e);
901
906
  }
902
907
  function Zt(e) {
903
908
  return e ? Ye(e) : null;
@@ -909,7 +914,7 @@ function Qt(e) {
909
914
  return e ? e.toUpperCase() : null;
910
915
  }
911
916
  function Jt(e) {
912
- return e ? xt(e) : null;
917
+ return e ? Ct(e) : null;
913
918
  }
914
919
  function en(e, t = 1) {
915
920
  return Lt(e, t);
@@ -948,7 +953,7 @@ function qn(e, t) {
948
953
  const u = document.createElement("div");
949
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());
950
955
  });
951
- const o = window.innerWidth - e.clientX, l = window.innerHeight - e.clientY, r = i.offsetHeight, a = i.offsetWidth, p = o < a ? e.clientX - a - 1 : e.clientX + 1, g = l < r ? e.clientY - r - 1 : e.clientY + 1;
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;
952
957
  i.style.left = p + "px", i.style.top = g + "px", setTimeout(() => {
953
958
  i.style.width = i.offsetWidth + "px";
954
959
  }, 50);
@@ -990,7 +995,7 @@ function Zn(e) {
990
995
  }
991
996
  });
992
997
  }
993
- const re = Symbol("HookState");
998
+ const le = Symbol("HookState");
994
999
  function Gn(e, t) {
995
1000
  const n = t ?? ee();
996
1001
  L(() => sn(n, e), n), ke(() => on(n), n), Se(() => pe(n), n), ne(() => pe(n), n);
@@ -1001,16 +1006,16 @@ function sn(e, t) {
1001
1006
  const i = De(e.vnode.el);
1002
1007
  i ? n.ancestor = new V(i, t.ancestorScrolledToBottom) : console.warn("[VueFoundation] No scollable ancestor found for component:", e);
1003
1008
  }
1004
- t.windowScrolledToBottom && (n.window = new V(window, t.windowScrolledToBottom)), e[re] = n;
1009
+ t.windowScrolledToBottom && (n.window = new V(window, t.windowScrolledToBottom)), e[le] = n;
1005
1010
  }
1006
1011
  function on(e) {
1007
1012
  var n, i, s;
1008
- const t = e[re];
1013
+ const t = e[le];
1009
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();
1010
1015
  }
1011
1016
  function pe(e) {
1012
1017
  var n, i, s;
1013
- const t = e[re];
1018
+ const t = e[le];
1014
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();
1015
1020
  }
1016
1021
  const Z = ["auto", "scroll"];
@@ -1040,7 +1045,7 @@ class V {
1040
1045
  function Qn(e) {
1041
1046
  L(() => window.addEventListener("resize", e)), ke(() => window.addEventListener("resize", e)), Se(() => window.removeEventListener("resize", e)), ne(() => window.removeEventListener("resize", e));
1042
1047
  }
1043
- const rn = {
1048
+ const ln = {
1044
1049
  mounted: ve,
1045
1050
  updated: ve
1046
1051
  }, me = Symbol("HasAutoFocused");
@@ -1051,13 +1056,13 @@ function ve(e, t) {
1051
1056
  const n = ["BUTTON", "INPUT", "TEXTAREA", "SELECT"].indexOf(e.tagName) > -1 ? e : e.querySelectorAll("input")[0];
1052
1057
  setTimeout(() => n.focus(), 10);
1053
1058
  }
1054
- const ln = {
1059
+ const rn = {
1055
1060
  mounted: an
1056
1061
  }, A = Symbol("ConfirmState");
1057
1062
  function an(e, t) {
1058
1063
  e.addEventListener("click", (n) => {
1059
- var l, r;
1060
- const i = Date.now(), s = ((l = t.value) == null ? void 0 : l.text) !== void 0 ? t.value.text : "Confirm";
1064
+ var r, l;
1065
+ const i = Date.now(), s = ((r = t.value) == null ? void 0 : r.text) !== void 0 ? t.value.text : "Confirm";
1061
1066
  if (e[A]) {
1062
1067
  if (i - e[A].initTime < 300)
1063
1068
  return;
@@ -1073,7 +1078,7 @@ function an(e, t) {
1073
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];
1074
1079
  }
1075
1080
  };
1076
- e[A] = o, s && (e.innerHTML = s), (r = t.value) != null && r.class && e.classList.add(t.value.class), e.addEventListener("mouseout", o.resetHandler);
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);
1077
1082
  });
1078
1083
  }
1079
1084
  const cn = {
@@ -1101,14 +1106,14 @@ function hn(e, t) {
1101
1106
  let n = "";
1102
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);
1103
1108
  e.attributes.getNamedItem("display-utc") !== null && o.setMinutes(o.getMinutes() - o.getTimezoneOffset());
1104
- let l = (p = e.attributes.getNamedItem("format")) == null ? void 0 : p.value;
1105
- if (!l && e.attributes.getNamedItem("relative-date") !== null) {
1109
+ let r = (p = e.attributes.getNamedItem("format")) == null ? void 0 : p.value;
1110
+ if (!r && e.attributes.getNamedItem("relative-date") !== null) {
1106
1111
  const g = /* @__PURE__ */ new Date();
1107
- g.getFullYear() == o.getFullYear() && g.getMonth() == o.getMonth() && g.getDate() == o.getDate() && (n = "at", l = "HH:mm");
1112
+ g.getFullYear() == o.getFullYear() && g.getMonth() == o.getMonth() && g.getDate() == o.getDate() && (n = "at", r = "HH:mm");
1108
1113
  }
1109
- l || (e.attributes.getNamedItem("date-only") !== null ? l = M.defaultDateFormat : l = M.defaultDateTimeFormat);
1110
- let r = G(o, l);
1111
- return n && (r = n + " " + r), r;
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;
1112
1117
  }
1113
1118
  const fn = {
1114
1119
  beforeMount: ge,
@@ -1125,29 +1130,29 @@ const mn = {
1125
1130
  beforeMount: Ee,
1126
1131
  updated: Ee,
1127
1132
  unmounted: $e
1128
- }, N = Symbol("HasAutoFocused"), le = [];
1133
+ }, R = Symbol("HasAutoFocused"), re = [];
1129
1134
  function vn() {
1130
- le.forEach(Ae);
1135
+ re.forEach(Ae);
1131
1136
  }
1132
1137
  setInterval(vn, 1e3);
1133
1138
  function Ee(e, t) {
1134
- var l;
1139
+ var r;
1135
1140
  if (t.value == t.oldValue)
1136
1141
  return;
1137
1142
  if (!t.value)
1138
1143
  return $e(e);
1139
- const n = new Date(t.value), i = (l = e.attributes.getNamedItem("base-time")) == null ? void 0 : l.value, s = n.getTime() - (i ? new Date(i).getTime() - t.value * 1e3 : 0), o = e.getAttribute("no-seconds") === null;
1140
- e[N] || le.push(e), e[N] = {
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] = {
1141
1146
  startTs: s,
1142
1147
  includeSeconds: o
1143
1148
  }, Ae(e);
1144
1149
  }
1145
1150
  function Ae(e) {
1146
- const t = e[N], n = Math.round((Date.now() - t.startTs) / 1e3);
1151
+ const t = e[R], n = Math.round((Date.now() - t.startTs) / 1e3);
1147
1152
  e.innerText = yn(n, t.includeSeconds);
1148
1153
  }
1149
1154
  function $e(e) {
1150
- e[N] && (Qe(le, e), delete e[N]), e.innerText = "-";
1155
+ e[R] && (Qe(re, e), delete e[R]), e.innerText = "-";
1151
1156
  }
1152
1157
  function yn(e, t) {
1153
1158
  const n = [], i = Math.floor(e / 86400);
@@ -1234,8 +1239,8 @@ class wn {
1234
1239
  }
1235
1240
  handleMouseMove(t) {
1236
1241
  const n = this.tipEl.offsetWidth, i = this.tipEl.offsetHeight, s = window.innerWidth, o = window.innerHeight;
1237
- let l = t.pageX + 10, r = t.pageY + 20;
1238
- l + n > s && (l = t.pageX - 5 - n), r + i > o && (r = t.pageY - 5 - i), this.tipEl.style.left = l + "px", this.tipEl.style.top = r + "px", this.lastMoveEvt = t;
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;
1239
1244
  }
1240
1245
  checkMoveEvent() {
1241
1246
  var t;
@@ -1246,7 +1251,7 @@ class wn {
1246
1251
  }
1247
1252
  }
1248
1253
  function On(e) {
1249
- e.directive("autofocus", rn), e.directive("confirm-button", ln), 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);
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);
1250
1255
  }
1251
1256
  function Jn(e) {
1252
1257
  On(e);
@@ -1258,12 +1263,12 @@ export {
1258
1263
  X as VfAlertModal,
1259
1264
  jn as VfEzSmartSelect,
1260
1265
  gt as VfModal,
1261
- Nt as VfSmartSelect,
1266
+ Rt as VfSmartSelect,
1262
1267
  Xn as cloneProp,
1263
1268
  Bn as configureVf,
1264
1269
  Wn as createFilters,
1265
1270
  ie as createOverlayInjection,
1266
- xt as desnakeCase,
1271
+ Ct as desnakeCase,
1267
1272
  dt as dismissOverlayInjectionById,
1268
1273
  Hn as dismissOverlayInjectionByInstance,
1269
1274
  Le as dismissOverlayInjectionByInternalInstance,
@@ -1271,7 +1276,7 @@ export {
1271
1276
  ni as escapeHtml,
1272
1277
  ut as formatError,
1273
1278
  nn as formatNumber,
1274
- Ct as formatPhone,
1279
+ xt as formatPhone,
1275
1280
  Lt as formatUSCurrency,
1276
1281
  Fn as handleError,
1277
1282
  Vn as handleErrorAndAlert,
@@ -1280,7 +1285,7 @@ export {
1280
1285
  _n as maskComponent,
1281
1286
  ht as maskEl,
1282
1287
  ft as maskForm,
1283
- Rn as nl2br,
1288
+ Nn as nl2br,
1284
1289
  Yn as nullifyEmptyInputs,
1285
1290
  se as presentOverlay,
1286
1291
  P as removeOverlayInjection,
@@ -1294,7 +1299,7 @@ export {
1294
1299
  tn as sleep,
1295
1300
  zn as sleepSecs,
1296
1301
  oe as toError,
1297
- Nn as unmaskComponent,
1302
+ Rn as unmaskComponent,
1298
1303
  Me as unmaskEl,
1299
1304
  Ie as unmaskForm,
1300
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.13.9",
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": "^8.0.0",
56
- "@vue/eslint-config-typescript": "^12.0.0",
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": "^2.15.1",
63
- "eslint-plugin-simple-import-sort": "^10.0.0",
64
- "eslint-plugin-unused-imports": "^3.0.0",
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
  });