react-mui-form-validator 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.cts CHANGED
@@ -92,65 +92,55 @@ interface ValidatorFormProps {
92
92
  debounceTime?: number;
93
93
  }
94
94
 
95
+ type FormContextValue = {
96
+ form: {
97
+ attachToForm: (component: any) => void;
98
+ detachFromForm: (component: any) => void;
99
+ instantValidate: boolean;
100
+ debounceTime: number;
101
+ } | null;
102
+ };
103
+ declare const FormContext: React$1.Context<FormContextValue>;
104
+
95
105
  declare class ValidatorForm extends React$1.Component<ValidatorFormProps & BoxProps> {
96
106
  static getValidator: (validator: Validator, value: any, includeRequired: boolean) => boolean;
97
- getFormHelpers: () => {
98
- form: {
99
- attachToForm: (component: any) => void;
100
- detachFromForm: (component: any) => void;
101
- instantValidate: boolean;
102
- debounceTime: number;
103
- };
104
- };
105
- instantValidate: boolean;
106
107
  childs: any[];
107
108
  errors: any[];
109
+ instantValidate: boolean;
108
110
  debounceTime: number;
111
+ getFormHelpers: () => FormContextValue;
109
112
  attachToForm: (component: any) => void;
110
113
  detachFromForm: (component: any) => void;
111
114
  submit: (event: React$1.FormEvent<HTMLFormElement>) => void;
112
115
  walk: (children: any[], dryRun?: boolean) => Promise<boolean>;
113
116
  checkInput: (input: any, dryRun?: boolean) => Promise<boolean>;
114
117
  validate: (input: any, includeRequired: boolean, dryRun?: boolean) => Promise<boolean>;
115
- find: (collection: any[], fn: (item: any) => boolean) => any;
116
118
  resetValidations: () => void;
117
119
  isFormValid: (dryRun?: boolean) => Promise<boolean>;
118
120
  render(): React$1.JSX.Element;
119
121
  }
120
122
 
121
123
  declare class ValidatorComponent extends React$1.Component<ValidatorComponentProps, ValidatorComponentState> {
122
- renderValidatorComponent(): React$1.ReactNode;
124
+ static contextType: React$1.Context<FormContextValue>;
125
+ context: React$1.ContextType<typeof FormContext>;
123
126
  validateDebounced: any;
124
- form: any;
125
- debounceTime: any;
126
- getSnapshotBeforeUpdate(nextProps: ValidatorComponentProps, prevState: ValidatorComponentState): {
127
- value: any;
128
- validators: Validator[];
129
- errorMessages: string | string[];
130
- } | {
131
- value: any;
132
- validators?: undefined;
133
- errorMessages?: undefined;
134
- };
135
- state: {
136
- isValid: boolean;
137
- value: any;
138
- errorMessages: string | string[] | undefined;
139
- validators: Validator[] | undefined;
140
- };
141
- componentDidMount(): void;
142
- shouldComponentUpdate(nextProps: ValidatorComponentProps, nextState: ValidatorComponentState): boolean;
143
- componentDidUpdate(prevProps: ValidatorComponentProps, prevState: ValidatorComponentState): void;
144
- componentWillUnmount(): void;
145
- getErrorMessage: () => string | boolean | string[];
127
+ form: FormContextValue["form"];
128
+ debounceTime: number;
146
129
  instantValidate: boolean;
147
130
  invalid: number[];
131
+ state: ValidatorComponentState;
132
+ renderValidatorComponent(): React$1.ReactNode;
133
+ componentDidMount(): void;
134
+ componentDidUpdate(prevProps: ValidatorComponentProps): void;
135
+ componentWillUnmount(): void;
136
+ shouldComponentUpdate(nextProps: ValidatorComponentProps, nextState: ValidatorComponentState): boolean;
148
137
  configure: () => void;
138
+ getErrorMessage: () => string | boolean;
149
139
  validate: (value: any, includeRequired?: boolean, dryRun?: boolean) => Promise<boolean>;
150
140
  isValid: () => boolean;
151
141
  makeInvalid: () => void;
152
142
  makeValid: () => void;
153
- renderComponent: (form: ValidatorForm) => React$1.ReactNode;
143
+ renderComponent: () => React$1.ReactNode;
154
144
  render(): React$1.JSX.Element;
155
145
  }
