linear-react-components-ui 0.4.76-beta.11 → 0.4.76-beta.12
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/.vscode/settings.json +2 -1
- package/README.md +0 -33
- package/lib/assets/styles/dropdown.scss +2 -28
- package/lib/assets/styles/effects.scss +0 -12
- package/lib/assets/styles/floatMenu.scss +1 -0
- package/lib/assets/styles/panel.scss +1 -0
- package/lib/assets/styles/progress.scss +1 -8
- package/lib/assets/styles/select.scss +0 -1
- package/lib/assets/styles/table.scss +5 -13
- package/lib/assets/styles/tabs.scss +44 -79
- package/lib/assets/styles/treeview.scss +0 -32
- package/lib/avatar/avatar.spec.js +6 -17
- package/lib/avatar/index.js +1 -1
- package/lib/buttons/DefaultButton.js +1 -7
- package/lib/checkbox/index.js +6 -20
- package/lib/dialog/base/index.js +6 -15
- package/lib/dialog/form/index.js +3 -16
- package/lib/drawer/index.js +1 -4
- package/lib/form/Field.js +0 -2
- package/lib/form/FieldNumber.js +2 -10
- package/lib/form/helpers.js +1 -9
- package/lib/form/index.js +222 -209
- package/lib/form/withFieldHOC.js +0 -2
- package/lib/icons/helper.js +0 -16
- package/lib/inputs/base/helpers.js +10 -15
- package/lib/inputs/date/Dropdown.js +3 -3
- package/lib/inputs/date/index.js +9 -10
- package/lib/inputs/number/BaseNumber.js +1 -1
- package/lib/inputs/number/index.js +5 -7
- package/lib/inputs/select/Dropdown.js +4 -4
- package/lib/inputs/select/index.js +3 -26
- package/lib/inputs/select/multiple/index.js +7 -9
- package/lib/inputs/select/simple/index.js +18 -30
- package/lib/internals/withTooltip.js +81 -85
- package/lib/list/Item.js +3 -3
- package/lib/list/index.js +10 -20
- package/lib/list/list.spec.js +85 -129
- package/lib/menus/float/MenuItem.js +8 -25
- package/lib/menus/sidenav/index.js +3 -7
- package/lib/menus/sidenav/popup_menu_search/index.js +1 -1
- package/lib/progress/Bar.js +9 -40
- package/lib/progress/index.js +4 -12
- package/lib/spinner/index.js +1 -6
- package/lib/split/Split.js +11 -5
- package/lib/table/Row.js +1 -1
- package/lib/tabs/Menu.js +5 -18
- package/lib/tabs/MenuItems.js +7 -7
- package/lib/tabs/Panel.js +3 -1
- package/lib/tabs/index.js +20 -151
- package/lib/tabs/tabs.spec.js +5 -8
- package/lib/toolbar/index.js +4 -8
- package/lib/tooltip/index.js +7 -20
- package/lib/treeview/Node.js +48 -347
- package/lib/treeview/index.js +35 -456
- package/package.json +8 -9
- package/.tool-versions +0 -1
- package/lib/assets/styles/multiSelect.scss +0 -105
- package/lib/assets/styles/periodpicker.scss +0 -65
- package/lib/checkbox/Label.js +0 -37
- package/lib/form/FieldPeriod.js +0 -100
- package/lib/form/withFormSecurity.js +0 -106
- package/lib/inputs/date/helpers.js +0 -36
- package/lib/inputs/multiSelect/ActionButtons.js +0 -68
- package/lib/inputs/multiSelect/Dropdown.js +0 -200
- package/lib/inputs/multiSelect/helper.js +0 -18
- package/lib/inputs/multiSelect/index.js +0 -343
- package/lib/inputs/period/Dialog.js +0 -38
- package/lib/inputs/period/Dropdown.js +0 -90
- package/lib/inputs/period/PeriodList.js +0 -79
- package/lib/inputs/period/helper.js +0 -118
- package/lib/inputs/period/index.js +0 -490
- package/lib/tabs/DropdownItems.js +0 -84
package/lib/form/index.js
CHANGED
|
@@ -41,247 +41,268 @@ var _FieldArray = _interopRequireDefault(require("./FieldArray"));
|
|
|
41
41
|
|
|
42
42
|
require("../assets/styles/form.scss");
|
|
43
43
|
|
|
44
|
-
var _dialog = require("../dialog");
|
|
45
|
-
|
|
46
|
-
var _withFormSecurity = require("./withFormSecurity");
|
|
47
|
-
|
|
48
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
49
45
|
|
|
50
46
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
51
47
|
|
|
52
48
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
53
49
|
|
|
54
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
55
|
-
|
|
56
|
-
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); }
|
|
57
|
-
|
|
58
50
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
59
51
|
|
|
60
52
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
61
53
|
|
|
54
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
55
|
+
|
|
62
56
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
63
57
|
|
|
64
58
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
65
59
|
|
|
66
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
67
|
-
|
|
68
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
69
|
-
|
|
70
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
71
|
-
|
|
72
60
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
73
61
|
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
77
|
-
|
|
78
|
-
var Form = function Form(_ref) {
|
|
79
|
-
var submitOnPressEnterKey = _ref.submitOnPressEnterKey,
|
|
80
|
-
dataSource = _ref.dataSource,
|
|
81
|
-
securityBeforeUnload = _ref.securityBeforeUnload,
|
|
82
|
-
handlerReset = _ref.handlerReset,
|
|
83
|
-
handlerSubmit = _ref.handlerSubmit,
|
|
84
|
-
children = _ref.children,
|
|
85
|
-
handlerValidates = _ref.handlerValidates,
|
|
86
|
-
style = _ref.style,
|
|
87
|
-
customClass = _ref.customClass,
|
|
88
|
-
securityTitle = _ref.securityTitle,
|
|
89
|
-
securityText = _ref.securityText,
|
|
90
|
-
onDataChange = _ref.onDataChange,
|
|
91
|
-
onValidateForm = _ref.onValidateForm,
|
|
92
|
-
externalFieldErrors = _ref.externalFieldErrors,
|
|
93
|
-
onSubmit = _ref.onSubmit;
|
|
94
|
-
|
|
95
|
-
var _useState = (0, _react.useState)(dataSource),
|
|
96
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
97
|
-
data = _useState2[0],
|
|
98
|
-
setData = _useState2[1];
|
|
99
|
-
|
|
100
|
-
var _useState3 = (0, _react.useState)(dataSource),
|
|
101
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
102
|
-
originalData = _useState4[0],
|
|
103
|
-
setOriginalData = _useState4[1];
|
|
104
|
-
|
|
105
|
-
var _useState5 = (0, _react.useState)(submitOnPressEnterKey),
|
|
106
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
107
|
-
submitFormOnEnter = _useState6[0],
|
|
108
|
-
setSubmitFormOnEnter = _useState6[1];
|
|
109
|
-
|
|
110
|
-
var _useState7 = (0, _react.useState)({}),
|
|
111
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
112
|
-
fieldErrors = _useState8[0],
|
|
113
|
-
setFieldErrors = _useState8[1];
|
|
114
|
-
|
|
115
|
-
var _useState9 = (0, _react.useState)({}),
|
|
116
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
117
|
-
fieldsValidators = _useState10[0],
|
|
118
|
-
setFieldsValidators = _useState10[1];
|
|
119
|
-
|
|
120
|
-
var context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
|
|
121
|
-
|
|
122
|
-
var getValidatesErrorMessages = function getValidatesErrorMessages(validators, fieldValue) {
|
|
123
|
-
var validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
124
|
-
var errors = [];
|
|
125
|
-
validatorsArray.forEach(function (validator) {
|
|
126
|
-
var result = validator(fieldValue);
|
|
127
|
-
if (result) errors = [].concat(_toConsumableArray(errors), [result]);
|
|
128
|
-
});
|
|
129
|
-
return errors;
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
var checkIsValid = function checkIsValid(value) {
|
|
133
|
-
var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
134
|
-
var dataValidate = value || data;
|
|
135
|
-
var currentFieldErrors = {};
|
|
62
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
136
63
|
|
|
137
|
-
|
|
138
|
-
var fieldValue = _lodash["default"].get(dataValidate, fieldName);
|
|
64
|
+
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); }
|
|
139
65
|
|
|
140
|
-
|
|
66
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
141
67
|
|
|
142
|
-
|
|
143
|
-
currentFieldErrors = _extends({}, fieldErrors, _defineProperty({}, fieldName, messages));
|
|
144
|
-
}
|
|
145
|
-
});
|
|
68
|
+
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); } }
|
|
146
69
|
|
|
147
|
-
|
|
148
|
-
return _lodash["default"].isEmpty(currentFieldErrors);
|
|
149
|
-
};
|
|
70
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
150
71
|
|
|
151
|
-
|
|
152
|
-
var _e$target = e.target,
|
|
153
|
-
name = _e$target.name,
|
|
154
|
-
value = _e$target.value;
|
|
72
|
+
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
155
73
|
|
|
156
|
-
|
|
74
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
157
75
|
|
|
158
|
-
|
|
76
|
+
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); }; }
|
|
159
77
|
|
|
160
|
-
|
|
161
|
-
var onChangedData = context.onChangedData;
|
|
78
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
162
79
|
|
|
163
|
-
|
|
164
|
-
onChangedData(true);
|
|
165
|
-
} else {
|
|
166
|
-
onChangedData(false);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
80
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
169
81
|
|
|
170
|
-
|
|
82
|
+
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; } }
|
|
171
83
|
|
|
172
|
-
|
|
173
|
-
if (onDataChange) onDataChange(newData);
|
|
174
|
-
};
|
|
84
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
175
85
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
var currentFieldErrors = fieldErrors;
|
|
179
|
-
var errors = getValidatesErrorMessages(validators, fieldValue);
|
|
86
|
+
var Form = /*#__PURE__*/function (_Component) {
|
|
87
|
+
_inherits(Form, _Component);
|
|
180
88
|
|
|
181
|
-
|
|
182
|
-
currentFieldErrors = _lodash["default"].omit(currentFieldErrors, fieldName);
|
|
183
|
-
} else {
|
|
184
|
-
currentFieldErrors = _extends({}, currentFieldErrors, _defineProperty({}, fieldName, errors));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
setFieldErrors(currentFieldErrors);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
89
|
+
var _super = _createSuper(Form);
|
|
190
90
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (checkIsValid(data)) onSubmit(data);
|
|
194
|
-
};
|
|
91
|
+
function Form(props) {
|
|
92
|
+
var _this;
|
|
195
93
|
|
|
196
|
-
|
|
197
|
-
setData(JSON.parse(JSON.stringify(originalData)));
|
|
198
|
-
setFieldErrors({});
|
|
199
|
-
};
|
|
94
|
+
_classCallCheck(this, Form);
|
|
200
95
|
|
|
201
|
-
|
|
202
|
-
|
|
96
|
+
_this = _super.call(this, props);
|
|
97
|
+
Object.defineProperty(_assertThisInitialized(_this), "onFieldChange", {
|
|
98
|
+
configurable: true,
|
|
99
|
+
enumerable: true,
|
|
100
|
+
writable: true,
|
|
101
|
+
value: function value(e) {
|
|
102
|
+
var _this$props = _this.props,
|
|
103
|
+
onValidateForm = _this$props.onValidateForm,
|
|
104
|
+
onDataChange = _this$props.onDataChange;
|
|
105
|
+
var data = _this.state.data;
|
|
106
|
+
var _e$target = e.target,
|
|
107
|
+
name = _e$target.name,
|
|
108
|
+
value = _e$target.value;
|
|
203
109
|
|
|
204
|
-
|
|
205
|
-
};
|
|
110
|
+
_lodash["default"].set(data, name, value);
|
|
206
111
|
|
|
207
|
-
|
|
208
|
-
|
|
112
|
+
_this.setState({
|
|
113
|
+
data: data
|
|
114
|
+
}); // TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
209
115
|
|
|
210
|
-
if (_lodash["default"].isEqual(data, originalData)) {
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
116
|
|
|
214
|
-
|
|
215
|
-
|
|
117
|
+
if (onValidateForm) onValidateForm(_this.checkIsValid(data, false));
|
|
118
|
+
if (onDataChange) onDataChange(data);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
Object.defineProperty(_assertThisInitialized(_this), "onValidate", {
|
|
122
|
+
configurable: true,
|
|
123
|
+
enumerable: true,
|
|
124
|
+
writable: true,
|
|
125
|
+
value: function value(fieldName, fieldValue, validators) {
|
|
126
|
+
if (validators) {
|
|
127
|
+
var fieldErrors = _this.state.fieldErrors;
|
|
128
|
+
|
|
129
|
+
var errors = _this.getValidatesErrorMessages(validators, fieldValue);
|
|
130
|
+
|
|
131
|
+
if (errors.length === 0) {
|
|
132
|
+
fieldErrors = _lodash["default"].omit(fieldErrors, fieldName);
|
|
133
|
+
} else {
|
|
134
|
+
fieldErrors = _extends({}, fieldErrors, _defineProperty({}, fieldName, errors));
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_this.setState({
|
|
138
|
+
fieldErrors: fieldErrors
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(_assertThisInitialized(_this), "onSubmit", {
|
|
144
|
+
configurable: true,
|
|
145
|
+
enumerable: true,
|
|
146
|
+
writable: true,
|
|
147
|
+
value: function value(event) {
|
|
148
|
+
if (event) event.preventDefault();
|
|
149
|
+
var data = _this.state.data;
|
|
150
|
+
if (_this.checkIsValid(data)) _this.props.onSubmit(data);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
Object.defineProperty(_assertThisInitialized(_this), "onReset", {
|
|
154
|
+
configurable: true,
|
|
155
|
+
enumerable: true,
|
|
156
|
+
writable: true,
|
|
157
|
+
value: function value() {
|
|
158
|
+
_this.setState({
|
|
159
|
+
data: JSON.parse(JSON.stringify(_this.state.originalData)),
|
|
160
|
+
fieldErrors: {}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(_assertThisInitialized(_this), "onRemoveFieldValidators", {
|
|
165
|
+
configurable: true,
|
|
166
|
+
enumerable: true,
|
|
167
|
+
writable: true,
|
|
168
|
+
value: function value(fieldName) {
|
|
169
|
+
_this.fieldsValidators = _lodash["default"].omit(_this.fieldsValidators, fieldName);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(_assertThisInitialized(_this), "getValidatesErrorMessages", {
|
|
173
|
+
configurable: true,
|
|
174
|
+
enumerable: true,
|
|
175
|
+
writable: true,
|
|
176
|
+
value: function value(validators, fieldValue) {
|
|
177
|
+
var validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
178
|
+
var errors = [];
|
|
179
|
+
validatorsArray.forEach(function (validator) {
|
|
180
|
+
var result = validator(fieldValue);
|
|
181
|
+
if (result) errors = [].concat(_toConsumableArray(errors), [result]);
|
|
182
|
+
});
|
|
183
|
+
return errors;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
Object.defineProperty(_assertThisInitialized(_this), "getContextValue", {
|
|
187
|
+
configurable: true,
|
|
188
|
+
enumerable: true,
|
|
189
|
+
writable: true,
|
|
190
|
+
value: function value() {
|
|
191
|
+
return {
|
|
192
|
+
handlerFieldChange: _this.onFieldChange,
|
|
193
|
+
handlerFieldValidade: _this.onValidate,
|
|
194
|
+
handlerStoreValidators: function handlerStoreValidators(fieldName, fieldValidates) {
|
|
195
|
+
_this.fieldsValidators = _extends({}, _this.fieldsValidators, _defineProperty({}, fieldName, fieldValidates));
|
|
196
|
+
},
|
|
197
|
+
handlerRemoveValidators: _this.onRemoveFieldValidators,
|
|
198
|
+
data: _this.state.data,
|
|
199
|
+
fieldErrors: _this.state.fieldErrors
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
Object.defineProperty(_assertThisInitialized(_this), "checkIsValid", {
|
|
204
|
+
configurable: true,
|
|
205
|
+
enumerable: true,
|
|
206
|
+
writable: true,
|
|
207
|
+
value: function value(data) {
|
|
208
|
+
var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
209
|
+
var dataValidate = data || _this.state.data;
|
|
210
|
+
var fieldErrors = {};
|
|
211
|
+
|
|
212
|
+
_lodash["default"].forEach(_this.fieldsValidators, function (validators, fieldName) {
|
|
213
|
+
var fieldValue = _lodash["default"].get(dataValidate, fieldName);
|
|
214
|
+
|
|
215
|
+
var messages = _this.getValidatesErrorMessages(validators, fieldValue);
|
|
216
|
+
|
|
217
|
+
if (messages.length > 0) {
|
|
218
|
+
fieldErrors = _extends({}, fieldErrors, _defineProperty({}, fieldName, messages));
|
|
219
|
+
}
|
|
220
|
+
});
|
|
216
221
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
event.preventDefault();
|
|
220
|
-
if (submitFormOnEnter) onFormSubmit();
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
var getContextValue = function getContextValue() {
|
|
225
|
-
return {
|
|
226
|
-
handlerFieldChange: onFieldChange,
|
|
227
|
-
handlerFieldValidade: onValidate,
|
|
228
|
-
handlerStoreValidators: function handlerStoreValidators(fieldName, fieldValidates) {
|
|
229
|
-
setFieldsValidators(function (prevState) {
|
|
230
|
-
return _extends({}, prevState, _defineProperty({}, fieldName, fieldValidates));
|
|
222
|
+
if (updateState) _this.setState({
|
|
223
|
+
fieldErrors: fieldErrors
|
|
231
224
|
});
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
225
|
+
return _lodash["default"].isEmpty(fieldErrors);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(_assertThisInitialized(_this), "submitOnEnter", {
|
|
229
|
+
configurable: true,
|
|
230
|
+
enumerable: true,
|
|
231
|
+
writable: true,
|
|
232
|
+
value: function value(event) {
|
|
233
|
+
if (event.key === 'Enter') {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
if (_this.state.submitFormOnEnter) _this.onSubmit();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
_this.fieldsValidators = {};
|
|
240
|
+
var dataSource = props.dataSource,
|
|
241
|
+
submitOnPressEnterKey = props.submitOnPressEnterKey;
|
|
242
|
+
_this.state = {
|
|
243
|
+
data: dataSource,
|
|
244
|
+
originalData: dataSource,
|
|
245
|
+
fieldErrors: {},
|
|
246
|
+
submitFormOnEnter: submitOnPressEnterKey
|
|
237
247
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
248
|
+
return _this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
_createClass(Form, [{
|
|
252
|
+
key: "componentDidMount",
|
|
253
|
+
value: function componentDidMount() {
|
|
254
|
+
var _this$props2 = this.props,
|
|
255
|
+
handlerReset = _this$props2.handlerReset,
|
|
256
|
+
handlerSubmit = _this$props2.handlerSubmit,
|
|
257
|
+
handlerValidates = _this$props2.handlerValidates;
|
|
258
|
+
handlerSubmit(this.onSubmit);
|
|
259
|
+
if (handlerReset) handlerReset(this.onReset);
|
|
260
|
+
if (handlerValidates) handlerValidates(this.checkIsValid);
|
|
261
|
+
} // up = data => _.debounce((data) => { this.props.onValidateForm(this.checkIsValid(data)); }, 300)
|
|
262
|
+
|
|
263
|
+
}, {
|
|
264
|
+
key: "render",
|
|
265
|
+
value: function render() {
|
|
266
|
+
var _this2 = this;
|
|
267
|
+
|
|
268
|
+
var _this$props3 = this.props,
|
|
269
|
+
style = _this$props3.style,
|
|
270
|
+
customClass = _this$props3.customClass,
|
|
271
|
+
children = _this$props3.children;
|
|
272
|
+
return /*#__PURE__*/_react["default"].createElement(_helpers.FormContext.Provider, {
|
|
273
|
+
value: this.getContextValue()
|
|
274
|
+
}, /*#__PURE__*/_react["default"].createElement("form", {
|
|
275
|
+
style: style,
|
|
276
|
+
onSubmit: function onSubmit(e) {
|
|
277
|
+
e.preventDefault();
|
|
278
|
+
},
|
|
279
|
+
onKeyPress: function onKeyPress(e) {
|
|
280
|
+
_this2.submitOnEnter(e);
|
|
281
|
+
},
|
|
282
|
+
role: "presentation",
|
|
283
|
+
className: "form-component ".concat(customClass)
|
|
284
|
+
}, children));
|
|
249
285
|
}
|
|
286
|
+
}], [{
|
|
287
|
+
key: "getDerivedStateFromProps",
|
|
288
|
+
value: function getDerivedStateFromProps(props, state) {
|
|
289
|
+
var submitOnPressEnterKey = props.submitOnPressEnterKey,
|
|
290
|
+
dataSource = props.dataSource;
|
|
291
|
+
|
|
292
|
+
if (submitOnPressEnterKey !== state.submitFormOnEnter || dataSource !== state.originalData) {
|
|
293
|
+
return {
|
|
294
|
+
submitFormOnEnter: submitOnPressEnterKey,
|
|
295
|
+
data: dataSource,
|
|
296
|
+
originalData: dataSource
|
|
297
|
+
};
|
|
298
|
+
}
|
|
250
299
|
|
|
251
|
-
|
|
252
|
-
return window.removeEventListener('beforeunload', onBeforeUnload);
|
|
253
|
-
};
|
|
254
|
-
}, [securityBeforeUnload, onBeforeUnload]);
|
|
255
|
-
(0, _react.useEffect)(function () {
|
|
256
|
-
if (submitOnPressEnterKey !== submitFormOnEnter || dataSource !== originalData) {
|
|
257
|
-
setData(dataSource);
|
|
258
|
-
setOriginalData(function (prevState) {
|
|
259
|
-
return prevState || dataSource;
|
|
260
|
-
});
|
|
261
|
-
setSubmitFormOnEnter(submitOnPressEnterKey);
|
|
300
|
+
return null;
|
|
262
301
|
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
style: style,
|
|
268
|
-
onSubmit: function onSubmit(e) {
|
|
269
|
-
return e.preventDefault();
|
|
270
|
-
},
|
|
271
|
-
onKeyPress: function onKeyPress(e) {
|
|
272
|
-
return submitOnEnter(e);
|
|
273
|
-
},
|
|
274
|
-
role: "presentation",
|
|
275
|
-
className: "form-component ".concat(customClass)
|
|
276
|
-
}, children)), /*#__PURE__*/_react["default"].createElement(_dialog.DialogQuestion, {
|
|
277
|
-
zIndex: "99999999",
|
|
278
|
-
title: securityTitle || 'Dados Alterados',
|
|
279
|
-
text: securityText || 'Você possui dados alterados, confirma o fechamento?',
|
|
280
|
-
visible: !!context && context.showQuestion,
|
|
281
|
-
onConfirmClick: context ? context.onConfirmClick : function () {},
|
|
282
|
-
onUnconfirmClick: context ? context.onUnconfirmClick : function () {}
|
|
283
|
-
}));
|
|
284
|
-
};
|
|
302
|
+
}]);
|
|
303
|
+
|
|
304
|
+
return Form;
|
|
305
|
+
}(_react.Component);
|
|
285
306
|
|
|
286
307
|
Form.propTypes = {
|
|
287
308
|
dataSource: _propTypes["default"].object.isRequired,
|
|
@@ -294,11 +315,7 @@ Form.propTypes = {
|
|
|
294
315
|
submitOnPressEnterKey: _propTypes["default"].bool,
|
|
295
316
|
style: _propTypes["default"].object,
|
|
296
317
|
customClass: _propTypes["default"].string,
|
|
297
|
-
onDataChange: _propTypes["default"].func
|
|
298
|
-
securityBeforeUnload: _propTypes["default"].bool,
|
|
299
|
-
securityTitle: _propTypes["default"].string,
|
|
300
|
-
securityText: _propTypes["default"].string,
|
|
301
|
-
externalFieldErrors: _propTypes["default"].object
|
|
318
|
+
onDataChange: _propTypes["default"].func
|
|
302
319
|
};
|
|
303
320
|
Form.defaultProps = {
|
|
304
321
|
onValidateForm: undefined,
|
|
@@ -307,11 +324,7 @@ Form.defaultProps = {
|
|
|
307
324
|
handlerReset: undefined,
|
|
308
325
|
handlerValidates: undefined,
|
|
309
326
|
customClass: '',
|
|
310
|
-
onDataChange: undefined
|
|
311
|
-
securityBeforeUnload: false,
|
|
312
|
-
securityTitle: null,
|
|
313
|
-
securityText: null,
|
|
314
|
-
externalFieldErrors: {}
|
|
327
|
+
onDataChange: undefined
|
|
315
328
|
};
|
|
316
329
|
var _default = Form;
|
|
317
330
|
exports["default"] = _default;
|
package/lib/form/withFieldHOC.js
CHANGED
|
@@ -151,7 +151,6 @@ function withFieldHOC(WrappedComponent) {
|
|
|
151
151
|
handlerFieldValidade = _ref.handlerFieldValidade,
|
|
152
152
|
data = _ref.data,
|
|
153
153
|
fieldErrors = _ref.fieldErrors,
|
|
154
|
-
externalFieldErrors = _ref.externalFieldErrors,
|
|
155
154
|
handlerStoreValidators = _ref.handlerStoreValidators,
|
|
156
155
|
handlerRemoveValidators = _ref.handlerRemoveValidators;
|
|
157
156
|
return /*#__PURE__*/_react["default"].createElement(FieldHOC, _extends({}, props, {
|
|
@@ -161,7 +160,6 @@ function withFieldHOC(WrappedComponent) {
|
|
|
161
160
|
handlerRemoveValidators: handlerRemoveValidators,
|
|
162
161
|
data: data,
|
|
163
162
|
fieldErrors: fieldErrors,
|
|
164
|
-
externalFieldErrors: externalFieldErrors,
|
|
165
163
|
forwardedRef: ref
|
|
166
164
|
}));
|
|
167
165
|
});
|
package/lib/icons/helper.js
CHANGED
|
@@ -538,22 +538,6 @@ function getIcons() {
|
|
|
538
538
|
minusCircle: {
|
|
539
539
|
viewbox: '0 0 16 16',
|
|
540
540
|
paths: ['M8 0c-4.418 0-8 3.582-8 8s3.582 8 8 8 8-3.582 8-8-3.582-8-8-8zM8 14c-3.314 0-6-2.686-6-6s2.686-6 6-6c3.314 0 6 2.686 6 6s-2.686 6-6 6zM4 7h8v2h-8z']
|
|
541
|
-
},
|
|
542
|
-
zoomIn: {
|
|
543
|
-
viewbox: '0 0 16 16',
|
|
544
|
-
paths: ['M6 3h-1v2h-2v1h2v2h1v-2h2v-1h-2zM9.962 8.716c0.653-0.905 1.038-2.015 1.038-3.216 0-3.038-2.462-5.5-5.5-5.5s-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5c1.201 0 2.312-0.385 3.216-1.038l5.284 6.038 2-2-6.038-5.284zM5.5 9.5c-2.209 0-4-1.791-4-4s1.791-4 4-4 4 1.791 4 4-1.791 4-4 4z']
|
|
545
|
-
},
|
|
546
|
-
zoomOut: {
|
|
547
|
-
viewbox: '0 0 16 16',
|
|
548
|
-
paths: ['M3 5h5v1h-5zM9.962 8.716c0.653-0.905 1.038-2.015 1.038-3.216 0-3.038-2.462-5.5-5.5-5.5s-5.5 2.462-5.5 5.5 2.462 5.5 5.5 5.5c1.201 0 2.312-0.385 3.216-1.038l5.284 6.038 2-2-6.038-5.284zM5.5 9.5c-2.209 0-4-1.791-4-4s1.791-4 4-4 4 1.791 4 4-1.791 4-4 4z']
|
|
549
|
-
},
|
|
550
|
-
flipVertical3: {
|
|
551
|
-
viewbox: '0 0 16 16',
|
|
552
|
-
paths: ['M10.854 1.854c0.143-0.143 0.186-0.358 0.108-0.545s-0.26-0.309-0.462-0.309h-10c-0.202 0-0.385 0.122-0.462 0.309-0.026 0.062-0.038 0.127-0.038 0.191 0 0.13 0.051 0.258 0.146 0.354l5 5c0.195 0.195 0.512 0.195 0.707 0l5-5z', 'M9 8.5c0-0.276 0.224-0.5 0.5-0.5h1c0.276 0 0.5 0.224 0.5 0.5s-0.224 0.5-0.5 0.5h-1c-0.276 0-0.5-0.224-0.5-0.5z', 'M6 8.5c0-0.276 0.224-0.5 0.5-0.5h1c0.276 0 0.5 0.224 0.5 0.5s-0.224 0.5-0.5 0.5h-1c-0.276 0-0.5-0.224-0.5-0.5z', 'M3 8.5c0-0.276 0.224-0.5 0.5-0.5h1c0.276 0 0.5 0.224 0.5 0.5s-0.224 0.5-0.5 0.5h-1c-0.276 0-0.5-0.224-0.5-0.5z', 'M0 8.5c0-0.276 0.224-0.5 0.5-0.5h1c0.276 0 0.5 0.224 0.5 0.5s-0.224 0.5-0.5 0.5h-1c-0.276 0-0.5-0.224-0.5-0.5z', 'M10.962 15.691c0.026-0.062 0.038-0.127 0.038-0.191 0-0.13-0.051-0.258-0.146-0.354l-5-5c-0.195-0.195-0.512-0.195-0.707 0l-5 5c-0.143 0.143-0.186 0.358-0.108 0.545s0.26 0.309 0.462 0.309h10c0.202 0 0.385-0.122 0.462-0.309zM2.009 14.875l3.491-3.491 3.491 3.491h-6.982z', 'M13 12.5c1.257-0.943 2-2.419 2-4 0-1.672-0.831-3.226-2.222-4.158-0.229-0.154-0.54-0.092-0.694 0.137s-0.092 0.54 0.137 0.694c1.113 0.745 1.778 1.989 1.778 3.327 0 1.313-0.64 2.534-1.716 3.284l-1.284-1.284v3.5h3.5l-1.5-1.5z']
|
|
553
|
-
},
|
|
554
|
-
flipVertical4: {
|
|
555
|
-
viewbox: '0 0 16 16',
|
|
556
|
-
paths: ['M0.854 5.146c-0.143-0.143-0.358-0.186-0.545-0.108s-0.309 0.26-0.309 0.462v10c0 0.202 0.122 0.385 0.309 0.462 0.062 0.026 0.127 0.038 0.191 0.038 0.13 0 0.258-0.051 0.354-0.146l5-5c0.195-0.195 0.195-0.512 0-0.707l-5-5z', 'M7.5 7c-0.276 0-0.5-0.224-0.5-0.5v-1c0-0.276 0.224-0.5 0.5-0.5s0.5 0.224 0.5 0.5v1c0 0.276-0.224 0.5-0.5 0.5z', 'M7.5 10c-0.276 0-0.5-0.224-0.5-0.5v-1c0-0.276 0.224-0.5 0.5-0.5s0.5 0.224 0.5 0.5v1c0 0.276-0.224 0.5-0.5 0.5z', 'M7.5 13c-0.276 0-0.5-0.224-0.5-0.5v-1c0-0.276 0.224-0.5 0.5-0.5s0.5 0.224 0.5 0.5v1c0 0.276-0.224 0.5-0.5 0.5z', 'M7.5 16c-0.276 0-0.5-0.224-0.5-0.5v-1c0-0.276 0.224-0.5 0.5-0.5s0.5 0.224 0.5 0.5v1c0 0.276-0.224 0.5-0.5 0.5z', 'M14.691 5.038c-0.062-0.026-0.127-0.038-0.191-0.038-0.13 0-0.258 0.051-0.354 0.146l-5 5c-0.195 0.195-0.195 0.512 0 0.707l5 5c0.143 0.143 0.358 0.186 0.545 0.108s0.309-0.26 0.309-0.462v-10c0-0.202-0.122-0.385-0.309-0.462zM13.875 13.991l-3.491-3.491 3.491-3.491v6.982z', 'M11.5 3c-0.943-1.257-2.419-2-4-2-1.672 0-3.226 0.831-4.158 2.222-0.154 0.229-0.092 0.54 0.137 0.694s0.54 0.092 0.694-0.137c0.745-1.113 1.989-1.778 3.327-1.778 1.313 0 2.534 0.64 3.284 1.716l-1.284 1.284h3.5v-3.5l-1.5 1.5z']
|
|
557
541
|
}
|
|
558
542
|
};
|
|
559
543
|
return icons;
|
|
@@ -9,12 +9,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
11
11
|
|
|
12
|
-
var _uuid = _interopRequireDefault(require("uuid"));
|
|
13
|
-
|
|
14
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
13
|
|
|
16
|
-
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); }
|
|
17
|
-
|
|
18
14
|
var getInputClass = function getInputClass(_ref) {
|
|
19
15
|
var textAlign = _ref.textAlign,
|
|
20
16
|
readOnly = _ref.readOnly;
|
|
@@ -45,21 +41,20 @@ exports.getErrorMessages = getErrorMessages;
|
|
|
45
41
|
|
|
46
42
|
var getRightElements = function getRightElements(rightElements, errorMessages) {
|
|
47
43
|
var elements = rightElements || [];
|
|
48
|
-
var newElements = _lodash["default"].isArray(elements) ? elements : [elements];
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
key: "rightelement-".concat(_uuid["default"].v1())
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
};
|
|
45
|
+
if (!_lodash["default"].isArray(elements)) {
|
|
46
|
+
elements = [elements];
|
|
47
|
+
}
|
|
57
48
|
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
elements = elements.map(function (element, index) {
|
|
50
|
+
return element && /*#__PURE__*/_react["default"].cloneElement(element, {
|
|
51
|
+
key: "rightelement-".concat(index + 1)
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
if (errorMessages.length === 0) return elements;
|
|
60
55
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
61
56
|
className: "sidebuttons"
|
|
62
|
-
},
|
|
57
|
+
}, elements);
|
|
63
58
|
};
|
|
64
59
|
|
|
65
60
|
exports.getRightElements = getRightElements;
|
|
@@ -13,7 +13,7 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
13
13
|
|
|
14
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _helper = _interopRequireDefault(require("./helper"));
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
|
|
@@ -52,7 +52,7 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
52
52
|
_this = _super.call(this, props);
|
|
53
53
|
_this.el = document.createElement('div');
|
|
54
54
|
_this.el.className = 'datepicker-component';
|
|
55
|
-
_this.el.style = (0,
|
|
55
|
+
_this.el.style = (0, _helper["default"])(props);
|
|
56
56
|
return _this;
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -65,7 +65,7 @@ var Dropdown = /*#__PURE__*/function (_Component) {
|
|
|
65
65
|
}, {
|
|
66
66
|
key: "componentDidUpdate",
|
|
67
67
|
value: function componentDidUpdate() {
|
|
68
|
-
this.el.style = (0,
|
|
68
|
+
this.el.style = (0, _helper["default"])(this.props);
|
|
69
69
|
}
|
|
70
70
|
}, {
|
|
71
71
|
key: "componentWillUnmount",
|