linear-react-components-ui 1.1.3 → 1.1.4
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/.eslintcache +1 -1
- package/lib/alerts/Message.d.ts +1 -1
- package/lib/alerts/Message.js +50 -7
- package/lib/alerts/types.d.ts +1 -0
- package/lib/assets/styles/alerts.scss +4 -7
- package/lib/assets/styles/button.scss +11 -9
- package/lib/assets/styles/table.scss +9 -1
- package/lib/buttons/DefaultButton.js +29 -11
- package/lib/buttons/types.d.ts +1 -0
- package/lib/checkbox/index.js +1 -1
- package/lib/form/FieldArray.js +12 -26
- package/lib/form/index.js +6 -7
- package/lib/form/types.d.ts +3 -2
- package/lib/inputs/mask/Cpf.js +0 -1
- package/lib/internals/types.d.ts +5 -2
- package/lib/internals/withTooltip.d.ts +3 -2
- package/lib/internals/withTooltip.js +19 -8
- package/lib/list/Item.js +24 -5
- package/lib/table/HeaderColumn.d.ts +1 -1
- package/lib/table/HeaderColumn.js +13 -3
- package/lib/table/RowColumn.js +6 -8
- package/lib/table/types.d.ts +1 -0
- package/lib/toolbar/types.d.ts +1 -0
- package/lib/uitour/index.d.ts +2 -1
- package/lib/uitour/index.js +57 -4
- package/lib/uitour/types.d.ts +9 -1
- package/package.json +4 -4
package/lib/alerts/Message.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ import '../@types/PositionAlert.js';
|
|
|
4
4
|
import '../@types/Icon.js';
|
|
5
5
|
import '../icons/helper.js';
|
|
6
6
|
|
|
7
|
-
declare const Message: ({ handleClose, message, id, color, icon, iconName, timeout, customClass, closeButton, className, position, }: IMessageProps) => JSX.Element;
|
|
7
|
+
declare const Message: ({ handleClose, message, id, color, icon, iconName, timeout, customClass, closeButton, className, position, pauseTimeoutOnMouseHover, }: IMessageProps) => JSX.Element;
|
|
8
8
|
|
|
9
9
|
export { Message as default };
|
package/lib/alerts/Message.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _icons = _interopRequireDefault(require("../icons"));
|
|
9
|
+
var _progress = _interopRequireDefault(require("../progress"));
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
11
|
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); }
|
|
11
12
|
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; }
|
|
@@ -40,16 +41,58 @@ const Message = _ref2 => {
|
|
|
40
41
|
customClass = '',
|
|
41
42
|
closeButton = false,
|
|
42
43
|
className = 'message',
|
|
43
|
-
position = 'centerTop'
|
|
44
|
+
position = 'centerTop',
|
|
45
|
+
pauseTimeoutOnMouseHover = false
|
|
44
46
|
} = _ref2;
|
|
47
|
+
const [progressBarTime, setProgressBarTime] = (0, _react.useState)(timeout - 300);
|
|
48
|
+
const [pauseTimeout, setPauseTimeout] = (0, _react.useState)(false);
|
|
49
|
+
const timeoutIdentifier = (0, _react.useRef)(null);
|
|
50
|
+
const intervalIdentifier = (0, _react.useRef)(null);
|
|
51
|
+
const handleMouseEnter = () => {
|
|
52
|
+
if (pauseTimeoutOnMouseHover) {
|
|
53
|
+
setPauseTimeout(true);
|
|
54
|
+
setProgressBarTime(prevProgressBarTime => prevProgressBarTime >= 800 ? prevProgressBarTime + 600 : prevProgressBarTime + 500);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const handleMouseLeave = () => {
|
|
58
|
+
if (pauseTimeoutOnMouseHover) {
|
|
59
|
+
setPauseTimeout(false);
|
|
60
|
+
setProgressBarTime(prevProgressBarTime => prevProgressBarTime >= 800 ? prevProgressBarTime - 600 : prevProgressBarTime - 500);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const getProgressBarType = () => customClass.replace('-', '');
|
|
45
64
|
(0, _react.useEffect)(() => {
|
|
46
|
-
if (
|
|
47
|
-
setTimeout(() => {
|
|
65
|
+
if (!pauseTimeout && progressBarTime > 0) {
|
|
66
|
+
timeoutIdentifier.current = setTimeout(() => {
|
|
48
67
|
handleClose(id, position);
|
|
49
|
-
},
|
|
68
|
+
}, progressBarTime);
|
|
69
|
+
intervalIdentifier.current = setInterval(() => progressBarTime > 0 ? setProgressBarTime(prevProgressBarTime => prevProgressBarTime > 0 ? prevProgressBarTime - 100 : 0) : null, 100);
|
|
70
|
+
} else {
|
|
71
|
+
if (timeoutIdentifier.current) clearInterval(timeoutIdentifier.current);
|
|
72
|
+
if (intervalIdentifier.current) clearInterval(intervalIdentifier.current);
|
|
50
73
|
}
|
|
51
|
-
|
|
74
|
+
return () => {
|
|
75
|
+
if (timeoutIdentifier.current) clearInterval(timeoutIdentifier.current);
|
|
76
|
+
if (intervalIdentifier.current) clearInterval(intervalIdentifier.current);
|
|
77
|
+
};
|
|
78
|
+
}, [pauseTimeout]);
|
|
52
79
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
+
onMouseEnter: handleMouseEnter,
|
|
81
|
+
onMouseLeave: handleMouseLeave
|
|
82
|
+
}, timeout > 0 && /*#__PURE__*/_react.default.createElement(_progress.default, {
|
|
83
|
+
min: 300,
|
|
84
|
+
max: timeout,
|
|
85
|
+
value: progressBarTime,
|
|
86
|
+
showLabel: false,
|
|
87
|
+
style: {
|
|
88
|
+
animation: 'tinRightIn 1s forwards ease-in-out',
|
|
89
|
+
margin: '0px',
|
|
90
|
+
borderRadius: '0px',
|
|
91
|
+
backgroundColor: 'rgb(234 234 234)'
|
|
92
|
+
},
|
|
93
|
+
height: "6px",
|
|
94
|
+
type: getProgressBarType()
|
|
95
|
+
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
53
96
|
className: getClass({
|
|
54
97
|
className,
|
|
55
98
|
customClass
|
|
@@ -58,7 +101,7 @@ const Message = _ref2 => {
|
|
|
58
101
|
className: "-icon"
|
|
59
102
|
}, (icon || iconName || color) && getIcon(icon, iconName, color)), /*#__PURE__*/_react.default.createElement("div", {
|
|
60
103
|
className: "-messagecontent"
|
|
61
|
-
}, message), /*#__PURE__*/_react.default.createElement("div", {
|
|
104
|
+
}, /*#__PURE__*/_react.default.createElement("p", null, message)), /*#__PURE__*/_react.default.createElement("div", {
|
|
62
105
|
className: "close"
|
|
63
106
|
}, closeButton || timeout === 0 ? /*#__PURE__*/_react.default.createElement("span", {
|
|
64
107
|
className: "close-button",
|
|
@@ -66,6 +109,6 @@ const Message = _ref2 => {
|
|
|
66
109
|
onKeyPress: () => {},
|
|
67
110
|
tabIndex: -1,
|
|
68
111
|
onClick: () => handleClose !== undefined ? handleClose(id, position) : null
|
|
69
|
-
}, "x") : null));
|
|
112
|
+
}, "x") : null)));
|
|
70
113
|
};
|
|
71
114
|
var _default = exports.default = Message;
|
package/lib/alerts/types.d.ts
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
.alert-component {
|
|
9
9
|
position: fixed;
|
|
10
10
|
z-index: 9999999;
|
|
11
|
-
pointer-events: none;
|
|
12
11
|
> .messagecontainer {
|
|
13
12
|
height: 100%;
|
|
14
13
|
> .lefttop, > .leftbottom, > .rightbottom, .righttop, .centertop, .centerbottom {
|
|
15
14
|
position: fixed;
|
|
16
|
-
width:
|
|
15
|
+
width: auto;
|
|
16
|
+
min-width: 20%;
|
|
17
|
+
max-width: 25%;
|
|
17
18
|
}
|
|
18
19
|
> .lefttop {
|
|
19
20
|
left: 0;
|
|
@@ -53,15 +54,11 @@
|
|
|
53
54
|
> .rightbottom {
|
|
54
55
|
right: 0;
|
|
55
56
|
bottom: 0;
|
|
56
|
-
&:hover {
|
|
57
|
-
opacity: 0.3!important;
|
|
58
|
-
background-color: #E0CABB;
|
|
59
|
-
}
|
|
60
57
|
}
|
|
61
58
|
}
|
|
62
59
|
.message {
|
|
63
60
|
display: flex;
|
|
64
|
-
flex-wrap:
|
|
61
|
+
flex-wrap: wrap;
|
|
65
62
|
width: 100%;
|
|
66
63
|
height: 100%;
|
|
67
64
|
min-height: 80px;
|
|
@@ -38,13 +38,14 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
38
38
|
@extend %component-splash-click;
|
|
39
39
|
content: "";
|
|
40
40
|
position: absolute;
|
|
41
|
-
top: 50
|
|
42
|
-
left: 50
|
|
41
|
+
top: 50% !important;
|
|
42
|
+
left: 50% !important;
|
|
43
43
|
display: block;
|
|
44
|
-
width: 0;
|
|
45
44
|
padding-top: 0;
|
|
46
45
|
border-radius: 100%;
|
|
47
46
|
background-color: rgba(236, 240, 241, 0.3);
|
|
47
|
+
width: 0;
|
|
48
|
+
height: 0 !important;
|
|
48
49
|
}
|
|
49
50
|
> .icon-component {
|
|
50
51
|
width: 15px;
|
|
@@ -69,7 +70,7 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
69
70
|
&:active:before {
|
|
70
71
|
@extend %component-effect-click;
|
|
71
72
|
}
|
|
72
|
-
&:hover {
|
|
73
|
+
&:hover, &[data-uitour="hover"] {
|
|
73
74
|
background-color: $default-hover-color;
|
|
74
75
|
}
|
|
75
76
|
&:focus {
|
|
@@ -102,6 +103,7 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
102
103
|
@extend %component-disabled;
|
|
103
104
|
opacity: 0.7;
|
|
104
105
|
border: solid 1px $font-color-disabled;
|
|
106
|
+
pointer-events: auto;
|
|
105
107
|
}
|
|
106
108
|
&.-shadowsdisabled {
|
|
107
109
|
box-shadow: none!important;
|
|
@@ -162,7 +164,7 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
162
164
|
border: 1px solid $primary-border-color;
|
|
163
165
|
text-shadow: $shadow-text-button;
|
|
164
166
|
@extend %color-effects;
|
|
165
|
-
&:hover {
|
|
167
|
+
&:hover, &[data-uitour="hover"] {
|
|
166
168
|
background-color: $primary-hover-color;
|
|
167
169
|
}
|
|
168
170
|
&:focus {
|
|
@@ -201,7 +203,7 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
201
203
|
border: 1px solid $warning-color;
|
|
202
204
|
text-shadow: $shadow-text-button;
|
|
203
205
|
@extend %color-effects;
|
|
204
|
-
&:hover {
|
|
206
|
+
&:hover, &[data-uitour="hover"] {
|
|
205
207
|
background-color: $warning-hover-color;
|
|
206
208
|
}
|
|
207
209
|
&:focus {
|
|
@@ -220,7 +222,7 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
220
222
|
text-shadow: $shadow-text-button;
|
|
221
223
|
@extend %color-effects;
|
|
222
224
|
color: $font-color-second;
|
|
223
|
-
&:hover {
|
|
225
|
+
&:hover, &[data-uitour="hover"] {
|
|
224
226
|
background-color: $danger-hover-color;
|
|
225
227
|
}
|
|
226
228
|
&:focus {
|
|
@@ -239,7 +241,7 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
239
241
|
text-shadow: $shadow-text-button;
|
|
240
242
|
@extend %color-effects;
|
|
241
243
|
color: $font-color-second;
|
|
242
|
-
&:hover {
|
|
244
|
+
&:hover, &[data-uitour="hover"] {
|
|
243
245
|
background-color: $success-hover-color;
|
|
244
246
|
color: $font-color-second;
|
|
245
247
|
}
|
|
@@ -259,7 +261,7 @@ $shadow-button-inset-default: inset 0 0 0 1px $default-border-color, $shadow-but
|
|
|
259
261
|
text-shadow: $shadow-text-button;
|
|
260
262
|
@extend %color-effects;
|
|
261
263
|
color: $font-color-second;
|
|
262
|
-
&:hover {
|
|
264
|
+
&:hover, &[data-uitour="hover"] {
|
|
263
265
|
background-color: $info-hover-color;
|
|
264
266
|
color: $font-color-second;
|
|
265
267
|
}
|
|
@@ -58,11 +58,19 @@
|
|
|
58
58
|
&.-noborder {
|
|
59
59
|
border-bottom: 0;
|
|
60
60
|
}
|
|
61
|
+
&.menu-column {
|
|
62
|
+
width: 100px;
|
|
63
|
+
text-align: center;
|
|
64
|
+
svg {
|
|
65
|
+
margin-left: 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
> .bodycontainer > .innertable > .tbody > .trow,
|
|
64
71
|
> .tbody > .trow {
|
|
65
|
-
&.-selected
|
|
72
|
+
&.-selected,
|
|
73
|
+
&[data-uitour="selected"] {
|
|
66
74
|
background-color: $component-bg-selected-color !important;
|
|
67
75
|
color: $font-selected-color;
|
|
68
76
|
}
|
|
@@ -7,11 +7,11 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
9
9
|
var _icons = _interopRequireDefault(require("../../lib/icons"));
|
|
10
|
-
var _withTooltip =
|
|
10
|
+
var _withTooltip = _interopRequireWildcard(require("../internals/withTooltip"));
|
|
11
11
|
var _spinner = _interopRequireDefault(require("../spinner"));
|
|
12
12
|
var _withDropdown = _interopRequireDefault(require("../dropdown/withDropdown"));
|
|
13
13
|
var _permissionValidations = require("../permissionValidations");
|
|
14
|
-
const _excluded = ["dropdown", "onClick", "disabled", "iconName", "icon", "targetRef", "tabIndex", "isLoading", "label", "showDropdown", "getDropdownPopup", "isDropdownOpened", "showIconDropdown", "content", "style", "toggleable", "activeIconColor", "iconStyle", "visible", "customClass", "className", "size", "iconAlign", "boxShadow", "transparent", "round", "permissionAttr", "skeletonize", "
|
|
14
|
+
const _excluded = ["dropdown", "onClick", "disabled", "iconName", "icon", "targetRef", "tabIndex", "isLoading", "label", "showDropdown", "getDropdownPopup", "isDropdownOpened", "showIconDropdown", "content", "style", "toggleable", "activeIconColor", "iconStyle", "visible", "customClass", "className", "size", "iconAlign", "boxShadow", "transparent", "round", "permissionAttr", "skeletonize", "errorMessage", "tooltipWidth", "isFloatMenu", "dropdownAlign", "customClassForDropdown", "buttonRef", "onDeniedText"];
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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); }
|
|
17
17
|
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; }
|
|
@@ -53,13 +53,13 @@ const DefaultButton = _ref => {
|
|
|
53
53
|
round,
|
|
54
54
|
permissionAttr,
|
|
55
55
|
skeletonize,
|
|
56
|
-
tooltipPosition,
|
|
57
56
|
errorMessage,
|
|
58
57
|
tooltipWidth,
|
|
59
58
|
isFloatMenu,
|
|
60
59
|
dropdownAlign,
|
|
61
60
|
customClassForDropdown,
|
|
62
|
-
buttonRef
|
|
61
|
+
buttonRef,
|
|
62
|
+
onDeniedText = 'Permissão Negada! Consulte o Administrador do sistema.'
|
|
63
63
|
} = _ref,
|
|
64
64
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
65
65
|
const options = [_permissionValidations.OPTIONS_ON_DENIED.disabled, _permissionValidations.OPTIONS_ON_DENIED.unvisible];
|
|
@@ -67,18 +67,30 @@ const DefaultButton = _ref => {
|
|
|
67
67
|
const [onDenied] = (0, _react.useState)((0, _permissionValidations.actionsOnPermissionDenied)(options, permissionAttr));
|
|
68
68
|
const refButton = (0, _react.useRef)(null);
|
|
69
69
|
const disabledIconColor = 'rgb(193, 193, 193)';
|
|
70
|
-
const
|
|
71
|
-
const
|
|
70
|
+
const disabledByPermission = onDenied.disabled;
|
|
71
|
+
const isDisabled = !!onDenied.disabled || disabled;
|
|
72
|
+
const {
|
|
73
|
+
handlerSetOnDeniedText
|
|
74
|
+
} = (0, _react.useContext)(_withTooltip.TooltipContext);
|
|
75
|
+
const getClass = () => "button-component ".concat(className, "\n ").concat(customClass, "\n ").concat(transparent && '-transparent', "\n ").concat(isDisabled && '-disabled', "\n ").concat(size && "-".concat(size), "\n ").concat(dropdown && !round && 'icon-right', "\n ").concat(dropdown && round && 'icon-center', "\n ").concat(iconAlign && !dropdown && "icon-".concat(iconAlign), "\n ").concat(boxShadow ? '' : '-shadowsdisabled', "\n ").concat(round && '-round');
|
|
76
|
+
const returnPadlockIcon = resultantStyle => /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
77
|
+
name: "padlock",
|
|
78
|
+
size: 16,
|
|
79
|
+
pointerEvents: "none",
|
|
80
|
+
color: disabledIconColor,
|
|
81
|
+
style: resultantStyle
|
|
82
|
+
});
|
|
72
83
|
const getIcon = () => {
|
|
73
84
|
let resultantStyle = iconStyle;
|
|
74
|
-
if (
|
|
85
|
+
if (isDisabled) {
|
|
75
86
|
resultantStyle = _objectSpread(_objectSpread({}, resultantStyle), {}, {
|
|
76
87
|
fill: disabledIconColor
|
|
77
88
|
});
|
|
78
89
|
}
|
|
79
90
|
if (dropdown && showIconDropdown) {
|
|
91
|
+
const openDropDownRule = isDropdownOpened ? 'mini_up' : 'mini_down';
|
|
80
92
|
return /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
81
|
-
name:
|
|
93
|
+
name: openDropDownRule,
|
|
82
94
|
size: 16,
|
|
83
95
|
customClass: "dropdown-icon",
|
|
84
96
|
pointerEvents: "none",
|
|
@@ -86,12 +98,16 @@ const DefaultButton = _ref => {
|
|
|
86
98
|
});
|
|
87
99
|
}
|
|
88
100
|
if (icon) {
|
|
89
|
-
if (
|
|
101
|
+
if (disabledByPermission) {
|
|
102
|
+
return returnPadlockIcon(resultantStyle);
|
|
103
|
+
} else if (disabled) {
|
|
90
104
|
return /*#__PURE__*/_react.default.createElement(_icons.default, _extends({}, icon.props, {
|
|
91
105
|
color: disabledIconColor
|
|
92
106
|
}));
|
|
93
107
|
}
|
|
94
108
|
return icon;
|
|
109
|
+
} else if (!icon && disabledByPermission) {
|
|
110
|
+
return returnPadlockIcon(resultantStyle);
|
|
95
111
|
} else if (iconName) {
|
|
96
112
|
return /*#__PURE__*/_react.default.createElement(_icons.default, {
|
|
97
113
|
name: iconName,
|
|
@@ -103,16 +119,18 @@ const DefaultButton = _ref => {
|
|
|
103
119
|
}
|
|
104
120
|
return null;
|
|
105
121
|
};
|
|
122
|
+
(0, _react.useEffect)(() => {
|
|
123
|
+
if (disabledByPermission) handlerSetOnDeniedText(onDeniedText);
|
|
124
|
+
}, [disabledByPermission]);
|
|
106
125
|
if (!visible || onDenied.unvisible) return null;
|
|
107
126
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("button", _extends({}, rest, {
|
|
108
127
|
style: style,
|
|
109
128
|
onClick: e => {
|
|
110
|
-
if (
|
|
129
|
+
if (isDisabled) return;
|
|
111
130
|
if (onClick) onClick(e);
|
|
112
131
|
if (dropdown && showDropdown) showDropdown();
|
|
113
132
|
if (onClick && toggleable) setActiveButton(!activeButton);
|
|
114
133
|
},
|
|
115
|
-
disabled: shouldDisable(),
|
|
116
134
|
className: "".concat(getClass(), " ").concat(activeButton ? '-toggleable' : '', " ").concat(skeletonize ? '-skeletonized' : ''),
|
|
117
135
|
ref: r => {
|
|
118
136
|
if (buttonRef) {
|
package/lib/buttons/types.d.ts
CHANGED
package/lib/checkbox/index.js
CHANGED
|
@@ -81,6 +81,7 @@ const CheckBox = _ref => {
|
|
|
81
81
|
"aria-checked": "false",
|
|
82
82
|
onKeyPress: undefined
|
|
83
83
|
}, /*#__PURE__*/_react.default.createElement("input", {
|
|
84
|
+
id: id || undefined,
|
|
84
85
|
ref: r => {
|
|
85
86
|
if (targetRef) targetRef(r);
|
|
86
87
|
inputRef.current = r;
|
|
@@ -93,7 +94,6 @@ const CheckBox = _ref => {
|
|
|
93
94
|
name: name,
|
|
94
95
|
required: required,
|
|
95
96
|
value: value,
|
|
96
|
-
id: id,
|
|
97
97
|
onChange: () => {}
|
|
98
98
|
}), /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_.Icon, {
|
|
99
99
|
size: 12,
|
package/lib/form/FieldArray.js
CHANGED
|
@@ -10,7 +10,8 @@ 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", "handlerFieldValidade", "changePropName", "fieldErrors", "externalMessagesErrors", "handlerRemoveValidators", "validators", "valuePropName", "originalData"];
|
|
13
|
+
const _excluded = ["cols", "label", "bordered", "labelContainerStyle", "skipLabel", "data", "name", "handlerStoreValidators", "component", "handlerFieldChange", "handlerFieldValidade", "changePropName", "fieldErrors", "externalMessagesErrors", "handlerRemoveValidators", "validators", "valuePropName", "originalData", "handlerSelecionados"];
|
|
14
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
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); }
|
|
16
17
|
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; }
|
|
@@ -33,12 +34,12 @@ const getDefaultProps = (props, handleShowValidateMessages) => {
|
|
|
33
34
|
onBlur
|
|
34
35
|
} = props;
|
|
35
36
|
return {
|
|
36
|
-
onBlur: e => {
|
|
37
|
+
onBlur: (0, _react.useCallback)(e => {
|
|
37
38
|
if (handleShowValidateMessages) handleShowValidateMessages(true);
|
|
38
39
|
if (onBlur) onBlur(e);
|
|
39
|
-
},
|
|
40
|
+
}, [handleShowValidateMessages, onBlur]),
|
|
40
41
|
[valuePropName]: _lodash.default.get(data, name),
|
|
41
|
-
[changePropName]: ids => {
|
|
42
|
+
[changePropName]: (0, _react.useCallback)(ids => {
|
|
42
43
|
if (handlerFieldChange) handlerFieldChange({
|
|
43
44
|
target: {
|
|
44
45
|
value: ids,
|
|
@@ -47,19 +48,7 @@ const getDefaultProps = (props, handleShowValidateMessages) => {
|
|
|
47
48
|
});
|
|
48
49
|
if (handlerSelecionados) handlerSelecionados(ids);
|
|
49
50
|
if (handleShowValidateMessages) handleShowValidateMessages(true);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
const getEvents = _ref => {
|
|
54
|
-
let {
|
|
55
|
-
onBlur,
|
|
56
|
-
handleShowValidateMessages
|
|
57
|
-
} = _ref;
|
|
58
|
-
return {
|
|
59
|
-
onBlur: e => {
|
|
60
|
-
handleShowValidateMessages(true);
|
|
61
|
-
if (onBlur) onBlur(e);
|
|
62
|
-
}
|
|
51
|
+
}, [handlerFieldChange, handlerSelecionados, handleShowValidateMessages, changePropName])
|
|
63
52
|
};
|
|
64
53
|
};
|
|
65
54
|
const FieldArray = props => {
|
|
@@ -81,15 +70,16 @@ const FieldArray = props => {
|
|
|
81
70
|
handlerRemoveValidators,
|
|
82
71
|
validators,
|
|
83
72
|
valuePropName,
|
|
84
|
-
originalData
|
|
73
|
+
originalData,
|
|
74
|
+
handlerSelecionados
|
|
85
75
|
} = props,
|
|
86
76
|
rest = _objectWithoutProperties(props, _excluded);
|
|
87
77
|
const [showValidateMessages, setShowValidateMessages] = (0, _react.useState)(false);
|
|
88
78
|
const currentValue = _lodash.default.get(data, name);
|
|
89
79
|
const originalValue = _lodash.default.get(originalData, name);
|
|
90
|
-
const handleShowValidateMessages = value => {
|
|
80
|
+
const handleShowValidateMessages = (0, _react.useCallback)(value => {
|
|
91
81
|
setShowValidateMessages(value);
|
|
92
|
-
};
|
|
82
|
+
}, []);
|
|
93
83
|
(0, _react.useEffect)(() => {
|
|
94
84
|
if (!_lodash.default.isEqual(currentValue, originalValue) && Array.isArray(currentValue) && currentValue.length > 0) {
|
|
95
85
|
setShowValidateMessages(true);
|
|
@@ -105,9 +95,7 @@ const FieldArray = props => {
|
|
|
105
95
|
customClass: "arraycontainer ".concat(bordered && '-bordered'),
|
|
106
96
|
style: labelContainerStyle,
|
|
107
97
|
titleCustomClass: "label"
|
|
108
|
-
}, /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getDefaultProps(props, handleShowValidateMessages),
|
|
109
|
-
handleShowValidateMessages: value => setShowValidateMessages(value)
|
|
110
|
-
})), {
|
|
98
|
+
}, /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getDefaultProps(props, handleShowValidateMessages), {
|
|
111
99
|
label: label,
|
|
112
100
|
name: name,
|
|
113
101
|
errorMessages: (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -115,9 +103,7 @@ const FieldArray = props => {
|
|
|
115
103
|
}))
|
|
116
104
|
})));
|
|
117
105
|
} else {
|
|
118
|
-
content = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getDefaultProps(props, handleShowValidateMessages),
|
|
119
|
-
handleShowValidateMessages: value => setShowValidateMessages(value)
|
|
120
|
-
})), {
|
|
106
|
+
content = /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getDefaultProps(props, handleShowValidateMessages), {
|
|
121
107
|
label: label,
|
|
122
108
|
name: name,
|
|
123
109
|
errorMessages: (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
package/lib/form/index.js
CHANGED
|
@@ -110,17 +110,16 @@ const Form = _ref => {
|
|
|
110
110
|
if (updateState) setFieldErrors(currentFieldErrors);
|
|
111
111
|
return Object.values(currentFieldErrors).every(value => value.length === 0);
|
|
112
112
|
};
|
|
113
|
-
const onFieldChange = event => {
|
|
113
|
+
const onFieldChange = (0, _react.useCallback)(event => {
|
|
114
114
|
const {
|
|
115
115
|
target
|
|
116
116
|
} = event;
|
|
117
117
|
if (!useInternalState && onDataChange) {
|
|
118
|
-
|
|
119
|
-
onDataChange(newData);
|
|
118
|
+
onDataChange(prevState => (0, _helpers.changeValue)(prevState, target));
|
|
120
119
|
} else {
|
|
121
120
|
setData(prevState => (0, _helpers.changeValue)(prevState, target));
|
|
122
121
|
}
|
|
123
|
-
};
|
|
122
|
+
}, []);
|
|
124
123
|
const onValidate = (fieldName, fieldValue, validators) => {
|
|
125
124
|
if (validators) {
|
|
126
125
|
let currentFieldErrors = fieldErrors;
|
|
@@ -135,10 +134,10 @@ const Form = _ref => {
|
|
|
135
134
|
setFieldErrors(currentFieldErrors);
|
|
136
135
|
}
|
|
137
136
|
};
|
|
138
|
-
const onFormSubmit = event => {
|
|
137
|
+
const onFormSubmit = (0, _react.useCallback)(event => {
|
|
139
138
|
if (event) event.preventDefault();
|
|
140
139
|
if (checkIsValid(usedData)) onSubmit(usedData);
|
|
141
|
-
};
|
|
140
|
+
}, [usedData]);
|
|
142
141
|
const onReset = () => {
|
|
143
142
|
if (!useInternalState && onDataChange) {
|
|
144
143
|
onDataChange(JSON.parse(JSON.stringify(originalData)));
|
|
@@ -186,7 +185,7 @@ const Form = _ref => {
|
|
|
186
185
|
onChangedData(false);
|
|
187
186
|
}
|
|
188
187
|
}
|
|
189
|
-
if (onDataChange) onDataChange(usedData);
|
|
188
|
+
if (onDataChange && useInternalState) onDataChange(usedData);
|
|
190
189
|
|
|
191
190
|
// TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
192
191
|
if (onValidateForm) onValidateForm(checkIsValid(usedData, true));
|
package/lib/form/types.d.ts
CHANGED
|
@@ -38,12 +38,13 @@ type BaseFormProps = {
|
|
|
38
38
|
skeletonize?: boolean;
|
|
39
39
|
disabled?: boolean;
|
|
40
40
|
};
|
|
41
|
+
type OnDataChange = React.Dispatch<React.SetStateAction<any>>;
|
|
41
42
|
type FormProps = BaseFormProps & ({
|
|
42
43
|
useInternalState?: false;
|
|
43
|
-
onDataChange:
|
|
44
|
+
onDataChange: OnDataChange;
|
|
44
45
|
} | {
|
|
45
46
|
useInternalState: true;
|
|
46
|
-
onDataChange?:
|
|
47
|
+
onDataChange?: OnDataChange;
|
|
47
48
|
});
|
|
48
49
|
type Data = {
|
|
49
50
|
[key: string]: any;
|
package/lib/inputs/mask/Cpf.js
CHANGED
|
@@ -30,7 +30,6 @@ const CpfField = props => {
|
|
|
30
30
|
}, 300), [handlerSetComponentValidator]);
|
|
31
31
|
(0, _react.useEffect)(() => debouncedOnChange.cancel, []);
|
|
32
32
|
const onChange = e => {
|
|
33
|
-
// console.log('onChange >>>', props.onChange);
|
|
34
33
|
if (enableValidation && e) {
|
|
35
34
|
debouncedOnChange(e.target.value);
|
|
36
35
|
if (props.onChange) props.onChange(e);
|
package/lib/internals/types.d.ts
CHANGED
|
@@ -8,9 +8,12 @@ interface WithTooltipProps {
|
|
|
8
8
|
tooltip?: string;
|
|
9
9
|
tooltipPosition?: Exclude<Position, 'center'>;
|
|
10
10
|
style?: CSSProperties;
|
|
11
|
-
|
|
11
|
+
handlerSetOnDeniedText?: (onDeniedValue: OnDenied) => void;
|
|
12
12
|
errorMessage?: string;
|
|
13
13
|
}
|
|
14
|
+
interface ITooltipContext {
|
|
15
|
+
handlerSetOnDeniedText: (text: string) => void;
|
|
16
|
+
}
|
|
14
17
|
interface GetDisplayNameParams {
|
|
15
18
|
displayName?: string;
|
|
16
19
|
name?: string;
|
|
@@ -19,4 +22,4 @@ interface HasToolTipParams {
|
|
|
19
22
|
tooltip?: string;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
export { GetDisplayNameParams, HasToolTipParams, WithTooltipProps };
|
|
25
|
+
export { GetDisplayNameParams, HasToolTipParams, ITooltipContext, WithTooltipProps };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React__default from 'react';
|
|
2
|
-
import { WithTooltipProps } from './types.js';
|
|
2
|
+
import { ITooltipContext, WithTooltipProps } from './types.js';
|
|
3
3
|
import '../@types/PermissionAttr.js';
|
|
4
4
|
import '../@types/Position.js';
|
|
5
5
|
|
|
6
|
+
declare const TooltipContext: React__default.Context<ITooltipContext>;
|
|
6
7
|
declare const withTooltip: <ComponentProps extends WithTooltipProps>(WrappedComponent: React__default.ComponentType<ComponentProps>) => {
|
|
7
8
|
(props: ComponentProps): JSX.Element;
|
|
8
9
|
displayName: string;
|
|
9
10
|
};
|
|
10
11
|
|
|
11
|
-
export { withTooltip as default };
|
|
12
|
+
export { TooltipContext, withTooltip as default };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.default = exports.TooltipContext = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _tooltip = _interopRequireDefault(require("../tooltip"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -17,6 +17,7 @@ const hasTooltip = _ref => {
|
|
|
17
17
|
} = _ref;
|
|
18
18
|
return tooltip;
|
|
19
19
|
};
|
|
20
|
+
const TooltipContext = exports.TooltipContext = /*#__PURE__*/_react.default.createContext({});
|
|
20
21
|
const getDisplayName = _ref2 => {
|
|
21
22
|
let {
|
|
22
23
|
displayName,
|
|
@@ -34,6 +35,7 @@ const withTooltip = WrappedComponent => {
|
|
|
34
35
|
errorMessage
|
|
35
36
|
} = props;
|
|
36
37
|
const [stateTooltipPosition, setStateTooltipPosition] = (0, _react.useState)(tooltipPosition);
|
|
38
|
+
const [onDeniedText, setOnDeniedText] = (0, _react.useState)('');
|
|
37
39
|
const [tooltipStyle, setTooltipStyle] = (0, _react.useState)('');
|
|
38
40
|
const [showTooltip, setShowTooltip] = (0, _react.useState)(false);
|
|
39
41
|
const [tooltipDimensions, setTooltipDimensions] = (0, _react.useState)({
|
|
@@ -54,7 +56,7 @@ const withTooltip = WrappedComponent => {
|
|
|
54
56
|
setShowTooltip(false);
|
|
55
57
|
};
|
|
56
58
|
(0, _react.useEffect)(() => {
|
|
57
|
-
if (hasTooltip(props)) {
|
|
59
|
+
if (hasTooltip(props) || onDeniedText) {
|
|
58
60
|
if (errorMessage) {
|
|
59
61
|
setShowTooltip(true);
|
|
60
62
|
} else {
|
|
@@ -67,7 +69,7 @@ const withTooltip = WrappedComponent => {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
return () => {
|
|
70
|
-
if (hasTooltip(props)) {
|
|
72
|
+
if (hasTooltip(props) || onDeniedText) {
|
|
71
73
|
document.removeEventListener('mouseover', onMouseOver);
|
|
72
74
|
document.removeEventListener('scroll', onAnyScroll, true);
|
|
73
75
|
if (targetElement && targetElement.current) {
|
|
@@ -75,7 +77,7 @@ const withTooltip = WrappedComponent => {
|
|
|
75
77
|
}
|
|
76
78
|
}
|
|
77
79
|
};
|
|
78
|
-
}, [errorMessage, tooltip]);
|
|
80
|
+
}, [errorMessage, tooltip, onDeniedText]);
|
|
79
81
|
(0, _react.useEffect)(() => {
|
|
80
82
|
if (targetElement.current && tooltipElement.current) {
|
|
81
83
|
const {
|
|
@@ -134,9 +136,9 @@ const withTooltip = WrappedComponent => {
|
|
|
134
136
|
setStateTooltipPosition(tooltipPosition);
|
|
135
137
|
}, [window.scrollY, window.scrollX, window.innerWidth]);
|
|
136
138
|
const getTooltip = () => {
|
|
137
|
-
if (tooltip) {
|
|
139
|
+
if (tooltip || onDeniedText) {
|
|
138
140
|
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
139
|
-
text: tooltip,
|
|
141
|
+
text: onDeniedText || tooltip,
|
|
140
142
|
textError: errorMessage,
|
|
141
143
|
tooltipRef: tooltipElement,
|
|
142
144
|
style: tooltipStyle,
|
|
@@ -150,8 +152,17 @@ const withTooltip = WrappedComponent => {
|
|
|
150
152
|
const getTarget = targetEl => {
|
|
151
153
|
if (!targetElement.current) targetElement.current = targetEl;
|
|
152
154
|
};
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
const contextValues = {
|
|
156
|
+
handlerSetOnDeniedText: setOnDeniedText
|
|
157
|
+
};
|
|
158
|
+
if (!hasTooltip(props) && !onDeniedText) {
|
|
159
|
+
return /*#__PURE__*/_react.default.createElement(TooltipContext.Provider, {
|
|
160
|
+
value: contextValues
|
|
161
|
+
}, /*#__PURE__*/_react.default.createElement(WrappedComponent, props));
|
|
162
|
+
}
|
|
163
|
+
return /*#__PURE__*/_react.default.createElement(TooltipContext.Provider, {
|
|
164
|
+
value: contextValues
|
|
165
|
+
}, /*#__PURE__*/_react.default.createElement(WrappedComponent, _extends({}, props, {
|
|
155
166
|
targetRef: getTarget
|
|
156
167
|
})), showTooltip && getTooltip());
|
|
157
168
|
};
|