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