|
1 |
| -import PropTypes from 'prop-types'; |
2 |
| -import React from 'react'; |
3 |
| -import { FormsyContextInterface, IModel, InputComponent, IResetModel, IUpdateInputsWithError, IUpdateInputsWithValue, ValidationError } from './interfaces'; |
4 |
| -import { PassDownProps } from './withFormsy'; |
5 |
| -declare type FormHTMLAttributesCleaned = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onChange' | 'onSubmit'>; |
6 |
| -declare type OnSubmitCallback = (model: IModel, resetModel: IResetModel, updateInputsWithError: IUpdateInputsWithError, event: React.SyntheticEvent<React.FormHTMLAttributes<any>>) => void; |
7 |
| -export interface FormsyProps extends FormHTMLAttributesCleaned { |
8 |
| - disabled: boolean; |
9 |
| - mapping: null | ((model: IModel) => IModel); |
10 |
| - onChange: (model: IModel, isChanged: boolean) => void; |
11 |
| - onInvalid: () => void; |
12 |
| - onReset?: () => void; |
13 |
| - onSubmit?: OnSubmitCallback; |
14 |
| - onValidSubmit?: OnSubmitCallback; |
15 |
| - onInvalidSubmit: OnSubmitCallback; |
16 |
| - onValid: () => void; |
17 |
| - preventDefaultSubmit?: boolean; |
18 |
| - preventExternalInvalidation?: boolean; |
19 |
| - validationErrors?: null | object; |
20 |
| -} |
21 |
| -export interface FormsyState { |
22 |
| - canChange: boolean; |
23 |
| - contextValue: FormsyContextInterface; |
24 |
| - formSubmitted?: boolean; |
25 |
| - isPristine?: boolean; |
26 |
| - isSubmitting: boolean; |
27 |
| - isValid: boolean; |
28 |
| -} |
29 |
| -export declare class Formsy extends React.Component<FormsyProps, FormsyState> { |
30 |
| - inputs: InstanceType<any & PassDownProps<any>>[]; |
31 |
| - emptyArray: any[]; |
32 |
| - prevInputNames: any[] | null; |
33 |
| - static displayName: string; |
34 |
| - static propTypes: { |
35 |
| - disabled: PropTypes.Requireable<boolean>; |
36 |
| - mapping: PropTypes.Requireable<(...args: any[]) => any>; |
37 |
| - onChange: PropTypes.Requireable<(...args: any[]) => any>; |
38 |
| - onInvalid: PropTypes.Requireable<(...args: any[]) => any>; |
39 |
| - onInvalidSubmit: PropTypes.Requireable<(...args: any[]) => any>; |
40 |
| - onReset: PropTypes.Requireable<(...args: any[]) => any>; |
41 |
| - onSubmit: PropTypes.Requireable<(...args: any[]) => any>; |
42 |
| - onValid: PropTypes.Requireable<(...args: any[]) => any>; |
43 |
| - onValidSubmit: PropTypes.Requireable<(...args: any[]) => any>; |
44 |
| - preventDefaultSubmit: PropTypes.Requireable<boolean>; |
45 |
| - preventExternalInvalidation: PropTypes.Requireable<boolean>; |
46 |
| - validationErrors: PropTypes.Requireable<object>; |
47 |
| - }; |
48 |
| - static defaultProps: Partial<FormsyProps>; |
49 |
| - private readonly throttledValidateForm; |
50 |
| - constructor(props: FormsyProps); |
51 |
| - componentDidMount: () => void; |
52 |
| - componentDidUpdate: (prevProps: FormsyProps) => void; |
53 |
| - getCurrentValues: () => any; |
54 |
| - getModel: () => any; |
55 |
| - getPristineValues: () => any; |
56 |
| - setFormPristine: (isPristine: boolean) => void; |
57 |
| - setInputValidationErrors: (errors: any) => void; |
58 |
| - setFormValidState: (allIsValid: boolean) => void; |
59 |
| - isValidValue: (component: any, value: any) => boolean; |
60 |
| - isFormDisabled: () => boolean; |
61 |
| - mapModel: (model: IModel) => IModel; |
62 |
| - reset: (model?: IModel) => void; |
63 |
| - private resetInternal; |
64 |
| - private resetModel; |
65 |
| - runValidation: <V>(component: InputComponent<V>, value?: V) => { |
66 |
| - isRequired: boolean; |
67 |
| - isValid: boolean; |
68 |
| - validationError: ValidationError[]; |
69 |
| - }; |
70 |
| - attachToForm: (component: any) => void; |
71 |
| - detachFromForm: <V>(component: InputComponent<V>) => void; |
72 |
| - isChanged: () => boolean; |
73 |
| - submit: (event?: React.SyntheticEvent) => void; |
74 |
| - updateInputsWithError: IUpdateInputsWithError; |
75 |
| - updateInputsWithValue: IUpdateInputsWithValue<any>; |
76 |
| - validate: <V>(component: InputComponent<V>) => void; |
77 |
| - validateForm: () => void; |
78 |
| - render(): React.FunctionComponentElement<React.ProviderProps<FormsyContextInterface>>; |
79 |
| -} |
80 |
| -export {}; |
| 1 | +import PropTypes from 'prop-types'; |
| 2 | +import React from 'react'; |
| 3 | +import { FormsyContextInterface, IModel, InputComponent, IResetModel, IUpdateInputsWithError, IUpdateInputsWithValue, ValidationError } from './interfaces'; |
| 4 | +import { PassDownProps } from './withFormsy'; |
| 5 | +declare type FormHTMLAttributesCleaned = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onChange' | 'onSubmit'>; |
| 6 | +declare type OnSubmitCallback = (model: IModel, resetModel: IResetModel, updateInputsWithError: IUpdateInputsWithError, event: React.SyntheticEvent<React.FormHTMLAttributes<any>>) => void; |
| 7 | +declare type FormElementType = string | React.ComponentType<{ |
| 8 | + onReset?: (e: React.SyntheticEvent) => void; |
| 9 | + onSubmit?: (e: React.SyntheticEvent) => void; |
| 10 | + disabled?: boolean; |
| 11 | + children?: React.ReactChildren; |
| 12 | +}>; |
| 13 | +export interface FormsyProps extends FormHTMLAttributesCleaned { |
| 14 | + disabled: boolean; |
| 15 | + mapping: null | ((model: IModel) => IModel); |
| 16 | + onChange: (model: IModel, isChanged: boolean) => void; |
| 17 | + onInvalid: () => void; |
| 18 | + onReset?: () => void; |
| 19 | + onSubmit?: OnSubmitCallback; |
| 20 | + onValidSubmit?: OnSubmitCallback; |
| 21 | + onInvalidSubmit: OnSubmitCallback; |
| 22 | + onValid: () => void; |
| 23 | + preventDefaultSubmit?: boolean; |
| 24 | + preventExternalInvalidation?: boolean; |
| 25 | + validationErrors?: null | object; |
| 26 | + formElement?: FormElementType; |
| 27 | +} |
| 28 | +export interface FormsyState { |
| 29 | + canChange: boolean; |
| 30 | + contextValue: FormsyContextInterface; |
| 31 | + formSubmitted?: boolean; |
| 32 | + isPristine?: boolean; |
| 33 | + isSubmitting: boolean; |
| 34 | + isValid: boolean; |
| 35 | +} |
| 36 | +export declare class Formsy extends React.Component<FormsyProps, FormsyState> { |
| 37 | + inputs: InstanceType<any & PassDownProps<any>>[]; |
| 38 | + emptyArray: any[]; |
| 39 | + prevInputNames: any[] | null; |
| 40 | + static displayName: string; |
| 41 | + static propTypes: { |
| 42 | + disabled: PropTypes.Requireable<boolean>; |
| 43 | + mapping: PropTypes.Requireable<(...args: any[]) => any>; |
| 44 | + formElement: PropTypes.Requireable<string | object>; |
| 45 | + onChange: PropTypes.Requireable<(...args: any[]) => any>; |
| 46 | + onInvalid: PropTypes.Requireable<(...args: any[]) => any>; |
| 47 | + onInvalidSubmit: PropTypes.Requireable<(...args: any[]) => any>; |
| 48 | + onReset: PropTypes.Requireable<(...args: any[]) => any>; |
| 49 | + onSubmit: PropTypes.Requireable<(...args: any[]) => any>; |
| 50 | + onValid: PropTypes.Requireable<(...args: any[]) => any>; |
| 51 | + onValidSubmit: PropTypes.Requireable<(...args: any[]) => any>; |
| 52 | + preventDefaultSubmit: PropTypes.Requireable<boolean>; |
| 53 | + preventExternalInvalidation: PropTypes.Requireable<boolean>; |
| 54 | + validationErrors: PropTypes.Requireable<object>; |
| 55 | + }; |
| 56 | + static defaultProps: Partial<FormsyProps>; |
| 57 | + private readonly throttledValidateForm; |
| 58 | + constructor(props: FormsyProps); |
| 59 | + componentDidMount: () => void; |
| 60 | + componentDidUpdate: (prevProps: FormsyProps) => void; |
| 61 | + getCurrentValues: () => any; |
| 62 | + getModel: () => any; |
| 63 | + getPristineValues: () => any; |
| 64 | + setFormPristine: (isPristine: boolean) => void; |
| 65 | + setInputValidationErrors: (errors: any) => void; |
| 66 | + setFormValidState: (allIsValid: boolean) => void; |
| 67 | + isValidValue: (component: any, value: any) => boolean; |
| 68 | + isFormDisabled: () => boolean; |
| 69 | + mapModel: (model: IModel) => IModel; |
| 70 | + reset: (model?: IModel) => void; |
| 71 | + private resetInternal; |
| 72 | + private resetModel; |
| 73 | + runValidation: <V>(component: InputComponent<V>, value?: V) => { |
| 74 | + isRequired: boolean; |
| 75 | + isValid: boolean; |
| 76 | + validationError: ValidationError[]; |
| 77 | + }; |
| 78 | + attachToForm: (component: any) => void; |
| 79 | + detachFromForm: <V>(component: InputComponent<V>) => void; |
| 80 | + isChanged: () => boolean; |
| 81 | + submit: (event?: React.SyntheticEvent) => void; |
| 82 | + updateInputsWithError: IUpdateInputsWithError; |
| 83 | + updateInputsWithValue: IUpdateInputsWithValue<any>; |
| 84 | + validate: <V>(component: InputComponent<V>) => void; |
| 85 | + validateForm: () => void; |
| 86 | + render(): React.FunctionComponentElement<React.ProviderProps<FormsyContextInterface>>; |
| 87 | +} |
| 88 | +export {}; |
0 commit comments