contentoh-components-library 21.4.97 → 21.4.98

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.
@@ -46,7 +46,9 @@ var ObservationFlag = function ObservationFlag(_ref) {
46
46
  contentObservation = _ref.contentObservation,
47
47
  dataProduct = _ref.dataProduct,
48
48
  isObservationVisible = _ref.isObservationVisible,
49
- toggleObservation = _ref.toggleObservation;
49
+ toggleObservation = _ref.toggleObservation,
50
+ handleClickOutside = _ref.handleClickOutside,
51
+ hideObservation = _ref.hideObservation;
50
52
  var PriorityFlags = (_PriorityFlags = {}, (0, _defineProperty2.default)(_PriorityFlags, "none", _noPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "low", _lowPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "medium", _mediumPriority.default), (0, _defineProperty2.default)(_PriorityFlags, "high", _highPriority.default), _PriorityFlags); // const [isObservationVisible, setObservationVisible] = useState(false);
51
53
 
52
54
  var _useState = (0, _react.useState)(contentObservation || ""),
@@ -69,26 +71,16 @@ var ObservationFlag = function ObservationFlag(_ref) {
69
71
  modalData = _useState8[0],
70
72
  setModalData = _useState8[1];
71
73
 
72
- var textareaRef = (0, _react.useRef)(null); // const toggleObservation = () => {
73
- // setObservationVisible(!isObservationVisible);
74
- // };
75
-
74
+ var textareaRef = (0, _react.useRef)(null);
76
75
  (0, _react.useEffect)(function () {
77
- var handleClickOutside = function handleClickOutside(event) {
78
- if (isObservationVisible && !event.target.closest(".Observation") && !event.target.closest(".Container")) {
79
- setObservationVisible(false);
80
- }
81
- };
82
-
83
76
  document.addEventListener("click", handleClickOutside);
84
77
  return function () {
85
78
  document.removeEventListener("click", handleClickOutside);
86
79
  };
87
- }, [isObservationVisible]);
80
+ }, [isObservationVisible, handleClickOutside]);
88
81
  (0, _react.useEffect)(function () {
89
- setMaterial(contentObservation || ""); // Establecer material después de montar el componente
90
- }, [contentObservation]); // Volver a establecer material cuando contentObservation cambia
91
-
82
+ setMaterial(contentObservation || "");
83
+ }, [contentObservation]);
92
84
  (0, _react.useEffect)(function () {
93
85
  setCurrentObservation(observation);
94
86
  }, [observation]);
