@trailguide/runtime 0.0.2 → 0.1.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/context/TourRegistryContext.d.ts +42 -0
- package/dist/context/TourRegistryContext.d.ts.map +1 -0
- package/dist/hooks/useTrailManager.d.ts +54 -0
- package/dist/hooks/useTrailManager.d.ts.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +176 -69
- package/package.json +8 -8
- package/LICENSE +0 -21
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UseTrailManagerOptions, UseTrailManagerReturn } from '../hooks/useTrailManager';
|
|
2
|
+
import { Trail } from '@trailguide/core';
|
|
3
|
+
|
|
4
|
+
interface TourRegistryContextValue {
|
|
5
|
+
/**
|
|
6
|
+
* Trigger the tour for whatever page/view is currently mounted.
|
|
7
|
+
* Call this from a persistent help button, keyboard shortcut, etc.
|
|
8
|
+
*/
|
|
9
|
+
startCurrentTour: () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Register a tour start function for the currently active page.
|
|
12
|
+
* Returns a cleanup function that deregisters on unmount.
|
|
13
|
+
* You typically won't call this directly — use useRegisterTour instead.
|
|
14
|
+
*/
|
|
15
|
+
registerTour: (startFn: () => void) => () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wrap your app's persistent layout (sidebar, navbar) with this provider.
|
|
19
|
+
* Wire your help button to `useTourRegistry().startCurrentTour()`.
|
|
20
|
+
* Each page uses `useRegisterTour()` to register itself.
|
|
21
|
+
*/
|
|
22
|
+
export declare function TourRegistryProvider({ children }: {
|
|
23
|
+
children: React.ReactNode;
|
|
24
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
/** Access the registry from a help button or keyboard shortcut handler */
|
|
26
|
+
export declare function useTourRegistry(): TourRegistryContextValue;
|
|
27
|
+
/**
|
|
28
|
+
* Drop-in replacement for useTrailManager that also registers the tour
|
|
29
|
+
* with the nearest TourRegistryProvider. The help menu will trigger
|
|
30
|
+
* this tour whenever this page/view is mounted.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // In your page component:
|
|
34
|
+
* const { isActive, dismiss } = useRegisterTour(MY_TOUR, { once: true })
|
|
35
|
+
*
|
|
36
|
+
* // In your layout's help button:
|
|
37
|
+
* const { startCurrentTour } = useTourRegistry()
|
|
38
|
+
* <button onClick={startCurrentTour}>Quick Start Tour</button>
|
|
39
|
+
*/
|
|
40
|
+
export declare function useRegisterTour(trail: Trail, options?: UseTrailManagerOptions): UseTrailManagerReturn;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=TourRegistryContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TourRegistryContext.d.ts","sourceRoot":"","sources":["../../src/context/TourRegistryContext.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAE9F,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,UAAU,wBAAwB;IAChC;;;OAGG;IACH,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B;;;;OAIG;IACH,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CACnD;AAOD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAmB/E;AAED,0EAA0E;AAC1E,wBAAgB,eAAe,6BAE9B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,sBAAsB,GAC/B,qBAAqB,CAavB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Trail, Step, AnalyticsConfig } from '@trailguide/core';
|
|
2
|
+
|
|
3
|
+
export interface UseTrailManagerOptions {
|
|
4
|
+
/**
|
|
5
|
+
* When true, the tour auto-shows on first visit and marks itself as seen
|
|
6
|
+
* on completion or skip so it never auto-shows again.
|
|
7
|
+
*/
|
|
8
|
+
once?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* localStorage key used to track completion and progress.
|
|
11
|
+
* Defaults to `trailguide:managed:{trail.id}`.
|
|
12
|
+
*/
|
|
13
|
+
storageKey?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The tour only auto-shows when this is true.
|
|
16
|
+
* Use this to gate on loading state, user tier, feature flags, etc.
|
|
17
|
+
* The help menu can still trigger the tour regardless of this value.
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
enabled?: boolean;
|
|
21
|
+
/** Delay in ms before the tour auto-shows on first visit. @default 500 */
|
|
22
|
+
delay?: number;
|
|
23
|
+
/**
|
|
24
|
+
* When true, saves the user's progress on each step so they resume
|
|
25
|
+
* where they left off if they navigate away mid-tour.
|
|
26
|
+
*/
|
|
27
|
+
resumable?: boolean;
|
|
28
|
+
onComplete?: () => void;
|
|
29
|
+
onSkip?: () => void;
|
|
30
|
+
/** Fires when the tour is stopped programmatically (e.g. user navigates away) */
|
|
31
|
+
onAbandoned?: () => void;
|
|
32
|
+
onStepChange?: (step: Step, index: number) => void;
|
|
33
|
+
/** Fires when a step's target element is not found or not visible */
|
|
34
|
+
onError?: (step: Step, error: 'element_not_found' | 'element_not_visible') => void;
|
|
35
|
+
analytics?: AnalyticsConfig;
|
|
36
|
+
}
|
|
37
|
+
export interface UseTrailManagerReturn {
|
|
38
|
+
isActive: boolean;
|
|
39
|
+
currentStep: Step | null;
|
|
40
|
+
currentStepIndex: number;
|
|
41
|
+
totalSteps: number;
|
|
42
|
+
/** Show the tour (optionally resuming from saved progress) */
|
|
43
|
+
show: () => void;
|
|
44
|
+
/** Hide the tour and, if once:true, mark it as completed */
|
|
45
|
+
dismiss: () => void;
|
|
46
|
+
/** Clear all saved state for this tour so it will auto-show again */
|
|
47
|
+
reset: () => void;
|
|
48
|
+
next: () => void;
|
|
49
|
+
prev: () => void;
|
|
50
|
+
skip: () => void;
|
|
51
|
+
goToStep: (index: number) => void;
|
|
52
|
+
}
|
|
53
|
+
export declare function useTrailManager(trail: Trail, options?: UseTrailManagerOptions): UseTrailManagerReturn;
|
|
54
|
+
//# sourceMappingURL=useTrailManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrailManager.d.ts","sourceRoot":"","sources":["../../src/hooks/useTrailManager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACrC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,qEAAqE;IACrE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,mBAAmB,GAAG,qBAAqB,KAAK,IAAI,CAAC;IACnF,SAAS,CAAC,EAAE,eAAe,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,4DAA4D;IAC5D,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qEAAqE;IACrE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CAwHvB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export type { Trail, Step, Placement, TrailguideOptions, AnalyticsConfig, } from '@trailguide/core';
|
|
2
|
-
export { findElement, isElementVisible, scrollToElement, } from '@trailguide/core';
|
|
2
|
+
export { findElement, isElementVisible, scrollToElement, tourStorage, } from '@trailguide/core';
|
|
3
3
|
export { Trailguide } from './components/Trailguide';
|
|
4
4
|
export type { TrailguideProps } from './components/Trailguide';
|
|
5
5
|
export { useTrail } from './hooks/useTrail';
|
|
6
6
|
export type { UseTrailOptions, UseTrailReturn } from './hooks/useTrail';
|
|
7
|
+
export { useTrailManager } from './hooks/useTrailManager';
|
|
8
|
+
export type { UseTrailManagerOptions, UseTrailManagerReturn } from './hooks/useTrailManager';
|
|
9
|
+
export { TourRegistryProvider, useTourRegistry, useRegisterTour, } from './context/TourRegistryContext';
|
|
7
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,KAAK,EACL,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,KAAK,EACL,IAAI,EACJ,SAAS,EACT,iBAAiB,EACjB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAExE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAG7F,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,97 +1,204 @@
|
|
|
1
|
-
import { Trailguide as
|
|
2
|
-
import { findElement as
|
|
3
|
-
import { useRef as
|
|
4
|
-
|
|
1
|
+
import { Trailguide as M, tourStorage as v } from "@trailguide/core";
|
|
2
|
+
import { findElement as F, isElementVisible as R, scrollToElement as rr, tourStorage as er } from "@trailguide/core";
|
|
3
|
+
import { useRef as a, useEffect as P, useState as $, useCallback as p, createContext as D, useContext as G } from "react";
|
|
4
|
+
import { jsx as H } from "react/jsx-runtime";
|
|
5
|
+
function U({
|
|
5
6
|
trail: n,
|
|
6
|
-
onComplete:
|
|
7
|
-
onStepChange:
|
|
8
|
-
onSkip:
|
|
9
|
-
analytics:
|
|
7
|
+
onComplete: e,
|
|
8
|
+
onStepChange: u,
|
|
9
|
+
onSkip: g,
|
|
10
|
+
analytics: l
|
|
10
11
|
}) {
|
|
11
|
-
const
|
|
12
|
-
return
|
|
12
|
+
const S = a(null), i = a(e), m = a(u), s = a(g);
|
|
13
|
+
return i.current = e, m.current = u, s.current = g, P(() => (S.current = new M({
|
|
13
14
|
onComplete: () => {
|
|
14
|
-
var
|
|
15
|
-
return (
|
|
15
|
+
var c;
|
|
16
|
+
return (c = i.current) == null ? void 0 : c.call(i);
|
|
16
17
|
},
|
|
17
|
-
onStepChange: (
|
|
18
|
-
var
|
|
19
|
-
return (
|
|
18
|
+
onStepChange: (c, o) => {
|
|
19
|
+
var d;
|
|
20
|
+
return (d = m.current) == null ? void 0 : d.call(m, c, o);
|
|
20
21
|
},
|
|
21
22
|
onSkip: () => {
|
|
22
|
-
var
|
|
23
|
-
return (
|
|
23
|
+
var c;
|
|
24
|
+
return (c = s.current) == null ? void 0 : c.call(s);
|
|
24
25
|
},
|
|
25
|
-
analytics:
|
|
26
|
-
}),
|
|
27
|
-
var
|
|
28
|
-
(
|
|
29
|
-
}), [n,
|
|
26
|
+
analytics: l
|
|
27
|
+
}), S.current.start(n), () => {
|
|
28
|
+
var c;
|
|
29
|
+
(c = S.current) == null || c.stop();
|
|
30
|
+
}), [n, l]), null;
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function W({
|
|
32
33
|
trail: n,
|
|
33
|
-
onComplete:
|
|
34
|
-
onStepChange:
|
|
35
|
-
onSkip:
|
|
36
|
-
autoStart:
|
|
37
|
-
analytics:
|
|
34
|
+
onComplete: e,
|
|
35
|
+
onStepChange: u,
|
|
36
|
+
onSkip: g,
|
|
37
|
+
autoStart: l = !1,
|
|
38
|
+
analytics: S
|
|
38
39
|
}) {
|
|
39
|
-
const [
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
40
|
+
const [i, m] = $(0), [s, c] = $(!1), o = a(null), d = a(e), T = a(u), f = a(g);
|
|
41
|
+
d.current = e, T.current = u, f.current = g;
|
|
42
|
+
const h = s && n.steps[i] ? n.steps[i] : null, k = n.steps.length;
|
|
43
|
+
P(() => (o.current = new M({
|
|
43
44
|
onComplete: () => {
|
|
44
45
|
var t;
|
|
45
|
-
|
|
46
|
+
c(!1), (t = d.current) == null || t.call(d);
|
|
46
47
|
},
|
|
47
|
-
onStepChange: (t,
|
|
48
|
-
var
|
|
49
|
-
|
|
48
|
+
onStepChange: (t, C) => {
|
|
49
|
+
var K;
|
|
50
|
+
m(C), (K = T.current) == null || K.call(T, t, C);
|
|
50
51
|
},
|
|
51
52
|
onSkip: () => {
|
|
52
53
|
var t;
|
|
53
|
-
|
|
54
|
+
c(!1), (t = f.current) == null || t.call(f);
|
|
54
55
|
},
|
|
55
|
-
analytics:
|
|
56
|
-
}),
|
|
56
|
+
analytics: S
|
|
57
|
+
}), l && (o.current.start(n), c(!0)), () => {
|
|
57
58
|
var t;
|
|
58
|
-
(t =
|
|
59
|
-
}), [n,
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
}, [n]),
|
|
59
|
+
(t = o.current) == null || t.stop();
|
|
60
|
+
}), [n, l, S]);
|
|
61
|
+
const w = p(() => {
|
|
62
|
+
o.current && (o.current.start(n), c(!0), m(0));
|
|
63
|
+
}, [n]), I = p(() => {
|
|
63
64
|
var t;
|
|
64
|
-
(t =
|
|
65
|
-
}, []),
|
|
65
|
+
(t = o.current) == null || t.stop(), c(!1);
|
|
66
|
+
}, []), b = p(() => {
|
|
66
67
|
var t;
|
|
67
|
-
(t =
|
|
68
|
-
}, []),
|
|
68
|
+
(t = o.current) == null || t.next();
|
|
69
|
+
}, []), j = p(() => {
|
|
69
70
|
var t;
|
|
70
|
-
(t =
|
|
71
|
-
}, []),
|
|
71
|
+
(t = o.current) == null || t.prev();
|
|
72
|
+
}, []), A = p(() => {
|
|
72
73
|
var t;
|
|
73
|
-
(t =
|
|
74
|
-
}, []),
|
|
75
|
-
var
|
|
76
|
-
(
|
|
74
|
+
(t = o.current) == null || t.skip();
|
|
75
|
+
}, []), y = p((t) => {
|
|
76
|
+
var C;
|
|
77
|
+
(C = o.current) == null || C.goToStep(t);
|
|
78
|
+
}, []);
|
|
79
|
+
return {
|
|
80
|
+
currentStep: h,
|
|
81
|
+
currentStepIndex: i,
|
|
82
|
+
totalSteps: k,
|
|
83
|
+
isActive: s,
|
|
84
|
+
next: b,
|
|
85
|
+
prev: j,
|
|
86
|
+
skip: A,
|
|
87
|
+
goToStep: y,
|
|
88
|
+
start: w,
|
|
89
|
+
stop: I
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function J(n, e = {}) {
|
|
93
|
+
const {
|
|
94
|
+
once: u = !1,
|
|
95
|
+
storageKey: g,
|
|
96
|
+
enabled: l = !0,
|
|
97
|
+
delay: S = 500,
|
|
98
|
+
resumable: i = !1,
|
|
99
|
+
analytics: m
|
|
100
|
+
} = e, s = g ?? `trailguide:managed:${n.id}`, [c, o] = $(!1), [d, T] = $(0), f = a(null), h = a(e.onComplete), k = a(e.onSkip), w = a(e.onAbandoned), I = a(e.onStepChange), b = a(e.onError);
|
|
101
|
+
h.current = e.onComplete, k.current = e.onSkip, w.current = e.onAbandoned, I.current = e.onStepChange, b.current = e.onError;
|
|
102
|
+
const j = c && n.steps[d] ? n.steps[d] : null;
|
|
103
|
+
P(() => (f.current = new M({
|
|
104
|
+
onComplete: () => {
|
|
105
|
+
var r;
|
|
106
|
+
u && v.markCompleted(s), i && v.clearProgress(s), o(!1), T(0), (r = h.current) == null || r.call(h);
|
|
107
|
+
},
|
|
108
|
+
onSkip: () => {
|
|
109
|
+
var r;
|
|
110
|
+
u && v.markCompleted(s), i && v.clearProgress(s), o(!1), T(0), (r = k.current) == null || r.call(k);
|
|
111
|
+
},
|
|
112
|
+
onAbandoned: () => {
|
|
113
|
+
var r;
|
|
114
|
+
o(!1), (r = w.current) == null || r.call(w);
|
|
115
|
+
},
|
|
116
|
+
onStepChange: (r, x) => {
|
|
117
|
+
var E;
|
|
118
|
+
T(x), i && v.saveProgress(s, x), (E = I.current) == null || E.call(I, r, x);
|
|
119
|
+
},
|
|
120
|
+
onError: (r, x) => {
|
|
121
|
+
var E;
|
|
122
|
+
(E = b.current) == null || E.call(b, r, x);
|
|
123
|
+
},
|
|
124
|
+
analytics: m
|
|
125
|
+
}), () => {
|
|
126
|
+
var r;
|
|
127
|
+
(r = f.current) == null || r.stop();
|
|
128
|
+
}), [n, m, u, s, i]);
|
|
129
|
+
const A = p(() => {
|
|
130
|
+
if (!f.current) return;
|
|
131
|
+
const r = i ? v.getProgress(s) ?? 0 : 0;
|
|
132
|
+
f.current.start(n), r > 0 && f.current.goToStep(r), o(!0), T(r);
|
|
133
|
+
}, [n, i, s]), y = a(A);
|
|
134
|
+
y.current = A, P(() => {
|
|
135
|
+
if (!l || u && v.hasCompleted(s)) return;
|
|
136
|
+
const r = setTimeout(() => y.current(), S);
|
|
137
|
+
return () => clearTimeout(r);
|
|
138
|
+
}, [l, u, s, S]);
|
|
139
|
+
const t = p(() => {
|
|
140
|
+
var r;
|
|
141
|
+
u && v.markCompleted(s), (r = f.current) == null || r.stop(), o(!1), T(0);
|
|
142
|
+
}, [u, s]), C = p(() => {
|
|
143
|
+
v.reset(s);
|
|
144
|
+
}, [s]), K = p(() => {
|
|
145
|
+
var r;
|
|
146
|
+
return (r = f.current) == null ? void 0 : r.next();
|
|
147
|
+
}, []), q = p(() => {
|
|
148
|
+
var r;
|
|
149
|
+
return (r = f.current) == null ? void 0 : r.prev();
|
|
150
|
+
}, []), z = p(() => {
|
|
151
|
+
var r;
|
|
152
|
+
return (r = f.current) == null ? void 0 : r.skip();
|
|
153
|
+
}, []), B = p((r) => {
|
|
154
|
+
var x;
|
|
155
|
+
return (x = f.current) == null ? void 0 : x.goToStep(r);
|
|
77
156
|
}, []);
|
|
78
157
|
return {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
158
|
+
isActive: c,
|
|
159
|
+
currentStep: j,
|
|
160
|
+
currentStepIndex: d,
|
|
161
|
+
totalSteps: n.steps.length,
|
|
162
|
+
show: A,
|
|
163
|
+
dismiss: t,
|
|
164
|
+
reset: C,
|
|
165
|
+
next: K,
|
|
166
|
+
prev: q,
|
|
167
|
+
skip: z,
|
|
168
|
+
goToStep: B
|
|
89
169
|
};
|
|
90
170
|
}
|
|
171
|
+
const V = D({
|
|
172
|
+
startCurrentTour: () => {
|
|
173
|
+
},
|
|
174
|
+
registerTour: () => () => {
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
function X({ children: n }) {
|
|
178
|
+
const e = a(null), u = p((l) => (e.current = l, () => {
|
|
179
|
+
e.current === l && (e.current = null);
|
|
180
|
+
}), []), g = p(() => {
|
|
181
|
+
var l;
|
|
182
|
+
(l = e.current) == null || l.call(e);
|
|
183
|
+
}, []);
|
|
184
|
+
return /* @__PURE__ */ H(V.Provider, { value: { startCurrentTour: g, registerTour: u }, children: n });
|
|
185
|
+
}
|
|
186
|
+
function L() {
|
|
187
|
+
return G(V);
|
|
188
|
+
}
|
|
189
|
+
function Y(n, e) {
|
|
190
|
+
const { registerTour: u } = L(), g = J(n, e), l = a(g.show);
|
|
191
|
+
return l.current = g.show, P(() => u(() => l.current()), [u]), g;
|
|
192
|
+
}
|
|
91
193
|
export {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
194
|
+
X as TourRegistryProvider,
|
|
195
|
+
U as Trailguide,
|
|
196
|
+
F as findElement,
|
|
197
|
+
R as isElementVisible,
|
|
198
|
+
rr as scrollToElement,
|
|
199
|
+
er as tourStorage,
|
|
200
|
+
Y as useRegisterTour,
|
|
201
|
+
L as useTourRegistry,
|
|
202
|
+
W as useTrail,
|
|
203
|
+
J as useTrailManager
|
|
97
204
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trailguide/runtime",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "React hooks and components for Trailguide product tours.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite build --watch",
|
|
20
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
18
23
|
"keywords": [
|
|
19
24
|
"react",
|
|
20
25
|
"product-tour",
|
|
@@ -39,7 +44,7 @@
|
|
|
39
44
|
"react-dom": "^18.0.0"
|
|
40
45
|
},
|
|
41
46
|
"dependencies": {
|
|
42
|
-
"@trailguide/core": "
|
|
47
|
+
"@trailguide/core": "workspace:*"
|
|
43
48
|
},
|
|
44
49
|
"devDependencies": {
|
|
45
50
|
"@types/react": "^18.2.0",
|
|
@@ -50,10 +55,5 @@
|
|
|
50
55
|
"typescript": "^5.4.0",
|
|
51
56
|
"vite": "^5.2.0",
|
|
52
57
|
"vite-plugin-dts": "^3.8.0"
|
|
53
|
-
},
|
|
54
|
-
"scripts": {
|
|
55
|
-
"dev": "vite build --watch",
|
|
56
|
-
"build": "vite build && tsc --emitDeclarationOnly",
|
|
57
|
-
"typecheck": "tsc --noEmit"
|
|
58
58
|
}
|
|
59
|
-
}
|
|
59
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Branden Langhals
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|