linear-react-components-ui 1.1.22-beta.2 → 1.1.22-beta.3
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/lib/assets/styles/file.scss +7 -10
- package/lib/assets/styles/select.scss +19 -15
- package/lib/assets/styles/tabs.scss +16 -3
- package/lib/dialog/form/index.js +3 -2
- package/lib/dialog/types.d.ts +1 -0
- package/lib/drawer/Drawer.d.ts +1 -1
- package/lib/drawer/Drawer.js +6 -2
- package/lib/drawer/types.d.ts +1 -0
- package/lib/form/Field.js +31 -8
- package/lib/form/FieldArray.js +11 -2
- package/lib/form/FieldNumber.js +10 -1
- package/lib/form/FieldPeriod.js +15 -1
- package/lib/form/index.d.ts +1 -1
- package/lib/form/index.js +30 -5
- package/lib/form/types.d.ts +13 -1
- package/lib/form/withFieldHOC.js +4 -2
- package/lib/inputs/date/helpers.d.ts +31 -1
- package/lib/inputs/date/helpers.js +32 -2
- package/lib/inputs/date/index.js +28 -20
- package/lib/inputs/date/types.d.ts +1 -0
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +6 -4
- package/lib/inputs/mask/helpers.d.ts +6 -53
- package/lib/inputs/mask/helpers.js +15 -35
- package/lib/inputs/mask/types.d.ts +1 -0
- package/lib/inputs/select/multiple/Selecteds.d.ts +1 -1
- package/lib/inputs/select/multiple/Selecteds.js +3 -1
- package/lib/inputs/select/multiple/index.js +3 -2
- package/lib/inputs/select/types.d.ts +1 -0
- package/lib/panel/Content.js +10 -7
- package/lib/radio/index.d.ts +4 -1
- package/lib/radio/index.js +1 -0
- package/lib/tabs/Menu.d.ts +1 -1
- package/lib/tabs/Menu.js +4 -2
- package/lib/tabs/MenuTabs.js +16 -5
- package/lib/tabs/context.d.ts +1 -1
- package/lib/tabs/context.js +3 -1
- package/lib/tabs/index.d.ts +1 -1
- package/lib/tabs/index.js +13 -6
- package/lib/tabs/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -159,8 +159,14 @@
|
|
|
159
159
|
margin-top: 3px;
|
|
160
160
|
}
|
|
161
161
|
> .-skeletonized {
|
|
162
|
+
@extend %skeleton-component;
|
|
162
163
|
height: 180px !important;
|
|
163
|
-
|
|
164
|
+
color: transparent !important;
|
|
165
|
+
text-shadow: none;
|
|
166
|
+
box-shadow: none;
|
|
167
|
+
border-color: transparent !important;
|
|
168
|
+
transition: none;
|
|
169
|
+
}
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
.input-simple-file-container {
|
|
@@ -213,12 +219,3 @@
|
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
}
|
|
216
|
-
|
|
217
|
-
.-skeletonized {
|
|
218
|
-
@extend %skeleton-component;
|
|
219
|
-
color: transparent !important;
|
|
220
|
-
text-shadow: none;
|
|
221
|
-
box-shadow: none;
|
|
222
|
-
border-color: transparent !important;
|
|
223
|
-
transition: none;
|
|
224
|
-
}
|
|
@@ -23,15 +23,15 @@
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.selectwrapper
|
|
26
|
+
.selectwrapper > .multiselect {
|
|
27
27
|
flex-wrap: wrap;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
> .textinput {
|
|
30
30
|
order: 1;
|
|
31
31
|
display: inline-block;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
> .selecteditem {
|
|
35
35
|
background-color: #f2f9fc;
|
|
36
36
|
border: 1px solid #c9e6f2;
|
|
37
37
|
border-radius: 3px;
|
|
@@ -44,14 +44,18 @@
|
|
|
44
44
|
float: left;
|
|
45
45
|
margin: 2px;
|
|
46
46
|
padding: 0px 8px 0px 5px;
|
|
47
|
-
|
|
47
|
+
&.-disabled {
|
|
48
|
+
@extend %component-disabled;
|
|
49
|
+
opacity: 0.7;
|
|
50
|
+
border: solid 1px $font-color-disabled;
|
|
51
|
+
}
|
|
48
52
|
.close {
|
|
49
53
|
all: unset;
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
}
|
|
53
57
|
|
|
54
|
-
.selectwrapper
|
|
58
|
+
.selectwrapper > .multiselect > .selecteditem > .close {
|
|
55
59
|
cursor: pointer;
|
|
56
60
|
|
|
57
61
|
&:after {
|
|
@@ -63,9 +67,9 @@
|
|
|
63
67
|
}
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
.dropdown-component
|
|
70
|
+
.dropdown-component > .select-dropdown {
|
|
67
71
|
animation: 0.5s ease-in 0s 1 slideDown;
|
|
68
|
-
background-color: #
|
|
72
|
+
background-color: #fff;
|
|
69
73
|
border: $component-border-color;
|
|
70
74
|
@extend %component-menu-dropdown;
|
|
71
75
|
display: grid;
|
|
@@ -75,7 +79,7 @@
|
|
|
75
79
|
overflow-x: hidden;
|
|
76
80
|
margin-top: 2px;
|
|
77
81
|
|
|
78
|
-
|
|
82
|
+
> .filtercontainer {
|
|
79
83
|
display: grid;
|
|
80
84
|
grid-template-columns: 1fr 20px;
|
|
81
85
|
align-items: center;
|
|
@@ -83,7 +87,7 @@
|
|
|
83
87
|
margin: 4px;
|
|
84
88
|
}
|
|
85
89
|
|
|
86
|
-
|
|
90
|
+
> .filtercontainer > .filterinput {
|
|
87
91
|
border: 0;
|
|
88
92
|
width: 100%;
|
|
89
93
|
font-size: 13px;
|
|
@@ -91,7 +95,7 @@
|
|
|
91
95
|
padding: 10px 5px;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
> .item {
|
|
95
99
|
margin: 0;
|
|
96
100
|
padding: 6px 10px;
|
|
97
101
|
display: flex;
|
|
@@ -132,21 +136,21 @@
|
|
|
132
136
|
display: flex;
|
|
133
137
|
justify-content: space-between;
|
|
134
138
|
align-items: center;
|
|
135
|
-
width: 100
|
|
139
|
+
width: 100%;
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
.menubutton {
|
|
139
|
-
|
|
143
|
+
> .label {
|
|
140
144
|
flex-grow: 1;
|
|
141
145
|
}
|
|
142
146
|
|
|
143
|
-
|
|
144
|
-
margin-right: 5px
|
|
147
|
+
> .menuicon {
|
|
148
|
+
margin-right: 5px;
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
}
|
|
148
152
|
|
|
149
|
-
|
|
153
|
+
> .notfound {
|
|
150
154
|
text-indent: 10px;
|
|
151
155
|
color: graytext;
|
|
152
156
|
font-style: italic;
|
|
@@ -49,12 +49,15 @@ $dropdown-width: 38px;
|
|
|
49
49
|
text-shadow: 0 1px $font-color-second;
|
|
50
50
|
cursor: pointer;
|
|
51
51
|
line-height: 20px;
|
|
52
|
-
margin-right:
|
|
52
|
+
margin-right: 2px;
|
|
53
53
|
padding: 0;
|
|
54
54
|
width: auto;
|
|
55
|
-
min-width:
|
|
55
|
+
min-width: 112px;
|
|
56
56
|
display: flex;
|
|
57
57
|
align-items: center;
|
|
58
|
+
border: 1px solid $font-color-second;
|
|
59
|
+
border-top: 2px solid $font-color-second;
|
|
60
|
+
border-bottom: 1px solid $component-border-color;
|
|
58
61
|
&.selected {
|
|
59
62
|
border: 1px solid $component-border-color;
|
|
60
63
|
background: $font-color-second;
|
|
@@ -63,6 +66,15 @@ $dropdown-width: 38px;
|
|
|
63
66
|
box-shadow: 0;
|
|
64
67
|
font-weight: bold;
|
|
65
68
|
}
|
|
69
|
+
&.witherrorcontent {
|
|
70
|
+
border: 1px solid $input-error-border-color;
|
|
71
|
+
border-top: 2px solid $input-error-border-color;
|
|
72
|
+
border-bottom: 1px solid transparent;
|
|
73
|
+
background-color: $input-error-bg-color;
|
|
74
|
+
&.selected {
|
|
75
|
+
border-top: 2px solid $component-selected-color;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
66
78
|
&.selected>.closepanel,
|
|
67
79
|
&:hover>.closepanel {
|
|
68
80
|
visibility: visible;
|
|
@@ -75,7 +87,8 @@ $dropdown-width: 38px;
|
|
|
75
87
|
background: transparent;
|
|
76
88
|
border: 0;
|
|
77
89
|
width: 100%;
|
|
78
|
-
text-align: left
|
|
90
|
+
text-align: left;
|
|
91
|
+
box-shadow: none !important;
|
|
79
92
|
}
|
|
80
93
|
|
|
81
94
|
.menu>.menuitem>.closepanel {
|
package/lib/dialog/form/index.js
CHANGED
|
@@ -32,7 +32,8 @@ const ModalForm = props => {
|
|
|
32
32
|
children,
|
|
33
33
|
className = '',
|
|
34
34
|
wrapperClassName = '',
|
|
35
|
-
contentClassName = ''
|
|
35
|
+
contentClassName = '',
|
|
36
|
+
headerClassName = ''
|
|
36
37
|
} = props;
|
|
37
38
|
const headerRef = (0, _react.useRef)(null);
|
|
38
39
|
const context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
|
|
@@ -62,7 +63,7 @@ const ModalForm = props => {
|
|
|
62
63
|
className: className,
|
|
63
64
|
wrapperClassName: `dialog-form-wrapper ${wrapperClassName}`
|
|
64
65
|
}), props.title && /*#__PURE__*/_react.default.createElement("div", {
|
|
65
|
-
className:
|
|
66
|
+
className: `header-form ${headerClassName}`
|
|
66
67
|
}, /*#__PURE__*/_react.default.createElement(_Header.default, {
|
|
67
68
|
title: props.title,
|
|
68
69
|
handlerClose: props.handlerClose,
|
package/lib/dialog/types.d.ts
CHANGED
package/lib/drawer/Drawer.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ import '../@types/Position.js';
|
|
|
5
5
|
import '../@types/Icon.js';
|
|
6
6
|
import '../icons/helper.js';
|
|
7
7
|
|
|
8
|
-
declare const BaseDrawer: ({ position, customClass, children, style, customClassForContent, targetId, closeOnEsc, overlay, permissionAttr, skeletonize, handlerClose, customClassForDrawer, content, title, isWaiting, ...rest }: IDrawerProps) => React__default.ReactPortal;
|
|
8
|
+
declare const BaseDrawer: ({ position, customClass, children, style, customClassForContent, targetId, closeOnEsc, overlay, permissionAttr, skeletonize, handlerClose, customClassForDrawer, content, title, isWaiting, customClassElementDrawer, ...rest }: IDrawerProps) => React__default.ReactPortal;
|
|
9
9
|
|
|
10
10
|
export { BaseDrawer as default };
|
package/lib/drawer/Drawer.js
CHANGED
|
@@ -10,7 +10,7 @@ var _helpers = _interopRequireDefault(require("./helpers"));
|
|
|
10
10
|
var _permissionValidations = require("../permissionValidations");
|
|
11
11
|
var _ = require(".");
|
|
12
12
|
var _spinner = _interopRequireDefault(require("../spinner"));
|
|
13
|
-
const _excluded = ["position", "customClass", "children", "style", "customClassForContent", "targetId", "closeOnEsc", "overlay", "permissionAttr", "skeletonize", "handlerClose", "customClassForDrawer", "content", "title", "isWaiting"];
|
|
13
|
+
const _excluded = ["position", "customClass", "children", "style", "customClassForContent", "targetId", "closeOnEsc", "overlay", "permissionAttr", "skeletonize", "handlerClose", "customClassForDrawer", "content", "title", "isWaiting", "customClassElementDrawer"];
|
|
14
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
15
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
16
|
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 && {}.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; }
|
|
@@ -38,7 +38,8 @@ const BaseDrawer = _ref => {
|
|
|
38
38
|
customClassForDrawer = '',
|
|
39
39
|
content,
|
|
40
40
|
title,
|
|
41
|
-
isWaiting = false
|
|
41
|
+
isWaiting = false,
|
|
42
|
+
customClassElementDrawer = ''
|
|
42
43
|
} = _ref,
|
|
43
44
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
44
45
|
const headerProps = _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -46,6 +47,9 @@ const BaseDrawer = _ref => {
|
|
|
46
47
|
});
|
|
47
48
|
const drawerContainerEl = (0, _react.useRef)(document.createElement('div'));
|
|
48
49
|
drawerContainerEl.current.className = 'drawercontainer';
|
|
50
|
+
if (customClassElementDrawer) {
|
|
51
|
+
drawerContainerEl.current.className = customClassElementDrawer;
|
|
52
|
+
}
|
|
49
53
|
const drawerComponentEl = (0, _react.useRef)();
|
|
50
54
|
const {
|
|
51
55
|
hideContent
|
package/lib/drawer/types.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ interface IDrawerProps extends React__default.HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
customClass?: string;
|
|
11
11
|
customClassForContent?: string;
|
|
12
12
|
customClassForDrawer?: string;
|
|
13
|
+
customClassElementDrawer?: string;
|
|
13
14
|
position?: Exclude<Position, 'center'>;
|
|
14
15
|
handlerClose?: () => void;
|
|
15
16
|
closeOnEsc?: boolean;
|
package/lib/form/Field.js
CHANGED
|
@@ -8,18 +8,19 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
9
|
var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
|
|
10
10
|
var _helpers = require("./helpers");
|
|
11
|
-
|
|
11
|
+
var constants = _interopRequireWildcard(require("../internals/constants"));
|
|
12
|
+
const _excluded = ["handlerFieldChange", "handlerFieldValidate", "onChange", "onBlur", "name", "validators", "data", "fieldErrors", "handlerStoreValidators", "handlerRemoveValidators", "component", "externalFieldErrors", "originalData", "handleValidationErrorsOnTab"];
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
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 && {}.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; }
|
|
15
16
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
18
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
16
19
|
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; }
|
|
17
20
|
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; }
|
|
18
21
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
19
22
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
20
23
|
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); }
|
|
21
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var s = Object.getOwnPropertySymbols(e); for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
22
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
|
|
23
24
|
const getEvents = _ref => {
|
|
24
25
|
let {
|
|
25
26
|
validators = [],
|
|
@@ -28,10 +29,13 @@ const getEvents = _ref => {
|
|
|
28
29
|
handlerFieldValidate,
|
|
29
30
|
validatorFromComponent,
|
|
30
31
|
handlerFieldChange,
|
|
31
|
-
onChange
|
|
32
|
+
onChange,
|
|
33
|
+
component,
|
|
34
|
+
onKeyDown
|
|
32
35
|
} = _ref;
|
|
33
36
|
if (!(validators || validatorFromComponent || onBlur || onChange)) return {};
|
|
34
37
|
const validatorsArray = (0, _helpers.getValidatorsArray)(validators, validatorFromComponent);
|
|
38
|
+
const maskComponents = ['PhoneField', 'CpfField', 'CnpjField', 'ZipCodeField', 'BaseMask'];
|
|
35
39
|
return {
|
|
36
40
|
onBlur: e => {
|
|
37
41
|
if (validatorsArray && e.target && handlerFieldValidate) {
|
|
@@ -39,8 +43,14 @@ const getEvents = _ref => {
|
|
|
39
43
|
}
|
|
40
44
|
if (onBlur) onBlur(e);
|
|
41
45
|
},
|
|
46
|
+
onKeyDown: e => {
|
|
47
|
+
if (component && maskComponents.includes(component.name) && [constants.keyCodes.ENTER].includes(e.keyCode) && validatorsArray && e.target && handlerFieldValidate) {
|
|
48
|
+
handlerFieldValidate(name, e.target.value, validatorsArray);
|
|
49
|
+
if (onKeyDown) onKeyDown(e);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
42
52
|
onChange: e => {
|
|
43
|
-
if (validatorsArray && e.target && handlerFieldValidate) {
|
|
53
|
+
if (component && !maskComponents.includes(component.name) && validatorsArray && e.target && handlerFieldValidate) {
|
|
44
54
|
handlerFieldValidate(name, e.target.value, validatorsArray);
|
|
45
55
|
}
|
|
46
56
|
if (handlerFieldChange) handlerFieldChange(e);
|
|
@@ -58,8 +68,11 @@ const getCustomProps = (props, handlerSetComponentValidator) => {
|
|
|
58
68
|
component
|
|
59
69
|
} = props;
|
|
60
70
|
if (componentType && componentType.toLowerCase() === 'radio') {
|
|
71
|
+
const convertedData = _objectSpread(_objectSpread({}, data), {}, {
|
|
72
|
+
[name]: String(data?.[name])
|
|
73
|
+
});
|
|
61
74
|
return {
|
|
62
|
-
checked: _lodash.default.get(
|
|
75
|
+
checked: _lodash.default.get(convertedData, name) === value,
|
|
63
76
|
id: fieldId
|
|
64
77
|
};
|
|
65
78
|
} else if (componentType && componentType.toLowerCase() === 'checkbox') {
|
|
@@ -91,13 +104,22 @@ const Field = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
91
104
|
handlerRemoveValidators,
|
|
92
105
|
component: Component,
|
|
93
106
|
externalFieldErrors,
|
|
94
|
-
originalData
|
|
107
|
+
originalData,
|
|
108
|
+
handleValidationErrorsOnTab
|
|
95
109
|
} = props,
|
|
96
110
|
rest = _objectWithoutProperties(props, _excluded);
|
|
97
111
|
const {
|
|
98
112
|
handlerSetValidatorFromComponent,
|
|
99
113
|
validatorFromComponent
|
|
100
114
|
} = (0, _react.useContext)(_helpers.withFieldContext);
|
|
115
|
+
const hasErrorsMessagesOnField = (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
116
|
+
fieldErrors: props.fieldErrors
|
|
117
|
+
}));
|
|
118
|
+
if (handleValidationErrorsOnTab) handleValidationErrorsOnTab({
|
|
119
|
+
name: name,
|
|
120
|
+
tabId: props.tabId,
|
|
121
|
+
hasErrors: !!hasErrorsMessagesOnField.length
|
|
122
|
+
});
|
|
101
123
|
return /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getEvents({
|
|
102
124
|
name,
|
|
103
125
|
validators,
|
|
@@ -105,7 +127,8 @@ const Field = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
105
127
|
validatorFromComponent,
|
|
106
128
|
handlerFieldValidate,
|
|
107
129
|
handlerFieldChange,
|
|
108
|
-
onChange
|
|
130
|
+
onChange,
|
|
131
|
+
component: Component
|
|
109
132
|
}), getCustomProps(props, handlerSetValidatorFromComponent), {
|
|
110
133
|
ref: ref,
|
|
111
134
|
name: name,
|
package/lib/form/FieldArray.js
CHANGED
|
@@ -10,7 +10,7 @@ var _withFieldHOC = _interopRequireDefault(require("./withFieldHOC"));
|
|
|
10
10
|
var _gridlayout = _interopRequireDefault(require("../gridlayout"));
|
|
11
11
|
var _fieldset = _interopRequireDefault(require("../fieldset"));
|
|
12
12
|
var _helpers = require("./helpers");
|
|
13
|
-
const _excluded = ["cols", "label", "bordered", "labelContainerStyle", "skipLabel", "data", "name", "handlerStoreValidators", "component", "handlerFieldChange", "handlerFieldValidate", "changePropName", "fieldErrors", "externalMessagesErrors", "handlerRemoveValidators", "validators", "valuePropName", "originalData", "handlerSelecionados"];
|
|
13
|
+
const _excluded = ["cols", "label", "bordered", "labelContainerStyle", "skipLabel", "data", "name", "handlerStoreValidators", "component", "handlerFieldChange", "handlerFieldValidate", "changePropName", "fieldErrors", "externalMessagesErrors", "handlerRemoveValidators", "validators", "valuePropName", "originalData", "handlerSelecionados", "handleValidationErrorsOnTab"];
|
|
14
14
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
15
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
@@ -69,10 +69,19 @@ const FieldArray = props => {
|
|
|
69
69
|
validators,
|
|
70
70
|
valuePropName,
|
|
71
71
|
originalData,
|
|
72
|
-
handlerSelecionados
|
|
72
|
+
handlerSelecionados,
|
|
73
|
+
handleValidationErrorsOnTab
|
|
73
74
|
} = props,
|
|
74
75
|
rest = _objectWithoutProperties(props, _excluded);
|
|
75
76
|
let content = null;
|
|
77
|
+
const hasErrorsMessagesOnField = (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
78
|
+
fieldErrors: props.fieldErrors
|
|
79
|
+
}));
|
|
80
|
+
if (handleValidationErrorsOnTab) handleValidationErrorsOnTab({
|
|
81
|
+
name: name,
|
|
82
|
+
tabId: props.tabId,
|
|
83
|
+
hasErrors: !!hasErrorsMessagesOnField.length
|
|
84
|
+
});
|
|
76
85
|
if (Component) {
|
|
77
86
|
if (!skipLabel && label) {
|
|
78
87
|
content = /*#__PURE__*/_react.default.createElement(_fieldset.default, {
|
package/lib/form/FieldNumber.js
CHANGED
|
@@ -55,9 +55,18 @@ const getEventProps = _ref => {
|
|
|
55
55
|
const FieldMask = props => {
|
|
56
56
|
const {
|
|
57
57
|
data,
|
|
58
|
-
name
|
|
58
|
+
name,
|
|
59
|
+
handleValidationErrorsOnTab
|
|
59
60
|
} = props;
|
|
60
61
|
const currentValue = _lodash.default.get(data, name);
|
|
62
|
+
const hasErrorsMessagesOnField = (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
63
|
+
fieldErrors: props.fieldErrors
|
|
64
|
+
}));
|
|
65
|
+
if (handleValidationErrorsOnTab) handleValidationErrorsOnTab({
|
|
66
|
+
name: name,
|
|
67
|
+
tabId: props.tabId,
|
|
68
|
+
hasErrors: !!hasErrorsMessagesOnField.length
|
|
69
|
+
});
|
|
61
70
|
return /*#__PURE__*/_react.default.createElement(props.component, _extends({}, props, getEventProps(_objectSpread({}, props)), {
|
|
62
71
|
errorMessages: (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
63
72
|
fieldErrors: props.fieldErrors
|
package/lib/form/FieldPeriod.js
CHANGED
|
@@ -12,6 +12,11 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
12
12
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
13
13
|
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 && {}.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; }
|
|
14
14
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : 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); }
|
|
15
20
|
const FieldPeriod = props => {
|
|
16
21
|
const {
|
|
17
22
|
data,
|
|
@@ -26,7 +31,8 @@ const FieldPeriod = props => {
|
|
|
26
31
|
originalData,
|
|
27
32
|
component: Component,
|
|
28
33
|
name,
|
|
29
|
-
externalFieldErrors
|
|
34
|
+
externalFieldErrors,
|
|
35
|
+
handleValidationErrorsOnTab
|
|
30
36
|
} = props;
|
|
31
37
|
let content = null;
|
|
32
38
|
const [showValidateMessages, setShowValidateMessages] = (0, _react.useState)(false);
|
|
@@ -45,6 +51,14 @@ const FieldPeriod = props => {
|
|
|
45
51
|
externalFieldErrors,
|
|
46
52
|
externalMessagesErrors
|
|
47
53
|
});
|
|
54
|
+
const hasErrorsMessagesOnField = (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
55
|
+
fieldErrors: props.fieldErrors
|
|
56
|
+
}));
|
|
57
|
+
if (handleValidationErrorsOnTab) handleValidationErrorsOnTab({
|
|
58
|
+
name: name,
|
|
59
|
+
tabId: props.tabId,
|
|
60
|
+
hasErrors: !!hasErrorsMessagesOnField.length
|
|
61
|
+
});
|
|
48
62
|
if (Component) {
|
|
49
63
|
content = /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
|
|
50
64
|
errorMessages: errorMessages,
|
package/lib/form/index.d.ts
CHANGED
|
@@ -13,6 +13,6 @@ import '../@types/Period.js';
|
|
|
13
13
|
import '../internals/types.js';
|
|
14
14
|
import '../@types/Position.js';
|
|
15
15
|
|
|
16
|
-
declare const Form: ({ submitOnPressEnterKey, dataSource, securityBeforeUnload, handlerReset, handlerSubmit, handlerValidates, style, customClass, securityTitle, securityText, securityData, onDataChange, onValidateForm, externalFieldErrors, onSubmit, skeletonize, disabled, children, useInternalState, }: FormProps) => JSX.Element;
|
|
16
|
+
declare const Form: ({ submitOnPressEnterKey, dataSource, securityBeforeUnload, handlerReset, handlerSubmit, handlerValidates, style, customClass, securityTitle, securityText, securityData, onDataChange, onValidateForm, externalFieldErrors, onSubmit, skeletonize, disabled, children, useInternalState, onValidateErrorsOnTab, }: FormProps) => JSX.Element;
|
|
17
17
|
|
|
18
18
|
export { Form as default };
|
package/lib/form/index.js
CHANGED
|
@@ -68,7 +68,8 @@ const Form = _ref => {
|
|
|
68
68
|
skeletonize,
|
|
69
69
|
disabled,
|
|
70
70
|
children,
|
|
71
|
-
useInternalState = false
|
|
71
|
+
useInternalState = false,
|
|
72
|
+
onValidateErrorsOnTab
|
|
72
73
|
} = _ref;
|
|
73
74
|
const formId = (0, _uuid.v1)();
|
|
74
75
|
const [data, setData] = (0, _react.useState)(dataSource);
|
|
@@ -80,6 +81,7 @@ const Form = _ref => {
|
|
|
80
81
|
const context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
|
|
81
82
|
const formRef = (0, _react.useRef)(null);
|
|
82
83
|
const fieldsValidators = (0, _react.useRef)({});
|
|
84
|
+
const tabsWithErrorRef = (0, _react.useRef)([]);
|
|
83
85
|
const usedData = useInternalState ? data : dataSource;
|
|
84
86
|
const getValidatesErrorMessages = (validators, fieldValue) => {
|
|
85
87
|
const validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
@@ -94,7 +96,7 @@ const Form = _ref => {
|
|
|
94
96
|
};
|
|
95
97
|
const getErrorMessages = (currentData, currentValidators) => {
|
|
96
98
|
const dataValidate = currentData || usedData;
|
|
97
|
-
let currentFieldErrors = _lodash.default.pickBy(fieldErrors, (
|
|
99
|
+
let currentFieldErrors = _lodash.default.pickBy(fieldErrors, (__, fieldName) => {
|
|
98
100
|
const fieldValidatorsNames = Object.keys(currentValidators);
|
|
99
101
|
return fieldValidatorsNames.includes(fieldName);
|
|
100
102
|
});
|
|
@@ -183,6 +185,23 @@ const Form = _ref => {
|
|
|
183
185
|
event.preventDefault();
|
|
184
186
|
if (_lodash.default.isEqual(usedData, originalData)) return;
|
|
185
187
|
};
|
|
188
|
+
const onValidateTabErrors = (0, _react.useCallback)(props => {
|
|
189
|
+
if (!props.tabId) return;
|
|
190
|
+
const tabIndex = [...tabsWithErrorRef.current].findIndex(tab => tab.name === props.name);
|
|
191
|
+
if (tabIndex !== -1) {
|
|
192
|
+
const novasTabs = [...tabsWithErrorRef.current];
|
|
193
|
+
novasTabs[tabIndex] = props;
|
|
194
|
+
tabsWithErrorRef.current = [...novasTabs];
|
|
195
|
+
} else {
|
|
196
|
+
tabsWithErrorRef.current = [...tabsWithErrorRef.current, props];
|
|
197
|
+
}
|
|
198
|
+
if (onValidateErrorsOnTab) {
|
|
199
|
+
const tabIdsWithErrors = _lodash.default.uniq(_lodash.default.compact(tabsWithErrorRef.current.map(tab => {
|
|
200
|
+
if (tab.hasErrors) return String(tab.tabId);
|
|
201
|
+
})));
|
|
202
|
+
onValidateErrorsOnTab(tabIdsWithErrors);
|
|
203
|
+
}
|
|
204
|
+
}, [onValidateErrorsOnTab]);
|
|
186
205
|
const formProps = () => {
|
|
187
206
|
let propsForm = null;
|
|
188
207
|
if (!disabled) {
|
|
@@ -213,7 +232,9 @@ const Form = _ref => {
|
|
|
213
232
|
if (onDataChange && useInternalState) onDataChange(usedData);
|
|
214
233
|
|
|
215
234
|
// TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
216
|
-
if (onValidateForm)
|
|
235
|
+
if (onValidateForm) {
|
|
236
|
+
onValidateForm(checkIsValid(usedData, true));
|
|
237
|
+
}
|
|
217
238
|
if (!disabled) {
|
|
218
239
|
handlerSubmit(onFormSubmit);
|
|
219
240
|
if (handlerReset) handlerReset(onReset);
|
|
@@ -229,10 +250,13 @@ const Form = _ref => {
|
|
|
229
250
|
}, [JSON.stringify(dataSource), useInternalState]);
|
|
230
251
|
(0, _react.useEffect)(() => {
|
|
231
252
|
if (securityBeforeUnload) {
|
|
232
|
-
if (context) context.setSecurityBeforeUnload(true);
|
|
253
|
+
if (Object.entries(context).length) context.setSecurityBeforeUnload(true);
|
|
233
254
|
window.addEventListener('beforeunload', onBeforeUnload);
|
|
234
255
|
}
|
|
235
|
-
return () =>
|
|
256
|
+
return () => {
|
|
257
|
+
if (securityBeforeUnload && Object.entries(context).length) context.setSecurityBeforeUnload(false);
|
|
258
|
+
window.removeEventListener('beforeunload', onBeforeUnload);
|
|
259
|
+
};
|
|
236
260
|
}, [securityBeforeUnload, onBeforeUnload]);
|
|
237
261
|
(0, _react.useEffect)(() => {
|
|
238
262
|
if (!disabled && submitOnPressEnterKey !== submitFormOnEnter) {
|
|
@@ -250,6 +274,7 @@ const Form = _ref => {
|
|
|
250
274
|
skeletonize,
|
|
251
275
|
handlerFieldChange: onFieldChange,
|
|
252
276
|
handlerFieldValidate: onValidate,
|
|
277
|
+
handleValidationErrorsOnTab: onValidateTabErrors,
|
|
253
278
|
handlerStoreValidators: (fieldName, fieldValidates) => {
|
|
254
279
|
fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, {
|
|
255
280
|
[fieldName]: fieldValidates
|
package/lib/form/types.d.ts
CHANGED
|
@@ -19,6 +19,11 @@ type OnFielChangeEvent = Event & {
|
|
|
19
19
|
type CustomKeyboardEvent = ChangeEvent<HTMLInputElement> & {
|
|
20
20
|
keyCode: number;
|
|
21
21
|
};
|
|
22
|
+
type PropsValidateTabErrors = {
|
|
23
|
+
name: string;
|
|
24
|
+
tabId?: string | number;
|
|
25
|
+
hasErrors: boolean;
|
|
26
|
+
};
|
|
22
27
|
type BaseFormProps = {
|
|
23
28
|
dataSource: object;
|
|
24
29
|
children: ReactNode;
|
|
@@ -27,6 +32,7 @@ type BaseFormProps = {
|
|
|
27
32
|
handlerReset?: (value: () => void) => void;
|
|
28
33
|
handlerValidates?: (value: any) => void;
|
|
29
34
|
onValidateForm?: (value: boolean) => void;
|
|
35
|
+
onValidateErrorsOnTab?: (tabIds: Array<string | number>) => void;
|
|
30
36
|
submitOnPressEnterKey?: boolean;
|
|
31
37
|
style?: CSSProperties;
|
|
32
38
|
customClass?: string;
|
|
@@ -95,6 +101,8 @@ interface IFieldProps extends WithFieldProps {
|
|
|
95
101
|
disabled?: boolean;
|
|
96
102
|
currencySymbol?: string;
|
|
97
103
|
checked?: boolean;
|
|
104
|
+
tabId?: string | number;
|
|
105
|
+
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
98
106
|
}
|
|
99
107
|
interface CustomEvent {
|
|
100
108
|
target: {
|
|
@@ -135,6 +143,7 @@ interface IFieldArrayProps extends WithFieldProps {
|
|
|
135
143
|
hintPosition?: 'below' | 'onLabelRight';
|
|
136
144
|
themePopover?: 'light' | 'dark';
|
|
137
145
|
popoverAlign?: 'right' | 'left';
|
|
146
|
+
tabId?: string | number;
|
|
138
147
|
}
|
|
139
148
|
type PeriodChangeEvent = {
|
|
140
149
|
initial: string;
|
|
@@ -172,6 +181,7 @@ interface IFieldPeriodProps extends WithFieldProps {
|
|
|
172
181
|
hintPosition?: 'below' | 'onLabelRight';
|
|
173
182
|
themePopover?: 'light' | 'dark';
|
|
174
183
|
popoverAlign?: 'right' | 'left';
|
|
184
|
+
tabId?: string | number;
|
|
175
185
|
}
|
|
176
186
|
interface FormContextProps {
|
|
177
187
|
skeletonize?: boolean;
|
|
@@ -184,6 +194,7 @@ interface FormContextProps {
|
|
|
184
194
|
fieldErrors: object;
|
|
185
195
|
externalFieldErrors?: object;
|
|
186
196
|
isFormValid?: boolean;
|
|
197
|
+
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
187
198
|
}
|
|
188
199
|
interface WithFieldProps {
|
|
189
200
|
name: string;
|
|
@@ -192,6 +203,7 @@ interface WithFieldProps {
|
|
|
192
203
|
handlerRemoveValidators?: (name: string) => void;
|
|
193
204
|
validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
|
|
194
205
|
customClass?: string;
|
|
206
|
+
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
195
207
|
}
|
|
196
208
|
interface IWithFieldContext {
|
|
197
209
|
validatorFromComponent: Validator | Validator[] | undefined;
|
|
@@ -240,4 +252,4 @@ type FieldValidator = {
|
|
|
240
252
|
[name: string]: Validator | Validator[];
|
|
241
253
|
};
|
|
242
254
|
|
|
243
|
-
export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, Validator, WithFieldProps };
|
|
255
|
+
export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, PropsValidateTabErrors, Validator, WithFieldProps };
|
package/lib/form/withFieldHOC.js
CHANGED
|
@@ -51,7 +51,8 @@ const withFieldHOC = WrappedComponent => {
|
|
|
51
51
|
externalFieldErrors,
|
|
52
52
|
handlerStoreValidators,
|
|
53
53
|
handlerRemoveValidators,
|
|
54
|
-
skeletonize
|
|
54
|
+
skeletonize,
|
|
55
|
+
handleValidationErrorsOnTab
|
|
55
56
|
} = _ref;
|
|
56
57
|
return /*#__PURE__*/_react.default.createElement(EnhancedComponent, _extends({}, props, {
|
|
57
58
|
skeletonize: skeletonize,
|
|
@@ -62,7 +63,8 @@ const withFieldHOC = WrappedComponent => {
|
|
|
62
63
|
data: data,
|
|
63
64
|
fieldErrors: fieldErrors,
|
|
64
65
|
externalFieldErrors: externalFieldErrors,
|
|
65
|
-
forwardedRef: ref
|
|
66
|
+
forwardedRef: ref,
|
|
67
|
+
handleValidationErrorsOnTab: handleValidationErrorsOnTab
|
|
66
68
|
}));
|
|
67
69
|
});
|
|
68
70
|
}
|