UNPKG

react-forminate

Version:

React.js + Typescript package that creates dynamic UI forms based on the JSON schema

38 lines (37 loc) 2.77 kB
import { FieldIdType } from '../types'; import { default as React } from 'react'; export interface EventHandlersResult<T = HTMLElement> { htmlHandlers: React.HTMLAttributes<T>; customHandlers: { onUpload?: (files: File[], fieldId: FieldIdType) => void; onRemove?: (file: File | string, fieldId: FieldIdType) => void; onChangeItems?: (items: (string | number | boolean)[], fieldId: FieldIdType) => void; onAddItems?: (items: (string | number | boolean)[], fieldId: FieldIdType) => void; onRemoveItems?: (items: (string | number | boolean)[], fieldId: FieldIdType) => void; onSearch?: (items: (string | number | boolean)[], selectedItems: (string | number | boolean)[], fieldId: FieldIdType, searchText?: string) => void; }; } interface BuildFieldEventHandlersParams<T = HTMLInputElement> { fieldId: string; value: any; type?: string; onCustomChange?: (e: React.ChangeEvent<T>, ...args: any[]) => void; onCustomClick?: (e: React.MouseEvent<T>, ...args: any[]) => void; onCustomBlur?: (e: React.FocusEvent<T>, ...args: any[]) => void; onCustomFocus?: (e: React.FocusEvent<T>, ...args: any[]) => void; onCustomKeyDown?: (e: React.KeyboardEvent<T>, ...args: any[]) => void; onCustomKeyUp?: (e: React.KeyboardEvent<T>, ...args: any[]) => void; onCustomMouseDown?: (e: React.MouseEvent<T>, ...args: any[]) => void; onCustomMouseEnter?: (e: React.MouseEvent<T>, ...args: any[]) => void; onCustomMouseLeave?: (e: React.MouseEvent<T>, ...args: any[]) => void; onCustomContextMenu?: (e: React.MouseEvent<T>, ...args: any[]) => void; onCustomUpload?: (files: File[], fieldId: string, event?: React.SyntheticEvent<T>, ...args: any[]) => void; onCustomRemove?: (file: File | string, // Could be file object or file name/id fieldId: string, ...args: any[]) => void; onCustomChangeItems?: (items: (string | number | boolean)[], fieldId: FieldIdType) => void; onCustomAddItems?: (items: (string | number | boolean)[], fieldId: FieldIdType) => void; onCustomRemoveItems?: (items: (string | number | boolean)[], fieldId: FieldIdType) => void; onCustomSearch?: (items: (string | number | boolean)[], selectedItems: (string | number | boolean)[], fieldId: FieldIdType, searchText?: string) => void; } export declare const buildFieldEventHandlers: <T = HTMLInputElement>({ fieldId, value, type, onCustomChange, onCustomClick, onCustomBlur, onCustomFocus, onCustomKeyDown, onCustomKeyUp, onCustomMouseDown, onCustomMouseEnter, onCustomMouseLeave, onCustomContextMenu, onCustomUpload, onCustomRemove, onCustomAddItems, onCustomChangeItems, onCustomRemoveItems, onCustomSearch, }: BuildFieldEventHandlersParams<T>) => EventHandlersResult<T>; export {};