linear-react-components-ui 1.0.14 → 1.1.0-beta.0
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.json +45 -77
- package/.gitlab-ci.yml +2 -2
- package/.vscode/settings.json +3 -3
- package/babel.config.json +2 -2
- package/lib/@types/Align.d.ts +1 -1
- package/lib/@types/ButtonTypes.d.ts +1 -1
- package/lib/@types/ColorStyles.d.ts +1 -1
- package/lib/@types/DataCombo.d.ts +1 -1
- package/lib/@types/Icon.d.ts +1 -1
- package/lib/@types/LabelStyles.d.ts +1 -1
- package/lib/@types/Period.d.ts +1 -1
- package/lib/@types/PermissionAttr.d.ts +1 -1
- package/lib/@types/PointerEvents.d.ts +1 -1
- package/lib/@types/Position.d.ts +1 -1
- package/lib/@types/PositionAlert.d.ts +1 -1
- package/lib/@types/Size.d.ts +1 -1
- package/lib/@types/SizePixels.d.ts +1 -1
- package/lib/@types/StorageMock.d.ts +1 -1
- package/lib/alerts/AlertContainer.js +7 -8
- package/lib/alerts/AlertProvider.js +17 -18
- package/lib/alerts/BaseAlert.js +5 -6
- package/lib/alerts/Message.js +12 -13
- package/lib/alerts/helpers.js +2 -3
- package/lib/alerts/index.js +4 -5
- package/lib/alerts/types.d.ts +1 -1
- package/lib/alerts/withAlert.js +8 -9
- package/lib/assets/styles/tabs.scss +1 -1
- package/lib/avatar/index.js +13 -14
- package/lib/avatar/types.d.ts +1 -1
- package/lib/badge/index.js +5 -6
- package/lib/badge/types.d.ts +1 -1
- package/lib/buttons/ActivateButton.js +4 -5
- package/lib/buttons/AddButton.js +5 -6
- package/lib/buttons/Button.js +7 -8
- package/lib/buttons/ButtonGroups.js +4 -5
- package/lib/buttons/CancelButton.js +4 -5
- package/lib/buttons/DangerButton.js +4 -5
- package/lib/buttons/DefaultButton.js +18 -19
- package/lib/buttons/DestroyButton.js +5 -6
- package/lib/buttons/EditButton.js +4 -5
- package/lib/buttons/InactivateButton.js +4 -5
- package/lib/buttons/InfoButton.js +4 -5
- package/lib/buttons/PrimaryButton.js +4 -5
- package/lib/buttons/RestoreButton.js +4 -5
- package/lib/buttons/SaveButton.js +4 -5
- package/lib/buttons/SuccessButton.js +4 -5
- package/lib/buttons/WarningButton.js +4 -5
- package/lib/buttons/button_container/index.js +10 -11
- package/lib/buttons/index.js +17 -18
- package/lib/buttons/split_button/index.js +5 -6
- package/lib/buttons/types.d.ts +1 -1
- package/lib/calendar/DangerCalendar.js +4 -5
- package/lib/calendar/InfoCalendar.js +4 -5
- package/lib/calendar/PrimaryCalendar.js +4 -5
- package/lib/calendar/SuccessCalendar.js +4 -5
- package/lib/calendar/WarningCalendar.js +4 -5
- package/lib/calendar/base/Day.js +8 -9
- package/lib/calendar/base/Month.js +5 -6
- package/lib/calendar/base/Week.js +5 -6
- package/lib/calendar/base/helpers.js +7 -9
- package/lib/calendar/base/index.js +17 -18
- package/lib/calendar/index.js +8 -9
- package/lib/calendar/types.d.ts +1 -1
- package/lib/checkbox/Label.js +4 -5
- package/lib/checkbox/index.js +13 -14
- package/lib/checkbox/types.d.ts +1 -1
- package/lib/dialog/Alert.js +6 -7
- package/lib/dialog/Custom.js +12 -13
- package/lib/dialog/Error.js +6 -7
- package/lib/dialog/Information.js +6 -7
- package/lib/dialog/Question.js +10 -11
- package/lib/dialog/Warning.js +8 -8
- package/lib/dialog/base/Content.js +4 -5
- package/lib/dialog/base/Footer.js +4 -5
- package/lib/dialog/base/Header.js +12 -13
- package/lib/dialog/base/index.js +10 -11
- package/lib/dialog/base/style.js +2 -3
- package/lib/dialog/form/index.js +23 -25
- package/lib/dialog/index.js +9 -10
- package/lib/dialog/types.d.ts +1 -1
- package/lib/drawer/Content.js +8 -9
- package/lib/drawer/Drawer.js +19 -20
- package/lib/drawer/Header.js +19 -20
- package/lib/drawer/helpers.js +4 -5
- package/lib/drawer/index.js +5 -6
- package/lib/drawer/types.d.ts +1 -1
- package/lib/dropdown/Popup.js +4 -5
- package/lib/dropdown/helper.js +3 -5
- package/lib/dropdown/types.d.ts +1 -1
- package/lib/dropdown/withDropdown.js +13 -15
- package/lib/fieldset/index.js +15 -16
- package/lib/fieldset/types.d.ts +1 -1
- package/lib/form/Field.d.ts +1 -1
- package/lib/form/Field.js +20 -20
- package/lib/form/FieldArray.js +20 -21
- package/lib/form/FieldNumber.js +15 -16
- package/lib/form/FieldPeriod.js +21 -22
- package/lib/form/helpers.js +12 -18
- package/lib/form/index.js +28 -29
- package/lib/form/types.d.ts +1 -1
- package/lib/form/withFieldHOC.js +11 -12
- package/lib/form/withFormSecurity.js +9 -11
- package/lib/gridlayout/GridCol.js +4 -5
- package/lib/gridlayout/GridRow.js +4 -5
- package/lib/gridlayout/index.js +4 -5
- package/lib/gridlayout/types.d.ts +1 -1
- package/lib/hint/index.js +8 -9
- package/lib/hint/types.d.ts +1 -1
- package/lib/icons/helper.js +3 -4
- package/lib/icons/index.js +10 -11
- package/lib/icons/types.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +10 -10
- package/lib/inputs/base/InputTextBase.js +21 -22
- package/lib/inputs/base/helpers.js +10 -14
- package/lib/inputs/base/types.d.ts +1 -1
- package/lib/inputs/color/index.js +13 -14
- package/lib/inputs/color/types.d.ts +1 -1
- package/lib/inputs/date/Dialog.js +4 -5
- package/lib/inputs/date/Dropdown.js +4 -5
- package/lib/inputs/date/helpers.js +9 -13
- package/lib/inputs/date/index.js +20 -21
- package/lib/inputs/date/types.d.ts +1 -1
- package/lib/inputs/file/DefaultFile.js +19 -20
- package/lib/inputs/file/DragDropFile.js +42 -43
- package/lib/inputs/file/File.js +9 -10
- package/lib/inputs/file/FileButtonSettings.js +6 -7
- package/lib/inputs/file/helpers.js +2 -3
- package/lib/inputs/file/index.js +5 -6
- package/lib/inputs/file/types.d.ts +1 -1
- package/lib/inputs/inputHOC.js +10 -11
- package/lib/inputs/mask/BaseMask.js +9 -10
- package/lib/inputs/mask/Cnpj.js +9 -10
- package/lib/inputs/mask/Cpf.js +9 -10
- package/lib/inputs/mask/Phone.js +4 -5
- package/lib/inputs/mask/ZipCode.js +4 -5
- package/lib/inputs/mask/helpers.js +7 -7
- package/lib/inputs/mask/imaskHOC.js +9 -10
- package/lib/inputs/mask/index.js +7 -8
- package/lib/inputs/mask/types.d.ts +1 -1
- package/lib/inputs/multiSelect/ActionButtons.js +10 -11
- package/lib/inputs/multiSelect/Dropdown.js +26 -27
- package/lib/inputs/multiSelect/helper.js +2 -3
- package/lib/inputs/multiSelect/index.js +21 -22
- package/lib/inputs/multiSelect/types.d.ts +1 -1
- package/lib/inputs/number/BaseNumber.js +9 -10
- package/lib/inputs/number/Currency.js +5 -6
- package/lib/inputs/number/Decimal.js +4 -5
- package/lib/inputs/number/format_number.js +4 -7
- package/lib/inputs/number/index.js +6 -7
- package/lib/inputs/number/types.d.ts +1 -1
- package/lib/inputs/period/Dialog.js +4 -5
- package/lib/inputs/period/Dropdown.js +6 -7
- package/lib/inputs/period/PeriodList.js +7 -8
- package/lib/inputs/period/helper.js +10 -14
- package/lib/inputs/period/index.js +48 -49
- package/lib/inputs/period/types.d.ts +1 -1
- package/lib/inputs/search/index.js +19 -20
- package/lib/inputs/select/ActionButtons.js +7 -8
- package/lib/inputs/select/Dropdown.js +22 -23
- package/lib/inputs/select/helper.js +6 -11
- package/lib/inputs/select/index.js +6 -7
- package/lib/inputs/select/multiple/Selecteds.js +6 -7
- package/lib/inputs/select/multiple/index.js +15 -16
- package/lib/inputs/select/simple/index.js +15 -16
- package/lib/inputs/select/types.d.ts +1 -1
- package/lib/inputs/text/index.js +4 -5
- package/lib/inputs/text/types.d.ts +1 -1
- package/lib/inputs/textarea/index.js +5 -6
- package/lib/inputs/textarea/types.d.ts +1 -1
- package/lib/inputs/types.d.ts +1 -1
- package/lib/internals/colorStyles.js +2 -3
- package/lib/internals/constants.js +2 -4
- package/lib/internals/types.d.ts +1 -1
- package/lib/internals/withTooltip.js +10 -11
- package/lib/labelMessages/index.js +12 -13
- package/lib/labelMessages/types.d.ts +1 -1
- package/lib/labels/DangerLabel.js +4 -5
- package/lib/labels/DefaultLabel.js +9 -10
- package/lib/labels/InfoLabel.js +4 -5
- package/lib/labels/PrimaryLabel.js +4 -5
- package/lib/labels/SuccessLabel.js +4 -5
- package/lib/labels/WarningLabel.js +4 -5
- package/lib/labels/index.js +9 -10
- package/lib/labels/label_container/index.js +5 -6
- package/lib/labels/types.d.ts +1 -1
- package/lib/list/Header.js +5 -6
- package/lib/list/Item.js +18 -19
- package/lib/list/Separator.js +4 -5
- package/lib/list/helpers.js +4 -6
- package/lib/list/index.js +17 -18
- package/lib/list/types.d.ts +1 -1
- package/lib/menus/float/MenuItem.js +14 -15
- package/lib/menus/float/SubMenuContainer.js +18 -19
- package/lib/menus/float/helpers.js +4 -5
- package/lib/menus/float/index.d.ts +10 -10
- package/lib/menus/float/index.js +10 -11
- package/lib/menus/float/types.d.ts +1 -1
- package/lib/menus/index.js +3 -4
- package/lib/menus/sidenav/ExpandMenu.js +5 -6
- package/lib/menus/sidenav/MenuLink.js +5 -6
- package/lib/menus/sidenav/NavMenuGroup.js +7 -8
- package/lib/menus/sidenav/NavMenuItem.js +15 -16
- package/lib/menus/sidenav/NavSubMenuItem.js +10 -11
- package/lib/menus/sidenav/helpers.js +5 -8
- package/lib/menus/sidenav/index.js +22 -23
- package/lib/menus/sidenav/popup_menu_search/EmptyList.js +7 -8
- package/lib/menus/sidenav/popup_menu_search/index.js +15 -16
- package/lib/menus/sidenav/types.d.ts +1 -1
- package/lib/noPermission/index.js +7 -8
- package/lib/panel/Content.d.ts +1 -1
- package/lib/panel/Content.js +8 -9
- package/lib/panel/DangerPanel.d.ts +1 -1
- package/lib/panel/DangerPanel.js +5 -6
- package/lib/panel/Default.d.ts +1 -1
- package/lib/panel/Default.js +11 -12
- package/lib/panel/Header.d.ts +1 -1
- package/lib/panel/Header.js +14 -15
- package/lib/panel/InfoPanel.d.ts +1 -1
- package/lib/panel/InfoPanel.js +5 -6
- package/lib/panel/PrimaryPanel.d.ts +1 -1
- package/lib/panel/PrimaryPanel.js +5 -6
- package/lib/panel/SuccessPanel.d.ts +1 -1
- package/lib/panel/SuccessPanel.js +5 -6
- package/lib/panel/ToolBar.d.ts +1 -1
- package/lib/panel/ToolBar.js +4 -5
- package/lib/panel/WarningPanel.d.ts +1 -1
- package/lib/panel/WarningPanel.js +5 -6
- package/lib/panel/helpers.d.ts +1 -1
- package/lib/panel/helpers.js +4 -5
- package/lib/panel/index.d.ts +1 -1
- package/lib/panel/index.js +10 -11
- package/lib/panel/types.d.ts +1 -1
- package/lib/permissionValidations.js +4 -7
- package/lib/popover/PopoverText.js +4 -5
- package/lib/popover/PopoverTitle.js +4 -5
- package/lib/popover/index.js +8 -9
- package/lib/popover/types.d.ts +1 -1
- package/lib/progress/Bar.js +5 -6
- package/lib/progress/index.js +11 -12
- package/lib/progress/types.d.ts +1 -1
- package/lib/radio/index.js +14 -15
- package/lib/radio/types.d.ts +1 -1
- package/lib/shortcuts/index.js +5 -6
- package/lib/shortcuts/types.d.ts +1 -1
- package/lib/skeleton/SkeletonContainer.js +4 -5
- package/lib/skeleton/index.js +11 -12
- package/lib/skeleton/types.d.ts +1 -1
- package/lib/spinner/SpinnerLoading.js +41 -42
- package/lib/spinner/index.js +10 -11
- package/lib/spinner/types.d.ts +1 -1
- package/lib/split/Split.js +15 -16
- package/lib/split/SplitSide.js +8 -9
- package/lib/split/helpers.d.ts +1 -1
- package/lib/split/helpers.js +4 -5
- package/lib/split/index.js +4 -5
- package/lib/split/types.d.ts +1 -1
- package/lib/table/Body.js +14 -15
- package/lib/table/Header.js +16 -17
- package/lib/table/HeaderColumn.js +9 -10
- package/lib/table/Row.js +15 -16
- package/lib/table/RowColumn.js +13 -14
- package/lib/table/helpers.js +6 -9
- package/lib/table/index.js +16 -17
- package/lib/table/types.d.ts +1 -1
- package/lib/tabs/DropdownItems.js +12 -13
- package/lib/tabs/Menu.js +5 -6
- package/lib/tabs/MenuItems.js +10 -11
- package/lib/tabs/Panel.d.ts +1 -1
- package/lib/tabs/Panel.js +22 -22
- package/lib/tabs/index.js +15 -15
- package/lib/tabs/tabHelpers.d.ts +2 -3
- package/lib/tabs/tabHelpers.js +27 -17
- package/lib/tabs/types.d.ts +2 -1
- package/lib/toolbar/ButtonBar.js +25 -26
- package/lib/toolbar/LabelBar.js +17 -18
- package/lib/toolbar/Separator.js +4 -5
- package/lib/toolbar/ToolBarGroup.js +4 -5
- package/lib/toolbar/helpers.js +2 -3
- package/lib/toolbar/index.js +14 -15
- package/lib/toolbar/types.d.ts +1 -1
- package/lib/tooltip/index.js +9 -10
- package/lib/tooltip/types.d.ts +1 -1
- package/lib/treetable/Body.js +9 -10
- package/lib/treetable/Header.js +7 -8
- package/lib/treetable/Row.d.ts +1 -1
- package/lib/treetable/Row.js +41 -42
- package/lib/treetable/helpers.d.ts +1 -1
- package/lib/treetable/helpers.js +4 -7
- package/lib/treetable/index.d.ts +2 -2
- package/lib/treetable/index.js +11 -12
- package/lib/treeview/Header.js +5 -6
- package/lib/treeview/Node.js +33 -34
- package/lib/treeview/constants.js +2 -3
- package/lib/treeview/index.js +22 -23
- package/lib/treeview/types.d.ts +1 -1
- package/lib/{types-fe4a1068.d.ts → types-PItfhaS-.d.ts} +1 -1
- package/lib/{types.d-73cece43.d.ts → types.d-BfM3lUbt.d.ts} +1 -1
- package/lib/uitour/helpers.js +4 -7
- package/lib/uitour/index.js +22 -23
- package/lib/uitour/types.d.ts +1 -1
- package/package.json +75 -76
package/lib/form/FieldNumber.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
10
|
var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
|
|
11
11
|
var _helpers = require("./helpers");
|
|
12
12
|
var constants = _interopRequireWildcard(require("../internals/constants"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _getRequireWildcardCache(
|
|
15
|
-
function _interopRequireWildcard(
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
16
16
|
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); }
|
|
17
|
-
function ownKeys(
|
|
18
|
-
function _objectSpread(
|
|
17
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
19
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
|
-
function _toPropertyKey(
|
|
21
|
-
function _toPrimitive(
|
|
20
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
22
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
23
|
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."); }
|
|
24
24
|
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); }
|
|
25
25
|
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; }
|
|
26
|
-
function _iterableToArrayLimit(
|
|
26
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
27
27
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
28
|
var getEventProps = function getEventProps(_ref) {
|
|
29
29
|
var name = _ref.name,
|
|
@@ -58,20 +58,20 @@ var FieldMask = function FieldMask(props) {
|
|
|
58
58
|
var data = props.data,
|
|
59
59
|
name = props.name,
|
|
60
60
|
originalData = props.originalData;
|
|
61
|
-
var currentValue = _lodash
|
|
61
|
+
var currentValue = _lodash["default"].get(data, name);
|
|
62
62
|
var _useState = (0, _react.useState)(false),
|
|
63
63
|
_useState2 = _slicedToArray(_useState, 2),
|
|
64
64
|
showValidateMessages = _useState2[0],
|
|
65
65
|
setShowValidateMessages = _useState2[1];
|
|
66
|
-
var originalValue = _lodash
|
|
66
|
+
var originalValue = _lodash["default"].get(originalData, name);
|
|
67
67
|
(0, _react.useEffect)(function () {
|
|
68
68
|
if (currentValue && currentValue !== originalValue && !!currentValue) {
|
|
69
69
|
setShowValidateMessages(true);
|
|
70
|
-
} else if (_lodash
|
|
70
|
+
} else if (_lodash["default"].isEmpty(data) || _lodash["default"].every(data, _lodash["default"].isEmpty) || currentValue === originalValue) {
|
|
71
71
|
setShowValidateMessages(false);
|
|
72
72
|
}
|
|
73
73
|
}, [currentValue, originalValue]);
|
|
74
|
-
return /*#__PURE__*/_react
|
|
74
|
+
return /*#__PURE__*/_react["default"].createElement(props.component, _extends({}, props, getEventProps(_objectSpread(_objectSpread({}, props), {}, {
|
|
75
75
|
handleShowValidateMessages: function handleShowValidateMessages(value) {
|
|
76
76
|
return setShowValidateMessages(value);
|
|
77
77
|
}
|
|
@@ -82,5 +82,4 @@ var FieldMask = function FieldMask(props) {
|
|
|
82
82
|
value: currentValue
|
|
83
83
|
}));
|
|
84
84
|
};
|
|
85
|
-
var _default = (0, _withFieldHOC
|
|
86
|
-
exports.default = _default;
|
|
85
|
+
var _default = exports["default"] = (0, _withFieldHOC["default"])(FieldMask);
|
package/lib/form/FieldPeriod.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
10
|
var _gridlayout = _interopRequireDefault(require("../gridlayout"));
|
|
11
11
|
var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
|
|
12
12
|
var _helpers = require("./helpers");
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _getRequireWildcardCache(
|
|
15
|
-
function _interopRequireWildcard(
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
16
16
|
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); }
|
|
17
17
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
-
function _toPropertyKey(
|
|
19
|
-
function _toPrimitive(
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
20
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
21
21
|
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."); }
|
|
22
22
|
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); }
|
|
23
23
|
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; }
|
|
24
|
-
function _iterableToArrayLimit(
|
|
24
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
25
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
26
|
var FieldPeriod = function FieldPeriod(props) {
|
|
27
27
|
var data = props.data,
|
|
@@ -43,12 +43,12 @@ var FieldPeriod = function FieldPeriod(props) {
|
|
|
43
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
44
|
showValidateMessages = _useState2[0],
|
|
45
45
|
setShowValidateMessages = _useState2[1];
|
|
46
|
-
var currentValue = _lodash
|
|
47
|
-
var originalValue = _lodash
|
|
46
|
+
var currentValue = _lodash["default"].get(data, name);
|
|
47
|
+
var originalValue = _lodash["default"].get(originalData, name);
|
|
48
48
|
(0, _react.useEffect)(function () {
|
|
49
|
-
if (!_lodash
|
|
49
|
+
if (!_lodash["default"].isEqual(currentValue, originalValue) && currentValue && (!!currentValue || currentValue === 0 || Array.isArray(currentValue) && currentValue.length > 0)) {
|
|
50
50
|
setShowValidateMessages(true);
|
|
51
|
-
} else if (_lodash
|
|
51
|
+
} else if (_lodash["default"].isEmpty(data) || _lodash["default"].every(data, _lodash["default"].isEmpty) || _lodash["default"].isEqual(currentValue, originalValue)) {
|
|
52
52
|
setShowValidateMessages(false);
|
|
53
53
|
}
|
|
54
54
|
}, [currentValue]);
|
|
@@ -59,14 +59,14 @@ var FieldPeriod = function FieldPeriod(props) {
|
|
|
59
59
|
externalMessagesErrors: externalMessagesErrors
|
|
60
60
|
});
|
|
61
61
|
if (Component) {
|
|
62
|
-
content = /*#__PURE__*/_react
|
|
62
|
+
content = /*#__PURE__*/_react["default"].createElement(Component, _extends({}, props, {
|
|
63
63
|
errorMessages: errorMessages,
|
|
64
64
|
onChange: function onChange(e, maskValue, _ref) {
|
|
65
65
|
var initial = _ref.initial,
|
|
66
|
-
|
|
66
|
+
_final = _ref["final"];
|
|
67
67
|
if (validators && handlerFieldValidade) {
|
|
68
68
|
var _handlerFieldValidade;
|
|
69
|
-
handlerFieldValidade(nameDateInitial, (_handlerFieldValidade = {}, _defineProperty(_handlerFieldValidade, nameDateInitial, initial), _defineProperty(_handlerFieldValidade, nameDateFinal,
|
|
69
|
+
handlerFieldValidade(nameDateInitial, (_handlerFieldValidade = {}, _defineProperty(_handlerFieldValidade, nameDateInitial, initial), _defineProperty(_handlerFieldValidade, nameDateFinal, _final), _handlerFieldValidade), validators);
|
|
70
70
|
setShowValidateMessages(true);
|
|
71
71
|
}
|
|
72
72
|
if (handlerFieldChange) {
|
|
@@ -74,23 +74,23 @@ var FieldPeriod = function FieldPeriod(props) {
|
|
|
74
74
|
handlerFieldChange({
|
|
75
75
|
target: {
|
|
76
76
|
name: name,
|
|
77
|
-
value: (_value = {}, _defineProperty(_value, nameDateInitial, initial), _defineProperty(_value, nameDateFinal,
|
|
77
|
+
value: (_value = {}, _defineProperty(_value, nameDateInitial, initial), _defineProperty(_value, nameDateFinal, _final), _value)
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
if (_onChange) _onChange({
|
|
82
82
|
initial: initial,
|
|
83
|
-
final:
|
|
83
|
+
"final": _final
|
|
84
84
|
});
|
|
85
85
|
},
|
|
86
86
|
value: {
|
|
87
|
-
initial: _lodash
|
|
88
|
-
final: _lodash
|
|
87
|
+
initial: _lodash["default"].get(data, "".concat(name, ".").concat(nameDateInitial)),
|
|
88
|
+
"final": _lodash["default"].get(data, "".concat(name, ".").concat(nameDateFinal))
|
|
89
89
|
}
|
|
90
90
|
}));
|
|
91
91
|
}
|
|
92
92
|
if (gridLayout !== undefined) {
|
|
93
|
-
return /*#__PURE__*/_react
|
|
93
|
+
return /*#__PURE__*/_react["default"].createElement(_gridlayout["default"], {
|
|
94
94
|
customClass: "-withinput",
|
|
95
95
|
cols: gridLayout,
|
|
96
96
|
style: {
|
|
@@ -100,5 +100,4 @@ var FieldPeriod = function FieldPeriod(props) {
|
|
|
100
100
|
}
|
|
101
101
|
return content;
|
|
102
102
|
};
|
|
103
|
-
var _default = (0, _withFieldHOC
|
|
104
|
-
exports.default = _default;
|
|
103
|
+
var _default = exports["default"] = (0, _withFieldHOC["default"])(FieldPeriod);
|
package/lib/form/helpers.js
CHANGED
|
@@ -6,26 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.withFieldContext = exports.securityBeforeUnload = exports.getValidatorsArray = exports.getErrorMessages = exports.changeValue = exports.FormContext = void 0;
|
|
7
7
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
10
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
11
|
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."); }
|
|
12
12
|
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); }
|
|
13
13
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
14
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
15
15
|
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; }
|
|
16
|
-
var securityBeforeUnload = 'securityBeforeUnload';
|
|
17
|
-
exports.
|
|
18
|
-
var
|
|
19
|
-
exports.
|
|
20
|
-
var withFieldContext = /*#__PURE__*/_react.default.createContext({});
|
|
21
|
-
exports.withFieldContext = withFieldContext;
|
|
22
|
-
var changeValue = function changeValue(data, target) {
|
|
16
|
+
var securityBeforeUnload = exports.securityBeforeUnload = 'securityBeforeUnload';
|
|
17
|
+
var FormContext = exports.FormContext = /*#__PURE__*/_react["default"].createContext({});
|
|
18
|
+
var withFieldContext = exports.withFieldContext = /*#__PURE__*/_react["default"].createContext({});
|
|
19
|
+
var changeValue = exports.changeValue = function changeValue(data, target) {
|
|
23
20
|
var name = target.name,
|
|
24
21
|
value = target.value;
|
|
25
|
-
return _lodash
|
|
22
|
+
return _lodash["default"].set(JSON.parse(JSON.stringify(data)), name, value);
|
|
26
23
|
};
|
|
27
|
-
exports.
|
|
28
|
-
var getErrorMessages = function getErrorMessages(_ref) {
|
|
24
|
+
var getErrorMessages = exports.getErrorMessages = function getErrorMessages(_ref) {
|
|
29
25
|
var name = _ref.name,
|
|
30
26
|
fieldErrors = _ref.fieldErrors,
|
|
31
27
|
externalFieldErrors = _ref.externalFieldErrors,
|
|
@@ -39,17 +35,15 @@ var getErrorMessages = function getErrorMessages(_ref) {
|
|
|
39
35
|
}
|
|
40
36
|
return errors;
|
|
41
37
|
};
|
|
42
|
-
exports.
|
|
43
|
-
var getValidatorsArray = function getValidatorsArray(validators, validatorFromComponent) {
|
|
38
|
+
var getValidatorsArray = exports.getValidatorsArray = function getValidatorsArray(validators, validatorFromComponent) {
|
|
44
39
|
var validatorsArray = [];
|
|
45
40
|
if (validators && validatorFromComponent) {
|
|
46
|
-
validatorsArray = !_lodash
|
|
47
|
-
validatorsArray = !_lodash
|
|
41
|
+
validatorsArray = !_lodash["default"].isArray(validators) ? [validators] : validators;
|
|
42
|
+
validatorsArray = !_lodash["default"].isArray(validatorFromComponent) ? [].concat(_toConsumableArray(validatorsArray), [validatorFromComponent]) : [].concat(_toConsumableArray(validatorsArray), _toConsumableArray(validatorFromComponent));
|
|
48
43
|
} else if (validatorFromComponent) {
|
|
49
|
-
validatorsArray = !_lodash
|
|
44
|
+
validatorsArray = !_lodash["default"].isArray(validatorFromComponent) ? [validatorFromComponent] : validatorFromComponent;
|
|
50
45
|
} else if (validators) {
|
|
51
46
|
validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
52
47
|
}
|
|
53
48
|
return validatorsArray;
|
|
54
|
-
};
|
|
55
|
-
exports.getValidatorsArray = getValidatorsArray;
|
|
49
|
+
};
|
package/lib/form/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
Object.defineProperty(exports, "Field", {
|
|
8
8
|
enumerable: true,
|
|
9
9
|
get: function get() {
|
|
10
|
-
return _Field
|
|
10
|
+
return _Field["default"];
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "FieldArray", {
|
|
14
14
|
enumerable: true,
|
|
15
15
|
get: function get() {
|
|
16
|
-
return _FieldArray
|
|
16
|
+
return _FieldArray["default"];
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "FieldNumber", {
|
|
20
20
|
enumerable: true,
|
|
21
21
|
get: function get() {
|
|
22
|
-
return _FieldNumber
|
|
22
|
+
return _FieldNumber["default"];
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "FieldPeriod", {
|
|
26
26
|
enumerable: true,
|
|
27
27
|
get: function get() {
|
|
28
|
-
return _FieldPeriod
|
|
28
|
+
return _FieldPeriod["default"];
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
exports
|
|
31
|
+
exports["default"] = void 0;
|
|
32
32
|
var _react = _interopRequireWildcard(require("react"));
|
|
33
33
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
34
34
|
var _helpers = require("./helpers");
|
|
@@ -39,15 +39,15 @@ var _FieldPeriod = _interopRequireDefault(require("./FieldPeriod"));
|
|
|
39
39
|
require("../assets/styles/form.scss");
|
|
40
40
|
var _dialog = require("../dialog");
|
|
41
41
|
var _withFormSecurity = require("./withFormSecurity");
|
|
42
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
43
|
-
function _getRequireWildcardCache(
|
|
44
|
-
function _interopRequireWildcard(
|
|
42
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
43
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
44
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
45
45
|
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); }
|
|
46
|
-
function ownKeys(
|
|
47
|
-
function _objectSpread(
|
|
46
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
47
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
48
48
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
49
|
-
function _toPropertyKey(
|
|
50
|
-
function _toPrimitive(
|
|
49
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
50
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
51
51
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
52
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."); }
|
|
53
53
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -56,7 +56,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
56
56
|
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."); }
|
|
57
57
|
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); }
|
|
58
58
|
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; }
|
|
59
|
-
function _iterableToArrayLimit(
|
|
59
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
60
60
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
61
61
|
var Form = function Form(_ref) {
|
|
62
62
|
var _ref$submitOnPressEnt = _ref.submitOnPressEnterKey,
|
|
@@ -116,12 +116,12 @@ var Form = function Form(_ref) {
|
|
|
116
116
|
};
|
|
117
117
|
var getErrorMessages = function getErrorMessages(currentData, currentValidators) {
|
|
118
118
|
var dataValidate = currentData || usedData;
|
|
119
|
-
var currentFieldErrors = _lodash
|
|
119
|
+
var currentFieldErrors = _lodash["default"].pickBy(fieldErrors, function (error, fieldName) {
|
|
120
120
|
var fieldValidatorsNames = Object.keys(currentValidators);
|
|
121
121
|
return fieldValidatorsNames.includes(fieldName);
|
|
122
122
|
});
|
|
123
|
-
_lodash
|
|
124
|
-
var fieldValue = _lodash
|
|
123
|
+
_lodash["default"].forEach(currentValidators, function (validators, fieldName) {
|
|
124
|
+
var fieldValue = _lodash["default"].get(dataValidate, fieldName);
|
|
125
125
|
var messages = getValidatesErrorMessages(validators, fieldValue);
|
|
126
126
|
currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, _defineProperty({}, fieldName, messages));
|
|
127
127
|
});
|
|
@@ -152,7 +152,7 @@ var Form = function Form(_ref) {
|
|
|
152
152
|
var currentFieldErrors = fieldErrors;
|
|
153
153
|
var errors = getValidatesErrorMessages(validators, fieldValue);
|
|
154
154
|
if (errors.length === 0) {
|
|
155
|
-
currentFieldErrors = _lodash
|
|
155
|
+
currentFieldErrors = _lodash["default"].omit(currentFieldErrors, fieldName);
|
|
156
156
|
} else {
|
|
157
157
|
currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, _defineProperty({}, fieldName, errors));
|
|
158
158
|
}
|
|
@@ -172,13 +172,13 @@ var Form = function Form(_ref) {
|
|
|
172
172
|
setFieldErrors({});
|
|
173
173
|
};
|
|
174
174
|
var onRemoveFieldValidators = function onRemoveFieldValidators(fieldName) {
|
|
175
|
-
var newFieldsValidators = _lodash
|
|
175
|
+
var newFieldsValidators = _lodash["default"].omit(fieldsValidators, fieldName);
|
|
176
176
|
fieldsValidators.current = newFieldsValidators;
|
|
177
177
|
};
|
|
178
178
|
var onBeforeUnload = function onBeforeUnload(e) {
|
|
179
179
|
var event = e;
|
|
180
180
|
event.preventDefault();
|
|
181
|
-
if (_lodash
|
|
181
|
+
if (_lodash["default"].isEqual(usedData, originalData)) {
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
184
|
event.returnValue = true;
|
|
@@ -204,9 +204,9 @@ var Form = function Form(_ref) {
|
|
|
204
204
|
return propsForm;
|
|
205
205
|
};
|
|
206
206
|
var updateFormState = function updateFormState() {
|
|
207
|
-
if (!_lodash
|
|
207
|
+
if (!_lodash["default"].isEmpty(context)) {
|
|
208
208
|
var onChangedData = context.onChangedData;
|
|
209
|
-
if (securityData && !_lodash
|
|
209
|
+
if (securityData && !_lodash["default"].isEqual(usedData, securityData)) {
|
|
210
210
|
onChangedData(true);
|
|
211
211
|
} else {
|
|
212
212
|
onChangedData(false);
|
|
@@ -223,7 +223,7 @@ var Form = function Form(_ref) {
|
|
|
223
223
|
return checkIsValid(usedData);
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
|
-
if (_lodash
|
|
226
|
+
if (_lodash["default"].isEmpty(usedData)) setOriginalData(usedData);
|
|
227
227
|
};
|
|
228
228
|
(0, _react.useEffect)(function () {
|
|
229
229
|
if (useInternalState) updateFormState();
|
|
@@ -267,21 +267,20 @@ var Form = function Form(_ref) {
|
|
|
267
267
|
fieldErrors: fieldErrors,
|
|
268
268
|
externalFieldErrors: externalFieldErrors
|
|
269
269
|
};
|
|
270
|
-
return /*#__PURE__*/_react
|
|
270
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement(_helpers.FormContext.Provider, {
|
|
271
271
|
value: contextValues
|
|
272
|
-
}, /*#__PURE__*/_react
|
|
272
|
+
}, /*#__PURE__*/_react["default"].createElement("form", _extends({
|
|
273
273
|
style: style
|
|
274
274
|
}, formProps(), {
|
|
275
275
|
role: "presentation",
|
|
276
276
|
className: "form-component ".concat(customClass)
|
|
277
|
-
}), children)), /*#__PURE__*/_react
|
|
277
|
+
}), children)), /*#__PURE__*/_react["default"].createElement(_dialog.DialogQuestion, {
|
|
278
278
|
zIndex: "99999999",
|
|
279
279
|
title: securityTitle || 'Dados Alterados',
|
|
280
280
|
text: securityText || 'Você possui dados alterados, confirma o fechamento?',
|
|
281
|
-
visible: !_lodash
|
|
281
|
+
visible: !_lodash["default"].isEmpty(context) && context.showQuestion,
|
|
282
282
|
onConfirmClick: context ? context.onConfirmClick : function () {},
|
|
283
283
|
onUnconfirmClick: context ? context.onUnconfirmClick : function () {}
|
|
284
284
|
}));
|
|
285
285
|
};
|
|
286
|
-
var _default = Form;
|
|
287
|
-
exports.default = _default;
|
|
286
|
+
var _default = exports["default"] = Form;
|
package/lib/form/types.d.ts
CHANGED
|
@@ -216,4 +216,4 @@ type FieldValidator = {
|
|
|
216
216
|
[name: string]: Validator | Validator[];
|
|
217
217
|
};
|
|
218
218
|
|
|
219
|
-
export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, Validator, WithFieldProps };
|
|
219
|
+
export type { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, Validator, WithFieldProps };
|
package/lib/form/withFieldHOC.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports["default"] = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _helpers = require("./helpers");
|
|
10
|
-
function _getRequireWildcardCache(
|
|
11
|
-
function _interopRequireWildcard(
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
12
12
|
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); }
|
|
13
13
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
14
|
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."); }
|
|
15
15
|
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); }
|
|
16
16
|
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; }
|
|
17
|
-
function _iterableToArrayLimit(
|
|
17
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
18
18
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
19
|
var withFieldHOC = function withFieldHOC(WrappedComponent) {
|
|
20
20
|
var EnhancedComponent = function EnhancedComponent(props) {
|
|
@@ -45,12 +45,12 @@ var withFieldHOC = function withFieldHOC(WrappedComponent) {
|
|
|
45
45
|
setValidatorFromComponent(validator);
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
return /*#__PURE__*/_react
|
|
48
|
+
return /*#__PURE__*/_react["default"].createElement(_helpers.withFieldContext.Provider, {
|
|
49
49
|
value: contextValues
|
|
50
|
-
}, /*#__PURE__*/_react
|
|
50
|
+
}, /*#__PURE__*/_react["default"].createElement(WrappedComponent, props));
|
|
51
51
|
};
|
|
52
52
|
function forwardRef(props, ref) {
|
|
53
|
-
return /*#__PURE__*/_react
|
|
53
|
+
return /*#__PURE__*/_react["default"].createElement(_helpers.FormContext.Consumer, null, function (_ref) {
|
|
54
54
|
var handlerFieldChange = _ref.handlerFieldChange,
|
|
55
55
|
handlerFieldValidade = _ref.handlerFieldValidade,
|
|
56
56
|
data = _ref.data,
|
|
@@ -59,7 +59,7 @@ var withFieldHOC = function withFieldHOC(WrappedComponent) {
|
|
|
59
59
|
handlerStoreValidators = _ref.handlerStoreValidators,
|
|
60
60
|
handlerRemoveValidators = _ref.handlerRemoveValidators,
|
|
61
61
|
skeletonize = _ref.skeletonize;
|
|
62
|
-
return /*#__PURE__*/_react
|
|
62
|
+
return /*#__PURE__*/_react["default"].createElement(EnhancedComponent, _extends({}, props, {
|
|
63
63
|
skeletonize: skeletonize,
|
|
64
64
|
handlerFieldChange: handlerFieldChange,
|
|
65
65
|
handlerFieldValidade: handlerFieldValidade,
|
|
@@ -72,7 +72,6 @@ var withFieldHOC = function withFieldHOC(WrappedComponent) {
|
|
|
72
72
|
}));
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
return /*#__PURE__*/_react
|
|
75
|
+
return /*#__PURE__*/_react["default"].forwardRef(forwardRef);
|
|
76
76
|
};
|
|
77
|
-
var _default = withFieldHOC;
|
|
78
|
-
exports.default = _default;
|
|
77
|
+
var _default = exports["default"] = withFieldHOC;
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports["default"] = exports.FormSecurityContext = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
function _getRequireWildcardCache(
|
|
10
|
-
function _interopRequireWildcard(
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
11
11
|
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); }
|
|
12
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
13
|
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."); }
|
|
14
14
|
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); }
|
|
15
15
|
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; }
|
|
16
|
-
function _iterableToArrayLimit(
|
|
16
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
var FormSecurityContext = /*#__PURE__*/_react
|
|
19
|
-
exports.FormSecurityContext = FormSecurityContext;
|
|
18
|
+
var FormSecurityContext = exports.FormSecurityContext = /*#__PURE__*/_react["default"].createContext({});
|
|
20
19
|
var withFormSecurity = function withFormSecurity(WrappedComponent) {
|
|
21
20
|
var EnhancedComponent = function EnhancedComponent(props) {
|
|
22
21
|
var handlerClose = props.handlerClose;
|
|
@@ -51,13 +50,12 @@ var withFormSecurity = function withFormSecurity(WrappedComponent) {
|
|
|
51
50
|
setSecurityBeforeUnload: setSecurityBeforeUnload,
|
|
52
51
|
securityBeforeUnload: securityBeforeUnload.current
|
|
53
52
|
};
|
|
54
|
-
return /*#__PURE__*/_react
|
|
53
|
+
return /*#__PURE__*/_react["default"].createElement(FormSecurityContext.Provider, {
|
|
55
54
|
value: contextValues
|
|
56
|
-
}, /*#__PURE__*/_react
|
|
55
|
+
}, /*#__PURE__*/_react["default"].createElement(WrappedComponent, _extends({}, props, {
|
|
57
56
|
handlerClose: newHandlerClose
|
|
58
57
|
})));
|
|
59
58
|
};
|
|
60
59
|
return EnhancedComponent;
|
|
61
60
|
};
|
|
62
|
-
var _default = withFormSecurity;
|
|
63
|
-
exports.default = _default;
|
|
61
|
+
var _default = exports["default"] = withFormSecurity;
|