* 完善所有用到的type对象,并添加中文注释

* 补充遗失的type
This commit is contained in:
xiaoFjun-eng
2026-05-19 09:05:04 +08:00
committed by GitHub
parent c499bfb4ed
commit ea399f1862
68 changed files with 986 additions and 208 deletions

View File

@@ -2,9 +2,7 @@ import { createContext, type ReactNode, useCallback, useEffect, useMemo, useStat
import { useExitOnCtrlCDWithKeybindings } from '../../hooks/useExitOnCtrlCDWithKeybindings.js';
import type { WizardContextValue, WizardProviderProps } from './types.js';
// Use any here for the context since it will be cast properly when used
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const WizardContext = createContext<WizardContextValue<any> | null>(null);
export const WizardContext = createContext<WizardContextValue<Record<string, unknown>> | null>(null);
export function WizardProvider<T extends Record<string, unknown>>({
steps,
@@ -18,7 +16,7 @@ export function WizardProvider<T extends Record<string, unknown>>({
initialData?: T;
onComplete: (data: T) => void;
onCancel: () => void;
children: ReactNode;
children?: ReactNode;
title: string;
showStepCounter?: boolean;
}): ReactNode {
@@ -123,5 +121,9 @@ export function WizardProvider<T extends Record<string, unknown>>({
return null;
}
return <WizardContext.Provider value={contextValue}>{children || <CurrentStepComponent />}</WizardContext.Provider>;
return (
<WizardContext.Provider value={contextValue as unknown as WizardContextValue<Record<string, unknown>>}>
{children || <CurrentStepComponent />}
</WizardContext.Provider>
);
}

View File

@@ -1,4 +1,27 @@
// Auto-generated stub — replace with real implementation
export type WizardContextValue<T = any> = any
export type WizardProviderProps = any
export type WizardStepComponent = any
import type { Dispatch, ReactNode, SetStateAction } from 'react'
/** 向导中每一步的组件(无 props 或由 Wizard 包裹后注入上下文)。 */
export type WizardStepComponent = (() => ReactNode) | React.ComponentType
/** `WizardProvider` 的声明 props与实现处交叉类型合并。 */
export type WizardProviderProps = {
steps: WizardStepComponent[] // 步骤组件序列
children?: ReactNode // 可选:自定义包裹层;缺省时渲染当前步组件
title: string // 标题栏文案
showStepCounter?: boolean // 是否显示「第 n / 共 m 步」
}
/** 向导上下文:当前步骤索引、累积数据与导航。 */
export type WizardContextValue<T extends Record<string, unknown>> = {
currentStepIndex: number // 当前步骤下标
totalSteps: number // 步骤总数
wizardData: T // 各步写入的聚合数据
setWizardData: Dispatch<SetStateAction<T>> // 整体替换向导数据
updateWizardData: (updates: Partial<T>) => void // 局部合并更新
goNext: () => void // 下一步;末步则标记完成
goBack: () => void // 上一步或退出
goToStep: (index: number) => void // 非线性跳步(写入历史栈)
cancel: () => void // 放弃并清空历史
title: string // 与 Provider 同步的标题
showStepCounter: boolean // 是否展示步数计数
}