tiny-essentials 1.10.2 → 1.11.0

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.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/dist/{TinyEssentials.js → v1/TinyEssentials.js} +804 -0
  3. package/dist/v1/TinyEssentials.min.js +2 -0
  4. package/dist/v1/TinyNotifyCenter.js +461 -0
  5. package/dist/v1/TinyNotifyCenter.min.js +1 -0
  6. package/dist/v1/TinyToastNotify.js +417 -0
  7. package/dist/v1/TinyToastNotify.min.js +1 -0
  8. package/dist/v1/build/TinyNotifyCenter.cjs +7 -0
  9. package/dist/v1/build/TinyNotifyCenter.d.mts +3 -0
  10. package/dist/v1/build/TinyNotifyCenter.mjs +2 -0
  11. package/dist/v1/build/TinyToastNotify.cjs +7 -0
  12. package/dist/v1/build/TinyToastNotify.d.mts +3 -0
  13. package/dist/v1/build/TinyToastNotify.mjs +2 -0
  14. package/dist/v1/css/TinyNotify.css +350 -0
  15. package/dist/v1/css/TinyNotify.min.css +1 -0
  16. package/dist/v1/index.cjs +4 -0
  17. package/dist/v1/index.d.mts +3 -1
  18. package/dist/v1/index.mjs +3 -1
  19. package/dist/v1/libs/TinyNotifyCenter.cjs +422 -0
  20. package/dist/v1/libs/TinyNotifyCenter.d.mts +166 -0
  21. package/dist/v1/libs/TinyNotifyCenter.mjs +385 -0
  22. package/dist/v1/libs/TinyToastNotify.cjs +378 -0
  23. package/dist/v1/libs/TinyToastNotify.d.mts +157 -0
  24. package/dist/v1/libs/TinyToastNotify.mjs +332 -0
  25. package/docs/{README.md → v1/README.md} +2 -0
  26. package/docs/{basics → v1/basics}/text.md +2 -2
  27. package/docs/v1/libs/TinyNotifyCenter.md +291 -0
  28. package/docs/v1/libs/TinyToastNotify.md +290 -0
  29. package/package.json +4 -2
  30. package/dist/TinyEssentials.min.js +0 -2
  31. package/dist/v1/libs/TinyRateLimit.cjs +0 -196
  32. package/dist/v1/libs/TinyRateLimit.d.mts +0 -86
  33. package/dist/v1/libs/TinyRateLimit.mjs +0 -171
  34. /package/dist/{ColorSafeStringify.js → v1/ColorSafeStringify.js} +0 -0
  35. /package/dist/{ColorSafeStringify.min.js → v1/ColorSafeStringify.min.js} +0 -0
  36. /package/dist/{TinyBasicsEs.js → v1/TinyBasicsEs.js} +0 -0
  37. /package/dist/{TinyBasicsEs.min.js → v1/TinyBasicsEs.min.js} +0 -0
  38. /package/dist/{TinyBasicsEs.min.js.LICENSE.txt → v1/TinyBasicsEs.min.js.LICENSE.txt} +0 -0
  39. /package/dist/{TinyEssentials.min.js.LICENSE.txt → v1/TinyEssentials.min.js.LICENSE.txt} +0 -0
  40. /package/dist/{TinyLevelUp.js → v1/TinyLevelUp.js} +0 -0
  41. /package/dist/{TinyLevelUp.min.js → v1/TinyLevelUp.min.js} +0 -0
  42. /package/dist/{TinyPromiseQueue.js → v1/TinyPromiseQueue.js} +0 -0
  43. /package/dist/{TinyPromiseQueue.min.js → v1/TinyPromiseQueue.min.js} +0 -0
  44. /package/dist/{TinyRateLimiter.js → v1/TinyRateLimiter.js} +0 -0
  45. /package/dist/{TinyRateLimiter.min.js → v1/TinyRateLimiter.min.js} +0 -0
  46. /package/dist/{aiMarker.css → v1/css/aiMarker.css} +0 -0
  47. /package/dist/{aiMarker.min.css → v1/css/aiMarker.min.css} +0 -0
  48. /package/docs/{basics → v1/basics}/array.md +0 -0
  49. /package/docs/{basics → v1/basics}/asyncReplace.md +0 -0
  50. /package/docs/{basics → v1/basics}/clock.md +0 -0
  51. /package/docs/{basics → v1/basics}/objFilter.md +0 -0
  52. /package/docs/{basics → v1/basics}/simpleMath.md +0 -0
  53. /package/docs/{libs → v1/libs}/ColorSafeStringify.md +0 -0
  54. /package/docs/{libs → v1/libs}/TinyLevelUp.md +0 -0
  55. /package/docs/{libs → v1/libs}/TinyPromiseQueue.md +0 -0
  56. /package/docs/{libs → v1/libs}/TinyRateLimiter.md +0 -0
