ono-react-element 0.0.12 → 0.0.13
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/es/{AutoSliderList-DCpCHe1X.js → AutoSliderList-w9mw0JCN.js} +9 -9
- package/dist/es/InjunctiveBox-DUNoNHCO.js +11 -0
- package/dist/es/{Input-CYA8Q8B5.js → Input-DLOeg2pz.js} +30 -30
- package/dist/es/Message-BGDILiLc.js +105 -0
- package/dist/es/{Modal-D4gV43Cy.js → Modal-BIFxRjSt.js} +10 -10
- package/dist/es/{Select-CJuIMAoG.js → Select-DAU6TuBu.js} +6 -6
- package/dist/es/{Switch-CN3M5pXb.js → Switch-CRJejHP9.js} +13 -13
- package/dist/es/{TemplateDialog-DKEBuvXA.js → TemplateDialog-dD8BcnbA.js} +9 -9
- package/dist/es/{Toast-DHu6WOZ0.js → Toast-CQEsbqUJ.js} +27 -27
- package/dist/es/{Tooltip-Dj8ZeMVG.js → Tooltip-j2AKREfX.js} +13 -13
- package/dist/es/VirtualList-w16-kBkT.js +65 -0
- package/dist/es/{Waterfall-Ce9ZeKxm.js → Waterfall-CFVkuuCO.js} +17 -17
- package/dist/es/colorUtils.ts-DYuRvCXZ.js +145 -0
- package/dist/es/common.ts-DQOEx8k3.js +126 -0
- package/dist/es/fileFormatConversion.ts-tUlewYon.js +38 -0
- package/dist/es/formatTimeUtils.ts-CkdWJ_Sl.js +32 -0
- package/dist/es/index.js +96 -185
- package/dist/es/useClickOutSide.tsx-CMvd2uTW.js +15 -0
- package/dist/es/useCountdown.tsx-Btzj-keH.js +16 -0
- package/dist/es/useEventListener.tsx-BBGVcI5T.js +12 -0
- package/dist/es/useGetElementSize.tsx-Dtshth0Y.js +22 -0
- package/dist/es/useKeyPress.tsx-Db44HXXz.js +18 -0
- package/dist/es/useMouseClick.tsx-C7uAH4n4.js +12 -0
- package/dist/es/useTheme.tsx-C5b7BRYz.js +24 -0
- package/dist/es/useThemePro.tsx-DQuSI8J7.js +20 -0
- package/dist/es/viewTransitionUtils.ts-CHa9uBpi.js +19 -0
- package/dist/index.css +1 -1
- package/dist/style/Button.css +1 -1
- package/dist/style/Message.css +1 -1
- package/dist/style/Modal.css +1 -1
- package/dist/style/Toast.css +1 -1
- package/dist/style/index.css +1 -1
- package/dist/types/hooks/useClickOutSide.d.ts +2 -2
- package/dist/types/hooks/useCountdown.d.ts +2 -1
- package/dist/types/hooks/useEventListener.d.ts +2 -2
- package/dist/types/hooks/useGetElementSize.d.ts +2 -1
- package/dist/types/hooks/useKeyPress.d.ts +2 -2
- package/dist/types/hooks/useMouseClick.d.ts +2 -1
- package/dist/types/hooks/useTheme.d.ts +2 -2
- package/dist/types/hooks/useThemePro.d.ts +2 -2
- package/dist/types/index.d.ts +8 -1
- package/dist/umd/index.css +1 -1
- package/dist/umd/index.css.br +0 -0
- package/dist/umd/index.css.gz +0 -0
- package/dist/umd/index.umd.cjs +393 -393
- package/dist/umd/index.umd.cjs.br +0 -0
- package/dist/umd/index.umd.cjs.gz +0 -0
- package/package.json +1 -1
- package/dist/es/InjunctiveBox-DsntB_UW.js +0 -11
- package/dist/es/Message-GvTC61N0.js +0 -68
- package/dist/es/VirtualList-BBvdkGKk.js +0 -65
- package/dist/es/utils-BxXROOPY.js +0 -394
- package/dist/types/hooks/index.d.ts +0 -8
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { u as t } from "./useEventListener.tsx-BBGVcI5T.js";
|
|
3
|
+
import { memo as r, useState as n, useMemo as i, useRef as l, useEffect as a } from "react";
|
|
4
|
+
const s = r(({ containerClassName: r2, dataSource: s2, containerStyle: d2 = {}, onEndCallback: c, refreshSpeed: o = 50, wrapperClassName: h, wrapperStyle: u = {}, estimatedSize: p = 35, updateDataSourceScroll2Top: f, direction: v = "vertical" }) => {
|
|
5
|
+
const [g, x] = n({ viewSize: 0, startIndex: 0, listSize: 0, renderCount: 0, prevLen: 0 }), [S, m] = n([]), z = "number" == typeof p ? p : p(), w = i(() => Math.min(s2.length, g.startIndex + g.renderCount), [s2, g]), I = i(() => {
|
|
6
|
+
var _a;
|
|
7
|
+
return g.startIndex > 0 ? (_a = S[g.startIndex - 1]) == null ? void 0 : _a.end : 0;
|
|
8
|
+
}, [g.startIndex, S]), y = i(() => s2.slice(g.startIndex, w).map(({ id: t2, data: r3 }) => e.jsx("li", { "data-virtual-id": t2, style: "vertical" === v ? { width: "100%" } : { height: "100%" }, children: r3 }, t2)), [w, s2, g.startIndex, v]), C = i(() => ({ display: "flex", listStyle: "none", flexDirection: "vertical" === v ? "column" : "row", height: "vertical" === v ? g.listSize - I + "px" : "100%", width: "vertical" === v ? "auto" : g.listSize - I + "px", transform: "vertical" === v ? `translate3d(0, ${I}px, 0)` : `translate3d(${I}px, 0, 0)` }), [g.listSize, I, v]), j = l(null), L = l(null), N = (e2) => x((t2) => ({ ...t2, ...e2 })), b = /* @__PURE__ */ ((e2, t2 = 300) => {
|
|
9
|
+
let r3 = 0;
|
|
10
|
+
return () => {
|
|
11
|
+
const n2 = Date.now();
|
|
12
|
+
n2 - r3 >= t2 && (e2(), r3 = n2);
|
|
13
|
+
};
|
|
14
|
+
})(() => {
|
|
15
|
+
const { scrollTop: e2, clientHeight: t2, scrollHeight: r3, scrollLeft: n2, clientWidth: i2, scrollWidth: l2 } = j.current, a2 = "vertical" === v ? r3 - t2 - e2 : l2 - i2 - n2;
|
|
16
|
+
N({ startIndex: E(S, "vertical" === v ? e2 : n2) }), ("vertical" === v ? e2 === z / 2 : n2 === z / 2) && N({ startIndex: 0 }), a2 <= 20 && c && c();
|
|
17
|
+
}, o), E = (e2, t2) => {
|
|
18
|
+
let r3 = 0, n2 = e2.length - 1, i2 = -1;
|
|
19
|
+
for (; r3 <= n2; ) {
|
|
20
|
+
const l2 = r3 + Math.floor((n2 - r3) / 2), a2 = e2[l2].end;
|
|
21
|
+
if (a2 === t2) return l2 + 1;
|
|
22
|
+
a2 < t2 ? r3 = l2 + 1 : ((-1 === i2 || i2 > l2) && (i2 = l2), n2 = l2 - 1);
|
|
23
|
+
}
|
|
24
|
+
return i2;
|
|
25
|
+
};
|
|
26
|
+
return t("scroll", b, { target: j.current, deps: [S, v] }), a(() => {
|
|
27
|
+
(() => {
|
|
28
|
+
if (!j.current) return;
|
|
29
|
+
const e2 = ("vertical" === v ? j.current.offsetHeight : j.current.offsetWidth) || 0;
|
|
30
|
+
N({ viewSize: e2, renderCount: Math.ceil(e2 / z) + 1 });
|
|
31
|
+
})();
|
|
32
|
+
}, [j, v]), a(() => {
|
|
33
|
+
s2.length && L && (() => {
|
|
34
|
+
var _a;
|
|
35
|
+
const e2 = [], t2 = s2.length - g.prevLen, r3 = t2 > 0 ? S.length : 0, n2 = r3 > 0 ? S[r3 - 1].end : 0;
|
|
36
|
+
for (let r4 = 0; r4 < (t2 > 0 ? t2 : s2.length); r4++) {
|
|
37
|
+
const i2 = s2[(t2 > 0 ? g.prevLen : 0) + r4];
|
|
38
|
+
e2.push({ index: i2.id, size: z, start: n2 ? n2 + r4 * z : i2.id * z, end: n2 ? n2 + (r4 + 1) * z : (i2.id + 1) * z, dSize: 0 });
|
|
39
|
+
}
|
|
40
|
+
m((r4) => [...t2 > 0 ? r4 : [], ...e2]), N({ prevLen: s2.length }), f && ((_a = j.current) == null ? void 0 : _a.scrollTo(0, 0));
|
|
41
|
+
})();
|
|
42
|
+
}, [L, s2, f]), a(() => {
|
|
43
|
+
(() => {
|
|
44
|
+
if (!L.current || 0 === S.length) return;
|
|
45
|
+
const e2 = Array.from(L.current.childNodes);
|
|
46
|
+
if (!e2.length) return;
|
|
47
|
+
e2.forEach((e3) => {
|
|
48
|
+
const t3 = e3.getBoundingClientRect(), r4 = +e3.getAttribute("data-virtual-id"), n3 = S[r4], i2 = n3.size - ("vertical" === v ? t3.height : t3.width);
|
|
49
|
+
i2 && (n3.size = "vertical" === v ? t3.height : t3.width, n3.end = n3.end - i2, n3.dSize = i2);
|
|
50
|
+
});
|
|
51
|
+
const t2 = +e2[0].getAttribute("data-virtual-id"), r3 = S.length;
|
|
52
|
+
let n2 = S[t2].dSize;
|
|
53
|
+
S[t2].dSize = 0;
|
|
54
|
+
for (let e3 = t2 + 1; e3 < r3; e3++) {
|
|
55
|
+
const t3 = S[e3];
|
|
56
|
+
t3.start = S[e3 - 1].end, t3.end = t3.end - n2, t3.dSize && (n2 += t3.dSize, t3.dSize = 0);
|
|
57
|
+
}
|
|
58
|
+
N({ listSize: S[r3 - 1].end });
|
|
59
|
+
})();
|
|
60
|
+
}, [L, S, g.startIndex, v]), e.jsx("div", { ref: j, className: r2, style: { width: "100%", height: "100%", overflow: "auto", ...d2 }, children: e.jsx("ul", { ref: L, className: h, style: { ...C, ...u }, children: y }) });
|
|
61
|
+
}), d = (e2, t2) => e2.map((e3, r2) => ({ id: r2, data: t2(e3, r2) }));
|
|
62
|
+
export {
|
|
63
|
+
s as E,
|
|
64
|
+
d as c
|
|
65
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
const r = ({ options: r2, pageSize:
|
|
5
|
-
const [f, x] =
|
|
2
|
+
import { u as t } from "./useEventListener.tsx-BBGVcI5T.js";
|
|
3
|
+
import { useState as a, useRef as i, useCallback as n, useEffect as o } from "react";
|
|
4
|
+
const r = ({ options: r2, pageSize: s, children: l, request: d, reloadData: c, className: m, style: g, updateData: p, loading: u = true, bottomThreshold: h = 50 }) => {
|
|
5
|
+
const [f, x] = a({ page: 1, reloadData: c, loading: false, isFinish: false, gap: "number" == typeof r2 ? 0 : r2.gap, imageWidth: "number" == typeof r2 ? r2 : 0, columns: "number" == typeof r2 ? 0 : r2.columns, imageList: [] }), [y, w] = a([]), [W, b] = a([]), j = i(null), v = i(null), D = i(null), L = (e2) => x((t2) => ({ ...t2, ...e2 })), N = async (e2, t2) => {
|
|
6
6
|
const a2 = c && f.reloadData !== c;
|
|
7
7
|
if (f.isFinish) return;
|
|
8
8
|
L({ loading: true });
|
|
9
9
|
const i2 = await d(e2, t2);
|
|
10
|
-
|
|
11
|
-
},
|
|
10
|
+
E(i2), L({ isFinish: !i2.length, imageList: a2 ? [...i2] : [...f.imageList, ...i2], page: e2 + 1, loading: false });
|
|
11
|
+
}, E = (e2) => x((t2) => {
|
|
12
12
|
const a2 = c && f.reloadData !== c, i2 = a2 ? [] : [...W], n2 = a2 ? Array(t2.columns).fill(0) : [..."[]" !== JSON.stringify(y) ? y : Array(t2.columns).fill(0)];
|
|
13
13
|
return e2.forEach((e3) => {
|
|
14
14
|
const a3 = ((e4) => {
|
|
@@ -17,7 +17,7 @@ const r = ({ options: r2, pageSize: l, children: s, request: d, reloadData: c, c
|
|
|
17
17
|
})(n2), o2 = Math.floor(e3.height * t2.imageWidth / e3.width);
|
|
18
18
|
i2.push({ x: a3.index % t2.columns !== 0 ? a3.index * t2.imageWidth + t2.gap * a3.index : a3.index * t2.imageWidth, y: a3.height }), n2[a3.index] += o2 + t2.gap, w(n2);
|
|
19
19
|
}), b(i2), t2;
|
|
20
|
-
}),
|
|
20
|
+
}), F = n(() => {
|
|
21
21
|
if (!D.current) return;
|
|
22
22
|
const e2 = D.current.clientWidth;
|
|
23
23
|
let t2 = 0, a2 = f.page;
|
|
@@ -31,10 +31,10 @@ const r = ({ options: r2, pageSize: l, children: s, request: d, reloadData: c, c
|
|
|
31
31
|
const a3 = (e2 - t2 * f.gap) / f.columns;
|
|
32
32
|
L({ imageWidth: a3 });
|
|
33
33
|
}
|
|
34
|
-
N(a2,
|
|
35
|
-
}, [f, c]),
|
|
36
|
-
j.current && clearTimeout(j.current), j.current = setTimeout(
|
|
37
|
-
},
|
|
34
|
+
N(a2, s);
|
|
35
|
+
}, [f, c]), M = () => {
|
|
36
|
+
j.current && clearTimeout(j.current), j.current = setTimeout(F, 50);
|
|
37
|
+
}, T = /* @__PURE__ */ ((e2, t2 = 50) => {
|
|
38
38
|
let a2 = 0;
|
|
39
39
|
return () => {
|
|
40
40
|
const i2 = Date.now();
|
|
@@ -42,13 +42,13 @@ const r = ({ options: r2, pageSize: l, children: s, request: d, reloadData: c, c
|
|
|
42
42
|
};
|
|
43
43
|
})(() => {
|
|
44
44
|
const { scrollTop: e2, clientHeight: t2, scrollHeight: a2 } = v.current;
|
|
45
|
-
a2 - t2 - e2 >
|
|
45
|
+
a2 - t2 - e2 > h || !f.loading && N(f.page, s);
|
|
46
46
|
});
|
|
47
|
-
return
|
|
48
|
-
window.removeEventListener("resize",
|
|
49
|
-
}), [D, c]),
|
|
50
|
-
p && N(f.page,
|
|
51
|
-
}, [p, f.loading, f.page, v.current]), e.jsxs("div", { className: "ono-waterfall-container", children: [e.jsx("div", { ref: v, className: [m, "ono-waterfall-content"].join(" ").trim(), style: g, children: e.jsx("div", { ref: D, className: "ono-waterfall-wrapper", style: { height: Math.max(...y) - f.gap + "px" }, children: f.imageList.map((t2, a2) => e.jsx("div", { className: "ono-waterfall-item", style: { width: `${f.imageWidth}px`, transform: `translate(${W[a2].x}px,${W[a2].y}px)` }, children:
|
|
47
|
+
return t("scroll", T, { target: v.current, deps: [f.loading, f.page] }), o(() => (F(), window.addEventListener("resize", M), () => {
|
|
48
|
+
window.removeEventListener("resize", M);
|
|
49
|
+
}), [D, c]), o(() => {
|
|
50
|
+
p && N(f.page, s);
|
|
51
|
+
}, [p, f.loading, f.page, v.current]), e.jsxs("div", { className: "ono-waterfall-container", children: [e.jsx("div", { ref: v, className: [m, "ono-waterfall-content"].join(" ").trim(), style: g, children: e.jsx("div", { ref: D, className: "ono-waterfall-wrapper", style: { height: Math.max(...y) - f.gap + "px" }, children: f.imageList.map((t2, a2) => e.jsx("div", { className: "ono-waterfall-item", style: { width: `${f.imageWidth}px`, transform: `translate(${W[a2].x}px,${W[a2].y}px)` }, children: l(t2, a2) }, t2.id)) }) }), f.loading && ("function" == typeof u ? u() : u && "boolean" == typeof u ? e.jsx("div", { className: "ono-waterfall-loading", children: "loading..." }) : u)] });
|
|
52
52
|
};
|
|
53
53
|
export {
|
|
54
54
|
r as W
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
const t = /\d+/g, r = (r2) => {
|
|
2
|
+
const e2 = r2.match(t), a2 = (t2) => Number(t2).toString(16).padStart(2, "0"), n2 = (t2) => t2.reduce((t3, r3) => t3 + a2(r3), "#"), s2 = (t2) => {
|
|
3
|
+
const r3 = t2, e3 = 1 !== Number(t2[t2.length - 1]) ? Number(t2[t2.length - 1]) : 100;
|
|
4
|
+
return r3.pop(), n2(r3) + a2(2.56 * e3);
|
|
5
|
+
};
|
|
6
|
+
return 3 === e2.length ? n2(e2) : 5 === e2.length ? s2([e2[0], e2[1], e2[2], 10 * Number(e2[e2.length - 1])]) : s2(e2);
|
|
7
|
+
}, e = (t2) => {
|
|
8
|
+
const r2 = t2.split("#")[1], e2 = (t3) => [parseInt(t3.slice(0, 2), 16), parseInt(t3.slice(2, 4), 16), parseInt(t3.slice(4, 6), 16)];
|
|
9
|
+
if (8 === r2.length) {
|
|
10
|
+
const t3 = parseInt(r2.slice(-2), 16) / 256, a2 = e2(r2.slice(0, -2));
|
|
11
|
+
return a2.push(t3), "rgba(" + a2.join(", ") + ")";
|
|
12
|
+
}
|
|
13
|
+
return "rgb(" + e2(r2).join(", ") + ")";
|
|
14
|
+
}, a = (r2) => {
|
|
15
|
+
const e2 = r2.match(t), a2 = Number(e2[0]) / 255, n2 = Number(e2[1]) / 255, s2 = Number(e2[2]) / 255, h2 = Math.min(a2, n2, s2), i2 = Math.max(a2, n2, s2);
|
|
16
|
+
let u2 = 0, o2 = 0, l2 = (i2 + h2) / 2;
|
|
17
|
+
if (i2 === h2) u2 = o2 = 0;
|
|
18
|
+
else {
|
|
19
|
+
const t2 = i2 - h2;
|
|
20
|
+
switch (o2 = l2 > 0.5 ? t2 / (2 - i2 - h2) : t2 / (i2 + h2), i2) {
|
|
21
|
+
case a2:
|
|
22
|
+
u2 = (n2 - s2) / t2 + (n2 < s2 ? 6 : 0);
|
|
23
|
+
break;
|
|
24
|
+
case n2:
|
|
25
|
+
u2 = (s2 - a2) / t2 + 2;
|
|
26
|
+
break;
|
|
27
|
+
case s2:
|
|
28
|
+
u2 = (a2 - n2) / t2 + 4;
|
|
29
|
+
}
|
|
30
|
+
u2 /= 6;
|
|
31
|
+
}
|
|
32
|
+
return `hsl(${Math.round(360 * u2)}, ${Math.round(100 * o2)}%, ${Math.round(100 * l2)}%)`;
|
|
33
|
+
}, n = (r2) => {
|
|
34
|
+
const e2 = r2.match(t), a2 = Number(e2[0]) / 360, n2 = Number(e2[1]) / 100, s2 = Number(e2[2]) / 100;
|
|
35
|
+
let h2, i2, u2;
|
|
36
|
+
function o2(t2, r3, e3) {
|
|
37
|
+
return e3 < 0 && (e3 += 1), e3 > 1 && (e3 -= 1), e3 < 1 / 6 ? t2 + 6 * (r3 - t2) * e3 : e3 < 0.5 ? r3 : e3 < 2 / 3 ? t2 + (r3 - t2) * (2 / 3 - e3) * 6 : t2;
|
|
38
|
+
}
|
|
39
|
+
let l2 = s2 < 0.5 ? s2 * (1 + n2) : s2 + n2 - s2 * n2, c2 = 2 * s2 - l2;
|
|
40
|
+
return h2 = o2(c2, l2, a2 + 1 / 3), i2 = o2(c2, l2, a2), u2 = o2(c2, l2, a2 - 1 / 3), `rgb(${Math.round(255 * h2)}, ${Math.round(255 * i2)}, ${Math.round(255 * u2)})`;
|
|
41
|
+
}, s = (t2) => a(e(t2)), h = (t2) => r(n(t2)), i = (r2) => {
|
|
42
|
+
const e2 = r2.match(t);
|
|
43
|
+
let a2 = Number(e2[0]) / 255, n2 = Number(e2[1]) / 255, s2 = Number(e2[2]) / 255;
|
|
44
|
+
const h2 = Math.max(a2, n2, s2), i2 = Math.min(a2, n2, s2);
|
|
45
|
+
let u2 = 0, o2 = 0, l2 = h2;
|
|
46
|
+
const c2 = h2 - i2;
|
|
47
|
+
if (o2 = 0 === h2 ? 0 : c2 / h2, h2 === i2) u2 = 0;
|
|
48
|
+
else {
|
|
49
|
+
switch (h2) {
|
|
50
|
+
case a2:
|
|
51
|
+
u2 = (n2 - s2) / c2 + (n2 < s2 ? 6 : 0);
|
|
52
|
+
break;
|
|
53
|
+
case n2:
|
|
54
|
+
u2 = (s2 - a2) / c2 + 2;
|
|
55
|
+
break;
|
|
56
|
+
case s2:
|
|
57
|
+
u2 = (a2 - n2) / c2 + 4;
|
|
58
|
+
}
|
|
59
|
+
u2 /= 6;
|
|
60
|
+
}
|
|
61
|
+
return `hsv(${360 * u2}, ${100 * o2}, ${100 * l2})`;
|
|
62
|
+
}, u = (r2) => {
|
|
63
|
+
const e2 = r2.match(t);
|
|
64
|
+
let a2, n2, s2, h2, i2, u2, o2, l2, c2 = Number(e2[0]) / 360, m = Number(e2[1]) / 100, b = Number(e2[2]) / 100;
|
|
65
|
+
if (c2 && 0 === m) a2 = n2 = s2 = b;
|
|
66
|
+
else switch (c2 /= 60, h2 = Math.floor(c2), i2 = c2 - h2, u2 = b * (1 - m), o2 = b * (1 - m * i2), l2 = b * (1 - m * (1 - i2)), h2) {
|
|
67
|
+
case 0:
|
|
68
|
+
a2 = b, n2 = l2, s2 = u2;
|
|
69
|
+
break;
|
|
70
|
+
case 1:
|
|
71
|
+
a2 = o2, n2 = b, s2 = u2;
|
|
72
|
+
break;
|
|
73
|
+
case 2:
|
|
74
|
+
a2 = u2, n2 = b, s2 = l2;
|
|
75
|
+
break;
|
|
76
|
+
case 3:
|
|
77
|
+
a2 = u2, n2 = o2, s2 = b;
|
|
78
|
+
break;
|
|
79
|
+
case 4:
|
|
80
|
+
a2 = l2, n2 = u2, s2 = b;
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
a2 = b, n2 = u2, s2 = o2;
|
|
84
|
+
}
|
|
85
|
+
return `rgb(${Math.round(255 * a2)}, ${Math.round(255 * n2)}, ${Math.round(255 * s2)})`;
|
|
86
|
+
}, o = (t2) => /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/.test(t2) ? "hex" : /^rgb\((1?\d{1,3},\s*1?\d{1,3},\s*1?\d{1,3})\)$/.test(t2) ? "rgb" : "unknown", l = (r2, e2, n2) => {
|
|
87
|
+
let i2 = [];
|
|
88
|
+
if (r2.includes("#")) i2 = s(r2).match(t);
|
|
89
|
+
else if (r2.includes("rgb")) i2 = a(r2).match(t);
|
|
90
|
+
else {
|
|
91
|
+
if (!r2.includes("hsl")) throw new Error("颜色格式错误");
|
|
92
|
+
i2 = r2.match(t);
|
|
93
|
+
}
|
|
94
|
+
return h(`${i2[0]}, ${i2[1]}%, ${"light" === e2 ? Number(i2[2]) + n2 > 100 ? 100 : Number(i2[2]) + n2 : Number(i2[2]) - n2 < 0 ? 0 : Number(i2[2]) - n2}%`);
|
|
95
|
+
}, c = { randomColor: () => "#" + Math.random().toString(16).slice(2, 8).padEnd(6, "0"), rgb2hex: r, hex2rgb: e, rgb2rgba: (t2, r2) => {
|
|
96
|
+
if (!r2) return t2;
|
|
97
|
+
if (t2.includes("rgba")) {
|
|
98
|
+
const e2 = t2.split(",");
|
|
99
|
+
return e2.pop(), e2.push(r2 + ")"), e2.join(",");
|
|
100
|
+
}
|
|
101
|
+
if (t2.includes("rgb")) {
|
|
102
|
+
const e2 = t2.split(","), a2 = "rgba(" + e2[0].split("(")[1], n2 = e2[e2.length - 1].split(")")[0];
|
|
103
|
+
return [a2, e2[1], n2, " " + r2 + ")"].join(",");
|
|
104
|
+
}
|
|
105
|
+
}, rgb2hsl: a, hsl2rgb: n, hex2hsl: s, hsl2hex: h, rgb2hsv: i, hsv2rgb: u, hex2hsv: (t2) => i(e(t2)), hsv2hex: (t2) => r(u(t2)), formatColor: (e2, n2, s2 = "rgba") => {
|
|
106
|
+
const h2 = e2.match(t);
|
|
107
|
+
let i2 = Number(h2[0]) / 255, u2 = Number(h2[1]) / 255, o2 = Number(h2[2]) / 255;
|
|
108
|
+
return "rgba" === s2 ? `rgba(${i2},${u2},${o2},${n2})` : "rgb" === s2 ? e2 : "hex" === s2 ? r(e2) : "hsl" === s2 ? a(`rgba(${i2},${u2},${o2},${n2})`) : `rgba(${i2},${u2},${o2},${n2})`;
|
|
109
|
+
}, getContrastColor: (t2) => {
|
|
110
|
+
const r2 = (function(t3) {
|
|
111
|
+
if (t3.startsWith("#")) return 4 === t3.length && (t3 = `#${t3.slice(1).repeat(2)}`), [parseInt(t3.substr(1, 2), 16), parseInt(t3.substr(3, 2), 16), parseInt(t3.substr(5, 2), 16)];
|
|
112
|
+
if (t3.startsWith("rgb")) {
|
|
113
|
+
const r3 = t3.match(/\d+/g);
|
|
114
|
+
return [parseInt(r3[0]), parseInt(r3[1]), parseInt(r3[2])];
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
})(t2);
|
|
118
|
+
return null === r2 ? null : (299 * (e2 = r2)[0] + 587 * e2[1] + 114 * e2[2]) / 1e3 > 128 ? "#000" : "#fff";
|
|
119
|
+
var e2;
|
|
120
|
+
}, adjustColor: (t2, r2, e2) => {
|
|
121
|
+
const a2 = o(t2);
|
|
122
|
+
if ("hex" === a2) {
|
|
123
|
+
const a3 = t2.replace("#", ""), n2 = parseInt(a3.slice(0, 2), 16), s2 = parseInt(a3.slice(2, 4), 16), h2 = parseInt(a3.slice(4, 6), 16);
|
|
124
|
+
if ("lighten" === r2) {
|
|
125
|
+
const t3 = Math.min(255, Math.max(0, n2 + (255 - n2) * e2 / 100)), r3 = Math.min(255, Math.max(0, s2 + (255 - s2) * e2 / 100)), a4 = Math.min(255, Math.max(0, h2 + (255 - h2) * e2 / 100));
|
|
126
|
+
return `#${t3.toString(16).padStart(2, "0")}${r3.toString(16).padStart(2, "0")}${a4.toString(16).padStart(2, "0")}`;
|
|
127
|
+
}
|
|
128
|
+
if ("darken" === r2) {
|
|
129
|
+
const t3 = Math.min(255, Math.max(0, n2 - n2 * e2 / 100)), r3 = Math.min(255, Math.max(0, s2 - s2 * e2 / 100)), a4 = Math.min(255, Math.max(0, h2 - h2 * e2 / 100));
|
|
130
|
+
return `#${t3.toString(16).padStart(2, "0")}${r3.toString(16).padStart(2, "0")}${a4.toString(16).padStart(2, "0")}`;
|
|
131
|
+
}
|
|
132
|
+
} else if ("rgb" === a2) {
|
|
133
|
+
const a3 = t2.match(/\d+/g), n2 = parseInt(a3[0]), s2 = parseInt(a3[1]), h2 = parseInt(a3[2]);
|
|
134
|
+
if ("lighten" === r2) return `rgb(${Math.min(255, Math.max(0, n2 + (255 - n2) * e2 / 100))},${Math.min(255, Math.max(0, s2 + (255 - s2) * e2 / 100))},${Math.min(255, Math.max(0, h2 + (255 - h2) * e2 / 100))})`;
|
|
135
|
+
if ("darken" === r2) return `rgb(${Math.min(255, Math.max(0, n2 - n2 * e2 / 100))},${Math.min(255, Math.max(0, s2 - s2 * e2 / 100))},${Math.min(255, Math.max(0, h2 - h2 * e2 / 100))})`;
|
|
136
|
+
}
|
|
137
|
+
return t2;
|
|
138
|
+
}, isValidColor: (t2) => !(!/^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/.test(t2) && !/^rgb\((1?\d{1,3},\s*1?\d{1,3},\s*1?\d{1,3})\)$/.test(t2)), getColorType: o, hex3To6: (t2) => {
|
|
139
|
+
const r2 = t2.replace("#", "").split("");
|
|
140
|
+
return `#${r2[0] + r2[0] + r2[1] + r2[1] + r2[2] + r2[2]}`;
|
|
141
|
+
}, adjustingColors: l };
|
|
142
|
+
export {
|
|
143
|
+
l as a,
|
|
144
|
+
c
|
|
145
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const t = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])[\da-zA-Z]{8,}$/, e = (t2) => t2 <= 11 ? Math.random().toString(36).substring(2, 2 + t2).padEnd(t2, "0") : e(11) + e(t2 - 11), r = ({ el: t2, str: e2 = "hello world", speed: r2 = 100, isExtendStr: n2 = true, onDone: o2 }) => {
|
|
2
|
+
let a2 = 0, s2 = null;
|
|
3
|
+
t2.textContent && n2 && (a2 = t2.textContent.length, e2 = t2.textContent + e2);
|
|
4
|
+
const i2 = () => {
|
|
5
|
+
clearTimeout(s2);
|
|
6
|
+
const n3 = e2.substring(0, a2 + 1);
|
|
7
|
+
t2.textContent = n3, a2++, a2 !== e2.length ? s2 = setTimeout(i2, r2) : o2 && o2();
|
|
8
|
+
};
|
|
9
|
+
i2();
|
|
10
|
+
}, n = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), o = async (t2, e2) => {
|
|
11
|
+
const r2 = (t3, e3) => {
|
|
12
|
+
const r3 = window.URL.createObjectURL(t3), n2 = document.createElement("a");
|
|
13
|
+
n2.href = r3, n2.download = encodeURIComponent(e3), document.body.appendChild(n2), n2.click(), document.body.removeChild(n2), window.URL.revokeObjectURL(r3);
|
|
14
|
+
};
|
|
15
|
+
try {
|
|
16
|
+
if ("string" == typeof t2) {
|
|
17
|
+
const n2 = await fetch(t2);
|
|
18
|
+
if (!n2.ok) throw new Error(`Network response was not ok: ${n2.statusText}`);
|
|
19
|
+
r2(await n2.blob(), e2);
|
|
20
|
+
} else r2(t2, e2);
|
|
21
|
+
} catch (t3) {
|
|
22
|
+
console.error("文件下载失败:", t3 instanceof Error ? t3.message : String(t3));
|
|
23
|
+
}
|
|
24
|
+
}, a = (t2, e2) => {
|
|
25
|
+
t2.toString().startsWith("2") ? e2.onSuccess && e2.onSuccess() : (t2.toString().startsWith("4") || t2.toString().startsWith("5")) && e2.onFail && e2.onFail();
|
|
26
|
+
}, s = (t2) => {
|
|
27
|
+
const e2 = t2.getBoundingClientRect();
|
|
28
|
+
return { x: e2.left + e2.width / 2, y: e2.top + e2.height / 2 };
|
|
29
|
+
}, i = (t2, e2, r2) => {
|
|
30
|
+
const n2 = new IntersectionObserver(e2, r2);
|
|
31
|
+
t2 instanceof HTMLElement ? n2.observe(t2) : t2.forEach((t3) => n2.observe(t3));
|
|
32
|
+
}, c = (t2) => {
|
|
33
|
+
const e2 = Math.floor(t2 / 3600), r2 = Math.floor(t2 % 3600 / 60), n2 = Math.floor(t2 % 60), o2 = (t3) => t3.toString().padStart(2, "0");
|
|
34
|
+
return (e2 > 0 ? `${o2(e2)}:${o2(r2)}:${o2(n2)}` : `${o2(r2)}:${o2(n2)}`) + (t2 < 10 ? ".00" : t2 < 100 ? ".0" : "");
|
|
35
|
+
}, l = (t2) => {
|
|
36
|
+
if (t2.length < 2) return t2;
|
|
37
|
+
const e2 = t2[0], r2 = t2.slice(1).filter((t3) => t3 <= e2), n2 = t2.slice(1).filter((t3) => t3 > e2);
|
|
38
|
+
return [...l(r2), e2, ...l(n2)];
|
|
39
|
+
}, d = (t2, e2) => {
|
|
40
|
+
const r2 = ["B", "KB", "MB", "GB", "TB"], n2 = 1024;
|
|
41
|
+
let o2 = r2.indexOf((e2 == null ? void 0 : e2.unit) ?? "B");
|
|
42
|
+
if (-1 === o2) throw new Error("Invalid unit");
|
|
43
|
+
if (!(e2 == null ? void 0 : e2.unit)) for (; t2 / Math.pow(n2, o2) >= n2; ) o2++;
|
|
44
|
+
return `${(t2 / Math.pow(n2, o2)).toFixed((e2 == null ? void 0 : e2.decimalPlaces) ?? 0)} ${r2[o2]}`;
|
|
45
|
+
}, u = (t2, e2) => `${Math.floor(t2 / g(t2, e2))}:${Math.floor(e2 / g(t2, e2))}`, g = (t2, e2) => {
|
|
46
|
+
for (; 0 !== e2; ) {
|
|
47
|
+
const r2 = e2;
|
|
48
|
+
e2 = t2 % e2, t2 = r2;
|
|
49
|
+
}
|
|
50
|
+
return t2;
|
|
51
|
+
}, h = (t2, e2, r2) => {
|
|
52
|
+
t2.muted = true, t2.play();
|
|
53
|
+
const n2 = new AudioContext(), o2 = "running" === n2.state;
|
|
54
|
+
n2.close(), o2 ? (t2.muted = false, e2 == null ? void 0 : e2()) : r2 == null ? void 0 : r2();
|
|
55
|
+
}, f = (t2) => new URLSearchParams(window.location.search).get(t2), p = (t2) => {
|
|
56
|
+
let e2;
|
|
57
|
+
const r2 = new Proxy(t2, { construct: (t3, r3) => (e2 || (e2 = Reflect.construct(t3, r3)), e2) });
|
|
58
|
+
return r2.prototype.construct = r2, r2;
|
|
59
|
+
}, m = (t2) => "string" != typeof t2 || 0 === t2.length ? "" : t2.charAt(0).toUpperCase() + t2.slice(1), w = (t2) => {
|
|
60
|
+
if ("object" != typeof t2 || null === t2) return t2;
|
|
61
|
+
const e2 = Array.isArray(t2) ? [] : {};
|
|
62
|
+
for (const r2 in t2) Object.prototype.hasOwnProperty.call(t2, r2) && (e2[r2] = w(t2[r2]));
|
|
63
|
+
return e2;
|
|
64
|
+
}, b = (t2) => new Promise((e2) => {
|
|
65
|
+
const r2 = new Image();
|
|
66
|
+
r2.src = "string" == typeof t2 ? t2 : URL.createObjectURL(t2), r2.onload = () => e2({ width: r2.width, height: r2.height });
|
|
67
|
+
}), y = (t2, e2) => {
|
|
68
|
+
let r2 = 0;
|
|
69
|
+
const n2 = (o2) => {
|
|
70
|
+
r2 || (r2 = o2), o2 - r2 >= e2 ? t2() : requestAnimationFrame(n2);
|
|
71
|
+
};
|
|
72
|
+
requestAnimationFrame(n2);
|
|
73
|
+
}, S = (t2, e2, r2) => {
|
|
74
|
+
const n2 = t2[e2];
|
|
75
|
+
t2[e2] = function(t3) {
|
|
76
|
+
n2 && "function" == typeof n2 && n2.call(this, t3), r2.call(this, t3);
|
|
77
|
+
};
|
|
78
|
+
}, x = (t2) => {
|
|
79
|
+
if ("number" != typeof t2 || isNaN(t2)) throw new Error("请输入有效的数字");
|
|
80
|
+
const e2 = t2.toString().split(".");
|
|
81
|
+
return e2[0] = e2[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), e2.join(".");
|
|
82
|
+
}, C = (t2) => parseFloat(t2.replace(/[^0-9.]/g, "")), O = (t2, e2, r2, n2) => Math.sqrt((t2 - r2) ** 2 + (e2 - n2) ** 2), M = (t2) => navigator.clipboard.writeText(t2), E = (t2) => Math.ceil((t2.getTime() - new Date(t2.getFullYear(), 0, 1).getTime()) / 864e5), A = (t2, e2, r2) => 0.2126 * t2 + 0.7152 * e2 + 0.0722 * r2, v = (t2) => {
|
|
83
|
+
const e2 = {};
|
|
84
|
+
return t2.replace(/([^?=&]+)=([^&]+)/g, (t3, r2, n2) => e2[r2] = n2), e2;
|
|
85
|
+
}, I = (t2, ...e2) => Object.fromEntries(Object.entries(t2).filter(([t3]) => e2.includes(t3))), P = (t2) => {
|
|
86
|
+
if (!t2) return "";
|
|
87
|
+
const e2 = t2.lastIndexOf(".");
|
|
88
|
+
return -1 === e2 ? P(t2.substring(t2.lastIndexOf("/") + 1)) : t2.substring(0, e2);
|
|
89
|
+
}, R = (t2) => {
|
|
90
|
+
if (!t2) return "";
|
|
91
|
+
const e2 = t2.lastIndexOf(".");
|
|
92
|
+
return t2.substring(e2 + 1);
|
|
93
|
+
}, $ = { addCommasToNumber: x, addEventWithOriginHandler: S, calculateAspectRatio: u, checkDeviceIsMobile: n, checkStatusCode: a, copy2Clipboard: M, createIntersectionObserver: i, dayOfYear: E, deepCopy: w, downloadFile: o, formatFileSize: d, formatSecondes: c, getElementCenterPosition: s, getFileName: P, getFileSuffix: R, getImageSIze: b, getPointDistance: O, getURLSearchParams: f, grayColor: A, mediaAutoplayPolicies: h, parseQuery: v, passwordStrength: t, pick: I, printStr: r, pureNumber: C, quickSort: l, rafTimeout: y, randomString: e, safeCapitalizeWord: m, singleton: p };
|
|
94
|
+
export {
|
|
95
|
+
l as A,
|
|
96
|
+
y as B,
|
|
97
|
+
e as C,
|
|
98
|
+
m as D,
|
|
99
|
+
p as E,
|
|
100
|
+
x as a,
|
|
101
|
+
S as b,
|
|
102
|
+
u as c,
|
|
103
|
+
n as d,
|
|
104
|
+
a as e,
|
|
105
|
+
$ as f,
|
|
106
|
+
s as g,
|
|
107
|
+
M as h,
|
|
108
|
+
i,
|
|
109
|
+
E as j,
|
|
110
|
+
w as k,
|
|
111
|
+
o as l,
|
|
112
|
+
d as m,
|
|
113
|
+
c as n,
|
|
114
|
+
P as o,
|
|
115
|
+
C as p,
|
|
116
|
+
R as q,
|
|
117
|
+
b as r,
|
|
118
|
+
O as s,
|
|
119
|
+
f as t,
|
|
120
|
+
A as u,
|
|
121
|
+
h as v,
|
|
122
|
+
v as w,
|
|
123
|
+
t as x,
|
|
124
|
+
I as y,
|
|
125
|
+
r as z
|
|
126
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const t = (t2) => {
|
|
2
|
+
const e2 = t2.split(","), a2 = e2[0].match(/:(.*?);/)[1], s2 = atob(e2[1]);
|
|
3
|
+
let n2 = s2.length;
|
|
4
|
+
const o2 = new Uint8Array(n2);
|
|
5
|
+
for (; n2--; ) o2[n2] = s2.charCodeAt(n2);
|
|
6
|
+
return new Blob([o2], { type: a2 });
|
|
7
|
+
}, e = (t2, e2) => {
|
|
8
|
+
const a2 = t2.split(","), s2 = a2[0].match(/:(.*?);/u)[1], n2 = atob(a2[1]);
|
|
9
|
+
let o2 = n2.length, i2 = "jpeg" === s2.split("/")[1] ? ".jpg" : "." + s2.split("/")[1];
|
|
10
|
+
const r2 = new Uint8Array(o2);
|
|
11
|
+
for (; o2--; ) r2[o2] = n2.charCodeAt(o2);
|
|
12
|
+
const l2 = new Blob([r2], { type: s2 });
|
|
13
|
+
return new File([l2], e2 + i2, { type: s2, lastModified: (/* @__PURE__ */ new Date()).getTime() });
|
|
14
|
+
}, a = (t2) => new Promise((e2) => {
|
|
15
|
+
const a2 = new FileReader();
|
|
16
|
+
a2.readAsDataURL(t2), a2.onload = (t3) => {
|
|
17
|
+
var _a;
|
|
18
|
+
const a3 = (_a = t3.target) == null ? void 0 : _a.result, s2 = a3.split(",")[1];
|
|
19
|
+
e2(s2);
|
|
20
|
+
};
|
|
21
|
+
}), s = (t2, e2 = "abc.jpg") => new File([t2], e2, { type: t2.type }), n = (t2) => new Promise((e2) => {
|
|
22
|
+
const a2 = new FileReader();
|
|
23
|
+
a2.readAsDataURL(t2), a2.onload = (t3) => {
|
|
24
|
+
var _a;
|
|
25
|
+
return e2((_a = t3.target) == null ? void 0 : _a.result);
|
|
26
|
+
};
|
|
27
|
+
}), o = (t2) => t2.slice(0, t2.size, t2.type), i = async (t2) => await (await fetch(t2)).blob(), r = async (t2) => s(await i(t2)), l = async (t2) => await a(await i(t2));
|
|
28
|
+
export {
|
|
29
|
+
e as a,
|
|
30
|
+
t as b,
|
|
31
|
+
a as c,
|
|
32
|
+
s as d,
|
|
33
|
+
o as e,
|
|
34
|
+
n as f,
|
|
35
|
+
i as g,
|
|
36
|
+
r as h,
|
|
37
|
+
l as u
|
|
38
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const t = (t2) => t2 < 10 ? `0${t2}` : `${t2}`, e = (t2) => t2.toString().length > 13 ? new Date(Number(t2.toString().substring(0, 13))) : 13 === t2.toString().length ? new Date(t2) : t2.toString().length < 13 && t2.toString().length > 10 ? new Date(Number((t2.toString() + "000").substring(0, 13))) : 10 === t2.toString().length ? new Date(1e3 * t2) : new Date(Number((t2.toString() + "000000000000").substring(0, 13))), n = (n2, r2 = "YY-MM-DD hh:mm:ss") => {
|
|
2
|
+
const s2 = ["YY", "MM", "DD", "hh", "mm", "ss"], u2 = [], o = e(n2);
|
|
3
|
+
u2.push(o.getFullYear().toString()), u2.push(t(o.getMonth() + 1)), u2.push(t(o.getDate())), u2.push(t(o.getHours())), u2.push(t(o.getMinutes())), u2.push(t(o.getSeconds()));
|
|
4
|
+
for (let t2 in u2) r2 = r2.replace(s2[t2], u2[t2]);
|
|
5
|
+
return r2;
|
|
6
|
+
}, r = (n2, r2 = "YY-MM-DD hh:mm:ss", s2 = "cn") => {
|
|
7
|
+
const u2 = ["YY", "MM", "DD", "hh", "mm", "ss"], o = [], h = e(n2);
|
|
8
|
+
o.push(((t2, e2) => {
|
|
9
|
+
const n3 = { en: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], cn: ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"] };
|
|
10
|
+
return t2.split("").map((t3) => n3[e2][Number(t3)]).join("");
|
|
11
|
+
})(h.getFullYear().toString(), s2)), o.push(((t2, e2) => ({ en: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], cn: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"] })[e2][Number(t2) - 1])(t(h.getMonth() + 1), s2)), o.push(((t2, e2) => {
|
|
12
|
+
let n3;
|
|
13
|
+
return "en" === e2 ? n3 = "01" === t2 || "21" === t2 || "31" === t2 ? Number(t2) + "st" : "02" === t2 || "22" === t2 ? Number(t2) + "nd" : "03" === t2 || "23" === t2 ? Number(t2) + "rd" : Number(t2) + "th" : "01" === t2 ? n3 = "一日" : "02" === t2 ? n3 = "二日" : "03" === t2 ? n3 = "三日" : "04" === t2 ? n3 = "四日" : "05" === t2 ? n3 = "五日" : "06" === t2 ? n3 = "六日" : "07" === t2 ? n3 = "七日" : "08" === t2 ? n3 = "八日" : "09" === t2 ? n3 = "九日" : "10" === t2 ? n3 = "十日" : "11" === t2 ? n3 = "十一日" : "12" === t2 ? n3 = "十二日" : "13" === t2 ? n3 = "十三日" : "14" === t2 ? n3 = "十四日" : "15" === t2 ? n3 = "十五日" : "16" === t2 ? n3 = "十六日" : "17" === t2 ? n3 = "十七日" : "18" === t2 ? n3 = "十八日" : "19" === t2 ? n3 = "十九日" : "20" === t2 ? n3 = "二十日" : "21" === t2 ? n3 = "二十一日" : "22" === t2 ? n3 = "二十二日" : "23" === t2 ? n3 = "二十三日" : "24" === t2 ? n3 = "二十四日" : "25" === t2 ? n3 = "二十五日" : "26" === t2 ? n3 = "二十六日" : "27" === t2 ? n3 = "二十七日" : "28" === t2 ? n3 = "二十八日" : "29" === t2 ? n3 = "二十九日" : "30" === t2 ? n3 = "三十日" : "31" === t2 && (n3 = "三十一日"), n3 ?? t2;
|
|
14
|
+
})(t(h.getDate()), s2)), o.push(t(h.getHours())), o.push(t(h.getMinutes())), o.push(t(h.getSeconds()));
|
|
15
|
+
for (let t2 in o) r2 = r2.replace(u2[t2], o[t2]);
|
|
16
|
+
return r2;
|
|
17
|
+
}, s = (e2, n2) => {
|
|
18
|
+
const r2 = ["DD", "hh", "mm", "ss"], s2 = [];
|
|
19
|
+
s2.push(Math.floor(e2 / 86400)), s2.push(t(Math.floor(e2 % 86400 / 3600))), s2.push(t(Math.floor(e2 % 3600 / 60))), s2.push(t(e2 % 60));
|
|
20
|
+
for (let t2 = 0; t2 < r2.length; t2++) n2 = n2.replace(r2[t2], s2[t2].toString());
|
|
21
|
+
return n2;
|
|
22
|
+
}, u = (t2, e2) => {
|
|
23
|
+
const n2 = { year: 31536e3, month: 2592e3, day: 86400, hour: 3600, minute: 60, second: 1 };
|
|
24
|
+
if (!n2[e2]) throw new Error('Invalid type. Please use "day", "hour", "minute", or "second".');
|
|
25
|
+
return Math.floor(t2 / n2[e2]);
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
u as c,
|
|
29
|
+
n as f,
|
|
30
|
+
r as l,
|
|
31
|
+
s
|
|
32
|
+
};
|