156
146
 
package/lib/index.d.ts CHANGED
@@ -92,65 +92,55 @@ interface ValidatorFormProps {
92
92
  debounceTime?: number;
93
93
  }
94
94
 
95
+ type FormContextValue = {
96
+ form: {
97
+ attachToForm: (component: any) => void;
98
+ detachFromForm: (component: any) => void;
99
+ instantValidate: boolean;
100
+ debounceTime: number;
101
+ } | null;
102
+ };
103
+ declare const FormContext: React$1.Context<FormContextValue>;
104
+
95
105
  declare class ValidatorForm extends React$1.Component<ValidatorFormProps & BoxProps> {
96
106
  static getValidator: (validator: Validator, value: any, includeRequired: boolean) => boolean;
97
- getFormHelpers: () => {
98
- form: {
99
- attachToForm: (component: any) => void;
100
- detachFromForm: (component: any) => void;
101
- instantValidate: boolean;
102
- debounceTime: number;
103
- };
104
- };
105
- instantValidate: boolean;
106
107
  childs: any[];
107
108
  errors: any[];
109
+ instantValidate: boolean;
108
110
  debounceTime: number;
111
+ getFormHelpers: () => FormContextValue;
109
112
  attachToForm: (component: any) => void;
110
113
  detachFromForm: (component: any) => void;
111
114
  submit: (event: React$1.FormEvent<HTMLFormElement>) => void;
112
115
  walk: (children: any[], dryRun?: boolean) => Promise<boolean>;
113
116
  checkInput: (input: any, dryRun?: boolean) => Promise<boolean>;
114
117
  validate: (input: any, includeRequired: boolean, dryRun?: boolean) => Promise<boolean>;
115
- find: (collection: any[], fn: (item: any) => boolean) => any;
116
118
  resetValidations: () => void;
117
119
  isFormValid: (dryRun?: boolean) => Promise<boolean>;
118
120
  render(): React$1.JSX.Element;
119
121
  }
120
122
 
121
123
  declare class ValidatorComponent extends React$1.Component<ValidatorComponentProps, ValidatorComponentState> {
122
- renderValidatorComponent(): React$1.ReactNode;
124
+ static contextType: React$1.Context<FormContextValue>;
125
+ context: React$1.ContextType<typeof FormContext>;
123
126
  validateDebounced: any;
124
- form: any;
125
- debounceTime: any;
126
- getSnapshotBeforeUpdate(nextProps: ValidatorComponentProps, prevState: ValidatorComponentState): {
127
- value: any;
128
- validators: Validator[];
129
- errorMessages: string | string[];
130
- } | {
131
- value: any;
132
- validators?: undefined;
133
- errorMessages?: undefined;
134
- };
135
- state: {
136
- isValid: boolean;
137
- value: any;
138
- errorMessages: string | string[] | undefined;
139
- validators: Validator[] | undefined;
140
- };
141
- componentDidMount(): void;
142
- shouldComponentUpdate(nextProps: ValidatorComponentProps, nextState: ValidatorComponentState): boolean;
143
- componentDidUpdate(prevProps: ValidatorComponentProps, prevState: ValidatorComponentState): void;
144
- componentWillUnmount(): void;
145
- getErrorMessage: () => string | boolean | string[];
127
+ form: FormContextValue["form"];
128
+ debounceTime: number;
146
129
  instantValidate: boolean;
147
130
  invalid: number[];
131
+ state: ValidatorComponentState;
132
+ renderValidatorComponent(): React$1.ReactNode;
133
+ componentDidMount(): void;
134
+ componentDidUpdate(prevProps: ValidatorComponentProps): void;
135
+ componentWillUnmount(): void;
136
+ shouldComponentUpdate(nextProps: ValidatorComponentProps, nextState: ValidatorComponentState): boolean;
148
137
  configure: () => void;
138
+ getErrorMessage: () => string | boolean;
149
139
  validate: (value: any, includeRequired?: boolean, dryRun?: boolean) => Promise<boolean>;
150
140
  isValid: () => boolean;
151
141
  makeInvalid: () => void;
152
142
  makeValid: () => void;
153
- renderComponent: (form: ValidatorForm) => React$1.ReactNode;
143
+ renderComponent: () => React$1.ReactNode;
154
144
  render(): React$1.JSX.Element;
155
145
  }
156
146