@wizzard-packages/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.cjs +680 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +116 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.js +655 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/context/WizardContext.tsx","../src/hooks/useWizard.ts","../src/factory.tsx","../src/components/WizardStepRenderer.tsx"],"sourcesContent":["export * from './factory';\nexport * from './context/WizardContext';\nexport * from './components/WizardStepRenderer';\nexport * from './hooks/useWizard';\nexport * from './types';\n\n// Re-export core for convenience and backward compatibility\nexport { WizardStore } from '@wizzard-packages/core';\nexport { loggerMiddleware } from '@wizzard-packages/middleware';\nexport type {\n IWizardState,\n IWizardActions,\n IWizardContext,\n IStepConfig,\n IWizardConfig,\n ValidationResult,\n IValidatorAdapter,\n PersistenceMode,\n WizardMiddleware,\n} from '@wizzard-packages/core';\n","import React, {\n createContext,\n useContext,\n useEffect,\n useMemo,\n useState,\n useCallback,\n useSyncExternalStore,\n useRef,\n} from 'react';\nimport {\n type IWizardConfig,\n type IPersistenceAdapter,\n type IStepConfig,\n type IWizardContext,\n type IWizardState,\n type IWizardActions,\n type IWizardStore,\n type WizardEventHandler,\n type WizardEventName,\n WizardStore,\n getByPath,\n setByPath,\n} from '@wizzard-packages/core';\nimport { MemoryAdapter } from '@wizzard-packages/persistence';\n\nconst WizardStateContext = createContext<IWizardState<any, any> | undefined>(undefined);\nconst WizardActionsContext = createContext<IWizardActions<any> | undefined>(undefined);\nconst WizardStoreContext = createContext<IWizardStore<any, any> | undefined>(undefined);\n\n/**\n * Props for WizardProvider.\n */\nexport interface WizardProviderProps<T, StepId extends string> {\n config: IWizardConfig<T, StepId>;\n initialData?: T;\n initialStepId?: StepId;\n children: React.ReactNode;\n}\n\n/**\n * Component that provides the wizard context to its children.\n */\nexport function WizardProvider<T extends Record<string, any>, StepId extends string = string>({\n config,\n initialData,\n initialStepId,\n children,\n}: WizardProviderProps<T, StepId>) {\n const [localConfig, setLocalConfig] = useState<IWizardConfig<T, StepId>>(config);\n\n const storeRef = useRef<IWizardStore<T, StepId>>(null as unknown as IWizardStore<T, StepId>);\n\n if (!storeRef.current) {\n storeRef.current = new WizardStore<T, StepId>((initialData || {}) as T, config.middlewares);\n }\n\n const isInitialized = useRef(false);\n\n const persistenceAdapter = useMemo<IPersistenceAdapter>(() => {\n return localConfig.persistence?.adapter || new MemoryAdapter();\n }, [localConfig.persistence?.adapter]);\n\n const persistenceMode = localConfig.persistence?.mode || 'onStepChange';\n const META_KEY = '__wizzard_meta__';\n\n const snapshot = useSyncExternalStore<IWizardState<T, StepId>>(\n storeRef.current.subscribe,\n storeRef.current.getSnapshot\n );\n\n const {\n activeSteps,\n currentStepId,\n history,\n visitedSteps,\n completedSteps,\n data,\n errors: _errors,\n } = snapshot;\n\n const stepsMap = useMemo(() => {\n const map = new Map<StepId, IStepConfig<T, StepId>>();\n localConfig.steps.forEach((step: IStepConfig<T, StepId>) => map.set(step.id, step));\n return map;\n }, [localConfig.steps]);\n\n useEffect(() => {\n setLocalConfig(config);\n }, [config]);\n\n const activeStepsIndexMap = useMemo(() => {\n const map = new Map<StepId, number>();\n activeSteps.forEach((s: IStepConfig<T, StepId>, i: number) => map.set(s.id, i));\n return map;\n }, [activeSteps]);\n\n const stateRef = useRef({\n config: localConfig,\n stepsMap,\n activeSteps,\n activeStepsIndexMap,\n visitedSteps,\n completedSteps,\n persistenceMode,\n persistenceAdapter,\n currentStepId,\n history,\n });\n\n const validationDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n stateRef.current = {\n config: localConfig,\n stepsMap,\n activeSteps,\n activeStepsIndexMap,\n visitedSteps,\n completedSteps,\n persistenceMode,\n persistenceAdapter,\n currentStepId,\n history,\n };\n });\n\n useEffect(() => {\n return () => {\n if (validationDebounceRef.current) {\n clearTimeout(validationDebounceRef.current);\n }\n };\n }, []);\n\n const trackEvent = useCallback<WizardEventHandler<StepId>>(\n (name: WizardEventName, payload: any) => {\n localConfig.analytics?.onEvent(name as any, payload);\n },\n [localConfig.analytics]\n );\n\n const resolveActiveStepsHelper = useCallback(\n (data: T) => storeRef.current.resolveActiveSteps(data),\n []\n );\n\n const validateStep = useCallback((stepId: StepId) => storeRef.current.validateStep(stepId), []);\n\n const goToStep = useCallback(\n async (\n stepId: StepId,\n providedActiveSteps?: IStepConfig<T, StepId>[],\n options: { validate?: boolean } = { validate: true }\n ): Promise<boolean> => {\n return storeRef.current.goToStep(stepId, {\n validate: options.validate,\n providedActiveSteps: providedActiveSteps as any,\n });\n },\n []\n );\n\n const goToNextStep = useCallback(async () => {\n const { currentStepId } = stateRef.current;\n if (!currentStepId) return;\n\n const currentData = storeRef.current.getSnapshot().data;\n const step = stepsMap.get(currentStepId as StepId);\n\n const shouldVal = step?.autoValidate ?? localConfig.autoValidate ?? !!step?.validationAdapter;\n\n if (shouldVal) {\n const ok = await validateStep(currentStepId as StepId);\n if (!ok) return;\n }\n\n const resolvedSteps = await resolveActiveStepsHelper(currentData);\n const idx = resolvedSteps.findIndex((s: IStepConfig<T, StepId>) => s.id === currentStepId);\n\n if (idx !== -1 && idx < resolvedSteps.length - 1) {\n const nextStepId = resolvedSteps[idx + 1].id;\n const success = await goToStep(nextStepId as any, resolvedSteps as any, {\n validate: false,\n });\n if (success) {\n const currentSnapshot = storeRef.current.getSnapshot();\n if (!currentSnapshot.errorSteps.has(currentStepId as StepId)) {\n const nextComp = new Set(currentSnapshot.completedSteps);\n nextComp.add(currentStepId as StepId);\n storeRef.current.dispatch({\n type: 'SET_COMPLETED_STEPS',\n payload: { steps: nextComp },\n });\n }\n }\n }\n }, [goToStep, resolveActiveStepsHelper, validateStep, stepsMap, localConfig]);\n\n const goToPrevStep = useCallback(async () => {\n const { currentStepId, activeSteps, activeStepsIndexMap } = stateRef.current;\n const idx = activeStepsIndexMap.get(currentStepId as StepId) ?? -1;\n if (idx > 0) await goToStep(activeSteps[idx - 1].id as any);\n }, [goToStep]);\n\n const handleStepDependencies = useCallback(\n (paths: string[], initialData: any) => {\n let currentData = { ...initialData };\n const allClearedPaths = new Set<string>();\n const { completedSteps, visitedSteps } = storeRef.current.getSnapshot();\n const nextComp = new Set(completedSteps);\n const nextVis = new Set(visitedSteps);\n let statusChanged = false;\n\n const processDependencies = (changedPaths: string[]) => {\n const newlyClearedPaths: string[] = [];\n\n localConfig.steps.forEach((step: IStepConfig<T, StepId>) => {\n const isDependent = step.dependsOn?.some((p: string) =>\n changedPaths.some(\n (path) => path === p || p.startsWith(path + '.') || path.startsWith(p + '.')\n )\n );\n\n if (isDependent) {\n if (nextComp.delete(step.id as StepId)) {\n statusChanged = true;\n }\n if (nextVis.delete(step.id as StepId)) {\n statusChanged = true;\n }\n\n if (step.clearData) {\n if (typeof step.clearData === 'function') {\n const patch = step.clearData(currentData, changedPaths);\n Object.keys(patch).forEach((key) => {\n if (currentData[key] !== patch[key]) {\n currentData[key] = patch[key];\n newlyClearedPaths.push(key);\n allClearedPaths.add(key);\n }\n });\n } else {\n const pathsToClear = Array.isArray(step.clearData)\n ? step.clearData\n : [step.clearData];\n pathsToClear.forEach((p: string) => {\n const val = getByPath(currentData, p);\n if (val !== undefined) {\n currentData = setByPath(currentData, p, undefined);\n newlyClearedPaths.push(p);\n allClearedPaths.add(p);\n }\n });\n }\n }\n }\n });\n\n if (newlyClearedPaths.length > 0) {\n processDependencies(newlyClearedPaths);\n }\n };\n\n processDependencies(paths);\n\n if (statusChanged) {\n storeRef.current.dispatch({\n type: 'SET_COMPLETED_STEPS',\n payload: { steps: nextComp },\n });\n storeRef.current.dispatch({\n type: 'SET_VISITED_STEPS',\n payload: { steps: nextVis },\n });\n }\n\n return {\n newData: currentData,\n hasClearing: allClearedPaths.size > 0,\n clearedPaths: Array.from(allClearedPaths),\n };\n },\n [localConfig.steps]\n );\n\n const setData = useCallback(\n (path: string, value: any, options?: { debounceValidation?: number }) => {\n const { stepsMap, currentStepId } = stateRef.current;\n const prevData = storeRef.current.getSnapshot().data;\n if (getByPath(prevData, path) === value) return;\n\n const baseData = setByPath(prevData, path, value);\n const { newData, hasClearing } = handleStepDependencies([path], baseData);\n\n if (!hasClearing) {\n storeRef.current.dispatch({\n type: 'SET_DATA',\n payload: {\n path,\n value,\n options: { ...options, __from_set_data__: true },\n },\n });\n } else {\n storeRef.current.dispatch({\n type: 'UPDATE_DATA',\n payload: {\n data: newData,\n options: { replace: true, __from_set_data__: true, path },\n },\n });\n }\n\n if (currentStepId) {\n storeRef.current.deleteError(currentStepId as StepId, path);\n const step = stepsMap.get(currentStepId as StepId);\n const mode = step?.validationMode || localConfig.validationMode || 'onStepChange';\n\n if (mode === 'onChange') {\n const debounceMs =\n options?.debounceValidation ?? localConfig.validationDebounceTime ?? 300;\n if (validationDebounceRef.current) {\n clearTimeout(validationDebounceRef.current);\n }\n validationDebounceRef.current = setTimeout(() => {\n validateStep(currentStepId as StepId);\n }, debounceMs);\n }\n }\n },\n [localConfig, validateStep, handleStepDependencies]\n );\n\n const updateData = useCallback(\n (data: Partial<T>, options?: { replace?: boolean; persist?: boolean }) => {\n const prev = storeRef.current.getSnapshot().data;\n const baseData = (options?.replace ? (data as T) : { ...prev, ...data }) as T;\n\n const { newData } = handleStepDependencies(Object.keys(data), baseData);\n\n storeRef.current.update(newData as T, Object.keys(data));\n if (options?.persist) {\n if (storeRef.current.save) {\n storeRef.current.save(storeRef.current.getSnapshot().currentStepId as StepId);\n }\n }\n },\n [handleStepDependencies]\n );\n\n const reset = useCallback(() => {\n storeRef.current.setInitialData(initialData || ({} as T));\n storeRef.current.update((initialData || {}) as T);\n storeRef.current.updateErrors({} as Record<StepId, Record<string, string>>);\n storeRef.current.dispatch({\n type: 'SET_VISITED_STEPS',\n payload: { steps: new Set() },\n });\n storeRef.current.dispatch({\n type: 'SET_COMPLETED_STEPS',\n payload: { steps: new Set() },\n });\n storeRef.current.dispatch({\n type: 'SET_ERROR_STEPS',\n payload: { steps: new Set() },\n });\n if (activeSteps.length > 0) {\n const startId = activeSteps[0].id;\n storeRef.current.dispatch({\n type: 'SET_CURRENT_STEP_ID',\n payload: { stepId: startId as StepId },\n });\n storeRef.current.dispatch({\n type: 'SET_HISTORY',\n payload: { history: [startId as StepId] },\n });\n } else {\n storeRef.current.dispatch({\n type: 'SET_CURRENT_STEP_ID',\n payload: { stepId: '' as StepId },\n });\n storeRef.current.dispatch({\n type: 'SET_HISTORY',\n payload: { history: [] },\n });\n }\n persistenceAdapter.clear();\n trackEvent('wizard_reset', { data: initialData } as any);\n }, [initialData, activeSteps, persistenceAdapter, trackEvent]);\n\n const stateValue = useMemo<IWizardState<T, StepId>>(\n () => ({\n ...snapshot,\n config: localConfig,\n }),\n [snapshot, localConfig]\n );\n\n const actionsValue = useMemo<IWizardActions<StepId>>(\n () => ({\n goToNextStep,\n goToPrevStep,\n goToStep: (sid: StepId, optionsOrUndefined?: any, thirdArg?: any) => {\n // Handle both signatures:\n // 1. goToStep(id, options)\n // 2. goToStep(id, undefined, options) - mistakenly used by user but likely legacy or internal leak\n\n let finalOptions = optionsOrUndefined;\n if (thirdArg && optionsOrUndefined === undefined) {\n finalOptions = thirdArg;\n }\n\n return goToStep(sid, undefined, finalOptions);\n },\n setStepData: (_stepId: StepId, data: any) => {\n const next = { ...storeRef.current.getSnapshot().data, ...data };\n storeRef.current.update(next as T, Object.keys(data));\n },\n handleStepChange: (f: string, v: any) => {\n if (stateRef.current.currentStepId) setData(f, v);\n },\n validateStep: (sid: StepId) => validateStep(sid),\n validateAll: async () => {\n storeRef.current.updateMeta({ isBusy: true });\n const data = storeRef.current.getSnapshot().data;\n const active = await resolveActiveStepsHelper(data);\n const results = await Promise.all(\n active.map((s: IStepConfig<T, StepId>) => validateStep(s.id as StepId))\n );\n storeRef.current.updateMeta({ isBusy: false });\n return {\n isValid: results.every(Boolean),\n errors: storeRef.current.getSnapshot().errors,\n };\n },\n save: (ids?: StepId | StepId[] | boolean) => {\n if (ids === true) {\n localConfig.steps.forEach((s: IStepConfig<T, StepId>) =>\n storeRef.current.save(s.id as StepId)\n );\n } else if (!ids) {\n storeRef.current.save();\n } else {\n (Array.isArray(ids) ? ids : [ids]).forEach((id) => storeRef.current.save(id as StepId));\n }\n },\n clearStorage: () => persistenceAdapter.clear(),\n reset,\n setData,\n updateData,\n getData: (p: string, d?: any) => getByPath(storeRef.current.getSnapshot().data, p, d),\n updateConfig: (nc: any) => {\n setLocalConfig((prev: IWizardConfig<T, StepId>) => ({ ...prev, ...nc }));\n },\n }),\n [\n goToNextStep,\n goToPrevStep,\n goToStep,\n validateStep,\n reset,\n setData,\n updateData,\n persistenceAdapter,\n localConfig,\n resolveActiveStepsHelper,\n ]\n );\n\n useEffect(() => {\n if (!isInitialized.current) {\n storeRef.current.injectPersistence(persistenceAdapter);\n storeRef.current.dispatch({\n type: 'INIT',\n payload: { data: initialData || ({} as T), config: localConfig as any },\n });\n storeRef.current.hydrate();\n isInitialized.current = true;\n } else {\n storeRef.current.updateMeta({ config: localConfig as any });\n }\n }, [initialData, localConfig, persistenceAdapter]);\n\n useEffect(() => {\n let isMounted = true;\n const timeoutId = setTimeout(async () => {\n const resolved = await resolveActiveStepsHelper(data);\n if (isMounted) {\n storeRef.current.dispatch({\n type: 'SET_ACTIVE_STEPS',\n payload: { steps: resolved as any },\n });\n }\n }, 200);\n\n return () => {\n isMounted = false;\n clearTimeout(timeoutId);\n };\n }, [data, resolveActiveStepsHelper]);\n\n const hasHydratedRef = useRef(false);\n\n useEffect(() => {\n if (hasHydratedRef.current) return;\n hasHydratedRef.current = true;\n\n const meta = persistenceAdapter.getStep<{\n currentStepId: string;\n visited: string[];\n completed: string[];\n history: string[];\n }>(META_KEY);\n if (meta) {\n if (meta.currentStepId) {\n storeRef.current.dispatch({\n type: 'SET_CURRENT_STEP_ID',\n payload: { stepId: meta.currentStepId as StepId },\n });\n }\n if (meta.visited)\n storeRef.current.dispatch({\n type: 'SET_VISITED_STEPS',\n payload: { steps: new Set(meta.visited as StepId[]) },\n });\n if (meta.completed)\n storeRef.current.dispatch({\n type: 'SET_COMPLETED_STEPS',\n payload: { steps: new Set(meta.completed as StepId[]) },\n });\n if (meta.history) {\n storeRef.current.dispatch({\n type: 'SET_HISTORY',\n payload: { history: meta.history as StepId[] },\n });\n }\n }\n\n const currentSnapshot = storeRef.current.getSnapshot();\n const currentActiveSteps = currentSnapshot.activeSteps;\n\n if (!currentSnapshot.currentStepId && currentActiveSteps.length > 0) {\n const startId =\n initialStepId &&\n currentActiveSteps.some((s: IStepConfig<T, StepId>) => s.id === initialStepId)\n ? initialStepId\n : currentActiveSteps[0].id;\n\n storeRef.current.dispatch({\n type: 'SET_CURRENT_STEP_ID',\n payload: { stepId: startId as StepId },\n });\n\n if (currentSnapshot.history.length === 0) {\n storeRef.current.dispatch({\n type: 'SET_HISTORY',\n payload: { history: [startId as StepId] },\n });\n }\n\n const currentVisited = new Set(currentSnapshot.visitedSteps);\n if (!currentVisited.has(startId as StepId)) {\n currentVisited.add(startId as StepId);\n storeRef.current.dispatch({\n type: 'SET_VISITED_STEPS',\n payload: { steps: currentVisited },\n });\n }\n }\n\n if (currentActiveSteps.length > 0 && currentSnapshot.isLoading) {\n storeRef.current.updateMeta({ isLoading: false });\n }\n }, [activeSteps, initialStepId, persistenceAdapter]);\n\n return (\n <WizardStoreContext.Provider value={storeRef.current as any}>\n <WizardStateContext.Provider value={stateValue}>\n <WizardActionsContext.Provider value={actionsValue}>\n {children}\n </WizardActionsContext.Provider>\n </WizardStateContext.Provider>\n </WizardStoreContext.Provider>\n );\n}\n\n/**\n * Reads the full wizard state.\n */\nexport function useWizardState<T = unknown, StepId extends string = string>(): IWizardState<\n T,\n StepId\n> {\n const context = useContext(WizardStateContext);\n if (!context) throw new Error('useWizardState must be used within a WizardProvider');\n return context as IWizardState<T, StepId>;\n}\n\n/**\n * Subscribes to a specific data value by path.\n */\nexport function useWizardValue<TValue = any>(\n path: string,\n options?: { isEqual?: (a: TValue, b: TValue) => boolean }\n): TValue {\n const store = useContext(WizardStoreContext);\n if (!store) throw new Error('useWizardValue must be used within a WizardProvider');\n const lastStateRef = useRef<any>(null);\n const lastValueRef = useRef<any>(null);\n const getSnapshot = useCallback(() => {\n const data = store.getSnapshot().data;\n if (data === lastStateRef.current) return lastValueRef.current;\n const value = getByPath(data, path) as TValue;\n if (\n lastValueRef.current !== undefined &&\n (options?.isEqual || Object.is)(lastValueRef.current, value)\n ) {\n lastStateRef.current = data;\n return lastValueRef.current;\n }\n lastStateRef.current = data;\n lastValueRef.current = value;\n return value;\n }, [store, path, options?.isEqual]);\n return useSyncExternalStore(store.subscribe, getSnapshot);\n}\n\n/**\n * Returns the first error message for a path across all steps.\n */\nexport function useWizardError(path: string): string | undefined {\n const store = useContext(WizardStoreContext);\n if (!store) throw new Error('useWizardError must be used within a WizardProvider');\n const getSnapshot = useCallback(() => {\n const errors = store.getSnapshot().errors;\n for (const [_, stepErrors] of Object.entries(errors)) {\n const typed = stepErrors as Record<string, string>;\n if (typed[path]) return typed[path];\n }\n return undefined;\n }, [store, path]);\n return useSyncExternalStore(store.subscribe, getSnapshot);\n}\n\n/**\n * Selects a derived value from the wizard state with optional equality check.\n */\nexport function useWizardSelector<TSelected = any>(\n selector: (state: any) => TSelected,\n options?: { isEqual?: (a: TSelected, b: TSelected) => boolean }\n): TSelected {\n const store = useContext(WizardStoreContext);\n if (!store) throw new Error('useWizardSelector must be used within a WizardProvider');\n\n const lastResultRef = useRef<TSelected | null>(null);\n\n const getSnapshot = useCallback(() => {\n const full = store.getSnapshot();\n const res = selector(full);\n\n if (\n lastResultRef.current !== null &&\n (options?.isEqual || Object.is)(lastResultRef.current, res)\n ) {\n return lastResultRef.current;\n }\n\n lastResultRef.current = res;\n return res;\n }, [store, selector, options?.isEqual]);\n\n return useSyncExternalStore(store.subscribe, getSnapshot);\n}\n\n/**\n * Returns the wizard actions API.\n */\nexport function useWizardActions<StepId extends string = string>(): IWizardActions<StepId> {\n const context = useContext(WizardActionsContext);\n if (!context) throw new Error('useWizardActions must be used within a WizardProvider');\n return context as IWizardActions<StepId>;\n}\n\n/**\n * Returns combined wizard state, actions, and derived errors.\n */\nexport function useWizardContext<T = any, StepId extends string = string>(): IWizardContext<\n T,\n StepId\n> {\n const state = useWizardState<T, StepId>();\n const actions = useWizardActions<StepId>();\n const store = useContext(WizardStoreContext) as IWizardStore<T, StepId>;\n const data = useWizardSelector((s: IWizardState<T, StepId>) => s.data);\n const allErrors = useWizardSelector((s: IWizardState<T, StepId>) => s.errors);\n const errors = useMemo(() => {\n const flat: Record<string, string> = {};\n Object.values(allErrors).forEach((stepErrors) => {\n Object.assign(flat, stepErrors as Record<string, string>);\n });\n return flat;\n }, [allErrors]);\n\n const { data: _d, errors: _e, ...stateProps } = state as any;\n return useMemo(\n () => ({\n ...stateProps,\n ...actions,\n data,\n allErrors,\n errors,\n store,\n }),\n [stateProps, actions, data, allErrors, errors, store]\n ) as IWizardContext<T, StepId>;\n}\n","import { useWizardContext } from '../context/WizardContext';\nimport type { IWizardContext } from '../types';\n\n/**\n * Alias for useWizardContext.\n */\nexport const useWizard = <T = any, StepId extends string = string>(): IWizardContext<T, StepId> => {\n return useWizardContext<T, StepId>();\n};\n","import React from 'react';\nimport {\n WizardProvider as BaseWizardProvider,\n useWizardContext as useBaseWizardContext,\n useWizardValue as useBaseWizardValue,\n useWizardSelector as useBaseWizardSelector,\n useWizardError as useBaseWizardError,\n useWizardActions as useBaseWizardActions,\n useWizardState as useBaseWizardState,\n} from './context/WizardContext';\nimport { useWizard as useBaseWizard } from './hooks/useWizard';\nimport type { IWizardConfig, IWizardContext, IStepConfig, Path, PathValue } from '@wizzard-packages/core';\n\n/**\n * createWizardFactory\n *\n * Creates a strongly-typed set of Wizard components and hooks for a specific data schema.\n *\n * @template TSchema The shape of your wizard's global data state\n */\nexport function createWizardFactory<\n TSchema extends Record<string, any>,\n StepId extends string = string,\n>() {\n const WizardProvider = ({\n config,\n initialData,\n children,\n }: {\n config: IWizardConfig<TSchema, StepId>;\n initialData?: Partial<TSchema>;\n children: React.ReactNode;\n }) => {\n return (\n <BaseWizardProvider<TSchema, StepId> config={config} initialData={initialData as TSchema}>\n {children}\n </BaseWizardProvider>\n );\n };\n\n const useWizard = (): IWizardContext<TSchema, StepId> => {\n return useBaseWizard<TSchema, StepId>() as any;\n };\n\n const useWizardContext = () => {\n return useBaseWizardContext<TSchema, StepId>() as any;\n };\n\n const useWizardValue = <P extends Path<TSchema>>(\n path: P,\n options?: {\n isEqual?: (a: PathValue<TSchema, P>, b: PathValue<TSchema, P>) => boolean;\n }\n ): PathValue<TSchema, P> => {\n return useBaseWizardValue<PathValue<TSchema, P>>(path as string, options);\n };\n\n const useWizardSelector = <TSelected,>(\n selector: (state: IWizardContext<TSchema, StepId>) => TSelected,\n options?: { isEqual?: (a: TSelected, b: TSelected) => boolean }\n ): TSelected => {\n return useBaseWizardSelector<TSelected>(selector as any, options);\n };\n\n const useWizardError = <P extends Path<TSchema>>(path: P): string | undefined => {\n return useBaseWizardError(path as string);\n };\n\n const useWizardActions = () => {\n return useBaseWizardActions<StepId>();\n };\n\n const useWizardState = () => {\n return useBaseWizardState<TSchema, StepId>();\n };\n\n const useBreadcrumbs = () => {\n return useBaseWizardState<TSchema, StepId>().breadcrumbs;\n };\n\n const createStep = (config: IStepConfig<TSchema, StepId>) => config;\n\n return {\n WizardProvider,\n useWizard,\n useWizardContext,\n useWizardValue,\n useWizardSelector,\n useWizardError,\n useWizardActions,\n useWizardState,\n useBreadcrumbs,\n createStep,\n };\n}\n","import React, { useMemo, Suspense } from 'react';\nimport { useWizardContext } from '../context/WizardContext';\n\n/**\n * Props for rendering the current step component.\n */\nexport interface WizardStepRendererProps {\n wrapper?: React.ComponentType<{ children: React.ReactNode; key: string }>;\n fallback?: React.ReactNode;\n}\n\n/**\n * Renders the active step component with optional wrapper and suspense fallback.\n */\nexport const WizardStepRenderer: React.FC<WizardStepRendererProps> = ({\n wrapper: Wrapper,\n fallback = null,\n}) => {\n const { currentStep } = useWizardContext();\n\n const StepComponent = useMemo(() => {\n if (!currentStep?.component) return null;\n return currentStep.component;\n }, [currentStep]);\n\n if (!currentStep || !StepComponent) {\n return null;\n }\n\n const content = (\n <Suspense fallback={fallback}>\n <StepComponent />\n </Suspense>\n );\n\n if (Wrapper) {\n return <Wrapper key={currentStep.id}>{content}</Wrapper>;\n }\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBASO;AACP,kBAaO;AACP,yBAA8B;AA2iBtB;AAziBR,IAAM,yBAAqB,4BAAkD,MAAS;AACtF,IAAM,2BAAuB,4BAA+C,MAAS;AACrF,IAAM,yBAAqB,4BAAkD,MAAS;AAe/E,SAAS,eAA8E;AAAA,EAC5F;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAmC,MAAM;AAE/E,QAAM,eAAW,qBAAgC,IAA0C;AAE3F,MAAI,CAAC,SAAS,SAAS;AACrB,aAAS,UAAU,IAAI,wBAAwB,eAAe,CAAC,GAAS,OAAO,WAAW;AAAA,EAC5F;AAEA,QAAM,oBAAgB,qBAAO,KAAK;AAElC,QAAM,yBAAqB,sBAA6B,MAAM;AAC5D,WAAO,YAAY,aAAa,WAAW,IAAI,iCAAc;AAAA,EAC/D,GAAG,CAAC,YAAY,aAAa,OAAO,CAAC;AAErC,QAAM,kBAAkB,YAAY,aAAa,QAAQ;AACzD,QAAM,WAAW;AAEjB,QAAM,eAAW;AAAA,IACf,SAAS,QAAQ;AAAA,IACjB,SAAS,QAAQ;AAAA,EACnB;AAEA,QAAM;AAAA,IACJ;AAAA,IACA;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,CACxB,UACA,YACc;AACd,WAAO,kBAAiC,UAAiB,OAAO;AAAA,EAClE;AAEA,QAAMC,kBAAiB,CAA0B,SAAgC;AAC/E,WAAO,eAAmB,IAAc;AAAA,EAC1C;AAEA,QAAMC,oBAAmB,MAAM;AAC7B,WAAO,iBAA6B;AAAA,EACtC;AAEA,QAAMC,kBAAiB,MAAM;AAC3B,WAAO,eAAoC;AAAA,EAC7C;AAEA,QAAM,iBAAiB,MAAM;AAC3B,WAAO,eAAoC,EAAE;AAAA,EAC/C;AAEA,QAAM,aAAa,CAAC,WAAyC;AAE7D,SAAO;AAAA,IACL,gBAAAP;AAAA,IACA,WAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;;;AC9FA,IAAAC,gBAAyC;AA+BnC,IAAAC,sBAAA;AAjBC,IAAM,qBAAwD,CAAC;AAAA,EACpE,SAAS;AAAA,EACT,WAAW;AACb,MAAM;AACJ,QAAM,EAAE,YAAY,IAAI,iBAAiB;AAEzC,QAAM,oBAAgB,uBAAQ,MAAM;AAClC,QAAI,CAAC,aAAa,UAAW,QAAO;AACpC,WAAO,YAAY;AAAA,EACrB,GAAG,CAAC,WAAW,CAAC;AAEhB,MAAI,CAAC,eAAe,CAAC,eAAe;AAClC,WAAO;AAAA,EACT;AAEA,QAAM,UACJ,6CAAC,0BAAS,UACR,uDAAC,iBAAc,GACjB;AAGF,MAAI,SAAS;AACX,WAAO,6CAAC,WAA8B,qBAAjB,YAAY,EAAa;AAAA,EAChD;AAEA,SAAO;AACT;;;AJjCA,IAAAC,eAA4B;AAC5B,wBAAiC;","names":["data","currentStepId","activeSteps","activeStepsIndexMap","initialData","completedSteps","visitedSteps","stepsMap","import_jsx_runtime","WizardProvider","useWizard","useWizardContext","useWizardValue","useWizardSelector","useWizardError","useWizardActions","useWizardState","import_react","import_jsx_runtime","import_core"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as _wizzard_packages_core from '@wizzard-packages/core';
|
|
2
|
+
import { IWizardConfig, IWizardContext as IWizardContext$1, Path, PathValue, IStepConfig, IWizardState, IWizardActions as IWizardActions$1 } from '@wizzard-packages/core';
|
|
3
|
+
export { IStepConfig, IValidatorAdapter, IWizardActions, IWizardConfig, IWizardContext, IWizardState, PersistenceMode, ValidationResult, WizardMiddleware, WizardStore } from '@wizzard-packages/core';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export { loggerMiddleware } from '@wizzard-packages/middleware';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* createWizardFactory
|
|
10
|
+
*
|
|
11
|
+
* Creates a strongly-typed set of Wizard components and hooks for a specific data schema.
|
|
12
|
+
*
|
|
13
|
+
* @template TSchema The shape of your wizard's global data state
|
|
14
|
+
*/
|
|
15
|
+
declare function createWizardFactory<TSchema extends Record<string, any>, StepId extends string = string>(): {
|
|
16
|
+
WizardProvider: ({ config, initialData, children, }: {
|
|
17
|
+
config: IWizardConfig<TSchema, StepId>;
|
|
18
|
+
initialData?: Partial<TSchema>;
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
21
|
+
useWizard: () => IWizardContext$1<TSchema, StepId>;
|
|
22
|
+
useWizardContext: () => any;
|
|
23
|
+
useWizardValue: <P extends Path<TSchema>>(path: P, options?: {
|
|
24
|
+
isEqual?: (a: PathValue<TSchema, P>, b: PathValue<TSchema, P>) => boolean;
|
|
25
|
+
}) => PathValue<TSchema, P>;
|
|
26
|
+
useWizardSelector: <TSelected>(selector: (state: IWizardContext$1<TSchema, StepId>) => TSelected, options?: {
|
|
27
|
+
isEqual?: (a: TSelected, b: TSelected) => boolean;
|
|
28
|
+
}) => TSelected;
|
|
29
|
+
useWizardError: <P extends Path<TSchema>>(path: P) => string | undefined;
|
|
30
|
+
useWizardActions: () => _wizzard_packages_core.IWizardActions<StepId>;
|
|
31
|
+
useWizardState: () => _wizzard_packages_core.IWizardState<TSchema, StepId>;
|
|
32
|
+
useBreadcrumbs: () => _wizzard_packages_core.IBreadcrumb<StepId>[];
|
|
33
|
+
createStep: (config: IStepConfig<TSchema, StepId>) => IStepConfig<TSchema, StepId>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Props for WizardProvider.
|
|
38
|
+
*/
|
|
39
|
+
interface WizardProviderProps<T, StepId extends string> {
|
|
40
|
+
config: IWizardConfig<T, StepId>;
|
|
41
|
+
initialData?: T;
|
|
42
|
+
initialStepId?: StepId;
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Component that provides the wizard context to its children.
|
|
47
|
+
*/
|
|
48
|
+
declare function WizardProvider<T extends Record<string, any>, StepId extends string = string>({ config, initialData, initialStepId, children, }: WizardProviderProps<T, StepId>): react_jsx_runtime.JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Reads the full wizard state.
|
|
51
|
+
*/
|
|
52
|
+
declare function useWizardState<T = unknown, StepId extends string = string>(): IWizardState<T, StepId>;
|
|
53
|
+
/**
|
|
54
|
+
* Subscribes to a specific data value by path.
|
|
55
|
+
*/
|
|
56
|
+
declare function useWizardValue<TValue = any>(path: string, options?: {
|
|
57
|
+
isEqual?: (a: TValue, b: TValue) => boolean;
|
|
58
|
+
}): TValue;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the first error message for a path across all steps.
|
|
61
|
+
*/
|
|
62
|
+
declare function useWizardError(path: string): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Selects a derived value from the wizard state with optional equality check.
|
|
65
|
+
*/
|
|
66
|
+
declare function useWizardSelector<TSelected = any>(selector: (state: any) => TSelected, options?: {
|
|
67
|
+
isEqual?: (a: TSelected, b: TSelected) => boolean;
|
|
68
|
+
}): TSelected;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the wizard actions API.
|
|
71
|
+
*/
|
|
72
|
+
declare function useWizardActions<StepId extends string = string>(): IWizardActions$1<StepId>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns combined wizard state, actions, and derived errors.
|
|
75
|
+
*/
|
|
76
|
+
declare function useWizardContext<T = any, StepId extends string = string>(): IWizardContext$1<T, StepId>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Props for rendering the current step component.
|
|
80
|
+
*/
|
|
81
|
+
interface WizardStepRendererProps {
|
|
82
|
+
wrapper?: React.ComponentType<{
|
|
83
|
+
children: React.ReactNode;
|
|
84
|
+
key: string;
|
|
85
|
+
}>;
|
|
86
|
+
fallback?: React.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Renders the active step component with optional wrapper and suspense fallback.
|
|
90
|
+
*/
|
|
91
|
+
declare const WizardStepRenderer: React.FC<WizardStepRendererProps>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Handle returned by components for imperative access to the wizard.
|
|
95
|
+
*/
|
|
96
|
+
interface IWizardHandle<T = unknown, StepId extends string = string> {
|
|
97
|
+
state: IWizardState<T, StepId>;
|
|
98
|
+
actions: IWizardActions<StepId>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* React-specific actions
|
|
102
|
+
*/
|
|
103
|
+
interface IWizardActions<StepId extends string = string> extends IWizardActions$1<StepId> {
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Core Wizard Context State
|
|
107
|
+
*/
|
|
108
|
+
interface IWizardContext<T = unknown, StepId extends string = string> extends IWizardContext$1<T, StepId> {
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Alias for useWizardContext.
|
|
113
|
+
*/
|
|
114
|
+
declare const useWizard: <T = any, StepId extends string = string>() => IWizardContext<T, StepId>;
|
|
115
|
+
|
|
116
|
+
export { type IWizardHandle, WizardProvider, type WizardProviderProps, WizardStepRenderer, type WizardStepRendererProps, createWizardFactory, useWizard, useWizardActions, useWizardContext, useWizardError, useWizardSelector, useWizardState, useWizardValue };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import * as _wizzard_packages_core from '@wizzard-packages/core';
|
|
2
|
+
import { IWizardConfig, IWizardContext as IWizardContext$1, Path, PathValue, IStepConfig, IWizardState, IWizardActions as IWizardActions$1 } from '@wizzard-packages/core';
|
|
3
|
+
export { IStepConfig, IValidatorAdapter, IWizardActions, IWizardConfig, IWizardContext, IWizardState, PersistenceMode, ValidationResult, WizardMiddleware, WizardStore } from '@wizzard-packages/core';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export { loggerMiddleware } from '@wizzard-packages/middleware';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* createWizardFactory
|
|
10
|
+
*
|
|
11
|
+
* Creates a strongly-typed set of Wizard components and hooks for a specific data schema.
|
|
12
|
+
*
|
|
13
|
+
* @template TSchema The shape of your wizard's global data state
|
|
14
|
+
*/
|
|
15
|
+
declare function createWizardFactory<TSchema extends Record<string, any>, StepId extends string = string>(): {
|
|
16
|
+
WizardProvider: ({ config, initialData, children, }: {
|
|
17
|
+
config: IWizardConfig<TSchema, StepId>;
|
|
18
|
+
initialData?: Partial<TSchema>;
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
21
|
+
useWizard: () => IWizardContext$1<TSchema, StepId>;
|
|
22
|
+
useWizardContext: () => any;
|
|
23
|
+
useWizardValue: <P extends Path<TSchema>>(path: P, options?: {
|
|
24
|
+
isEqual?: (a: PathValue<TSchema, P>, b: PathValue<TSchema, P>) => boolean;
|
|
25
|
+
}) => PathValue<TSchema, P>;
|
|
26
|
+
useWizardSelector: <TSelected>(selector: (state: IWizardContext$1<TSchema, StepId>) => TSelected, options?: {
|
|
27
|
+
isEqual?: (a: TSelected, b: TSelected) => boolean;
|
|
28
|
+
}) => TSelected;
|
|
29
|
+
useWizardError: <P extends Path<TSchema>>(path: P) => string | undefined;
|
|
30
|
+
useWizardActions: () => _wizzard_packages_core.IWizardActions<StepId>;
|
|
31
|
+
useWizardState: () => _wizzard_packages_core.IWizardState<TSchema, StepId>;
|
|
32
|
+
useBreadcrumbs: () => _wizzard_packages_core.IBreadcrumb<StepId>[];
|
|
33
|
+
createStep: (config: IStepConfig<TSchema, StepId>) => IStepConfig<TSchema, StepId>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Props for WizardProvider.
|
|
38
|
+
*/
|
|
39
|
+
interface WizardProviderProps<T, StepId extends string> {
|
|
40
|
+
config: IWizardConfig<T, StepId>;
|
|
41
|
+
initialData?: T;
|
|
42
|
+
initialStepId?: StepId;
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Component that provides the wizard context to its children.
|
|
47
|
+
*/
|
|
48
|
+
declare function WizardProvider<T extends Record<string, any>, StepId extends string = string>({ config, initialData, initialStepId, children, }: WizardProviderProps<T, StepId>): react_jsx_runtime.JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Reads the full wizard state.
|
|
51
|
+
*/
|
|
52
|
+
declare function useWizardState<T = unknown, StepId extends string = string>(): IWizardState<T, StepId>;
|
|
53
|
+
/**
|
|
54
|
+
* Subscribes to a specific data value by path.
|
|
55
|
+
*/
|
|
56
|
+
declare function useWizardValue<TValue = any>(path: string, options?: {
|
|
57
|
+
isEqual?: (a: TValue, b: TValue) => boolean;
|
|
58
|
+
}): TValue;
|
|
59
|
+
/**
|
|
60
|
+
* Returns the first error message for a path across all steps.
|
|
61
|
+
*/
|
|
62
|
+
declare function useWizardError(path: string): string | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Selects a derived value from the wizard state with optional equality check.
|
|
65
|
+
*/
|
|
66
|
+
declare function useWizardSelector<TSelected = any>(selector: (state: any) => TSelected, options?: {
|
|
67
|
+
isEqual?: (a: TSelected, b: TSelected) => boolean;
|
|
68
|
+
}): TSelected;
|
|
69
|
+
/**
|
|
70
|
+
* Returns the wizard actions API.
|
|
71
|
+
*/
|
|
72
|
+
declare function useWizardActions<StepId extends string = string>(): IWizardActions$1<StepId>;
|
|
73
|
+
/**
|
|
74
|
+
* Returns combined wizard state, actions, and derived errors.
|
|
75
|
+
*/
|
|
76
|
+
declare function useWizardContext<T = any, StepId extends string = string>(): IWizardContext$1<T, StepId>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Props for rendering the current step component.
|
|
80
|
+
*/
|
|
81
|
+
interface WizardStepRendererProps {
|
|
82
|
+
wrapper?: React.ComponentType<{
|
|
83
|
+
children: React.ReactNode;
|
|
84
|
+
key: string;
|
|
85
|
+
}>;
|
|
86
|
+
fallback?: React.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Renders the active step component with optional wrapper and suspense fallback.
|
|
90
|
+
*/
|
|
91
|
+
declare const WizardStepRenderer: React.FC<WizardStepRendererProps>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Handle returned by components for imperative access to the wizard.
|
|
95
|
+
*/
|
|
96
|
+
interface IWizardHandle<T = unknown, StepId extends string = string> {
|
|
97
|
+
state: IWizardState<T, StepId>;
|
|
98
|
+
actions: IWizardActions<StepId>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* React-specific actions
|
|
102
|
+
*/
|
|
103
|
+
interface IWizardActions<StepId extends string = string> extends IWizardActions$1<StepId> {
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Core Wizard Context State
|
|
107
|
+
*/
|
|
108
|
+
interface IWizardContext<T = unknown, StepId extends string = string> extends IWizardContext$1<T, StepId> {
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Alias for useWizardContext.
|
|
113
|
+
*/
|
|
114
|
+
declare const useWizard: <T = any, StepId extends string = string>() => IWizardContext<T, StepId>;
|
|
115
|
+
|
|
116
|
+
export { type IWizardHandle, WizardProvider, type WizardProviderProps, WizardStepRenderer, type WizardStepRendererProps, createWizardFactory, useWizard, useWizardActions, useWizardContext, useWizardError, useWizardSelector, useWizardState, useWizardValue };
|