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
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parser" : "babel-eslint",
|
|
3
|
-
"plugins": [
|
|
4
|
-
"import"
|
|
5
|
-
],
|
|
6
|
-
"extends" : ["airbnb"],
|
|
7
|
-
"rules": {
|
|
8
|
-
// Soft some rules.
|
|
9
|
-
"camelcase": "off",
|
|
10
|
-
"class-methods-use-this": "off",
|
|
11
|
-
"default-case": 0, // Required default case is nonsense.
|
|
12
|
-
"indent": [2, 4, { "SwitchCase": 1, "VariableDeclarator": 1 }],
|
|
13
|
-
"linebreak-style": "off",
|
|
14
|
-
"max-len": "off",
|
|
15
|
-
"new-cap": [2, {"capIsNew": false, "newIsCap": true}], // For Record() etc.
|
|
16
|
-
"newline-per-chained-call": 0,
|
|
17
|
-
"no-cond-assign": "off",
|
|
18
|
-
"no-floating-decimal": 0, // .5 is just fine.
|
|
19
|
-
"no-nested-ternary": 0, // It's nice for JSX.
|
|
20
|
-
"no-param-reassign": 0, // We love param reassignment. Naming is hard.
|
|
21
|
-
"no-plusplus": 0,
|
|
22
|
-
"no-prototype-builtins": 0,
|
|
23
|
-
"no-shadow": 0, // Shadowing is a nice language feature. Naming is hard.
|
|
24
|
-
"react/no-string-refs": 0,
|
|
25
|
-
"no-underscore-dangle": "off",
|
|
26
|
-
// eslint-plugin-import
|
|
27
|
-
"import/no-unresolved": [2, {"commonjs": true}],
|
|
28
|
-
"import/no-extraneous-dependencies": 0,
|
|
29
|
-
"import/named": 2,
|
|
30
|
-
"import/default": 2,
|
|
31
|
-
"import/namespace": 2,
|
|
32
|
-
"import/export": 2,
|
|
33
|
-
"func-names": ["error", "as-needed"],
|
|
34
|
-
// Overide Stateless
|
|
35
|
-
"react/prefer-stateless-function": 0,
|
|
36
|
-
"react/jsx-indent": [2, 4],
|
|
37
|
-
"react/jsx-indent-props": [2, 4],
|
|
38
|
-
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
|
|
39
|
-
"react/no-unused-prop-types": 0,
|
|
40
|
-
"react/no-array-index-key": 0,
|
|
41
|
-
"react/forbid-prop-types": 0,
|
|
42
|
-
"react/require-default-props": 0,
|
|
43
|
-
"jsx-a11y/anchor-has-content": 0,
|
|
44
|
-
},
|
|
45
|
-
"globals": {
|
|
46
|
-
"after": false,
|
|
47
|
-
"afterEach": false,
|
|
48
|
-
"before": false,
|
|
49
|
-
"beforeEach": false,
|
|
50
|
-
"describe": false,
|
|
51
|
-
"it": false,
|
|
52
|
-
"require": false,
|
|
53
|
-
"window": true,
|
|
54
|
-
"localStorage": true,
|
|
55
|
-
"document": true,
|
|
56
|
-
"navigator": true,
|
|
57
|
-
"location": true,
|
|
58
|
-
"XMLHttpRequest": true,
|
|
59
|
-
"XDomainRequest": true,
|
|
60
|
-
"Blob": true,
|
|
61
|
-
},
|
|
62
|
-
"settings": {
|
|
63
|
-
"import/ignore": [
|
|
64
|
-
"node_modules",
|
|
65
|
-
"\\.json$"
|
|
66
|
-
],
|
|
67
|
-
"import/parser": "babel-eslint",
|
|
68
|
-
"import/resolve": {
|
|
69
|
-
"extensions": [
|
|
70
|
-
".js",
|
|
71
|
-
".jsx",
|
|
72
|
-
".json"
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports["default"] = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
|
-
var _red = _interopRequireDefault(require("@mui/material/colors/red"));
|
|
13
|
-
|
|
14
|
-
var _Checkbox = _interopRequireDefault(require("@mui/material/Checkbox"));
|
|
15
|
-
|
|
16
|
-
var _MuiComponent2 = _interopRequireDefault(require("../core/MuiComponent"));
|
|
17
|
-
|
|
18
|
-
var _excluded = ["errorStyle", "errorMessages", "validators", "requiredError", "value"];
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
-
|
|
22
|
-
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); }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
|
-
|
|
30
|
-
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); } }
|
|
31
|
-
|
|
32
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
|
-
|
|
34
|
-
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); }
|
|
35
|
-
|
|
36
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
37
|
-
|
|
38
|
-
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); }; }
|
|
39
|
-
|
|
40
|
-
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); }
|
|
41
|
-
|
|
42
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
43
|
-
|
|
44
|
-
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; } }
|
|
45
|
-
|
|
46
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
47
|
-
|
|
48
|
-
var red300 = _red["default"]["500"];
|
|
49
|
-
var style = {
|
|
50
|
-
right: 0,
|
|
51
|
-
fontSize: "12px",
|
|
52
|
-
color: red300,
|
|
53
|
-
position: "absolute",
|
|
54
|
-
marginTop: "-25px"
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
var MuiCheckbox = /*#__PURE__*/function (_MuiComponent) {
|
|
58
|
-
_inherits(MuiCheckbox, _MuiComponent);
|
|
59
|
-
|
|
60
|
-
var _super = _createSuper(MuiCheckbox);
|
|
61
|
-
|
|
62
|
-
function MuiCheckbox() {
|
|
63
|
-
_classCallCheck(this, MuiCheckbox);
|
|
64
|
-
|
|
65
|
-
return _super.apply(this, arguments);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
_createClass(MuiCheckbox, [{
|
|
69
|
-
key: "renderMuiComponent",
|
|
70
|
-
value: function renderMuiComponent() {
|
|
71
|
-
var _this = this;
|
|
72
|
-
|
|
73
|
-
var _this$props = this.props,
|
|
74
|
-
errorStyle = _this$props.errorStyle,
|
|
75
|
-
errorMessages = _this$props.errorMessages,
|
|
76
|
-
validators = _this$props.validators,
|
|
77
|
-
requiredError = _this$props.requiredError,
|
|
78
|
-
value = _this$props.value,
|
|
79
|
-
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
80
|
-
|
|
81
|
-
return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Checkbox["default"], _extends({}, rest, {
|
|
82
|
-
ref: function ref(r) {
|
|
83
|
-
_this.input = r;
|
|
84
|
-
}
|
|
85
|
-
})), this.errorText());
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "errorText",
|
|
89
|
-
value: function errorText() {
|
|
90
|
-
var isValid = this.state.isValid;
|
|
91
|
-
|
|
92
|
-
if (isValid) {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
97
|
-
style: errorStyle ? errorStyle : style
|
|
98
|
-
}, this.getErrorMessage());
|
|
99
|
-
}
|
|
100
|
-
}]);
|
|
101
|
-
|
|
102
|
-
return MuiCheckbox;
|
|
103
|
-
}(_MuiComponent2["default"]);
|
|
104
|
-
|
|
105
|
-
var _default = MuiCheckbox;
|
|
106
|
-
exports["default"] = _default;
|
package/lib/utils/utils.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.debounce = void 0;
|
|
7
|
-
|
|
8
|
-
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); } }
|
|
9
|
-
|
|
10
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
-
|
|
12
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
|
|
14
|
-
var debounce = function debounce(func, wait, immediate) {
|
|
15
|
-
var timeout;
|
|
16
|
-
|
|
17
|
-
function cancel() {
|
|
18
|
-
if (timeout !== undefined) {
|
|
19
|
-
clearTimeout(timeout);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var debounced = /*#__PURE__*/_createClass(function debounced() {
|
|
24
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
-
args[_key] = arguments[_key];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
_classCallCheck(this, debounced);
|
|
29
|
-
|
|
30
|
-
var context = this;
|
|
31
|
-
|
|
32
|
-
var later = function delayed() {
|
|
33
|
-
timeout = null;
|
|
34
|
-
|
|
35
|
-
if (!immediate) {
|
|
36
|
-
func.apply(context, args);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
var callNow = immediate && !timeout;
|
|
41
|
-
clearTimeout(timeout);
|
|
42
|
-
timeout = setTimeout(later, wait);
|
|
43
|
-
|
|
44
|
-
if (callNow) {
|
|
45
|
-
func.apply(context, args);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
debounced.cancel = cancel;
|
|
50
|
-
return debounced;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
exports.debounce = debounce;
|