linear-react-components-ui 1.1.13 → 1.1.14-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 +77 -45
- package/.gitlab-ci.yml +5 -13
- package/.tool-versions +1 -0
- package/.vscode/settings.json +3 -12
- package/babel.config.json +4 -4
- package/lib/@types/SizePixels.d.ts +1 -1
- package/lib/alerts/AlertContainer.js +56 -47
- package/lib/alerts/AlertProvider.js +51 -33
- package/lib/alerts/BaseAlert.js +18 -11
- package/lib/alerts/Message.d.ts +1 -1
- package/lib/alerts/Message.js +44 -77
- package/lib/alerts/helpers.js +3 -2
- package/lib/alerts/index.js +3 -2
- package/lib/alerts/types.d.ts +0 -1
- package/lib/alerts/withAlert.js +9 -8
- package/lib/assets/styles/alerts.scss +7 -4
- package/lib/assets/styles/button.scss +9 -11
- package/lib/assets/styles/checkbox.scss +38 -45
- package/lib/assets/styles/colors.scss +1 -3
- package/lib/assets/styles/commons.scss +0 -1
- package/lib/assets/styles/dialog.scss +20 -37
- package/lib/assets/styles/drawers.scss +6 -9
- package/lib/assets/styles/fieldset.scss +0 -3
- package/lib/assets/styles/gridlayout.scss +2 -0
- package/lib/assets/styles/hint.scss +0 -21
- package/lib/assets/styles/icon.scss +4 -31
- package/lib/assets/styles/input.scss +7 -7
- package/lib/assets/styles/multiSelect.scss +1 -6
- package/lib/assets/styles/radio.scss +35 -37
- package/lib/assets/styles/select.scss +7 -13
- package/lib/assets/styles/table.scss +1 -9
- package/lib/assets/styles/tabs.scss +18 -28
- package/lib/avatar/index.js +39 -39
- package/lib/badge/index.js +13 -11
- package/lib/buttons/ActivateButton.js +7 -4
- package/lib/buttons/AddButton.js +10 -7
- package/lib/buttons/Button.js +9 -8
- package/lib/buttons/ButtonGroups.js +4 -5
- package/lib/buttons/CancelButton.js +5 -6
- package/lib/buttons/DangerButton.js +5 -6
- package/lib/buttons/DefaultButton.js +85 -85
- package/lib/buttons/DestroyButton.js +5 -6
- package/lib/buttons/EditButton.js +7 -4
- package/lib/buttons/InactivateButton.js +7 -4
- package/lib/buttons/InfoButton.js +5 -6
- package/lib/buttons/PrimaryButton.js +5 -6
- package/lib/buttons/RestoreButton.js +7 -4
- package/lib/buttons/SaveButton.js +5 -6
- package/lib/buttons/SuccessButton.js +5 -6
- package/lib/buttons/WarningButton.js +5 -6
- package/lib/buttons/button_container/index.js +19 -15
- package/lib/buttons/index.js +16 -15
- package/lib/buttons/split_button/index.js +23 -20
- package/lib/buttons/types.d.ts +0 -1
- package/lib/calendar/DangerCalendar.js +5 -6
- package/lib/calendar/InfoCalendar.js +5 -6
- package/lib/calendar/PrimaryCalendar.js +5 -6
- package/lib/calendar/SuccessCalendar.js +5 -6
- package/lib/calendar/WarningCalendar.js +5 -6
- package/lib/calendar/base/Day.js +11 -12
- package/lib/calendar/base/Month.js +17 -12
- package/lib/calendar/base/Week.js +17 -12
- package/lib/calendar/base/helpers.js +11 -11
- package/lib/calendar/base/index.js +43 -29
- package/lib/calendar/index.js +7 -6
- package/lib/checkbox/Label.js +9 -19
- package/lib/checkbox/index.d.ts +2 -2
- package/lib/checkbox/index.js +95 -81
- package/lib/checkbox/types.d.ts +1 -2
- package/lib/dialog/Alert.js +4 -3
- package/lib/dialog/Custom.js +16 -14
- package/lib/dialog/Error.js +4 -3
- package/lib/dialog/Information.js +4 -3
- package/lib/dialog/Question.js +12 -11
- package/lib/dialog/Warning.js +5 -5
- package/lib/dialog/base/Content.js +5 -7
- package/lib/dialog/base/Footer.js +7 -4
- package/lib/dialog/base/Header.js +28 -28
- package/lib/dialog/base/index.d.ts +2 -8
- package/lib/dialog/base/index.js +104 -108
- package/lib/dialog/base/style.js +10 -7
- package/lib/dialog/form/index.js +35 -36
- package/lib/dialog/index.js +8 -7
- package/lib/dialog/types.d.ts +13 -8
- package/lib/drawer/Content.js +10 -11
- package/lib/drawer/Drawer.js +83 -69
- package/lib/drawer/Header.js +36 -33
- package/lib/drawer/helpers.js +3 -2
- package/lib/drawer/index.js +4 -3
- package/lib/dropdown/Popup.d.ts +1 -1
- package/lib/dropdown/Popup.js +39 -38
- package/lib/dropdown/helper.js +5 -3
- package/lib/dropdown/types.d.ts +0 -1
- package/lib/dropdown/withDropdown.js +58 -37
- package/lib/fieldset/index.js +56 -50
- package/lib/fieldset/types.d.ts +0 -2
- package/lib/form/Field.d.ts +0 -2
- package/lib/form/Field.js +74 -68
- package/lib/form/FieldArray.d.ts +0 -2
- package/lib/form/FieldArray.js +90 -66
- package/lib/form/FieldNumber.d.ts +0 -2
- package/lib/form/FieldNumber.js +53 -33
- package/lib/form/FieldPeriod.d.ts +0 -2
- package/lib/form/FieldPeriod.js +52 -46
- package/lib/form/helpers.d.ts +0 -2
- package/lib/form/helpers.js +26 -21
- package/lib/form/index.d.ts +0 -2
- package/lib/form/index.js +143 -111
- package/lib/form/types.d.ts +4 -7
- package/lib/form/withFieldHOC.d.ts +0 -2
- package/lib/form/withFieldHOC.js +38 -31
- package/lib/form/withFormSecurity.d.ts +0 -2
- package/lib/form/withFormSecurity.js +34 -26
- package/lib/gridlayout/GridCol.js +13 -13
- package/lib/gridlayout/GridRow.js +11 -17
- package/lib/gridlayout/index.js +3 -2
- package/lib/gridlayout/types.d.ts +1 -1
- package/lib/hint/index.d.ts +1 -2
- package/lib/hint/index.js +28 -17
- package/lib/hint/types.d.ts +0 -3
- package/lib/icons/helper.d.ts +0 -4
- package/lib/icons/helper.js +4 -7
- package/lib/icons/index.d.ts +2 -3
- package/lib/icons/index.js +47 -42
- package/lib/icons/types.d.ts +9 -22
- package/lib/index.d.ts +1 -2
- package/lib/index.js +9 -9
- package/lib/inputs/base/InputTextBase.d.ts +0 -2
- package/lib/inputs/base/InputTextBase.js +111 -143
- package/lib/inputs/base/helpers.d.ts +2 -3
- package/lib/inputs/base/helpers.js +25 -20
- package/lib/inputs/base/types.d.ts +3 -17
- package/lib/inputs/color/index.js +38 -27
- package/lib/inputs/date/Dialog.d.ts +0 -2
- package/lib/inputs/date/Dialog.js +9 -8
- package/lib/inputs/date/Dropdown.d.ts +0 -2
- package/lib/inputs/date/Dropdown.js +10 -11
- package/lib/inputs/date/helpers.d.ts +0 -2
- package/lib/inputs/date/helpers.js +13 -13
- package/lib/inputs/date/index.d.ts +0 -2
- package/lib/inputs/date/index.js +150 -125
- package/lib/inputs/date/types.d.ts +1 -4
- package/lib/inputs/file/DefaultFile.d.ts +0 -2
- package/lib/inputs/file/DefaultFile.js +72 -45
- package/lib/inputs/file/DragDropFile.d.ts +0 -2
- package/lib/inputs/file/DragDropFile.js +147 -95
- package/lib/inputs/file/File.d.ts +1 -3
- package/lib/inputs/file/File.js +28 -22
- package/lib/inputs/file/FileButtonSettings.d.ts +0 -2
- package/lib/inputs/file/FileButtonSettings.js +12 -12
- package/lib/inputs/file/helpers.d.ts +0 -2
- package/lib/inputs/file/helpers.js +6 -4
- package/lib/inputs/file/index.d.ts +0 -2
- package/lib/inputs/file/index.js +4 -3
- package/lib/inputs/file/types.d.ts +0 -2
- package/lib/inputs/inputHOC.d.ts +1 -2
- package/lib/inputs/inputHOC.js +32 -19
- package/lib/inputs/mask/BaseMask.d.ts +5 -4
- package/lib/inputs/mask/BaseMask.js +34 -121
- package/lib/inputs/mask/Cnpj.d.ts +0 -2
- package/lib/inputs/mask/Cnpj.js +29 -16
- package/lib/inputs/mask/Cpf.d.ts +0 -2
- package/lib/inputs/mask/Cpf.js +35 -18
- package/lib/inputs/mask/Phone.d.ts +0 -2
- package/lib/inputs/mask/Phone.js +4 -5
- package/lib/inputs/mask/ZipCode.d.ts +0 -2
- package/lib/inputs/mask/ZipCode.js +7 -4
- package/lib/inputs/mask/helpers.d.ts +12 -53
- package/lib/inputs/mask/helpers.js +36 -90
- package/lib/inputs/{errorMessage/index.d.ts → mask/imaskHOC.d.ts} +7 -5
- package/lib/inputs/mask/imaskHOC.js +224 -0
- package/lib/inputs/mask/index.d.ts +2 -4
- package/lib/inputs/mask/index.js +6 -5
- package/lib/inputs/mask/types.d.ts +18 -22
- package/lib/inputs/multiSelect/ActionButtons.d.ts +0 -2
- package/lib/inputs/multiSelect/ActionButtons.js +21 -22
- package/lib/inputs/multiSelect/Dropdown.d.ts +0 -2
- package/lib/inputs/multiSelect/Dropdown.js +65 -48
- package/lib/inputs/multiSelect/helper.d.ts +0 -2
- package/lib/inputs/multiSelect/helper.js +7 -8
- package/lib/inputs/multiSelect/index.d.ts +0 -2
- package/lib/inputs/multiSelect/index.js +132 -80
- package/lib/inputs/multiSelect/types.d.ts +0 -2
- package/lib/inputs/number/BaseNumber.d.ts +2 -3
- package/lib/inputs/number/BaseNumber.js +21 -22
- package/lib/inputs/number/Currency.d.ts +2 -3
- package/lib/inputs/number/Currency.js +6 -6
- package/lib/inputs/number/Decimal.d.ts +2 -3
- package/lib/inputs/number/Decimal.js +5 -2
- package/lib/inputs/number/format_number.js +5 -5
- package/lib/inputs/number/index.d.ts +2 -3
- package/lib/inputs/number/index.js +49 -18
- package/lib/inputs/number/types.d.ts +14 -15
- package/lib/inputs/period/Dialog.d.ts +1 -3
- package/lib/inputs/period/Dialog.js +9 -8
- package/lib/inputs/period/Dropdown.d.ts +0 -2
- package/lib/inputs/period/Dropdown.js +8 -7
- package/lib/inputs/period/PeriodList.d.ts +0 -2
- package/lib/inputs/period/PeriodList.js +12 -13
- package/lib/inputs/period/helper.d.ts +0 -2
- package/lib/inputs/period/helper.js +36 -33
- package/lib/inputs/period/index.d.ts +0 -2
- package/lib/inputs/period/index.js +194 -160
- package/lib/inputs/period/types.d.ts +1 -3
- package/lib/inputs/search/index.d.ts +1 -2
- package/lib/inputs/search/index.js +63 -40
- package/lib/inputs/select/ActionButtons.d.ts +1 -2
- package/lib/inputs/select/ActionButtons.js +34 -24
- package/lib/inputs/select/Dropdown.d.ts +1 -2
- package/lib/inputs/select/Dropdown.js +58 -39
- package/lib/inputs/select/helper.d.ts +1 -2
- package/lib/inputs/select/helper.js +43 -49
- package/lib/inputs/select/index.d.ts +0 -2
- package/lib/inputs/select/index.js +8 -9
- package/lib/inputs/select/multiple/Selecteds.d.ts +1 -3
- package/lib/inputs/select/multiple/Selecteds.js +21 -16
- package/lib/inputs/select/multiple/index.d.ts +0 -2
- package/lib/inputs/select/multiple/index.js +176 -128
- package/lib/inputs/select/simple/index.d.ts +0 -2
- package/lib/inputs/select/simple/index.js +179 -151
- package/lib/inputs/select/types.d.ts +2 -5
- package/lib/inputs/text/index.js +5 -2
- package/lib/inputs/textarea/index.d.ts +0 -2
- package/lib/inputs/textarea/index.js +9 -9
- package/lib/inputs/textarea/types.d.ts +0 -2
- package/lib/inputs/types.d.ts +7 -12
- package/lib/internals/colorStyles.js +3 -2
- package/lib/internals/constants.js +4 -2
- package/lib/internals/types.d.ts +2 -5
- package/lib/internals/withTooltip.d.ts +2 -3
- package/lib/internals/withTooltip.js +74 -74
- package/lib/labelMessages/index.js +41 -21
- package/lib/labels/DangerLabel.js +5 -6
- package/lib/labels/DefaultLabel.js +39 -25
- package/lib/labels/InfoLabel.js +5 -6
- package/lib/labels/PrimaryLabel.js +5 -6
- package/lib/labels/SuccessLabel.js +5 -6
- package/lib/labels/WarningLabel.js +5 -6
- package/lib/labels/index.js +8 -7
- package/lib/labels/label_container/index.js +7 -7
- package/lib/list/Header.js +7 -8
- package/lib/list/Item.js +68 -72
- package/lib/list/Separator.js +7 -4
- package/lib/list/helpers.js +5 -3
- package/lib/list/index.js +100 -73
- package/lib/menus/float/MenuItem.js +19 -18
- package/lib/menus/float/SubMenuContainer.js +32 -26
- package/lib/menus/float/helpers.js +3 -2
- package/lib/menus/float/index.js +17 -16
- package/lib/menus/float/types.d.ts +1 -1
- package/lib/menus/index.js +2 -1
- package/lib/menus/sidenav/ExpandMenu.js +7 -8
- package/lib/menus/sidenav/MenuLink.js +8 -9
- package/lib/menus/sidenav/NavMenuGroup.js +11 -12
- package/lib/menus/sidenav/NavMenuItem.js +60 -46
- package/lib/menus/sidenav/NavSubMenuItem.js +24 -19
- package/lib/menus/sidenav/helpers.js +8 -5
- package/lib/menus/sidenav/index.js +111 -83
- package/lib/menus/sidenav/popup_menu_search/EmptyList.js +6 -6
- package/lib/menus/sidenav/popup_menu_search/index.js +83 -63
- package/lib/menus/sidenav/types.d.ts +1 -1
- package/lib/noPermission/index.js +16 -13
- package/lib/panel/Content.d.ts +1 -1
- package/lib/panel/Content.js +56 -43
- package/lib/panel/DangerPanel.d.ts +1 -1
- package/lib/panel/DangerPanel.js +7 -4
- package/lib/panel/Default.d.ts +1 -1
- package/lib/panel/Default.js +56 -41
- package/lib/panel/Header.d.ts +1 -1
- package/lib/panel/Header.js +26 -28
- package/lib/panel/InfoPanel.d.ts +1 -1
- package/lib/panel/InfoPanel.js +7 -4
- package/lib/panel/PrimaryPanel.d.ts +1 -1
- package/lib/panel/PrimaryPanel.js +7 -4
- package/lib/panel/SuccessPanel.d.ts +1 -1
- package/lib/panel/SuccessPanel.js +7 -4
- 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 +7 -4
- package/lib/panel/helpers.d.ts +2 -7
- package/lib/panel/helpers.js +23 -11
- package/lib/panel/index.d.ts +1 -1
- package/lib/panel/index.js +9 -8
- package/lib/panel/types.d.ts +5 -46
- package/lib/permissionValidations.js +29 -24
- package/lib/popover/PopoverText.js +4 -5
- package/lib/popover/PopoverTitle.js +4 -5
- package/lib/popover/index.js +18 -14
- package/lib/progress/Bar.js +36 -30
- package/lib/progress/index.js +18 -16
- package/lib/radio/index.js +55 -34
- package/lib/shortcuts/index.js +8 -9
- package/lib/skeleton/SkeletonContainer.js +10 -9
- package/lib/skeleton/index.js +32 -25
- package/lib/spinner/SpinnerLoading.js +7 -6
- package/lib/spinner/index.js +36 -22
- package/lib/split/Split.js +110 -93
- package/lib/split/SplitSide.js +18 -19
- package/lib/split/helpers.js +3 -2
- package/lib/split/index.js +3 -2
- package/lib/table/Body.js +44 -41
- package/lib/table/Header.js +31 -28
- package/lib/table/HeaderColumn.d.ts +1 -1
- package/lib/table/HeaderColumn.js +21 -34
- package/lib/table/Row.js +47 -44
- package/lib/table/RowColumn.js +37 -36
- package/lib/table/helpers.js +12 -6
- package/lib/table/index.js +98 -78
- package/lib/table/types.d.ts +0 -3
- package/lib/tabs/{MenuTabs.d.ts → DropdownItems.d.ts} +3 -3
- package/lib/tabs/DropdownItems.js +65 -0
- package/lib/tabs/Menu.d.ts +1 -1
- package/lib/tabs/Menu.js +20 -32
- package/lib/tabs/MenuItems.d.ts +11 -0
- package/lib/tabs/MenuItems.js +76 -0
- package/lib/tabs/Panel.d.ts +1 -1
- package/lib/tabs/Panel.js +65 -69
- package/lib/tabs/index.d.ts +1 -1
- package/lib/tabs/index.js +221 -42
- package/lib/tabs/tabHelpers.d.ts +15 -4
- package/lib/tabs/tabHelpers.js +41 -36
- package/lib/tabs/types.d.ts +15 -48
- package/lib/toolbar/ButtonBar.js +39 -35
- package/lib/toolbar/LabelBar.js +36 -32
- package/lib/toolbar/Separator.js +7 -4
- package/lib/toolbar/ToolBarGroup.js +6 -6
- package/lib/toolbar/helpers.js +3 -2
- package/lib/toolbar/index.js +21 -19
- package/lib/toolbar/types.d.ts +0 -1
- package/lib/tooltip/index.js +32 -27
- package/lib/treetable/Body.js +32 -20
- package/lib/treetable/Header.js +14 -11
- package/lib/treetable/Row.js +137 -85
- package/lib/treetable/helpers.js +24 -15
- package/lib/treetable/index.js +10 -8
- package/lib/treeview/Header.js +6 -7
- package/lib/treeview/Node.js +132 -92
- package/lib/treeview/constants.js +2 -1
- package/lib/treeview/index.js +214 -148
- package/lib/treeview_old/Header.js +28 -0
- package/lib/treeview_old/Node.js +88 -0
- package/lib/treeview_old/index.js +42 -0
- package/lib/types-c2a0f035.d.ts +50 -0
- package/lib/uitour/helpers.js +7 -4
- package/lib/uitour/index.d.ts +1 -2
- package/lib/uitour/index.js +99 -112
- package/lib/uitour/types.d.ts +1 -9
- package/package.json +82 -77
- package/tsconfig.json +0 -1
- package/.eslintcache +0 -1
- package/.nvmrc +0 -1
- package/lib/assets/styles/error.scss +0 -9
- package/lib/assets/styles/textContent.scss +0 -9
- package/lib/hint/helpers.d.ts +0 -3
- package/lib/hint/helpers.js +0 -21
- package/lib/inputs/base/Label.d.ts +0 -14
- package/lib/inputs/base/Label.js +0 -35
- package/lib/inputs/errorMessage/index.js +0 -26
- package/lib/tabs/DropdownTabs.d.ts +0 -11
- package/lib/tabs/DropdownTabs.js +0 -71
- package/lib/tabs/MenuTabs.js +0 -82
- package/lib/tabs/context.d.ts +0 -12
- package/lib/tabs/context.js +0 -130
- package/lib/tabs/useTabs.d.ts +0 -11
- package/lib/tabs/useTabs.js +0 -11
- package/lib/textContent/index.d.ts +0 -8
- package/lib/textContent/index.js +0 -30
package/lib/form/index.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
Object.defineProperty(exports, "Field", {
|
|
7
8
|
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
+
get: function get() {
|
|
9
10
|
return _Field.default;
|
|
10
11
|
}
|
|
11
12
|
});
|
|
12
13
|
Object.defineProperty(exports, "FieldArray", {
|
|
13
14
|
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
+
get: function get() {
|
|
15
16
|
return _FieldArray.default;
|
|
16
17
|
}
|
|
17
18
|
});
|
|
18
19
|
Object.defineProperty(exports, "FieldNumber", {
|
|
19
20
|
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
+
get: function get() {
|
|
21
22
|
return _FieldNumber.default;
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
Object.defineProperty(exports, "FieldPeriod", {
|
|
25
26
|
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
+
get: function get() {
|
|
27
28
|
return _FieldPeriod.default;
|
|
28
29
|
}
|
|
29
30
|
});
|
|
@@ -39,106 +40,130 @@ require("../assets/styles/form.scss");
|
|
|
39
40
|
var _dialog = require("../dialog");
|
|
40
41
|
var _withFormSecurity = require("./withFormSecurity");
|
|
41
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
42
|
-
function _getRequireWildcardCache(
|
|
43
|
-
function _interopRequireWildcard(
|
|
43
|
+
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); }
|
|
44
|
+
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; }
|
|
44
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); }
|
|
45
|
-
function ownKeys(
|
|
46
|
-
function _objectSpread(
|
|
46
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
47
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
47
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; }
|
|
48
|
-
function _toPropertyKey(
|
|
49
|
-
function _toPrimitive(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
49
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
50
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
51
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
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
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
54
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
55
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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
|
+
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
|
+
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
60
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
61
|
+
var Form = function Form(_ref) {
|
|
62
|
+
var _ref$submitOnPressEnt = _ref.submitOnPressEnterKey,
|
|
63
|
+
submitOnPressEnterKey = _ref$submitOnPressEnt === void 0 ? true : _ref$submitOnPressEnt,
|
|
64
|
+
dataSource = _ref.dataSource,
|
|
65
|
+
securityBeforeUnload = _ref.securityBeforeUnload,
|
|
66
|
+
handlerReset = _ref.handlerReset,
|
|
67
|
+
handlerSubmit = _ref.handlerSubmit,
|
|
68
|
+
handlerValidates = _ref.handlerValidates,
|
|
69
|
+
style = _ref.style,
|
|
70
|
+
customClass = _ref.customClass,
|
|
71
|
+
securityTitle = _ref.securityTitle,
|
|
72
|
+
securityText = _ref.securityText,
|
|
73
|
+
securityData = _ref.securityData,
|
|
74
|
+
onDataChange = _ref.onDataChange,
|
|
75
|
+
onValidateForm = _ref.onValidateForm,
|
|
76
|
+
externalFieldErrors = _ref.externalFieldErrors,
|
|
77
|
+
onSubmit = _ref.onSubmit,
|
|
78
|
+
skeletonize = _ref.skeletonize,
|
|
79
|
+
disabled = _ref.disabled,
|
|
80
|
+
children = _ref.children,
|
|
81
|
+
_ref$useInternalState = _ref.useInternalState,
|
|
82
|
+
useInternalState = _ref$useInternalState === void 0 ? false : _ref$useInternalState;
|
|
83
|
+
var _useState = (0, _react.useState)(dataSource),
|
|
84
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
85
|
+
data = _useState2[0],
|
|
86
|
+
setData = _useState2[1];
|
|
87
|
+
var _useState3 = (0, _react.useState)(dataSource),
|
|
88
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
89
|
+
originalData = _useState4[0],
|
|
90
|
+
setOriginalData = _useState4[1];
|
|
91
|
+
var _useState5 = (0, _react.useState)(submitOnPressEnterKey),
|
|
92
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
93
|
+
submitFormOnEnter = _useState6[0],
|
|
94
|
+
setSubmitFormOnEnter = _useState6[1];
|
|
95
|
+
var _useState7 = (0, _react.useState)({}),
|
|
96
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
97
|
+
fieldErrors = _useState8[0],
|
|
98
|
+
setFieldErrors = _useState8[1];
|
|
99
|
+
var fieldsValidators = (0, _react.useRef)({});
|
|
100
|
+
var _useState9 = (0, _react.useState)(0),
|
|
101
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
102
|
+
oldFieldsValidatorsQuantity = _useState10[0],
|
|
103
|
+
setOldFieldsValidatorsQuantity = _useState10[1];
|
|
104
|
+
var context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
|
|
105
|
+
var usedData = useInternalState ? data : dataSource;
|
|
106
|
+
var getValidatesErrorMessages = function getValidatesErrorMessages(validators, fieldValue) {
|
|
107
|
+
var validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
108
|
+
var errors = [];
|
|
109
|
+
validatorsArray.forEach(function (validator) {
|
|
84
110
|
if (typeof validator === 'function') {
|
|
85
|
-
|
|
86
|
-
if (result) errors = [
|
|
111
|
+
var result = validator(fieldValue);
|
|
112
|
+
if (result) errors = [].concat(_toConsumableArray(errors), [result]);
|
|
87
113
|
}
|
|
88
114
|
});
|
|
89
115
|
return errors;
|
|
90
116
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
117
|
+
var getErrorMessages = function getErrorMessages(currentData, currentValidators) {
|
|
118
|
+
var dataValidate = currentData || usedData;
|
|
119
|
+
var currentFieldErrors = _lodash.default.pickBy(fieldErrors, function (error, fieldName) {
|
|
120
|
+
var fieldValidatorsNames = Object.keys(currentValidators);
|
|
95
121
|
return fieldValidatorsNames.includes(fieldName);
|
|
96
122
|
});
|
|
97
|
-
_lodash.default.forEach(currentValidators, (validators, fieldName)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, {
|
|
101
|
-
[fieldName]: messages
|
|
102
|
-
});
|
|
123
|
+
_lodash.default.forEach(currentValidators, function (validators, fieldName) {
|
|
124
|
+
var fieldValue = _lodash.default.get(dataValidate, fieldName);
|
|
125
|
+
var messages = getValidatesErrorMessages(validators, fieldValue);
|
|
126
|
+
currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, _defineProperty({}, fieldName, messages));
|
|
103
127
|
});
|
|
104
128
|
return currentFieldErrors;
|
|
105
129
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
130
|
+
var checkIsValid = function checkIsValid(currentData) {
|
|
131
|
+
var updateState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
132
|
+
var currentValidators = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
133
|
+
var currentFieldErrors = getErrorMessages(currentData, currentValidators || fieldsValidators.current);
|
|
110
134
|
if (updateState) setFieldErrors(currentFieldErrors);
|
|
111
|
-
return Object.values(currentFieldErrors).every(
|
|
135
|
+
return Object.values(currentFieldErrors).every(function (value) {
|
|
136
|
+
return value.length === 0;
|
|
137
|
+
});
|
|
112
138
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
target
|
|
116
|
-
} = event;
|
|
139
|
+
var onFieldChange = function onFieldChange(event) {
|
|
140
|
+
var target = event.target;
|
|
117
141
|
if (!useInternalState && onDataChange) {
|
|
118
|
-
|
|
142
|
+
var newData = (0, _helpers.changeValue)(dataSource, target);
|
|
143
|
+
onDataChange(newData);
|
|
119
144
|
} else {
|
|
120
|
-
setData(
|
|
145
|
+
setData(function (prevState) {
|
|
146
|
+
return (0, _helpers.changeValue)(prevState, target);
|
|
147
|
+
});
|
|
121
148
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
149
|
+
};
|
|
150
|
+
var onValidate = function onValidate(fieldName, fieldValue, validators) {
|
|
124
151
|
if (validators) {
|
|
125
|
-
|
|
126
|
-
|
|
152
|
+
var currentFieldErrors = fieldErrors;
|
|
153
|
+
var errors = getValidatesErrorMessages(validators, fieldValue);
|
|
127
154
|
if (errors.length === 0) {
|
|
128
155
|
currentFieldErrors = _lodash.default.omit(currentFieldErrors, fieldName);
|
|
129
156
|
} else {
|
|
130
|
-
currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, {
|
|
131
|
-
[fieldName]: errors
|
|
132
|
-
});
|
|
157
|
+
currentFieldErrors = _objectSpread(_objectSpread({}, currentFieldErrors), {}, _defineProperty({}, fieldName, errors));
|
|
133
158
|
}
|
|
134
159
|
setFieldErrors(currentFieldErrors);
|
|
135
160
|
}
|
|
136
161
|
};
|
|
137
|
-
|
|
162
|
+
var onFormSubmit = function onFormSubmit(event) {
|
|
138
163
|
if (event) event.preventDefault();
|
|
139
164
|
if (checkIsValid(usedData)) onSubmit(usedData);
|
|
140
|
-
}
|
|
141
|
-
|
|
165
|
+
};
|
|
166
|
+
var onReset = function onReset() {
|
|
142
167
|
if (!useInternalState && onDataChange) {
|
|
143
168
|
onDataChange(JSON.parse(JSON.stringify(originalData)));
|
|
144
169
|
} else {
|
|
@@ -146,95 +171,101 @@ const Form = _ref => {
|
|
|
146
171
|
}
|
|
147
172
|
setFieldErrors({});
|
|
148
173
|
};
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
var onRemoveFieldValidators = function onRemoveFieldValidators(fieldName) {
|
|
175
|
+
var newFieldsValidators = _lodash.default.omit(fieldsValidators, fieldName);
|
|
151
176
|
fieldsValidators.current = newFieldsValidators;
|
|
152
177
|
};
|
|
153
|
-
|
|
154
|
-
|
|
178
|
+
var onBeforeUnload = function onBeforeUnload(e) {
|
|
179
|
+
var event = e;
|
|
155
180
|
event.preventDefault();
|
|
156
181
|
if (_lodash.default.isEqual(usedData, originalData)) {
|
|
157
182
|
return;
|
|
158
183
|
}
|
|
159
184
|
event.returnValue = true;
|
|
160
185
|
};
|
|
161
|
-
|
|
186
|
+
var submitOnEnter = function submitOnEnter(event) {
|
|
162
187
|
if (event.key === 'Enter') {
|
|
163
188
|
event.preventDefault();
|
|
164
189
|
if (submitFormOnEnter) onFormSubmit();
|
|
165
190
|
}
|
|
166
191
|
};
|
|
167
|
-
|
|
168
|
-
|
|
192
|
+
var formProps = function formProps() {
|
|
193
|
+
var propsForm = null;
|
|
169
194
|
if (!disabled) {
|
|
170
195
|
propsForm = {
|
|
171
|
-
onSubmit:
|
|
172
|
-
|
|
196
|
+
onSubmit: function onSubmit(event) {
|
|
197
|
+
return event.preventDefault();
|
|
198
|
+
},
|
|
199
|
+
onKeyPress: function onKeyPress(event) {
|
|
200
|
+
return submitOnEnter(event);
|
|
201
|
+
}
|
|
173
202
|
};
|
|
174
203
|
}
|
|
175
204
|
return propsForm;
|
|
176
205
|
};
|
|
177
|
-
|
|
206
|
+
var updateFormState = function updateFormState() {
|
|
178
207
|
if (!_lodash.default.isEmpty(context)) {
|
|
179
|
-
|
|
180
|
-
onChangedData
|
|
181
|
-
} = context;
|
|
208
|
+
var onChangedData = context.onChangedData;
|
|
182
209
|
if (securityData && !_lodash.default.isEqual(usedData, securityData)) {
|
|
183
210
|
onChangedData(true);
|
|
184
211
|
} else {
|
|
185
212
|
onChangedData(false);
|
|
186
213
|
}
|
|
187
214
|
}
|
|
188
|
-
if (onDataChange
|
|
215
|
+
if (onDataChange) onDataChange(usedData);
|
|
189
216
|
|
|
190
217
|
// TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
191
218
|
if (onValidateForm) onValidateForm(checkIsValid(usedData, true));
|
|
192
219
|
if (!disabled) {
|
|
193
220
|
handlerSubmit(onFormSubmit);
|
|
194
221
|
if (handlerReset) handlerReset(onReset);
|
|
195
|
-
if (handlerValidates) handlerValidates(()
|
|
222
|
+
if (handlerValidates) handlerValidates(function () {
|
|
223
|
+
return checkIsValid(usedData);
|
|
224
|
+
});
|
|
196
225
|
}
|
|
197
226
|
if (_lodash.default.isEmpty(usedData)) setOriginalData(usedData);
|
|
198
227
|
};
|
|
199
|
-
(0, _react.useEffect)(()
|
|
228
|
+
(0, _react.useEffect)(function () {
|
|
200
229
|
if (useInternalState) updateFormState();
|
|
201
230
|
}, [JSON.stringify(data), useInternalState]);
|
|
202
|
-
(0, _react.useEffect)(()
|
|
231
|
+
(0, _react.useEffect)(function () {
|
|
203
232
|
if (!useInternalState && onDataChange) updateFormState();
|
|
204
233
|
}, [JSON.stringify(dataSource), useInternalState]);
|
|
205
|
-
(0, _react.useEffect)(()
|
|
234
|
+
(0, _react.useEffect)(function () {
|
|
206
235
|
if (securityBeforeUnload) {
|
|
207
236
|
if (context) context.setSecurityBeforeUnload(true);
|
|
208
237
|
window.addEventListener('beforeunload', onBeforeUnload);
|
|
209
238
|
}
|
|
210
|
-
return ()
|
|
239
|
+
return function () {
|
|
240
|
+
return window.removeEventListener('beforeunload', onBeforeUnload);
|
|
241
|
+
};
|
|
211
242
|
}, [securityBeforeUnload, onBeforeUnload]);
|
|
212
|
-
(0, _react.useEffect)(()
|
|
243
|
+
(0, _react.useEffect)(function () {
|
|
213
244
|
if (!disabled && submitOnPressEnterKey !== submitFormOnEnter) {
|
|
214
245
|
setSubmitFormOnEnter(submitOnPressEnterKey);
|
|
215
246
|
}
|
|
216
247
|
}, [submitOnPressEnterKey]);
|
|
217
|
-
(0, _react.useEffect)(()
|
|
218
|
-
|
|
248
|
+
(0, _react.useEffect)(function () {
|
|
249
|
+
var newValidatorsQuantity = Object.values(fieldsValidators.current).reduce(function (acc, currentValue) {
|
|
250
|
+
return acc + ((currentValue === null || currentValue === void 0 ? void 0 : currentValue.length) || 0);
|
|
251
|
+
}, 0);
|
|
219
252
|
if (fieldsValidators.current && onValidateForm && oldFieldsValidatorsQuantity !== newValidatorsQuantity) {
|
|
220
253
|
setOldFieldsValidatorsQuantity(newValidatorsQuantity);
|
|
221
254
|
onValidateForm(checkIsValid(usedData, true, fieldsValidators.current));
|
|
222
255
|
}
|
|
223
256
|
}, [fieldsValidators.current, oldFieldsValidatorsQuantity, onValidateForm, JSON.stringify(usedData)]);
|
|
224
|
-
|
|
225
|
-
skeletonize,
|
|
257
|
+
var contextValues = {
|
|
258
|
+
skeletonize: skeletonize,
|
|
226
259
|
handlerFieldChange: onFieldChange,
|
|
227
260
|
handlerFieldValidade: onValidate,
|
|
228
|
-
handlerStoreValidators: (fieldName, fieldValidates)
|
|
229
|
-
fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, {
|
|
230
|
-
[fieldName]: fieldValidates
|
|
231
|
-
});
|
|
261
|
+
handlerStoreValidators: function handlerStoreValidators(fieldName, fieldValidates) {
|
|
262
|
+
fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, _defineProperty({}, fieldName, fieldValidates));
|
|
232
263
|
},
|
|
233
264
|
handlerRemoveValidators: onRemoveFieldValidators,
|
|
234
265
|
data: useInternalState ? data : dataSource,
|
|
235
|
-
originalData,
|
|
236
|
-
fieldErrors,
|
|
237
|
-
externalFieldErrors
|
|
266
|
+
originalData: originalData,
|
|
267
|
+
fieldErrors: fieldErrors,
|
|
268
|
+
externalFieldErrors: externalFieldErrors
|
|
238
269
|
};
|
|
239
270
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_helpers.FormContext.Provider, {
|
|
240
271
|
value: contextValues
|
|
@@ -248,8 +279,9 @@ const Form = _ref => {
|
|
|
248
279
|
title: securityTitle || 'Dados Alterados',
|
|
249
280
|
text: securityText || 'Você possui dados alterados, confirma o fechamento?',
|
|
250
281
|
visible: !_lodash.default.isEmpty(context) && context.showQuestion,
|
|
251
|
-
onConfirmClick: context ? context.onConfirmClick : ()
|
|
252
|
-
onUnconfirmClick: context ? context.onUnconfirmClick : ()
|
|
282
|
+
onConfirmClick: context ? context.onConfirmClick : function () {},
|
|
283
|
+
onUnconfirmClick: context ? context.onUnconfirmClick : function () {}
|
|
253
284
|
}));
|
|
254
285
|
};
|
|
255
|
-
var _default =
|
|
286
|
+
var _default = Form;
|
|
287
|
+
exports.default = _default;
|
package/lib/form/types.d.ts
CHANGED
|
@@ -5,8 +5,6 @@ import '../@types/DataCombo.js';
|
|
|
5
5
|
import '../@types/PermissionAttr.js';
|
|
6
6
|
import '../inputs/base/types.js';
|
|
7
7
|
import '../@types/Period.js';
|
|
8
|
-
import '../internals/types.js';
|
|
9
|
-
import '../@types/Position.js';
|
|
10
8
|
|
|
11
9
|
type Validator = (value: string) => string | undefined;
|
|
12
10
|
type PeriodValidator = (value: {
|
|
@@ -38,13 +36,12 @@ type BaseFormProps = {
|
|
|
38
36
|
skeletonize?: boolean;
|
|
39
37
|
disabled?: boolean;
|
|
40
38
|
};
|
|
41
|
-
type OnDataChange = React.Dispatch<React.SetStateAction<any>>;
|
|
42
39
|
type FormProps = BaseFormProps & ({
|
|
43
40
|
useInternalState?: false;
|
|
44
|
-
onDataChange:
|
|
41
|
+
onDataChange: (data: object) => void;
|
|
45
42
|
} | {
|
|
46
43
|
useInternalState: true;
|
|
47
|
-
onDataChange?:
|
|
44
|
+
onDataChange?: (data: object) => void;
|
|
48
45
|
});
|
|
49
46
|
type Data = {
|
|
50
47
|
[key: string]: any;
|
|
@@ -85,6 +82,7 @@ interface IFieldProps extends WithFieldProps {
|
|
|
85
82
|
autoFocus?: boolean;
|
|
86
83
|
autoCompleteMask?: 'left' | 'right';
|
|
87
84
|
mask?: string;
|
|
85
|
+
removeZeroLeft?: boolean;
|
|
88
86
|
}
|
|
89
87
|
interface CustomEvent {
|
|
90
88
|
target: {
|
|
@@ -172,14 +170,12 @@ interface WithFieldProps {
|
|
|
172
170
|
handlerStoreValidators?: (name: string, validators: Validator | Validator[]) => void;
|
|
173
171
|
handlerRemoveValidators?: (name: string) => void;
|
|
174
172
|
validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
|
|
175
|
-
customClass?: string;
|
|
176
173
|
}
|
|
177
174
|
interface IWithFieldContext {
|
|
178
175
|
validatorFromComponent: Validator | Validator[] | undefined;
|
|
179
176
|
handlerSetValidatorFromComponent: (validator: Validator | Validator[]) => void;
|
|
180
177
|
}
|
|
181
178
|
interface IWithFormSecurity {
|
|
182
|
-
onOpenChange?: (open: boolean) => void;
|
|
183
179
|
handlerClose?: () => void;
|
|
184
180
|
onClick?: MouseEventHandler;
|
|
185
181
|
children?: ReactNode;
|
|
@@ -203,6 +199,7 @@ interface IEventParams {
|
|
|
203
199
|
handlerFieldChange?: (event: ChangeEvent<HTMLInputElement> | CustomKeyboardEvent) => void;
|
|
204
200
|
validatorFromComponent?: Validator | Validator[];
|
|
205
201
|
handleShowValidateMessages: (value: boolean) => void;
|
|
202
|
+
component?: ComponentType<any>;
|
|
206
203
|
}
|
|
207
204
|
interface IGetErrorMessagesParams {
|
|
208
205
|
name: string;
|
|
@@ -6,8 +6,6 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../internals/types.js';
|
|
10
|
-
import '../@types/Position.js';
|
|
11
9
|
|
|
12
10
|
declare const withFieldHOC: <ComponentProps extends WithFieldProps>(WrappedComponent: React__default.ComponentType<ComponentProps>) => React__default.ForwardRefExoticComponent<React__default.PropsWithoutRef<ComponentProps> & React__default.RefAttributes<HTMLElement>>;
|
|
13
11
|
|
package/lib/form/withFieldHOC.js
CHANGED
|
@@ -1,39 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.default = void 0;
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _helpers = require("./helpers");
|
|
9
|
-
function _getRequireWildcardCache(
|
|
10
|
-
function _interopRequireWildcard(
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
11
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); }
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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
|
+
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
|
+
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
18
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
19
|
+
var withFieldHOC = function withFieldHOC(WrappedComponent) {
|
|
20
|
+
var EnhancedComponent = function EnhancedComponent(props) {
|
|
21
|
+
var name = props.name,
|
|
22
|
+
validators = props.validators,
|
|
23
|
+
handlerStoreValidators = props.handlerStoreValidators,
|
|
24
|
+
handlerRemoveValidators = props.handlerRemoveValidators;
|
|
25
|
+
var _useState = (0, _react.useState)(undefined),
|
|
26
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
27
|
+
validatorFromComponent = _useState2[0],
|
|
28
|
+
setValidatorFromComponent = _useState2[1];
|
|
29
|
+
var updateValidators = function updateValidators() {
|
|
30
|
+
var validatorsArray = (0, _helpers.getValidatorsArray)(validators, validatorFromComponent);
|
|
23
31
|
if (validatorsArray && handlerStoreValidators) handlerStoreValidators(name, validatorsArray);
|
|
24
32
|
};
|
|
25
|
-
(0, _react.useEffect)(()
|
|
33
|
+
(0, _react.useEffect)(function () {
|
|
26
34
|
updateValidators();
|
|
27
|
-
return ()
|
|
35
|
+
return function () {
|
|
28
36
|
if (validators && handlerRemoveValidators) handlerRemoveValidators(name);
|
|
29
37
|
};
|
|
30
38
|
}, []);
|
|
31
|
-
(0, _react.useEffect)(()
|
|
39
|
+
(0, _react.useEffect)(function () {
|
|
32
40
|
updateValidators();
|
|
33
41
|
}, [validators]);
|
|
34
|
-
|
|
35
|
-
validatorFromComponent,
|
|
36
|
-
handlerSetValidatorFromComponent: validator
|
|
42
|
+
var contextValues = {
|
|
43
|
+
validatorFromComponent: validatorFromComponent,
|
|
44
|
+
handlerSetValidatorFromComponent: function handlerSetValidatorFromComponent(validator) {
|
|
37
45
|
setValidatorFromComponent(validator);
|
|
38
46
|
}
|
|
39
47
|
};
|
|
@@ -42,17 +50,15 @@ const withFieldHOC = WrappedComponent => {
|
|
|
42
50
|
}, /*#__PURE__*/_react.default.createElement(WrappedComponent, props));
|
|
43
51
|
};
|
|
44
52
|
function forwardRef(props, ref) {
|
|
45
|
-
return /*#__PURE__*/_react.default.createElement(_helpers.FormContext.Consumer, null, _ref
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
skeletonize
|
|
55
|
-
} = _ref;
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_helpers.FormContext.Consumer, null, function (_ref) {
|
|
54
|
+
var handlerFieldChange = _ref.handlerFieldChange,
|
|
55
|
+
handlerFieldValidade = _ref.handlerFieldValidade,
|
|
56
|
+
data = _ref.data,
|
|
57
|
+
fieldErrors = _ref.fieldErrors,
|
|
58
|
+
externalFieldErrors = _ref.externalFieldErrors,
|
|
59
|
+
handlerStoreValidators = _ref.handlerStoreValidators,
|
|
60
|
+
handlerRemoveValidators = _ref.handlerRemoveValidators,
|
|
61
|
+
skeletonize = _ref.skeletonize;
|
|
56
62
|
return /*#__PURE__*/_react.default.createElement(EnhancedComponent, _extends({}, props, {
|
|
57
63
|
skeletonize: skeletonize,
|
|
58
64
|
handlerFieldChange: handlerFieldChange,
|
|
@@ -68,4 +74,5 @@ const withFieldHOC = WrappedComponent => {
|
|
|
68
74
|
}
|
|
69
75
|
return /*#__PURE__*/_react.default.forwardRef(forwardRef);
|
|
70
76
|
};
|
|
71
|
-
var _default =
|
|
77
|
+
var _default = withFieldHOC;
|
|
78
|
+
exports.default = _default;
|
|
@@ -6,8 +6,6 @@ import '../@types/DataCombo.js';
|
|
|
6
6
|
import '../@types/PermissionAttr.js';
|
|
7
7
|
import '../inputs/base/types.js';
|
|
8
8
|
import '../@types/Period.js';
|
|
9
|
-
import '../internals/types.js';
|
|
10
|
-
import '../@types/Position.js';
|
|
11
9
|
|
|
12
10
|
declare const FormSecurityContext: React__default.Context<IFormSecurityContext>;
|
|
13
11
|
declare const withFormSecurity: <ComponentProps extends IWithFormSecurity>(WrappedComponent: React__default.ComponentType<ComponentProps>) => (props: ComponentProps) => JSX.Element;
|