@@ -0,0 +1,422 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Represents a single notification entry.
5
+ *
6
+ * A notification can be provided as a simple string (treated as a plain message),
7
+ * or as an object with additional data such as a title, an avatar image, and a click handler.
8
+ *
9
+ * @typedef {string | {
10
+ * title?: string, // Optional title displayed above the message
11
+ * message: string, // Required message content
12
+ * avatar?: string, // Optional avatar image URL (displayed on the left)
13
+ * onClick?: (e: MouseEvent) => void // Optional click handler for the entire notification
14
+ * }} NotifyData
15
+ */
16
+
17
+ /**
18
+ * A notification center component for displaying interactive alerts in the UI.
19
+ *
20
+ * This class renders a notification overlay on the page and allows dynamically
21
+ * adding, clearing, or interacting with notification items. Notifications can
22
+ * contain plain text or HTML, and optionally support click events, titles, and avatars.
23
+ *
24
+ * Features:
25
+ * - Dynamic rendering of notification UI with `insertTemplate()`
26
+ * - Supports text and HTML content modes
27
+ * - Optional avatars for each notification
28
+ * - Callback support on notification click
29
+ * - Per-notification close buttons
30
+ * - Notification count badge
31
+ *
32
+ * @class
33
+ */
34
+ class TinyNotifyCenter {
35
+ /**
36
+ * Returns the full HTML structure for the notification system as a string.
37
+ *
38
+ * This includes:
39
+ * - A hidden `.notify-overlay` containing the central notification panel (`#notifCenter`),
40
+ * which has a header with a "Notifications" label, a "clear all" button, and a close button.
41
+ * - A `.list` container for dynamically added notifications.
42
+ * - A bell button (`.notify-bell`) to toggle the notification center, with an embedded badge.
43
+ *
44
+ * This template can be inserted into the DOM using `insertAdjacentHTML()` or parsed dynamically
45
+ * into elements using JavaScript or jQuery, depending on the needs of the system.
46
+ *
47
+ * @returns {string} The complete HTML structure for the notification center.
48
+ */
49
+ static getTemplate() {
50
+ return `
51
+ <div class="notify-overlay hidden">
52
+ <div class="notify-center" id="notifCenter">
53
+ <div class="header">
54
+ <div>Notifications</div>
55
+ <div class="options">
56
+ <button class="clear-all" type="button">
57
+ <svg
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ viewBox="0 0 24 24"
60
+ width="24"
61
+ height="24"
62
+ fill="currentColor"
63
+ >
64
+ <path
65
+ d="M21.6 2.4a1 1 0 0 0-1.4 0L13 9.6l-1.3-1.3a1 1 0 0 0-1.4 0L3 15.6a1 1 0 0 0 0 1.4l4 4a1 1 0 0 0 1.4 0l7.3-7.3a1 1 0 0 0 0-1.4l-1.3-1.3 7.2-7.2a1 1 0 0 0 0-1.4zM6 17l3.5-3.5 1.5 1.5L7.5 18.5 6 17z"
66
+ />
67
+ </svg>
68
+ </button>
69
+ <button class="close">×</button>
70
+ </div>
71
+ </div>
72
+ <div class="list"></div>
73
+ </div>
74
+ </div>
75
+
76
+ <button class="notify-bell" aria-label="Open notifications">
77
+ <svg
78
+ xmlns="http://www.w3.org/2000/svg"
79
+ width="20"
80
+ height="20"
81
+ fill="currentColor"
82
+ viewBox="0 0 24 24"
83
+ >
84
+ <path
85
+ d="M12 2C10.3 2 9 3.3 9 5v1.1C6.7 7.2 5 9.4 5 12v5l-1 1v1h16v-1l-1-1v-5c0-2.6-1.7-4.8-4-5.9V5c0-1.7-1.3-3-3-3zm0 20c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2z"
86
+ />
87
+ </svg>
88
+ <span class="badge" id="notifBadge">0</span>
89
+ </button>
90
+ `;
91
+ }
92
+
93
+ /**
94
+ * Inserts the full notification center template into the document body.
95
+ *
96
+ * The structure is injected directly into the DOM using
97
+ * `insertAdjacentHTML`.
98
+ *
99
+ * The `where` parameter allows control over where inside the `document.body`
100
+ * the HTML is inserted:
101
+ * - `'afterbegin'` (default): Inserts right after the opening <body> tag.
102
+ * - `'beforeend'`: Inserts right before the closing </body> tag.
103
+ * - Any valid position accepted by `insertAdjacentHTML`.
104
+ *
105
+ * @param {'beforebegin'|'afterbegin'|'beforeend'|'afterend'} [where='afterbegin']
106
+ * The position relative to `document.body` where the HTML should be inserted.
107
+ */
108
+ static insertTemplate(where = 'afterbegin') {
109
+ document.body.insertAdjacentHTML(where, TinyNotifyCenter.getTemplate());
110
+ }
111
+
112
+ /** @type {HTMLElement} */
113
+ #center;
114
+ /** @type {HTMLElement} */
115
+ #list;
116
+ /** @type {HTMLElement} */
117
+ #badge;
118
+ /** @type {HTMLElement} */
119
+ #button;
120
+ /** @type {HTMLElement} */
121
+ #overlay;
122
+
123
+ #count = 0;
124
+ #maxCount = 99;
125
+ #removeDelay = 300;
126
+ #markAllAsReadOnClose = false;
127
+ #modes = new WeakMap();
128
+
129
+ /** @param {HTMLElement|ChildNode} item */
130
+ #removeItem(item) {
131
+ this.#modes.delete(item);
132
+ if (item instanceof HTMLElement) {
133
+ item.classList.add('removing');
134
+
135
+ setTimeout(() => {
136
+ this.markAsRead(item);
137
+ item.remove();
138
+ }, this.#removeDelay);
139
+ } else throw new Error('Invalid HTMLElement to clear.');
140
+ }
141
+
142
+ /**
143
+ * Update notify count and badge.
144
+ * @param {number} value
145
+ */
146
+ #updateCount(value) {
147
+ this.#count = Math.max(0, value);
148
+ this.#badge.setAttribute('data-value', String(this.#count));
149
+ this.#badge.textContent =
150
+ this.#count > this.#maxCount ? `${this.#maxCount}+` : String(this.#count);
151
+ }
152
+
153
+ /**
154
+ * Options for configuring the NotificationCenter instance.
155
+ *
156
+ * Allows manual specification of the main elements used by the notification center.
157
+ * If not provided, default elements will be selected from the DOM automatically.
158
+ *
159
+ * @param {Object} options - Configuration object.
160
+ * @param {HTMLElement} [options.center=document.getElementById('notifCenter')] - The container element that holds the list of notifications.
161
+ * @param {HTMLElement} [options.badge=document.getElementById('notifBadge')] - The badge element used to display the current notification count.
162
+ * @param {HTMLElement} [options.button=document.querySelector('.notify-bell')] - The button element that toggles the notification center.
163
+ * @param {HTMLElement} [options.overlay=document.querySelector('.notify-overlay')] - The overlay element that covers the screen when the center is visible.
164
+ */
165
+ constructor(options = {}) {
166
+ const {
167
+ center = document.getElementById('notifCenter'),
168
+ badge = document.getElementById('notifBadge'),
169
+ button = document.querySelector('.notify-bell'),
170
+ overlay = document.querySelector('.notify-overlay'),
171
+ } = options;
172
+
173
+ // Element existence and type validation
174
+ if (!(center instanceof HTMLElement))
175
+ throw new Error(`NotificationCenter: "center" must be an HTMLElement. Got: ${center}`);
176
+ if (!(overlay instanceof HTMLElement))
177
+ throw new Error(`NotificationCenter: "overlay" must be an HTMLElement. Got: ${overlay}`);
178
+ if (!(badge instanceof HTMLElement))
179
+ throw new Error(`NotificationCenter: "badge" must be an HTMLElement. Got: ${badge}`);
180
+ if (!(button instanceof HTMLElement))
181
+ throw new Error(`NotificationCenter: "button" must be an HTMLElement. Got: ${button}`);
182
+
183
+ const clearAllBtn = center?.querySelector('.clear-all');
184
+ const list = center?.querySelector('.list') ?? null;
185
+ if (!(list instanceof HTMLElement))
186
+ throw new Error(
187
+ `NotificationCenter: ".list" inside center must be an HTMLElement. Got: ${list}`,
188
+ );
189
+
190
+ this.#center = center;
191
+ this.#list = list;
192
+ this.#badge = badge;
193
+ this.#button = button;
194
+ this.#overlay = overlay;
195
+
196
+ this.#button.addEventListener('click', () => this.toggle());
197
+ this.#center.querySelector('.close')?.addEventListener('click', () => this.close());
198
+ if (clearAllBtn) clearAllBtn.addEventListener('click', () => this.clear());
199
+ this.#overlay.addEventListener('click', (e) => {
200
+ if (e.target === this.#overlay) this.close();
201
+ });
202
+ }
203
+
204
+ /**
205
+ * Enable or disable automatic mark-as-read on close.
206
+ * @param {boolean} value
207
+ */
208
+ setMarkAllAsReadOnClose(value) {
209
+ if (typeof value !== 'boolean')
210
+ throw new TypeError(`Expected boolean for markAllAsReadOnClose, got ${typeof value}`);
211
+ this.#markAllAsReadOnClose = value;
212
+ }
213
+
214
+ /**
215
+ * Define how long the remove animation takes (in ms).
216
+ * @param {number} ms
217
+ */
218
+ setRemoveDelay(ms) {
219
+ if (typeof ms !== 'number') throw new Error(`NotificationCenter: "ms" must be an number.`);
220
+ this.#removeDelay = ms;
221
+ }
222
+
223
+ /**
224
+ * Get rendering mode ('text' or 'html') by index.
225
+ * @param {number} index
226
+ * @returns {'text' | 'html' | null}
227
+ */
228
+ getItemMode(index) {
229
+ const item = this.getItem(index);
230
+ return item ? this.#modes.get(item) : null;
231
+ }
232
+
233
+ /**
234
+ * Get a notify element by index.
235
+ * @param {number} index
236
+ * @returns {HTMLElement}
237
+ */
238
+ getItem(index) {
239
+ const element = this.#list.children.item(index);
240
+ if (!(element instanceof HTMLElement))
241
+ throw new Error(`NotificationCenter: "item" must be an HTMLElement. Got: ${element}`);
242
+ return element;
243
+ }
244
+
245
+ /**
246
+ * Check if a notify exists at the given index.
247
+ * @param {number} index
248
+ * @returns {boolean}
249
+ */
250
+ hasItem(index) {
251
+ return index >= 0 && index < this.#list.children.length;
252
+ }
253
+
254
+ /**
255
+ * Mark a notification index as read.
256
+ * @param {number|HTMLElement} index
257
+ */
258
+ markAsRead(index) {
259
+ const item = index instanceof HTMLElement ? index : this.getItem(index);
260
+ if (item.classList.contains('unread')) {
261
+ item.classList.remove('unread');
262
+ this.#updateCount(this.#count - 1);
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Add a new notify to the center.
268
+ *
269
+ * @param {NotifyData} message - Notification content or a full object with title, avatar, and callback.
270
+ * @param {'text'|'html'} [mode='text'] - How to treat the message content.
271
+ */
272
+ add(message, mode = 'text') {
273
+ const item = document.createElement('div');
274
+ item.className = 'item unread';
275
+
276
+ let titleText = null;
277
+ let messageText = null;
278
+ let avatarUrl = null;
279
+ let onClick = null;
280
+
281
+ if (typeof message === 'object' && message !== null) {
282
+ titleText = message.title;
283
+ messageText = message.message;
284
+ avatarUrl = message.avatar;
285
+ onClick = message.onClick;
286
+ } else {
287
+ messageText = message;
288
+ }
289
+
290
+ // Optional avatar
291
+ if (avatarUrl) {
292
+ const avatarElem = document.createElement('div');
293
+ avatarElem.className = 'avatar';
294
+ avatarElem.style.backgroundImage = `url("${avatarUrl}")`;
295
+ item.appendChild(avatarElem);
296
+ }
297
+
298
+ // Content wrapper
299
+ const contentWrapper = document.createElement('div');
300
+ contentWrapper.className = 'content';
301
+
302
+ // Optional title
303
+ if (titleText) {
304
+ const titleElem = document.createElement('div');
305
+ titleElem.className = 'title';
306
+ titleElem.textContent = titleText;
307
+ contentWrapper.appendChild(titleElem);
308
+ }
309
+
310
+ // Message
311
+ const messageElem = document.createElement('div');
312
+ messageElem.className = 'message';
313
+
314
+ if (mode === 'html') {
315
+ messageElem.innerHTML = messageText;
316
+ } else {
317
+ messageElem.textContent = messageText;
318
+ }
319
+
320
+ contentWrapper.appendChild(messageElem);
321
+
322
+ // Action by clicking (if provided)
323
+ if (typeof onClick === 'function') {
324
+ item.classList.add('clickable');
325
+ item.addEventListener('click', (e) => {
326
+ // Prevents the close button from clicking
327
+ if (e.target instanceof HTMLElement && !e.target.closest('.notify-close')) {
328
+ onClick(e);
329
+ }
330
+ });
331
+ }
332
+
333
+ // Close button
334
+ const closeBtn = document.createElement('button');
335
+ closeBtn.className = 'notify-close';
336
+ closeBtn.setAttribute('type', 'button');
337
+ closeBtn.innerHTML = '&times;';
338
+ closeBtn.addEventListener('click', (e) => {
339
+ e.stopPropagation(); // prevents propagation for the main onClick
340
+ this.#removeItem(item);
341
+ });
342
+
343
+ item.append(contentWrapper, closeBtn);
344
+ this.#list.prepend(item);
345
+ this.#modes.set(item, mode);
346
+ this.#updateCount(this.#count + 1);
347
+ }
348
+
349
+ /**
350
+ * Remove a notify by index.
351
+ * @param {number} index
352
+ */
353
+ remove(index) {
354
+ const item = this.getItem(index);
355
+ this.#removeItem(item);
356
+ }
357
+
358
+ /**
359
+ * Clear all notifications safely.
360
+ */
361
+ clear() {
362
+ let needAgain = true;
363
+ while (needAgain) {
364
+ needAgain = false;
365
+ const items = Array.from(this.#list.children);
366
+ for (const item of items) {
367
+ if (item instanceof HTMLElement && !item.classList.contains('removing')) {
368
+ this.#removeItem(item);
369
+ needAgain = true;
370
+ }
371
+ }
372
+ }
373
+ }
374
+
375
+ /**
376
+ * Open the notify center.
377
+ */
378
+ open() {
379
+ this.#overlay.classList.remove('hidden');
380
+ this.#center.classList.add('open');
381
+ }
382
+
383
+ /**
384
+ * Close the notify center.
385
+ */
386
+ close() {
387
+ this.#overlay.classList.add('hidden');
388
+ this.#center.classList.remove('open');
389
+ if (this.#markAllAsReadOnClose) {
390
+ const items = this.#list.querySelectorAll('.item.unread');
391
+ for (const item of items) {
392
+ if (item instanceof HTMLElement) this.markAsRead(item);
393
+ }
394
+ }
395
+ }
396
+
397
+ /**
398
+ * Toggle open/close state.
399
+ */
400
+ toggle() {
401
+ if (this.#center.classList.contains('open')) this.close();
402
+ else this.open();
403
+ }
404
+
405
+ /**
406
+ * Recalculate the number of notifications based on the actual DOM list.
407
+ */
408
+ recount() {
409
+ const count = this.#list.querySelectorAll('.item.unread').length;
410
+ this.#updateCount(count);
411
+ }
412
+
413
+ /**
414
+ * Get current count.
415
+ * @returns {number}
416
+ */
417
+ get count() {
418
+ return this.#count;
419
+ }
420
+ }
421
+
422
+ module.exports = TinyNotifyCenter;
@@ -0,0 +1,166 @@
1
+ export default TinyNotifyCenter;
2
+ /**
3
+ * Represents a single notification entry.
4
+ *
5
+ * A notification can be provided as a simple string (treated as a plain message),
6
+ * or as an object with additional data such as a title, an avatar image, and a click handler.
7
+ */
8
+ export type NotifyData = string | {
9
+ title?: string;
10
+ message: string;
11
+ avatar?: string;
12
+ onClick?: (e: MouseEvent) => void;
13
+ };
14
+ /**
15
+ * Represents a single notification entry.
16
+ *
17
+ * A notification can be provided as a simple string (treated as a plain message),
18
+ * or as an object with additional data such as a title, an avatar image, and a click handler.
19
+ *
20
+ * @typedef {string | {
21
+ * title?: string, // Optional title displayed above the message
22
+ * message: string, // Required message content
23
+ * avatar?: string, // Optional avatar image URL (displayed on the left)
24
+ * onClick?: (e: MouseEvent) => void // Optional click handler for the entire notification
25
+ * }} NotifyData
26
+ */
27
+ /**
28
+ * A notification center component for displaying interactive alerts in the UI.
29
+ *
30
+ * This class renders a notification overlay on the page and allows dynamically
31
+ * adding, clearing, or interacting with notification items. Notifications can
32
+ * contain plain text or HTML, and optionally support click events, titles, and avatars.
33
+ *
34
+ * Features:
35
+ * - Dynamic rendering of notification UI with `insertTemplate()`
36
+ * - Supports text and HTML content modes
37
+ * - Optional avatars for each notification
38
+ * - Callback support on notification click
39
+ * - Per-notification close buttons
40
+ * - Notification count badge
41
+ *
42
+ * @class
43
+ */
44
+ declare class TinyNotifyCenter {
45
+ /**
46
+ * Returns the full HTML structure for the notification system as a string.
47
+ *
48
+ * This includes:
49
+ * - A hidden `.notify-overlay` containing the central notification panel (`#notifCenter`),
50
+ * which has a header with a "Notifications" label, a "clear all" button, and a close button.
51
+ * - A `.list` container for dynamically added notifications.
52
+ * - A bell button (`.notify-bell`) to toggle the notification center, with an embedded badge.
53
+ *
54
+ * This template can be inserted into the DOM using `insertAdjacentHTML()` or parsed dynamically
55
+ * into elements using JavaScript or jQuery, depending on the needs of the system.
56
+ *
57
+ * @returns {string} The complete HTML structure for the notification center.
58
+ */
59
+ static getTemplate(): string;
60
+ /**
61
+ * Inserts the full notification center template into the document body.
62
+ *
63
+ * The structure is injected directly into the DOM using
64
+ * `insertAdjacentHTML`.
65
+ *
66
+ * The `where` parameter allows control over where inside the `document.body`
67
+ * the HTML is inserted:
68
+ * - `'afterbegin'` (default): Inserts right after the opening <body> tag.
69
+ * - `'beforeend'`: Inserts right before the closing </body> tag.
70
+ * - Any valid position accepted by `insertAdjacentHTML`.
71
+ *
72
+ * @param {'beforebegin'|'afterbegin'|'beforeend'|'afterend'} [where='afterbegin']
73
+ * The position relative to `document.body` where the HTML should be inserted.
74
+ */
75
+ static insertTemplate(where?: "beforebegin" | "afterbegin" | "beforeend" | "afterend"): void;
76
+ /**
77
+ * Options for configuring the NotificationCenter instance.
78
+ *
79
+ * Allows manual specification of the main elements used by the notification center.
80
+ * If not provided, default elements will be selected from the DOM automatically.
81
+ *
82
+ * @param {Object} options - Configuration object.
83
+ * @param {HTMLElement} [options.center=document.getElementById('notifCenter')] - The container element that holds the list of notifications.
84
+ * @param {HTMLElement} [options.badge=document.getElementById('notifBadge')] - The badge element used to display the current notification count.
85
+ * @param {HTMLElement} [options.button=document.querySelector('.notify-bell')] - The button element that toggles the notification center.
86
+ * @param {HTMLElement} [options.overlay=document.querySelector('.notify-overlay')] - The overlay element that covers the screen when the center is visible.
87
+ */
88
+ constructor(options?: {
89
+ center?: HTMLElement | undefined;
90
+ badge?: HTMLElement | undefined;
91
+ button?: HTMLElement | undefined;
92
+ overlay?: HTMLElement | undefined;
93
+ });
94
+ /**
95
+ * Enable or disable automatic mark-as-read on close.
96
+ * @param {boolean} value
97
+ */
98
+ setMarkAllAsReadOnClose(value: boolean): void;
99
+ /**
100
+ * Define how long the remove animation takes (in ms).
101
+ * @param {number} ms
102
+ */
103
+ setRemoveDelay(ms: number): void;
104
+ /**
105
+ * Get rendering mode ('text' or 'html') by index.
106
+ * @param {number} index
107
+ * @returns {'text' | 'html' | null}
108
+ */
109
+ getItemMode(index: number): "text" | "html" | null;
110
+ /**
111
+ * Get a notify element by index.
112
+ * @param {number} index
113
+ * @returns {HTMLElement}
114
+ */
115
+ getItem(index: number): HTMLElement;
116
+ /**
117
+ * Check if a notify exists at the given index.
118
+ * @param {number} index
119
+ * @returns {boolean}
120
+ */
121
+ hasItem(index: number): boolean;
122
+ /**
123
+ * Mark a notification index as read.
124
+ * @param {number|HTMLElement} index
125
+ */
126
+ markAsRead(index: number | HTMLElement): void;
127
+ /**
128
+ * Add a new notify to the center.
129
+ *
130
+ * @param {NotifyData} message - Notification content or a full object with title, avatar, and callback.
131
+ * @param {'text'|'html'} [mode='text'] - How to treat the message content.
132
+ */
133
+ add(message: NotifyData, mode?: "text" | "html"): void;
134
+ /**
135
+ * Remove a notify by index.
136
+ * @param {number} index
137
+ */
138
+ remove(index: number): void;
139
+ /**
140
+ * Clear all notifications safely.
141
+ */
142
+ clear(): void;
143
+ /**
144
+ * Open the notify center.
145
+ */
146
+ open(): void;
147
+ /**
148
+ * Close the notify center.
149
+ */
150
+ close(): void;
151
+ /**
152
+ * Toggle open/close state.
153
+ */
154
+ toggle(): void;
155
+ /**
156
+ * Recalculate the number of notifications based on the actual DOM list.
157
+ */
158
+ recount(): void;
159
+ /**
160
+ * Get current count.
161
+ * @returns {number}
162
+ */
163
+ get count(): number;
164
+ #private;
165
+ }
166
+ //# sourceMappingURL=TinyNotifyCenter.d.mts.map