@@ -126,7 +118,7 @@ var ObservationFlag = function ObservationFlag(_ref) {
126
118
  setShowModal(true);
127
119
  setModalData(response.data.statusCode === 200 ? succesResponse : errorResponse);
128
120
  setCurrentObservation(material !== "" ? "high" : "low");
129
- setObservationVisible(false);
121
+ hideObservation();
130
122
  return _context.abrupt("return", response);
131
123
 
132
124
  case 14:
@@ -28,7 +28,9 @@ var ProductNameHeader = function ProductNameHeader(_ref) {
28
28
  productObservation = _ref.productObservation,
29
29
  dataProduct = _ref.dataProduct,
30
30
  isObservationVisible = _ref.isObservationVisible,
31
- toggleObservation = _ref.toggleObservation;
31
+ toggleObservation = _ref.toggleObservation,
32
+ handleClickOutside = _ref.handleClickOutside,
33
+ hideObservation = _ref.hideObservation;
32
34
  var typeFlag = productObservation !== null && productObservation !== "" ? "high" : "low";
33
35
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styles.Container, {
34
36
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ScreenHeader, {
@@ -45,7 +47,9 @@ var ProductNameHeader = function ProductNameHeader(_ref) {
45
47
  contentObservation: productObservation,
46
48
  dataProduct: dataProduct,
47
49
  isObservationVisible: isObservationVisible,
48
- toggleObservation: toggleObservation
50
+ toggleObservation: toggleObservation,
51
+ handleClickOutside: handleClickOutside,
52
+ hideObservation: hideObservation
49
53
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_index.ScreenHeader, {
50
54
  headerType: "date-header",
51
55
  text: date
@@ -37,7 +37,9 @@ var FullProductNameHeader = function FullProductNameHeader(_ref) {
37
37
  showApproveRejectAll = _ref.showApproveRejectAll,
38
38
  productObservation = _ref.productObservation,
39
39
  isObservationVisible = _ref.isObservationVisible,
40
- toggleObservation = _ref.toggleObservation;
40
+ toggleObservation = _ref.toggleObservation,
41
+ handleClickOutside = _ref.handleClickOutside,
42
+ hideObservation = _ref.hideObservation;
41
43
 
42
44
  var _useState = (0, _react.useState)([]),
43
45
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -75,7 +77,9 @@ var FullProductNameHeader = function FullProductNameHeader(_ref) {
75
77
  date: getTime((headerData === null || headerData === void 0 ? void 0 : (_headerData$article2 = headerData.article) === null || _headerData$article2 === void 0 ? void 0 : _headerData$article2.timestamp) || (headerData === null || headerData === void 0 ? void 0 : headerData.timestamp)),
76
78
  dataProduct: headerData,
77
79
  isObservationVisible: isObservationVisible,
78
- toggleObservation: toggleObservation
80
+ toggleObservation: toggleObservation,
81
+ handleClickOutside: handleClickOutside,
82
+ hideObservation: hideObservation
79
83
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
80
84
  className: "features-bar-container",
81
85
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_FeaturesBar.FeaturesBar, {
@@ -15,6 +15,6 @@ var _variables = require("../../../global-files/variables");
15
15
 
16
16
  var _templateObject;
17
17
 
18
- var ContainerModal = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n overflow: auto;\n display: grid;\n place-items: center;\n background-color: rgba(0, 0, 0, 0.4);\n\n .contentModal {\n width: fit-content;\n max-width: 80%;\n min-width: 80px;\n height: fit-content;\n max-height: 90%;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: white;\n border-radius: 10px;\n padding: 25px 25px 20px 25px;\n box-shadow: 0px 2px 4px 0px #00000040;\n\n header {\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n gap: 6px;\n\n .label-title {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 17px;\n line-height: 1.2;\n color: #262626;\n white-space: pre-wrap;\n }\n\n & + * {\n margin-top: 20px;\n }\n }\n\n .iconModal {\n width: 50px;\n height: 50px;\n font-size: 30px;\n border-width: 4px;\n margin-bottom: 20px;\n overflow: hidden;\n\n &.iconModal-error {\n background-color: #953737;\n border-color: #953737;\n color: white;\n }\n &.iconModal-warning {\n font-size: 27px;\n padding-bottom: 8px;\n color: #af9647;\n border-color: #af9647;\n }\n &.iconModal-info {\n border-color: #9e3e26;\n color: #9e3e26;\n }\n &.iconModal-success {\n }\n &.iconModal-successv2{\n border-color: #85BC5B;\n color: #85BC5B;\n }\n }\n\n .label-message {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 13px;\n color: #707070;\n white-space: pre-wrap;\n }\n\n .container-customComponent {\n width: 100%;\n max-height: 50vh;\n display: flex;\n flex-direction: column;\n margin-top: 20px;\n padding: 0px 0px;\n //border: 1px solid red;\n }\n\n .container-buttons {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 12px;\n margin-top: 20px;\n //border: 1px solid red;\n }\n }\n"])), _variables.FontFamily.RobotoMedium, _variables.FontFamily.RobotoRegular);
18
+ var ContainerModal = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n overflow: auto;\n display: grid;\n place-items: center;\n background-color: rgba(0, 0, 0, 0.4);\n z-index: 10100;\n\n .contentModal {\n width: fit-content;\n max-width: 80%;\n min-width: 80px;\n height: fit-content;\n max-height: 90%;\n min-height: 120px;\n display: flex;\n flex-direction: column;\n align-items: center;\n background-color: white;\n border-radius: 10px;\n padding: 25px 25px 20px 25px;\n box-shadow: 0px 2px 4px 0px #00000040;\n\n header {\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n justify-content: flex-start;\n gap: 6px;\n\n .label-title {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 17px;\n line-height: 1.2;\n color: #262626;\n white-space: pre-wrap;\n }\n\n & + * {\n margin-top: 20px;\n }\n }\n\n .iconModal {\n width: 50px;\n height: 50px;\n font-size: 30px;\n border-width: 4px;\n margin-bottom: 20px;\n overflow: hidden;\n\n &.iconModal-error {\n background-color: #953737;\n border-color: #953737;\n color: white;\n }\n &.iconModal-warning {\n font-size: 27px;\n padding-bottom: 8px;\n color: #af9647;\n border-color: #af9647;\n }\n &.iconModal-info {\n border-color: #9e3e26;\n color: #9e3e26;\n }\n &.iconModal-success {\n }\n &.iconModal-successv2{\n border-color: #85BC5B;\n color: #85BC5B;\n }\n }\n\n .label-message {\n width: 100%;\n text-align: center;\n font-family: ", ", sans-serif;\n font-size: 13px;\n color: #707070;\n white-space: pre-wrap;\n }\n\n .container-customComponent {\n width: 100%;\n max-height: 50vh;\n display: flex;\n flex-direction: column;\n margin-top: 20px;\n padding: 0px 0px;\n //border: 1px solid red;\n }\n\n .container-buttons {\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n gap: 12px;\n margin-top: 20px;\n //border: 1px solid red;\n }\n }\n"])), _variables.FontFamily.RobotoMedium, _variables.FontFamily.RobotoRegular);
19
19
 
20
20
  exports.ContainerModal = ContainerModal;
@@ -516,6 +516,23 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
516
516
  setObservationVisible(!isObservationVisible);
517
517
  };
518
518
 
519
+ var handleClickOutside = function handleClickOutside(event) {
520
+ if (isObservationVisible && !event.target.closest(".Observation") && !event.target.closest(".Container")) {
521
+ setObservationVisible(false);
522
+ }
523
+ };
524
+
525
+ (0, _react.useEffect)(function () {
526
+ document.addEventListener("click", handleClickOutside);
527
+ return function () {
528
+ document.removeEventListener("click", handleClickOutside);
529
+ };
530
+ }, [isObservationVisible]);
531
+
532
+ var hideObservation = function hideObservation() {
533
+ setObservationVisible(false);
534
+ };
535
+
519
536
  (0, _react.useEffect)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
520
537
  var _ref3, id_article;
521
538
 
@@ -2033,7 +2050,9 @@ var RetailerProductEdition = function RetailerProductEdition(_ref) {
2033
2050
  setValRejAll(true);
2034
2051
  },
2035
2052
  isObservationVisible: isObservationVisible,
2036
- toggleObservation: toggleObservation
2053
+ toggleObservation: toggleObservation,
2054
+ handleClickOutside: handleClickOutside,
2055
+ hideObservation: hideObservation
2037
2056
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FullTabsMenu.FullTabsMenu, {
2038
2057
  tabsSections: tabsSections,
2039
2058
  status: retailerStatus,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contentoh-components-library",
3
- "version": "21.4.97",
3
+ "version": "21.4.98",
4
4
  "dependencies": {
5
5
  "@aws-amplify/auth": "^4.5.3",
6
6
  "@aws-amplify/datastore": "^3.11.0",
@@ -13,7 +13,7 @@ export const ObservationFlag = ({
13
13
  observation,
14
14
  contentObservation,
15
15
  dataProduct,
16
- isObservationVisible, toggleObservation,
16
+ isObservationVisible, toggleObservation,handleClickOutside,hideObservation
17
17
  }) => {
18
18
  const PriorityFlags = {
19
19
  ["none"]: without,
@@ -30,28 +30,17 @@ export const ObservationFlag = ({
30
30
  const [modalData, setModalData] = useState({});
31
31
 
32
32
  const textareaRef = useRef(null);
33
- // const toggleObservation = () => {
34
- // setObservationVisible(!isObservationVisible);
35
- // };
33
+
36
34
  useEffect(() => {
37
- const handleClickOutside = (event) => {
38
- if (
39
- isObservationVisible &&
40
- !event.target.closest(".Observation") &&
41
- !event.target.closest(".Container")
42
- ) {
43
- setObservationVisible(false);
44
- }
45
- };
46
35
  document.addEventListener("click", handleClickOutside);
47
36
  return () => {
48
37
  document.removeEventListener("click", handleClickOutside);
49
38
  };
50
- }, [isObservationVisible]);
51
-
39
+ }, [isObservationVisible, handleClickOutside]);
40
+
52
41
  useEffect(() => {
53
- setMaterial(contentObservation || ""); // Establecer material después de montar el componente
54
- }, [contentObservation]); // Volver a establecer material cuando contentObservation cambia
42
+ setMaterial(contentObservation || "");
43
+ }, [contentObservation]);
55
44
 
56
45
  useEffect(() => {
57
46
  setCurrentObservation(observation);
@@ -88,7 +77,7 @@ export const ObservationFlag = ({
88
77
  response.data.statusCode === 200 ? succesResponse : errorResponse
89
78
  );
90
79
  setCurrentObservation(material !== "" ? "high" : "low");
91
- setObservationVisible(false);
80
+ hideObservation();
92
81
  return response;
93
82
  } catch (err) {
94
83
  console.log(err);
@@ -14,7 +14,9 @@ export const ProductNameHeader = ({
14
14
  productObservation,
15
15
  dataProduct,
16
16
  isObservationVisible,
17
- toggleObservation
17
+ toggleObservation,
18
+ handleClickOutside,
19
+ hideObservation
18
20
  }) => {
19
21
  const typeFlag =
20
22
  productObservation !== null && productObservation !== "" ? "high" : "low";
@@ -34,6 +36,8 @@ toggleObservation
34
36
  dataProduct={dataProduct}
35
37
  isObservationVisible ={isObservationVisible}
36
38
  toggleObservation = {toggleObservation}
39
+ handleClickOutside = {handleClickOutside}
40
+ hideObservation={hideObservation}
37
41
  />
38
42
  <ScreenHeader headerType={"date-header"} text={date} />
39
43
  </Container>
@@ -19,7 +19,9 @@ export const FullProductNameHeader = ({
19
19
  showApproveRejectAll,
20
20
  productObservation,
21
21
  isObservationVisible,
22
- toggleObservation
22
+ toggleObservation,
23
+ handleClickOutside,
24
+ hideObservation
23
25
  }) => {
24
26
  const [retailers, setRetailers] = useState([]);
25
27
 
@@ -60,6 +62,9 @@ export const FullProductNameHeader = ({
60
62
  dataProduct={headerData}
61
63
  isObservationVisible ={isObservationVisible}
62
64
  toggleObservation = {toggleObservation}
65
+ handleClickOutside ={handleClickOutside}
66
+ hideObservation={hideObservation}
67
+
63
68
  />
64
69
  <div className="features-bar-container">
65
70
  <FeaturesBar
@@ -8,6 +8,7 @@ export const ContainerModal = styled.div`
8
8
  display: grid;
9
9
  place-items: center;
10
10
  background-color: rgba(0, 0, 0, 0.4);
11
+ z-index: 10100;
11
12
 
12
13
  .contentModal {
13
14
  width: fit-content;
@@ -236,7 +236,26 @@ export const RetailerProductEdition = ({
236
236
  const toggleObservation = () => {
237
237
  setObservationVisible(!isObservationVisible);
238
238
  };
239
+ const handleClickOutside = (event) => {
240
+ if (
241
+ isObservationVisible &&
242
+ !event.target.closest(".Observation") &&
243
+ !event.target.closest(".Container")
244
+ ) {
245
+ setObservationVisible(false);
246
+ }
247
+ };
239
248
 
249
+ useEffect(() => {
250
+ document.addEventListener("click", handleClickOutside);
251
+ return () => {
252
+ document.removeEventListener("click", handleClickOutside);
253
+ };
254
+ }, [isObservationVisible]);
255
+
256
+ const hideObservation = () => {
257
+ setObservationVisible(false);
258
+ };
240
259
 
241
260
  useEffect(async () => {
242
261
  const { id_article } = product?.article || {};
@@ -1371,6 +1390,8 @@ export const RetailerProductEdition = ({
1371
1390
  }}
1372
1391
  isObservationVisible={isObservationVisible}
1373
1392
  toggleObservation={toggleObservation}
1393
+ handleClickOutside={handleClickOutside}
1394
+ hideObservation={hideObservation}
1374
1395
  />
1375
1396
  <FullTabsMenu
1376
1397
  tabsSections={tabsSections}