react-mui-form-validator 1.5.5 → 1.5.6

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.
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ presets: [
3
+ "@babel/preset-flow",
4
+ "@babel/preset-env",
5
+ ["@babel/preset-react", { runtime: "automatic" }],
6
+ ],
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-mui-form-validator",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "Validator for forms designed with material-ui components.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -17,6 +17,7 @@
17
17
  "keywords": [
18
18
  "react",
19
19
  "mui",
20
+ "mui-validator",
20
21
  "material-ui",
21
22
  "form",
22
23
  "form-validator",
@@ -39,15 +40,24 @@
39
40
  "react-dom": "^16.0.0 || ^17.0.0 || ^18.2.0"
40
41
  },
41
42
  "devDependencies": {
42
- "@mui/material": "^5.14.16",
43
+ "@babel/preset-env": "^7.23.2",
44
+ "@babel/preset-flow": "^7.22.15",
45
+ "@babel/preset-react": "^7.22.15",
46
+ "@jest/globals": "^29.7.0",
47
+ "@mui/material": "^5.14.17",
48
+ "@testing-library/react": "^14.0.0",
43
49
  "@types/node": "^20.8.10",
44
- "@types/react": "^18.2.34",
50
+ "@types/react": "^18.2.36",
45
51
  "@types/react-dom": "^18.2.14",
46
52
  "@types/react-lifecycles-compat": "^3.0.3",
53
+ "@types/react-test-renderer": "^18.0.5",
54
+ "babel-jest": "^29.7.0",
55
+ "jest": "^29.7.0",
47
56
  "mui-tel-input": "4.0.1",
57
+ "react-scripts": "5.0.1",
58
+ "react-test-renderer": "^18.2.0",
48
59
  "rimraf": "^5.0.5",
49
60
  "tsup": "^7.2.0",
50
- "react-scripts": "5.0.1",
51
61
  "typescript": "^4.9.5"
52
62
  },
53
63
  "browserslist": {
package/tsconfig.json CHANGED
@@ -23,4 +23,4 @@
23
23
  },
24
24
 
25
25
  "include": ["src/**/*"]
