@t007/toast 0.0.33 → 0.0.34

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.
@@ -53,7 +53,7 @@
53
53
  return el;
54
54
  }
55
55
 
56
- // ../../../sia-reactor/dist/chunk-SHWIAQD2.js
56
+ // ../../../sia-reactor/dist/chunk-WYSENFHG.js
57
57
  var RTR_BATCH = "undefined" !== typeof window ? ("undefined" !== typeof queueMicrotask ? queueMicrotask : setTimeout).bind(window) : "undefined" !== typeof process && process.nextTick ? process.nextTick : setTimeout;
58
58
  var RTR_LOG = console.log.bind(console, "[S.I.A Reactor]");
59
59
  var NIL = Object.freeze({});
@@ -66,7 +66,7 @@
66
66
  return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
67
67
  }
68
68
 
69
- // ../utils/dist/chunk-ZALPHCSJ.js
69
+ // ../utils/dist/chunk-ZOFWWRKV.js
70
70
  var INTERACTIVE_SELECTOR = ":is(button,[href],input:not([type='hidden']),select,textarea,details>summary,[contenteditable],iframe,audio[controls],video[controls],[tabindex]):not([disabled],[tabindex='-1'],[data-focus-guard],[inert],[inert] *)";
71
71
  var isInteractive = (target) => target instanceof HTMLElement && target.matches(INTERACTIVE_SELECTOR);
72
72
  var VIRTUAL_RESOURCE = /* @__PURE__ */ Symbol.for("T007_VIRTUAL_RESOURCE");
@@ -86,7 +86,7 @@
86
86
  console.warn(`Retrying ${type} load for "${src}" (${attempts - remaining + 1})...`);
87
87
  } else {
88
88
  delete win.t007._resourceCache[src];
89
- reject(new Error(`${capitalize(type)} load failed for "${src}" after ${attempts - 1} attempts`));
89
+ reject(new Error(`${capitalize(type)} load failed for "${src}"`));
90
90
  }
91
91
  };
92
92
  const url = retryKey && remaining < attempts ? `${src}${src.includes("?") ? "&" : "?"}_${retryKey}=${Date.now()}` : src;
@@ -159,11 +159,11 @@
159
159
  inactive = true;
160
160
  #visiblityChange = () => this.#shouldUnPause = document.visibilityState === "visible";
161
161
  constructor(options) {
162
- bindAllMethods(this), bindCleanupToSignal(this.abort, options.signal);
162
+ bindAllMethods(this);
163
163
  this.opts = options;
164
164
  t007.toasts.set(this.opts.id ??= uid(this.opts.groupId ??= "t007_toast_"), this);
165
165
  !isNum(this.opts.delay) ? this.activate() : this.queue.push(setTimeout2(this.activate, this.opts.delay, this.opts.signal));
166
- this.update(this.opts);
166
+ this.update(this.opts), bindCleanupToSignal(this.abort, options.signal);
167
167
  }
168
168
  activate() {
169
169
  this.toastElement = createEl("div", { className: `t007-toast${this.scoped ? " t007-toast-scoped" : ""}`, id: this.opts.id, ariaAtomic: "true" }, { groupId: this.opts.groupId });
@@ -407,8 +407,8 @@
407
407
  document.removeEventListener("visibilitychange", this.#visiblityChange);
408
408
  cancelAnimationFrame(this.#autoCloseInterval), cancelAnimationFrame(this.#progressInterval);
409
409
  if (this.inactive || manner === "instant" || !this.animation) this._cleanUpToast();
410
- else this.toastElement.onanimationend = this._cleanUpToast;
411
- this.toastElement.classList.remove("t007-toast-show");
410
+ else if (this.toastElement) this.toastElement.onanimationend = this._cleanUpToast;
411
+ this.toastElement?.classList.remove("t007-toast-show");
412
412
  this.onClose?.(timeElapsed);
413
413
  }
414
414
  abort = () => this.remove("instant", false);
package/dist/index.js CHANGED
@@ -12,11 +12,11 @@ var T007_Toast = class {
12
12
  inactive = true;
13
13
  #visiblityChange = () => this.#shouldUnPause = document.visibilityState === "visible";
14
14
  constructor(options) {
15
- bindAllMethods(this), bindCleanupToSignal(this.abort, options.signal);
15
+ bindAllMethods(this);
16
16
  this.opts = options;
17
17
  t007.toasts.set(this.opts.id ??= uid(this.opts.groupId ??= "t007_toast_"), this);
18
18
  !isNum(this.opts.delay) ? this.activate() : this.queue.push(setTimeout(this.activate, this.opts.delay, this.opts.signal));
19
- this.update(this.opts);
19
+ this.update(this.opts), bindCleanupToSignal(this.abort, options.signal);
20
20
  }
21
21
  activate() {
22
22
  this.toastElement = createEl("div", { className: `t007-toast${this.scoped ? " t007-toast-scoped" : ""}`, id: this.opts.id, ariaAtomic: "true" }, { groupId: this.opts.groupId });
@@ -260,8 +260,8 @@ var T007_Toast = class {
260
260
  document.removeEventListener("visibilitychange", this.#visiblityChange);
261
261
  cancelAnimationFrame(this.#autoCloseInterval), cancelAnimationFrame(this.#progressInterval);
262
262
  if (this.inactive || manner === "instant" || !this.animation) this._cleanUpToast();
263
- else this.toastElement.onanimationend = this._cleanUpToast;
264
- this.toastElement.classList.remove("t007-toast-show");
263
+ else if (this.toastElement) this.toastElement.onanimationend = this._cleanUpToast;
264
+ this.toastElement?.classList.remove("t007-toast-show");
265
265
  this.onClose?.(timeElapsed);
266
266
  }
267
267
  abort = () => this.remove("instant", false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t007/toast",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "A lightweight, pure JS toast system.",
5
5
  "author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
6
6
  "license": "MIT",
@@ -55,7 +55,7 @@
55
55
  "promise"
56
56
  ],
57
57
  "dependencies": {
58
- "@t007/utils": "^0.0.35"
58
+ "@t007/utils": "^0.0.36"
59
59
  },
60
60
  "devDependencies": {
61
61
  "esbuild-sass-plugin": "^3.7.0"