@mekari/pixel3-tour 0.0.1-dev.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.
- package/dist/chunk-5MGBFCZE.mjs +44 -0
- package/dist/chunk-7BC44YZN.mjs +31 -0
- package/dist/chunk-LCGHHNKQ.mjs +203 -0
- package/dist/chunk-QZ7VFGWC.mjs +6 -0
- package/dist/chunk-TQSSSA7Q.mjs +20 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +297 -0
- package/dist/index.mjs +10 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/metafile-esm.json +1 -0
- package/dist/modules/tour.connects.d.mts +11 -0
- package/dist/modules/tour.connects.d.ts +11 -0
- package/dist/modules/tour.connects.js +65 -0
- package/dist/modules/tour.connects.mjs +7 -0
- package/dist/modules/tour.hooks.d.mts +8 -0
- package/dist/modules/tour.hooks.d.ts +8 -0
- package/dist/modules/tour.hooks.js +77 -0
- package/dist/modules/tour.hooks.mjs +8 -0
- package/dist/modules/tour.props.d.mts +31 -0
- package/dist/modules/tour.props.d.ts +31 -0
- package/dist/modules/tour.props.js +56 -0
- package/dist/modules/tour.props.mjs +9 -0
- package/dist/modules/tour.types.d.mts +50 -0
- package/dist/modules/tour.types.d.ts +50 -0
- package/dist/modules/tour.types.js +18 -0
- package/dist/modules/tour.types.mjs +0 -0
- package/dist/tour.d.mts +8 -0
- package/dist/tour.d.ts +8 -0
- package/dist/tour.js +295 -0
- package/dist/tour.mjs +10 -0
- package/package.json +42 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
4
|
+
|
|
5
|
+
// src/modules/tour.connects.ts
|
|
6
|
+
import { useId } from "@mekari/pixel3-utils";
|
|
7
|
+
function tourConnect(state, classes) {
|
|
8
|
+
const {
|
|
9
|
+
id,
|
|
10
|
+
steps,
|
|
11
|
+
stepIndex,
|
|
12
|
+
isDisableScroll,
|
|
13
|
+
isManual,
|
|
14
|
+
isDebug
|
|
15
|
+
} = state;
|
|
16
|
+
const idx = id != null ? id : `mp-tour-${useId()}`;
|
|
17
|
+
return {
|
|
18
|
+
id,
|
|
19
|
+
steps,
|
|
20
|
+
stepIndex,
|
|
21
|
+
isDisableScroll,
|
|
22
|
+
isManual,
|
|
23
|
+
isDebug,
|
|
24
|
+
rootProps: {
|
|
25
|
+
class: classes.root,
|
|
26
|
+
"data-pixel-component": "MpTour"
|
|
27
|
+
},
|
|
28
|
+
overlayProps: {
|
|
29
|
+
id: `${idx}-overlay`,
|
|
30
|
+
class: classes.overlay,
|
|
31
|
+
"data-pixel-component": "MpTourOverlay"
|
|
32
|
+
},
|
|
33
|
+
panelProps: {
|
|
34
|
+
id: `${idx}`,
|
|
35
|
+
class: classes.panel,
|
|
36
|
+
"data-pixel-component": "MpTourPanel"
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
__name(tourConnect, "tourConnect");
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
tourConnect
|
|
44
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/modules/tour.props.ts
|
|
2
|
+
import { declareEmit } from "@mekari/pixel3-utils";
|
|
3
|
+
var tourProps = {
|
|
4
|
+
id: {
|
|
5
|
+
type: String
|
|
6
|
+
},
|
|
7
|
+
steps: {
|
|
8
|
+
type: Array
|
|
9
|
+
},
|
|
10
|
+
stepIndex: {
|
|
11
|
+
type: Number
|
|
12
|
+
},
|
|
13
|
+
isDisableScroll: {
|
|
14
|
+
type: Boolean,
|
|
15
|
+
default: false
|
|
16
|
+
},
|
|
17
|
+
isManual: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
isDebug: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: false
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var tourEmits = declareEmit(["next", "prev", "close"]);
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
tourProps,
|
|
30
|
+
tourEmits
|
|
31
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useTour
|
|
3
|
+
} from "./chunk-TQSSSA7Q.mjs";
|
|
4
|
+
import {
|
|
5
|
+
tourEmits,
|
|
6
|
+
tourProps
|
|
7
|
+
} from "./chunk-7BC44YZN.mjs";
|
|
8
|
+
import {
|
|
9
|
+
__name
|
|
10
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
11
|
+
|
|
12
|
+
// src/tour.tsx
|
|
13
|
+
import { mergeProps as _mergeProps, createVNode as _createVNode } from "vue";
|
|
14
|
+
import { defineComponent, createApp, Teleport, ref, onMounted, computed, watch } from "vue";
|
|
15
|
+
import { createPopper } from "@popperjs/core";
|
|
16
|
+
var MpTour = defineComponent({
|
|
17
|
+
name: "MpTour",
|
|
18
|
+
props: tourProps,
|
|
19
|
+
emits: tourEmits,
|
|
20
|
+
setup(props, {
|
|
21
|
+
emit
|
|
22
|
+
}) {
|
|
23
|
+
const api = useTour(props);
|
|
24
|
+
const targetElement = ref();
|
|
25
|
+
const refElement = ref();
|
|
26
|
+
const index = ref(api.value.stepIndex || 0);
|
|
27
|
+
const getStepsLength = computed(() => api.value.steps && api.value.steps.length || 0);
|
|
28
|
+
const isLastStep = computed(() => index.value === getStepsLength.value);
|
|
29
|
+
const updateHighlight = /* @__PURE__ */ __name((action) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const target = targetElement.value;
|
|
32
|
+
const step = (_a = api.value.steps) == null ? void 0 : _a[index.value];
|
|
33
|
+
if (!target)
|
|
34
|
+
return;
|
|
35
|
+
const methods = {
|
|
36
|
+
add: () => {
|
|
37
|
+
target.style.zIndex = "9999";
|
|
38
|
+
target.style.position = "relative";
|
|
39
|
+
target.style.pointerEvents = "none";
|
|
40
|
+
if (step == null ? void 0 : step.isScrollIntoElement)
|
|
41
|
+
scrollToElement(step == null ? void 0 : step.offset);
|
|
42
|
+
if (step == null ? void 0 : step.isHighlighted) {
|
|
43
|
+
target.classList.add("tour-pulse");
|
|
44
|
+
createPulseAnimation(step == null ? void 0 : step.highlightColor);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
remove: () => {
|
|
48
|
+
target.style.zIndex = "";
|
|
49
|
+
target.style.position = "";
|
|
50
|
+
target.style.pointerEvents = "";
|
|
51
|
+
target.classList.remove("tour-pulse");
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
methods[action]();
|
|
55
|
+
}, "updateHighlight");
|
|
56
|
+
const scrollToElement = /* @__PURE__ */ __name((offset = 16) => {
|
|
57
|
+
if (targetElement.value) {
|
|
58
|
+
const top = targetElement.value.getBoundingClientRect().top + window.pageYOffset - offset;
|
|
59
|
+
window.scrollTo({
|
|
60
|
+
top,
|
|
61
|
+
behavior: "smooth"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, "scrollToElement");
|
|
65
|
+
const createStep = /* @__PURE__ */ __name(() => {
|
|
66
|
+
var _a;
|
|
67
|
+
if (isLastStep.value)
|
|
68
|
+
return;
|
|
69
|
+
updateHighlight("remove");
|
|
70
|
+
const step = (_a = api.value.steps) == null ? void 0 : _a[index.value];
|
|
71
|
+
if (!step)
|
|
72
|
+
return;
|
|
73
|
+
if (api.value.isDisableScroll)
|
|
74
|
+
document.body.style.overflow = "hidden";
|
|
75
|
+
targetElement.value = step.target ? document.querySelector(step.target) : null;
|
|
76
|
+
refElement.value = document.querySelector(`#${api.value.id}`);
|
|
77
|
+
if (api.value.isDebug) {
|
|
78
|
+
console.log("[MpTour] The target element:", targetElement.value);
|
|
79
|
+
console.log("[MpTour] The refs element:", refElement.value);
|
|
80
|
+
}
|
|
81
|
+
if (targetElement.value && refElement.value) {
|
|
82
|
+
updateHighlight("add");
|
|
83
|
+
createPopper(targetElement.value, refElement.value, {
|
|
84
|
+
modifiers: [{
|
|
85
|
+
name: "preventOverflow",
|
|
86
|
+
options: {
|
|
87
|
+
rootBoundary: "window"
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
name: "offset",
|
|
91
|
+
options: {
|
|
92
|
+
offset: [0, 16]
|
|
93
|
+
}
|
|
94
|
+
}],
|
|
95
|
+
placement: "bottom",
|
|
96
|
+
...step.options
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}, "createStep");
|
|
100
|
+
const createPulseAnimation = /* @__PURE__ */ __name((color = "dark") => {
|
|
101
|
+
const colorMap = {
|
|
102
|
+
dark: "35, 41, 51",
|
|
103
|
+
pink: "236, 72, 153",
|
|
104
|
+
blue: "59, 130, 240"
|
|
105
|
+
};
|
|
106
|
+
const isValidColor = /* @__PURE__ */ __name((color2) => {
|
|
107
|
+
return color2 in colorMap;
|
|
108
|
+
}, "isValidColor");
|
|
109
|
+
const [r, g, b] = isValidColor(color) ? colorMap[color].split(", ") : colorMap["dark"].split(", ");
|
|
110
|
+
const style = document.createElement("style");
|
|
111
|
+
style.textContent = `
|
|
112
|
+
.tour-pulse {
|
|
113
|
+
box-shadow: 0 0 0 0 rgba(${r}, ${g}, ${b}, 1);
|
|
114
|
+
animation: pulse 2s infinite;
|
|
115
|
+
}
|
|
116
|
+
@keyframes pulse {
|
|
117
|
+
0% { box-shadow: 0 0 0 0 rgba(${r}, ${g}, ${b}, 0.9); }
|
|
118
|
+
70% { box-shadow: 0 0 0 10px rgba(${r}, ${g}, ${b}, 0); }
|
|
119
|
+
100% { box-shadow: 0 0 0 0 rgba(${r}, ${g}, ${b}, 0); }
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
document.head.appendChild(style);
|
|
123
|
+
}, "createPulseAnimation");
|
|
124
|
+
const navigateStep = /* @__PURE__ */ __name((direction) => {
|
|
125
|
+
if (!api.value.isManual) {
|
|
126
|
+
if (direction === "next" && index.value < getStepsLength.value)
|
|
127
|
+
index.value += 1;
|
|
128
|
+
if (direction === "prev" && index.value > 0)
|
|
129
|
+
index.value -= 1;
|
|
130
|
+
}
|
|
131
|
+
updateHighlight("remove");
|
|
132
|
+
if (api.value.isDisableScroll)
|
|
133
|
+
document.body.style.overflow = "";
|
|
134
|
+
emit(direction, index.value);
|
|
135
|
+
}, "navigateStep");
|
|
136
|
+
const close = /* @__PURE__ */ __name(() => {
|
|
137
|
+
updateHighlight("remove");
|
|
138
|
+
if (api.value.isDisableScroll)
|
|
139
|
+
document.body.style.overflow = "";
|
|
140
|
+
emit("close", index.value);
|
|
141
|
+
}, "close");
|
|
142
|
+
watch(index, createStep);
|
|
143
|
+
onMounted(createStep);
|
|
144
|
+
return () => {
|
|
145
|
+
var _a, _b, _c;
|
|
146
|
+
return _createVNode("div", api.value.rootProps, [_createVNode("div", api.value.overlayProps, null), _createVNode("div", _mergeProps({
|
|
147
|
+
"id": api.value.id
|
|
148
|
+
}, api.value.panelProps, {
|
|
149
|
+
"style": {
|
|
150
|
+
position: "absolute",
|
|
151
|
+
top: !targetElement.value ? "50%" : void 0,
|
|
152
|
+
left: !targetElement.value ? "50%" : void 0,
|
|
153
|
+
transform: !targetElement.value ? "translate(-50%, -50%)" : void 0
|
|
154
|
+
}
|
|
155
|
+
}), [(_c = (_b = (_a = api.value.steps) == null ? void 0 : _a[index.value]) == null ? void 0 : _b.render) == null ? void 0 : _c.call(_b, () => navigateStep("next"), () => navigateStep("prev"), close)])]);
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
var PORTAL_ID = "pixel-tour-portal";
|
|
160
|
+
var createPortal = /* @__PURE__ */ __name(() => {
|
|
161
|
+
if (typeof window === "undefined")
|
|
162
|
+
return null;
|
|
163
|
+
let portalElement = document.getElementById(PORTAL_ID);
|
|
164
|
+
if (!portalElement) {
|
|
165
|
+
portalElement = document.createElement("div");
|
|
166
|
+
portalElement.id = PORTAL_ID;
|
|
167
|
+
portalElement.className = "Tour";
|
|
168
|
+
document.body.appendChild(portalElement);
|
|
169
|
+
}
|
|
170
|
+
return portalElement;
|
|
171
|
+
}, "createPortal");
|
|
172
|
+
var tour = /* @__PURE__ */ __name((isStart = false, steps, options) => {
|
|
173
|
+
var _a;
|
|
174
|
+
if (isStart) {
|
|
175
|
+
const portalElement = createPortal();
|
|
176
|
+
if (!portalElement)
|
|
177
|
+
return;
|
|
178
|
+
return createApp({
|
|
179
|
+
render() {
|
|
180
|
+
return _createVNode(Teleport, {
|
|
181
|
+
"to": `#${PORTAL_ID}`
|
|
182
|
+
}, {
|
|
183
|
+
default: () => [isStart && _createVNode(MpTour, {
|
|
184
|
+
"id": options == null ? void 0 : options.id,
|
|
185
|
+
"steps": steps,
|
|
186
|
+
"stepIndex": options == null ? void 0 : options.stepIndex,
|
|
187
|
+
"isDisableScroll": options == null ? void 0 : options.isDisableScroll,
|
|
188
|
+
"isManual": options == null ? void 0 : options.isManual,
|
|
189
|
+
"isDebug": options == null ? void 0 : options.isDebug,
|
|
190
|
+
"onNext": options == null ? void 0 : options.next,
|
|
191
|
+
"onPrev": options == null ? void 0 : options.prev,
|
|
192
|
+
"onClose": options == null ? void 0 : options.close
|
|
193
|
+
}, null)]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}).mount(document.createElement("div"));
|
|
197
|
+
}
|
|
198
|
+
(_a = document.getElementById(PORTAL_ID)) == null ? void 0 : _a.remove();
|
|
199
|
+
}, "tour");
|
|
200
|
+
|
|
201
|
+
export {
|
|
202
|
+
tour
|
|
203
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
tourConnect
|
|
3
|
+
} from "./chunk-5MGBFCZE.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "./chunk-QZ7VFGWC.mjs";
|
|
7
|
+
|
|
8
|
+
// src/modules/tour.hooks.ts
|
|
9
|
+
import { computed, ref } from "vue";
|
|
10
|
+
import { tourSlotRecipe } from "@mekari/pixel3-styled-system/recipes";
|
|
11
|
+
var useTour = /* @__PURE__ */ __name((props) => {
|
|
12
|
+
const context = ref(props);
|
|
13
|
+
const [value] = tourSlotRecipe.splitVariantProps(context.value);
|
|
14
|
+
const classes = tourSlotRecipe(value);
|
|
15
|
+
return computed(() => tourConnect(context.value, classes));
|
|
16
|
+
}, "useTour");
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
useTour
|
|
20
|
+
};
|
package/dist/index.d.mts
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
tour: () => tour
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
|
|
28
|
+
// src/tour.tsx
|
|
29
|
+
var import_vue2 = require("vue");
|
|
30
|
+
var import_vue3 = require("vue");
|
|
31
|
+
var import_core = require("@popperjs/core");
|
|
32
|
+
|
|
33
|
+
// src/modules/tour.props.ts
|
|
34
|
+
var import_pixel3_utils = require("@mekari/pixel3-utils");
|
|
35
|
+
var tourProps = {
|
|
36
|
+
id: {
|
|
37
|
+
type: String
|
|
38
|
+
},
|
|
39
|
+
steps: {
|
|
40
|
+
type: Array
|
|
41
|
+
},
|
|
42
|
+
stepIndex: {
|
|
43
|
+
type: Number
|
|
44
|
+
},
|
|
45
|
+
isDisableScroll: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false
|
|
48
|
+
},
|
|
49
|
+
isManual: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
53
|
+
isDebug: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: false
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var tourEmits = (0, import_pixel3_utils.declareEmit)(["next", "prev", "close"]);
|
|
59
|
+
|
|
60
|
+
// src/modules/tour.hooks.ts
|
|
61
|
+
var import_vue = require("vue");
|
|
62
|
+
var import_recipes = require("@mekari/pixel3-styled-system/recipes");
|
|
63
|
+
|
|
64
|
+
// src/modules/tour.connects.ts
|
|
65
|
+
var import_pixel3_utils2 = require("@mekari/pixel3-utils");
|
|
66
|
+
function tourConnect(state, classes) {
|
|
67
|
+
const {
|
|
68
|
+
id,
|
|
69
|
+
steps,
|
|
70
|
+
stepIndex,
|
|
71
|
+
isDisableScroll,
|
|
72
|
+
isManual,
|
|
73
|
+
isDebug
|
|
74
|
+
} = state;
|
|
75
|
+
const idx = id != null ? id : `mp-tour-${(0, import_pixel3_utils2.useId)()}`;
|
|
76
|
+
return {
|
|
77
|
+
id,
|
|
78
|
+
steps,
|
|
79
|
+
stepIndex,
|
|
80
|
+
isDisableScroll,
|
|
81
|
+
isManual,
|
|
82
|
+
isDebug,
|
|
83
|
+
rootProps: {
|
|
84
|
+
class: classes.root,
|
|
85
|
+
"data-pixel-component": "MpTour"
|
|
86
|
+
},
|
|
87
|
+
overlayProps: {
|
|
88
|
+
id: `${idx}-overlay`,
|
|
89
|
+
class: classes.overlay,
|
|
90
|
+
"data-pixel-component": "MpTourOverlay"
|
|
91
|
+
},
|
|
92
|
+
panelProps: {
|
|
93
|
+
id: `${idx}`,
|
|
94
|
+
class: classes.panel,
|
|
95
|
+
"data-pixel-component": "MpTourPanel"
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
__name(tourConnect, "tourConnect");
|
|
100
|
+
|
|
101
|
+
// src/modules/tour.hooks.ts
|
|
102
|
+
var useTour = /* @__PURE__ */ __name((props) => {
|
|
103
|
+
const context = (0, import_vue.ref)(props);
|
|
104
|
+
const [value] = import_recipes.tourSlotRecipe.splitVariantProps(context.value);
|
|
105
|
+
const classes = (0, import_recipes.tourSlotRecipe)(value);
|
|
106
|
+
return (0, import_vue.computed)(() => tourConnect(context.value, classes));
|
|
107
|
+
}, "useTour");
|
|
108
|
+
|
|
109
|
+
// src/tour.tsx
|
|
110
|
+
var MpTour = (0, import_vue3.defineComponent)({
|
|
111
|
+
name: "MpTour",
|
|
112
|
+
props: tourProps,
|
|
113
|
+
emits: tourEmits,
|
|
114
|
+
setup(props, {
|
|
115
|
+
emit
|
|
116
|
+
}) {
|
|
117
|
+
const api = useTour(props);
|
|
118
|
+
const targetElement = (0, import_vue3.ref)();
|
|
119
|
+
const refElement = (0, import_vue3.ref)();
|
|
120
|
+
const index = (0, import_vue3.ref)(api.value.stepIndex || 0);
|
|
121
|
+
const getStepsLength = (0, import_vue3.computed)(() => api.value.steps && api.value.steps.length || 0);
|
|
122
|
+
const isLastStep = (0, import_vue3.computed)(() => index.value === getStepsLength.value);
|
|
123
|
+
const updateHighlight = /* @__PURE__ */ __name((action) => {
|
|
124
|
+
var _a;
|
|
125
|
+
const target = targetElement.value;
|
|
126
|
+
const step = (_a = api.value.steps) == null ? void 0 : _a[index.value];
|
|
127
|
+
if (!target)
|
|
128
|
+
return;
|
|
129
|
+
const methods = {
|
|
130
|
+
add: () => {
|
|
131
|
+
target.style.zIndex = "9999";
|
|
132
|
+
target.style.position = "relative";
|
|
133
|
+
target.style.pointerEvents = "none";
|
|
134
|
+
if (step == null ? void 0 : step.isScrollIntoElement)
|
|
135
|
+
scrollToElement(step == null ? void 0 : step.offset);
|
|
136
|
+
if (step == null ? void 0 : step.isHighlighted) {
|
|
137
|
+
target.classList.add("tour-pulse");
|
|
138
|
+
createPulseAnimation(step == null ? void 0 : step.highlightColor);
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
remove: () => {
|
|
142
|
+
target.style.zIndex = "";
|
|
143
|
+
target.style.position = "";
|
|
144
|
+
target.style.pointerEvents = "";
|
|
145
|
+
target.classList.remove("tour-pulse");
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
methods[action]();
|
|
149
|
+
}, "updateHighlight");
|
|
150
|
+
const scrollToElement = /* @__PURE__ */ __name((offset = 16) => {
|
|
151
|
+
if (targetElement.value) {
|
|
152
|
+
const top = targetElement.value.getBoundingClientRect().top + window.pageYOffset - offset;
|
|
153
|
+
window.scrollTo({
|
|
154
|
+
top,
|
|
155
|
+
behavior: "smooth"
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}, "scrollToElement");
|
|
159
|
+
const createStep = /* @__PURE__ */ __name(() => {
|
|
160
|
+
var _a;
|
|
161
|
+
if (isLastStep.value)
|
|
162
|
+
return;
|
|
163
|
+
updateHighlight("remove");
|
|
164
|
+
const step = (_a = api.value.steps) == null ? void 0 : _a[index.value];
|
|
165
|
+
if (!step)
|
|
166
|
+
return;
|
|
167
|
+
if (api.value.isDisableScroll)
|
|
168
|
+
document.body.style.overflow = "hidden";
|
|
169
|
+
targetElement.value = step.target ? document.querySelector(step.target) : null;
|
|
170
|
+
refElement.value = document.querySelector(`#${api.value.id}`);
|
|
171
|
+
if (api.value.isDebug) {
|
|
172
|
+
console.log("[MpTour] The target element:", targetElement.value);
|
|
173
|
+
console.log("[MpTour] The refs element:", refElement.value);
|
|
174
|
+
}
|
|
175
|
+
if (targetElement.value && refElement.value) {
|
|
176
|
+
updateHighlight("add");
|
|
177
|
+
(0, import_core.createPopper)(targetElement.value, refElement.value, {
|
|
178
|
+
modifiers: [{
|
|
179
|
+
name: "preventOverflow",
|
|
180
|
+
options: {
|
|
181
|
+
rootBoundary: "window"
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
name: "offset",
|
|
185
|
+
options: {
|
|
186
|
+
offset: [0, 16]
|
|
187
|
+
}
|
|
188
|
+
}],
|
|
189
|
+
placement: "bottom",
|
|
190
|
+
...step.options
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}, "createStep");
|
|
194
|
+
const createPulseAnimation = /* @__PURE__ */ __name((color = "dark") => {
|
|
195
|
+
const colorMap = {
|
|
196
|
+
dark: "35, 41, 51",
|
|
197
|
+
pink: "236, 72, 153",
|
|
198
|
+
blue: "59, 130, 240"
|
|
199
|
+
};
|
|
200
|
+
const isValidColor = /* @__PURE__ */ __name((color2) => {
|
|
201
|
+
return color2 in colorMap;
|
|
202
|
+
}, "isValidColor");
|
|
203
|
+
const [r, g, b] = isValidColor(color) ? colorMap[color].split(", ") : colorMap["dark"].split(", ");
|
|
204
|
+
const style = document.createElement("style");
|
|
205
|
+
style.textContent = `
|
|
206
|
+
.tour-pulse {
|
|
207
|
+
box-shadow: 0 0 0 0 rgba(${r}, ${g}, ${b}, 1);
|
|
208
|
+
animation: pulse 2s infinite;
|
|
209
|
+
}
|
|
210
|
+
@keyframes pulse {
|
|
211
|
+
0% { box-shadow: 0 0 0 0 rgba(${r}, ${g}, ${b}, 0.9); }
|
|
212
|
+
70% { box-shadow: 0 0 0 10px rgba(${r}, ${g}, ${b}, 0); }
|
|
213
|
+
100% { box-shadow: 0 0 0 0 rgba(${r}, ${g}, ${b}, 0); }
|
|
214
|
+
}
|
|
215
|
+
`;
|
|
216
|
+
document.head.appendChild(style);
|
|
217
|
+
}, "createPulseAnimation");
|
|
218
|
+
const navigateStep = /* @__PURE__ */ __name((direction) => {
|
|
219
|
+
if (!api.value.isManual) {
|
|
220
|
+
if (direction === "next" && index.value < getStepsLength.value)
|
|
221
|
+
index.value += 1;
|
|
222
|
+
if (direction === "prev" && index.value > 0)
|
|
223
|
+
index.value -= 1;
|
|
224
|
+
}
|
|
225
|
+
updateHighlight("remove");
|
|
226
|
+
if (api.value.isDisableScroll)
|
|
227
|
+
document.body.style.overflow = "";
|
|
228
|
+
emit(direction, index.value);
|
|
229
|
+
}, "navigateStep");
|
|
230
|
+
const close = /* @__PURE__ */ __name(() => {
|
|
231
|
+
updateHighlight("remove");
|
|
232
|
+
if (api.value.isDisableScroll)
|
|
233
|
+
document.body.style.overflow = "";
|
|
234
|
+
emit("close", index.value);
|
|
235
|
+
}, "close");
|
|
236
|
+
(0, import_vue3.watch)(index, createStep);
|
|
237
|
+
(0, import_vue3.onMounted)(createStep);
|
|
238
|
+
return () => {
|
|
239
|
+
var _a, _b, _c;
|
|
240
|
+
return (0, import_vue2.createVNode)("div", api.value.rootProps, [(0, import_vue2.createVNode)("div", api.value.overlayProps, null), (0, import_vue2.createVNode)("div", (0, import_vue2.mergeProps)({
|
|
241
|
+
"id": api.value.id
|
|
242
|
+
}, api.value.panelProps, {
|
|
243
|
+
"style": {
|
|
244
|
+
position: "absolute",
|
|
245
|
+
top: !targetElement.value ? "50%" : void 0,
|
|
246
|
+
left: !targetElement.value ? "50%" : void 0,
|
|
247
|
+
transform: !targetElement.value ? "translate(-50%, -50%)" : void 0
|
|
248
|
+
}
|
|
249
|
+
}), [(_c = (_b = (_a = api.value.steps) == null ? void 0 : _a[index.value]) == null ? void 0 : _b.render) == null ? void 0 : _c.call(_b, () => navigateStep("next"), () => navigateStep("prev"), close)])]);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
var PORTAL_ID = "pixel-tour-portal";
|
|
254
|
+
var createPortal = /* @__PURE__ */ __name(() => {
|
|
255
|
+
if (typeof window === "undefined")
|
|
256
|
+
return null;
|
|
257
|
+
let portalElement = document.getElementById(PORTAL_ID);
|
|
258
|
+
if (!portalElement) {
|
|
259
|
+
portalElement = document.createElement("div");
|
|
260
|
+
portalElement.id = PORTAL_ID;
|
|
261
|
+
portalElement.className = "Tour";
|
|
262
|
+
document.body.appendChild(portalElement);
|
|
263
|
+
}
|
|
264
|
+
return portalElement;
|
|
265
|
+
}, "createPortal");
|
|
266
|
+
var tour = /* @__PURE__ */ __name((isStart = false, steps, options) => {
|
|
267
|
+
var _a;
|
|
268
|
+
if (isStart) {
|
|
269
|
+
const portalElement = createPortal();
|
|
270
|
+
if (!portalElement)
|
|
271
|
+
return;
|
|
272
|
+
return (0, import_vue3.createApp)({
|
|
273
|
+
render() {
|
|
274
|
+
return (0, import_vue2.createVNode)(import_vue3.Teleport, {
|
|
275
|
+
"to": `#${PORTAL_ID}`
|
|
276
|
+
}, {
|
|
277
|
+
default: () => [isStart && (0, import_vue2.createVNode)(MpTour, {
|
|
278
|
+
"id": options == null ? void 0 : options.id,
|
|
279
|
+
"steps": steps,
|
|
280
|
+
"stepIndex": options == null ? void 0 : options.stepIndex,
|
|
281
|
+
"isDisableScroll": options == null ? void 0 : options.isDisableScroll,
|
|
282
|
+
"isManual": options == null ? void 0 : options.isManual,
|
|
283
|
+
"isDebug": options == null ? void 0 : options.isDebug,
|
|
284
|
+
"onNext": options == null ? void 0 : options.next,
|
|
285
|
+
"onPrev": options == null ? void 0 : options.prev,
|
|
286
|
+
"onClose": options == null ? void 0 : options.close
|
|
287
|
+
}, null)]
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
}).mount(document.createElement("div"));
|
|
291
|
+
}
|
|
292
|
+
(_a = document.getElementById(PORTAL_ID)) == null ? void 0 : _a.remove();
|
|
293
|
+
}, "tour");
|
|
294
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
295
|
+
0 && (module.exports = {
|
|
296
|
+
tour
|
|
297
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/modules/tour.props.ts":{"bytes":858,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"./tour.types","kind":"import-statement","external":true}],"format":"esm"},"src/modules/tour.connects.ts":{"bytes":911,"imports":[{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"./tour.types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/modules/tour.hooks.ts":{"bytes":587,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"src/modules/tour.connects.ts","kind":"import-statement","original":"./tour.connects"},{"path":"./tour.types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/tour.tsx":{"bytes":6691,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@popperjs/core","kind":"import-statement","external":true},{"path":"src/modules/tour.props.ts","kind":"import-statement","original":"./modules/tour.props"},{"path":"src/modules/tour.hooks.ts","kind":"import-statement","original":"./modules/tour.hooks"},{"path":"./modules/tour.types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":231,"imports":[{"path":"src/tour.tsx","kind":"import-statement","original":"./tour"}],"format":"esm"},"src/modules/tour.types.ts":{"bytes":1313,"imports":[{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"@popperjs/core","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@popperjs/core","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":113},"src/tour.tsx":{"bytesInOutput":7290},"src/modules/tour.props.ts":{"bytesInOutput":436},"src/modules/tour.hooks.ts":{"bytesInOutput":435},"src/modules/tour.connects.ts":{"bytesInOutput":756}},"bytes":10191},"dist/tour.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@popperjs/core","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true},{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/tour.tsx","inputs":{"src/tour.tsx":{"bytesInOutput":7406},"src/modules/tour.props.ts":{"bytesInOutput":436},"src/modules/tour.hooks.ts":{"bytesInOutput":435},"src/modules/tour.connects.ts":{"bytesInOutput":756}},"bytes":10177},"dist/modules/tour.connects.js":{"imports":[{"path":"@mekari/pixel3-utils","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/modules/tour.connects.ts","inputs":{"src/modules/tour.connects.ts":{"bytesInOutput":911}},"bytes":1938},"dist/modules/tour.hooks.js":{"imports":[{"path":"vue","kind":"require-call","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"require-call","external":true},{"path":"@mekari/pixel3-utils","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/modules/tour.hooks.ts","inputs":{"src/modules/tour.hooks.ts":{"bytesInOutput":575},"src/modules/tour.connects.ts":{"bytesInOutput":754}},"bytes":2412},"dist/modules/tour.props.js":{"imports":[{"path":"@mekari/pixel3-utils","kind":"require-call","external":true}],"exports":[],"entryPoint":"src/modules/tour.props.ts","inputs":{"src/modules/tour.props.ts":{"bytesInOutput":610}},"bytes":1555},"dist/modules/tour.types.js":{"imports":[],"exports":[],"entryPoint":"src/modules/tour.types.ts","inputs":{"src/modules/tour.types.ts":{"bytesInOutput":80}},"bytes":781}}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/modules/tour.props.ts":{"bytes":858,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"./tour.types","kind":"import-statement","external":true}],"format":"esm"},"src/modules/tour.connects.ts":{"bytes":911,"imports":[{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"./tour.types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/modules/tour.hooks.ts":{"bytes":587,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true},{"path":"src/modules/tour.connects.ts","kind":"import-statement","original":"./tour.connects"},{"path":"./tour.types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/tour.tsx":{"bytes":6691,"imports":[{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@popperjs/core","kind":"import-statement","external":true},{"path":"src/modules/tour.props.ts","kind":"import-statement","original":"./modules/tour.props"},{"path":"src/modules/tour.hooks.ts","kind":"import-statement","original":"./modules/tour.hooks"},{"path":"./modules/tour.types","kind":"import-statement","external":true},{"path":"<runtime>","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":231,"imports":[{"path":"src/tour.tsx","kind":"import-statement","original":"./tour"}],"format":"esm"},"src/modules/tour.types.ts":{"bytes":1313,"imports":[{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true},{"path":"@popperjs/core","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/index.mjs":{"imports":[{"path":"dist/chunk-LCGHHNKQ.mjs","kind":"import-statement"},{"path":"dist/chunk-TQSSSA7Q.mjs","kind":"import-statement"},{"path":"dist/chunk-5MGBFCZE.mjs","kind":"import-statement"},{"path":"dist/chunk-7BC44YZN.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["tour"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":190},"dist/tour.mjs":{"imports":[{"path":"dist/chunk-LCGHHNKQ.mjs","kind":"import-statement"},{"path":"dist/chunk-TQSSSA7Q.mjs","kind":"import-statement"},{"path":"dist/chunk-5MGBFCZE.mjs","kind":"import-statement"},{"path":"dist/chunk-7BC44YZN.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["tour"],"entryPoint":"src/tour.tsx","inputs":{},"bytes":190},"dist/chunk-LCGHHNKQ.mjs":{"imports":[{"path":"dist/chunk-TQSSSA7Q.mjs","kind":"import-statement"},{"path":"dist/chunk-7BC44YZN.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"vue","kind":"import-statement","external":true},{"path":"@popperjs/core","kind":"import-statement","external":true}],"exports":["tour"],"inputs":{"src/tour.tsx":{"bytesInOutput":7117}},"bytes":7318},"dist/modules/tour.connects.mjs":{"imports":[{"path":"dist/chunk-5MGBFCZE.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["tourConnect"],"entryPoint":"src/modules/tour.connects.ts","inputs":{},"bytes":113},"dist/modules/tour.hooks.mjs":{"imports":[{"path":"dist/chunk-TQSSSA7Q.mjs","kind":"import-statement"},{"path":"dist/chunk-5MGBFCZE.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["useTour"],"entryPoint":"src/modules/tour.hooks.ts","inputs":{},"bytes":137},"dist/chunk-TQSSSA7Q.mjs":{"imports":[{"path":"dist/chunk-5MGBFCZE.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"},{"path":"vue","kind":"import-statement","external":true},{"path":"@mekari/pixel3-styled-system/recipes","kind":"import-statement","external":true}],"exports":["useTour"],"inputs":{"src/modules/tour.hooks.ts":{"bytesInOutput":373}},"bytes":529},"dist/chunk-5MGBFCZE.mjs":{"imports":[{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"},{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true}],"exports":["tourConnect"],"inputs":{"src/modules/tour.connects.ts":{"bytesInOutput":716}},"bytes":825},"dist/modules/tour.props.mjs":{"imports":[{"path":"dist/chunk-7BC44YZN.mjs","kind":"import-statement"},{"path":"dist/chunk-QZ7VFGWC.mjs","kind":"import-statement"}],"exports":["tourEmits","tourProps"],"entryPoint":"src/modules/tour.props.ts","inputs":{},"bytes":135},"dist/chunk-7BC44YZN.mjs":{"imports":[{"path":"@mekari/pixel3-utils","kind":"import-statement","external":true}],"exports":["tourEmits","tourProps"],"inputs":{"src/modules/tour.props.ts":{"bytesInOutput":404}},"bytes":471},"dist/chunk-QZ7VFGWC.mjs":{"imports":[],"exports":["__name"],"inputs":{},"bytes":151},"dist/modules/tour.types.mjs":{"imports":[],"exports":[],"entryPoint":"src/modules/tour.types.ts","inputs":{"src/modules/tour.types.ts":{"bytesInOutput":0}},"bytes":0}}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TourState, TourClasses, TourApiMachine } from './tour.types.mjs';
|
|
2
|
+
import '@mekari/pixel3-utils';
|
|
3
|
+
import '@popperjs/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Exported tour connects.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
declare function tourConnect(state: TourState, classes: TourClasses): TourApiMachine;
|
|
10
|
+
|
|
11
|
+
export { tourConnect };
|