linear-react-components-ui 1.1.21-rc.5 → 1.1.22-beta.2
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/button.scss +29 -56
- package/lib/assets/styles/file.scss +10 -7
- package/lib/assets/styles/floatMenu.scss +3 -1
- package/lib/assets/styles/sidenav.scss +3 -4
- package/lib/assets/styles/tabs.scss +3 -24
- package/lib/buttons/DefaultButton.js +11 -7
- package/lib/buttons/DestroyButton.d.ts +1 -1
- package/lib/buttons/DestroyButton.js +7 -2
- package/lib/buttons/split_button/index.d.ts +2 -2
- package/lib/buttons/split_button/index.js +12 -18
- package/lib/buttons/types.d.ts +2 -5
- package/lib/calendar/DangerCalendar.d.ts +1 -1
- package/lib/calendar/DangerCalendar.js +7 -2
- package/lib/calendar/InfoCalendar.d.ts +1 -1
- package/lib/calendar/InfoCalendar.js +7 -2
- package/lib/calendar/PrimaryCalendar.d.ts +1 -1
- package/lib/calendar/PrimaryCalendar.js +7 -2
- package/lib/calendar/SuccessCalendar.d.ts +1 -1
- package/lib/calendar/SuccessCalendar.js +7 -2
- package/lib/calendar/WarningCalendar.d.ts +1 -1
- package/lib/calendar/WarningCalendar.js +7 -2
- package/lib/checkbox/Label.js +31 -0
- package/lib/dialog/Question.js +1 -1
- package/lib/dialog/form/index.js +2 -3
- package/lib/dialog/types.d.ts +0 -1
- package/lib/drawer/Drawer.d.ts +1 -1
- package/lib/drawer/Drawer.js +2 -6
- package/lib/drawer/types.d.ts +0 -1
- package/lib/form/Field.js +13 -30
- package/lib/form/FieldArray.js +13 -10
- package/lib/form/FieldNumber.js +1 -10
- package/lib/form/FieldPeriod.js +1 -15
- package/lib/form/index.d.ts +1 -1
- package/lib/form/index.js +5 -30
- package/lib/form/types.d.ts +1 -13
- package/lib/form/withFieldHOC.js +2 -4
- package/lib/icons/index.js +21 -23
- package/lib/inputs/base/InputTextBase.js +1 -0
- package/lib/inputs/base/types.d.ts +0 -1
- package/lib/inputs/date/helpers.d.ts +1 -31
- package/lib/inputs/date/helpers.js +2 -32
- package/lib/inputs/date/index.js +20 -28
- package/lib/inputs/date/types.d.ts +0 -1
- package/lib/inputs/mask/BaseMask.d.ts +1 -1
- package/lib/inputs/mask/BaseMask.js +4 -6
- package/lib/inputs/mask/helpers.d.ts +53 -6
- package/lib/inputs/mask/helpers.js +35 -16
- package/lib/inputs/mask/imaskHOC.js +205 -0
- package/lib/inputs/mask/types.d.ts +0 -1
- package/lib/inputs/select/Dropdown.js +1 -1
- package/lib/inputs/select/multiple/index.js +3 -5
- package/lib/inputs/select/simple/index.js +2 -5
- package/lib/internals/constants.d.ts +1 -4
- package/lib/internals/constants.js +1 -4
- package/lib/labels/DangerLabel.d.ts +1 -1
- package/lib/labels/DangerLabel.js +7 -2
- package/lib/labels/InfoLabel.d.ts +1 -1
- package/lib/labels/InfoLabel.js +7 -2
- package/lib/labels/PrimaryLabel.d.ts +1 -1
- package/lib/labels/PrimaryLabel.js +7 -2
- package/lib/labels/SuccessLabel.d.ts +1 -1
- package/lib/labels/SuccessLabel.js +7 -2
- package/lib/labels/WarningLabel.d.ts +1 -1
- package/lib/labels/WarningLabel.js +7 -2
- package/lib/menus/sidenav/NavMenuItem.js +20 -16
- package/lib/menus/sidenav/popup_menu_help/index.js +85 -0
- package/lib/panel/Content.js +7 -10
- package/lib/panel/Header.js +3 -1
- package/lib/radio/index.d.ts +1 -4
- package/lib/radio/index.js +0 -1
- package/lib/spinner/SpinnerLoading.js +0 -1
- package/lib/spinner/types.d.ts +2 -2
- package/lib/table/index.js +8 -2
- package/lib/tabs/DropdownItems.js +62 -0
- package/lib/tabs/Menu.d.ts +1 -1
- package/lib/tabs/Menu.js +2 -4
- package/lib/tabs/MenuItems.js +70 -0
- package/lib/tabs/MenuTabs.js +5 -16
- package/lib/tabs/context.d.ts +1 -1
- package/lib/tabs/context.js +1 -3
- package/lib/tabs/index.d.ts +1 -1
- package/lib/tabs/index.js +7 -13
- package/lib/tabs/tabHelpers.js +7 -2
- package/lib/tabs/types.d.ts +1 -7
- package/lib/textContent/index.js +5 -1
- package/lib/toolbar/types.d.ts +1 -1
- package/lib/treeview_old/Header.js +29 -0
- package/lib/treeview_old/Node.js +68 -0
- package/lib/treeview_old/index.js +43 -0
- package/package.json +1 -1
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"];
|
|
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,8 +38,7 @@ const BaseDrawer = _ref => {
|
|
|
38
38
|
customClassForDrawer = '',
|
|
39
39
|
content,
|
|
40
40
|
title,
|
|
41
|
-
isWaiting = false
|
|
42
|
-
customClassElementDrawer = ''
|
|
41
|
+
isWaiting = false
|
|
43
42
|
} = _ref,
|
|
44
43
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
45
44
|
const headerProps = _objectSpread(_objectSpread({}, rest), {}, {
|
|
@@ -47,9 +46,6 @@ const BaseDrawer = _ref => {
|
|
|
47
46
|
});
|
|
48
47
|
const drawerContainerEl = (0, _react.useRef)(document.createElement('div'));
|
|
49
48
|
drawerContainerEl.current.className = 'drawercontainer';
|
|
50
|
-
if (customClassElementDrawer) {
|
|
51
|
-
drawerContainerEl.current.className = customClassElementDrawer;
|
|
52
|
-
}
|
|
53
49
|
const drawerComponentEl = (0, _react.useRef)();
|
|
54
50
|
const {
|
|
55
51
|
hideContent
|
package/lib/drawer/types.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ interface IDrawerProps extends React__default.HTMLAttributes<HTMLDivElement> {
|
|
|
10
10
|
customClass?: string;
|
|
11
11
|
customClassForContent?: string;
|
|
12
12
|
customClassForDrawer?: string;
|
|
13
|
-
customClassElementDrawer?: string;
|
|
14
13
|
position?: Exclude<Position, 'center'>;
|
|
15
14
|
handlerClose?: () => void;
|
|
16
15
|
closeOnEsc?: boolean;
|
package/lib/form/Field.js
CHANGED
|
@@ -8,19 +8,18 @@ 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
|
-
|
|
12
|
-
const _excluded = ["handlerFieldChange", "handlerFieldValidate", "onChange", "onBlur", "name", "validators", "component", "handleValidationErrorsOnTab"];
|
|
11
|
+
const _excluded = ["handlerFieldChange", "handlerFieldValidate", "onChange", "onBlur", "name", "validators", "data", "fieldErrors", "handlerStoreValidators", "handlerRemoveValidators", "component", "externalFieldErrors", "originalData"];
|
|
13
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
13
|
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); }
|
|
15
14
|
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; }
|
|
16
15
|
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; }
|
|
19
16
|
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; }
|
|
20
17
|
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; }
|
|
21
18
|
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; }
|
|
22
19
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
23
20
|
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; }
|
|
24
23
|
const getEvents = _ref => {
|
|
25
24
|
let {
|
|
26
25
|
validators = [],
|
|
@@ -29,13 +28,10 @@ const getEvents = _ref => {
|
|
|
29
28
|
handlerFieldValidate,
|
|
30
29
|
validatorFromComponent,
|
|
31
30
|
handlerFieldChange,
|
|
32
|
-
onChange
|
|
33
|
-
component,
|
|
34
|
-
onKeyDown
|
|
31
|
+
onChange
|
|
35
32
|
} = _ref;
|
|
36
33
|
if (!(validators || validatorFromComponent || onBlur || onChange)) return {};
|
|
37
34
|
const validatorsArray = (0, _helpers.getValidatorsArray)(validators, validatorFromComponent);
|
|
38
|
-
const maskComponents = ['PhoneField', 'CpfField', 'CnpjField', 'ZipCodeField', 'BaseMask'];
|
|
39
35
|
return {
|
|
40
36
|
onBlur: e => {
|
|
41
37
|
if (validatorsArray && e.target && handlerFieldValidate) {
|
|
@@ -43,14 +39,8 @@ const getEvents = _ref => {
|
|
|
43
39
|
}
|
|
44
40
|
if (onBlur) onBlur(e);
|
|
45
41
|
},
|
|
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
|
-
},
|
|
52
42
|
onChange: e => {
|
|
53
|
-
if (
|
|
43
|
+
if (validatorsArray && e.target && handlerFieldValidate) {
|
|
54
44
|
handlerFieldValidate(name, e.target.value, validatorsArray);
|
|
55
45
|
}
|
|
56
46
|
if (handlerFieldChange) handlerFieldChange(e);
|
|
@@ -68,11 +58,8 @@ const getCustomProps = (props, handlerSetComponentValidator) => {
|
|
|
68
58
|
component
|
|
69
59
|
} = props;
|
|
70
60
|
if (componentType && componentType.toLowerCase() === 'radio') {
|
|
71
|
-
const convertedData = _objectSpread(_objectSpread({}, data), {}, {
|
|
72
|
-
[name]: String(data?.[name])
|
|
73
|
-
});
|
|
74
61
|
return {
|
|
75
|
-
checked: _lodash.default.get(
|
|
62
|
+
checked: _lodash.default.get(data, name) === value,
|
|
76
63
|
id: fieldId
|
|
77
64
|
};
|
|
78
65
|
} else if (componentType && componentType.toLowerCase() === 'checkbox') {
|
|
@@ -98,22 +85,19 @@ const Field = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
98
85
|
onBlur,
|
|
99
86
|
name,
|
|
100
87
|
validators,
|
|
88
|
+
data,
|
|
89
|
+
fieldErrors,
|
|
90
|
+
handlerStoreValidators,
|
|
91
|
+
handlerRemoveValidators,
|
|
101
92
|
component: Component,
|
|
102
|
-
|
|
93
|
+
externalFieldErrors,
|
|
94
|
+
originalData
|
|
103
95
|
} = props,
|
|
104
96
|
rest = _objectWithoutProperties(props, _excluded);
|
|
105
97
|
const {
|
|
106
98
|
handlerSetValidatorFromComponent,
|
|
107
99
|
validatorFromComponent
|
|
108
100
|
} = (0, _react.useContext)(_helpers.withFieldContext);
|
|
109
|
-
const hasErrorsMessagesOnField = (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
110
|
-
fieldErrors: props.fieldErrors
|
|
111
|
-
}));
|
|
112
|
-
if (handleValidationErrorsOnTab) handleValidationErrorsOnTab({
|
|
113
|
-
name: name,
|
|
114
|
-
tabId: props.tabId,
|
|
115
|
-
hasErrors: !!hasErrorsMessagesOnField.length
|
|
116
|
-
});
|
|
117
101
|
return /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, getEvents({
|
|
118
102
|
name,
|
|
119
103
|
validators,
|
|
@@ -121,8 +105,7 @@ const Field = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
121
105
|
validatorFromComponent,
|
|
122
106
|
handlerFieldValidate,
|
|
123
107
|
handlerFieldChange,
|
|
124
|
-
onChange
|
|
125
|
-
component: Component
|
|
108
|
+
onChange
|
|
126
109
|
}), getCustomProps(props, handlerSetValidatorFromComponent), {
|
|
127
110
|
ref: ref,
|
|
128
111
|
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", "name", "component", "
|
|
13
|
+
const _excluded = ["cols", "label", "bordered", "labelContainerStyle", "skipLabel", "data", "name", "handlerStoreValidators", "component", "handlerFieldChange", "handlerFieldValidate", "changePropName", "fieldErrors", "externalMessagesErrors", "handlerRemoveValidators", "validators", "valuePropName", "originalData", "handlerSelecionados"];
|
|
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); }
|
|
@@ -56,20 +56,23 @@ const FieldArray = props => {
|
|
|
56
56
|
bordered,
|
|
57
57
|
labelContainerStyle,
|
|
58
58
|
skipLabel,
|
|
59
|
+
data,
|
|
59
60
|
name,
|
|
61
|
+
handlerStoreValidators,
|
|
60
62
|
component: Component,
|
|
61
|
-
|
|
63
|
+
handlerFieldChange,
|
|
64
|
+
handlerFieldValidate,
|
|
65
|
+
changePropName,
|
|
66
|
+
fieldErrors,
|
|
67
|
+
externalMessagesErrors,
|
|
68
|
+
handlerRemoveValidators,
|
|
69
|
+
validators,
|
|
70
|
+
valuePropName,
|
|
71
|
+
originalData,
|
|
72
|
+
handlerSelecionados
|
|
62
73
|
} = props,
|
|
63
74
|
rest = _objectWithoutProperties(props, _excluded);
|
|
64
75
|
let content = null;
|
|
65
|
-
const hasErrorsMessagesOnField = (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
66
|
-
fieldErrors: props.fieldErrors
|
|
67
|
-
}));
|
|
68
|
-
if (handleValidationErrorsOnTab) handleValidationErrorsOnTab({
|
|
69
|
-
name: name,
|
|
70
|
-
tabId: props.tabId,
|
|
71
|
-
hasErrors: !!hasErrorsMessagesOnField.length
|
|
72
|
-
});
|
|
73
76
|
if (Component) {
|
|
74
77
|
if (!skipLabel && label) {
|
|
75
78
|
content = /*#__PURE__*/_react.default.createElement(_fieldset.default, {
|
package/lib/form/FieldNumber.js
CHANGED
|
@@ -55,18 +55,9 @@ const getEventProps = _ref => {
|
|
|
55
55
|
const FieldMask = props => {
|
|
56
56
|
const {
|
|
57
57
|
data,
|
|
58
|
-
name
|
|
59
|
-
handleValidationErrorsOnTab
|
|
58
|
+
name
|
|
60
59
|
} = props;
|
|
61
60
|
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
|
-
});
|
|
70
61
|
return /*#__PURE__*/_react.default.createElement(props.component, _extends({}, props, getEventProps(_objectSpread({}, props)), {
|
|
71
62
|
errorMessages: (0, _helpers.getErrorMessages)(_objectSpread(_objectSpread({}, props), {}, {
|
|
72
63
|
fieldErrors: props.fieldErrors
|
package/lib/form/FieldPeriod.js
CHANGED
|
@@ -12,11 +12,6 @@ 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); }
|
|
20
15
|
const FieldPeriod = props => {
|
|
21
16
|
const {
|
|
22
17
|
data,
|
|
@@ -31,8 +26,7 @@ const FieldPeriod = props => {
|
|
|
31
26
|
originalData,
|
|
32
27
|
component: Component,
|
|
33
28
|
name,
|
|
34
|
-
externalFieldErrors
|
|
35
|
-
handleValidationErrorsOnTab
|
|
29
|
+
externalFieldErrors
|
|
36
30
|
} = props;
|
|
37
31
|
let content = null;
|
|
38
32
|
const [showValidateMessages, setShowValidateMessages] = (0, _react.useState)(false);
|
|
@@ -51,14 +45,6 @@ const FieldPeriod = props => {
|
|
|
51
45
|
externalFieldErrors,
|
|
52
46
|
externalMessagesErrors
|
|
53
47
|
});
|
|
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
|
-
});
|
|
62
48
|
if (Component) {
|
|
63
49
|
content = /*#__PURE__*/_react.default.createElement(Component, _extends({}, props, {
|
|
64
50
|
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,
|
|
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;
|
|
17
17
|
|
|
18
18
|
export { Form as default };
|
package/lib/form/index.js
CHANGED
|
@@ -68,8 +68,7 @@ const Form = _ref => {
|
|
|
68
68
|
skeletonize,
|
|
69
69
|
disabled,
|
|
70
70
|
children,
|
|
71
|
-
useInternalState = false
|
|
72
|
-
onValidateErrorsOnTab
|
|
71
|
+
useInternalState = false
|
|
73
72
|
} = _ref;
|
|
74
73
|
const formId = (0, _uuid.v1)();
|
|
75
74
|
const [data, setData] = (0, _react.useState)(dataSource);
|
|
@@ -81,7 +80,6 @@ const Form = _ref => {
|
|
|
81
80
|
const context = (0, _react.useContext)(_withFormSecurity.FormSecurityContext);
|
|
82
81
|
const formRef = (0, _react.useRef)(null);
|
|
83
82
|
const fieldsValidators = (0, _react.useRef)({});
|
|
84
|
-
const tabsWithErrorRef = (0, _react.useRef)([]);
|
|
85
83
|
const usedData = useInternalState ? data : dataSource;
|
|
86
84
|
const getValidatesErrorMessages = (validators, fieldValue) => {
|
|
87
85
|
const validatorsArray = !(validators instanceof Array) ? [validators] : validators;
|
|
@@ -96,7 +94,7 @@ const Form = _ref => {
|
|
|
96
94
|
};
|
|
97
95
|
const getErrorMessages = (currentData, currentValidators) => {
|
|
98
96
|
const dataValidate = currentData || usedData;
|
|
99
|
-
let currentFieldErrors = _lodash.default.pickBy(fieldErrors, (
|
|
97
|
+
let currentFieldErrors = _lodash.default.pickBy(fieldErrors, (error, fieldName) => {
|
|
100
98
|
const fieldValidatorsNames = Object.keys(currentValidators);
|
|
101
99
|
return fieldValidatorsNames.includes(fieldName);
|
|
102
100
|
});
|
|
@@ -185,23 +183,6 @@ const Form = _ref => {
|
|
|
185
183
|
event.preventDefault();
|
|
186
184
|
if (_lodash.default.isEqual(usedData, originalData)) return;
|
|
187
185
|
};
|
|
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]);
|
|
205
186
|
const formProps = () => {
|
|
206
187
|
let propsForm = null;
|
|
207
188
|
if (!disabled) {
|
|
@@ -232,9 +213,7 @@ const Form = _ref => {
|
|
|
232
213
|
if (onDataChange && useInternalState) onDataChange(usedData);
|
|
233
214
|
|
|
234
215
|
// TODO - Usar debounce para evitar chamada a cada letra digitada
|
|
235
|
-
if (onValidateForm)
|
|
236
|
-
onValidateForm(checkIsValid(usedData, true));
|
|
237
|
-
}
|
|
216
|
+
if (onValidateForm) onValidateForm(checkIsValid(usedData, true));
|
|
238
217
|
if (!disabled) {
|
|
239
218
|
handlerSubmit(onFormSubmit);
|
|
240
219
|
if (handlerReset) handlerReset(onReset);
|
|
@@ -250,13 +229,10 @@ const Form = _ref => {
|
|
|
250
229
|
}, [JSON.stringify(dataSource), useInternalState]);
|
|
251
230
|
(0, _react.useEffect)(() => {
|
|
252
231
|
if (securityBeforeUnload) {
|
|
253
|
-
if (
|
|
232
|
+
if (context) context.setSecurityBeforeUnload(true);
|
|
254
233
|
window.addEventListener('beforeunload', onBeforeUnload);
|
|
255
234
|
}
|
|
256
|
-
return () =>
|
|
257
|
-
if (securityBeforeUnload && Object.entries(context).length) context.setSecurityBeforeUnload(false);
|
|
258
|
-
window.removeEventListener('beforeunload', onBeforeUnload);
|
|
259
|
-
};
|
|
235
|
+
return () => window.removeEventListener('beforeunload', onBeforeUnload);
|
|
260
236
|
}, [securityBeforeUnload, onBeforeUnload]);
|
|
261
237
|
(0, _react.useEffect)(() => {
|
|
262
238
|
if (!disabled && submitOnPressEnterKey !== submitFormOnEnter) {
|
|
@@ -274,7 +250,6 @@ const Form = _ref => {
|
|
|
274
250
|
skeletonize,
|
|
275
251
|
handlerFieldChange: onFieldChange,
|
|
276
252
|
handlerFieldValidate: onValidate,
|
|
277
|
-
handleValidationErrorsOnTab: onValidateTabErrors,
|
|
278
253
|
handlerStoreValidators: (fieldName, fieldValidates) => {
|
|
279
254
|
fieldsValidators.current = _objectSpread(_objectSpread({}, fieldsValidators.current), {}, {
|
|
280
255
|
[fieldName]: fieldValidates
|
package/lib/form/types.d.ts
CHANGED
|
@@ -19,11 +19,6 @@ 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
|
-
};
|
|
27
22
|
type BaseFormProps = {
|
|
28
23
|
dataSource: object;
|
|
29
24
|
children: ReactNode;
|
|
@@ -32,7 +27,6 @@ type BaseFormProps = {
|
|
|
32
27
|
handlerReset?: (value: () => void) => void;
|
|
33
28
|
handlerValidates?: (value: any) => void;
|
|
34
29
|
onValidateForm?: (value: boolean) => void;
|
|
35
|
-
onValidateErrorsOnTab?: (tabIds: Array<string | number>) => void;
|
|
36
30
|
submitOnPressEnterKey?: boolean;
|
|
37
31
|
style?: CSSProperties;
|
|
38
32
|
customClass?: string;
|
|
@@ -101,8 +95,6 @@ interface IFieldProps extends WithFieldProps {
|
|
|
101
95
|
disabled?: boolean;
|
|
102
96
|
currencySymbol?: string;
|
|
103
97
|
checked?: boolean;
|
|
104
|
-
tabId?: string | number;
|
|
105
|
-
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
106
98
|
}
|
|
107
99
|
interface CustomEvent {
|
|
108
100
|
target: {
|
|
@@ -143,7 +135,6 @@ interface IFieldArrayProps extends WithFieldProps {
|
|
|
143
135
|
hintPosition?: 'below' | 'onLabelRight';
|
|
144
136
|
themePopover?: 'light' | 'dark';
|
|
145
137
|
popoverAlign?: 'right' | 'left';
|
|
146
|
-
tabId?: string | number;
|
|
147
138
|
}
|
|
148
139
|
type PeriodChangeEvent = {
|
|
149
140
|
initial: string;
|
|
@@ -181,7 +172,6 @@ interface IFieldPeriodProps extends WithFieldProps {
|
|
|
181
172
|
hintPosition?: 'below' | 'onLabelRight';
|
|
182
173
|
themePopover?: 'light' | 'dark';
|
|
183
174
|
popoverAlign?: 'right' | 'left';
|
|
184
|
-
tabId?: string | number;
|
|
185
175
|
}
|
|
186
176
|
interface FormContextProps {
|
|
187
177
|
skeletonize?: boolean;
|
|
@@ -194,7 +184,6 @@ interface FormContextProps {
|
|
|
194
184
|
fieldErrors: object;
|
|
195
185
|
externalFieldErrors?: object;
|
|
196
186
|
isFormValid?: boolean;
|
|
197
|
-
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
198
187
|
}
|
|
199
188
|
interface WithFieldProps {
|
|
200
189
|
name: string;
|
|
@@ -203,7 +192,6 @@ interface WithFieldProps {
|
|
|
203
192
|
handlerRemoveValidators?: (name: string) => void;
|
|
204
193
|
validators?: Validator | Validator[] | PeriodValidator | PeriodValidator[];
|
|
205
194
|
customClass?: string;
|
|
206
|
-
handleValidationErrorsOnTab?: (props: PropsValidateTabErrors) => void;
|
|
207
195
|
}
|
|
208
196
|
interface IWithFieldContext {
|
|
209
197
|
validatorFromComponent: Validator | Validator[] | undefined;
|
|
@@ -252,4 +240,4 @@ type FieldValidator = {
|
|
|
252
240
|
[name: string]: Validator | Validator[];
|
|
253
241
|
};
|
|
254
242
|
|
|
255
|
-
export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator,
|
|
243
|
+
export { CustomEvent, CustomKeyboardEvent, FieldErrors, FieldValidator, FormContextProps, FormProps, IEventParams, IFieldArrayProps, IFieldPeriodProps, IFieldProps, IFormSecurityContext, IGetErrorMessagesParams, IWithFieldContext, IWithFormSecurity, OnFielChangeEvent, PeriodChangeEvent, PeriodValidator, Validator, WithFieldProps };
|
package/lib/form/withFieldHOC.js
CHANGED
|
@@ -51,8 +51,7 @@ const withFieldHOC = WrappedComponent => {
|
|
|
51
51
|
externalFieldErrors,
|
|
52
52
|
handlerStoreValidators,
|
|
53
53
|
handlerRemoveValidators,
|
|
54
|
-
skeletonize
|
|
55
|
-
handleValidationErrorsOnTab
|
|
54
|
+
skeletonize
|
|
56
55
|
} = _ref;
|
|
57
56
|
return /*#__PURE__*/_react.default.createElement(EnhancedComponent, _extends({}, props, {
|
|
58
57
|
skeletonize: skeletonize,
|
|
@@ -63,8 +62,7 @@ const withFieldHOC = WrappedComponent => {
|
|
|
63
62
|
data: data,
|
|
64
63
|
fieldErrors: fieldErrors,
|
|
65
64
|
externalFieldErrors: externalFieldErrors,
|
|
66
|
-
forwardedRef: ref
|
|
67
|
-
handleValidationErrorsOnTab: handleValidationErrorsOnTab
|
|
65
|
+
forwardedRef: ref
|
|
68
66
|
}));
|
|
69
67
|
});
|
|
70
68
|
}
|
package/lib/icons/index.js
CHANGED
|
@@ -36,29 +36,27 @@ const Icon = _ref => {
|
|
|
36
36
|
const refSvg = (0, _react.useRef)(null);
|
|
37
37
|
const viewBoxFromIconOrSvgStrcut = name ? listIcon[name].viewbox : svgStruct?.viewbox;
|
|
38
38
|
const getPaths = () => name ? listIcon[name].paths : svgStruct?.paths;
|
|
39
|
-
const getSvg = () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
onClick
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})));
|
|
61
|
-
};
|
|
39
|
+
const getSvg = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
40
|
+
"data-testid": "icon",
|
|
41
|
+
"data-color-style": colorStyle,
|
|
42
|
+
onClick: () => {
|
|
43
|
+
if (onClick && !disabled) onClick();
|
|
44
|
+
},
|
|
45
|
+
ref: r => {
|
|
46
|
+
refSvg.current = r;
|
|
47
|
+
},
|
|
48
|
+
width: `${size}px`,
|
|
49
|
+
height: `${size}px`,
|
|
50
|
+
fill: disabled ? disabledIconColor : colorFromProp,
|
|
51
|
+
viewBox: viewBox || viewBoxFromIconOrSvgStrcut,
|
|
52
|
+
className: `icon-component ${customClass}`,
|
|
53
|
+
pointerEvents: pointerEvents,
|
|
54
|
+
style: style
|
|
55
|
+
}, getPaths()?.map(value => /*#__PURE__*/_react.default.createElement("path", {
|
|
56
|
+
"data-testid": "icon-path",
|
|
57
|
+
d: value,
|
|
58
|
+
key: value
|
|
59
|
+
})));
|
|
62
60
|
if (color && colorStyle !== 'default') throw new Error('Expected only one of the two properties: colorStyle or color');
|
|
63
61
|
if (!name && !svgStruct) throw new Error('One of the "name" and "svgStruct" props must be filled');
|
|
64
62
|
if (!visible) return null;
|
|
@@ -1,37 +1,7 @@
|
|
|
1
|
-
import * as imask from 'imask';
|
|
2
1
|
import moment from 'moment';
|
|
3
2
|
|
|
4
3
|
declare const PT_BR_FORMAT = "DD/MM/YYYY";
|
|
5
|
-
declare const PT_BR_FORMAT_DATETIME = "DD/MM/YYYY HH:mm";
|
|
6
4
|
declare const EN_US_FORMAT = "YYYY-MM-DD";
|
|
7
|
-
declare const EN_US_FORMAT_DATETIME = "YYYY-MM-DD HH.mm";
|
|
8
5
|
declare const getMomentValue: (value: string) => moment.Moment;
|
|
9
|
-
declare const blocksDateTimeFormat: {
|
|
10
|
-
DD: {
|
|
11
|
-
mask: typeof imask.MaskedRange;
|
|
12
|
-
from: number;
|
|
13
|
-
to: number;
|
|
14
|
-
};
|
|
15
|
-
MM: {
|
|
16
|
-
mask: typeof imask.MaskedRange;
|
|
17
|
-
from: number;
|
|
18
|
-
to: number;
|
|
19
|
-
};
|
|
20
|
-
YYYY: {
|
|
21
|
-
mask: typeof imask.MaskedRange;
|
|
22
|
-
from: number;
|
|
23
|
-
to: number;
|
|
24
|
-
};
|
|
25
|
-
HH: {
|
|
26
|
-
mask: typeof imask.MaskedRange;
|
|
27
|
-
from: number;
|
|
28
|
-
to: number;
|
|
29
|
-
};
|
|
30
|
-
mm: {
|
|
31
|
-
mask: typeof imask.MaskedRange;
|
|
32
|
-
from: number;
|
|
33
|
-
to: number;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
6
|
|
|
37
|
-
export { EN_US_FORMAT,
|
|
7
|
+
export { EN_US_FORMAT, PT_BR_FORMAT, getMomentValue };
|
|
@@ -3,14 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getMomentValue = exports.
|
|
6
|
+
exports.getMomentValue = exports.PT_BR_FORMAT = exports.EN_US_FORMAT = void 0;
|
|
7
7
|
var _moment = _interopRequireDefault(require("moment"));
|
|
8
|
-
var _reactImask = require("react-imask");
|
|
9
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
const PT_BR_FORMAT = exports.PT_BR_FORMAT = 'DD/MM/YYYY';
|
|
11
|
-
const PT_BR_FORMAT_DATETIME = exports.PT_BR_FORMAT_DATETIME = 'DD/MM/YYYY HH:mm';
|
|
12
10
|
const EN_US_FORMAT = exports.EN_US_FORMAT = 'YYYY-MM-DD';
|
|
13
|
-
const EN_US_FORMAT_DATETIME = exports.EN_US_FORMAT_DATETIME = 'YYYY-MM-DD HH.mm';
|
|
14
11
|
const getMomentValue = value => {
|
|
15
12
|
let newValue = value;
|
|
16
13
|
if ((0, _moment.default)(newValue, PT_BR_FORMAT, true).isValid()) {
|
|
@@ -18,31 +15,4 @@ const getMomentValue = value => {
|
|
|
18
15
|
}
|
|
19
16
|
return typeof newValue === 'string' ? (0, _moment.default)(newValue, EN_US_FORMAT) : newValue;
|
|
20
17
|
};
|
|
21
|
-
exports.getMomentValue = getMomentValue;
|
|
22
|
-
const blocksDateTimeFormat = exports.blocksDateTimeFormat = {
|
|
23
|
-
DD: {
|
|
24
|
-
mask: _reactImask.IMask.MaskedRange,
|
|
25
|
-
from: 1,
|
|
26
|
-
to: 31
|
|
27
|
-
},
|
|
28
|
-
MM: {
|
|
29
|
-
mask: _reactImask.IMask.MaskedRange,
|
|
30
|
-
from: 1,
|
|
31
|
-
to: 12
|
|
32
|
-
},
|
|
33
|
-
YYYY: {
|
|
34
|
-
mask: _reactImask.IMask.MaskedRange,
|
|
35
|
-
from: 1900,
|
|
36
|
-
to: 2999
|
|
37
|
-
},
|
|
38
|
-
HH: {
|
|
39
|
-
mask: _reactImask.IMask.MaskedRange,
|
|
40
|
-
from: 0,
|
|
41
|
-
to: 23
|
|
42
|
-
},
|
|
43
|
-
mm: {
|
|
44
|
-
mask: _reactImask.IMask.MaskedRange,
|
|
45
|
-
from: 0,
|
|
46
|
-
to: 59
|
|
47
|
-
}
|
|
48
|
-
};
|
|
18
|
+
exports.getMomentValue = getMomentValue;
|