flicker-alerts 1.0.7 → 1.0.8
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/index.js +10 -4
- package/package.json +3 -2
package/index.js
CHANGED
@@ -2,6 +2,15 @@ const FlickerAlerts = {
|
|
2
2
|
showAlert: function ({ type, title, message, timer = 3000 }) {
|
3
3
|
// Verifique se está no ambiente do navegador (client-side) antes de tentar manipular o DOM
|
4
4
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
5
|
+
// Garantir que o container de alertas exista, se não, criá-lo
|
6
|
+
let container = document.getElementById('alerts-container');
|
7
|
+
if (!container) {
|
8
|
+
// Cria o container se ele não existir
|
9
|
+
container = document.createElement('div');
|
10
|
+
container.id = 'alerts-container';
|
11
|
+
document.body.appendChild(container); // Adiciona o container ao body ou a outro elemento desejado
|
12
|
+
}
|
13
|
+
|
5
14
|
// Criação do alerta
|
6
15
|
const alertBox = document.createElement('div');
|
7
16
|
alertBox.className = `alert-custom alert-${type}`;
|
@@ -36,10 +45,7 @@ const FlickerAlerts = {
|
|
36
45
|
alertBox.appendChild(progressBar);
|
37
46
|
|
38
47
|
// Adicionar ao container
|
39
|
-
|
40
|
-
if (container) {
|
41
|
-
container.appendChild(alertBox);
|
42
|
-
}
|
48
|
+
container.appendChild(alertBox);
|
43
49
|
|
44
50
|
// Remoção automática após o tempo especificado
|
45
51
|
setTimeout(() => alertBox.remove(), timer);
|
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "flicker-alerts",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.8",
|
4
4
|
"description": "Biblioteca para alertas animados",
|
5
5
|
"main": "index.js",
|
6
|
-
"types": "index.d.ts",
|
6
|
+
"types": "index.d.ts",
|
7
|
+
"style": "style.css",
|
7
8
|
"scripts": {
|
8
9
|
"test": "echo \"Error: no test specified\" && exit 1"
|
9
10
|
},
|