@ulu/frontend-vue 0.6.29 → 0.6.31

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 +1 @@
1
- {"version":3,"file":"UluPopoverBase.vue.d.ts","sourceRoot":"","sources":["../../../lib/plugins/popovers/UluPopoverBase.vue"],"names":[],"mappings":"AA+BA;wBAweqB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;;6BAEtE,CAAC,EAAE,CAAC;;;AAdjC;IAzHI;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;oBA0HJ"}
1
+ {"version":3,"file":"UluPopoverBase.vue.d.ts","sourceRoot":"","sources":["../../../lib/plugins/popovers/UluPopoverBase.vue"],"names":[],"mappings":"AA+BA;wBAkfqB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;;6BAEtE,CAAC,EAAE,CAAC;;;AAdjC;IAzHI;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;;;;;;;;;;;;;;;oBA0HJ"}
@@ -1,4 +1,4 @@
1
- import { ref as x, computed as y, watch as L, nextTick as v, onUnmounted as M, createElementBlock as u, openBlock as p, withKeys as T, unref as l, normalizeStyle as O, normalizeClass as j, createElementVNode as A, createCommentVNode as k, renderSlot as C } from "vue";
1
+ import { ref as x, computed as y, watch as L, nextTick as O, onUnmounted as M, createElementBlock as u, openBlock as d, withKeys as T, unref as l, normalizeStyle as v, normalizeClass as j, createElementVNode as A, createCommentVNode as k, renderSlot as C } from "vue";
2
2
  import { useUluFloating as H } from "../../composables/useUluFloating.js";
3
3
  import { useModifiers as U } from "../../composables/useModifiers.js";
4
4
  import { wasClickOutside as $ } from "@ulu/utils/browser/dom.js";
