/** * Common TypeScript types for antd-components * Shared types used across multiple components */ import { InputProps } from 'antd'; import { NavigateFunction } from 'react-router-dom'; /** * Supported locale languages * @example * lang?: AppLocale; */ export type AppLocale = 'zh-CN' | 'en-US'; /** * Custom event target for input components * @description This is a custom type that wraps onChange values in a standard format. * Antd components don't always return standard React events, so we normalize * all onChange callbacks to use this consistent { target: { value } } structure. * @example * const handleChange = (event: StdEventTarget) => { * console.log(event.target.value); * }; * @template T The type of the value */ export type StdEventTarget = { target: { value: T } }; /** * Standard callback function for value changes * @description Normalized onChange callback that accepts our custom event format. * @example * onChange?: (inEvent: StdEventTarget) => void; * @template T The type of the value */ export type StdCallback = (inEvent: StdEventTarget) => void; /** * Template callback for rendering items * @example * renderItem?: (item: { item: any; index: number }) => React.ReactNode; */ export type TemplateCallback = ( item: { item: T; index: number }, options?: any ) => React.ReactNode; /** * Template callback with items array * @example * renderItem?: (item: { item: any; index: number; items: any[] }, cb: any) => React.ReactNode; */ export type TemplateCallbackWithItems = ( item: { item: T; index: number; items: T[] }, cb: any ) => React.ReactNode; /** * Template callback with options * @example * renderItem?: (item: { item: any; index: number }, options?: any) => React.ReactNode; */ export type TemplateCallbackWithOptions = ( item: { item: T; index: number }, options?: any ) => React.ReactNode; /** * Base form props interface */ export interface BaseFormProps { className?: string; disabled?: boolean; readOnly?: boolean; } /** * Form props with onChange handler */ export interface FormWithOnChangeProps extends BaseFormProps { value?: T; onChange?: StdCallback; } /** * Form props with items array */ export interface FormWithItemsProps extends FormWithOnChangeProps { items?: T[]; } /** * API fetcher parameters */ export interface FetcherParams { current: number; pageSize: number; params?: Record; } /** * API fetcher response */ export type FetcherResponse = Promise<{ data: T[]; total: number; }>; /** * Table action configuration */ export interface TableActionProps { name: string; module?: string; params?: Record; paramsAdd?: Record; paramsEdit?: Record; paramsReset?: Record; pathAdd?: string; pathEdit?: string; } declare global { interface NxStatic { $event: any; $api: Record; $nav: NavigateFunction; err: (msg: string) => any; msg: (msg: string) => any; info: (msg: string) => any; alert: (msg: string, title?: String) => any; confirm: (msg: string, title?: String) => any; prompt: (msg: string, options?: InputProps) => any; } }