@t007/toast 0.0.10 → 0.0.12
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/dist/index.global.js +21 -22
- package/dist/index.js +2 -2
- package/dist/standalone.js +21 -22
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
|
-
// ../utils/
|
|
3
|
+
// ../utils/dist/index.js
|
|
4
4
|
function isDef(val) {
|
|
5
5
|
return "undefined" !== typeof val;
|
|
6
6
|
}
|
|
7
|
-
function isObj(obj, checkArr = true) {
|
|
8
|
-
return "object" === typeof obj && obj !== null && (checkArr ? !Array.isArray(obj) : true);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// ../utils/dist/index.js
|
|
12
7
|
function isSym(val) {
|
|
13
8
|
return "symbol" === typeof val;
|
|
14
9
|
}
|
|
@@ -18,21 +13,12 @@
|
|
|
18
13
|
function isStr(val) {
|
|
19
14
|
return "string" === typeof val;
|
|
20
15
|
}
|
|
16
|
+
function isObj(obj, arraycheck = true) {
|
|
17
|
+
return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
|
|
18
|
+
}
|
|
21
19
|
function isFunc(val) {
|
|
22
20
|
return "function" === typeof val;
|
|
23
21
|
}
|
|
24
|
-
function uid(prefix = "") {
|
|
25
|
-
return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
|
|
26
|
-
}
|
|
27
|
-
function isSameURL(src1, src2) {
|
|
28
|
-
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
29
|
-
try {
|
|
30
|
-
const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
|
|
31
|
-
return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
|
|
32
|
-
} catch {
|
|
33
|
-
return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
22
|
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
37
23
|
return assignEl(el, props, dataset, styles), el;
|
|
38
24
|
}
|
|
@@ -79,14 +65,27 @@
|
|
|
79
65
|
function clamp(min = 0, val, max = Infinity) {
|
|
80
66
|
return Math.min(Math.max(val, min), max);
|
|
81
67
|
}
|
|
82
|
-
function
|
|
68
|
+
function uid(prefix = "") {
|
|
69
|
+
return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
|
|
70
|
+
}
|
|
71
|
+
function isSameURL(src1, src2) {
|
|
72
|
+
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
73
|
+
try {
|
|
74
|
+
const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
|
|
75
|
+
return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
|
|
76
|
+
} catch {
|
|
77
|
+
return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function onAllMethods(owner, callback, skipNestedOwn = true, nested = false) {
|
|
83
81
|
let proto = owner;
|
|
84
82
|
while (proto && proto !== Object.prototype) {
|
|
85
83
|
for (const method of Object.getOwnPropertyNames(proto)) {
|
|
86
84
|
if (method === "constructor") continue;
|
|
85
|
+
if (nested && skipNestedOwn && Object.prototype.hasOwnProperty.call(owner, method)) continue;
|
|
87
86
|
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
|
|
88
87
|
}
|
|
89
|
-
proto = Object.getPrototypeOf(proto);
|
|
88
|
+
proto = Object.getPrototypeOf(proto), nested = true;
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
function bindAllMethods(owner) {
|
|
@@ -129,7 +128,7 @@
|
|
|
129
128
|
this.destroyed = false;
|
|
130
129
|
}
|
|
131
130
|
update(options) {
|
|
132
|
-
if (!options || isObj(options)) return this.opts.id;
|
|
131
|
+
if (!options || !isObj(options)) return this.opts.id;
|
|
133
132
|
try {
|
|
134
133
|
this.opts = { ...this.opts, ...options };
|
|
135
134
|
const run = () => Object.keys(options).forEach((key) => this[key] = options[key]);
|
|
@@ -439,7 +438,7 @@
|
|
|
439
438
|
type: ""
|
|
440
439
|
}),
|
|
441
440
|
promise(base, promise = new Promise((res, rej) => setTimeout(Math.round(Math.random()) ? res : rej, 3e3)), { pending, success, error } = {}) {
|
|
442
|
-
if (!promise || isFunc(promise.then)) return console.error("toast.promise() requires a valid promise");
|
|
441
|
+
if (!promise || !isFunc(promise.then)) return console.error("toast.promise() requires a valid promise");
|
|
443
442
|
const NFC = (input, type) => isStr(input) ? { render: input, type } : isObj(input) ? { ...input, type } : { type };
|
|
444
443
|
const pendingConfig = NFC(pending);
|
|
445
444
|
const pendingToastId = base.loading(pendingConfig.render || "Promise pending...", { ...pendingConfig });
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var T007_Toast = class {
|
|
|
23
23
|
this.destroyed = false;
|
|
24
24
|
}
|
|
25
25
|
update(options) {
|
|
26
|
-
if (!options || isObj(options)) return this.opts.id;
|
|
26
|
+
if (!options || !isObj(options)) return this.opts.id;
|
|
27
27
|
try {
|
|
28
28
|
this.opts = { ...this.opts, ...options };
|
|
29
29
|
const run = () => Object.keys(options).forEach((key) => this[key] = options[key]);
|
|
@@ -333,7 +333,7 @@ var toasting = {
|
|
|
333
333
|
type: ""
|
|
334
334
|
}),
|
|
335
335
|
promise(base, promise = new Promise((res, rej) => setTimeout(Math.round(Math.random()) ? res : rej, 3e3)), { pending, success, error } = {}) {
|
|
336
|
-
if (!promise || isFunc(promise.then)) return console.error("toast.promise() requires a valid promise");
|
|
336
|
+
if (!promise || !isFunc(promise.then)) return console.error("toast.promise() requires a valid promise");
|
|
337
337
|
const NFC = (input, type) => isStr(input) ? { render: input, type } : isObj(input) ? { ...input, type } : { type };
|
|
338
338
|
const pendingConfig = NFC(pending);
|
|
339
339
|
const pendingToastId = base.loading(pendingConfig.render || "Promise pending...", { ...pendingConfig });
|
package/dist/standalone.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
// ../utils/
|
|
1
|
+
// ../utils/dist/index.js
|
|
2
2
|
function isDef(val) {
|
|
3
3
|
return "undefined" !== typeof val;
|
|
4
4
|
}
|
|
5
|
-
function isObj(obj, checkArr = true) {
|
|
6
|
-
return "object" === typeof obj && obj !== null && (checkArr ? !Array.isArray(obj) : true);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// ../utils/dist/index.js
|
|
10
5
|
function isSym(val) {
|
|
11
6
|
return "symbol" === typeof val;
|
|
12
7
|
}
|
|
@@ -16,21 +11,12 @@ function isNum(val) {
|
|
|
16
11
|
function isStr(val) {
|
|
17
12
|
return "string" === typeof val;
|
|
18
13
|
}
|
|
14
|
+
function isObj(obj, arraycheck = true) {
|
|
15
|
+
return "object" === typeof obj && obj !== null && (arraycheck ? !Array.isArray(obj) : true);
|
|
16
|
+
}
|
|
19
17
|
function isFunc(val) {
|
|
20
18
|
return "function" === typeof val;
|
|
21
19
|
}
|
|
22
|
-
function uid(prefix = "") {
|
|
23
|
-
return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
|
|
24
|
-
}
|
|
25
|
-
function isSameURL(src1, src2) {
|
|
26
|
-
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
27
|
-
try {
|
|
28
|
-
const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
|
|
29
|
-
return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
|
|
30
|
-
} catch {
|
|
31
|
-
return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
20
|
function createEl(tag, props, dataset, styles, el = tag ? document?.createElement(tag) : null) {
|
|
35
21
|
return assignEl(el, props, dataset, styles), el;
|
|
36
22
|
}
|
|
@@ -77,14 +63,27 @@ function loadResource(req, type = "style", { module, media, crossOrigin, integri
|
|
|
77
63
|
function clamp(min = 0, val, max = Infinity) {
|
|
78
64
|
return Math.min(Math.max(val, min), max);
|
|
79
65
|
}
|
|
80
|
-
function
|
|
66
|
+
function uid(prefix = "") {
|
|
67
|
+
return prefix + Date.now().toString(36) + "_" + performance.now().toString(36).replace(".", "") + "_" + Math.random().toString(36).slice(2);
|
|
68
|
+
}
|
|
69
|
+
function isSameURL(src1, src2) {
|
|
70
|
+
if (!isStr(src1) || !isStr(src2) || !src1 || !src2) return false;
|
|
71
|
+
try {
|
|
72
|
+
const u1 = new URL(src1, window.location.href), u2 = new URL(src2, window.location.href);
|
|
73
|
+
return decodeURIComponent(u1.origin + u1.pathname) === decodeURIComponent(u2.origin + u2.pathname);
|
|
74
|
+
} catch {
|
|
75
|
+
return src1.replace(/\\/g, "/").split("?")[0].trim() === src2.replace(/\\/g, "/").split("?")[0].trim();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function onAllMethods(owner, callback, skipNestedOwn = true, nested = false) {
|
|
81
79
|
let proto = owner;
|
|
82
80
|
while (proto && proto !== Object.prototype) {
|
|
83
81
|
for (const method of Object.getOwnPropertyNames(proto)) {
|
|
84
82
|
if (method === "constructor") continue;
|
|
83
|
+
if (nested && skipNestedOwn && Object.prototype.hasOwnProperty.call(owner, method)) continue;
|
|
85
84
|
if (isFunc(Object.getOwnPropertyDescriptor(proto, method)?.value)) callback(method, owner);
|
|
86
85
|
}
|
|
87
|
-
proto = Object.getPrototypeOf(proto);
|
|
86
|
+
proto = Object.getPrototypeOf(proto), nested = true;
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
function bindAllMethods(owner) {
|
|
@@ -127,7 +126,7 @@ var T007_Toast = class {
|
|
|
127
126
|
this.destroyed = false;
|
|
128
127
|
}
|
|
129
128
|
update(options) {
|
|
130
|
-
if (!options || isObj(options)) return this.opts.id;
|
|
129
|
+
if (!options || !isObj(options)) return this.opts.id;
|
|
131
130
|
try {
|
|
132
131
|
this.opts = { ...this.opts, ...options };
|
|
133
132
|
const run = () => Object.keys(options).forEach((key) => this[key] = options[key]);
|
|
@@ -437,7 +436,7 @@ var toasting = {
|
|
|
437
436
|
type: ""
|
|
438
437
|
}),
|
|
439
438
|
promise(base, promise = new Promise((res, rej) => setTimeout(Math.round(Math.random()) ? res : rej, 3e3)), { pending, success, error } = {}) {
|
|
440
|
-
if (!promise || isFunc(promise.then)) return console.error("toast.promise() requires a valid promise");
|
|
439
|
+
if (!promise || !isFunc(promise.then)) return console.error("toast.promise() requires a valid promise");
|
|
441
440
|
const NFC = (input, type) => isStr(input) ? { render: input, type } : isObj(input) ? { ...input, type } : { type };
|
|
442
441
|
const pendingConfig = NFC(pending);
|
|
443
442
|
const pendingToastId = base.loading(pendingConfig.render || "Promise pending...", { ...pendingConfig });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/toast",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "A lightweight, pure JS toast system.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,6 +55,6 @@
|
|
|
55
55
|
"promise"
|
|
56
56
|
],
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@t007/utils": "^0.0.
|
|
58
|
+
"@t007/utils": "^0.0.15"
|
|
59
59
|
}
|
|
60
60
|
}
|