react-mui-form-validator 1.7.1 → 1.7.3
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.cjs +12521 -5194
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +40 -37
- package/lib/index.d.ts +40 -37
- package/lib/index.js +12530 -5203
- package/lib/index.js.map +1 -1
- package/package.json +17 -17
- package/tsconfig.json +2 -1
package/lib/index.d.cts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { FilledTextFieldProps, OutlinedTextFieldProps, StandardTextFieldProps, BoxProps } from '@mui/material';
|
|
4
4
|
import { MuiTelInputInfo } from 'mui-tel-input';
|
|
5
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
5
6
|
|
|
6
7
|
interface required {
|
|
7
8
|
validator: "required";
|
|
@@ -92,65 +93,59 @@ interface ValidatorFormProps {
|
|
|
92
93
|
debounceTime?: number;
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
type FormContextValue = {
|
|
97
|
+
form: {
|
|
98
|
+
attachToForm: (component: any) => void;
|
|
99
|
+
detachFromForm: (component: any) => void;
|
|
100
|
+
instantValidate: boolean;
|
|
101
|
+
debounceTime: number;
|
|
102
|
+
} | null;
|
|
103
|
+
};
|
|
104
|
+
declare const FormContext: React$1.Context<FormContextValue>;
|
|
105
|
+
|
|
95
106
|
declare class ValidatorForm extends React$1.Component<ValidatorFormProps & BoxProps> {
|
|
96
107
|
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
108
|
childs: any[];
|
|
107
109
|
errors: any[];
|
|
108
|
-
|
|
110
|
+
get instantValidate(): boolean;
|
|
111
|
+
get debounceTime(): number;
|
|
112
|
+
getFormHelpers: () => FormContextValue;
|
|
109
113
|
attachToForm: (component: any) => void;
|
|
110
114
|
detachFromForm: (component: any) => void;
|
|
111
115
|
submit: (event: React$1.FormEvent<HTMLFormElement>) => void;
|
|
112
116
|
walk: (children: any[], dryRun?: boolean) => Promise<boolean>;
|
|
113
117
|
checkInput: (input: any, dryRun?: boolean) => Promise<boolean>;
|
|
114
118
|
validate: (input: any, includeRequired: boolean, dryRun?: boolean) => Promise<boolean>;
|
|
115
|
-
find: (collection: any[], fn: (item: any) => boolean) => any;
|
|
116
119
|
resetValidations: () => void;
|
|
117
120
|
isFormValid: (dryRun?: boolean) => Promise<boolean>;
|
|
118
121
|
render(): React$1.JSX.Element;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
type DebouncedValidate = {
|
|
125
|
+
(value: any, includeRequired?: boolean, dryRun?: boolean): void;
|
|
126
|
+
cancel?: () => void;
|
|
127
|
+
};
|
|
128
|
+
declare class ValidatorComponent<P extends ValidatorComponentProps = ValidatorComponentProps> extends React$1.Component<P, ValidatorComponentState> {
|
|
129
|
+
static contextType: React$1.Context<FormContextValue>;
|
|
130
|
+
context: React$1.ContextType<typeof FormContext>;
|
|
131
|
+
validateDebounced: DebouncedValidate | null;
|
|
132
|
+
form: NonNullable<FormContextValue["form"]> | null;
|
|
133
|
+
debounceTime: number;
|
|
134
|
+
instantValidate: boolean;
|
|
135
|
+
invalid: number[];
|
|
136
|
+
state: ValidatorComponentState;
|
|
122
137
|
renderValidatorComponent(): React$1.ReactNode;
|
|
123
|
-
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
138
|
componentDidMount(): void;
|
|
142
|
-
|
|
143
|
-
componentDidUpdate(prevProps: ValidatorComponentProps, prevState: ValidatorComponentState): void;
|
|
139
|
+
componentDidUpdate(prevProps: P): void;
|
|
144
140
|
componentWillUnmount(): void;
|
|
145
|
-
|
|
146
|
-
instantValidate: boolean;
|
|
147
|
-
invalid: number[];
|
|
141
|
+
shouldComponentUpdate(nextProps: P, nextState: ValidatorComponentState): boolean;
|
|
148
142
|
configure: () => void;
|
|
143
|
+
getErrorMessage: () => string | boolean;
|
|
149
144
|
validate: (value: any, includeRequired?: boolean, dryRun?: boolean) => Promise<boolean>;
|
|
150
145
|
isValid: () => boolean;
|
|
151
146
|
makeInvalid: () => void;
|
|
152
147
|
makeValid: () => void;
|
|
153
|
-
renderComponent: (
|
|
148
|
+
renderComponent: () => React$1.ReactNode;
|
|
154
149
|
render(): React$1.JSX.Element;
|
|
155
150
|
}
|
|
156
151
|
|
|
@@ -158,7 +153,15 @@ declare class MuiSelect extends ValidatorComponent {
|
|
|
158
153
|
renderValidatorComponent(): React$1.JSX.Element;
|
|
159
154
|
}
|
|
160
155
|
|
|
161
|
-
|
|
156
|
+
type MuiTextFieldProps = Omit<TextFieldProps, "value"> & {
|
|
157
|
+
value: unknown;
|
|
158
|
+
validators?: any[];
|
|
159
|
+
errorMessages?: string | string[];
|
|
160
|
+
validatorListener?: (isValid: boolean) => void;
|
|
161
|
+
withRequiredValidator?: boolean;
|
|
162
|
+
containerProps?: React__default.HTMLAttributes<HTMLDivElement>;
|
|
163
|
+
};
|
|
164
|
+
declare class MuiTextField extends ValidatorComponent<MuiTextFieldProps> {
|
|
162
165
|
renderValidatorComponent(): React__default.JSX.Element;
|
|
163
166
|
}
|
|
164
167
|
|
package/lib/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { FilledTextFieldProps, OutlinedTextFieldProps, StandardTextFieldProps, BoxProps } from '@mui/material';
|
|
4
4
|
import { MuiTelInputInfo } from 'mui-tel-input';
|
|
5
|
+
import { TextFieldProps } from '@mui/material/TextField';
|
|
5
6
|
|
|
6
7
|
interface required {
|
|
7
8
|
validator: "required";
|
|
@@ -92,65 +93,59 @@ interface ValidatorFormProps {
|
|
|
92
93
|
debounceTime?: number;
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
type FormContextValue = {
|
|
97
|
+
form: {
|
|
98
|
+
attachToForm: (component: any) => void;
|
|
99
|
+
detachFromForm: (component: any) => void;
|
|
100
|
+
instantValidate: boolean;
|
|
101
|
+
debounceTime: number;
|
|
102
|
+
} | null;
|
|
103
|
+
};
|
|
104
|
+
declare const FormContext: React$1.Context<FormContextValue>;
|
|
105
|
+
|
|
95
106
|
declare class ValidatorForm extends React$1.Component<ValidatorFormProps & BoxProps> {
|
|
96
107
|
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
108
|
childs: any[];
|
|
107
109
|
errors: any[];
|
|
108
|
-
|
|
110
|
+
get instantValidate(): boolean;
|
|
111
|
+
get debounceTime(): number;
|
|
112
|
+
getFormHelpers: () => FormContextValue;
|
|
109
113
|
attachToForm: (component: any) => void;
|
|
110
114
|
detachFromForm: (component: any) => void;
|
|
111
115
|
submit: (event: React$1.FormEvent<HTMLFormElement>) => void;
|
|
112
116
|
walk: (children: any[], dryRun?: boolean) => Promise<boolean>;
|
|
113
117
|
checkInput: (input: any, dryRun?: boolean) => Promise<boolean>;
|
|
114
118
|
validate: (input: any, includeRequired: boolean, dryRun?: boolean) => Promise<boolean>;
|
|
115
|
-
find: (collection: any[], fn: (item: any) => boolean) => any;
|
|
116
119
|
resetValidations: () => void;
|
|
117
120
|
isFormValid: (dryRun?: boolean) => Promise<boolean>;
|
|
118
121
|
render(): React$1.JSX.Element;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
type DebouncedValidate = {
|
|
125
|
+
(value: any, includeRequired?: boolean, dryRun?: boolean): void;
|
|
126
|
+
cancel?: () => void;
|
|
127
|
+
};
|
|
128
|
+
declare class ValidatorComponent<P extends ValidatorComponentProps = ValidatorComponentProps> extends React$1.Component<P, ValidatorComponentState> {
|
|
129
|
+
static contextType: React$1.Context<FormContextValue>;
|
|
130
|
+
context: React$1.ContextType<typeof FormContext>;
|
|
131
|
+
validateDebounced: DebouncedValidate | null;
|
|
132
|
+
form: NonNullable<FormContextValue["form"]> | null;
|
|
133
|
+
debounceTime: number;
|
|
134
|
+
instantValidate: boolean;
|
|
135
|
+
invalid: number[];
|
|
136
|
+
state: ValidatorComponentState;
|
|
122
137
|
renderValidatorComponent(): React$1.ReactNode;
|
|
123
|
-
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
138
|
componentDidMount(): void;
|
|
142
|
-
|
|
143
|
-
componentDidUpdate(prevProps: ValidatorComponentProps, prevState: ValidatorComponentState): void;
|
|
139
|
+
componentDidUpdate(prevProps: P): void;
|
|
144
140
|
componentWillUnmount(): void;
|
|
145
|
-
|
|
146
|
-
instantValidate: boolean;
|
|
147
|
-
invalid: number[];
|
|
141
|
+
shouldComponentUpdate(nextProps: P, nextState: ValidatorComponentState): boolean;
|
|
148
142
|
configure: () => void;
|
|
143
|
+
getErrorMessage: () => string | boolean;
|
|
149
144
|
validate: (value: any, includeRequired?: boolean, dryRun?: boolean) => Promise<boolean>;
|
|
150
145
|
isValid: () => boolean;
|
|
151
146
|
makeInvalid: () => void;
|
|
152
147
|
makeValid: () => void;
|
|
153
|
-
renderComponent: (
|
|
148
|
+
renderComponent: () => React$1.ReactNode;
|
|
154
149
|
render(): React$1.JSX.Element;
|
|
155
150
|
}
|
|
156
151
|
|
|
@@ -158,7 +153,15 @@ declare class MuiSelect extends ValidatorComponent {
|
|
|
158
153
|
renderValidatorComponent(): React$1.JSX.Element;
|
|
159
154
|
}
|
|
160
155
|
|
|
161
|
-
|
|
156
|
+
type MuiTextFieldProps = Omit<TextFieldProps, "value"> & {
|
|
157
|
+
value: unknown;
|
|
158
|
+
validators?: any[];
|
|
159
|
+
errorMessages?: string | string[];
|
|
160
|
+
validatorListener?: (isValid: boolean) => void;
|
|
161
|
+
withRequiredValidator?: boolean;
|
|
162
|
+
containerProps?: React__default.HTMLAttributes<HTMLDivElement>;
|
|
163
|
+
};
|
|
164
|
+
declare class MuiTextField extends ValidatorComponent<MuiTextFieldProps> {
|
|
162
165
|
renderValidatorComponent(): React__default.JSX.Element;
|
|
163
166
|
}
|
|
164
167
|
|