shineout
Version:
A components library for React
28 lines (27 loc) • 1.3 kB
TypeScript
import React from 'react';
import type { FormFieldProps } from '@sheinx/base';
export interface ExtendsFieldProps<T, Name = string> extends Omit<FormFieldProps<T>, 'value' | 'defaultValue' | 'children' | 'onChange' | 'name' | 'getProps' | 'getValidateProps'> {
/**
* @en The key access data in the Form
* @cn Form 内存取数据的 key
*/
name?: Name;
defaultValue?: T;
/**
* @en The callback before the value is changed, when the return value is not empty, it will be used as the new value of the component
* @cn 值改变前的回调,当返回值不为空时将作为组件的新值
*/
beforeChange?: (value: T) => T | undefined | void;
/**
* @private for rule
*/
title?: string;
}
export interface FiledItemCommonProps {
defaultValue?: any;
onChange?: (...args: any) => void;
beforeChange?: (value: any) => any;
}
export type GetWithFieldProps<Props, Value, Name = string> = Omit<Props, 'beforeChange'> & ExtendsFieldProps<Value, Name>;
declare const useFieldCommon: <Props extends FiledItemCommonProps, Value, Name extends string | string[] = string>(props: GetWithFieldProps<Props, Value, Name>, Origin: React.ComponentType<Props>, type?: 'number' | 'string' | 'array') => JSX.Element;
export default useFieldCommon;