@zauru-sdk/hooks 2.0.61 → 2.0.66

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.
@@ -18,7 +18,7 @@ const Alert = ({ type, title, description, onClose }) => {
18
18
  case "info":
19
19
  return "bg-blue-100 text-blue-800";
20
20
  case "warning":
21
- return "bg-yellow-100 text-yellow-800";
21
+ return "bg-yellow-200 text-yellow-800";
22
22
  default:
23
23
  return "bg-gray-100 text-gray-800";
24
24
  }
@@ -70,6 +70,7 @@ const Alert = ({ type, title, description, onClose }) => {
70
70
  }, children: (0, jsx_runtime_1.jsx)(icons_1.ExitSvg, {}) })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-2", children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm overflow-wrap break-words", children: description }) }), (0, jsx_runtime_1.jsx)("div", { className: "relative h-1 mt-4 bg-gray-200 rounded", children: (0, jsx_runtime_1.jsx)("div", { className: `absolute left-0 top-0 h-full ${getColor()} rounded`, style: { width: `${progress * 100}%` } }) })] }));
71
71
  };
72
72
  let activeAlerts = [];
73
+ let lastAlerts = [];
73
74
  const showAlert = (alertProps) => {
74
75
  if (typeof document === "undefined") {
75
76
  return;
@@ -87,10 +88,24 @@ const showAlert = (alertProps) => {
87
88
  onClose();
88
89
  }, 0);
89
90
  };
91
+ // Check if the alert is a duplicate
92
+ const isDuplicate = lastAlerts.some((lastAlert) => lastAlert.title === alertProps.title &&
93
+ lastAlert.description === alertProps.description &&
94
+ lastAlert.type === alertProps.type);
95
+ if (isDuplicate) {
96
+ return; // Do not show the alert if it's a duplicate
97
+ }
90
98
  activeAlerts.push(container);
91
99
  updateAlertOffsets();
92
100
  const root = (0, client_1.createRoot)(container);
93
101
  root.render((0, jsx_runtime_1.jsx)(Alert, { ...alertProps, onClose: asyncOnClose }));
102
+ // Update the last alerts shown
103
+ lastAlerts.push(alertProps);
104
+ setTimeout(() => {
105
+ lastAlerts = lastAlerts.filter((lastAlert) => lastAlert.title !== alertProps.title ||
106
+ lastAlert.description !== alertProps.description ||
107
+ lastAlert.type !== alertProps.type);
108
+ }, 4000); // Remove the alert from the last alerts list after 4 seconds
94
109
  };
95
110
  exports.showAlert = showAlert;
96
111
  const updateAlertOffsets = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/hooks",
3
- "version": "2.0.61",
3
+ "version": "2.0.66",
4
4
  "description": "Hooks reutilizables dentro de las webapps de Zauru.",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -33,5 +33,5 @@
33
33
  "react": "^18.2.0",
34
34
  "react-dom": "^18.2.0"
35
35
  },
36
- "gitHead": "1ce5c4fa59354272ffa305d364172b1114059daa"
36
+ "gitHead": "9448a1f8c79c28126c09778ad4da0c38a5a88908"
37
37
  }