@ulu/frontend-vue 0.6.34 → 0.6.36

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.
@@ -2,17 +2,21 @@ 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
+ * @property {String|Function|HTMLElement} [highlightElement] - Element to highlight if different from target. Falls back to target if not provided.
6
7
  * @property {String} [title] - The title text for the step.
7
8
  * @property {String|Array|Object} [titleClass] - Class to apply to the title.
8
9
  * @property {String|Array|Object} [pagerClass] - Class to apply to the pager footer.
10
+ * @property {String|Array|Object} [progressClass] - Class to apply to the progress indicator.
9
11
  * @property {String} [content] - The content text for the step.
10
12
  * @property {Object} [component] - A Vue component to completely replace the modal/popover wrapper and layout.
11
13
  * @property {Object} [contentComponent] - A Vue component to replace the step text content, keeping the modal/popover wrappers and default footer.
12
14
  * @property {Object} [componentProps] - Props to bind to the custom component.
13
15
  * @property {Boolean} [hideFooter] - If true, hides the default tour footer (Next/Back buttons).
16
+ * @property {Boolean} [hideProgress] - If true, hides the "Part X / Y" progress indicator for this step.
14
17
  * @property {String} [placement] - Floating UI placement string (e.g. 'bottom', 'right').
15
18
  * @property {Boolean} [highlight] - If true, darkens the backdrop around the target element.
19
+ * @property {Boolean|Function} [skip] - If true or returns true, this step will be skipped when navigating the tour.
16
20
  * @property {Object} [modalProps] - Props to pass to the modal (if target is omitted).
17
21
  * @property {Object} [popoverProps] - Props to pass to the popover (if target is present).
18
22
  * @property {Function} [onEnter] - Async hook called before the step is rendered.
@@ -35,6 +39,8 @@ export const createApi = (state) => ({
35
39
  * @param {String|Array|Object} [tour.modalTitleClass] - Global class applied to the title of modal steps.
36
40
  * @param {String|Array|Object} [tour.popoverTitleClass] - Global class applied to the title of popover steps.
37
41
  * @param {String|Array|Object} [tour.pagerClass] - Global class applied to the pager.
42
+ * @param {String|Array|Object} [tour.progressClass] - Global class applied to the progress indicator.
43
+ * @param {Boolean} [tour.hideProgress] - Globally hides the progress indicator for all steps unless overridden.
38
44
  * @param {Function} [tour.onStart] - Async hook called before the tour starts.
39
45
  * @param {Function} [tour.onStop] - Async hook called when the tour is closed/finished.
40
46
  */
@@ -46,9 +52,23 @@ export const createApi = (state) => ({
46
52
  if (typeof tour.onStart === 'function') {
47
53
  await tour.onStart();
48
54
  }
49
- await this._runHooks(tour.steps[0]);
55
+
56
+ let startIndex = 0;
57
+ while (startIndex < tour.steps.length) {
58
+ const step = tour.steps[startIndex];
59
+ const shouldSkip = typeof step.skip === 'function' ? await step.skip() : step.skip;
60
+ if (!shouldSkip) break;
61
+ startIndex++;
62
+ }
63
+
64
+ if (startIndex >= tour.steps.length) {
65
+ if (typeof tour.onStop === 'function') await tour.onStop();
66
+ return;
67
+ }
68
+
69
+ await this._runHooks(tour.steps[startIndex]);
50
70
  state.active = markRaw(tour);
51
- state.stepIndex = 0;
71
+ state.stepIndex = startIndex;
52
72
  } finally {
53
73
  state.isTransitioning = false;
54
74
  }
@@ -63,9 +83,16 @@ export const createApi = (state) => ({
63
83
 
64
84
  state.isTransitioning = true;
65
85
  try {
66
- if (state.stepIndex < active.steps.length - 1) {
86
+ let nextIndex = state.stepIndex + 1;
87
+ while (nextIndex < active.steps.length) {
88
+ const step = active.steps[nextIndex];
89
+ const shouldSkip = typeof step.skip === 'function' ? await step.skip() : step.skip;
90
+ if (!shouldSkip) break;
91
+ nextIndex++;
92
+ }
93
+
94
+ if (nextIndex < active.steps.length) {
67
95
  await this._runLeaveHook(active.steps[state.stepIndex]);
68
- const nextIndex = state.stepIndex + 1;
69
96
  await this._runHooks(active.steps[nextIndex]);
70
97
  state.stepIndex = nextIndex;
71
98
  } else {
@@ -85,9 +112,16 @@ export const createApi = (state) => ({
85
112
 
86
113
  state.isTransitioning = true;
87
114
  try {
88
- if (state.stepIndex > 0) {
115
+ let prevIndex = state.stepIndex - 1;
116
+ while (prevIndex >= 0) {
117
+ const step = active.steps[prevIndex];
118
+ const shouldSkip = typeof step.skip === 'function' ? await step.skip() : step.skip;
119
+ if (!shouldSkip) break;
120
+ prevIndex--;
121
+ }
122
+
123
+ if (prevIndex >= 0) {
89
124
  await this._runLeaveHook(active.steps[state.stepIndex]);
90
- const prevIndex = state.stepIndex - 1;
91
125
  await this._runHooks(active.steps[prevIndex]);
92
126
  state.stepIndex = prevIndex;
93
127
  }
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.36",
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": [