@korsolutions/guidon 1.0.8 → 1.0.10
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 +160 -39
- package/dist/commonjs/components/GuidonProvider.js +27 -11
- package/dist/commonjs/components/GuidonProvider.js.map +1 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/store.js +96 -9
- package/dist/commonjs/store.js.map +1 -1
- package/dist/module/components/GuidonProvider.js +27 -11
- package/dist/module/components/GuidonProvider.js.map +1 -1
- package/dist/module/index.js.map +1 -1
- package/dist/module/store.js +96 -9
- package/dist/module/store.js.map +1 -1
- package/dist/typescript/commonjs/components/GuidonProvider.d.ts +1 -1
- package/dist/typescript/commonjs/components/GuidonProvider.d.ts.map +1 -1
- package/dist/typescript/commonjs/index.d.ts +1 -1
- package/dist/typescript/commonjs/index.d.ts.map +1 -1
- package/dist/typescript/commonjs/store.d.ts +28 -4
- package/dist/typescript/commonjs/store.d.ts.map +1 -1
- package/dist/typescript/commonjs/types.d.ts +18 -6
- package/dist/typescript/commonjs/types.d.ts.map +1 -1
- package/dist/typescript/module/components/GuidonProvider.d.ts +1 -1
- package/dist/typescript/module/components/GuidonProvider.d.ts.map +1 -1
- package/dist/typescript/module/index.d.ts +1 -1
- package/dist/typescript/module/index.d.ts.map +1 -1
- package/dist/typescript/module/store.d.ts +28 -4
- package/dist/typescript/module/store.d.ts.map +1 -1
- package/dist/typescript/module/types.d.ts +18 -6
- package/dist/typescript/module/types.d.ts.map +1 -1
- package/package.json +6 -2
- package/src/components/GuidonProvider.tsx +28 -12
- package/src/index.ts +1 -0
- package/src/store.ts +104 -13
- package/src/types.ts +19 -6
|
@@ -165,8 +165,8 @@ export interface GuidonTooltipRenderProps {
|
|
|
165
165
|
*/
|
|
166
166
|
export interface GuidonProviderProps {
|
|
167
167
|
children: ReactNode;
|
|
168
|
-
/** Configuration for the guidon */
|
|
169
|
-
config
|
|
168
|
+
/** Configuration for the guidon (optional when using configureTours) */
|
|
169
|
+
config?: GuidonConfig;
|
|
170
170
|
/** Whether to auto-start when the component mounts */
|
|
171
171
|
autoStart?: boolean;
|
|
172
172
|
/** Condition function to determine if guidon should start */
|
|
@@ -194,11 +194,19 @@ export interface GuidonTargetProps {
|
|
|
194
194
|
/** Whether this target is currently active (for conditional rendering) */
|
|
195
195
|
active?: boolean;
|
|
196
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Collection of named tours
|
|
199
|
+
*/
|
|
200
|
+
export type GuidonTours = Record<string, GuidonConfig>;
|
|
197
201
|
/**
|
|
198
202
|
* Internal store state
|
|
199
203
|
*/
|
|
200
204
|
export interface GuidonState {
|
|
201
|
-
/**
|
|
205
|
+
/** Collection of all configured tours */
|
|
206
|
+
tours: GuidonTours;
|
|
207
|
+
/** ID of the currently active tour */
|
|
208
|
+
activeTourId: string | null;
|
|
209
|
+
/** Currently active guidon config (derived from tours + activeTourId, or legacy single config) */
|
|
202
210
|
config: GuidonConfig | null;
|
|
203
211
|
/** Whether the guidon is currently active */
|
|
204
212
|
isActive: boolean;
|
|
@@ -221,10 +229,14 @@ export interface GuidonState {
|
|
|
221
229
|
* Internal store actions
|
|
222
230
|
*/
|
|
223
231
|
export interface GuidonActions {
|
|
224
|
-
/** Configure
|
|
232
|
+
/** Configure a single guidon (legacy API, still supported) */
|
|
225
233
|
configure: (config: GuidonConfig) => void;
|
|
226
|
-
/**
|
|
227
|
-
|
|
234
|
+
/** Configure multiple named tours */
|
|
235
|
+
configureTours: (tours: GuidonTours) => void;
|
|
236
|
+
/** Start a tour by ID, or the legacy single config if no ID provided */
|
|
237
|
+
start: (tourId?: string) => void;
|
|
238
|
+
/** Stop the current tour without completing it */
|
|
239
|
+
stop: () => void;
|
|
228
240
|
/** Go to the next step */
|
|
229
241
|
next: () => void;
|
|
230
242
|
/** Go to the previous step */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],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CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,qCAAqC;IACrC,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IAC7C,wEAAwE;IACxE,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,kDAAkD;IAClD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,0BAA0B;IAC1B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,4BAA4B;IAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,sBAAsB;IACtB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,uCAAuC;IACvC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC7E,0BAA0B;IAC1B,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,wBAAwB;IACxB,UAAU,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,sBAAsB;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korsolutions/guidon",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "A cross-platform walkthrough/onboarding component library for React Native with web support. Features spotlight effects, customizable tooltips, and flexible persistence options. ",
|
|
5
5
|
"repository": "https://github.com/KorSoftwareSolutions/guidon.git",
|
|
6
6
|
"author": "Christian Jimenez <christianjimenezfael@gmail.com>",
|
|
@@ -84,5 +84,9 @@
|
|
|
84
84
|
"cross-platform",
|
|
85
85
|
"expo"
|
|
86
86
|
],
|
|
87
|
-
"license": "MIT"
|
|
87
|
+
"license": "MIT",
|
|
88
|
+
"publishConfig": {
|
|
89
|
+
"access": "public",
|
|
90
|
+
"registry": "https://registry.npmjs.org/"
|
|
91
|
+
}
|
|
88
92
|
}
|
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
} from '../types';
|
|
11
11
|
|
|
12
12
|
interface GuidonContextValue {
|
|
13
|
-
start: () => void;
|
|
13
|
+
start: (tourId?: string) => void;
|
|
14
14
|
skip: () => void;
|
|
15
15
|
reset: () => void;
|
|
16
16
|
replay: () => Promise<void>;
|
|
@@ -43,6 +43,7 @@ export function GuidonProvider({
|
|
|
43
43
|
const hasInitialized = useRef(false);
|
|
44
44
|
const isActive = useGuidonStore((state: GuidonStore) => state.isActive);
|
|
45
45
|
const storeIsCompleted = useGuidonStore((state: GuidonStore) => state.isCompleted);
|
|
46
|
+
const storeConfig = useGuidonStore((state: GuidonStore) => state.config);
|
|
46
47
|
const currentStepIndex = useGuidonStore((state: GuidonStore) => state.currentStepIndex);
|
|
47
48
|
const configure = useGuidonStore((state: GuidonStore) => state.configure);
|
|
48
49
|
const start = useGuidonStore((state: GuidonStore) => state.start);
|
|
@@ -53,17 +54,23 @@ export function GuidonProvider({
|
|
|
53
54
|
// Check for waiting state (target element not mounted)
|
|
54
55
|
const waitingState = useWaitingState();
|
|
55
56
|
|
|
57
|
+
// Use config prop ID for persistence, or fall back to store config ID
|
|
58
|
+
const persistenceId = config?.id ?? storeConfig?.id ?? '__guidon_default__';
|
|
59
|
+
|
|
56
60
|
const {
|
|
57
61
|
isLoading,
|
|
58
62
|
isCompleted: persistedCompleted,
|
|
59
63
|
markCompleted,
|
|
60
64
|
markStepViewed,
|
|
61
65
|
clearProgress,
|
|
62
|
-
} = useGuidonPersistence(persistenceAdapter,
|
|
66
|
+
} = useGuidonPersistence(persistenceAdapter, persistenceId);
|
|
63
67
|
|
|
64
68
|
const isCompleted = storeIsCompleted || persistedCompleted;
|
|
65
69
|
|
|
70
|
+
// Only configure if a config prop is provided (legacy single-config mode)
|
|
66
71
|
useEffect(() => {
|
|
72
|
+
if (!config) return;
|
|
73
|
+
|
|
67
74
|
const enhancedConfig: GuidonConfig = {
|
|
68
75
|
...config,
|
|
69
76
|
onComplete: async () => {
|
|
@@ -89,8 +96,9 @@ export function GuidonProvider({
|
|
|
89
96
|
configure(enhancedConfig);
|
|
90
97
|
}, [config, configure, persistenceAdapter, markCompleted, markStepViewed, currentStepIndex]);
|
|
91
98
|
|
|
99
|
+
// Auto-start only in legacy single-config mode
|
|
92
100
|
useEffect(() => {
|
|
93
|
-
if (!autoStart || hasInitialized.current || isLoading) return;
|
|
101
|
+
if (!config || !autoStart || hasInitialized.current || isLoading) return;
|
|
94
102
|
|
|
95
103
|
const checkAndStart = async () => {
|
|
96
104
|
hasInitialized.current = true;
|
|
@@ -108,11 +116,15 @@ export function GuidonProvider({
|
|
|
108
116
|
};
|
|
109
117
|
|
|
110
118
|
checkAndStart();
|
|
111
|
-
}, [autoStart, isLoading, persistedCompleted, shouldStart, start]);
|
|
119
|
+
}, [config, autoStart, isLoading, persistedCompleted, shouldStart, start]);
|
|
112
120
|
|
|
113
121
|
// Handle wait timeout - auto-skip to next step if waiting too long
|
|
122
|
+
// Works for both legacy and multi-tour mode (reads from store)
|
|
114
123
|
useEffect(() => {
|
|
115
|
-
const
|
|
124
|
+
const activeConfig = storeConfig;
|
|
125
|
+
if (!activeConfig) return;
|
|
126
|
+
|
|
127
|
+
const currentStep = activeConfig.steps[currentStepIndex];
|
|
116
128
|
const waitTimeout = currentStep?.waitTimeout;
|
|
117
129
|
|
|
118
130
|
// Only set timeout if:
|
|
@@ -132,7 +144,7 @@ export function GuidonProvider({
|
|
|
132
144
|
}, waitTimeout);
|
|
133
145
|
|
|
134
146
|
return () => clearTimeout(timer);
|
|
135
|
-
}, [currentStepIndex,
|
|
147
|
+
}, [currentStepIndex, storeConfig, waitingState?.isWaiting, next]);
|
|
136
148
|
|
|
137
149
|
const replay = useCallback(async () => {
|
|
138
150
|
if (persistenceAdapter) {
|
|
@@ -145,9 +157,9 @@ export function GuidonProvider({
|
|
|
145
157
|
}, 100);
|
|
146
158
|
}, [persistenceAdapter, clearProgress, reset, start]);
|
|
147
159
|
|
|
148
|
-
const manualStart = useCallback(() => {
|
|
160
|
+
const manualStart = useCallback((tourId?: string) => {
|
|
149
161
|
if (!isActive && !isLoading) {
|
|
150
|
-
start();
|
|
162
|
+
start(tourId);
|
|
151
163
|
}
|
|
152
164
|
}, [isActive, isLoading, start]);
|
|
153
165
|
|
|
@@ -161,16 +173,20 @@ export function GuidonProvider({
|
|
|
161
173
|
isLoading,
|
|
162
174
|
};
|
|
163
175
|
|
|
176
|
+
// Get theme from prop config or store config
|
|
177
|
+
const activeTheme = config?.theme ?? storeConfig?.theme;
|
|
178
|
+
const activeDuration = config?.animationDuration ?? storeConfig?.animationDuration;
|
|
179
|
+
|
|
164
180
|
const overlayContent = (
|
|
165
181
|
<>
|
|
166
182
|
<GuidonOverlay
|
|
167
|
-
theme={
|
|
168
|
-
animationDuration={
|
|
183
|
+
theme={activeTheme}
|
|
184
|
+
animationDuration={activeDuration}
|
|
169
185
|
onBackdropPress={onBackdropPress}
|
|
170
186
|
/>
|
|
171
187
|
<GuidonTooltip
|
|
172
|
-
theme={
|
|
173
|
-
animationDuration={
|
|
188
|
+
theme={activeTheme}
|
|
189
|
+
animationDuration={activeDuration}
|
|
174
190
|
renderCustomTooltip={renderTooltip}
|
|
175
191
|
labels={tooltipLabels}
|
|
176
192
|
/>
|
package/src/index.ts
CHANGED
package/src/store.ts
CHANGED
|
@@ -1,29 +1,66 @@
|
|
|
1
1
|
import { create } from "zustand";
|
|
2
2
|
import { useShallow } from "zustand/react/shallow";
|
|
3
|
-
import type { GuidonConfig, GuidonStore, TargetMeasurements } from "./types";
|
|
3
|
+
import type { GuidonConfig, GuidonStore, GuidonTours, TargetMeasurements } from "./types";
|
|
4
4
|
|
|
5
5
|
const initialState = {
|
|
6
|
-
|
|
6
|
+
tours: {} as GuidonTours,
|
|
7
|
+
activeTourId: null as string | null,
|
|
8
|
+
config: null as GuidonConfig | null,
|
|
7
9
|
isActive: false,
|
|
8
10
|
currentStepIndex: 0,
|
|
9
11
|
isCompleted: false,
|
|
10
|
-
targetMeasurements: {},
|
|
12
|
+
targetMeasurements: {} as Record<string, TargetMeasurements>,
|
|
11
13
|
isLoading: false,
|
|
12
|
-
error: null,
|
|
14
|
+
error: null as string | null,
|
|
13
15
|
waitingForTarget: false,
|
|
14
|
-
waitingTargetId: null,
|
|
16
|
+
waitingTargetId: null as string | null,
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
export const useGuidonStore = create<GuidonStore>((set, get) => ({
|
|
18
20
|
...initialState,
|
|
19
21
|
|
|
20
22
|
configure: (config: GuidonConfig) => {
|
|
23
|
+
const { config: existingConfig } = get();
|
|
24
|
+
|
|
25
|
+
// Skip if same config reference (prevents re-renders from resetting)
|
|
26
|
+
if (existingConfig === config) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log("[Guidon] configure() called - resetting to step 0");
|
|
21
31
|
set({ config, currentStepIndex: 0, isCompleted: false });
|
|
22
32
|
},
|
|
23
33
|
|
|
24
|
-
|
|
25
|
-
const {
|
|
34
|
+
configureTours: (tours: GuidonTours) => {
|
|
35
|
+
const { tours: existingTours } = get();
|
|
36
|
+
|
|
37
|
+
// Skip if same tours reference (prevents re-renders from resetting)
|
|
38
|
+
if (existingTours === tours) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log("[Guidon] configureTours() called with tours:", Object.keys(tours));
|
|
43
|
+
set({ tours });
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
start: (tourId?: string) => {
|
|
47
|
+
const { tours, config: legacyConfig } = get();
|
|
48
|
+
|
|
49
|
+
// If tourId provided, use that tour from the tours collection
|
|
50
|
+
let config: GuidonConfig | null = null;
|
|
51
|
+
if (tourId) {
|
|
52
|
+
config = tours[tourId] ?? null;
|
|
53
|
+
if (!config) {
|
|
54
|
+
console.log(`[Guidon] start() - tour "${tourId}" not found`);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
// Fall back to legacy single config
|
|
59
|
+
config = legacyConfig;
|
|
60
|
+
}
|
|
61
|
+
|
|
26
62
|
console.log("[Guidon] start() called", {
|
|
63
|
+
tourId: tourId ?? "legacy",
|
|
27
64
|
hasConfig: !!config,
|
|
28
65
|
stepCount: config?.steps.length ?? 0,
|
|
29
66
|
});
|
|
@@ -37,7 +74,13 @@ export const useGuidonStore = create<GuidonStore>((set, get) => ({
|
|
|
37
74
|
"[Guidon] starting walkthrough with steps:",
|
|
38
75
|
config.steps.map((s) => s.id),
|
|
39
76
|
);
|
|
40
|
-
set({
|
|
77
|
+
set({
|
|
78
|
+
config,
|
|
79
|
+
activeTourId: tourId ?? null,
|
|
80
|
+
isActive: true,
|
|
81
|
+
currentStepIndex: 0,
|
|
82
|
+
isCompleted: false
|
|
83
|
+
});
|
|
41
84
|
|
|
42
85
|
// Call onStepEnter for the first step
|
|
43
86
|
const firstStep = config.steps[0];
|
|
@@ -47,6 +90,18 @@ export const useGuidonStore = create<GuidonStore>((set, get) => ({
|
|
|
47
90
|
}
|
|
48
91
|
},
|
|
49
92
|
|
|
93
|
+
stop: () => {
|
|
94
|
+
const { config, currentStepIndex, isActive } = get();
|
|
95
|
+
if (!isActive) return;
|
|
96
|
+
|
|
97
|
+
console.log("[Guidon] stop() called");
|
|
98
|
+
|
|
99
|
+
const currentStep = config?.steps[currentStepIndex];
|
|
100
|
+
currentStep?.onStepExit?.();
|
|
101
|
+
|
|
102
|
+
set({ isActive: false, activeTourId: null });
|
|
103
|
+
},
|
|
104
|
+
|
|
50
105
|
next: () => {
|
|
51
106
|
const { config, currentStepIndex, isActive } = get();
|
|
52
107
|
console.log("[Guidon] next() called", {
|
|
@@ -74,7 +129,7 @@ export const useGuidonStore = create<GuidonStore>((set, get) => ({
|
|
|
74
129
|
nextIndex,
|
|
75
130
|
nextStep?.id ?? "undefined",
|
|
76
131
|
);
|
|
77
|
-
set({
|
|
132
|
+
set({ currentStepIndex: nextIndex });
|
|
78
133
|
|
|
79
134
|
nextStep?.onStepEnter?.();
|
|
80
135
|
if (nextStep) {
|
|
@@ -192,17 +247,39 @@ export const useGuidonStore = create<GuidonStore>((set, get) => ({
|
|
|
192
247
|
*/
|
|
193
248
|
export const Guidon = {
|
|
194
249
|
/**
|
|
195
|
-
* Configure
|
|
250
|
+
* Configure a single walkthrough (legacy API)
|
|
196
251
|
*/
|
|
197
252
|
configure: (config: GuidonConfig) => {
|
|
198
253
|
useGuidonStore.getState().configure(config);
|
|
199
254
|
},
|
|
200
255
|
|
|
201
256
|
/**
|
|
202
|
-
*
|
|
257
|
+
* Configure multiple named tours
|
|
258
|
+
* @example
|
|
259
|
+
* Guidon.configureTours({
|
|
260
|
+
* explore: { steps: [...], onComplete: () => {} },
|
|
261
|
+
* profile: { steps: [...] },
|
|
262
|
+
* });
|
|
263
|
+
*/
|
|
264
|
+
configureTours: (tours: GuidonTours) => {
|
|
265
|
+
useGuidonStore.getState().configureTours(tours);
|
|
266
|
+
},
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Start a tour by ID, or the legacy single config if no ID provided
|
|
270
|
+
* @example
|
|
271
|
+
* Guidon.start('explore'); // Start the 'explore' tour
|
|
272
|
+
* Guidon.start(); // Start legacy single config
|
|
203
273
|
*/
|
|
204
|
-
start: () => {
|
|
205
|
-
useGuidonStore.getState().start();
|
|
274
|
+
start: (tourId?: string) => {
|
|
275
|
+
useGuidonStore.getState().start(tourId);
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Stop the current tour without completing it
|
|
280
|
+
*/
|
|
281
|
+
stop: () => {
|
|
282
|
+
useGuidonStore.getState().stop();
|
|
206
283
|
},
|
|
207
284
|
|
|
208
285
|
/**
|
|
@@ -261,6 +338,20 @@ export const Guidon = {
|
|
|
261
338
|
return useGuidonStore.getState().isCompleted;
|
|
262
339
|
},
|
|
263
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Get the currently active tour ID (null if using legacy single config)
|
|
343
|
+
*/
|
|
344
|
+
getActiveTourId: () => {
|
|
345
|
+
return useGuidonStore.getState().activeTourId;
|
|
346
|
+
},
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Get all configured tours
|
|
350
|
+
*/
|
|
351
|
+
getTours: () => {
|
|
352
|
+
return useGuidonStore.getState().tours;
|
|
353
|
+
},
|
|
354
|
+
|
|
264
355
|
/**
|
|
265
356
|
* Get the current step index
|
|
266
357
|
*/
|
package/src/types.ts
CHANGED
|
@@ -186,8 +186,8 @@ export interface GuidonTooltipRenderProps {
|
|
|
186
186
|
*/
|
|
187
187
|
export interface GuidonProviderProps {
|
|
188
188
|
children: ReactNode;
|
|
189
|
-
/** Configuration for the guidon */
|
|
190
|
-
config
|
|
189
|
+
/** Configuration for the guidon (optional when using configureTours) */
|
|
190
|
+
config?: GuidonConfig;
|
|
191
191
|
/** Whether to auto-start when the component mounts */
|
|
192
192
|
autoStart?: boolean;
|
|
193
193
|
/** Condition function to determine if guidon should start */
|
|
@@ -215,11 +215,20 @@ export interface GuidonTargetProps {
|
|
|
215
215
|
active?: boolean;
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* Collection of named tours
|
|
220
|
+
*/
|
|
221
|
+
export type GuidonTours = Record<string, GuidonConfig>;
|
|
222
|
+
|
|
218
223
|
/**
|
|
219
224
|
* Internal store state
|
|
220
225
|
*/
|
|
221
226
|
export interface GuidonState {
|
|
222
|
-
/**
|
|
227
|
+
/** Collection of all configured tours */
|
|
228
|
+
tours: GuidonTours;
|
|
229
|
+
/** ID of the currently active tour */
|
|
230
|
+
activeTourId: string | null;
|
|
231
|
+
/** Currently active guidon config (derived from tours + activeTourId, or legacy single config) */
|
|
223
232
|
config: GuidonConfig | null;
|
|
224
233
|
/** Whether the guidon is currently active */
|
|
225
234
|
isActive: boolean;
|
|
@@ -243,10 +252,14 @@ export interface GuidonState {
|
|
|
243
252
|
* Internal store actions
|
|
244
253
|
*/
|
|
245
254
|
export interface GuidonActions {
|
|
246
|
-
/** Configure
|
|
255
|
+
/** Configure a single guidon (legacy API, still supported) */
|
|
247
256
|
configure: (config: GuidonConfig) => void;
|
|
248
|
-
/**
|
|
249
|
-
|
|
257
|
+
/** Configure multiple named tours */
|
|
258
|
+
configureTours: (tours: GuidonTours) => void;
|
|
259
|
+
/** Start a tour by ID, or the legacy single config if no ID provided */
|
|
260
|
+
start: (tourId?: string) => void;
|
|
261
|
+
/** Stop the current tour without completing it */
|
|
262
|
+
stop: () => void;
|
|
250
263
|
/** Go to the next step */
|
|
251
264
|
next: () => void;
|
|
252
265
|
/** Go to the previous step */
|