@ulu/frontend-vue 0.6.34 → 0.6.35

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,37 +1,40 @@
1
- import { computed as l, ref as h, watch as z, nextTick as L, onMounted as F, onUnmounted as I, createBlock as a, openBlock as n, Teleport as M, createElementBlock as $, createCommentVNode as k, unref as r, Fragment as R, resolveDynamicComponent as p, mergeProps as d, createSlots as w, withCtx as f, normalizeStyle as D } from "vue";
2
- import U from "../../components/collapsible/UluModal.vue.js";
3
- import V from "../popovers/UluPopoverBase.vue.js";
4
- import q from "./UluTourPager.vue.js";
5
- import P from "./UluTourContent.vue.js";
6
- import { useTour as N } from "./useTour.js";
7
- const Q = {
1
+ import { computed as l, ref as h, watch as L, nextTick as D, onMounted as F, onUnmounted as I, createBlock as a, openBlock as n, Teleport as M, createElementBlock as w, createCommentVNode as $, unref as r, Fragment as R, resolveDynamicComponent as p, mergeProps as c, createSlots as P, withCtx as f, normalizeStyle as U } from "vue";
2
+ import V from "../../components/collapsible/UluModal.vue.js";
3
+ import q from "../popovers/UluPopoverBase.vue.js";
4
+ import N from "./UluTourPager.vue.js";
5
+ import _ from "./UluTourContent.vue.js";
6
+ import { useTour as O } from "./useTour.js";
7
+ const W = {
8
8
  __name: "UluTourDisplay",
9
- setup(O) {
10
- const { api: i, state: o } = N(), t = l(() => o.active?.steps[o.stepIndex]), y = l(() => t.value?.component || o.active?.component), c = l(() => t.value?.contentComponent || o.active?.contentComponent), C = l(() => t.value?.pagerComponent || o.active?.pagerComponent || q), _ = l(() => t.value?.modalComponent || o.active?.modalComponent || U), S = l(() => t.value?.popoverComponent || o.active?.popoverComponent || V), v = h(null), g = h(null), E = l(() => ({
9
+ setup(j) {
10
+ const { api: s, state: o } = O(), t = l(() => o.active?.steps[o.stepIndex]), y = l(() => t.value?.component || o.active?.component), d = l(() => t.value?.contentComponent || o.active?.contentComponent), C = l(() => t.value?.pagerComponent || o.active?.pagerComponent || N), S = l(() => t.value?.modalComponent || o.active?.modalComponent || V), E = l(() => t.value?.popoverComponent || o.active?.popoverComponent || q), i = h(null), g = h(null), x = l(() => {
11
+ const e = t.value?.target;
12
+ return typeof e == "function" ? e() : e;
13
+ }), T = l(() => ({
11
14
  placement: t.value?.placement || "bottom",
12
15
  arrow: !0,
13
16
  offset: 8
14
17
  })), B = l(() => ({
15
18
  ...o.active?.modalProps || {},
16
19
  ...t.value?.modalProps || {}
17
- })), T = l(() => ({
20
+ })), b = l(() => ({
18
21
  modifiers: "large",
19
22
  ...o.active?.popoverProps || {},
20
23
  ...t.value?.popoverProps || {}
21
- })), s = h(null), m = () => {
22
- if (v.value) {
23
- const e = v.value.getBoundingClientRect();
24
- s.value = {
24
+ })), v = h(null), m = () => {
25
+ if (i.value) {
26
+ const e = i.value.getBoundingClientRect();
27
+ v.value = {
25
28
  top: e.top,
26
29
  left: e.left,
27
30
  width: e.width,
28
31
  height: e.height
29
32
  };
30
33
  } else
31
- s.value = null;
32
- }, b = l(() => {
33
- if (!s.value) return {};
34
- const e = s.value;
34
+ v.value = null;
35
+ }, z = l(() => {
36
+ if (!v.value) return {};
37
+ const e = v.value;
35
38
  return {
36
39
  position: "fixed",
37
40
  top: 0,
@@ -56,44 +59,44 @@ const Q = {
56
59
  )`
57
60
  };
58
61
  });
59
- return z(t, async (e) => {
60
- if (e?.target) {
61
- await L();
62
- const u = document.querySelector(e.target);
63
- u ? (v.value = u, g.value && g.value.update(), e.highlight && m()) : console.warn(`Tour target not found: ${e.target}`);
62
+ return L(x, async (e) => {
63
+ if (e) {
64
+ await D();
65
+ const u = typeof e == "string" ? document.querySelector(e) : e;
66
+ u ? (i.value = u, g.value && g.value.update(), t.value?.highlight && m()) : (console.warn("Tour target not found:", e), i.value = null);
64
67
  } else
65
- v.value = null, s.value = null;
68
+ i.value = null, v.value = null;
66
69
  }, { immediate: !0 }), F(() => {
67
70
  window.addEventListener("resize", m), window.addEventListener("scroll", m);
68
71
  }), I(() => {
69
72
  window.removeEventListener("resize", m), window.removeEventListener("scroll", m);
70
73
  }), (e, u) => (n(), a(M, { to: "body" }, [
71
- r(o).active ? (n(), $(R, { key: 0 }, [
72
- y.value ? (n(), a(p(y.value), d({
74
+ r(o).active ? (n(), w(R, { key: 0 }, [
75
+ y.value ? (n(), a(p(y.value), c({
73
76
  key: 0,
74
77
  "data-ulu-tour-ui": "true",
75
78
  step: t.value,
76
79
  tourState: r(o),
77
- api: r(i)
78
- }, t.value.componentProps), null, 16, ["step", "tourState", "api"])) : t.value?.target ? (n(), a(p(S.value), d({
80
+ api: r(s)
81
+ }, t.value.componentProps), null, 16, ["step", "tourState", "api"])) : x.value ? (n(), a(p(E.value), c({
79
82
  key: 2,
80
83
  ref_key: "popoverBase",
81
84
  ref: g,
82
- trigger: v.value,
83
- config: E.value,
85
+ trigger: i.value,
86
+ config: T.value,
84
87
  style: { zIndex: 9999 },
85
88
  isOpen: !0,
86
89
  "data-ulu-tour-ui": "true",
87
- onClose: u[1] || (u[1] = (x) => r(i).stop())
88
- }, T.value), w({
90
+ onClose: u[1] || (u[1] = (k) => r(s).stop())
91
+ }, b.value), P({
89
92
  default: f(() => [
90
- c.value ? (n(), a(p(c.value), d({
93
+ d.value ? (n(), a(p(d.value), c({
91
94
  key: 0,
92
95
  step: t.value,
93
96
  tourState: r(o),
94
- api: r(i),
97
+ api: r(s),
95
98
  "is-modal": !1
96
- }, t.value.componentProps), null, 16, ["step", "tourState", "api"])) : (n(), a(P, {
99
+ }, t.value.componentProps), null, 16, ["step", "tourState", "api"])) : (n(), a(_, {
97
100
  key: 1,
98
101
  step: t.value,
99
102
  "is-modal": !1
@@ -108,21 +111,21 @@ const Q = {
108
111
  ]),
109
112
  key: "0"
110
113
  }
111
- ]), 1040, ["trigger", "config"])) : (n(), a(p(_.value), d({
114
+ ]), 1040, ["trigger", "config"])) : (n(), a(p(S.value), c({
112
115
  key: 1,
113
116
  modelValue: !0,
114
117
  "data-ulu-tour-ui": "true"
115
118
  }, B.value, {
116
- onClose: u[0] || (u[0] = (x) => r(i).stop())
117
- }), w({
119
+ onClose: u[0] || (u[0] = (k) => r(s).stop())
120
+ }), P({
118
121
  default: f(() => [
119
- c.value ? (n(), a(p(c.value), d({
122
+ d.value ? (n(), a(p(d.value), c({
120
123
  key: 0,
121
124
  step: t.value,
122
125
  tourState: r(o),
123
- api: r(i),
126
+ api: r(s),
124
127
  "is-modal": !0
125
- }, t.value.componentProps), null, 16, ["step", "tourState", "api"])) : (n(), a(P, {
128
+ }, t.value.componentProps), null, 16, ["step", "tourState", "api"])) : (n(), a(_, {
126
129
  key: 1,
127
130
  step: t.value,
128
131
  "is-modal": !0
@@ -138,17 +141,17 @@ const Q = {
138
141
  key: "0"
139
142
  }
140
143
  ]), 1040)),
141
- t.value?.target && t.value?.highlight && s.value ? (n(), $("div", {
144
+ t.value?.target && t.value?.highlight && v.value ? (n(), w("div", {
142
145
  key: 3,
143
146
  class: "tour-highlight-backdrop",
144
- style: D(b.value),
147
+ style: U(z.value),
145
148
  "data-ulu-tour-ui": "true",
146
- onClick: u[2] || (u[2] = (x) => r(i).stop())
147
- }, null, 4)) : k("", !0)
148
- ], 64)) : k("", !0)
149
+ onClick: u[2] || (u[2] = (k) => r(s).stop())
150
+ }, null, 4)) : $("", !0)
151
+ ], 64)) : $("", !0)
149
152
  ]));
150
153
  }
151
154
  };
152
155
  export {
153
- Q as default
156
+ W as default
154
157
  };
@@ -1,9 +1,9 @@
1
1
  export function createApi(state: Object): Object;
2
2
  export type TourStep = {
3
3
  /**
4
- * - The CSS selector for the target element. If omitted, step renders as a modal.
4
+ * - The CSS selector, DOM element, or function returning either, for the target element. If omitted or resolves to falsy, step renders as a modal.
5
5
  */
6
- target?: string | undefined;
6
+ target?: string | Function | HTMLElement | undefined;
7
7
  /**
8
8
  * - The title text for the step.
9
9
  */
@@ -44,6 +44,10 @@ export type TourStep = {
44
44
  * - If true, darkens the backdrop around the target element.
45
45
  */
46
46
  highlight?: boolean | undefined;
47
+ /**
48
+ * - If true or returns true, this step will be skipped when navigating the tour.
49
+ */
50
+ skip?: boolean | Function | undefined;
47
51
  /**
48
52
  * - Props to pass to the modal (if target is omitted).
49
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../lib/plugins/tour/api.js"],"names":[],"mappings":"AA0BO,iCAHI,MAAM,GACJ,MAAM,CAkHjB"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../lib/plugins/tour/api.js"],"names":[],"mappings":"AA2BO,iCAHI,MAAM,GACJ,MAAM,CA8IjB"}
@@ -1,5 +1,5 @@
1
- import { markRaw as s } from "vue";
2
- const r = (n) => ({
1
+ import { markRaw as o } from "vue";
2
+ const a = (n) => ({
3
3
  /**
4
4
  * Starts a new tour
5
5
  * @param {Object} tour - The tour configuration object
@@ -18,7 +18,18 @@ const r = (n) => ({
18
18
  n.isTransitioning = !0;
19
19
  try {
20
20
  if (!i?.steps?.length) return;
21
- typeof i.onStart == "function" && await i.onStart(), await this._runHooks(i.steps[0]), n.active = s(i), n.stepIndex = 0;
21
+ typeof i.onStart == "function" && await i.onStart();
22
+ let s = 0;
23
+ for (; s < i.steps.length; ) {
24
+ const e = i.steps[s];
25
+ if (!(typeof e.skip == "function" ? await e.skip() : e.skip)) break;
26
+ s++;
27
+ }
28
+ if (s >= i.steps.length) {
29
+ typeof i.onStop == "function" && await i.onStop();
30
+ return;
31
+ }
32
+ await this._runHooks(i.steps[s]), n.active = o(i), n.stepIndex = s;
22
33
  } finally {
23
34
  n.isTransitioning = !1;
24
35
  }
@@ -33,12 +44,13 @@ const r = (n) => ({
33
44
  if (i) {
34
45
  n.isTransitioning = !0;
35
46
  try {
36
- if (n.stepIndex < i.steps.length - 1) {
37
- await this._runLeaveHook(i.steps[n.stepIndex]);
38
- const e = n.stepIndex + 1;
39
- await this._runHooks(i.steps[e]), n.stepIndex = e;
40
- } else
41
- await this.stop(!0);
47
+ let s = n.stepIndex + 1;
48
+ for (; s < i.steps.length; ) {
49
+ const e = i.steps[s];
50
+ if (!(typeof e.skip == "function" ? await e.skip() : e.skip)) break;
51
+ s++;
52
+ }
53
+ s < i.steps.length ? (await this._runLeaveHook(i.steps[n.stepIndex]), await this._runHooks(i.steps[s]), n.stepIndex = s) : await this.stop(!0);
42
54
  } finally {
43
55
  n.isTransitioning = !1;
44
56
  }
@@ -53,11 +65,13 @@ const r = (n) => ({
53
65
  if (i) {
54
66
  n.isTransitioning = !0;
55
67
  try {
56
- if (n.stepIndex > 0) {
57
- await this._runLeaveHook(i.steps[n.stepIndex]);
58
- const e = n.stepIndex - 1;
59
- await this._runHooks(i.steps[e]), n.stepIndex = e;
68
+ let s = n.stepIndex - 1;
69
+ for (; s >= 0; ) {
70
+ const e = i.steps[s];
71
+ if (!(typeof e.skip == "function" ? await e.skip() : e.skip)) break;
72
+ s--;
60
73
  }
74
+ s >= 0 && (await this._runLeaveHook(i.steps[n.stepIndex]), await this._runHooks(i.steps[s]), n.stepIndex = s);
61
75
  } finally {
62
76
  n.isTransitioning = !1;
63
77
  }
@@ -71,8 +85,8 @@ const r = (n) => ({
71
85
  if (!(!i && n.isTransitioning)) {
72
86
  n.isTransitioning = !0;
73
87
  try {
74
- const e = n.active;
75
- e && (e.steps[n.stepIndex] && await this._runLeaveHook(e.steps[n.stepIndex]), typeof e.onStop == "function" && await e.onStop()), n.active = null, n.stepIndex = 0;
88
+ const s = n.active;
89
+ s && (s.steps[n.stepIndex] && await this._runLeaveHook(s.steps[n.stepIndex]), typeof s.onStop == "function" && await s.onStop()), n.active = null, n.stepIndex = 0;
76
90
  } finally {
77
91
  n.isTransitioning = !1;
78
92
  }
@@ -94,5 +108,5 @@ const r = (n) => ({
94
108
  }
95
109
  });
96
110
  export {
97
- r as createApi
111
+ a as createApi
98
112
  };
@@ -15,7 +15,7 @@
15
15
 
16
16
  <!-- 2. RENDER MODAL STEP -->
17
17
  <component
18
- v-else-if="!currentStep?.target"
18
+ v-else-if="!resolvedTargetDescriptor"
19
19
  :is="resolvedModalComponent"
20
20
  :modelValue="true"
21
21
  data-ulu-tour-ui="true"
@@ -102,6 +102,12 @@
102
102
  const targetEl = ref(null);
103
103
  const popoverBase = ref(null);
104
104
 
105
+ const resolvedTargetDescriptor = computed(() => {
106
+ const t = currentStep.value?.target;
107
+ if (typeof t === 'function') return t();
108
+ return t;
109
+ });
110
+
105
111
  const resolvedConfig = computed(() => ({
106
112
  placement: currentStep.value?.placement || 'bottom',
107
113
  arrow: true,
@@ -170,10 +176,10 @@
170
176
  });
171
177
 
172
178
  // Watch for step changes to update floating UI target
173
- watch(currentStep, async (step) => {
174
- if (step?.target) {
179
+ watch(resolvedTargetDescriptor, async (descriptor) => {
180
+ if (descriptor) {
175
181
  await nextTick();
176
- const el = document.querySelector(step.target);
182
+ const el = typeof descriptor === 'string' ? document.querySelector(descriptor) : descriptor;
177
183
  if (el) {
178
184
  targetEl.value = el;
179
185
  // UluPopoverBase's isOpen watcher automatically calls update(),
@@ -182,11 +188,12 @@
182
188
  if (popoverBase.value) {
183
189
  popoverBase.value.update();
184
190
  }
185
- if (step.highlight) {
191
+ if (currentStep.value?.highlight) {
186
192
  updateTargetRect();
187
193
  }
188
194
  } else {
189
- console.warn(`Tour target not found: ${step.target}`);
195
+ console.warn(`Tour target not found:`, descriptor);
196
+ targetEl.value = null;
190
197
  }
191
198
  } else {
192
199
  targetEl.value = null;
@@ -2,7 +2,7 @@ import { markRaw } from "vue";
2
2
 
3
3
  /**
4
4
  * @typedef {Object} TourStep
5
- * @property {String} [target] - The CSS selector for the target element. If omitted, step renders as a modal.
5
+ * @property {String|Function|HTMLElement} [target] - The CSS selector, DOM element, or function returning either, for the target element. If omitted or resolves to falsy, step renders as a modal.
6
6
  * @property {String} [title] - The title text for the step.
7
7
  * @property {String|Array|Object} [titleClass] - Class to apply to the title.
8
8
  * @property {String|Array|Object} [pagerClass] - Class to apply to the pager footer.
@@ -13,6 +13,7 @@ import { markRaw } from "vue";
13
13
  * @property {Boolean} [hideFooter] - If true, hides the default tour footer (Next/Back buttons).
14
14
  * @property {String} [placement] - Floating UI placement string (e.g. 'bottom', 'right').
15
15
  * @property {Boolean} [highlight] - If true, darkens the backdrop around the target element.
16
+ * @property {Boolean|Function} [skip] - If true or returns true, this step will be skipped when navigating the tour.
16
17
  * @property {Object} [modalProps] - Props to pass to the modal (if target is omitted).
17
18
  * @property {Object} [popoverProps] - Props to pass to the popover (if target is present).
18
19
  * @property {Function} [onEnter] - Async hook called before the step is rendered.
@@ -46,9 +47,23 @@ export const createApi = (state) => ({
46
47
  if (typeof tour.onStart === 'function') {
47
48
  await tour.onStart();
48
49
  }
49
- await this._runHooks(tour.steps[0]);
50
+
51
+ let startIndex = 0;
52
+ while (startIndex < tour.steps.length) {
53
+ const step = tour.steps[startIndex];
54
+ const shouldSkip = typeof step.skip === 'function' ? await step.skip() : step.skip;
55
+ if (!shouldSkip) break;
56
+ startIndex++;
57
+ }
58
+
59
+ if (startIndex >= tour.steps.length) {
60
+ if (typeof tour.onStop === 'function') await tour.onStop();
61
+ return;
62
+ }
63
+
64
+ await this._runHooks(tour.steps[startIndex]);
50
65
  state.active = markRaw(tour);
51
- state.stepIndex = 0;
66
+ state.stepIndex = startIndex;
52
67
  } finally {
53
68
  state.isTransitioning = false;
54
69
  }
@@ -63,9 +78,16 @@ export const createApi = (state) => ({
63
78
 
64
79
  state.isTransitioning = true;
65
80
  try {
66
- if (state.stepIndex < active.steps.length - 1) {
81
+ let nextIndex = state.stepIndex + 1;
82
+ while (nextIndex < active.steps.length) {
83
+ const step = active.steps[nextIndex];
84
+ const shouldSkip = typeof step.skip === 'function' ? await step.skip() : step.skip;
85
+ if (!shouldSkip) break;
86
+ nextIndex++;
87
+ }
88
+
89
+ if (nextIndex < active.steps.length) {
67
90
  await this._runLeaveHook(active.steps[state.stepIndex]);
68
- const nextIndex = state.stepIndex + 1;
69
91
  await this._runHooks(active.steps[nextIndex]);
70
92
  state.stepIndex = nextIndex;
71
93
  } else {
@@ -85,9 +107,16 @@ export const createApi = (state) => ({
85
107
 
86
108
  state.isTransitioning = true;
87
109
  try {
88
- if (state.stepIndex > 0) {
110
+ let prevIndex = state.stepIndex - 1;
111
+ while (prevIndex >= 0) {
112
+ const step = active.steps[prevIndex];
113
+ const shouldSkip = typeof step.skip === 'function' ? await step.skip() : step.skip;
114
+ if (!shouldSkip) break;
115
+ prevIndex--;
116
+ }
117
+
118
+ if (prevIndex >= 0) {
89
119
  await this._runLeaveHook(active.steps[state.stepIndex]);
90
- const prevIndex = state.stepIndex - 1;
91
120
  await this._runHooks(active.steps[prevIndex]);
92
121
  state.stepIndex = prevIndex;
93
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ulu/frontend-vue",
3
- "version": "0.6.34",
3
+ "version": "0.6.35",
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": [