@pablo2410/shared-ui 0.24.0 → 0.25.1
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/README.md +51 -0
- package/dist/{chunk-4QJMLQSH.js → chunk-7LI4Y6WT.js} +21 -2
- package/dist/chunk-7LI4Y6WT.js.map +1 -0
- package/dist/chunk-LUQAR6NB.js +1206 -0
- package/dist/chunk-LUQAR6NB.js.map +1 -0
- package/dist/{chunk-4ERWOH67.js → chunk-MGTOQY6O.js} +2 -2
- package/dist/{chunk-S4UQSTZN.js → chunk-UQUMDBCZ.js} +8 -2
- package/dist/chunk-UQUMDBCZ.js.map +1 -0
- package/dist/components/index.js +3 -3
- package/dist/hierarchy/index.js +1 -1
- package/dist/layout/index.js +4 -3
- package/dist/reporting/index.js +3 -3
- package/dist/services/index.d.ts +18 -2
- package/dist/services/index.js +2 -2
- package/dist/shell/index.js +5 -4
- package/dist/shell/index.js.map +1 -1
- package/dist/shell/oplytics-shell.css +1 -1
- package/dist/tour/index.d.ts +197 -1
- package/dist/tour/index.js +55 -601
- package/dist/tour/index.js.map +1 -1
- package/package.json +15 -9
- package/dist/chunk-4QJMLQSH.js.map +0 -1
- package/dist/chunk-S4UQSTZN.js.map +0 -1
- /package/dist/{chunk-4ERWOH67.js.map → chunk-MGTOQY6O.js.map} +0 -0
package/dist/tour/index.js
CHANGED
|
@@ -1,609 +1,63 @@
|
|
|
1
|
-
// src/tour/TourShell.tsx
|
|
2
|
-
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
3
1
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
const domRect = el.getBoundingClientRect();
|
|
37
|
-
setRect({
|
|
38
|
-
top: domRect.top,
|
|
39
|
-
left: domRect.left,
|
|
40
|
-
width: domRect.width,
|
|
41
|
-
height: domRect.height
|
|
42
|
-
});
|
|
43
|
-
setFound(true);
|
|
44
|
-
if (scrolledForSelector.current !== selector) {
|
|
45
|
-
scrolledForSelector.current = selector;
|
|
46
|
-
el.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
measure();
|
|
50
|
-
const initialFrame = requestAnimationFrame(measure);
|
|
51
|
-
const onResize = () => {
|
|
52
|
-
if (resizeTimer) clearTimeout(resizeTimer);
|
|
53
|
-
resizeTimer = setTimeout(measure, RESIZE_DEBOUNCE_MS);
|
|
54
|
-
};
|
|
55
|
-
const onScroll = () => measure();
|
|
56
|
-
window.addEventListener("resize", onResize);
|
|
57
|
-
window.addEventListener("scroll", onScroll, { capture: true });
|
|
58
|
-
const observer = new MutationObserver(measure);
|
|
59
|
-
observer.observe(document.body, {
|
|
60
|
-
childList: true,
|
|
61
|
-
subtree: true,
|
|
62
|
-
attributes: true
|
|
63
|
-
});
|
|
64
|
-
return () => {
|
|
65
|
-
cancelled = true;
|
|
66
|
-
cancelAnimationFrame(initialFrame);
|
|
67
|
-
if (resizeTimer) clearTimeout(resizeTimer);
|
|
68
|
-
window.removeEventListener("resize", onResize);
|
|
69
|
-
window.removeEventListener("scroll", onScroll, { capture: true });
|
|
70
|
-
observer?.disconnect();
|
|
71
|
-
};
|
|
72
|
-
}, [selector]);
|
|
73
|
-
return { rect, found };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/tour/spotlightMath.ts
|
|
77
|
-
function computeSpotlightFrame(target, viewport) {
|
|
78
|
-
const targetBottom = target.top + target.height;
|
|
79
|
-
const targetRight = target.left + target.width;
|
|
80
|
-
return {
|
|
81
|
-
// Full-width strip above the target.
|
|
82
|
-
top: {
|
|
83
|
-
top: 0,
|
|
84
|
-
left: 0,
|
|
85
|
-
width: viewport.width,
|
|
86
|
-
height: Math.max(0, target.top)
|
|
87
|
-
},
|
|
88
|
-
// Full-width strip below the target.
|
|
89
|
-
bottom: {
|
|
90
|
-
top: targetBottom,
|
|
91
|
-
left: 0,
|
|
92
|
-
width: viewport.width,
|
|
93
|
-
height: Math.max(0, viewport.height - targetBottom)
|
|
94
|
-
},
|
|
95
|
-
// Strip to the left of the target, spanning only the target's own row
|
|
96
|
-
// (the top/bottom strips already cover the rest of those rows).
|
|
97
|
-
left: {
|
|
98
|
-
top: target.top,
|
|
99
|
-
left: 0,
|
|
100
|
-
width: Math.max(0, target.left),
|
|
101
|
-
height: target.height
|
|
102
|
-
},
|
|
103
|
-
// Strip to the right of the target, same row-only span as `left`.
|
|
104
|
-
right: {
|
|
105
|
-
top: target.top,
|
|
106
|
-
left: targetRight,
|
|
107
|
-
width: Math.max(0, viewport.width - targetRight),
|
|
108
|
-
height: target.height
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
var FALLBACK_ORDER = {
|
|
113
|
-
bottom: ["bottom", "top", "right", "left"],
|
|
114
|
-
top: ["top", "bottom", "right", "left"],
|
|
115
|
-
right: ["right", "left", "bottom", "top"],
|
|
116
|
-
left: ["left", "right", "bottom", "top"]
|
|
117
|
-
};
|
|
118
|
-
var AUTO_ORDER = FALLBACK_ORDER.bottom;
|
|
119
|
-
var PANEL_GAP = 12;
|
|
120
|
-
function computePanelPosition(target, panelSize, viewport, placement = "auto") {
|
|
121
|
-
const order = placement === "auto" ? AUTO_ORDER : FALLBACK_ORDER[placement];
|
|
122
|
-
for (const candidate of order) {
|
|
123
|
-
const pos2 = placeAt(candidate, target, panelSize);
|
|
124
|
-
if (fits(pos2, panelSize, viewport)) {
|
|
125
|
-
return { ...pos2, placement: candidate };
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
const fallback = order[0];
|
|
129
|
-
const pos = placeAt(fallback, target, panelSize);
|
|
130
|
-
return {
|
|
131
|
-
top: clamp(pos.top, 0, Math.max(0, viewport.height - panelSize.height)),
|
|
132
|
-
left: clamp(pos.left, 0, Math.max(0, viewport.width - panelSize.width)),
|
|
133
|
-
placement: fallback
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
function placeAt(side, target, panelSize) {
|
|
137
|
-
const targetCenterX = target.left + target.width / 2;
|
|
138
|
-
const targetCenterY = target.top + target.height / 2;
|
|
139
|
-
switch (side) {
|
|
140
|
-
case "bottom":
|
|
141
|
-
return {
|
|
142
|
-
top: target.top + target.height + PANEL_GAP,
|
|
143
|
-
left: targetCenterX - panelSize.width / 2
|
|
144
|
-
};
|
|
145
|
-
case "top":
|
|
146
|
-
return {
|
|
147
|
-
top: target.top - panelSize.height - PANEL_GAP,
|
|
148
|
-
left: targetCenterX - panelSize.width / 2
|
|
149
|
-
};
|
|
150
|
-
case "right":
|
|
151
|
-
return {
|
|
152
|
-
top: targetCenterY - panelSize.height / 2,
|
|
153
|
-
left: target.left + target.width + PANEL_GAP
|
|
154
|
-
};
|
|
155
|
-
case "left":
|
|
156
|
-
return {
|
|
157
|
-
top: targetCenterY - panelSize.height / 2,
|
|
158
|
-
left: target.left - panelSize.width - PANEL_GAP
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
function fits(pos, panelSize, viewport) {
|
|
163
|
-
return pos.top >= 0 && pos.left >= 0 && pos.top + panelSize.height <= viewport.height && pos.left + panelSize.width <= viewport.width;
|
|
164
|
-
}
|
|
165
|
-
function clamp(value, min, max) {
|
|
166
|
-
return Math.min(Math.max(value, min), max);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// src/tour/TourShell.tsx
|
|
170
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
171
|
-
var defaultSkin = {
|
|
172
|
-
accent: "#8C34E9",
|
|
173
|
-
overlayBg: "rgba(10,14,26,0.72)",
|
|
174
|
-
panelBg: "#0e1624",
|
|
175
|
-
panelBorder: "1px solid #1e2738",
|
|
176
|
-
mutedText: "#596475",
|
|
177
|
-
bodyText: "#c0c6d0",
|
|
178
|
-
softText: "#8890a0"
|
|
179
|
-
};
|
|
180
|
-
var SPOTLIGHT_PANEL_SIZE = { width: 320, height: 280 };
|
|
181
|
-
function TourShell({
|
|
182
|
-
step,
|
|
183
|
-
index,
|
|
184
|
-
total,
|
|
185
|
-
isFirst,
|
|
186
|
-
isLast,
|
|
187
|
-
onNext,
|
|
188
|
-
onBack,
|
|
189
|
-
onDismiss,
|
|
190
|
-
narration,
|
|
191
|
-
narrationPending,
|
|
192
|
-
children,
|
|
193
|
-
skin = defaultSkin,
|
|
194
|
-
orb,
|
|
195
|
-
onSpotlightTargetActivated
|
|
196
|
-
}) {
|
|
197
|
-
const panelRef = useRef2(null);
|
|
198
|
-
const { rect, found } = useSpotlight(step.spotlight?.selector ?? null);
|
|
199
|
-
const isSpotlight = Boolean(step.spotlight) && found && rect !== null;
|
|
200
|
-
useEffect2(() => {
|
|
201
|
-
const onKeyDown = (e) => {
|
|
202
|
-
if (e.key === "Escape") onDismiss();
|
|
203
|
-
};
|
|
204
|
-
document.addEventListener("keydown", onKeyDown);
|
|
205
|
-
return () => document.removeEventListener("keydown", onKeyDown);
|
|
206
|
-
}, [onDismiss]);
|
|
207
|
-
useEffect2(() => {
|
|
208
|
-
panelRef.current?.focus();
|
|
209
|
-
}, [step.id]);
|
|
210
|
-
useEffect2(() => {
|
|
211
|
-
if (!isSpotlight || !onSpotlightTargetActivated || !step.spotlight) return;
|
|
212
|
-
const selector = step.spotlight.selector;
|
|
213
|
-
const onClickCapture = (e) => {
|
|
214
|
-
const target = e.target;
|
|
215
|
-
if (target?.closest(`[data-tour-target="${selector}"]`)) {
|
|
216
|
-
onSpotlightTargetActivated();
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
document.addEventListener("click", onClickCapture, { capture: true });
|
|
220
|
-
return () => document.removeEventListener("click", onClickCapture, {
|
|
221
|
-
capture: true
|
|
222
|
-
});
|
|
223
|
-
}, [isSpotlight, onSpotlightTargetActivated, step.spotlight]);
|
|
224
|
-
if (isSpotlight && rect) {
|
|
225
|
-
const viewport = { width: window.innerWidth, height: window.innerHeight };
|
|
226
|
-
const frame = computeSpotlightFrame(rect, viewport);
|
|
227
|
-
const panelPos = computePanelPosition(
|
|
228
|
-
rect,
|
|
229
|
-
SPOTLIGHT_PANEL_SIZE,
|
|
230
|
-
viewport,
|
|
231
|
-
step.spotlight?.placement ?? "auto"
|
|
232
|
-
);
|
|
233
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
234
|
-
["top", "bottom", "left", "right"].map((side) => {
|
|
235
|
-
const segment = frame[side];
|
|
236
|
-
if (segment.width <= 0 || segment.height <= 0) return null;
|
|
237
|
-
return /* @__PURE__ */ jsx(
|
|
238
|
-
"div",
|
|
239
|
-
{
|
|
240
|
-
className: "fixed z-50",
|
|
241
|
-
style: {
|
|
242
|
-
top: segment.top,
|
|
243
|
-
left: segment.left,
|
|
244
|
-
width: segment.width,
|
|
245
|
-
height: segment.height,
|
|
246
|
-
background: skin.overlayBg
|
|
247
|
-
},
|
|
248
|
-
onClick: onDismiss
|
|
249
|
-
},
|
|
250
|
-
side
|
|
251
|
-
);
|
|
252
|
-
}),
|
|
253
|
-
/* @__PURE__ */ jsx(
|
|
254
|
-
"div",
|
|
255
|
-
{
|
|
256
|
-
className: "fixed z-50 rounded-xl pointer-events-none transition-all",
|
|
257
|
-
style: {
|
|
258
|
-
top: rect.top - 4,
|
|
259
|
-
left: rect.left - 4,
|
|
260
|
-
width: rect.width + 8,
|
|
261
|
-
height: rect.height + 8,
|
|
262
|
-
boxShadow: `0 0 0 2px ${skin.accent}, 0 0 24px 4px ${skin.accent}66`
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
),
|
|
266
|
-
/* @__PURE__ */ jsxs(
|
|
267
|
-
"div",
|
|
268
|
-
{
|
|
269
|
-
ref: panelRef,
|
|
270
|
-
tabIndex: -1,
|
|
271
|
-
role: "dialog",
|
|
272
|
-
"aria-modal": "true",
|
|
273
|
-
"aria-label": step.label,
|
|
274
|
-
className: "fixed z-50 rounded-xl overflow-hidden flex flex-col outline-none",
|
|
275
|
-
style: {
|
|
276
|
-
top: panelPos.top,
|
|
277
|
-
left: panelPos.left,
|
|
278
|
-
width: SPOTLIGHT_PANEL_SIZE.width,
|
|
279
|
-
maxHeight: SPOTLIGHT_PANEL_SIZE.height,
|
|
280
|
-
background: skin.panelBg,
|
|
281
|
-
border: skin.panelBorder
|
|
282
|
-
},
|
|
283
|
-
children: [
|
|
284
|
-
/* @__PURE__ */ jsx(TourShellHeader, { step, orb, onDismiss }),
|
|
285
|
-
/* @__PURE__ */ jsx(TourShellStepDots, { total, index, skin }),
|
|
286
|
-
/* @__PURE__ */ jsx("div", { className: "overflow-y-auto px-4 py-3 space-y-3", children: /* @__PURE__ */ jsx(
|
|
287
|
-
TourShellBody,
|
|
288
|
-
{
|
|
289
|
-
step,
|
|
290
|
-
narration,
|
|
291
|
-
narrationPending,
|
|
292
|
-
skin,
|
|
293
|
-
children
|
|
294
|
-
}
|
|
295
|
-
) }),
|
|
296
|
-
/* @__PURE__ */ jsx(
|
|
297
|
-
TourShellFooter,
|
|
298
|
-
{
|
|
299
|
-
isFirst,
|
|
300
|
-
isLast,
|
|
301
|
-
onNext,
|
|
302
|
-
onBack,
|
|
303
|
-
onDismiss,
|
|
304
|
-
skin
|
|
305
|
-
}
|
|
306
|
-
)
|
|
307
|
-
]
|
|
308
|
-
}
|
|
309
|
-
)
|
|
310
|
-
] });
|
|
311
|
-
}
|
|
312
|
-
return /* @__PURE__ */ jsx(
|
|
313
|
-
"div",
|
|
314
|
-
{
|
|
315
|
-
className: "fixed inset-0 z-50 flex items-center justify-center p-4",
|
|
316
|
-
style: { background: skin.overlayBg },
|
|
317
|
-
onClick: (e) => {
|
|
318
|
-
if (e.target === e.currentTarget) onDismiss();
|
|
319
|
-
},
|
|
320
|
-
children: /* @__PURE__ */ jsxs(
|
|
321
|
-
"div",
|
|
322
|
-
{
|
|
323
|
-
ref: panelRef,
|
|
324
|
-
tabIndex: -1,
|
|
325
|
-
role: "dialog",
|
|
326
|
-
"aria-modal": "true",
|
|
327
|
-
"aria-label": step.label,
|
|
328
|
-
className: "w-full max-w-md rounded-xl overflow-hidden flex flex-col max-h-[85vh] outline-none",
|
|
329
|
-
style: { background: skin.panelBg, border: skin.panelBorder },
|
|
330
|
-
children: [
|
|
331
|
-
/* @__PURE__ */ jsx(TourShellHeader, { step, orb, onDismiss }),
|
|
332
|
-
/* @__PURE__ */ jsx(TourShellStepDots, { total, index, skin }),
|
|
333
|
-
/* @__PURE__ */ jsx("div", { className: "overflow-y-auto px-5 py-4 space-y-4", children: /* @__PURE__ */ jsx(
|
|
334
|
-
TourShellBody,
|
|
335
|
-
{
|
|
336
|
-
step,
|
|
337
|
-
narration,
|
|
338
|
-
narrationPending,
|
|
339
|
-
skin,
|
|
340
|
-
children
|
|
341
|
-
}
|
|
342
|
-
) }),
|
|
343
|
-
/* @__PURE__ */ jsx(
|
|
344
|
-
TourShellFooter,
|
|
345
|
-
{
|
|
346
|
-
isFirst,
|
|
347
|
-
isLast,
|
|
348
|
-
onNext,
|
|
349
|
-
onBack,
|
|
350
|
-
onDismiss,
|
|
351
|
-
skin
|
|
352
|
-
}
|
|
353
|
-
)
|
|
354
|
-
]
|
|
355
|
-
}
|
|
356
|
-
)
|
|
357
|
-
}
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
function TourShellHeader({
|
|
361
|
-
step,
|
|
362
|
-
orb,
|
|
363
|
-
onDismiss
|
|
364
|
-
}) {
|
|
365
|
-
return /* @__PURE__ */ jsxs(
|
|
366
|
-
"div",
|
|
367
|
-
{
|
|
368
|
-
className: "flex items-center justify-between gap-3 px-5 py-4 shrink-0",
|
|
369
|
-
style: {
|
|
370
|
-
background: "linear-gradient(135deg, #2a1450 0%, #1a0e33 100%)"
|
|
371
|
-
},
|
|
372
|
-
children: [
|
|
373
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 min-w-0", children: [
|
|
374
|
-
orb,
|
|
375
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm font-bold text-white truncate", children: step.label })
|
|
376
|
-
] }),
|
|
377
|
-
/* @__PURE__ */ jsx(
|
|
378
|
-
"button",
|
|
379
|
-
{
|
|
380
|
-
onClick: onDismiss,
|
|
381
|
-
className: "p-1 rounded hover:bg-white/10 transition-colors shrink-0",
|
|
382
|
-
title: "Skip tour",
|
|
383
|
-
children: /* @__PURE__ */ jsx(X, { size: 16, className: "text-white/70" })
|
|
384
|
-
}
|
|
385
|
-
)
|
|
386
|
-
]
|
|
387
|
-
}
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
|
-
function TourShellStepDots({
|
|
391
|
-
total,
|
|
392
|
-
index,
|
|
393
|
-
skin
|
|
394
|
-
}) {
|
|
395
|
-
return /* @__PURE__ */ jsx(
|
|
396
|
-
"div",
|
|
397
|
-
{
|
|
398
|
-
className: "flex items-center gap-1.5 px-5 py-3 shrink-0",
|
|
399
|
-
style: { borderBottom: skin.panelBorder },
|
|
400
|
-
children: Array.from({ length: total }, (_, i) => /* @__PURE__ */ jsx(
|
|
401
|
-
"span",
|
|
402
|
-
{
|
|
403
|
-
className: "h-1.5 rounded-full transition-all",
|
|
404
|
-
style: {
|
|
405
|
-
width: i === index ? 20 : 8,
|
|
406
|
-
background: i === index ? skin.accent : skin.mutedText,
|
|
407
|
-
opacity: i === index ? 1 : 0.4
|
|
408
|
-
}
|
|
409
|
-
},
|
|
410
|
-
i
|
|
411
|
-
))
|
|
412
|
-
}
|
|
413
|
-
);
|
|
414
|
-
}
|
|
415
|
-
function TourShellBody({
|
|
416
|
-
step,
|
|
417
|
-
narration,
|
|
418
|
-
narrationPending,
|
|
419
|
-
skin,
|
|
420
|
-
children
|
|
421
|
-
}) {
|
|
422
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
423
|
-
/* @__PURE__ */ jsx(
|
|
424
|
-
"p",
|
|
425
|
-
{
|
|
426
|
-
className: "text-[13px] leading-relaxed transition-opacity",
|
|
427
|
-
style: {
|
|
428
|
-
color: skin.bodyText,
|
|
429
|
-
opacity: narrationPending ? 0.7 : 1
|
|
430
|
-
},
|
|
431
|
-
children: narration
|
|
432
|
-
}
|
|
433
|
-
),
|
|
434
|
-
step.features && step.features.length > 0 ? /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: step.features.map((f, i) => /* @__PURE__ */ jsxs("li", { className: "text-[12.5px] leading-relaxed", children: [
|
|
435
|
-
/* @__PURE__ */ jsx("span", { className: "font-semibold", style: { color: skin.accent }, children: f.name }),
|
|
436
|
-
/* @__PURE__ */ jsxs("span", { style: { color: skin.softText }, children: [
|
|
437
|
-
" \u2014 ",
|
|
438
|
-
f.detail
|
|
439
|
-
] })
|
|
440
|
-
] }, i)) }) : step.highlights && step.highlights.length > 0 && /* @__PURE__ */ jsx("ul", { className: "space-y-1.5", children: step.highlights.map((h, i) => /* @__PURE__ */ jsxs(
|
|
441
|
-
"li",
|
|
442
|
-
{
|
|
443
|
-
className: "text-[12.5px] leading-relaxed pl-3 relative",
|
|
444
|
-
style: { color: skin.softText },
|
|
445
|
-
children: [
|
|
446
|
-
/* @__PURE__ */ jsx(
|
|
447
|
-
"span",
|
|
448
|
-
{
|
|
449
|
-
className: "absolute left-0",
|
|
450
|
-
style: { color: skin.mutedText },
|
|
451
|
-
children: "\u2022"
|
|
452
|
-
}
|
|
453
|
-
),
|
|
454
|
-
h
|
|
455
|
-
]
|
|
456
|
-
},
|
|
457
|
-
i
|
|
458
|
-
)) }),
|
|
459
|
-
step.action && /* @__PURE__ */ jsxs(
|
|
460
|
-
"a",
|
|
461
|
-
{
|
|
462
|
-
href: step.action.href,
|
|
463
|
-
target: step.action.external ? "_blank" : void 0,
|
|
464
|
-
rel: step.action.external ? "noopener noreferrer" : void 0,
|
|
465
|
-
className: "inline-flex items-center gap-1.5 px-3.5 py-2 rounded-lg text-[13px] font-semibold transition-opacity hover:opacity-90",
|
|
466
|
-
style: { background: `${skin.accent}20`, color: skin.accent },
|
|
467
|
-
children: [
|
|
468
|
-
step.action.label,
|
|
469
|
-
step.action.external ? /* @__PURE__ */ jsx(ExternalLink, { size: 13 }) : /* @__PURE__ */ jsx(ArrowRight, { size: 13 })
|
|
470
|
-
]
|
|
471
|
-
}
|
|
472
|
-
),
|
|
473
|
-
children
|
|
474
|
-
] });
|
|
475
|
-
}
|
|
476
|
-
function TourShellFooter({
|
|
477
|
-
isFirst,
|
|
478
|
-
isLast,
|
|
479
|
-
onNext,
|
|
480
|
-
onBack,
|
|
481
|
-
onDismiss,
|
|
482
|
-
skin
|
|
483
|
-
}) {
|
|
484
|
-
return /* @__PURE__ */ jsxs(
|
|
485
|
-
"div",
|
|
486
|
-
{
|
|
487
|
-
className: "flex items-center justify-between gap-2 px-5 py-3.5 shrink-0",
|
|
488
|
-
style: { borderTop: skin.panelBorder },
|
|
489
|
-
children: [
|
|
490
|
-
/* @__PURE__ */ jsx(
|
|
491
|
-
"button",
|
|
492
|
-
{
|
|
493
|
-
onClick: onDismiss,
|
|
494
|
-
className: "text-[12px] font-medium transition-colors hover:underline",
|
|
495
|
-
style: { color: skin.mutedText },
|
|
496
|
-
children: "Skip tour"
|
|
497
|
-
}
|
|
498
|
-
),
|
|
499
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
500
|
-
!isFirst && /* @__PURE__ */ jsxs(
|
|
501
|
-
"button",
|
|
502
|
-
{
|
|
503
|
-
onClick: onBack,
|
|
504
|
-
className: "flex items-center gap-1 px-3 py-1.5 rounded-md text-[12.5px] font-medium transition-colors",
|
|
505
|
-
style: { color: skin.bodyText, border: skin.panelBorder },
|
|
506
|
-
children: [
|
|
507
|
-
/* @__PURE__ */ jsx(ChevronLeft, { size: 13 }),
|
|
508
|
-
"Back"
|
|
509
|
-
]
|
|
510
|
-
}
|
|
511
|
-
),
|
|
512
|
-
/* @__PURE__ */ jsxs(
|
|
513
|
-
"button",
|
|
514
|
-
{
|
|
515
|
-
onClick: onNext,
|
|
516
|
-
className: "flex items-center gap-1 px-3.5 py-1.5 rounded-md text-[12.5px] font-bold text-white transition-opacity hover:opacity-90",
|
|
517
|
-
style: {
|
|
518
|
-
background: "linear-gradient(135deg, #8C34E9 0%, #5B1FA6 100%)"
|
|
519
|
-
},
|
|
520
|
-
children: [
|
|
521
|
-
isLast ? "Done" : "Next",
|
|
522
|
-
!isLast && /* @__PURE__ */ jsx(ChevronRight, { size: 13 })
|
|
523
|
-
]
|
|
524
|
-
}
|
|
525
|
-
)
|
|
526
|
-
] })
|
|
527
|
-
]
|
|
528
|
-
}
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// src/tour/useTour.ts
|
|
533
|
-
import { useCallback, useState as useState2 } from "react";
|
|
534
|
-
|
|
535
|
-
// src/tour/tourMachine.ts
|
|
536
|
-
function resolveInitialIndex(steps, initialStepId) {
|
|
537
|
-
if (!initialStepId) return 0;
|
|
538
|
-
const found = steps.findIndex((s) => s.id === initialStepId);
|
|
539
|
-
return found === -1 ? 0 : found;
|
|
540
|
-
}
|
|
541
|
-
function nextIndex(steps, current) {
|
|
542
|
-
if (current >= steps.length - 1) {
|
|
543
|
-
return { index: current, completed: true };
|
|
544
|
-
}
|
|
545
|
-
return { index: current + 1, completed: false };
|
|
546
|
-
}
|
|
547
|
-
function backIndex(current) {
|
|
548
|
-
return Math.max(0, current - 1);
|
|
549
|
-
}
|
|
550
|
-
function gotoIndex(steps, stepId, current) {
|
|
551
|
-
const target = steps.findIndex((s) => s.id === stepId);
|
|
552
|
-
return target === -1 ? current : target;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
// src/tour/useTour.ts
|
|
556
|
-
function useTour(steps, opts = {}) {
|
|
557
|
-
if (steps.length === 0) {
|
|
558
|
-
throw new Error("useTour requires at least one step");
|
|
559
|
-
}
|
|
560
|
-
const [index, setIndex] = useState2(
|
|
561
|
-
() => resolveInitialIndex(steps, opts.initialStepId)
|
|
562
|
-
);
|
|
563
|
-
const next = useCallback(() => {
|
|
564
|
-
const result = nextIndex(steps, index);
|
|
565
|
-
if (result.completed) {
|
|
566
|
-
opts.onComplete?.();
|
|
567
|
-
return;
|
|
568
|
-
}
|
|
569
|
-
setIndex(result.index);
|
|
570
|
-
opts.onStepChange?.(steps[result.index], result.index);
|
|
571
|
-
}, [index, steps]);
|
|
572
|
-
const back = useCallback(() => {
|
|
573
|
-
const target = backIndex(index);
|
|
574
|
-
if (target === index) return;
|
|
575
|
-
setIndex(target);
|
|
576
|
-
opts.onStepChange?.(steps[target], target);
|
|
577
|
-
}, [index, steps]);
|
|
578
|
-
const goto = useCallback(
|
|
579
|
-
(stepId) => {
|
|
580
|
-
const target = gotoIndex(steps, stepId, index);
|
|
581
|
-
if (target === index) return;
|
|
582
|
-
setIndex(target);
|
|
583
|
-
opts.onStepChange?.(steps[target], target);
|
|
584
|
-
},
|
|
585
|
-
[steps, index]
|
|
586
|
-
);
|
|
587
|
-
const dismiss = useCallback(() => {
|
|
588
|
-
opts.onDismiss?.();
|
|
589
|
-
}, []);
|
|
590
|
-
return {
|
|
591
|
-
step: steps[index],
|
|
592
|
-
index,
|
|
593
|
-
total: steps.length,
|
|
594
|
-
isFirst: index === 0,
|
|
595
|
-
isLast: index === steps.length - 1,
|
|
596
|
-
next,
|
|
597
|
-
back,
|
|
598
|
-
goto,
|
|
599
|
-
dismiss
|
|
600
|
-
};
|
|
601
|
-
}
|
|
2
|
+
InvalidTourDefinitionError,
|
|
3
|
+
NARRATION_PROMPT,
|
|
4
|
+
ONBOARDING_NARRATION_SERVICE,
|
|
5
|
+
OpiTourHost,
|
|
6
|
+
SERVICE_HUB_TOUR_ID,
|
|
7
|
+
TakeTheTourButton,
|
|
8
|
+
TourProgressError,
|
|
9
|
+
TourProvider,
|
|
10
|
+
TourShell,
|
|
11
|
+
buildNarrationInput,
|
|
12
|
+
computePanelPosition,
|
|
13
|
+
computeSpotlightFrame,
|
|
14
|
+
createPortalNarrator,
|
|
15
|
+
createPortalTourProgressTransport,
|
|
16
|
+
createTourProgressController,
|
|
17
|
+
createTourStore,
|
|
18
|
+
decideAutoOpen,
|
|
19
|
+
defaultTourStore,
|
|
20
|
+
shouldAutoOpen,
|
|
21
|
+
useActiveTour,
|
|
22
|
+
useRegisterTour,
|
|
23
|
+
useSpotlight,
|
|
24
|
+
useTour,
|
|
25
|
+
useTourLauncher,
|
|
26
|
+
useTourNarrator,
|
|
27
|
+
useTourProgress,
|
|
28
|
+
useTourState,
|
|
29
|
+
validateTourDefinition
|
|
30
|
+
} from "../chunk-LUQAR6NB.js";
|
|
31
|
+
import "../chunk-7LI4Y6WT.js";
|
|
32
|
+
import "../chunk-JT3XLKKD.js";
|
|
602
33
|
export {
|
|
34
|
+
InvalidTourDefinitionError,
|
|
35
|
+
NARRATION_PROMPT,
|
|
36
|
+
ONBOARDING_NARRATION_SERVICE,
|
|
37
|
+
OpiTourHost,
|
|
38
|
+
SERVICE_HUB_TOUR_ID,
|
|
39
|
+
TakeTheTourButton,
|
|
40
|
+
TourProgressError,
|
|
41
|
+
TourProvider,
|
|
603
42
|
TourShell,
|
|
43
|
+
buildNarrationInput,
|
|
604
44
|
computePanelPosition,
|
|
605
45
|
computeSpotlightFrame,
|
|
46
|
+
createPortalNarrator,
|
|
47
|
+
createPortalTourProgressTransport,
|
|
48
|
+
createTourProgressController,
|
|
49
|
+
createTourStore,
|
|
50
|
+
decideAutoOpen,
|
|
51
|
+
defaultTourStore,
|
|
52
|
+
shouldAutoOpen,
|
|
53
|
+
useActiveTour,
|
|
54
|
+
useRegisterTour,
|
|
606
55
|
useSpotlight,
|
|
607
|
-
useTour
|
|
56
|
+
useTour,
|
|
57
|
+
useTourLauncher,
|
|
58
|
+
useTourNarrator,
|
|
59
|
+
useTourProgress,
|
|
60
|
+
useTourState,
|
|
61
|
+
validateTourDefinition
|
|
608
62
|
};
|
|
609
63
|
//# sourceMappingURL=index.js.map
|