import { GridColumns, GridEventListener, GridEvents, DataGridProps } from '@mui/x-data-grid'; import { TextFieldProps } from '@mui/material/TextField'; import { PopperPlacementType } from '@mui/material/Popper'; import { PopperPlacementType as PopperPlacementType$1, SelectProps, FormControlProps, CheckboxProps, FormControlLabelProps, SwitchProps, TextFieldProps as TextFieldProps$1, TextField, PopoverProps } from '@mui/material'; import * as react_hook_form from 'react-hook-form'; import { FieldValues, UseFormReturn, FieldPath, UseControllerProps } from 'react-hook-form'; import React from 'react'; import { TreeViewProps } from '@mui/lab/TreeView'; import { TreeItemProps } from '@mui/lab/TreeItem'; /** * DowndownRanderProps * @date 2023/4/1 - 17:19:03 * * @export * @typedef {DowndownRanderProps} */ type DowndownRanderProps = { /** 关闭函数 */ close: () => void; /** 展开状态 */ open: boolean; }; /** 组件入参 * @extends TextFieldProps TextField入参 * @param DowndownRander 自定义下拉框组件 */ type DropDownInputProps = TextFieldProps & { /** 自定义下拉框组件 */ downRander: ({ close }: DowndownRanderProps) => JSX.Element; /** 下拉框位置 * @default "bottom" */ placement?: PopperPlacementType; /** zIndex * @default 999 */ zIndex?: number; }; /** * 输入框下拉弹框 * @date 2023/4/1 - 17:19:37 * * @param {DropDownInputProps} { downRander, onFocus, placement, style = {}, zIndex = 999, ...props } * @returns {*} */ declare const DropDownInput: ({ downRander, onFocus, placement, style, zIndex, ...props }: DropDownInputProps) => JSX.Element; /** mui DataGrid 数据必须有id */ type IDataItem = { id: any; }; type MuiSearchProps = { /** 列定义 */ columns: GridColumns; /** 获取数据方法 */ getDataList: (value: string) => Promise; /** 点击事件 */ onRowClick?: GridEventListener; /** 下拉框位置 * @default "bottom" */ placement?: PopperPlacementType$1; dataGridWidth?: any; dataGridHeight?: any; /** 输入框value */ inputValue?: string; /** 输入框valueChange */ onInputChange?: (value: string) => void; } & Omit; /** * 输入下拉 不支持回显 * @date 2023/4/1 - 17:21:53 * * @template T * @param {MuiSearchProps} { columns, onRowClick, getDataList, inputValue, onInputChange, placement, dataGridWidth = 500, dataGridHeight = 250, ...props } * @returns {*} */ declare const MuiSearch: ({ columns, onRowClick, getDataList, inputValue, onInputChange, placement, dataGridWidth, dataGridHeight, ...props }: MuiSearchProps) => JSX.Element; /** MuiFormSearch 入参 */ interface MuiFormSearchProps extends MuiSearchProps { /** 下拉选框单项 非id */ value: T; /** key键 * @default "id" */ keyExpr?: string; /** 展示键 * @default "name" */ displayExpr?: string; /** 更新value值 */ onValueChange: (value: T) => void; } /** * 用于表单中的搜索组件 * @date 2023/4/1 - 17:20:58 * @formBase * @param {MuiFormSearchProps} { value, keyExpr = 'id', displayExpr = 'name', // inputValue, // onInputChange, onValueChange, getDataList, onRowClick, ...props } * @returns {*} */ declare const MuiFormSearch: ({ value, keyExpr, displayExpr, onValueChange, getDataList, onRowClick, ...props }: MuiFormSearchProps) => JSX.Element; /** 工具 取函数第0个参数 */ type FunctionsProp0 any> = Parameters[0]; /** 工具 把类型的属性指定为为某个类型 * @description 把 T 的所有属性置为 V */ type TypeConversion = { [P in keyof T]?: V; }; /** value必须和onChange保持一致 */ type IChange = ((value: T) => void); /** Form表单组件入参基本参数 * @param TValue 组件绑定的数据类型 */ type IFormComponentPropsBase = { /** 错误状态 */ error?: boolean; /** 组件下提示文本 */ helperText?: string | JSX.Element; /** 组件内提示 */ label?: string | JSX.Element; /** 表单值 */ value?: TValue; /** 更新值 */ onChange?: IChange; /** 用于Select同时绑定多个Form属性 * @description 如果需要使用otherNames属性绑定多个属性, 请实现该方法 */ onItemChange?: IChange; }; /** Form表单组件 */ type IFormComponentBase = (props: IFormComponentPropsBase) => JSX.Element; /** Form表单组件入参 * @description 剔除原始组件的同名参数 */ type IFormComponentProps = IFormComponentPropsBase & Partial>; /** Form表单内容Store */ type IFormReturnProps = UseFormReturn; /** Form 单项可注入参数 */ type IFormItemProps = FieldPath> = UseControllerProps; /** 返回组件入参 */ type ReturnComponentProps = FieldPath, TValue = TForm[TName], TItem = null, /** 组件原始入参 */ TFormComponentProps extends IFormComponentPropsBase = IFormComponentPropsBase> = IFormItemProps & Omit & { defaultErrorMessage?: string | JSX.Element; /** 同时绑定多个Form属性 * @description 如果需要使用otherNames属性绑定多个属性, 请在原始组件中实现onItemChange方法 */ otherNames?: TypeConversion; }; /** 返回组件 */ type ReturnComponent = FieldPath, TIFormComponentBase extends IFormComponentBase = IFormComponentBase> = (props: Omit[0], keyof IFormItemProps> & IFormItemProps & { defaultErrorMessage?: string | JSX.Element; /** 同时绑定多个Form属性 * @description 如果需要使用otherNames属性绑定多个属性, 请在原始组件中实现onItemChange方法 */ otherNames?: TypeConversion[0]["onItemChange"] extends IChange ? Parameters[0]["onItemChange"]>[0] : { [props: string]: any; }, TName>; }) => JSX.Element; /** * Description placeholder * @date 2023/4/1 - 16:54:02 * * @export * @typedef {IBaseFormSearchProps} * @template TV * @template TI */ type IBaseFormSearchProps = IFormComponentProps, TV, TI>; /** * Description placeholder * @date 2023/4/1 - 16:54:24 * @formBase * @template TV * @template TI * @param {IBaseFormSearchProps} { onItemChange, onRowClick, columns = [], getDataList = async () => [], ...props } * @returns {*} */ declare const BaseFormSearch: ({ onItemChange, onRowClick, columns, getDataList, ...props }: IBaseFormSearchProps) => JSX.Element; /** * 选择器入口参数 * @date 2023/4/1 - 16:58:33 * * @export * @typedef {BaseSelectProps} * @template TItem typeof select item * @template TValue typeof select value * @template K * @template K2 */ type BaseSelectProps = IFormComponentProps & FormControlProps & { data?: TItem[]; keyExpr?: K; displayExpr?: K2; onItemClick?: (e: any, item: TItem) => void; }, TValue, TItem>; /** * 选择器基础封装 * @date 2023/4/1 - 16:57:58 * @formBase * @template T typeof item * @template V typeof value * @param {BaseSelectProps} { data = [], label, fullWidth, size, keyExpr = 'id', error, displayExpr = 'name', helperText, style, onChange, onItemChange, onItemClick, ...props } * @returns {*} */ declare const BaseSelect: ({ data, label, fullWidth, size, keyExpr, error, displayExpr, helperText, style, onChange, onItemChange, onItemClick, ...props }: BaseSelectProps) => JSX.Element; /** * BaseFormCheckbox Component Props; extends CheckboxProps and IFormComponentProps * @date 2023/4/1 - 16:49:21 * * @export * @typedef {BaseFormCheckboxProps} */ type BaseFormCheckboxProps = IFormComponentProps; /** * BaseFormCheckbox extends MUI.FormControlLabel * @date 2023/4/1 - 16:48:06 * @formBase * @param {BaseFormCheckboxProps} { value, label, labelProps, onChange, ...prop } * @returns {*} */ declare const BaseFormCheckbox: ({ value, label, labelProps, onChange, ...prop }: BaseFormCheckboxProps) => JSX.Element; /** * BaseFormSwitch Props * @date 2023/4/1 - 17:02:59 * * @export * @typedef {BaseFormSwitchProps} */ type BaseFormSwitchProps = IFormComponentProps; /** * 开关 implementat by MUI.FormControlLabel and MUI.Switch * @date 2023/4/1 - 17:01:09 * @formBase * @param {BaseFormSwitchProps} { value, labelProps, onChange, ...prop } * @returns {*} */ declare const BaseFormSwitch: ({ value, labelProps, onChange, ...prop }: BaseFormSwitchProps) => JSX.Element; /** 地区数据单项内容 */ type RegionItem = any; /** 地区选择数据类型 */ type RegionValue = Partial<{ province: RegionItem; city: RegionItem; area: RegionItem; street: RegionItem; postalCode: RegionItem; }>; /** * Region Props * @date 2023/4/1 - 17:05:44 * * @export * @typedef {RegionProps} */ type RegionProps = IFormComponentProps<{ /** 控制省输入框样式 */ provinceTextProps?: BaseSelectProps; /** 控制市输入框样式 */ cityTextProps?: BaseSelectProps; /** 控制区输入框样式 */ areaTextProps?: BaseSelectProps; /** 控制街道输入框样式 */ streetTextProps?: TextFieldProps$1; /** 控制邮编输入框样式 */ postalCodeTextProps?: TextFieldProps$1; /** 获取地区数据方法 获取省级不传parent */ getRegionData?: (parent?: RegionItem) => Promise; /** code属性 * @default RegionCode */ keyExpr?: string; /** 展示键 * @default RegionName */ displayExpr?: string; /** 是否启用街道输入框 * @default true */ enableStreet?: boolean; /** 是否启用邮编输入框 * @default true */ enablePostalCode?: boolean; /** 启用非受控组件 * @description 当为true时候,不使用外部传入状态(value,onChange) * @default false */ isUseInputValue?: boolean; /** 数据类型 * @default key 默认取Item的keyExpr */ dataType?: 'key' | 'item'; }, RegionValue, RegionValue>; /** * 地区选择 Area selection * @date 2023/4/1 - 17:04:00 * @formBase * * @param {RegionProps} { // value, // onChange, isUseInputValue = false, enableStreet = true, enablePostalCode = true, error, helperText, getRegionData, keyExpr = 'RegionCode', displayExpr = 'RegionName', dataType = 'key', ...props } * @returns {*} */ declare const Region: ({ isUseInputValue, enableStreet, enablePostalCode, error, helperText, getRegionData, keyExpr, displayExpr, dataType, ...props }: RegionProps) => JSX.Element; /** * @description 获取指定filed的错误信息 * @param name 表单绑定属性 * @param formStateErrors formState.errors 错误状态 * @param defaultErrorMessage 默认错误提示 * @return {} {error:是否错误,helperText:错误提示} */ declare const getErrorState: (name: string, formStateErrors: any, defaultErrorMessage?: string | JSX.Element) => { error: boolean; helperText: any; }; /** withControllerFields 附加参数 */ type IWithControllerFieldsOptions = { formProps: IFormReturnProps; }; /** 为组件注入FormStore * @description 返回组件的入参 ControllerProps&原始组价入参 * @description 用户传入参数优先于注入参数 * @param TForm Form表单类型 * @param TIFormComponent 外部组件类型 * @param TContext 框架依赖 未使用 * @param component 原始组件 * @param options.formProps 附加参数 react-hook-form.useForm的返回值 * @return 已注入状态的组件 */ declare function withControllerFields = IFormComponentBase, TContext = any>(Component: TIFormComponent, { formProps }: IWithControllerFieldsOptions): ReturnComponent, TIFormComponent>; /** * @description Implement by react-hook-form and Mui , for quick definition form. * @description 基于 react-hook-form 和 Mui 实现,可用于快速定义表单 * @description It inherits and extends react-hook-form. * @description 它继承并拓展了react-hook-form * @date 2023/4/1 - 17:06:57 * * @template TForm * @template TContext * @param {?UseFormProps} [props] * @returns {*} */ declare const useFormComponent: (props?: Partial<{ mode: keyof react_hook_form.ValidationMode; reValidateMode: "onChange" | "onBlur" | "onSubmit"; defaultValues: react_hook_form.DeepPartial | ((payload?: unknown) => Promise); values: TForm; resetOptions: Partial<{ keepDirtyValues: boolean; keepErrors: boolean; keepDirty: boolean; keepValues: boolean; keepDefaultValues: boolean; keepIsSubmitted: boolean; keepTouched: boolean; keepIsValid: boolean; keepSubmitCount: boolean; }>; resolver: react_hook_form.Resolver; context: TContext; shouldFocusError: boolean; shouldUnregister: boolean; shouldUseNativeValidation: boolean; criteriaMode: react_hook_form.CriteriaMode; delayError: number; }>) => { formProps: react_hook_form.UseFormReturn; FormText: ReturnComponent, typeof TextField>; FormSelect: ReturnComponent, ({ data, label, fullWidth, size, keyExpr, error, displayExpr, helperText, style, onChange, onItemChange, onItemClick, ...props }: BaseSelectProps) => JSX.Element>; FormSearch: ReturnComponent, ({ onItemChange, onRowClick, columns, getDataList, ...props }: IBaseFormSearchProps) => JSX.Element>; FormCheckbox: ReturnComponent, ({ value, label, labelProps, onChange, ...prop }: BaseFormCheckboxProps) => JSX.Element>; FormSwitch: ReturnComponent, ({ value, labelProps, onChange, ...prop }: BaseFormSwitchProps) => JSX.Element>; FormRegion: ReturnComponent, ({ isUseInputValue, enableStreet, enablePostalCode, error, helperText, getRegionData, keyExpr, displayExpr, dataType, ...props }: RegionProps) => JSX.Element>; watch: react_hook_form.UseFormWatch; getValues: react_hook_form.UseFormGetValues; getFieldState: react_hook_form.UseFormGetFieldState; setError: react_hook_form.UseFormSetError; clearErrors: react_hook_form.UseFormClearErrors; setValue: react_hook_form.UseFormSetValue; trigger: react_hook_form.UseFormTrigger; formState: react_hook_form.FormState; resetField: react_hook_form.UseFormResetField; reset: react_hook_form.UseFormReset; handleSubmit: react_hook_form.UseFormHandleSubmit; unregister: react_hook_form.UseFormUnregister; control: react_hook_form.Control; register: react_hook_form.UseFormRegister; setFocus: react_hook_form.UseFormSetFocus; }; /** * 优化样式后的DataGrid * @date 2023/4/1 - 17:20:14 * * @param {DataGridProps} props * @returns {*} */ declare const MuiDataGrid: (props: DataGridProps) => JSX.Element; type AsyncTreeProps = TreeViewProps & Partial<{ /** 异步获取子节点方法 */ createChildren: (parent?: T) => Promise; /** key键 * @default "id" */ keyExpr: string; /** 展示键 * @default "name" */ displayExpr: string; /** 根节点Key */ rootValue: any; /** 父节点 */ parentExpr: string; /** 子节点参数 */ treeItemProps: TreeItemProps; /** 是否有子节点属性 * @default "hasChildren" */ hasChildrenExpr: string; /** * 改变Expanded */ setExpanded: any; }>; type TreeData = Array>; }>; type TreeProps = TreeViewProps & Partial<{ /** 异步获取子节点方法 */ listData: TreeData; /** key键 * @default "id" */ keyExpr: string; /** 展示键 * @default "name" */ displayExpr: string; /** 根节点Key */ rootValue: any; /** 子节点键 用于tree型数据 */ childrenExpr: string; /** 子节点参数 */ treeItemProps: Partial; /** 父节点 用于plat型数据 */ parentExpr: string; /** 数据结构 */ dataStructure: 'tree' | 'plat'; }>; /** * 将Tree参数注入 */ declare const TreeProps: React.Context & AsyncTreeProps>; /** * @description 异步树 * @description 通过createChildren分次从后端获取节点数据 */ /** * @description 异步树 * @description 通过createChildren分次从后端获取节点数据 * @date 2023/4/1 - 17:23:26 * @param {AsyncTreeProps} props * @returns {*} */ declare const AsyncTree: (props: AsyncTreeProps) => JSX.Element; /** * Tree * @date 2023/4/1 - 17:24:17 * * @param {TreeProps} { listData: outListData = [], ...statusProps } * @returns {*} */ declare const Tree: ({ listData: outListData, ...statusProps }: TreeProps) => JSX.Element; interface MuiTreeProps { treeItemProps?: Partial; treeViewProps?: TreeViewProps; data: any[]; childrenExpr?: string; keyExpr?: string; iconExpr?: string; displayExpr?: string; TreeItem?: (props: Omit & { itemData: any; } & Partial) => JSX.Element; customLabelText?: (props: Omit & { itemData: any; }) => JSX.Element; } declare function MuiTree({ treeViewProps: { defaultCollapseIcon, defaultExpandIcon, defaultEndIcon, sx, ...treeViewProps }, ...MuiTreeProps }: MuiTreeProps): JSX.Element; interface E { currentTarget: HTMLElement; } interface TargetProps { open: boolean; handleOpen: (e: E) => void; handleClose: () => void; } interface DropDownProps { target: (props: TargetProps) => JSX.Element; downContent: (props: TargetProps) => JSX.Element; downPageProps?: Partial; } /** * DropDown 当DropDown触发指定事件时, 展开或关闭Popover * @date 2023/4/1 - 17:25:51 * * @export * @param {DropDownProps} { target: Target, downContent: DownContent, downPageProps: { anchorOrigin = defaultanchorOrigin, transformOrigin = defaulttransformOrigin, PaperProps = defaultPaperProps, ...downPageProps } = {} } * @returns {*} */ declare function DropDown({ target: Target, downContent: DownContent, downPageProps: { anchorOrigin, transformOrigin, PaperProps, ...downPageProps } }: DropDownProps): JSX.Element; export { AsyncTree, AsyncTreeProps, BaseFormCheckbox, BaseFormCheckboxProps, BaseFormSearch, BaseFormSwitch, BaseFormSwitchProps, BaseSelect, BaseSelectProps, DowndownRanderProps, DropDown, DropDownInput, DropDownInputProps, DropDownProps, FunctionsProp0, IBaseFormSearchProps, IChange, IDataItem, IFormComponentBase, IFormComponentProps, IFormComponentPropsBase, IFormItemProps, IFormReturnProps, IWithControllerFieldsOptions, MuiDataGrid, MuiFormSearch, MuiFormSearchProps, MuiSearch, MuiSearchProps, MuiTree, MuiTreeProps, Region, RegionItem, RegionProps, RegionValue, ReturnComponent, ReturnComponentProps, Tree, TreeProps, TypeConversion, getErrorState, useFormComponent, withControllerFields };