dynamic-modal
Version:
The dynamic-modal is a solution of creation different modals into project using a json configuration file
40 lines (39 loc) • 1.95 kB
TypeScript
import { CSSProperties, FC, PropsWithChildren, ReactNode } from 'react';
import { FieldError } from 'react-hook-form';
import { IOption } from './option';
import { IMakeInput } from './make-input';
import { IMakeButton } from './make-button';
import { IMakeSelect } from './make-select';
import { IMakeTextarea } from './make-textarea';
import { IMakeToggle } from './make-toggle';
import { IMakeCustomUpload } from './make-custom-upload';
export interface IComponentAditionalProps {
onChange: (...event: any[]) => void;
value: any;
invalid: boolean;
error?: FieldError;
liveSearching?: boolean;
}
export interface IModalSectionComponentProps {
children: ReactNode;
className?: string;
style?: CSSProperties;
}
export interface IComponentState {
ModalContainer?: FC<IModalSectionComponentProps>;
ModalHeader?: FC<IModalSectionComponentProps>;
ModalTitle?: FC<IModalSectionComponentProps>;
ModalBody?: FC<IModalSectionComponentProps>;
ModalFooter?: FC<IModalSectionComponentProps>;
ModalButtonCancel: FC<Omit<IMakeButton, 'elementType'>>;
ModalButtonAction: FC<Omit<IMakeButton, 'elementType'>>;
Button: FC<Omit<IMakeButton, 'elementType'>>;
Input: FC<Omit<IMakeInput, 'elementType' | 'validation' | 'renderIf' | 'enableIf'> & IComponentAditionalProps>;
CustomUpload: FC<Omit<IMakeCustomUpload, 'elementType' | 'validation' | 'renderIf' | 'enableIf'> & IComponentAditionalProps>;
Select: FC<Omit<IMakeSelect, 'elementType' | 'validation' | 'renderIf' | 'enableIf'> & IComponentAditionalProps & Record<'options', Array<IOption>>>;
Textarea: FC<Omit<IMakeTextarea, 'elementType' | 'validation' | 'renderIf' | 'enableIf'> & IComponentAditionalProps>;
Toggle: FC<Omit<IMakeToggle, 'elementType' | 'validation' | 'renderIf' | 'enableIf'> & IComponentAditionalProps>;
}
export interface IComponentStateProps extends PropsWithChildren {
components: IComponentState;
}