avalynx-alert 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -16,8 +16,9 @@ AvalynxAlert is a lightweight, dependency-free alert system designed for web app
16
16
  Here's a simple example of how to use AvalynxAlert in your project:
17
17
 
18
18
  * [Overview](https://avalynx-alert.jbs-newmedia.de/examples/index.html)
19
- * [Random Alerts](https://avalynx-alert.jbs-newmedia.de/examples/random-alerts.html)
19
+ * [Random alerts](https://avalynx-alert.jbs-newmedia.de/examples/random-alerts.html)
20
20
  * [Callback on close](https://avalynx-alert.jbs-newmedia.de/examples/callback-onclose.html)
21
+ * [Random alerts every 3 seconds](https://avalynx-alert.jbs-newmedia.de/examples/random-alerts-every-3s.html)
21
22
 
22
23
  ## Installation
23
24
 
@@ -101,15 +102,15 @@ new AvalynxAlert('Your message here', 'success', {
101
102
 
102
103
  AvalynxAlert allows the following options for customization:
103
104
 
104
- - `message`: The message to display in the alert.
105
- - `type`: The type of alert (`primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`).
105
+ - `message`: (string) The message to display in the alert (default: `''`).
106
+ - `type`: (string) The type of alert. One of (`primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`, `dark`) (default: `'info'`).
106
107
  - `options`: An object containing the following keys:
107
- - `duration`: Duration in milliseconds for the alert to be displayed (default: 5000).
108
- - `position`: Position of the alert on the screen (default: `top-center`).
109
- - `closeable`: Whether the alert can be closed by the user (default: true).
110
- - `autoClose`: Whether the alert will close automatically after the duration (default: true).
111
- - `width`: The width of the alert (default: `400px`).
112
- - `onClose`: A callback function to be called when the alert is closed.
108
+ - `duration`: (number) Duration in milliseconds for the alert to be displayed (default: `5000`).
109
+ - `position`: (string) Position of the alert on the screen. One of `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, `bottom-right` (default: `'top-right'`).
110
+ - `closeable`: (boolean) Whether the alert can be closed by the user (default: `true`).
111
+ - `autoClose`: (boolean) Whether the alert will close automatically after the duration (default: `true`).
112
+ - `width`: (string) The width of the alert (default: `400px`).
113
+ - `onClose`: (function) A callback function to execute when the alert is closed (default: `null`).
113
114
 
114
115
  ## Contributing
115
116
 
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 0.0.5
6
+ * @version 0.0.7
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-alert/graphs/contributors
9
9
  * @website https://github.com/avalynx/
@@ -53,4 +53,4 @@
53
53
 
54
54
  .avalynx-alert.alert-dark .alert-timer {
55
55
  background-color: var(--bs-dark-border-subtle);
56
- }
56
+ }
@@ -3,135 +3,139 @@
3
3
  *
4
4
  * A simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 0.0.5
6
+ * @version 0.0.7
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-alert/graphs/contributors
9
9
  * @website https://github.com/avalynx/
10
10
  * @repository https://github.com/avalynx/avalynx-alert.git
11
11
  * @bugs https://github.com/avalynx/avalynx-alert/issues
12
12
  *
13
- * @param {string} message - The message to display in the alert.
14
- * @param {string} type - The type of alert. One of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'.
15
- * @param {object} options - The options for the alert.
16
- * @param {number} options.duration - The duration in milliseconds for the alert to be displayed. Default is 5000.
17
- * @param {string} options.position - The position of the alert. One of 'top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'. Default is 'top-center'.
18
- * @param {boolean} options.closeable - Whether the alert can be closed by the user. Default is true.
19
- * @param {boolean} options.autoClose - Whether the alert will close automatically after the duration. Default is true.
20
- * @param {string} options.width - The width of the alert. Default is '400px'.
13
+ * @param {string} message - The message to display in the alert (default: '').
14
+ * @param {string} type - The type of alert. One of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark' (default: 'info').
15
+ * @param {object} options - An object containing the following keys:
16
+ * @param {number} options.duration - Duration in milliseconds for the alert to be displayed (default: 5000).
17
+ * @param {string} options.position - Position of the alert on the screen. One of 'top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right' (default: 'top-center').
18
+ * @param {boolean} options.closeable - Whether the alert can be closed by the user (default: true).
19
+ * @param {boolean} options.autoClose - Whether the alert will close automatically after the duration (default: true).
20
+ * @param {string} options.width - The width of the alert (default: '400px').
21
+ * @param {function} options.onClose - A callback function to execute when the alert is closed (default: null).
22
+ *
21
23
  */
22
24
 
23
25
  export class AvalynxAlert {
24
- constructor(message, type, options = {}) {
25
- this.message = message;
26
- this.type = type;
27
- this.duration = options.duration || 5000;
28
- this.position = options.position || 'top-center';
29
- this.closeable = options.closeable || true;
30
- this.autoClose = options.autoClose || true;
31
- this.width = options.width || '400px';
32
- this.onClose = options.onClose || null;
33
-
34
- if (!['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(this.type)) {
35
- this.type = 'info';
36
- }
37
- if (!['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'].includes(this.position)) {
38
- this.position = 'top-center';
39
- }
40
- if (this.autoClose !== false && this.autoClose !== true) {
41
- this.autoClose = true;
42
- }
43
- if ((this.closeable !== false && this.closeable !== true) || (this.autoClose === true)) {
44
- this.closeable = true;
45
- }
26
+ constructor(message, type, options = {}) {
27
+ this.message = message;
28
+ this.type = type;
29
+ this.options = {
30
+ duration: options.duration || 5000,
31
+ position: options.position || 'top-center',
32
+ closeable: options.closeable || true,
33
+ autoClose: options.autoClose || true,
34
+ width: options.width || '400px',
35
+ onClose: options.onClose || null,
36
+ ...options
37
+ };
38
+ if (!['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(this.type)) {
39
+ this.type = 'info';
40
+ }
41
+ if (!['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'].includes(this.options.position)) {
42
+ this.options.position = 'top-center';
43
+ }
44
+ if (this.options.autoClose !== false && this.options.autoClose !== true) {
45
+ this.options.autoClose = true;
46
+ }
47
+ if ((this.options.closeable !== false && this.options.closeable !== true) || (this.options.autoClose === true)) {
48
+ this.options.closeable = true;
49
+ }
46
50
 
47
- this.init();
48
- }
51
+ this.init();
52
+ }
49
53
 
50
- ensureAlertContainer() {
51
- if (!document.getElementById('avalynx-alert-container-' + this.position)) {
52
- var container = document.createElement('div');
53
- container.id = 'avalynx-alert-container-' + this.position;
54
- container.style.width = '100%';
55
- container.style.maxWidth = this.width;
56
- container.style.zIndex = '1000';
57
- container.classList.add('container-fluid');
54
+ ensureAlertContainer() {
55
+ if (!document.getElementById('avalynx-alert-container-' + this.options.position)) {
56
+ var container = document.createElement('div');
57
+ container.id = 'avalynx-alert-container-' + this.options.position;
58
+ container.style.width = '100%';
59
+ container.style.maxWidth = this.options.width;
60
+ container.style.zIndex = '1000';
61
+ container.classList.add('container-fluid');
58
62
 
59
- if (this.position === 'top-left') {
60
- container.style.position = 'fixed';
61
- container.style.top = '10px';
62
- container.style.left = '0px';
63
- } else if (this.position === 'top-center') {
64
- container.style.position = 'fixed';
65
- container.style.top = '10px';
66
- container.style.left = '50%';
67
- container.style.transform = 'translateX(-50%)';
68
- } else if (this.position === 'top-right') {
69
- container.style.position = 'fixed';
70
- container.style.top = '10px';
71
- container.style.right = '0px';
72
- } else if (this.position === 'bottom-left') {
73
- container.style.position = 'fixed';
74
- container.style.bottom = '10px';
75
- container.style.left = '0px';
76
- } else if (this.position === 'bottom-center') {
77
- container.style.position = 'fixed';
78
- container.style.bottom = '10px';
79
- container.style.left = '50%';
80
- container.style.transform = 'translateX(-50%)';
81
- } else if (this.position === 'bottom-right') {
82
- container.style.position = 'fixed';
83
- container.style.bottom = '10px';
84
- container.style.right = '0px';
85
- }
63
+ if (this.options.position === 'top-left') {
64
+ container.style.position = 'fixed';
65
+ container.style.top = '10px';
66
+ container.style.left = '0px';
67
+ } else if (this.options.position === 'top-center') {
68
+ container.style.position = 'fixed';
69
+ container.style.top = '10px';
70
+ container.style.left = '50%';
71
+ container.style.transform = 'translateX(-50%)';
72
+ } else if (this.options.position === 'top-right') {
73
+ container.style.position = 'fixed';
74
+ container.style.top = '10px';
75
+ container.style.right = '0px';
76
+ } else if (this.options.position === 'bottom-left') {
77
+ container.style.position = 'fixed';
78
+ container.style.bottom = '10px';
79
+ container.style.left = '0px';
80
+ } else if (this.options.position === 'bottom-center') {
81
+ container.style.position = 'fixed';
82
+ container.style.bottom = '10px';
83
+ container.style.left = '50%';
84
+ container.style.transform = 'translateX(-50%)';
85
+ } else if (this.options.position === 'bottom-right') {
86
+ container.style.position = 'fixed';
87
+ container.style.bottom = '10px';
88
+ container.style.right = '0px';
89
+ }
86
90
 
87
- document.body.appendChild(container);
88
- }
89
- }
91
+ document.body.appendChild(container);
92
+ }
93
+ }
90
94
 
91
- init() {
92
- this.ensureAlertContainer();
95
+ init() {
96
+ this.ensureAlertContainer();
93
97
 
94
- var alert = document.createElement('div');
95
- alert.className = `alert alert-${this.type}`;
96
- if (this.closeable) {
97
- alert.classList.add('alert-dismissible');
98
- }
99
- alert.classList.add('fade');
100
- alert.classList.add('show');
101
- alert.classList.add('p-0');
102
- alert.classList.add('overflow-hidden');
103
- alert.classList.add('avalynx-alert');
104
- alert.role = 'alert';
105
- alert.innerHTML = `<div class="alert-content">${this.message}`;
106
- if (this.closeable) {
107
- alert.innerHTML += `<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>`;
108
- }
109
- alert.innerHTML += `</div>`;
110
- if (this.autoClose) {
111
- alert.innerHTML += `<div class="alert-timer" style="height: 5px; width: 0;"></div>`;
112
- }
98
+ var alert = document.createElement('div');
99
+ alert.className = `alert alert-${this.type}`;
100
+ if (this.options.closeable) {
101
+ alert.classList.add('alert-dismissible');
102
+ }
103
+ alert.classList.add('fade');
104
+ alert.classList.add('show');
105
+ alert.classList.add('p-0');
106
+ alert.classList.add('overflow-hidden');
107
+ alert.classList.add('avalynx-alert');
108
+ alert.role = 'alert';
109
+ alert.innerHTML = `<div class="alert-content">${this.message}`;
110
+ if (this.options.closeable) {
111
+ alert.innerHTML += `<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>`;
112
+ }
113
+ alert.innerHTML += `</div>`;
114
+ if (this.options.autoClose) {
115
+ alert.innerHTML += `<div class="alert-timer" style="height: 5px; width: 0;"></div>`;
116
+ }
113
117
 
114
- document.getElementById('avalynx-alert-container-' + this.position).appendChild(alert);
118
+ document.getElementById('avalynx-alert-container-' + this.options.position).appendChild(alert);
115
119
 
116
- if (this.autoClose) {
117
- var timerBar = alert.querySelector('.alert-timer');
118
- timerBar.style.transition = `width ${this.duration}ms linear`;
120
+ if (this.options.autoClose) {
121
+ var timerBar = alert.querySelector('.alert-timer');
122
+ timerBar.style.transition = `width ${this.options.duration}ms linear`;
119
123
 
120
- requestAnimationFrame(() => {
121
- requestAnimationFrame(() => {
122
- timerBar.style.width = '100%';
123
- });
124
- });
124
+ requestAnimationFrame(() => {
125
+ requestAnimationFrame(() => {
126
+ timerBar.style.width = '100%';
127
+ });
128
+ });
125
129
 
126
- setTimeout(() => {
127
- alert.classList.remove('show');
128
- setTimeout(() => {
129
- alert.remove();
130
- if (typeof this.onClose === 'function') {
131
- this.onClose();
132
- }
133
- }, 150);
134
- }, this.duration);
135
- }
136
- }
137
- }
130
+ setTimeout(() => {
131
+ alert.classList.remove('show');
132
+ setTimeout(() => {
133
+ alert.remove();
134
+ if (typeof this.options.onClose === 'function') {
135
+ this.options.onClose();
136
+ }
137
+ }, 150);
138
+ }, this.options.duration);
139
+ }
140
+ }
141
+ }
@@ -3,136 +3,139 @@
3
3
  *
4
4
  * A simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.
5
5
  *
6
- * @version 0.0.5
6
+ * @version 0.0.7
7
7
  * @license MIT
8
8
  * @author https://github.com/avalynx/avalynx-alert/graphs/contributors
9
9
  * @website https://github.com/avalynx/
10
10
  * @repository https://github.com/avalynx/avalynx-alert.git
11
11
  * @bugs https://github.com/avalynx/avalynx-alert/issues
12
12
  *
13
- * @param {string} message - The message to display in the alert.
14
- * @param {string} type - The type of alert. One of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'.
15
- * @param {object} options - The options for the alert.
16
- * @param {number} options.duration - The duration in milliseconds for the alert to be displayed. Default is 5000.
17
- * @param {string} options.position - The position of the alert. One of 'top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'. Default is 'top-center'.
18
- * @param {boolean} options.closeable - Whether the alert can be closed by the user. Default is true.
19
- * @param {boolean} options.autoClose - Whether the alert will close automatically after the duration. Default is true.
20
- * @param {string} options.width - The width of the alert. Default is '400px'.
21
- * @param {function} options.onClose - A callback function to be called when the alert is closed.
13
+ * @param {string} message - The message to display in the alert (default: '').
14
+ * @param {string} type - The type of alert. One of 'primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark' (default: 'info').
15
+ * @param {object} options - An object containing the following keys:
16
+ * @param {number} options.duration - Duration in milliseconds for the alert to be displayed (default: 5000).
17
+ * @param {string} options.position - Position of the alert on the screen. One of 'top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right' (default: 'top-center').
18
+ * @param {boolean} options.closeable - Whether the alert can be closed by the user (default: true).
19
+ * @param {boolean} options.autoClose - Whether the alert will close automatically after the duration (default: true).
20
+ * @param {string} options.width - The width of the alert (default: '400px').
21
+ * @param {function} options.onClose - A callback function to execute when the alert is closed (default: null).
22
+ *
22
23
  */
23
24
 
24
25
  class AvalynxAlert {
25
- constructor(message, type, options = {}) {
26
- this.message = message;
27
- this.type = type;
28
- this.duration = options.duration || 5000;
29
- this.position = options.position || 'top-center';
30
- this.closeable = options.closeable || true;
31
- this.autoClose = options.autoClose || true;
32
- this.width = options.width || '400px';
33
- this.onClose = options.onClose || null;
34
-
35
- if (!['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(this.type)) {
36
- this.type = 'info';
37
- }
38
- if (!['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'].includes(this.position)) {
39
- this.position = 'top-center';
40
- }
41
- if (this.autoClose !== false && this.autoClose !== true) {
42
- this.autoClose = true;
43
- }
44
- if ((this.closeable !== false && this.closeable !== true) || (this.autoClose === true)) {
45
- this.closeable = true;
46
- }
26
+ constructor(message, type, options = {}) {
27
+ this.message = message;
28
+ this.type = type;
29
+ this.options = {
30
+ duration: options.duration || 5000,
31
+ position: options.position || 'top-center',
32
+ closeable: options.closeable || true,
33
+ autoClose: options.autoClose || true,
34
+ width: options.width || '400px',
35
+ onClose: options.onClose || null,
36
+ ...options
37
+ };
38
+ if (!['primary', 'secondary', 'success', 'danger', 'warning', 'info', 'light', 'dark'].includes(this.type)) {
39
+ this.type = 'info';
40
+ }
41
+ if (!['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right'].includes(this.options.position)) {
42
+ this.options.position = 'top-center';
43
+ }
44
+ if (this.options.autoClose !== false && this.options.autoClose !== true) {
45
+ this.options.autoClose = true;
46
+ }
47
+ if ((this.options.closeable !== false && this.options.closeable !== true) || (this.options.autoClose === true)) {
48
+ this.options.closeable = true;
49
+ }
47
50
 
48
- this.init();
49
- }
51
+ this.init();
52
+ }
50
53
 
51
- ensureAlertContainer() {
52
- if (!document.getElementById('avalynx-alert-container-' + this.position)) {
53
- var container = document.createElement('div');
54
- container.id = 'avalynx-alert-container-' + this.position;
55
- container.style.width = '100%';
56
- container.style.maxWidth = this.width;
57
- container.style.zIndex = '1000';
58
- container.classList.add('container-fluid');
54
+ ensureAlertContainer() {
55
+ if (!document.getElementById('avalynx-alert-container-' + this.options.position)) {
56
+ var container = document.createElement('div');
57
+ container.id = 'avalynx-alert-container-' + this.options.position;
58
+ container.style.width = '100%';
59
+ container.style.maxWidth = this.options.width;
60
+ container.style.zIndex = '1000';
61
+ container.classList.add('container-fluid');
59
62
 
60
- if (this.position === 'top-left') {
61
- container.style.position = 'fixed';
62
- container.style.top = '10px';
63
- container.style.left = '0px';
64
- } else if (this.position === 'top-center') {
65
- container.style.position = 'fixed';
66
- container.style.top = '10px';
67
- container.style.left = '50%';
68
- container.style.transform = 'translateX(-50%)';
69
- } else if (this.position === 'top-right') {
70
- container.style.position = 'fixed';
71
- container.style.top = '10px';
72
- container.style.right = '0px';
73
- } else if (this.position === 'bottom-left') {
74
- container.style.position = 'fixed';
75
- container.style.bottom = '10px';
76
- container.style.left = '0px';
77
- } else if (this.position === 'bottom-center') {
78
- container.style.position = 'fixed';
79
- container.style.bottom = '10px';
80
- container.style.left = '50%';
81
- container.style.transform = 'translateX(-50%)';
82
- } else if (this.position === 'bottom-right') {
83
- container.style.position = 'fixed';
84
- container.style.bottom = '10px';
85
- container.style.right = '0px';
86
- }
63
+ if (this.options.position === 'top-left') {
64
+ container.style.position = 'fixed';
65
+ container.style.top = '10px';
66
+ container.style.left = '0px';
67
+ } else if (this.options.position === 'top-center') {
68
+ container.style.position = 'fixed';
69
+ container.style.top = '10px';
70
+ container.style.left = '50%';
71
+ container.style.transform = 'translateX(-50%)';
72
+ } else if (this.options.position === 'top-right') {
73
+ container.style.position = 'fixed';
74
+ container.style.top = '10px';
75
+ container.style.right = '0px';
76
+ } else if (this.options.position === 'bottom-left') {
77
+ container.style.position = 'fixed';
78
+ container.style.bottom = '10px';
79
+ container.style.left = '0px';
80
+ } else if (this.options.position === 'bottom-center') {
81
+ container.style.position = 'fixed';
82
+ container.style.bottom = '10px';
83
+ container.style.left = '50%';
84
+ container.style.transform = 'translateX(-50%)';
85
+ } else if (this.options.position === 'bottom-right') {
86
+ container.style.position = 'fixed';
87
+ container.style.bottom = '10px';
88
+ container.style.right = '0px';
89
+ }
87
90
 
88
- document.body.appendChild(container);
89
- }
90
- }
91
+ document.body.appendChild(container);
92
+ }
93
+ }
91
94
 
92
- init() {
93
- this.ensureAlertContainer();
95
+ init() {
96
+ this.ensureAlertContainer();
94
97
 
95
- var alert = document.createElement('div');
96
- alert.className = `alert alert-${this.type}`;
97
- if (this.closeable) {
98
- alert.classList.add('alert-dismissible');
99
- }
100
- alert.classList.add('fade');
101
- alert.classList.add('show');
102
- alert.classList.add('p-0');
103
- alert.classList.add('overflow-hidden');
104
- alert.classList.add('avalynx-alert');
105
- alert.role = 'alert';
106
- alert.innerHTML = `<div class="alert-content">${this.message}`;
107
- if (this.closeable) {
108
- alert.innerHTML += `<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>`;
109
- }
110
- alert.innerHTML += `</div>`;
111
- if (this.autoClose) {
112
- alert.innerHTML += `<div class="alert-timer" style="height: 5px; width: 0;"></div>`;
113
- }
98
+ var alert = document.createElement('div');
99
+ alert.className = `alert alert-${this.type}`;
100
+ if (this.options.closeable) {
101
+ alert.classList.add('alert-dismissible');
102
+ }
103
+ alert.classList.add('fade');
104
+ alert.classList.add('show');
105
+ alert.classList.add('p-0');
106
+ alert.classList.add('overflow-hidden');
107
+ alert.classList.add('avalynx-alert');
108
+ alert.role = 'alert';
109
+ alert.innerHTML = `<div class="alert-content">${this.message}`;
110
+ if (this.options.closeable) {
111
+ alert.innerHTML += `<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>`;
112
+ }
113
+ alert.innerHTML += `</div>`;
114
+ if (this.options.autoClose) {
115
+ alert.innerHTML += `<div class="alert-timer" style="height: 5px; width: 0;"></div>`;
116
+ }
114
117
 
115
- document.getElementById('avalynx-alert-container-' + this.position).appendChild(alert);
118
+ document.getElementById('avalynx-alert-container-' + this.options.position).appendChild(alert);
116
119
 
117
- if (this.autoClose) {
118
- var timerBar = alert.querySelector('.alert-timer');
119
- timerBar.style.transition = `width ${this.duration}ms linear`;
120
+ if (this.options.autoClose) {
121
+ var timerBar = alert.querySelector('.alert-timer');
122
+ timerBar.style.transition = `width ${this.options.duration}ms linear`;
120
123
 
121
- requestAnimationFrame(() => {
122
- requestAnimationFrame(() => {
123
- timerBar.style.width = '100%';
124
- });
125
- });
124
+ requestAnimationFrame(() => {
125
+ requestAnimationFrame(() => {
126
+ timerBar.style.width = '100%';
127
+ });
128
+ });
126
129
 
127
- setTimeout(() => {
128
- alert.classList.remove('show');
129
- setTimeout(() => {
130
- alert.remove();
131
- if (typeof this.onClose === 'function') {
132
- this.onClose();
133
- }
134
- }, 150);
135
- }, this.duration);
136
- }
137
- }
138
- }
130
+ setTimeout(() => {
131
+ alert.classList.remove('show');
132
+ setTimeout(() => {
133
+ alert.remove();
134
+ if (typeof this.options.onClose === 'function') {
135
+ this.options.onClose();
136
+ }
137
+ }, 150);
138
+ }, this.options.duration);
139
+ }
140
+ }
141
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "avalynx-alert",
3
3
  "title": "AvalynxAlert",
4
4
  "description": "AvalynxAlert is a simple alert system for web applications. Based on Bootstrap >=5.3 without any framework dependencies.",
5
- "version": "0.0.5",
5
+ "version": "0.0.7",
6
6
  "license": "MIT",
7
7
  "main": "dist/js/avalynx-alert.js",
8
8
  "module": "dist/js/avalynx-alert.esm.js",
@@ -13,15 +13,14 @@
13
13
  "dist/js/avalynx-alert.esm.js"
14
14
  ],
15
15
  "keywords": [
16
+ "avalynx",
16
17
  "alert",
17
18
  "bootstrap",
19
+ "bootstrap5",
18
20
  "component",
19
21
  "notification",
20
22
  "popup"
21
23
  ],
22
- "dependencies": {
23
- "bootstrap": ">=5.3"
24
- },
25
24
  "ignore": [
26
25
  "package.json"
27
26
  ],
@@ -36,5 +35,18 @@
36
35
  },
37
36
  "bugs": {
38
37
  "url": "https://github.com/avalynx/avalynx-alert/issues"
38
+ },
39
+ "scripts": {
40
+ "test": "jest"
41
+ },
42
+ "dependencies": {
43
+ "bootstrap": ">=5.3"
44
+ },
45
+ "devDependencies": {
46
+ "@babel/core": "^7",
47
+ "@babel/preset-env": "^7",
48
+ "babel-jest": "^29",
49
+ "jest": "^29",
50
+ "jest-environment-jsdom": "^29"
39
51
  }
40
- }
52
+ }