react-wizard-engine 0.1.3 → 0.1.4
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/CHANGELOG.md +6 -0
- package/dist/chunk-5ZSA2PNS.js +76 -0
- package/dist/chunk-5ZSA2PNS.js.map +1 -0
- package/dist/chunk-XNH2LQZL.cjs +76 -0
- package/dist/chunk-XNH2LQZL.cjs.map +1 -0
- package/dist/index.cjs +388 -548
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -104
- package/dist/index.js.map +1 -1
- package/dist/shadcn/index.cjs +64 -156
- package/dist/shadcn/index.cjs.map +1 -1
- package/dist/shadcn/index.js +32 -83
- package/dist/shadcn/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# react-wizard-engine
|
|
2
2
|
|
|
3
|
+
## 0.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix `WizardComponentsContext` being duplicated across the main and `/shadcn` entries. Previously the bundler-emitted output had two independent React contexts, so `<WizardComponentsProviderWithDefaults>` (`/shadcn`) and `<WizardActionButton>` (headless) couldn't communicate - every consumer of the styled default Button fell back to the unstyled headless `<button>`. `tsup` now uses `splitting: true` so the context lives in a shared chunk imported by both entries.
|
|
8
|
+
|
|
3
9
|
## 0.1.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/core/errors/wizard.error.ts
|
|
4
|
+
var WizardError = class extends Error {
|
|
5
|
+
name = "WizardError";
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
var WizardInitializationError = class extends WizardError {
|
|
12
|
+
name = "WizardInitializationError";
|
|
13
|
+
};
|
|
14
|
+
var WizardNavigationError = class extends WizardError {
|
|
15
|
+
name = "WizardNavigationError";
|
|
16
|
+
};
|
|
17
|
+
var WizardResolverError = class extends WizardError {
|
|
18
|
+
name = "WizardResolverError";
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/react/components-provider.tsx
|
|
22
|
+
import { createContext, useContext } from "react";
|
|
23
|
+
import { jsx } from "react/jsx-runtime";
|
|
24
|
+
var FallbackButton = (props) => {
|
|
25
|
+
const { children, asChild: _asChild, variant: _variant, size: _size, ...rest } = props;
|
|
26
|
+
return /* @__PURE__ */ jsx("button", { ...rest, type: props.type ?? "button", children });
|
|
27
|
+
};
|
|
28
|
+
var FallbackBackArrowIcon = ({ className }) => /* @__PURE__ */ jsx("svg", { className, width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 4 L6 8 L10 12", stroke: "currentColor", strokeWidth: "1.5", fill: "none" }) });
|
|
29
|
+
var defaults = { Button: FallbackButton, BackArrowIcon: FallbackBackArrowIcon };
|
|
30
|
+
var WizardComponentsContext = createContext(defaults);
|
|
31
|
+
function WizardComponentsProvider(props) {
|
|
32
|
+
const { Button, BackArrowIcon, children } = props;
|
|
33
|
+
const value = {
|
|
34
|
+
Button: Button ?? defaults.Button,
|
|
35
|
+
BackArrowIcon: BackArrowIcon ?? defaults.BackArrowIcon
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ jsx(WizardComponentsContext.Provider, { value, children });
|
|
38
|
+
}
|
|
39
|
+
function useWizardComponents() {
|
|
40
|
+
return useContext(WizardComponentsContext);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/react/context.ts
|
|
44
|
+
import { createContext as createContext2 } from "react";
|
|
45
|
+
var WizardEngineContext = createContext2(null);
|
|
46
|
+
|
|
47
|
+
// src/react/use-wizard.ts
|
|
48
|
+
import { useContext as useContext2, useSyncExternalStore } from "react";
|
|
49
|
+
function useWizard() {
|
|
50
|
+
const engine = useContext2(WizardEngineContext);
|
|
51
|
+
if (!engine) {
|
|
52
|
+
throw new WizardError("useWizard must be used inside <WizardProvider>");
|
|
53
|
+
}
|
|
54
|
+
useSyncExternalStore(engine.subscribe, engine.getTreeSnapshot, engine.getTreeSnapshot);
|
|
55
|
+
return engine;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/utils/cn.ts
|
|
59
|
+
import { clsx } from "clsx";
|
|
60
|
+
import { twMerge } from "tailwind-merge";
|
|
61
|
+
function cn(...inputs) {
|
|
62
|
+
return twMerge(clsx(...inputs));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export {
|
|
66
|
+
WizardError,
|
|
67
|
+
WizardInitializationError,
|
|
68
|
+
WizardNavigationError,
|
|
69
|
+
WizardResolverError,
|
|
70
|
+
WizardComponentsProvider,
|
|
71
|
+
useWizardComponents,
|
|
72
|
+
WizardEngineContext,
|
|
73
|
+
useWizard,
|
|
74
|
+
cn
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=chunk-5ZSA2PNS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/errors/wizard.error.ts","../src/react/components-provider.tsx","../src/react/context.ts","../src/react/use-wizard.ts","../src/utils/cn.ts"],"sourcesContent":["export class WizardError extends Error {\n\tpublic override readonly name: string = 'WizardError';\n\n\tconstructor(message?: string) {\n\t\tsuper(message);\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\nexport class WizardInitializationError extends WizardError {\n\tpublic override readonly name: string = 'WizardInitializationError';\n}\n\nexport class WizardNavigationError extends WizardError {\n\tpublic override readonly name: string = 'WizardNavigationError';\n}\n\nexport class WizardResolverError extends WizardError {\n\tpublic override readonly name: string = 'WizardResolverError';\n}\n","'use client';\n\nimport { type ComponentType, createContext, type ReactNode, useContext } from 'react';\n\nexport interface IWizardButtonProps {\n\tasChild?: boolean;\n\tchildren?: ReactNode;\n\tclassName?: string;\n\tdisabled?: boolean;\n\tonClick?: () => void;\n\ttype?: 'button' | 'submit';\n\tvariant?: 'default' | 'ghost';\n\tsize?: 'default' | 'icon-sm';\n\t'aria-label'?: string;\n}\n\nexport interface IWizardBackArrowIconProps {\n\tclassName?: string;\n}\n\nexport interface IWizardComponents {\n\tButton: ComponentType<IWizardButtonProps>;\n\tBackArrowIcon: ComponentType<IWizardBackArrowIconProps>;\n}\n\nconst FallbackButton: ComponentType<IWizardButtonProps> = (props) => {\n\tconst { children, asChild: _asChild, variant: _variant, size: _size, ...rest } = props;\n\treturn (\n\t\t<button {...rest} type={props.type ?? 'button'}>\n\t\t\t{children}\n\t\t</button>\n\t);\n};\n\nconst FallbackBackArrowIcon: ComponentType<IWizardBackArrowIconProps> = ({ className }) => (\n\t<svg className={className} width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden>\n\t\t<path d=\"M10 4 L6 8 L10 12\" stroke=\"currentColor\" strokeWidth=\"1.5\" fill=\"none\" />\n\t</svg>\n);\n\nconst defaults: IWizardComponents = { Button: FallbackButton, BackArrowIcon: FallbackBackArrowIcon };\n\nconst WizardComponentsContext = createContext<IWizardComponents>(defaults);\n\nexport function WizardComponentsProvider(props: {\n\tButton?: ComponentType<IWizardButtonProps>;\n\tBackArrowIcon?: ComponentType<IWizardBackArrowIconProps>;\n\tchildren: ReactNode;\n}) {\n\tconst { Button, BackArrowIcon, children } = props;\n\tconst value: IWizardComponents = {\n\t\tButton: Button ?? defaults.Button,\n\t\tBackArrowIcon: BackArrowIcon ?? defaults.BackArrowIcon,\n\t};\n\treturn <WizardComponentsContext.Provider value={value}>{children}</WizardComponentsContext.Provider>;\n}\n\nexport function useWizardComponents(): IWizardComponents {\n\treturn useContext(WizardComponentsContext);\n}\n","'use client';\n\nimport { createContext } from 'react';\n\nimport type { WizardEngine } from '../core/wizard-engine';\n\n/**\n * React context exposing the active `WizardEngine` instance to descendants.\n * `null` outside a `<WizardProvider>` — `useWizard()` throws a clear error.\n */\nexport const WizardEngineContext = createContext<null | WizardEngine<string, string, string>>(null);\n","'use client';\n\nimport { useContext, useSyncExternalStore } from 'react';\n\nimport type { WizardEngine } from '../core/wizard-engine';\n\nimport { WizardError } from '../core/errors';\nimport { WizardEngineContext } from './context';\n\n/**\n * Returns the active `WizardEngine` instance and re-renders the consumer on\n * every tree change. Throws if used outside a `<WizardProvider>`.\n *\n * Engine identity is stable across renders.\n */\nexport function useWizard<Step extends string, Category extends string, Branch extends string = string>(): WizardEngine<\n\tStep,\n\tCategory,\n\tBranch\n> {\n\tconst engine = useContext(WizardEngineContext) as null | WizardEngine<Step, Category, Branch>;\n\tif (!engine) {\n\t\tthrow new WizardError('useWizard must be used inside <WizardProvider>');\n\t}\n\tuseSyncExternalStore(engine.subscribe, engine.getTreeSnapshot, engine.getTreeSnapshot);\n\treturn engine;\n}\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(...inputs));\n}\n"],"mappings":";;;AAAO,IAAM,cAAN,cAA0B,MAAM;AAAA,EACb,OAAe;AAAA,EAExC,YAAY,SAAkB;AAC7B,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,WAAW,SAAS;AAAA,EACjD;AACD;AAEO,IAAM,4BAAN,cAAwC,YAAY;AAAA,EACjC,OAAe;AACzC;AAEO,IAAM,wBAAN,cAAoC,YAAY;AAAA,EAC7B,OAAe;AACzC;AAEO,IAAM,sBAAN,cAAkC,YAAY;AAAA,EAC3B,OAAe;AACzC;;;ACjBA,SAA6B,eAA+B,kBAAkB;AA0B5E;AAHF,IAAM,iBAAoD,CAAC,UAAU;AACpE,QAAM,EAAE,UAAU,SAAS,UAAU,SAAS,UAAU,MAAM,OAAO,GAAG,KAAK,IAAI;AACjF,SACC,oBAAC,YAAQ,GAAG,MAAM,MAAM,MAAM,QAAQ,UACpC,UACF;AAEF;AAEA,IAAM,wBAAkE,CAAC,EAAE,UAAU,MACpF,oBAAC,SAAI,WAAsB,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,gBAAe,eAAW,MACpG,8BAAC,UAAK,GAAE,qBAAoB,QAAO,gBAAe,aAAY,OAAM,MAAK,QAAO,GACjF;AAGD,IAAM,WAA8B,EAAE,QAAQ,gBAAgB,eAAe,sBAAsB;AAEnG,IAAM,0BAA0B,cAAiC,QAAQ;AAElE,SAAS,yBAAyB,OAItC;AACF,QAAM,EAAE,QAAQ,eAAe,SAAS,IAAI;AAC5C,QAAM,QAA2B;AAAA,IAChC,QAAQ,UAAU,SAAS;AAAA,IAC3B,eAAe,iBAAiB,SAAS;AAAA,EAC1C;AACA,SAAO,oBAAC,wBAAwB,UAAxB,EAAiC,OAAe,UAAS;AAClE;AAEO,SAAS,sBAAyC;AACxD,SAAO,WAAW,uBAAuB;AAC1C;;;ACzDA,SAAS,iBAAAA,sBAAqB;AAQvB,IAAM,sBAAsBA,eAA2D,IAAI;;;ACRlG,SAAS,cAAAC,aAAY,4BAA4B;AAa1C,SAAS,YAId;AACD,QAAM,SAASC,YAAW,mBAAmB;AAC7C,MAAI,CAAC,QAAQ;AACZ,UAAM,IAAI,YAAY,gDAAgD;AAAA,EACvE;AACA,uBAAqB,OAAO,WAAW,OAAO,iBAAiB,OAAO,eAAe;AACrF,SAAO;AACR;;;AC1BA,SAAS,YAA6B;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAA8B;AAClD,SAAO,QAAQ,KAAK,GAAG,MAAM,CAAC;AAChC;","names":["createContext","useContext","useContext"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class; var _class2; var _class3; var _class4;"use client";
|
|
2
|
+
|
|
3
|
+
// src/core/errors/wizard.error.ts
|
|
4
|
+
var WizardError = (_class = class extends Error {
|
|
5
|
+
__init() {this.name = "WizardError"}
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);_class.prototype.__init.call(this);;
|
|
8
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
9
|
+
}
|
|
10
|
+
}, _class);
|
|
11
|
+
var WizardInitializationError = (_class2 = class extends WizardError {constructor(...args) { super(...args); _class2.prototype.__init2.call(this); }
|
|
12
|
+
__init2() {this.name = "WizardInitializationError"}
|
|
13
|
+
}, _class2);
|
|
14
|
+
var WizardNavigationError = (_class3 = class extends WizardError {constructor(...args2) { super(...args2); _class3.prototype.__init3.call(this); }
|
|
15
|
+
__init3() {this.name = "WizardNavigationError"}
|
|
16
|
+
}, _class3);
|
|
17
|
+
var WizardResolverError = (_class4 = class extends WizardError {constructor(...args3) { super(...args3); _class4.prototype.__init4.call(this); }
|
|
18
|
+
__init4() {this.name = "WizardResolverError"}
|
|
19
|
+
}, _class4);
|
|
20
|
+
|
|
21
|
+
// src/react/components-provider.tsx
|
|
22
|
+
var _react = require('react');
|
|
23
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
24
|
+
var FallbackButton = (props) => {
|
|
25
|
+
const { children, asChild: _asChild, variant: _variant, size: _size, ...rest } = props;
|
|
26
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { ...rest, type: _nullishCoalesce(props.type, () => ( "button")), children });
|
|
27
|
+
};
|
|
28
|
+
var FallbackBackArrowIcon = ({ className }) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { className, width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M10 4 L6 8 L10 12", stroke: "currentColor", strokeWidth: "1.5", fill: "none" }) });
|
|
29
|
+
var defaults = { Button: FallbackButton, BackArrowIcon: FallbackBackArrowIcon };
|
|
30
|
+
var WizardComponentsContext = _react.createContext.call(void 0, defaults);
|
|
31
|
+
function WizardComponentsProvider(props) {
|
|
32
|
+
const { Button, BackArrowIcon, children } = props;
|
|
33
|
+
const value = {
|
|
34
|
+
Button: _nullishCoalesce(Button, () => ( defaults.Button)),
|
|
35
|
+
BackArrowIcon: _nullishCoalesce(BackArrowIcon, () => ( defaults.BackArrowIcon))
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WizardComponentsContext.Provider, { value, children });
|
|
38
|
+
}
|
|
39
|
+
function useWizardComponents() {
|
|
40
|
+
return _react.useContext.call(void 0, WizardComponentsContext);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/react/context.ts
|
|
44
|
+
|
|
45
|
+
var WizardEngineContext = _react.createContext.call(void 0, null);
|
|
46
|
+
|
|
47
|
+
// src/react/use-wizard.ts
|
|
48
|
+
|
|
49
|
+
function useWizard() {
|
|
50
|
+
const engine = _react.useContext.call(void 0, WizardEngineContext);
|
|
51
|
+
if (!engine) {
|
|
52
|
+
throw new WizardError("useWizard must be used inside <WizardProvider>");
|
|
53
|
+
}
|
|
54
|
+
_react.useSyncExternalStore.call(void 0, engine.subscribe, engine.getTreeSnapshot, engine.getTreeSnapshot);
|
|
55
|
+
return engine;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/utils/cn.ts
|
|
59
|
+
var _clsx = require('clsx');
|
|
60
|
+
var _tailwindmerge = require('tailwind-merge');
|
|
61
|
+
function cn(...inputs) {
|
|
62
|
+
return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, ...inputs));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
exports.WizardError = WizardError; exports.WizardInitializationError = WizardInitializationError; exports.WizardNavigationError = WizardNavigationError; exports.WizardResolverError = WizardResolverError; exports.WizardComponentsProvider = WizardComponentsProvider; exports.useWizardComponents = useWizardComponents; exports.WizardEngineContext = WizardEngineContext; exports.useWizard = useWizard; exports.cn = cn;
|
|
76
|
+
//# sourceMappingURL=chunk-XNH2LQZL.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/knazark/work/extract-tmp/perks-extract/dist/chunk-XNH2LQZL.cjs","../src/core/errors/wizard.error.ts","../src/react/components-provider.tsx","../src/react/context.ts","../src/react/use-wizard.ts","../src/utils/cn.ts"],"names":["createContext","useContext"],"mappings":"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","file":"/Users/knazark/work/extract-tmp/perks-extract/dist/chunk-XNH2LQZL.cjs","sourcesContent":[null,"export class WizardError extends Error {\n\tpublic override readonly name: string = 'WizardError';\n\n\tconstructor(message?: string) {\n\t\tsuper(message);\n\t\tObject.setPrototypeOf(this, new.target.prototype);\n\t}\n}\n\nexport class WizardInitializationError extends WizardError {\n\tpublic override readonly name: string = 'WizardInitializationError';\n}\n\nexport class WizardNavigationError extends WizardError {\n\tpublic override readonly name: string = 'WizardNavigationError';\n}\n\nexport class WizardResolverError extends WizardError {\n\tpublic override readonly name: string = 'WizardResolverError';\n}\n","'use client';\n\nimport { type ComponentType, createContext, type ReactNode, useContext } from 'react';\n\nexport interface IWizardButtonProps {\n\tasChild?: boolean;\n\tchildren?: ReactNode;\n\tclassName?: string;\n\tdisabled?: boolean;\n\tonClick?: () => void;\n\ttype?: 'button' | 'submit';\n\tvariant?: 'default' | 'ghost';\n\tsize?: 'default' | 'icon-sm';\n\t'aria-label'?: string;\n}\n\nexport interface IWizardBackArrowIconProps {\n\tclassName?: string;\n}\n\nexport interface IWizardComponents {\n\tButton: ComponentType<IWizardButtonProps>;\n\tBackArrowIcon: ComponentType<IWizardBackArrowIconProps>;\n}\n\nconst FallbackButton: ComponentType<IWizardButtonProps> = (props) => {\n\tconst { children, asChild: _asChild, variant: _variant, size: _size, ...rest } = props;\n\treturn (\n\t\t<button {...rest} type={props.type ?? 'button'}>\n\t\t\t{children}\n\t\t</button>\n\t);\n};\n\nconst FallbackBackArrowIcon: ComponentType<IWizardBackArrowIconProps> = ({ className }) => (\n\t<svg className={className} width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden>\n\t\t<path d=\"M10 4 L6 8 L10 12\" stroke=\"currentColor\" strokeWidth=\"1.5\" fill=\"none\" />\n\t</svg>\n);\n\nconst defaults: IWizardComponents = { Button: FallbackButton, BackArrowIcon: FallbackBackArrowIcon };\n\nconst WizardComponentsContext = createContext<IWizardComponents>(defaults);\n\nexport function WizardComponentsProvider(props: {\n\tButton?: ComponentType<IWizardButtonProps>;\n\tBackArrowIcon?: ComponentType<IWizardBackArrowIconProps>;\n\tchildren: ReactNode;\n}) {\n\tconst { Button, BackArrowIcon, children } = props;\n\tconst value: IWizardComponents = {\n\t\tButton: Button ?? defaults.Button,\n\t\tBackArrowIcon: BackArrowIcon ?? defaults.BackArrowIcon,\n\t};\n\treturn <WizardComponentsContext.Provider value={value}>{children}</WizardComponentsContext.Provider>;\n}\n\nexport function useWizardComponents(): IWizardComponents {\n\treturn useContext(WizardComponentsContext);\n}\n","'use client';\n\nimport { createContext } from 'react';\n\nimport type { WizardEngine } from '../core/wizard-engine';\n\n/**\n * React context exposing the active `WizardEngine` instance to descendants.\n * `null` outside a `<WizardProvider>` — `useWizard()` throws a clear error.\n */\nexport const WizardEngineContext = createContext<null | WizardEngine<string, string, string>>(null);\n","'use client';\n\nimport { useContext, useSyncExternalStore } from 'react';\n\nimport type { WizardEngine } from '../core/wizard-engine';\n\nimport { WizardError } from '../core/errors';\nimport { WizardEngineContext } from './context';\n\n/**\n * Returns the active `WizardEngine` instance and re-renders the consumer on\n * every tree change. Throws if used outside a `<WizardProvider>`.\n *\n * Engine identity is stable across renders.\n */\nexport function useWizard<Step extends string, Category extends string, Branch extends string = string>(): WizardEngine<\n\tStep,\n\tCategory,\n\tBranch\n> {\n\tconst engine = useContext(WizardEngineContext) as null | WizardEngine<Step, Category, Branch>;\n\tif (!engine) {\n\t\tthrow new WizardError('useWizard must be used inside <WizardProvider>');\n\t}\n\tuseSyncExternalStore(engine.subscribe, engine.getTreeSnapshot, engine.getTreeSnapshot);\n\treturn engine;\n}\n","import { clsx, type ClassValue } from 'clsx';\nimport { twMerge } from 'tailwind-merge';\n\nexport function cn(...inputs: ClassValue[]): string {\n return twMerge(clsx(...inputs));\n}\n"]}
|