react-wizard-engine 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.
@@ -0,0 +1,1083 @@
1
+ import * as react from 'react';
2
+ import { ReactNode, RefObject } from 'react';
3
+ export { I as IWizardBackArrowIconProps, a as IWizardButtonProps, b as IWizardComponents, W as WizardComponentsProvider, u as useWizardComponents } from './components-provider-bC3_zfyb.js';
4
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
+
6
+ /**
7
+ * Flat list of step states — the raw array form a tree is built from.
8
+ */
9
+ type IWizardState<Step extends string, Category extends string, Branch extends string = string> = Array<IWizardStepState<Step, Category, Branch>>;
10
+
11
+ interface IWizardEntityState {
12
+ /**
13
+ * Is a step currently shown on the screen.
14
+ * Can be mutated only by wizard itself via navigation methods like wizard.go/next/back etc.
15
+ *
16
+ * NOTE: on mobile multiple steps can be active but only the last one will be on the screen.
17
+ */
18
+ readonly isActive: boolean;
19
+ /**
20
+ * Is a step completed.
21
+ *
22
+ * Can be set in step options or will be automatically completed with wizard navigation
23
+ * progress with methods like wizard.go/next/back etc.
24
+ */
25
+ readonly isCompleted: boolean;
26
+ /**
27
+ * Is a step can be activated.
28
+ * Similar to React conditional rendering.
29
+ *
30
+ * Can be changed via **wizard.showStep/hideStep**
31
+ */
32
+ readonly isShow: boolean;
33
+ /**
34
+ * Is a step was skipped.
35
+ * This is an alternative to "isCompleted", but the main difference is that you can skip at any point
36
+ *
37
+ * Can be changed via **wizard.skipCategory**
38
+ */
39
+ readonly isSkipped: boolean;
40
+ }
41
+
42
+ interface IWizardStepState<Step extends string, Category extends string, Branch extends string = string> extends IWizardEntityState {
43
+ readonly branches: Branch[];
44
+ readonly categoryId: Category;
45
+ readonly htmlIndex: number;
46
+ readonly id: Step;
47
+ }
48
+
49
+ interface IWizardCategoryState<Step extends string, Category extends string, Branch extends string = string> extends IWizardEntityState {
50
+ readonly activeStepIndex: number;
51
+ readonly activeSteps: Array<IWizardStepState<Step, Category, Branch>>;
52
+ readonly branches: Branch[];
53
+ readonly completedSteps: Array<IWizardStepState<Step, Category, Branch>>;
54
+ readonly firstActiveStep: IWizardStepState<Step, Category, Branch>;
55
+ readonly firstStep: IWizardStepState<Step, Category, Branch>;
56
+ readonly htmlIndex: number;
57
+ readonly id: Category;
58
+ /** is completed OR skipped */
59
+ readonly isPassed: boolean;
60
+ readonly lastActiveStep: IWizardStepState<Step, Category, Branch>;
61
+ readonly lastStep: IWizardStepState<Step, Category, Branch>;
62
+ readonly nextStep: IWizardStepState<Step, Category, Branch> | null | undefined;
63
+ /** completed OR skipped steps */
64
+ readonly passedSteps: Array<IWizardStepState<Step, Category, Branch>>;
65
+ readonly prevStep: IWizardStepState<Step, Category, Branch> | null | undefined;
66
+ readonly shownSteps: Array<IWizardStepState<Step, Category, Branch>>;
67
+ /** Step from what category was skipped, -1 if not skipped */
68
+ readonly skippedAt: number;
69
+ readonly skippedSteps: Array<IWizardStepState<Step, Category, Branch>>;
70
+ readonly steps: Array<IWizardStepState<Step, Category, Branch>>;
71
+ }
72
+
73
+ interface IWizardBranchState<Step extends string, Category extends string, Branch extends string = string> {
74
+ readonly activeCategories: Array<IWizardCategoryState<Step, Category, Branch>>;
75
+ readonly activeCategory: IWizardCategoryState<Step, Category, Branch>;
76
+ readonly activeCategoryIndex: number;
77
+ readonly categories: Array<IWizardCategoryState<Step, Category, Branch>>;
78
+ readonly completedCategories: Array<IWizardCategoryState<Step, Category, Branch>>;
79
+ readonly firstCategory: IWizardCategoryState<Step, Category, Branch>;
80
+ /** NOTE: not HTMLIndex, just a regular index. */
81
+ getShownCategories(fromIndex: number, toIndex: number): Array<IWizardCategoryState<Step, Category, Branch>>;
82
+ getShownCategoryIndex(category: IWizardCategoryState<Step, Category, Branch>): number;
83
+ readonly id: Branch;
84
+ readonly lastCategory: IWizardCategoryState<Step, Category, Branch>;
85
+ readonly nextCategory: IWizardCategoryState<Step, Category, Branch> | null | undefined;
86
+ /** completed OR skipped categories */
87
+ readonly passedCategories: Array<IWizardCategoryState<Step, Category, Branch>>;
88
+ readonly prevCategory: IWizardCategoryState<Step, Category, Branch> | null | undefined;
89
+ readonly shownCategories: Array<IWizardCategoryState<Step, Category, Branch>>;
90
+ readonly skippedCategories: Array<IWizardCategoryState<Step, Category, Branch>>;
91
+ }
92
+
93
+ /**
94
+ * Wizard tree state subtype for the initial tree.
95
+ */
96
+ type IWizardInitTreeState<Step extends string, Category extends string, Branch extends string = string> = IWizardTreeState<Step, Category, Branch>;
97
+ interface IWizardTreeState<Step extends string, Category extends string, Branch extends string = string> {
98
+ readonly activeBranch: IWizardBranchState<Step, Category, Branch>;
99
+ readonly activeCategory: IWizardCategoryState<Step, Category, Branch>;
100
+ readonly activeSteps: Array<IWizardStepState<Step, Category, Branch>>;
101
+ readonly branches: Array<IWizardBranchState<Step, Category, Branch>>;
102
+ readonly branchMap: Record<Branch, IWizardBranchState<Step, Category, Branch>>;
103
+ readonly categoryMap: Record<Category, IWizardCategoryState<Step, Category, Branch>>;
104
+ readonly id: string;
105
+ readonly lastActiveStep: IWizardStepState<Step, Category, Branch>;
106
+ readonly state: IWizardState<Step, Category, Branch>;
107
+ readonly stepMap: Record<Step, IWizardStepState<Step, Category, Branch>>;
108
+ }
109
+ /**
110
+ * Terminal "complete" tree state. See `WizardExitTreeState` for the rationale on
111
+ * keeping this as a class.
112
+ */
113
+ declare class WizardCompleteTreeState<Step extends string, Category extends string, Branch extends string = string> {
114
+ readonly originTree: Readonly<IWizardTreeState<Step, Category, Branch>>;
115
+ readonly state: "complete";
116
+ constructor(originTree: Readonly<IWizardTreeState<Step, Category, Branch>>);
117
+ }
118
+ /**
119
+ * Terminal "exit" tree state. Carries the originating tree so listeners can read
120
+ * what state the wizard exited from. Kept as a class so the navigation pipeline can
121
+ * branch on it via `instanceof`.
122
+ */
123
+ declare class WizardExitTreeState<Step extends string, Category extends string, Branch extends string = string> {
124
+ readonly originTree: Readonly<IWizardTreeState<Step, Category, Branch>>;
125
+ readonly state: "exit";
126
+ constructor(originTree: Readonly<IWizardTreeState<Step, Category, Branch>>);
127
+ }
128
+
129
+ /**
130
+ * Pure factory for `IWizardBranchState`.
131
+ */
132
+ declare function buildWizardBranchState<Step extends string, Category extends string, Branch extends string = string>(id: Branch, categories: ReadonlyArray<IWizardCategoryState<Step, Category, Branch>>): IWizardBranchState<Step, Category, Branch>;
133
+ /**
134
+ * Pure factory for `IWizardCategoryState`. Groups steps into shown/active/completed/skipped/passed
135
+ * buckets, then derives all relational fields.
136
+ */
137
+ declare function buildWizardCategoryState<Step extends string, Category extends string, Branch extends string = string>(id: Category, htmlIndex: number, steps: ReadonlyArray<IWizardStepState<Step, Category, Branch>>): IWizardCategoryState<Step, Category, Branch>;
138
+ /**
139
+ * Pure factory for `IWizardTreeState`. Builds stepMap, groups steps by category in declaration order,
140
+ * groups categories by branch (a category may belong to multiple branches), and
141
+ * picks the active branch.
142
+ */
143
+ declare function buildWizardTreeState<Step extends string, Category extends string, Branch extends string = string>(state: ReadonlyArray<IWizardStepState<Step, Category, Branch>>, activeBranchId?: Branch | null): IWizardTreeState<Step, Category, Branch>;
144
+
145
+ /**
146
+ * Default per-step entity state.
147
+ */
148
+ declare const wizardDefaultState: IWizardEntityState;
149
+ /**
150
+ * Default branch id when steps don't declare branches.
151
+ */
152
+ declare const wizardDefaultBranch = "main";
153
+
154
+ type MutableStepState<Step extends string, Category extends string, Branch extends string> = {
155
+ -readonly [K in keyof IWizardStepState<Step, Category, Branch>]: IWizardStepState<Step, Category, Branch>[K];
156
+ };
157
+ /**
158
+ * Mutator for wizard tree state. Fluent API: clone an existing tree, mutate
159
+ * flat per-step flags, then call `build()` to produce a fully-derived (and
160
+ * rule-validated) tree.
161
+ */
162
+ declare class WizardTreeStateBuilder<Step extends string, Category extends string, Branch extends string = string> {
163
+ private readonly branch;
164
+ private readonly state;
165
+ constructor(treeState: Readonly<IWizardTreeState<Step, Category, Branch>>, branch?: Branch | null);
166
+ static validate<Step extends string, Category extends string, Branch extends string = string>(tree: Readonly<IWizardTreeState<Step, Category, Branch>>): Readonly<IWizardTreeState<Step, Category, Branch>>;
167
+ /** Activate completed steps + the next step after the last completed one. */
168
+ activateCategory(categoryId: Category): this;
169
+ /** Activate first shown step of a category; deactivate the rest. */
170
+ activateFirstStep(categoryId: Category): this;
171
+ activateStep(step: Step): this;
172
+ build(): Readonly<IWizardTreeState<Step, Category, Branch>>;
173
+ /** Build a terminal complete tree (skips rule validation since the tree is sealed). */
174
+ buildComplete(): Readonly<WizardCompleteTreeState<Step, Category, Branch>>;
175
+ /** Build a terminal exit tree (skips rule validation since the tree is sealed). */
176
+ buildExit(): Readonly<WizardExitTreeState<Step, Category, Branch>>;
177
+ completeCategory(categoryId: Category): this;
178
+ completeStep(step: Step): this;
179
+ deactivateCategory(categoryId: Category): this;
180
+ deactivateStep(step: Step): this;
181
+ getCategoryStepStates(categoryId: Category): Array<MutableStepState<Step, Category, Branch>>;
182
+ /** Reset every step in the tree to `wizardDefaultState`. */
183
+ getResetTree(): Readonly<IWizardTreeState<Step, Category, Branch>>;
184
+ getStepState(step: Step): MutableStepState<Step, Category, Branch>;
185
+ hideCategory(categoryId: Category): this;
186
+ hideStep(step: Step): this;
187
+ /** Reset category steps from `from` index onward; deactivate all but first. */
188
+ resetCategory(categoryId: Category, from?: number): this;
189
+ showCategory(categoryId: Category): this;
190
+ showStep(step: Step): this;
191
+ skipCategory(categoryId: Category): this;
192
+ skipCategoryUncompleted(categoryId: Category): this;
193
+ uncompleteStep(step: Step): this;
194
+ unskipCategory(categoryId: Category): this;
195
+ }
196
+
197
+ declare class WizardNavigation<Step extends string, Category extends string, Branch extends string = string> {
198
+ readonly from: Readonly<IWizardTreeState<Step, Category, Branch>>;
199
+ readonly to: Readonly<IWizardTreeState<Step, Category, Branch>> | WizardCompleteTreeState<Step, Category, Branch> | WizardExitTreeState<Step, Category, Branch>;
200
+ readonly direction: 'back' | 'next';
201
+ readonly id: string;
202
+ readonly isCategoryChanging: boolean;
203
+ readonly isComplete: boolean;
204
+ readonly isExit: boolean;
205
+ readonly isScrollChanging: boolean;
206
+ readonly isSkipping: boolean;
207
+ constructor(from: Readonly<IWizardTreeState<Step, Category, Branch>>, to: Readonly<IWizardTreeState<Step, Category, Branch>> | WizardCompleteTreeState<Step, Category, Branch> | WizardExitTreeState<Step, Category, Branch>);
208
+ static getDirection(from: Readonly<IWizardTreeState<string, string>>, to: Readonly<IWizardTreeState<string, string>>): 'back' | 'next';
209
+ static isCategoryChanging(from: Readonly<IWizardTreeState<string, string>>, to: Readonly<IWizardTreeState<string, string>>): boolean;
210
+ static isScrollChanging(from: Readonly<IWizardTreeState<string, string>>, to: Readonly<IWizardTreeState<string, string>>): boolean;
211
+ /**
212
+ * Navigation counted as skipped when Category "A" was "active" and not "skipped" before transition
213
+ * and became "inactive" and "skipped" after transition.
214
+ */
215
+ static isSkipping(from: Readonly<IWizardTreeState<string, string>>, to: Readonly<IWizardTreeState<string, string>>, direction?: 'back' | 'next'): boolean;
216
+ }
217
+
218
+ type IWizardResolverHook<Step extends string, Category extends string, Branch extends string = string> = (navigation: WizardNavigation<Step, Category, Branch>) => boolean | Promise<boolean>;
219
+
220
+ /**
221
+ * Per-category-aware wizard config options. Adds a category-keyed translation map
222
+ * for the wizard header and the four resolver hooks consumed by the navigation pipeline.
223
+ */
224
+ interface IWizardConfigOptions<Category extends string = string> extends IWizardGeneralConfigOptions {
225
+ /** Object with translation to get wizard header point title by category key. If no option no text will appear */
226
+ headerI18n: null | Record<Category, string>;
227
+ resolveCategoryChange: IWizardResolverHook<string, Category, string>;
228
+ resolveCategoryComplete: IWizardResolverHook<string, Category, string>;
229
+ resolveCategoryEnter: IWizardResolverHook<string, Category, string>;
230
+ resolveStepChange: IWizardResolverHook<string, Category, string>;
231
+ }
232
+ /**
233
+ * General (non-category-aware) wizard config options.
234
+ */
235
+ interface IWizardGeneralConfigOptions {
236
+ /** Class for wizard back btn */
237
+ backBtnClass: string;
238
+ /** Back text for wizard back btn. 'Back' is default */
239
+ backBtnText: string;
240
+ /** Title for 'Finish' category */
241
+ doneDotText: string;
242
+ /**
243
+ * Use for debugging.
244
+ *
245
+ * When "events" log all internal navigation events to the console.
246
+ * When "state" log only state changes.
247
+ * When "none" no logs will be shown.
248
+ *
249
+ * Default is 'none'
250
+ */
251
+ enableTracing: 'events' | 'none' | 'state';
252
+ /** 'Finish' is default */
253
+ finishText: string;
254
+ /** Whether click on active category in header will reset category. Default true */
255
+ isActiveCategoryClickReset: boolean;
256
+ /** If true every time user presses back it will set a step as not completed. Default is true */
257
+ isBackResetCompleted: boolean;
258
+ /** To show done dot in header steps. Default false */
259
+ isDoneDot: boolean;
260
+ /**
261
+ * When moving forward into a completed category, start from its first step.
262
+ * By default, the wizard remembers your progress (you land on the last completed
263
+ * or the next uncompleted step). With this option enabled, progress is still
264
+ * tracked but ignored on forward transitions — you always begin from the first step.
265
+ * On backward transitions, the last completed step is still shown.
266
+ * @default false
267
+ */
268
+ isShowFirstStepOnCategoryChange: boolean;
269
+ /** Condition to show default wizard header */
270
+ isShowWizardHeader: boolean;
271
+ /** Condition to show default wizard header dots */
272
+ isShowWizardHeaderSteps: boolean;
273
+ /** Class for wizard next btn */
274
+ nextBtnClass: string;
275
+ /** Next text between category steps. 'Next' is default */
276
+ nextBtnText: string;
277
+ /** Next text between categories. 'Continue' is default */
278
+ nextCategoryText: string;
279
+ /** Will silence error handled by wizard. Use for debugging. Default is false. Use !environment.production in your project */
280
+ silenceErrors: boolean;
281
+ /** Is header will scroll with the page. Default true */
282
+ stickyHeader: boolean;
283
+ /** Prefix for data stored in different storages like LocalStorage. Can't be dynamically changed */
284
+ storagePrefix?: number | string;
285
+ }
286
+
287
+ interface IWizardStepButtonOptions {
288
+ /** Custom node for the step button */
289
+ btnTemplate?: ReactNode | undefined;
290
+ /** Text of next step btn. Default is got from WizardConfig */
291
+ btnText?: string;
292
+ /**
293
+ * If true pressing enter will trigger wizard.next(). Default: true
294
+ * NOTE: listener for "enter" pressing lives in the React next-button component;
295
+ * without it this option won't fire.
296
+ */
297
+ isEnterTriggerNext: boolean;
298
+ /** Whether to show wizard default next button. Default: true */
299
+ isShowNextBtn: boolean;
300
+ /** Disable 'next' btn if not valid */
301
+ isValid: boolean;
302
+ }
303
+ interface IWizardStepHeaderOptions {
304
+ /** Default: true */
305
+ isShowBackBtn: boolean;
306
+ /** Show close button in wizard-dashboard-header. Default: true */
307
+ isShowCloseBtn: boolean;
308
+ /** Default: true */
309
+ isShowHeader: boolean;
310
+ /** Default: true */
311
+ isShowHeaderSteps: boolean;
312
+ }
313
+ interface IWizardStepOptions extends IWizardStepButtonOptions, IWizardStepHeaderOptions {
314
+ }
315
+
316
+ /**
317
+ * Base contract for wizard tree-state initializers. Each initializer in a chain
318
+ * receives the result of the previous one (and the original HTML tree) and may
319
+ * mutate the active step / category / completion based on persisted state, URL
320
+ * params, server data, etc.
321
+ */
322
+ declare abstract class WizardInitializer<Step extends string, Category extends string, Branch extends string = string> {
323
+ abstract getState(tree: Readonly<IWizardTreeState<Step, Category, Branch>>, htmlTree: Readonly<IWizardTreeState<Step, Category, Branch>>): Promise<Readonly<IWizardTreeState<Step, Category, Branch>>> | Readonly<IWizardTreeState<Step, Category, Branch>>;
324
+ }
325
+
326
+ /**
327
+ * Default initializer: if the tree already has an active step, return it as-is.
328
+ * Otherwise activate the first non-passed category (or the active category as
329
+ * a fallback) so the wizard always boots with a valid active step.
330
+ */
331
+ declare class WizardDefaultInitializer<Step extends string, Category extends string, Branch extends string = string> extends WizardInitializer<Step, Category, Branch> {
332
+ getState(tree: Readonly<IWizardTreeState<Step, Category, Branch>>): Readonly<IWizardTreeState<Step, Category, Branch>>;
333
+ }
334
+
335
+ declare enum WizardEventType {
336
+ Complete = "complete",
337
+ Exit = "exit",
338
+ NavigationCancelled = "navigation_cancelled",
339
+ NavigationEnd = "navigation_end",
340
+ NavigationError = "navigation_error",
341
+ NavigationIgnored = "navigation_ignored",
342
+ NavigationStart = "navigation_start",
343
+ ResolveEnd = "resolve_end",
344
+ ResolveStart = "resolve_start",
345
+ ScrollEnd = "scroll_end",
346
+ ScrollStart = "scroll_start",
347
+ StepHide = "step_hide",
348
+ StepShow = "step_show"
349
+ }
350
+
351
+ /**
352
+ * General parent event for all wizard events.
353
+ */
354
+ declare abstract class WizardEvent<Step extends string, Category extends string, Branch extends string = string> {
355
+ readonly navigation?: WizardNavigation<Step, Category, Branch> | undefined;
356
+ abstract readonly type: WizardEventType;
357
+ /** @param navigation - Specific navigation data associated with event */
358
+ constructor(navigation?: WizardNavigation<Step, Category, Branch> | undefined);
359
+ }
360
+ declare class WizardCompleteEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
361
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
362
+ readonly type: WizardEventType.Complete;
363
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
364
+ }
365
+ /**
366
+ * Exit can be triggered in 2 ways:
367
+ * - as a part of navigation (with navigation data)
368
+ * - before wizard init, where no state exists yet
369
+ */
370
+ declare class WizardExitEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
371
+ readonly type: WizardEventType.Exit;
372
+ }
373
+ declare class WizardNavigationCancelledEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
374
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
375
+ readonly reason: 'new_navigation' | 'resolver';
376
+ readonly type: WizardEventType.NavigationCancelled;
377
+ constructor(navigation: WizardNavigation<Step, Category, Branch>, reason: 'new_navigation' | 'resolver');
378
+ }
379
+ declare class WizardNavigationEndEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
380
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
381
+ readonly type: WizardEventType.NavigationEnd;
382
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
383
+ }
384
+ declare class WizardNavigationErrorEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
385
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
386
+ readonly type: WizardEventType.NavigationError;
387
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
388
+ }
389
+ declare class WizardNavigationIgnoredEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
390
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
391
+ readonly reason: 'same_navigation';
392
+ readonly type: WizardEventType.NavigationIgnored;
393
+ constructor(navigation: WizardNavigation<Step, Category, Branch>, reason: 'same_navigation');
394
+ }
395
+ declare class WizardNavigationStartEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
396
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
397
+ readonly type: WizardEventType.NavigationStart;
398
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
399
+ }
400
+ declare class WizardResolveEndEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
401
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
402
+ readonly type: WizardEventType.ResolveEnd;
403
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
404
+ }
405
+ declare class WizardResolveStartEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
406
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
407
+ readonly type: WizardEventType.ResolveStart;
408
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
409
+ }
410
+ declare class WizardScrollEndEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
411
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
412
+ readonly type: WizardEventType.ScrollEnd;
413
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
414
+ }
415
+ declare class WizardScrollStartEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
416
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
417
+ readonly type: WizardEventType.ScrollStart;
418
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
419
+ }
420
+ declare class WizardStepHideEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
421
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
422
+ readonly type: WizardEventType.StepHide;
423
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
424
+ }
425
+ declare class WizardStepShowEvent<Step extends string, Category extends string, Branch extends string = string> extends WizardEvent<Step, Category, Branch> {
426
+ readonly navigation: WizardNavigation<Step, Category, Branch>;
427
+ readonly type: WizardEventType.StepShow;
428
+ constructor(navigation: WizardNavigation<Step, Category, Branch>);
429
+ }
430
+
431
+ /**
432
+ * Base contract for wizard lifecycle listeners.
433
+ */
434
+ declare abstract class WizardListener<Step extends string, Category extends string, Branch extends string = string> {
435
+ onDestroy(_tree: Readonly<IWizardTreeState<Step, Category, Branch>>): void;
436
+ onEvent(_event: WizardEvent<Step, Category, Branch>): void;
437
+ onInit(_tree: Readonly<IWizardTreeState<Step, Category, Branch>>): void;
438
+ onTreeChange(_tree: Readonly<IWizardTreeState<Step, Category, Branch>>): void;
439
+ }
440
+
441
+ /**
442
+ * Minimal structural shape of `WizardConfig` used by the completed-progress
443
+ * strategy for its `isBackResetCompleted` interaction warning.
444
+ */
445
+ interface IWizardProgressConfigLike {
446
+ readonly isBackResetCompleted: boolean;
447
+ }
448
+ /**
449
+ * Minimal structural shape of `WizardLog` used by the completed-progress
450
+ * strategy to surface a configuration warning.
451
+ */
452
+ interface IWizardProgressLogLike {
453
+ error(error: Error): void;
454
+ }
455
+ /**
456
+ * Strategy for calculating wizard progress (per-category percentage 0-100).
457
+ */
458
+ declare abstract class WizardProgressStrategy<Step extends string, Category extends string, Branch extends string = string> {
459
+ abstract getProgress(tree: Readonly<IWizardTreeState<Step, Category, Branch>>): Record<Category, number>;
460
+ }
461
+
462
+ /**
463
+ * Default progress strategy: progress to the last active step of each category.
464
+ * Past categories report 100; future ones report 0; the active category reports
465
+ * `(activeSteps.length - 1) * 100 / shownSteps.length`.
466
+ */
467
+ declare class WizardActiveProgressStrategy<Step extends string, Category extends string, Branch extends string = string> extends WizardProgressStrategy<Step, Category, Branch> {
468
+ getProgress(tree: Readonly<IWizardTreeState<Step, Category, Branch>>): Record<Category, number>;
469
+ }
470
+
471
+ /**
472
+ * Where the wizard should scroll. Accepts an element directly, a React-style
473
+ * ref object, or a getter — the last two resolve lazily, which is required
474
+ * when the container lives behind a ref (refs are populated after the engine
475
+ * is built). When omitted, the strategy scrolls the page (`window`).
476
+ */
477
+ type WizardScrollContainer = (() => HTMLElement | null) | HTMLElement | null | {
478
+ readonly current: HTMLElement | null;
479
+ };
480
+ /**
481
+ * Strategy for scrolling between steps in the wizard.
482
+ *
483
+ * Backed by native `Element.scrollIntoView({ behavior, block })`. Smooth/instant
484
+ * variants ship as separate strategies. A scroll container can be attached via
485
+ * `setContainer` (typically by the engine, fed from `withScrollContainer`); the
486
+ * container takes over scroll-to-top from `window`. Step-anchored scrolls keep
487
+ * using `scrollIntoView`, which already walks up to the nearest scrollable
488
+ * ancestor, so the container does not need to be re-resolved per element.
489
+ */
490
+ declare abstract class WizardScrollStrategy<Step extends string, Category extends string, Branch extends string = string> {
491
+ protected static projectToTree: <Step_1 extends string, Category_1 extends string, Branch_1 extends string>(target: Readonly<IWizardTreeState<Step_1, Category_1, Branch_1>> | WizardCompleteTreeState<Step_1, Category_1, Branch_1> | WizardExitTreeState<Step_1, Category_1, Branch_1>) => Readonly<IWizardTreeState<Step_1, Category_1, Branch_1>>;
492
+ protected container?: WizardScrollContainer;
493
+ /** Called by the navigation pipeline after `setState` lands a new tree. */
494
+ abstract onNavigate(navigation: WizardNavigation<Step, Category, Branch>): Promise<boolean>;
495
+ /** Called when toggling step/category visibility (instant scroll by default). */
496
+ onToggle(navigation: WizardNavigation<Step, Category, Branch>): Promise<boolean>;
497
+ /**
498
+ * Imperative scroll-to-top of the configured container (or window). Useful
499
+ * for surfacing top-of-page state — e.g. an error banner — after a failed
500
+ * submit, without re-running the navigation pipeline.
501
+ */
502
+ scrollToTop(behavior?: 'auto' | 'smooth'): Promise<boolean>;
503
+ setContainer(container?: WizardScrollContainer): void;
504
+ }
505
+ /**
506
+ * Internal helper: scroll to a step by element id (or to the top for `null`).
507
+ * SSR-safe (no-op when `document` is unavailable). Honors `prefers-reduced-motion`
508
+ * by silently downgrading 'smooth' to 'auto'. When `container` is provided, the
509
+ * scroll-to-top case targets that element instead of `window`.
510
+ */
511
+ declare function scrollToStep(stepId: null | string | undefined, behavior: 'auto' | 'instant' | 'smooth', container?: WizardScrollContainer): Promise<boolean>;
512
+
513
+ /**
514
+ * Minimal structural shape of `WizardConfig` used by the smooth scroll strategy.
515
+ * Phase 7 replaces this with the concrete class.
516
+ */
517
+ interface IWizardScrollConfigLike {
518
+ readonly isMobile: boolean;
519
+ }
520
+ /**
521
+ * Smooth-scroll strategy. Scrolls to the active step on every navigation;
522
+ * downgrades to instant scroll on category transitions, on mobile, and when
523
+ * `prefers-reduced-motion: reduce` is set.
524
+ */
525
+ declare class WizardSmoothScrollStrategy<Step extends string, Category extends string, Branch extends string = string> extends WizardScrollStrategy<Step, Category, Branch> {
526
+ private readonly wizardConfig?;
527
+ constructor(wizardConfig?: IWizardScrollConfigLike | undefined);
528
+ onNavigate(navigation: WizardNavigation<Step, Category, Branch>): Promise<boolean>;
529
+ }
530
+
531
+ /**
532
+ * Minimal structural shape of `WizardConfig` used by visibility strategies.
533
+ * Phase 7 replaces this with the concrete class.
534
+ */
535
+ interface IWizardVisibilityConfigLike {
536
+ readonly isMobile: boolean;
537
+ }
538
+ /**
539
+ * Strategy for calculating which wizard steps are visible (mounted in the DOM).
540
+ */
541
+ declare abstract class WizardVisibilityStrategy<Step extends string, Category extends string, Branch extends string = string> {
542
+ abstract isStepVisible(step: IWizardStepState<Step, Category, Branch>, tree: Readonly<IWizardTreeState<Step, Category, Branch>>): boolean;
543
+ }
544
+
545
+ /**
546
+ * Default visibility: show all active steps of the active category on desktop;
547
+ * show only the last active step on mobile.
548
+ */
549
+ declare class WizardDefaultVisibilityStrategy<Step extends string, Category extends string, Branch extends string = string> extends WizardVisibilityStrategy<Step, Category, Branch> {
550
+ private readonly wizardConfig;
551
+ constructor(wizardConfig: IWizardVisibilityConfigLike);
552
+ isStepVisible(step: IWizardStepState<Step, Category, Branch>, tree: Readonly<IWizardTreeState<Step, Category, Branch>>): boolean;
553
+ }
554
+
555
+ /**
556
+ * Show only the last active step of the category.
557
+ */
558
+ declare class WizardLastActiveVisibilityStrategy<Step extends string, Category extends string, Branch extends string = string> extends WizardVisibilityStrategy<Step, Category, Branch> {
559
+ isStepVisible(step: IWizardStepState<Step, Category, Branch>, tree: Readonly<IWizardTreeState<Step, Category, Branch>>): boolean;
560
+ }
561
+
562
+ interface WizardEngineOptions<Step extends string, Category extends string, Branch extends string = string> {
563
+ activeBranch?: Branch;
564
+ config?: Partial<IWizardConfigOptions<Category>>;
565
+ initializers?: ReadonlyArray<WizardInitializer<Step, Category, Branch>>;
566
+ listeners?: ReadonlyArray<WizardListener<Step, Category, Branch>>;
567
+ scrollContainer?: WizardScrollContainer;
568
+ state: ReadonlyArray<WizardEngineStepRegistration<Step, Category, Branch>>;
569
+ strategies?: WizardEngineStrategies<Step, Category, Branch>;
570
+ }
571
+ /**
572
+ * Step-shape descriptor passed to the engine when constructing it. The full
573
+ * `WizardStep` per-step UI control object lives in the React adapter (Phase 15);
574
+ * the engine itself only needs the flat per-step state plus the categoryId so
575
+ * it can build a tree.
576
+ */
577
+ type WizardEngineStepRegistration<Step extends string, Category extends string, Branch extends string = string> = IWizardStepState<Step, Category, Branch>;
578
+ interface WizardEngineStrategies<Step extends string, Category extends string, Branch extends string = string> {
579
+ progress?: WizardProgressStrategy<Step, Category, Branch>;
580
+ scroll?: WizardScrollStrategy<Step, Category, Branch>;
581
+ visibility?: WizardVisibilityStrategy<Step, Category, Branch>;
582
+ }
583
+ /**
584
+ * Top-level wizard façade. Framework-free: pass plain objects in, subscribe via
585
+ * `subscribe()` / `on()`, control via the imperative methods.
586
+ */
587
+ declare class WizardEngine<Step extends string, Category extends string, Branch extends string = string> {
588
+ get configOptions(): Readonly<IWizardConfigOptions<Category>>;
589
+ get isInitialized(): boolean;
590
+ get lastActiveStep(): IWizardStepState<Step, Category, Branch>;
591
+ get progress(): Record<Category, number>;
592
+ get shapeId(): string;
593
+ get steps(): Readonly<Record<Step, IWizardStepState<Step, Category, Branch>>>;
594
+ get tree(): Readonly<IWizardTreeState<Step, Category, Branch>>;
595
+ private committed;
596
+ private readonly config;
597
+ private disposed;
598
+ private readonly initialBranch?;
599
+ private initialized;
600
+ private readonly initialState;
601
+ private readonly initService;
602
+ private readonly listeners;
603
+ private readonly log;
604
+ private readonly navService;
605
+ private readonly pendingPostInitTasks;
606
+ private readonly progressStrategy;
607
+ private readonly scrollStrategy;
608
+ private readonly stateService;
609
+ private readonly store;
610
+ private readonly visibilityStrategy;
611
+ constructor(options: WizardEngineOptions<Step, Category, Branch>);
612
+ back(): Promise<boolean>;
613
+ backCategory(): Promise<boolean>;
614
+ commitRegistration(): Promise<void>;
615
+ completeWizard(): Promise<boolean>;
616
+ dispose(): void;
617
+ exitWizard(): Promise<boolean>;
618
+ getTreeSnapshot: () => Readonly<IWizardTreeState<Step, Category, Branch>>;
619
+ go(tree: Readonly<IWizardTreeState<Step, Category, Branch>>): Promise<boolean>;
620
+ goToCategory(category: Category): Promise<boolean>;
621
+ hideCategory(category: Category): Promise<boolean>;
622
+ hideStep(step: Step | Step[]): Promise<boolean>;
623
+ isStepVisible(stepId: Step): boolean;
624
+ next(branch?: Branch | null): Promise<boolean>;
625
+ nextCategory(branch?: Branch | null): Promise<boolean>;
626
+ on(type: '*' | WizardEvent<Step, Category, Branch>['type'], handler: (event: WizardEvent<Step, Category, Branch>) => void): () => void;
627
+ resetActiveCategory(from?: number): Promise<boolean>;
628
+ resetCategory(category: Category, from?: number): Promise<boolean>;
629
+ resetWizard(): Promise<boolean>;
630
+ scrollToTop(behavior?: 'auto' | 'smooth'): Promise<boolean>;
631
+ showCategory(category: Category): Promise<boolean>;
632
+ showStep(step: Step | Step[]): Promise<boolean>;
633
+ skipActiveCategory(): Promise<boolean>;
634
+ skipCategory(category?: Category): Promise<boolean>;
635
+ subscribe: (listener: () => void) => (() => void);
636
+ toggleCategory(category: Category, show: boolean): Promise<boolean>;
637
+ toggleStep(step: Step | Step[], show: boolean): Promise<boolean>;
638
+ private runOrQueue;
639
+ }
640
+
641
+ /**
642
+ * Aggregated provider props — what `<WizardProvider>` (Phase 15) consumes and
643
+ * passes through to `new WizardEngine(...)`. Built up by chaining `with*`
644
+ * helpers via `composeWizardProviders(...)`.
645
+ */
646
+ interface IWizardProviderProps<Step extends string, Category extends string, Branch extends string = string> {
647
+ config: Partial<IWizardConfigOptions<Category>>;
648
+ initializers: Array<WizardInitializer<Step, Category, Branch>>;
649
+ listeners: Array<WizardListener<Step, Category, Branch>>;
650
+ scrollContainer?: WizardScrollContainer;
651
+ strategies: WizardEngineStrategies<Step, Category, Branch>;
652
+ }
653
+ /**
654
+ * Modifier function — receives the props in flight, mutates them, returns void.
655
+ * Each `with*` helper returns one of these.
656
+ */
657
+ type WizardProviderMod<Step extends string, Category extends string, Branch extends string = string> = (props: IWizardProviderProps<Step, Category, Branch>) => void;
658
+ declare function composeWizardProviders<Step extends string, Category extends string, Branch extends string = string>(...mods: Array<WizardProviderMod<Step, Category, Branch>>): IWizardProviderProps<Step, Category, Branch>;
659
+ declare const withConfig: <Step extends string = string, Category extends string = string, Branch extends string = string>(options: Partial<IWizardConfigOptions<Category>>) => WizardProviderMod<Step, Category, Branch>;
660
+ declare const withInitializer: <Step extends string, Category extends string, Branch extends string = string>(initializer: WizardInitializer<Step, Category, Branch>) => WizardProviderMod<Step, Category, Branch>;
661
+ declare const withListener: <Step extends string, Category extends string, Branch extends string = string>(listener: WizardListener<Step, Category, Branch>) => WizardProviderMod<Step, Category, Branch>;
662
+ declare const withScrollStrategy: <Step extends string, Category extends string, Branch extends string = string>(strategy: WizardScrollStrategy<Step, Category, Branch>) => WizardProviderMod<Step, Category, Branch>;
663
+ /**
664
+ * Point the wizard's scroll strategy at a specific element instead of the
665
+ * window. Pass a getter when the container lives behind a React ref so the
666
+ * element resolves at scroll time, after commit.
667
+ */
668
+ declare const withScrollContainer: <Step extends string = string, Category extends string = string, Branch extends string = string>(container: WizardScrollContainer) => WizardProviderMod<Step, Category, Branch>;
669
+ declare const withProgressStrategy: <Step extends string, Category extends string, Branch extends string = string>(strategy: WizardProgressStrategy<Step, Category, Branch>) => WizardProviderMod<Step, Category, Branch>;
670
+ declare const withVisibilityStrategy: <Step extends string, Category extends string, Branch extends string = string>(strategy: WizardVisibilityStrategy<Step, Category, Branch>) => WizardProviderMod<Step, Category, Branch>;
671
+
672
+ declare class WizardError extends Error {
673
+ readonly name: string;
674
+ constructor(message?: string);
675
+ }
676
+ declare class WizardInitializationError extends WizardError {
677
+ readonly name: string;
678
+ }
679
+ declare class WizardNavigationError extends WizardError {
680
+ readonly name: string;
681
+ }
682
+ declare class WizardResolverError extends WizardError {
683
+ readonly name: string;
684
+ }
685
+
686
+ /**
687
+ * Minimal structural shape of `WizardConfig` consumed by `WizardLog` —
688
+ * it reads `enableTracing` and `silenceErrors` only. Phase 7's `WizardConfig`
689
+ * class structurally satisfies this interface (it exposes `getOptions()`).
690
+ */
691
+ interface IWizardLogConfigLike {
692
+ getOptions(): Pick<IWizardConfigOptions, 'enableTracing' | 'silenceErrors'>;
693
+ }
694
+ /**
695
+ * Console-based logger. Respects `config.enableTracing` for `trace()` and
696
+ * `config.silenceErrors` for `WizardError` instances.
697
+ */
698
+ declare class WizardLog {
699
+ private readonly wizardConfig;
700
+ constructor(wizardConfig: IWizardLogConfigLike);
701
+ error(e: unknown): void;
702
+ trace(...args: unknown[]): void;
703
+ }
704
+
705
+ /**
706
+ * Runs the registered initializer chain on top of the HTML-derived tree to
707
+ * produce the boot state. Validates step uniqueness and active-branch presence
708
+ * before delegating to the chain.
709
+ */
710
+ declare class WizardInitializerService<Step extends string, Category extends string, Branch extends string = string> {
711
+ private readonly wizardLog;
712
+ private readonly wizardInitializers;
713
+ constructor(wizardLog: WizardLog, wizardInitializers: ReadonlyArray<WizardInitializer<Step, Category, Branch>>);
714
+ getInitialState(state: ReadonlyArray<IWizardStepState<Step, Category, Branch>>, activeBranch?: Branch): Promise<Readonly<IWizardTreeState<Step, Category, Branch>>>;
715
+ private validateActiveBranch;
716
+ private validateHtmlTree;
717
+ }
718
+
719
+ type ConfigListener<Category extends string> = (config: Readonly<IWizardConfigOptions<Category>>) => void;
720
+ /**
721
+ * Holds the merged wizard config and notifies subscribers on change.
722
+ *
723
+ * Multiple `setOptions` calls within one microtask coalesce into a single
724
+ * notification.
725
+ */
726
+ declare class WizardConfig<Category extends string = string> {
727
+ /**
728
+ * Whether the wizard is rendering on a mobile viewport. Used by the default
729
+ * visibility and scroll strategies. The React adapter (Phase 15) updates this
730
+ * via a media-query subscription; in plain Node (tests/SSR), it stays `false`.
731
+ */
732
+ isMobile: boolean;
733
+ get options(): Readonly<IWizardConfigOptions<Category>>;
734
+ private current;
735
+ private disposed;
736
+ private readonly listeners;
737
+ private notifyScheduled;
738
+ constructor(overrides?: Partial<IWizardConfigOptions<Category>>);
739
+ dispose(): void;
740
+ getOptions(): Readonly<IWizardConfigOptions<Category>>;
741
+ setOptions(options: Partial<IWizardConfigOptions<Category>>): this;
742
+ subscribe(listener: ConfigListener<Category>): () => void;
743
+ private scheduleNotify;
744
+ }
745
+
746
+ type StoreListener = () => void;
747
+ /**
748
+ * Holds the current wizard tree, exposes a `useSyncExternalStore`-shaped
749
+ * subscription, and gates `setState` calls behind `init()`.
750
+ */
751
+ declare class WizardStore<Step extends string, Category extends string, Branch extends string = string> {
752
+ private readonly storagePrefix?;
753
+ readonly initOnce: Promise<Readonly<IWizardTreeState<Step, Category, Branch>>>;
754
+ get shapeId(): string;
755
+ private _shapeId;
756
+ private current;
757
+ private disposed;
758
+ private initialTree;
759
+ private readonly listeners;
760
+ private resolveInitOnce;
761
+ constructor(storagePrefix?: number | string | undefined);
762
+ dispose(): void;
763
+ getTreeSnapshot(): Readonly<IWizardTreeState<Step, Category, Branch>>;
764
+ init(initialTree: Readonly<IWizardTreeState<Step, Category, Branch>>): void;
765
+ setState(tree: Readonly<IWizardTreeState<Step, Category, Branch>>): void;
766
+ subscribe: (listener: StoreListener) => (() => void);
767
+ }
768
+
769
+ /**
770
+ * Pure-ish next-tree computations. Each method returns a target tree (or a
771
+ * terminal exit/complete subtype) without mutating the store. Methods accept an
772
+ * optional `tree` argument; when omitted they read from the store's current
773
+ * snapshot.
774
+ */
775
+ type WizardStateResult<Step extends string, Category extends string, Branch extends string> = Readonly<IWizardTreeState<Step, Category, Branch>> | WizardCompleteTreeState<Step, Category, Branch> | WizardExitTreeState<Step, Category, Branch>;
776
+ declare class WizardStateService<Step extends string, Category extends string, Branch extends string = string> {
777
+ private readonly wizardStore;
778
+ private readonly wizardConfig;
779
+ constructor(wizardStore: WizardStore<Step, Category, Branch>, wizardConfig: WizardConfig<Category>);
780
+ completeCategory(category: Category, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
781
+ goToCategory(categoryId: Category, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): Readonly<IWizardTreeState<Step, Category, Branch>>;
782
+ hideCategory(categoryId: Category, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
783
+ hideStep(step: Step, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
784
+ next(branch?: Branch | null, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
785
+ nextCategory(branch?: Branch | null, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
786
+ prev(tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
787
+ prevCategory(tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
788
+ resetCategory(category: Category, from?: number, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): Readonly<IWizardTreeState<Step, Category, Branch>>;
789
+ resetTree(tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): Readonly<IWizardTreeState<Step, Category, Branch>>;
790
+ showCategory(categoryId: Category, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): Readonly<IWizardTreeState<Step, Category, Branch>>;
791
+ showStep(step: Step, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): Readonly<IWizardTreeState<Step, Category, Branch>>;
792
+ skipCategory(category: Category, tree?: Readonly<IWizardTreeState<Step, Category, Branch>>): WizardStateResult<Step, Category, Branch>;
793
+ private currentTree;
794
+ private projectShownCategory;
795
+ private projectShownStep;
796
+ }
797
+
798
+ /**
799
+ * Async navigation pipeline. Each `navigate()` (or `showStep` / `hideStep` /
800
+ * `exitWizard` / `completeWizard`) emits a strict ordering of events:
801
+ *
802
+ * NavigationStart → ResolveStart → resolver chain → ResolveEnd → setState →
803
+ * StepShow/StepHide (visibility flips) → ScrollStart → scroll strategy →
804
+ * ScrollEnd → NavigationEnd (or Exit/Complete for terminals)
805
+ *
806
+ * Race semantics: a new navigate() while another is in flight aborts the prior
807
+ * one (emits `NavigationCancelled('new_navigation')` and resolves the prior
808
+ * Promise to `false`). Resolver returning `false` or rejecting emits
809
+ * `NavigationCancelled('resolver')`. Resolver throwing emits `NavigationError`.
810
+ */
811
+ declare class WizardNavigationService<Step extends string, Category extends string, Branch extends string = string> {
812
+ private readonly wizardStore;
813
+ private readonly wizardConfig;
814
+ private readonly wizardStateService;
815
+ private readonly wizardScrollStrategy;
816
+ get isNavigating(): boolean;
817
+ private disposed;
818
+ private readonly emitter;
819
+ private inFlight;
820
+ private prevSuccessId;
821
+ constructor(wizardStore: WizardStore<Step, Category, Branch>, wizardConfig: WizardConfig<Category>, wizardStateService: WizardStateService<Step, Category, Branch>, wizardScrollStrategy: WizardScrollStrategy<Step, Category, Branch>);
822
+ completeWizard(): Promise<boolean>;
823
+ dispose(): void;
824
+ exitWizard(): Promise<boolean>;
825
+ hideCategory(categoryId: Category): Promise<boolean>;
826
+ hideStep(step: Step | Step[]): Promise<boolean>;
827
+ navigate(to: WizardStateResult<Step, Category, Branch>): Promise<boolean>;
828
+ on(type: '*' | WizardEvent<Step, Category, Branch>['type'], handler: (event: WizardEvent<Step, Category, Branch>) => void): () => void;
829
+ showCategory(categoryId: Category): Promise<boolean>;
830
+ showStep(step: Step | Step[]): Promise<boolean>;
831
+ private commitTree;
832
+ private emitVisibilityFlips;
833
+ private hide;
834
+ private invokeResolver;
835
+ private isAbortReason;
836
+ private projectTree;
837
+ private runResolverChain;
838
+ private show;
839
+ }
840
+
841
+ type Listener<E> = (event: E) => void;
842
+ /**
843
+ * Tiny typed event emitter. Subscribers can listen to a specific event type
844
+ * (matched on `event.type`) or via the `'*'` wildcard. Returns an unsubscribe
845
+ * handle from `on()`.
846
+ */
847
+ declare class TypedEmitter<E extends {
848
+ type: string;
849
+ }> {
850
+ private readonly map;
851
+ dispose(): void;
852
+ emit(event: E): void;
853
+ on(type: '*' | E['type'], handler: Listener<E>): () => void;
854
+ }
855
+
856
+ /**
857
+ * Base contract every wizard tree-state rule must implement.
858
+ *
859
+ * Rules run on every freshly built tree before it's published; any rule that
860
+ * fails throws a `WizardError`, aborting the build. This keeps invariants
861
+ * (single active category, no skipped-but-active step, etc.) checked centrally.
862
+ */
863
+ declare abstract class WizardRule {
864
+ abstract verify(tree: Readonly<IWizardTreeState<string, string>>): never | void;
865
+ }
866
+
867
+ declare class WizardActiveStepRule extends WizardRule {
868
+ verify({ lastActiveStep }: Readonly<IWizardTreeState<string, string>>): void;
869
+ }
870
+
871
+ declare class WizardPassedPrevCategoriesRule extends WizardRule {
872
+ verify({ activeBranch, activeCategory }: Readonly<IWizardTreeState<string, string>>): void;
873
+ }
874
+
875
+ declare class WizardPassedPrevStepsRule extends WizardRule {
876
+ verify({ activeCategory }: Readonly<IWizardTreeState<string, string>>): void;
877
+ }
878
+
879
+ /**
880
+ * Default rule chain run by `WizardTreeStateBuilder.validate(tree)` on every build.
881
+ */
882
+ declare const wizardRules: WizardRule[];
883
+
884
+ declare class WizardShownActiveCategoryRule extends WizardRule {
885
+ verify({ activeCategory }: Readonly<IWizardTreeState<string, string>>): void;
886
+ }
887
+
888
+ declare class WizardSingleActiveCategoryRule extends WizardRule {
889
+ verify({ activeBranch }: Readonly<IWizardTreeState<string, string>>): void;
890
+ }
891
+
892
+ declare const wizardDefaultConfig: IWizardConfigOptions;
893
+
894
+ declare enum WizardCategoryDirection {
895
+ Backward = "backward",
896
+ Forward = "forward"
897
+ }
898
+
899
+ interface IWizardBackComponentProps {
900
+ asChild?: boolean;
901
+ children?: ReactNode;
902
+ className?: string;
903
+ }
904
+ /**
905
+ * Back button. Calls `wizard.back()` on click. Wrap a custom button via
906
+ * `asChild` to compose with shadcn variants.
907
+ */
908
+ declare function WizardBack(props: IWizardBackComponentProps): react_jsx_runtime.JSX.Element;
909
+
910
+ interface IWizardCategoryComponentProps<Category extends string> {
911
+ categoryId: Category;
912
+ children: ReactNode;
913
+ }
914
+ /**
915
+ * Wrapper that renders its children only while the named category is active.
916
+ */
917
+ declare function WizardCategory<Category extends string>(props: IWizardCategoryComponentProps<Category>): react_jsx_runtime.JSX.Element | null;
918
+
919
+ /**
920
+ * Default wizard header — renders an optional back button and the visual
921
+ * stepper. Gates on `config.isShowWizardHeader`, reserves space when the back
922
+ * button is hidden, and forwards click handlers that delegate to
923
+ * `wizard.goToCategory` / `wizard.resetCategory`.
924
+ */
925
+ declare function WizardHeader<Category extends string = string>(): react_jsx_runtime.JSX.Element | null;
926
+
927
+ interface IWizardNextComponentProps {
928
+ asChild?: boolean;
929
+ children?: ReactNode;
930
+ className?: string;
931
+ }
932
+ /**
933
+ * Next button. Calls `wizard.next()` on click. Use `asChild` to compose with a
934
+ * custom button.
935
+ *
936
+ * The default label is contextual:
937
+ * - `nextBtnText` (default "Next") within a category
938
+ * - `nextCategoryText` (default "Continue") on the last step of a non-final category
939
+ * - `finishText` (default "Finish") on the last step of the last category
940
+ */
941
+ declare function WizardNext(props: IWizardNextComponentProps): react_jsx_runtime.JSX.Element;
942
+
943
+ interface IWizardCategoryView<Step extends string, Category extends string> {
944
+ id: Category;
945
+ isActive: boolean;
946
+ state: WizardCategoryViewState;
947
+ subSteps: ReadonlyArray<{
948
+ id: Step;
949
+ isActive: boolean;
950
+ }>;
951
+ }
952
+ type WizardCategoryViewState = 'active' | 'completed' | 'pending' | 'skipped';
953
+ /**
954
+ * Projects the wizard's active branch into a normalized list for navigation
955
+ * surfaces (rail, stepper). Pure projection — re-renders on tree change via
956
+ * `useWizard`.
957
+ */
958
+ declare function useWizardCategoriesView<Step extends string, Category extends string, Branch extends string = string>(): ReadonlyArray<IWizardCategoryView<Step, Category>>;
959
+
960
+ interface IWizardRailProps<Step extends string, Category extends string> {
961
+ canAccessCategory?: (category: IWizardCategoryView<Step, Category>) => boolean;
962
+ className?: string;
963
+ headerI18n?: Partial<Record<Category, ReactNode>>;
964
+ subStepLabels?: Partial<Record<Step, ReactNode>>;
965
+ }
966
+ /**
967
+ * Vertical category rail for full-page wizard layouts. Renders one button per
968
+ * shown category with dot state, expands the active category to surface its
969
+ * sub-steps when present, and dispatches `wizard.goToCategory` on click.
970
+ *
971
+ * Pure consumer of `useWizard` — no local state.
972
+ */
973
+ declare function WizardRail<Step extends string, Category extends string, Branch extends string = string>(props: IWizardRailProps<Step, Category>): react_jsx_runtime.JSX.Element;
974
+
975
+ interface IWizardStepComponentProps<Step extends string> {
976
+ children: ReactNode;
977
+ id: Step;
978
+ }
979
+ /**
980
+ * Renders children only when the active visibility strategy reports the step
981
+ * as visible. Delegates to `WizardEngine.isStepVisible(id)` so swapping the
982
+ * strategy via `withVisibilityStrategy(...)` actually changes mount behavior.
983
+ */
984
+ declare function WizardStep<Step extends string>(props: IWizardStepComponentProps<Step>): react_jsx_runtime.JSX.Element | null;
985
+
986
+ type WizardStepperDotState = 'active' | 'completed' | 'pending' | 'skipped';
987
+ interface IWizardStepperDotProps {
988
+ clickable?: boolean;
989
+ isLast?: boolean;
990
+ label?: string;
991
+ onClick?: () => void;
992
+ progress: number;
993
+ state: WizardStepperDotState;
994
+ }
995
+ /**
996
+ * Single dot in `WizardStepper`. Renders a 12px circle with a trailing track
997
+ * fill (sized by `progress` 0-100) unless `isLast`. Optional label sits above.
998
+ *
999
+ * Visual states map to project semantic status tokens
1000
+ * (`success-bg`, `success-text`, `success-border`, `border`, `muted-foreground`).
1001
+ */
1002
+ declare function WizardStepperDot(props: IWizardStepperDotProps): react_jsx_runtime.JSX.Element;
1003
+
1004
+ interface IWizardStepperProps<Category extends string> {
1005
+ canAccessCategory?: (category: IWizardCategoryState<string, Category, string>) => boolean;
1006
+ categories: ReadonlyArray<IWizardCategoryState<string, Category, string>>;
1007
+ doneDot?: {
1008
+ text: string;
1009
+ };
1010
+ headerI18n?: null | Record<Category, string>;
1011
+ onCategoryClick?: (category: IWizardCategoryState<string, Category, string>) => void;
1012
+ progress: Record<Category, number>;
1013
+ }
1014
+ /**
1015
+ * Pure-presentational horizontal stepper. Renders one `WizardStepperDot` per
1016
+ * category with the per-category progress fill on the trailing track, plus an
1017
+ * optional trailing "done" dot.
1018
+ */
1019
+ declare function WizardStepper<Category extends string>(props: IWizardStepperProps<Category>): react_jsx_runtime.JSX.Element;
1020
+
1021
+ /**
1022
+ * React context exposing the active `WizardEngine` instance to descendants.
1023
+ * `null` outside a `<WizardProvider>` — `useWizard()` throws a clear error.
1024
+ */
1025
+ declare const WizardEngineContext: react.Context<WizardEngine<string, string, string> | null>;
1026
+
1027
+ interface IWizardProviderComponentProps<Step extends string, Category extends string, Branch extends string = string> extends Partial<IWizardProviderProps<Step, Category, Branch>> {
1028
+ activeBranch?: Branch;
1029
+ children: ReactNode;
1030
+ state: ReadonlyArray<IWizardStepState<Step, Category, Branch>>;
1031
+ }
1032
+ /**
1033
+ * Top-level wizard provider. Captures the boot options once via lazy
1034
+ * `useState`, then constructs a fresh `WizardEngine` inside an effect so React
1035
+ * 19 Strict Mode's mount/unmount/remount cycle does not leave a permanently
1036
+ * disposed engine in shared state. The engine is disposed on unmount.
1037
+ *
1038
+ * Idiomatic shape:
1039
+ * ```tsx
1040
+ * <WizardProvider state={...} {...composeWizardProviders(withConfig(...))}>
1041
+ * <WizardLayout>...</WizardLayout>
1042
+ * </WizardProvider>
1043
+ * ```
1044
+ */
1045
+ declare function WizardProvider<Step extends string, Category extends string, Branch extends string = string>(props: IWizardProviderComponentProps<Step, Category, Branch>): react_jsx_runtime.JSX.Element | null;
1046
+
1047
+ interface IWizardEngineRefCaptureProps<Step extends string, Category extends string> {
1048
+ engineRef: RefObject<null | WizardEngine<Step, Category>>;
1049
+ }
1050
+ /**
1051
+ * Holds a ref to the live `WizardEngine`. Place `<WizardEngineRefCapture
1052
+ * engineRef={ref} />` inside `<WizardProvider>` so a form's submit handler
1053
+ * (which sits outside the provider) can navigate the wizard programmatically.
1054
+ */
1055
+ declare function useWizardEngineRef<Step extends string, Category extends string>(): RefObject<null | WizardEngine<Step, Category>>;
1056
+ declare function WizardEngineRefCapture<Step extends string, Category extends string>({ engineRef, }: IWizardEngineRefCaptureProps<Step, Category>): null;
1057
+
1058
+ type WildcardOrType<E extends {
1059
+ type: string;
1060
+ }> = '*' | E['type'];
1061
+ /**
1062
+ * Subscribe to a wizard event type (or all events with `'*'`). The handler is
1063
+ * stored in a ref so updating it across renders doesn't resubscribe — the
1064
+ * subscription is bound to the type only.
1065
+ */
1066
+ declare function useWizardEvent<Step extends string, Category extends string, Branch extends string = string>(type: WildcardOrType<WizardEvent<Step, Category, Branch>>, handler: (event: WizardEvent<Step, Category, Branch>) => void): void;
1067
+
1068
+ /**
1069
+ * Subscribe to a single step's state. Re-renders only when this step's slice
1070
+ * changes (compared by `Object.is` on each flag). Returns the step state, or
1071
+ * `null` if the engine doesn't know about this id.
1072
+ */
1073
+ declare function useWizardStep<Step extends string, Category extends string = string, Branch extends string = string>(stepId: Step): IWizardStepState<Step, Category, Branch> | null;
1074
+
1075
+ /**
1076
+ * Returns the active `WizardEngine` instance and re-renders the consumer on
1077
+ * every tree change. Throws if used outside a `<WizardProvider>`.
1078
+ *
1079
+ * Engine identity is stable across renders.
1080
+ */
1081
+ declare function useWizard<Step extends string, Category extends string, Branch extends string = string>(): WizardEngine<Step, Category, Branch>;
1082
+
1083
+ export { type IWizardBranchState, type IWizardCategoryState, type IWizardConfigOptions, type IWizardEntityState, type IWizardInitTreeState, type IWizardProgressConfigLike, type IWizardProgressLogLike, type IWizardProviderProps, type IWizardResolverHook, type IWizardScrollConfigLike, type IWizardStepOptions, type IWizardStepState, type IWizardTreeState, type IWizardVisibilityConfigLike, TypedEmitter, WizardActiveProgressStrategy, WizardActiveStepRule, WizardBack, WizardCategory, WizardCategoryDirection, WizardCompleteEvent, WizardCompleteTreeState, WizardConfig, WizardDefaultInitializer, WizardDefaultVisibilityStrategy, WizardEngine, WizardEngineContext, type WizardEngineOptions, WizardEngineRefCapture, type WizardEngineStepRegistration, type WizardEngineStrategies, WizardError, WizardEvent, WizardEventType, WizardExitEvent, WizardExitTreeState, WizardHeader, WizardInitializationError, WizardInitializer, WizardInitializerService, WizardLastActiveVisibilityStrategy, WizardListener, WizardLog, WizardNavigation, WizardNavigationCancelledEvent, WizardNavigationEndEvent, WizardNavigationError, WizardNavigationErrorEvent, WizardNavigationIgnoredEvent, WizardNavigationService, WizardNavigationStartEvent, WizardNext, WizardPassedPrevCategoriesRule, WizardPassedPrevStepsRule, WizardProgressStrategy, WizardProvider, type WizardProviderMod, WizardRail, WizardResolveEndEvent, WizardResolveStartEvent, WizardResolverError, WizardRule, type WizardScrollContainer, WizardScrollEndEvent, WizardScrollStartEvent, WizardScrollStrategy, WizardShownActiveCategoryRule, WizardSingleActiveCategoryRule, WizardSmoothScrollStrategy, type WizardStateResult, WizardStateService, WizardStep, WizardStepHideEvent, WizardStepShowEvent, WizardStepper, WizardStepperDot, type WizardStepperDotState, WizardStore, WizardTreeStateBuilder, WizardVisibilityStrategy, buildWizardBranchState, buildWizardCategoryState, buildWizardTreeState, composeWizardProviders, scrollToStep, useWizard, useWizardCategoriesView, useWizardEngineRef, useWizardEvent, useWizardStep, withConfig, withInitializer, withListener, withProgressStrategy, withScrollContainer, withScrollStrategy, withVisibilityStrategy, wizardDefaultBranch, wizardDefaultConfig, wizardDefaultState, wizardRules };