react-mui-form-validator 1.0.3 → 1.0.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.
- package/.eslintrc.js +29 -0
- package/Readme.md +12 -33
- package/lib/components/MuiTextField.js +27 -52
- package/lib/components/MuiTextSelect.js +27 -52
- package/lib/core/context/index.js +12 -0
- package/lib/core/utils/utils.js +35 -0
- package/lib/core/{MuiRules.js → validator/ValidationRules.js} +0 -6
- package/lib/core/{MuiComponent.js → validator/ValidatorComponent.js} +23 -74
- package/lib/core/{MuiForm.js → validator/ValidatorForm.js} +39 -106
- package/lib/index.js +0 -8
- package/package.json +21 -18
- package/tsconfig.json +27 -0
- package/.eslintrc +0 -76
- package/lib/components/MuiCheckbox.js +0 -106
- package/lib/utils/utils.js +0 -53
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
browser: true,
|
|
4
|
+
es2021: true,
|
|
5
|
+
},
|
|
6
|
+
extends: 'airbnb',
|
|
7
|
+
overrides: [
|
|
8
|
+
{
|
|
9
|
+
env: {
|
|
10
|
+
node: true,
|
|
11
|
+
},
|
|
12
|
+
files: [
|
|
13
|
+
'.eslintrc.{js,cjs}',
|
|
14
|
+
],
|
|
15
|
+
parserOptions: {
|
|
16
|
+
sourceType: 'script',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
parserOptions: {
|
|
21
|
+
ecmaVersion: 'latest',
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
},
|
|
26
|
+
compilerOptions: {
|
|
27
|
+
"module": "esnext"
|
|
28
|
+
}
|
|
29
|
+
};
|
package/Readme.md
CHANGED
|
@@ -15,32 +15,12 @@ Some rules can accept extra parameter, example:
|
|
|
15
15
|
|
|
16
16
|
TextField
|
|
17
17
|
```javascript
|
|
18
|
-
<
|
|
18
|
+
<TextFieldValidator
|
|
19
19
|
{...someProps}
|
|
20
20
|
validators={["minNumber:0", "maxNumber:255", "matchRegexp:^[0-9]$"]}
|
|
21
21
|
/>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
Select
|
|
25
|
-
```javascript
|
|
26
|
-
<MuiTextSelect
|
|
27
|
-
{...someProps}
|
|
28
|
-
validators={["required"]}
|
|
29
|
-
errorMessages={["this select is required"]}
|
|
30
|
-
/>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Checkbox
|
|
34
|
-
```javascript
|
|
35
|
-
<MuiCheckbox
|
|
36
|
-
{...someProps}
|
|
37
|
-
validators={["required"]}
|
|
38
|
-
errorMessages={["this checkbox is required"]}
|
|
39
|
-
checked={value}
|
|
40
|
-
value={value}
|
|
41
|
-
/>
|
|
42
|
-
```
|
|
43
|
-
|
|
44
24
|
### Usage Example
|
|
45
25
|
|
|
46
26
|
You can pass any props of field components, but note that `errorText` prop will be replaced when validation errors occurred.
|
|
@@ -49,7 +29,7 @@ Your component must [provide a theme](http://www.material-ui.com/#/get-started/u
|
|
|
49
29
|
```javascript
|
|
50
30
|
import React from "react";
|
|
51
31
|
import Button from "@mui/material/Button";
|
|
52
|
-
import {
|
|
32
|
+
import { FormValidator, TextFieldValidator } from "react-mui-form-validator";
|
|
53
33
|
|
|
54
34
|
class MyForm extends React.Component {
|
|
55
35
|
state = {
|
|
@@ -68,12 +48,11 @@ class MyForm extends React.Component {
|
|
|
68
48
|
render() {
|
|
69
49
|
const { email } = this.state;
|
|
70
50
|
return (
|
|
71
|
-
<
|
|
72
|
-
ref="form"
|
|
51
|
+
<FormValidator
|
|
73
52
|
onSubmit={this.handleSubmit}
|
|
74
53
|
onError={(errors) => console.log(errors)}
|
|
75
54
|
>
|
|
76
|
-
<
|
|
55
|
+
<TextFieldValidator
|
|
77
56
|
label="Email"
|
|
78
57
|
onChange={this.handleChange}
|
|
79
58
|
name="email"
|
|
@@ -82,7 +61,7 @@ class MyForm extends React.Component {
|
|
|
82
61
|
errorMessages={["this field is required", "email is not valid"]}
|
|
83
62
|
/>
|
|
84
63
|
<Button type="submit">Submit</Button>
|
|
85
|
-
</
|
|
64
|
+
</FormValidator>
|
|
86
65
|
);
|
|
87
66
|
}
|
|
88
67
|
}
|
|
@@ -94,7 +73,7 @@ You can add your custom rules:
|
|
|
94
73
|
|
|
95
74
|
import React from 'react';
|
|
96
75
|
import Button from '@mui/material/Button';
|
|
97
|
-
import {
|
|
76
|
+
import { FormValidator, TextFieldValidator} from 'react-mui-form-validator';
|
|
98
77
|
|
|
99
78
|
class ResetPasswordForm extends React.Component {
|
|
100
79
|
|
|
@@ -107,7 +86,7 @@ class ResetPasswordForm extends React.Component {
|
|
|
107
86
|
|
|
108
87
|
componentDidMount() {
|
|
109
88
|
// custom rule will have name 'isPasswordMatch'
|
|
110
|
-
|
|
89
|
+
FormValidator.addValidationRule('isPasswordMatch', (value) => {
|
|
111
90
|
if (value !== this.state.user.password) {
|
|
112
91
|
return false;
|
|
113
92
|
}
|
|
@@ -117,7 +96,7 @@ class ResetPasswordForm extends React.Component {
|
|
|
117
96
|
|
|
118
97
|
componentWillUnmount() {
|
|
119
98
|
// remove rule when it is not needed
|
|
120
|
-
|
|
99
|
+
FormValidator.removeValidationRule('isPasswordMatch');
|
|
121
100
|
}
|
|
122
101
|
|
|
123
102
|
handleChange = (event) => {
|
|
@@ -134,10 +113,10 @@ class ResetPasswordForm extends React.Component {
|
|
|
134
113
|
const { user } = this.state;
|
|
135
114
|
|
|
136
115
|
return (
|
|
137
|
-
<
|
|
116
|
+
<FormValidator
|
|
138
117
|
onSubmit={this.handleSubmit}
|
|
139
118
|
>
|
|
140
|
-
<
|
|
119
|
+
<TextFieldValidator
|
|
141
120
|
label="Password"
|
|
142
121
|
onChange={this.handleChange}
|
|
143
122
|
name="password"
|
|
@@ -146,7 +125,7 @@ class ResetPasswordForm extends React.Component {
|
|
|
146
125
|
errorMessages={['this field is required']}
|
|
147
126
|
value={user.password}
|
|
148
127
|
/>
|
|
149
|
-
<
|
|
128
|
+
<TextFieldValidator
|
|
150
129
|
label="Repeat password"
|
|
151
130
|
onChange={this.handleChange}
|
|
152
131
|
name="repeatPassword"
|
|
@@ -156,7 +135,7 @@ class ResetPasswordForm extends React.Component {
|
|
|
156
135
|
value={user.repeatPassword}
|
|
157
136
|
/>
|
|
158
137
|
<Button type="submit">Submit</Button>
|
|
159
|
-
</
|
|
138
|
+
</FormValidator>
|
|
160
139
|
);
|
|
161
140
|
}
|
|
162
141
|
|
|
@@ -1,73 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
13
|
-
|
|
14
|
-
var _MuiComponent2 = _interopRequireDefault(require("../core/MuiComponent"));
|
|
15
|
-
|
|
10
|
+
var _ValidatorComponent2 = _interopRequireDefault(require("utils/ui/validator/ValidatorComponent"));
|
|
16
11
|
var _excluded = ["error", "errorMessages", "validators", "requiredError", "helperText", "validatorListener", "withRequiredValidator", "containerProps"];
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
13
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
22
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
23
|
-
|
|
24
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
|
-
|
|
26
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
-
|
|
28
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
|
-
|
|
17
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
30
18
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
|
-
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
32
21
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
|
-
|
|
34
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
-
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
36
23
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
|
-
|
|
38
24
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
39
|
-
|
|
40
25
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
-
|
|
42
26
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var _super = _createSuper(MuiTextField);
|
|
50
|
-
|
|
51
|
-
function MuiTextField() {
|
|
52
|
-
_classCallCheck(this, MuiTextField);
|
|
53
|
-
|
|
27
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
+
var TextValidator = /*#__PURE__*/function (_ValidatorComponent) {
|
|
29
|
+
_inherits(TextValidator, _ValidatorComponent);
|
|
30
|
+
var _super = _createSuper(TextValidator);
|
|
31
|
+
function TextValidator() {
|
|
32
|
+
_classCallCheck(this, TextValidator);
|
|
54
33
|
return _super.apply(this, arguments);
|
|
55
34
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
value: function renderMuiComponent() {
|
|
35
|
+
_createClass(TextValidator, [{
|
|
36
|
+
key: "renderValidatorComponent",
|
|
37
|
+
value: function renderValidatorComponent() {
|
|
60
38
|
var _this$props = this.props,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
39
|
+
error = _this$props.error,
|
|
40
|
+
errorMessages = _this$props.errorMessages,
|
|
41
|
+
validators = _this$props.validators,
|
|
42
|
+
requiredError = _this$props.requiredError,
|
|
43
|
+
helperText = _this$props.helperText,
|
|
44
|
+
validatorListener = _this$props.validatorListener,
|
|
45
|
+
withRequiredValidator = _this$props.withRequiredValidator,
|
|
46
|
+
containerProps = _this$props.containerProps,
|
|
47
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
71
48
|
var isValid = this.state.isValid;
|
|
72
49
|
return /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({}, rest, {
|
|
73
50
|
error: !isValid || error,
|
|
@@ -75,8 +52,6 @@ var MuiTextField = /*#__PURE__*/function (_MuiComponent) {
|
|
|
75
52
|
}));
|
|
76
53
|
}
|
|
77
54
|
}]);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
exports["default"] = MuiTextField;
|
|
55
|
+
return TextValidator;
|
|
56
|
+
}(_ValidatorComponent2["default"]);
|
|
57
|
+
exports["default"] = TextValidator;
|
|
@@ -1,73 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = void 0;
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _TextField = _interopRequireDefault(require("@mui/material/TextField"));
|
|
13
|
-
|
|
14
|
-
var _MuiComponent2 = _interopRequireDefault(require("../core/MuiComponent"));
|
|
15
|
-
|
|
10
|
+
var _index = require("utils/ui/validator/index");
|
|
16
11
|
var _excluded = ["error", "errorMessages", "validators", "requiredError", "helperText", "validatorListener", "withRequiredValidator", "containerProps"];
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
13
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
22
14
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
23
|
-
|
|
24
15
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
|
-
|
|
26
16
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
27
|
-
|
|
28
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
29
|
-
|
|
17
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
30
18
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
31
|
-
|
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
32
21
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
33
|
-
|
|
34
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
35
|
-
|
|
22
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
36
23
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
37
|
-
|
|
38
24
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
39
|
-
|
|
40
25
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
41
|
-
|
|
42
26
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
var _super = _createSuper(MuiTextSelect);
|
|
50
|
-
|
|
51
|
-
function MuiTextSelect() {
|
|
52
|
-
_classCallCheck(this, MuiTextSelect);
|
|
53
|
-
|
|
27
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
28
|
+
var SelectValidator = /*#__PURE__*/function (_ValidatorComponent) {
|
|
29
|
+
_inherits(SelectValidator, _ValidatorComponent);
|
|
30
|
+
var _super = _createSuper(SelectValidator);
|
|
31
|
+
function SelectValidator() {
|
|
32
|
+
_classCallCheck(this, SelectValidator);
|
|
54
33
|
return _super.apply(this, arguments);
|
|
55
34
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
value: function renderMuiComponent() {
|
|
35
|
+
_createClass(SelectValidator, [{
|
|
36
|
+
key: "renderValidatorComponent",
|
|
37
|
+
value: function renderValidatorComponent() {
|
|
60
38
|
var _this$props = this.props,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
39
|
+
error = _this$props.error,
|
|
40
|
+
errorMessages = _this$props.errorMessages,
|
|
41
|
+
validators = _this$props.validators,
|
|
42
|
+
requiredError = _this$props.requiredError,
|
|
43
|
+
helperText = _this$props.helperText,
|
|
44
|
+
validatorListener = _this$props.validatorListener,
|
|
45
|
+
withRequiredValidator = _this$props.withRequiredValidator,
|
|
46
|
+
containerProps = _this$props.containerProps,
|
|
47
|
+
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
71
48
|
var isValid = this.state.isValid;
|
|
72
49
|
return /*#__PURE__*/_react["default"].createElement(_TextField["default"], _extends({}, rest, {
|
|
73
50
|
select: true,
|
|
@@ -76,8 +53,6 @@ var MuiTextSelect = /*#__PURE__*/function (_MuiComponent) {
|
|
|
76
53
|
}));
|
|
77
54
|
}
|
|
78
55
|
}]);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
exports["default"] = MuiTextSelect;
|
|
56
|
+
return SelectValidator;
|
|
57
|
+
}(_index.ValidatorComponent);
|
|
58
|
+
exports["default"] = SelectValidator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _implementation = _interopRequireDefault(require("./implementation"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
// @flow
|
|
11
|
+
var _default = _react["default"].createContext || _implementation["default"];
|
|
12
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.debounce = void 0;
|
|
7
|
+
var debounce = function debounce(func, wait, immediate) {
|
|
8
|
+
var timeout;
|
|
9
|
+
function cancel() {
|
|
10
|
+
if (timeout !== undefined) {
|
|
11
|
+
clearTimeout(timeout);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
var debounced = function debounced() {
|
|
15
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
16
|
+
args[_key] = arguments[_key];
|
|
17
|
+
}
|
|
18
|
+
var context = this;
|
|
19
|
+
var later = function delayed() {
|
|
20
|
+
timeout = null;
|
|
21
|
+
if (!immediate) {
|
|
22
|
+
func.apply(context, args);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var callNow = immediate && !timeout;
|
|
26
|
+
clearTimeout(timeout);
|
|
27
|
+
timeout = setTimeout(later, wait);
|
|
28
|
+
if (callNow) {
|
|
29
|
+
func.apply(context, args);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
debounced.cancel = cancel;
|
|
33
|
+
return debounced;
|
|
34
|
+
};
|
|
35
|
+
exports.debounce = debounce;
|
|
@@ -3,23 +3,18 @@
|
|
|
3
3
|
var isExisty = function isExisty(value) {
|
|
4
4
|
return value !== null && value !== undefined;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
6
|
var _isEmpty = function isEmpty(value) {
|
|
8
7
|
if (value instanceof Array) {
|
|
9
8
|
return value.length === 0;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
return value === '' || !isExisty(value);
|
|
13
11
|
};
|
|
14
|
-
|
|
15
12
|
var isEmptyTrimed = function isEmptyTrimed(value) {
|
|
16
13
|
if (typeof value === 'string') {
|
|
17
14
|
return value.trim() === '';
|
|
18
15
|
}
|
|
19
|
-
|
|
20
16
|
return true;
|
|
21
17
|
};
|
|
22
|
-
|
|
23
18
|
var validations = {
|
|
24
19
|
matchRegexp: function matchRegexp(value, regexp) {
|
|
25
20
|
var validationRegexp = regexp instanceof RegExp ? regexp : new RegExp(regexp);
|
|
@@ -48,7 +43,6 @@ var validations = {
|
|
|
48
43
|
if (isExisty(value)) {
|
|
49
44
|
return (validations.isNumber(value) || validations.isFloat(value)) && value >= 0;
|
|
50
45
|
}
|
|
51
|
-
|
|
52
46
|
return true;
|
|
53
47
|
},
|
|
54
48
|
maxNumber: function maxNumber(value, max) {
|