@@ -34,8 +34,8 @@ const z = ["data-placement"], K = { class: "popover__inner" }, N = {
34
34
  */
35
35
  directFocus: {
36
36
  type: Function,
37
- default: ({ isOpen: s, trigger: r, content: c }) => {
38
- s && c ? c.focus({ preventScroll: !0 }) : !s && r && r instanceof HTMLElement && r.focus({ preventScroll: !0 });
37
+ default: ({ isOpen: s, trigger: n, content: c }) => {
38
+ s && c ? c.focus({ preventScroll: !0 }) : !s && n && n instanceof HTMLElement && n.focus({ preventScroll: !0 });
39
39
  }
40
40
  },
41
41
  /**
@@ -58,39 +58,39 @@ const z = ["data-placement"], K = { class: "popover__inner" }, N = {
58
58
  modifiers: [String, Array, Object]
59
59
  },
60
60
  emits: ["close", "update:isOpen"],
61
- setup(s, { expose: r, emit: c }) {
62
- const d = c, e = s, o = x(null), { resolvedModifiers: _ } = U({ props: e, baseClass: "popover" }), f = y(() => e.config || {}), { floatingStyles: w, placement: E, arrowStyles: F, update: m, isFixedStrategy: S, contentArrow: h } = H(
61
+ setup(s, { expose: n, emit: c }) {
62
+ const p = c, e = s, o = x(null), { resolvedModifiers: _ } = U({ props: e, baseClass: "popover" }), f = y(() => e.config || {}), { floatingStyles: w, placement: E, arrowStyles: F, update: m, isFixedStrategy: S, contentArrow: h } = H(
63
63
  y(() => e.trigger),
64
64
  o,
65
65
  f
66
66
  ), i = () => {
67
- d("close"), d("update:isOpen", !1);
67
+ p("close"), p("update:isOpen", !1);
68
68
  }, b = (t) => {
69
69
  e.isOpen && e.escapeCloses && (t.preventDefault(), i());
70
70
  };
71
- let n = null;
71
+ let r = null;
72
72
  const a = () => {
73
- n && (document.removeEventListener("click", n), n = null);
73
+ r && (document.removeEventListener("click", r), r = null);
74
74
  }, B = () => {
75
- a(), e.clickOutsideCloses && (n = (t) => {
76
- if (!(!e.isOpen || !o.value) && document.body.contains(t.target) && !o.value.contains(t.target) && $(o.value, t)) {
75
+ a(), e.clickOutsideCloses && (r = (t) => {
76
+ if (!(!e.isOpen || !o.value) && document.body.contains(t.target) && !o.value.contains(t.target) && !t.target.closest("[data-ulu-tour-ui]") && $(o.value, t)) {
77
77
  if (e.trigger instanceof HTMLElement && e.trigger.contains(t.target))
78
78
  return;
79
79
  i();
80
80
  }
81
81
  }, setTimeout(() => {
82
- n && document.addEventListener("click", n);
82
+ r && document.addEventListener("click", r);
83
83
  }, 0));
84
84
  };
85
85
  return L(() => e.isOpen, (t, g) => {
86
- t ? (m(), B(), e.directFocus && v(() => {
86
+ t ? (m(), B(), e.directFocus && O(() => {
87
87
  e.directFocus({ isOpen: !0, trigger: e.trigger, content: o.value });
88
- })) : (a(), e.directFocus && g === !0 && v(() => {
88
+ })) : (a(), e.directFocus && g === !0 && O(() => {
89
89
  e.directFocus({ isOpen: !1, trigger: e.trigger, content: o.value });
90
90
  }));
91
91
  }, { immediate: !0 }), M(() => {
92
92
  a();
93
- }), r({
93
+ }), n({
94
94
  /**
95
95
  * Emits the close event
96
96
  */
@@ -103,7 +103,7 @@ const z = ["data-placement"], K = { class: "popover__inner" }, N = {
103
103
  * The internal root popover element reference
104
104
  */
105
105
  content: o
106
- }), (t, g) => (p(), u("span", {
106
+ }), (t, g) => (d(), u("span", {
107
107
  class: j(["popover", [
108
108
  {
109
109
  "popover--fixed": l(S),
@@ -113,7 +113,7 @@ const z = ["data-placement"], K = { class: "popover__inner" }, N = {
113
113
  ]]),
114
114
  ref_key: "contentEl",
115
115
  ref: o,
116
- style: O(l(w)),
116
+ style: v(l(w)),
117
117
  "data-placement": l(E),
118
118
  onKeydown: T(b, ["esc"]),
119
119
  tabindex: "-1"
@@ -124,18 +124,18 @@ const z = ["data-placement"], K = { class: "popover__inner" }, N = {
124
124
  close: i
125
125
  })
126
126
  ]),
127
- t.$slots.footer ? (p(), u("span", N, [
127
+ t.$slots.footer ? (d(), u("span", N, [
128
128
  C(t.$slots, "footer", {
129
129
  isOpen: s.isOpen,
130
130
  close: i
131
131
  })
132
132
  ])) : k("", !0),
133
- f.value.arrow ? (p(), u("span", {
133
+ f.value.arrow ? (d(), u("span", {
134
134
  key: 1,
135
135
  class: "popover__arrow",
136
136
  ref_key: "contentArrow",
137
137
  ref: h,
138
- style: O(l(F)),
138
+ style: v(l(F)),
139
139
  "data-ulu-popover-arrow": ""
140
140
  }, null, 4)) : k("", !0)
141
141
  ], 46, z));
@@ -1 +1 @@
1
- {"version":3,"file":"UluTourDisplay.vue.d.ts","sourceRoot":"","sources":["../../../lib/plugins/tour/UluTourDisplay.vue"],"names":[],"mappings":"AA+DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAkhBs4S,GAAG,8CAA8C,GAAG,yBAAyB,GAAG,6DAAmC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBA1Vn7S,KAAK"}
1
+ {"version":3,"file":"UluTourDisplay.vue.d.ts","sourceRoot":"","sources":["../../../lib/plugins/tour/UluTourDisplay.vue"],"names":[],"mappings":"AAmEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCA6hBklS,GAAG,8CAA8C,GAAG,yBAAyB,GAAG,6DAAmC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAjW/nS,KAAK"}
@@ -1,4 +1,4 @@
1
- import { computed as i, ref as f, watch as S, nextTick as T, onMounted as b, onUnmounted as L, createBlock as l, openBlock as o, Teleport as F, createElementBlock as x, createCommentVNode as $, unref as v, Fragment as I, resolveDynamicComponent as g, normalizeProps as h, mergeProps as s, createSlots as k, withCtx as c, createVNode as w, normalizeStyle as R } from "vue";
1
+ import { computed as p, ref as f, watch as S, nextTick as T, onMounted as b, onUnmounted as L, createBlock as l, openBlock as o, Teleport as F, createElementBlock as y, createCommentVNode as x, unref as v, Fragment as I, resolveDynamicComponent as g, mergeProps as s, createSlots as $, withCtx as c, normalizeProps as k, createVNode as w, normalizeStyle as R } from "vue";
2
2
  import V from "../../components/collapsible/UluModal.vue.js";
3
3
  import D from "../popovers/UluPopoverBase.vue.js";
4
4
  import P from "./UluTourPager.vue.js";
@@ -7,20 +7,20 @@ import { useTour as M } from "./useTour.js";
7
7
  const H = {
8
8
  __name: "UluTourDisplay",
9
9
  setup(N) {
10
- const { api: m, state: a } = M(), t = i(() => a.active?.steps[a.stepIndex]), u = f(null), d = f(null), C = i(() => ({
10
+ const { api: d, state: u } = M(), t = p(() => u.active?.steps[u.stepIndex]), a = f(null), m = f(null), C = p(() => ({
11
11
  placement: t.value?.placement || "bottom",
12
12
  arrow: !0,
13
13
  offset: 8
14
- })), E = i(() => ({
15
- ...a.active?.modalProps || {},
14
+ })), E = p(() => ({
15
+ ...u.active?.modalProps || {},
16
16
  ...t.value?.modalProps || {}
17
- })), z = i(() => ({
17
+ })), z = p(() => ({
18
18
  modifiers: "large",
19
- ...a.active?.popoverProps || {},
19
+ ...u.active?.popoverProps || {},
20
20
  ...t.value?.popoverProps || {}
21
- })), r = f(null), p = () => {
22
- if (u.value) {
23
- const e = u.value.getBoundingClientRect();
21
+ })), r = f(null), i = () => {
22
+ if (a.value) {
23
+ const e = a.value.getBoundingClientRect();
24
24
  r.value = {
25
25
  top: e.top,
26
26
  left: e.left,
@@ -29,7 +29,7 @@ const H = {
29
29
  };
30
30
  } else
31
31
  r.value = null;
32
- }, B = i(() => {
32
+ }, B = p(() => {
33
33
  if (!r.value) return {};
34
34
  const e = r.value;
35
35
  return {
@@ -60,27 +60,31 @@ const H = {
60
60
  if (e?.target) {
61
61
  await T();
62
62
  const n = document.querySelector(e.target);
63
- n ? (u.value = n, d.value && d.value.update(), e.highlight && p()) : console.warn(`Tour target not found: ${e.target}`);
63
+ n ? (a.value = n, m.value && m.value.update(), e.highlight && i()) : console.warn(`Tour target not found: ${e.target}`);
64
64
  } else
65
- u.value = null, r.value = null;
65
+ a.value = null, r.value = null;
66
66
  }, { immediate: !0 }), b(() => {
67
- window.addEventListener("resize", p), window.addEventListener("scroll", p);
67
+ window.addEventListener("resize", i), window.addEventListener("scroll", i);
68
68
  }), L(() => {
69
- window.removeEventListener("resize", p), window.removeEventListener("scroll", p);
69
+ window.removeEventListener("resize", i), window.removeEventListener("scroll", i);
70
70
  }), (e, n) => (o(), l(F, { to: "body" }, [
71
- v(a).active ? (o(), x(I, { key: 0 }, [
72
- t.value?.component ? (o(), l(g(t.value.component), h(s({ key: 0 }, t.value.componentProps)), null, 16)) : t.value?.target ? (o(), l(D, s({
71
+ v(u).active ? (o(), y(I, { key: 0 }, [
72
+ t.value?.component ? (o(), l(g(t.value.component), s({
73
+ key: 0,
74
+ "data-ulu-tour-ui": "true"
75
+ }, t.value.componentProps), null, 16)) : t.value?.target ? (o(), l(D, s({
73
76
  key: 2,
74
77
  ref_key: "popoverBase",
75
- ref: d,
76
- trigger: u.value,
78
+ ref: m,
79
+ trigger: a.value,
77
80
  config: C.value,
78
81
  style: { zIndex: 9999 },
79
82
  isOpen: !0,
80
- onClose: n[1] || (n[1] = (y) => v(m).stop())
81
- }, z.value), k({
83
+ "data-ulu-tour-ui": "true",
84
+ onClose: n[1] || (n[1] = (h) => v(d).stop())
85
+ }, z.value), $({
82
86
  default: c(() => [
83
- t.value?.contentComponent ? (o(), l(g(t.value.contentComponent), h(s({ key: 0 }, t.value.componentProps)), null, 16)) : (o(), l(_, {
87
+ t.value?.contentComponent ? (o(), l(g(t.value.contentComponent), k(s({ key: 0 }, t.value.componentProps)), null, 16)) : (o(), l(_, {
84
88
  key: 1,
85
89
  step: t.value,
86
90
  "is-modal": !1
@@ -97,12 +101,13 @@ const H = {
97
101
  }
98
102
  ]), 1040, ["trigger", "config"])) : (o(), l(V, s({
99
103
  key: 1,
100
- modelValue: !0
104
+ modelValue: !0,
105
+ "data-ulu-tour-ui": "true"
101
106
  }, E.value, {
102
- onClose: n[0] || (n[0] = (y) => v(m).stop())
103
- }), k({
107
+ onClose: n[0] || (n[0] = (h) => v(d).stop())
108
+ }), $({
104
109
  default: c(() => [
105
- t.value?.contentComponent ? (o(), l(g(t.value.contentComponent), h(s({ key: 0 }, t.value.componentProps)), null, 16)) : (o(), l(_, {
110
+ t.value?.contentComponent ? (o(), l(g(t.value.contentComponent), k(s({ key: 0 }, t.value.componentProps)), null, 16)) : (o(), l(_, {
106
111
  key: 1,
107
112
  step: t.value,
108
113
  "is-modal": !0
@@ -118,13 +123,14 @@ const H = {
118
123
  key: "0"
119
124
  }
120
125
  ]), 1040)),
121
- t.value?.target && t.value?.highlight && r.value ? (o(), x("div", {
126
+ t.value?.target && t.value?.highlight && r.value ? (o(), y("div", {
122
127
  key: 3,
123
128
  class: "tour-highlight-backdrop",
124
129
  style: R(B.value),
125
- onClick: n[2] || (n[2] = (y) => v(m).stop())
126
- }, null, 4)) : $("", !0)
127
- ], 64)) : $("", !0)
130
+ "data-ulu-tour-ui": "true",
131
+ onClick: n[2] || (n[2] = (h) => v(d).stop())
132
+ }, null, 4)) : x("", !0)
133
+ ], 64)) : x("", !0)
128
134
  ]));
129
135
  }
130
136
  };
@@ -56,5 +56,9 @@ export type TourStep = {
56
56
  * - Async hook called before the step is rendered.
57
57
  */
58
58
  onEnter?: Function | undefined;
59
+ /**
60
+ * - Async hook called after the step is exited.
61
+ */
62
+ onLeave?: Function | undefined;
59
63
  };
60
64
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../lib/plugins/tour/api.js"],"names":[],"mappings":"AAyBO,iCAHI,MAAM,GACJ,MAAM,CAgEjB"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../lib/plugins/tour/api.js"],"names":[],"mappings":"AA0BO,iCAHI,MAAM,GACJ,MAAM,CAqFjB"}
@@ -1,5 +1,5 @@
1
- import { markRaw as t } from "vue";
2
- const o = (e) => ({
1
+ import { markRaw as o } from "vue";
2
+ const s = (e) => ({
3
3
  /**
4
4
  * Starts a new tour
5
5
  * @param {Object} tour - The tour configuration object
@@ -10,9 +10,10 @@ const o = (e) => ({
10
10
  * @param {String|Array|Object} [tour.modalTitleClass] - Global class applied to the title of modal steps.
11
11
  * @param {String|Array|Object} [tour.popoverTitleClass] - Global class applied to the title of popover steps.
12
12
  * @param {String|Array|Object} [tour.pagerClass] - Global class applied to the pager.
13
+ * @param {Function} [tour.onStop] - Async hook called when the tour is closed/finished.
13
14
  */
14
15
  async start(n) {
15
- n?.steps?.length && (await this._runHooks(n.steps[0]), e.active = t(n), e.stepIndex = 0);
16
+ n?.steps?.length && (await this._runHooks(n.steps[0]), e.active = o(n), e.stepIndex = 0);
16
17
  },
17
18
  /**
18
19
  * Advances the tour to the next step, or stops if it is the last step
@@ -21,10 +22,11 @@ const o = (e) => ({
21
22
  const n = e.active;
22
23
  if (n)
23
24
  if (e.stepIndex < n.steps.length - 1) {
24
- const s = e.stepIndex + 1;
25
- await this._runHooks(n.steps[s]), e.stepIndex = s;
25
+ await this._runLeaveHook(n.steps[e.stepIndex]);
26
+ const i = e.stepIndex + 1;
27
+ await this._runHooks(n.steps[i]), e.stepIndex = i;
26
28
  } else
27
- this.stop();
29
+ await this.stop();
28
30
  },
29
31
  /**
30
32
  * Returns the tour to the previous step
@@ -32,24 +34,33 @@ const o = (e) => ({
32
34
  async prev() {
33
35
  const n = e.active;
34
36
  if (n && e.stepIndex > 0) {
35
- const s = e.stepIndex - 1;
36
- await this._runHooks(n.steps[s]), e.stepIndex = s;
37
+ await this._runLeaveHook(n.steps[e.stepIndex]);
38
+ const i = e.stepIndex - 1;
39
+ await this._runHooks(n.steps[i]), e.stepIndex = i;
37
40
  }
38
41
  },
39
42
  /**
40
43
  * Stops and closes the current tour
41
44
  */
42
- stop() {
43
- e.active = null, e.stepIndex = 0;
45
+ async stop() {
46
+ const n = e.active;
47
+ n && (n.steps[e.stepIndex] && await this._runLeaveHook(n.steps[e.stepIndex]), typeof n.onStop == "function" && await n.onStop()), e.active = null, e.stepIndex = 0;
44
48
  },
45
49
  /**
46
- * Internal method to run asynchronous lifecycle hooks on a step
50
+ * Internal method to run asynchronous enter hooks on a step
47
51
  * @param {Object} step - The tour step configuration
48
52
  */
49
53
  async _runHooks(n) {
50
54
  n && typeof n.onEnter == "function" && await n.onEnter();
55
+ },
56
+ /**
57
+ * Internal method to run asynchronous leave hooks on a step
58
+ * @param {Object} step - The tour step configuration
59
+ */
60
+ async _runLeaveHook(n) {
61
+ n && typeof n.onLeave == "function" && await n.onLeave();
51
62
  }
52
63
  });
53
64
  export {
54
- o as createApi
65
+ s as createApi
55
66
  };
@@ -11,6 +11,7 @@
11
11
  :aria-describedby="describedby"
12
12
  ref="container"
13
13
  :style="{ width: containerWidth }"
14
+ v-bind="$attrs"
14
15
  @cancel.prevent="close"
15
16
  @close="handleDialogCloseEvent"
16
17
  @click="handleClick"
@@ -16,6 +16,7 @@ import { markRaw } from "vue";
16
16
  * @property {Object} [modalProps] - Props to pass to the modal (if target is omitted).
17
17
  * @property {Object} [popoverProps] - Props to pass to the popover (if target is present).
18
18
  * @property {Function} [onEnter] - Async hook called before the step is rendered.
19
+ * @property {Function} [onLeave] - Async hook called after the step is exited.
19
20
  */
20
21
 
21
22
  /**
@@ -34,6 +35,7 @@ export const createApi = (state) => ({
34
35
  * @param {String|Array|Object} [tour.modalTitleClass] - Global class applied to the title of modal steps.
35
36
  * @param {String|Array|Object} [tour.popoverTitleClass] - Global class applied to the title of popover steps.
36
37
  * @param {String|Array|Object} [tour.pagerClass] - Global class applied to the pager.
38
+ * @param {Function} [tour.onStop] - Async hook called when the tour is closed/finished.
37
39
  */
38
40
  async start(tour) {
39
41
  if (!tour?.steps?.length) return;
@@ -49,11 +51,12 @@ export const createApi = (state) => ({
49
51
  if (!active) return;
50
52
 
51
53
  if (state.stepIndex < active.steps.length - 1) {
54
+ await this._runLeaveHook(active.steps[state.stepIndex]);
52
55
  const nextIndex = state.stepIndex + 1;
53
56
  await this._runHooks(active.steps[nextIndex]);
54
57
  state.stepIndex = nextIndex;
55
58
  } else {
56
- this.stop();
59
+ await this.stop();
57
60
  }
58
61
  },
59
62
  /**
@@ -64,6 +67,7 @@ export const createApi = (state) => ({
64
67
  if (!active) return;
65
68
 
66
69
  if (state.stepIndex > 0) {
70
+ await this._runLeaveHook(active.steps[state.stepIndex]);
67
71
  const prevIndex = state.stepIndex - 1;
68
72
  await this._runHooks(active.steps[prevIndex]);
69
73
  state.stepIndex = prevIndex;
@@ -72,17 +76,35 @@ export const createApi = (state) => ({
72
76
  /**
73
77
  * Stops and closes the current tour
74
78
  */
75
- stop() {
79
+ async stop() {
80
+ const active = state.active;
81
+ if (active) {
82
+ if (active.steps[state.stepIndex]) {
83
+ await this._runLeaveHook(active.steps[state.stepIndex]);
84
+ }
85
+ if (typeof active.onStop === 'function') {
86
+ await active.onStop();
87
+ }
88
+ }
76
89
  state.active = null;
77
90
  state.stepIndex = 0;
78
91
  },
79
92
  /**
80
- * Internal method to run asynchronous lifecycle hooks on a step
93
+ * Internal method to run asynchronous enter hooks on a step
81
94
  * @param {Object} step - The tour step configuration
82
95
  */
83
96
  async _runHooks(step) {
84
97
  if (step && typeof step.onEnter === 'function') {
85
98
  await step.onEnter();
86
99
  }
100
+ },
101
+ /**
102
+ * Internal method to run asynchronous leave hooks on a step
103
+ * @param {Object} step - The tour step configuration
104
+ */
105
+ async _runLeaveHook(step) {
106
+ if (step && typeof step.onLeave === 'function') {
107
+ await step.onLeave();
108
+ }
87
109
  }
88
110
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.6.29",
3
+ "version": "0.6.31",
4
4
  "description": "A modular, tree-shakeable Vue 3 component library for the Ulu Frontend theming system, plus general utilities for Vue development",
5
5
  "type": "module",
6
6
  "files": [