26
- }
26
+ }
package/lib/index.d.ts DELETED
@@ -1,166 +0,0 @@
1
- import * as React$1 from 'react';
2
- import React__default from 'react';
3
- import { TextFieldVariants, FilledTextFieldProps, StandardTextFieldProps, OutlinedTextFieldProps } from '@mui/material';
4
- import { MuiTelInputInfo } from 'mui-tel-input';
5
-
6
- interface required {
7
- validator: "required";
8
- }
9
- interface matchRegexp {
10
- validator: "matchRegexp";
11
- regexp: RegExp | string;
12
- }
13
- interface isEmail {
14
- validator: "isEmail";
15
- }
16
- interface isEmpty {
17
- validator: "isEmpty";
18
- }
19
- interface trim {
20
- validator: "trim";
21
- }
22
- interface isNumber {
23
- validator: "isNumber";
24
- }
25
- interface isFloat {
26
- validator: "isFloat";
27
- }
28
- interface isPositive {
29
- validator: "isPositive";
30
- }
31
- interface maxNumber {
32
- validator: "maxNumber";
33
- max: number;
34
- }
35
- interface minNumber {
36
- validator: "minNumber";
37
- min: number;
38
- }
39
- interface maxFloat {
40
- validator: "maxFloat";
41
- max: number;
42
- }
43
- interface minFloat {
44
- validator: "minFloat";
45
- min: number;
46
- }
47
- interface isString {
48
- validator: "isString";
49
- }
50
- interface minStringLength {
51
- validator: "minStringLength";
52
- min: number;
53
- }
54
- interface maxStringLength {
55
- validator: "maxStringLength";
56
- max: number;
57
- }
58
- interface isFile {
59
- validator: "isFile";
60
- }
61
- interface maxFileSize {
62
- validator: "maxFileSize";
63
- max: number;
64
- }
65
- interface allowedExtensions {
66
- validator: "allowedExtensions";
67
- fileTypes: string;
68
- }
69
- type Validator = required | matchRegexp | isEmail | isEmpty | trim | isNumber | isFloat | isPositive | maxNumber | minNumber | maxFloat | minFloat | isString | minStringLength | maxStringLength | isFile | maxFileSize | allowedExtensions;
70
-
71
- type MuiTextFieldProps<Variant extends TextFieldVariants = TextFieldVariants> = Variant extends "filled" ? FilledTextFieldProps : Variant extends "standard" ? StandardTextFieldProps : OutlinedTextFieldProps & ValidatorComponentProps;
72
- interface ValidatorComponentProps {
73
- errorMessages?: string | string[];
74
- validators?: Validator[];
75
- value: any;
76
- validatorListener?: (value: boolean) => void;
77
- withRequiredValidator?: boolean;
78
- containerProps?: object;
79
- onChangeTel?: (value: string, info: MuiTelInputInfo) => void;
80
- }
81
- interface ValidatorComponentState {
82
- isValid?: boolean;
83
- value: any;
84
- errorMessages?: string | string[];
85
- validators?: Validator[];
86
- }
87
- interface ValidatorFormProps {
88
- children: React.ReactNode;
89
- onSubmit: () => void;
90
- instantValidate?: boolean;
91
- onError?: (errors: any) => void;
92
- debounceTime?: number;
93
- }
94
-
95
- declare class ValidatorForm extends React$1.Component<ValidatorFormProps> {
96
- 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
- childs: any[];
107
- errors: any[];
108
- debounceTime: number;
109
- attachToForm: (component: any) => void;
110
- detachFromForm: (component: any) => void;
111
- submit: (event: React$1.FormEvent<HTMLFormElement>) => void;
112
- walk: (children: any[], dryRun?: boolean) => Promise<boolean>;
113
- checkInput: (input: any, dryRun?: boolean) => Promise<boolean>;
114
- validate: (input: any, includeRequired: boolean, dryRun?: boolean) => Promise<boolean>;
115
- find: (collection: any[], fn: (item: any) => boolean) => any;
116
- resetValidations: () => void;
117
- isFormValid: (dryRun?: boolean) => Promise<boolean>;
118
- render(): React$1.JSX.Element;
119
- }
120
-
121
- declare class ValidatorComponent extends React$1.Component<MuiTextFieldProps & ValidatorComponentProps, ValidatorComponentState> {
122
- [x: string]: any;
123
- getSnapshotBeforeUpdate(nextProps: ValidatorComponentProps, prevState: ValidatorComponentState): {
124
- value: any;
125
- validators: Validator[];
126
- errorMessages: string | string[];
127
- } | {
128
- value: any;
129
- validators?: undefined;
130
- errorMessages?: undefined;
131
- };
132
- state: {
133
- isValid: boolean;
134
- value: any;
135
- errorMessages: string | string[] | undefined;
136
- validators: Validator[] | undefined;
137
- };
138
- componentDidMount(): void;
139
- shouldComponentUpdate(nextProps: ValidatorComponentProps, nextState: ValidatorComponentState): boolean;
140
- componentDidUpdate(prevProps: ValidatorComponentProps, prevState: ValidatorComponentState): void;
141
- componentWillUnmount(): void;
142
- getErrorMessage: () => string | boolean | string[];
143
- instantValidate: boolean;
144
- invalid: number[];
145
- configure: () => void;
146
- validate: (value: any, includeRequired?: boolean, dryRun?: boolean) => Promise<boolean>;
147
- isValid: () => boolean;
148
- makeInvalid: () => void;
149
- makeValid: () => void;
150
- renderComponent: (form: ValidatorForm) => React$1.ReactNode;
151
- render(): React$1.JSX.Element;
152
- }
153
-
154
- declare class MuiSelect extends ValidatorComponent {
155
- renderValidatorComponent(): React$1.JSX.Element;
156
- }
157
-
158
- declare class MuiTextField extends ValidatorComponent {
159
- renderValidatorComponent(): React__default.JSX.Element;
160
- }
161
-
162
- declare class MuiTelInputDefault extends ValidatorComponent {
163
- renderValidatorComponent(): React__default.JSX.Element;
164
- }
165
-
166
- export { ValidatorComponent as MuiComponent, ValidatorForm as MuiForm, MuiTelInputDefault as MuiPhoneNumber, MuiSelect, MuiTextField, Validator as MuiValidator };