material-form-builder
Version:
A dynamic React form builder using Material UI
861 lines (787 loc) • 30.2 kB
TypeScript
import * as React$1 from 'react';
import React__default, { Component, RefObject, HTMLProps, CSSProperties, ReactNode } from 'react';
import * as react_jsx_runtime from 'react/jsx-runtime';
import { AutocompleteProps, TextFieldProps, AutocompleteChangeReason, AutocompleteChangeDetails, CheckboxProps, InputProps as InputProps$1, FormControlProps, InputLabelProps, FormHelperTextProps, BoxProps, TypographyProps, SelectProps, SelectChangeEvent, SwitchProps, ToggleButtonGroupProps } from '@mui/material';
import { MuiPickersAdapter, PickerChangeHandlerContext, DateValidationError, DateTimePickerProps, DateTimeValidationError, TimePickerProps, TimeValidationError } from '@mui/x-date-pickers';
import { Dayjs } from 'dayjs';
import { DatePickerProps } from '@mui/x-date-pickers/DatePicker';
type AutocompleteOptionType = {
label: string
value: string
}
type AutocompleteFragType = string | number
type AutocompleteValueType = AutocompleteOptionType[] | AutocompleteOptionType | undefined
type AutocompleteInputValueType = AutocompleteFragType | AutocompleteFragType[] | null
interface AutocompleteInputProps
extends BaseInput<AutocompleteInputValueType>,
Omit<AutocompleteProps<any, boolean, true, boolean, 'div'>, 'renderInput' | 'defaultValue' | 'ref'> {
type: 'autocomplete'
disableClearOnChangeOptions?: boolean
variant?: Variant
label?: string
renderInput?: (params: TextFieldProps) => React.ReactNode
InputProps?: TextFieldProps
defaultValue?: AutocompleteInputValueType
loading?: boolean
}
interface IState$i {
value: AutocompleteValueType | null;
error: boolean;
}
declare class AutocompleteInput extends Component<AutocompleteInputProps, IState$i> implements Omit<InputImplement<AutocompleteInputValueType>, 'onChange'> {
state: IState$i;
validationTimeout: any;
inputRef: HTMLInputElement | undefined;
shouldComponentUpdate(nextProps: AutocompleteInputProps, nextState: IState$i): boolean;
private getValuesFrom;
private loadingComponent;
componentDidUpdate(props: AutocompleteInputProps): void;
setValue(value: AutocompleteInputValueType, disableOnChangeEvent?: boolean): Promise<AutocompleteInputValueType>;
getValue(): AutocompleteInputValueType;
clear(withoutDefaults?: boolean): Promise<AutocompleteInputValueType>;
validation(): boolean;
onChange: (_: React__default.SyntheticEvent, option: any, reason: AutocompleteChangeReason, details?: AutocompleteChangeDetails<any> | undefined) => void;
private onClick;
click: () => void;
focus: () => void;
blur: () => void;
private optionGetter;
private getValueForCheck;
private onInputBlur;
private renderOption;
private getOptionLabel;
private isOptionEqualToValue;
renderInput: (params: TextFieldProps) => React__default.ReactNode;
render(): react_jsx_runtime.JSX.Element;
}
type CheckboxInputValueType = boolean
interface CheckboxInputProps extends BaseInput<CheckboxInputValueType>, Omit<CheckboxProps, 'defaultChecked' | 'ref'> {
type: 'checkbox'
label?: string
defaultChecked?: CheckboxInputValueType
}
interface IState$h {
value: CheckboxInputValueType;
error: boolean;
}
declare class CheckboxInput extends Component<CheckboxInputProps, IState$h> implements InputImplement<CheckboxInputValueType> {
state: IState$h;
validationTimeout: any;
inputRef: HTMLInputElement | null | undefined;
shouldComponentUpdate(nextProps: CheckboxInputProps, nextState: IState$h): boolean;
setValue(value: CheckboxInputValueType, disableOnChangeEvent?: boolean): Promise<CheckboxInputValueType>;
getValue(): CheckboxInputValueType;
clear(): Promise<CheckboxInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
private onClick;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type CustomInputValueType = any
interface CustomInputProps extends Omit<BaseInput, 'onChangeValue' | 'ref'> {
type: 'custom'
element: React.ElementType
allowObject?: boolean,
[key: string]: any
}
interface IState$g {
value: CustomInputValueType;
error: boolean;
}
declare class CustomInput extends Component<CustomInputProps, IState$g> implements InputImplement<CustomInputValueType> {
private elementRef;
state: IState$g;
setValue(value: CustomInputValueType): Promise<CustomInputValueType>;
getValue(): CustomInputValueType;
clear(): Promise<CustomInputValueType>;
validation(): boolean;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type DateInputValueType = Dayjs | null
interface DateInputProps extends BaseInput<DateInputValueType>, Omit<DatePickerProps<Dayjs, false>, 'value' | 'renderInput' | 'ref'> {
type: 'date'
/**
* @deprecated
* use LocalizationProvider wrapper instead
* @docs https://mui.com/x/react-date-pickers/getting-started/#localizationprovider
*/
dateAdapter?: new (...args: any) => MuiPickersAdapter<Dayjs>
variant?: Variant
defaultValue?: DateInputValueType
fullWidth?: boolean
InputProps?: TextFieldProps
// onChange?: (value: any, keyboardInputValue?: string) => void
}
interface IState$f {
value: DateInputValueType;
error: boolean;
}
declare class DateInput extends Component<DateInputProps, IState$f> implements InputImplement<DateInputValueType> {
state: IState$f;
validationTimeout: any;
inputRef: HTMLInputElement | null | undefined;
shouldComponentUpdate(nextProps: DateInputProps, nextState: IState$f): boolean;
setValue(value: DateInputValueType, disableOnChangeEvent?: boolean): Promise<DateInputValueType>;
getValue(): DateInputValueType;
clear(): Promise<DateInputValueType>;
validation(): boolean;
onChange: (value: Dayjs | null, context: PickerChangeHandlerContext<DateValidationError>) => void;
private onClick;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type DatetimeInputValueType = Dayjs | null
interface DatetimeInputProps extends BaseInput<DatetimeInputValueType>, Omit<DateTimePickerProps<Dayjs, false>, 'value' | 'renderInput' | 'ref'> {
type: 'datetime'
/**
* @deprecated
* use LocalizationProvider wrapper instead
* @docs https://mui.com/x/react-date-pickers/getting-started/#localizationprovider
*/
dateAdapter?: new (...args: any) => MuiPickersAdapter<Dayjs>
variant?: Variant
defaultValue?: DatetimeInputValueType
fullWidth?: boolean
InputProps?: TextFieldProps
}
interface IState$e {
value: DatetimeInputValueType;
error: boolean;
}
declare class DatetimeInput extends Component<DatetimeInputProps, IState$e> implements InputImplement<DatetimeInputValueType> {
state: IState$e;
validationTimeout: any;
inputRef: HTMLInputElement | null | undefined;
shouldComponentUpdate(nextProps: DatetimeInputProps, nextState: IState$e): boolean;
setValue(value: DatetimeInputValueType, disableOnChangeEvent?: boolean): Promise<DatetimeInputValueType>;
getValue(): DatetimeInputValueType;
clear(): Promise<DatetimeInputValueType>;
validation(): boolean;
onChange: (value: Dayjs | null, context: PickerChangeHandlerContext<DateTimeValidationError>) => void;
private onClick;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type FileInputValueType = FileList | null
interface FileInputProps extends BaseInput<FileInputValueType>, Omit<InputProps$1, 'ref'> {
type: 'file'
label?: string
defaultValue?: FileInputValueType
variant?: Variant
helperText?: string
FormControlProps?: FormControlProps
InputLabelProps?: InputLabelProps
FormHelperTextProps?: FormHelperTextProps
multiple?: boolean
}
interface IState$d {
value: FileInputValueType;
error: boolean;
inputKey: string;
}
declare class FileInput extends Component<FileInputProps, IState$d> implements InputImplement<FileInputValueType> {
state: IState$d;
validationTimeout: any;
inputIdentity: string;
textHelperIdentity: string;
inputRef: HTMLInputElement | undefined;
constructor(props: FileInputProps);
shouldComponentUpdate(nextProps: FileInputProps, nextState: IState$d): boolean;
setValue(value: FileInputValueType, disableOnChangeEvent?: boolean): Promise<any>;
getValue(): FileInputValueType;
clear(): Promise<FileInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
private onClick;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type GroupInputValueType = ObjectLiteral | undefined | null
interface GroupInputProps extends Omit<BaseInput<GroupInputValueType>, 'onChangeValue'> {
type: 'group'
inputs: InputProps[]
itemWrapper?: (children: JSX.Element) => JSX.Element,
onChangeValue?: (data: OutputValues) => void
}
interface IState$c {
error: boolean;
value: GroupInputValueType;
}
declare class GroupInput extends Component<GroupInputProps, IState$c> implements InputImplement<GroupInputValueType> {
state: IState$c;
validationTimeout: any;
builderRef: RefObject<FormBuilder>;
constructor(props: GroupInputProps);
setValue(values: GroupInputValueType): Promise<GroupInputValueType>;
getValue(validation?: boolean): GroupInputValueType;
clear(): Promise<GroupInputValueType>;
validation(): boolean;
onChangeValue: (data: OutputValues) => void;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type ItemsInputValueType = any;
interface ItemsInputBaseProps extends Omit<BaseInput<ItemsInputValueType>, "onChangeValue"> {
type: "items";
inputs: InputProps[];
renderHeader?: (addItem: Function, removeAll: Function) => JSX.Element;
removeIcon?: JSX.Element | React.ReactNode | boolean;
copyIcon?: JSX.Element | React.ReactNode | boolean;
minItems?: number;
maxItems?: number;
}
interface ItemsInputPropsCustomWrapper extends ItemsInputBaseProps {
disableDefaultItemWrapper: true;
itemWrapper: (children: JSX.Element, key: string, actions: { copyItem: () => void; removeItem: () => void }) => JSX.Element;
}
interface ItemsInputPropsDefaultWrapper extends ItemsInputBaseProps {
disableDefaultItemWrapper?: false;
itemWrapper?: (children: JSX.Element, key: string, actions: { copyItem: () => void; removeItem: () => void }) => JSX.Element;
}
type ItemsInputProps = ItemsInputPropsCustomWrapper | ItemsInputPropsDefaultWrapper;
interface IState$b {
error: boolean;
items: string[];
}
declare class ItemsInput extends Component<ItemsInputProps, IState$b> implements InputImplement<ItemsInputValueType> {
state: IState$b;
validationTimeout: any;
formBuilderRef: {
[key: string]: FormBuilder<any> | null;
};
shouldComponentUpdate(nextProps: any, nextState: IState$b): boolean;
UNSAFE_componentWillMount(): void;
private sleep;
setValue(values: ItemsInputValueType): Promise<ItemsInputValueType>;
private setItemValue;
exportFormBuilderData: () => OutputValues[];
getValue(): any;
clear(): Promise<ItemsInputValueType>;
validation(): boolean;
getRandomKey: () => string;
addItem: () => Promise<string>;
copyItem: (key: string) => () => Promise<void>;
removeItem: (key: string) => () => Promise<void>;
removeAll: () => Promise<any>;
click: () => void;
focus: () => void;
blur: () => void;
renderItem: (key: string) => react_jsx_runtime.JSX.Element;
render(): react_jsx_runtime.JSX.Element;
}
type MaskInputValueType = string | null
interface MaskInputProps extends BaseInput<MaskInputValueType>, Omit<TextFieldProps, 'defaultValue' | 'ref'> {
type: 'mask'
pattern: string
/**
* @default _
*/
char?: string
defaultValue?: MaskInputValueType
}
interface IState$a {
value: MaskInputValueType;
value_when_focus: MaskInputValueType;
error: boolean;
}
declare class MaskInput extends Component<MaskInputProps, IState$a> implements InputImplement<MaskInputValueType> {
state: IState$a;
validationTimeout: any;
inputRef: HTMLInputElement | undefined;
shouldComponentUpdate(nextProps: MaskInputProps, nextState: IState$a): boolean;
setValue(value: MaskInputValueType, disableOnChangeEvent?: boolean): Promise<MaskInputValueType>;
getValue(): MaskInputValueType;
clear(): Promise<MaskInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
private normalizeValue;
private onClick;
private onBlur;
private onFocus;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type Country = {
title: string;
dialCode: string;
mask: string;
flag: string;
};
type MobileInputValueType = string | null
interface MobileInputProps extends BaseInput<MobileInputValueType>, Omit<TextFieldProps, 'defaultValue' | 'ref'> {
type: 'mobile'
defaultValue?: MobileInputValueType
}
interface IState$9 {
value: MobileInputValueType;
value_when_focus: MobileInputValueType;
error: boolean;
country: Country;
}
declare class MobileInput extends Component<MobileInputProps, IState$9> implements InputImplement<MobileInputValueType> {
state: IState$9;
validationTimeout: any;
inputRef: HTMLInputElement | undefined;
shouldComponentUpdate(nextProps: MobileInputProps, nextState: IState$9): boolean;
setValue(value: MobileInputValueType, internalSet?: boolean, disableOnChangeEvent?: boolean): Promise<MobileInputValueType>;
getValue(): MobileInputValueType;
clear(): Promise<MobileInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
private onClick;
private onBlur;
private onFocus;
private normalizeValue;
private onChangeCountry;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type NumberInputValueType = number | null
interface NumberInputProps extends BaseInput<NumberInputValueType>, Omit<TextFieldProps, 'defaultValue' | 'ref'> {
type: 'number'
defaultValue?: NumberInputValueType
}
interface IState$8 {
value: NumberInputValueType;
value_when_focus: NumberInputValueType;
error: boolean;
}
declare class NumberInput extends Component<NumberInputProps, IState$8> implements InputImplement<NumberInputValueType> {
state: IState$8;
validationTimeout: any;
inputRef: HTMLInputElement | null | undefined;
shouldComponentUpdate(nextProps: NumberInputProps, nextState: IState$8): boolean;
setValue(value: NumberInputValueType, disableOnChangeEvent?: boolean): Promise<NumberInputValueType>;
getValue(): NumberInputValueType;
clear(): Promise<NumberInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
private onClick;
private onBlur;
private onFocus;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type OtpInputValueType = string | null
interface OtpInputProps extends BaseInput<OtpInputValueType>, Omit<HTMLProps<HTMLInputElement>, 'defaultValue' | 'ref'> {
type: 'otp'
defaultValue?: OtpInputValueType
/** * @default standard */
variant?: 'outlined' | 'standard'
/** * @default 4 */
digits?: number
autoFocus?: boolean
/** @default 55 */
height?: number
/** @default 34.61 */
width?: number
/** @default 1 */
borderWidth?: number
/** @default 8 */
spaceBetween?: number
/** @default 4 */
borderRadius?: number
/** @default #0000003b */
emptyColor?: CSSProperties['color']
/** @default #1976d2 */
focusColor?: CSSProperties['color']
/** @default #68b36b */
completeColor?: CSSProperties['color']
/**
* @default 400
* use digitTextProps.sx instead
*/
fontWeight?: number
/**
* @default 23
* use digitTextProps.sx instead
*/
fontSize?: number
/** @default #323232 */
color?: CSSProperties['color'],
/**
* props per digit box
* @default undefined
*/
digitBoxProps?: BoxProps,
/**
*
*/
digitTextProps?: TypographyProps
}
interface IState$7 {
value: OtpInputValueType;
value_when_focus: OtpInputValueType;
error: boolean;
isInputFocused: boolean;
}
declare class OtpInput extends Component<OtpInputProps, IState$7> implements InputImplement<OtpInputValueType> {
state: IState$7;
validationTimeout: any;
inputRef: HTMLInputElement | undefined | null;
shouldComponentUpdate(nextProps: OtpInputProps, nextState: IState$7): boolean;
setValue(value: OtpInputValueType, disableOnChangeEvent?: boolean): Promise<OtpInputValueType>;
getValue(): OtpInputValueType;
clear(): Promise<OtpInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
private onClick;
private onBlur;
private onFocus;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type PasswordInputValueType = string | null
interface PasswordInputProps extends BaseInput<PasswordInputValueType>, Omit<TextFieldProps, 'defaultValue' | 'ref'> {
type: 'password'
defaultValue?: PasswordInputValueType
}
interface IState$6 {
value: PasswordInputValueType;
value_when_focus: PasswordInputValueType;
error: boolean;
showPassword: boolean;
}
declare class PasswordInput extends Component<PasswordInputProps, IState$6> implements InputImplement<PasswordInputValueType> {
state: IState$6;
validationTimeout: any;
inputRef: HTMLInputElement | null | undefined;
shouldComponentUpdate(nextProps: PasswordInputProps, nextState: IState$6): boolean;
setValue(value: PasswordInputValueType, disableOnChangeEvent?: boolean): Promise<PasswordInputValueType>;
getValue(): PasswordInputValueType;
clear(): Promise<PasswordInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
private onClick;
private onBlur;
private onFocus;
private handleClickShowPassword;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type SelectInputValueType = any
type SelectOptionType = {
label: string | JSX.Element
value: any
}
interface SelectInputProps extends BaseInput<SelectInputValueType>, Omit<SelectProps, 'defaultValue' | 'ref'> {
type: 'select'
options: SelectOptionType[]
defaultValue?: SelectInputValueType
listSubheaderText?: string
loading?: boolean
}
interface IState$5 {
value: SelectInputValueType;
error: boolean;
}
declare class SelectInput extends Component<SelectInputProps, IState$5> implements InputImplement<SelectInputValueType> {
state: IState$5;
validationTimeout: any;
inputRef: HTMLInputElement | null | undefined;
shouldComponentUpdate(nextProps: SelectInputProps, nextState: IState$5): boolean;
componentDidUpdate(props: SelectInputProps): void;
setValue(value: SelectInputValueType, disableOnChangeEvent?: boolean): Promise<SelectInputValueType>;
getValue(): SelectInputValueType;
clear(): Promise<SelectInputValueType>;
validation(): boolean;
onChange: (event: SelectChangeEvent<any>, child: React__default.ReactNode) => void;
private onOpen;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type SwitchInputValueType = boolean
interface SwitchInputProps extends BaseInput<SwitchInputValueType>, Omit<SwitchProps, 'defaultChecked' | 'ref'> {
type: 'switch'
label?: string
defaultChecked?: SwitchInputValueType
}
interface IState$4 {
value: SwitchInputValueType;
error: boolean;
}
declare class SwitchInput extends Component<SwitchInputProps, IState$4> implements InputImplement<SwitchInputValueType> {
state: IState$4;
validationTimeout: any;
inputRef: HTMLInputElement | null | undefined;
shouldComponentUpdate(nextProps: SwitchInputProps, nextState: IState$4): boolean;
setValue(value: SwitchInputValueType, disableOnChangeEvent?: boolean): Promise<SwitchInputValueType>;
getValue(): SwitchInputValueType;
clear(): Promise<SwitchInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
private onClick;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type TextInputValueType = string | null;
interface TextInputProps extends BaseInput<TextInputValueType>, Omit<TextFieldProps, "defaultValue" | "ref"> {
type: "text";
autoDirection?: boolean;
defaultValue?: TextInputValueType;
}
interface IState$3 {
value: TextInputValueType;
value_when_focus: TextInputValueType;
error: boolean;
}
declare class TextInput extends Component<TextInputProps, IState$3> implements InputImplement<TextInputValueType> {
state: IState$3;
validationTimeout: any;
inputRef: HTMLInputElement | undefined;
shouldComponentUpdate(nextProps: TextInputProps, nextState: IState$3): boolean;
setValue(value: TextInputValueType, disableOnChangeEvent?: boolean): Promise<TextInputValueType>;
getValue(): TextInputValueType;
clear(): Promise<TextInputValueType>;
validation(): boolean;
onChange: (event: React__default.ChangeEvent<HTMLInputElement>) => void;
private onClick;
private onBlur;
private onFocus;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type TimeInputValueType = Dayjs | null
interface TimeInputProps extends BaseInput<TimeInputValueType>, Omit<TimePickerProps<Dayjs, false>, 'value' | 'ref'> {
type: 'time'
/**
* @deprecated
* use LocalizationProvider wrapper instead
* @docs https://mui.com/x/react-date-pickers/getting-started/#localizationprovider
*/
dateAdapter?: new (...args: any) => MuiPickersAdapter<Dayjs>
variant?: Variant
defaultValue?: TimeInputValueType
fullWidth?: boolean
InputProps?: TextFieldProps
}
interface IState$2 {
value: TimeInputValueType;
error: boolean;
}
declare class TimeInput extends Component<TimeInputProps, IState$2> implements InputImplement<TimeInputValueType> {
state: IState$2;
validationTimeout: any;
shouldComponentUpdate(nextProps: TimeInputProps, nextState: IState$2): boolean;
setValue(value: TimeInputValueType, disableOnChangeEvent?: boolean): Promise<TimeInputValueType>;
getValue(): TimeInputValueType;
clear(): Promise<TimeInputValueType>;
validation(): boolean;
onChange: (value: Dayjs | null, context: PickerChangeHandlerContext<TimeValidationError>) => void;
private onClick;
inputRef: HTMLInputElement | null | undefined;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type ToggleInputValueType = string | string[] | null
type ToggleInputOptionType = {
label: string | ReactNode
value: any
}
interface ToggleInputProps extends BaseInput<ToggleInputValueType>, Omit<ToggleButtonGroupProps, 'defaultValue' | 'ref'> {
type: 'toggle'
options: ToggleInputOptionType[]
defaultValue?: ToggleInputValueType
exclusive?: boolean
label?: string
enforceValueSet?: boolean
}
interface IState$1 {
value: ToggleInputValueType;
error: boolean;
}
declare class ToggleInput extends Component<ToggleInputProps, IState$1> implements InputImplement<ToggleInputValueType> {
state: IState$1;
validationTimeout: any;
inputRef: HTMLInputElement | undefined;
shouldComponentUpdate(nextProps: ToggleInputProps, nextState: IState$1): boolean;
setValue(value: ToggleInputValueType, disableOnChangeEvent?: boolean): Promise<ToggleInputValueType>;
getValue(): ToggleInputValueType;
clear(): Promise<ToggleInputValueType>;
validation(): boolean;
onChange: (_: React__default.MouseEvent<HTMLElement>, value: ToggleInputValueType) => void;
click: () => void;
focus: () => void;
blur: () => void;
render(): react_jsx_runtime.JSX.Element;
}
type InputProps =
| TextInputProps
| NumberInputProps
| ItemsInputProps
| CustomInputProps
| CheckboxInputProps
| MobileInputProps
| OtpInputProps
| PasswordInputProps
| SelectInputProps
| DateInputProps
| TimeInputProps
| DatetimeInputProps
| MaskInputProps
| FileInputProps
| AutocompleteInputProps
| ToggleInputProps
| GroupInputProps
| SwitchInputProps
type Input =
| TextInput
| NumberInput
| ItemsInput
| CustomInput
| CheckboxInput
| MobileInput
| OtpInput
| PasswordInput
| SelectInput
| DateInput
| TimeInput
| DatetimeInput
| MaskInput
| FileInput
| AutocompleteInput
| ToggleInput
| GroupInput
| SwitchInput;
type InputRefs<TValues extends ObjectLiteral> = {
[K in keyof TValues]: InputImplement<TValues[K]>
}
type ObjectLiteral = { [key: string]: any }
type Variant = 'standard' | 'filled' | 'outlined'
interface InputActions<ValueType = any> {
setValue: (data: ValueType) => Promise<ValueType>
getValue: () => Promise<ValueType>
clear: () => Promise<ValueType>
click: () => Promise<any>
focus: () => Promise<any>
blur: () => Promise<any>
copy?: () => Promise<any>
}
interface BaseInput<ValueType = any> {
selector: string
required?: boolean
/**
* @default true
*/
visible?: ((e: any) => boolean | undefined) | boolean
wrapper?: (children: JSX.Element, actions: InputActions<ValueType>) => JSX.Element
/**
* listen for changes to update component from external state or resource
* @examples
* updateListener: {
* disabled: this.state.isDisabled
* }
*
*
*/
updateListener?: Array<string | null | number | undefined | boolean> | { [key: number | string]: string | null | number | undefined | boolean }
onChangeValue?: (value: ValueType) => void
getMutator?: (value: any) => any
setMutator?: (value: any) => any
formatter?: (value: any) => any
_call_parent_for_update?: () => Promise<boolean>
ref?: any,
reactKey?: string
}
interface InputImplement<ValueType> {
setValue: (data: ValueType, disableOnChangeEvent?: boolean) => Promise<ValueType>
getValue: (validation?: boolean) => ValueType
clear: () => Promise<ValueType>
validation?: () => boolean
click?: () => void
focus?: () => void
blur?: () => void
}
type OutputValues<T = ObjectLiteral> = {
data: T
validation: {
status: boolean
inputs: Array<any>
},
api: {
refs: InputRefs<T>
}
}
type BuilderValue<T = any> = OutputValues<T> | undefined
type WrapperElement = JSX.Element
type WrapperActions<T = any> = InputActions<T>
interface FormBuilderImplements {
getValues: (validation: boolean) => OutputValues;
setValues: (values: ObjectLiteral) => Promise<void>;
clear: () => Promise<void>;
}
interface IState {
isMounted: boolean;
time: number | null;
inInternalSettingProcess: boolean;
}
interface FormBuilderProps {
inputs: InputProps[];
onChange?: Function;
onMount?: Function;
}
declare class FormBuilder<TValues extends ObjectLiteral = ObjectLiteral> extends Component<FormBuilderProps, IState> implements FormBuilderImplements {
state: IState;
private _typecheck_only;
private inputRefs;
private inputs;
private defaultValues;
private didMountEvent;
componentDidMount(): void;
componentWillUnmount(): void;
componentDidUpdate(): void;
getValues: (validation?: boolean) => OutputValues;
private setObjectValues;
private setNormalValue;
private setValue;
setValues: (value: ObjectLiteral) => Promise<any>;
private syncSetValues;
clear: () => Promise<any>;
private lastVisibilityOfInputs;
private checkVisibility;
private onUpdateInputs;
private executeAction;
private renderInput;
render(): JSX.Element;
}
declare function useFormBuilder<TValues extends ObjectLiteral>(): {
ref: React$1.RefObject<FormBuilder<TValues>>;
getValues: (validation?: boolean) => OutputValues<TValues>;
getBuilder: (validation?: boolean) => OutputValues<TValues>;
setValues: (values: Partial<TValues>) => Promise<any>;
clear: () => Promise<any>;
};
export { CheckboxInput, CustomInput, DateInput, DatetimeInput, FileInput, FormBuilder, GroupInput, ItemsInput, MaskInput, MobileInput, NumberInput, OtpInput, PasswordInput, SelectInput, SwitchInput, TextInput, TimeInput, ToggleInput, FormBuilder as default, useFormBuilder };
export type { AutocompleteInputProps, AutocompleteOptionType, AutocompleteValueType, BuilderValue, CheckboxInputProps, CheckboxInputValueType, CustomInputProps, CustomInputValueType, DateInputProps, DateInputValueType, DatetimeInputProps, DatetimeInputValueType, FileInputProps, FileInputValueType, GroupInputProps, GroupInputValueType, Input, InputActions, InputImplement, InputProps, ItemsInputProps, ItemsInputValueType, MaskInputProps, MaskInputValueType, MobileInputProps, MobileInputValueType, NumberInputProps, NumberInputValueType, OtpInputProps, OtpInputValueType, OutputValues, PasswordInputProps, PasswordInputValueType, SelectInputProps, SelectInputValueType, TextInputProps, TextInputValueType, TimeInputProps, TimeInputValueType, ToggleInputProps, ToggleInputValueType, WrapperActions, WrapperElement };