ono-react-element 0.0.11 → 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.
Files changed (58) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/es/AutoSliderList-w9mw0JCN.js +30 -0
  3. package/dist/es/InjunctiveBox-DUNoNHCO.js +11 -0
  4. package/dist/es/{Input-Z3uL5-nj.js → Input-DLOeg2pz.js} +32 -32
  5. package/dist/es/Message-BGDILiLc.js +105 -0
  6. package/dist/es/{Modal-C-c_S_VM.js → Modal-BIFxRjSt.js} +10 -10
  7. package/dist/es/{Select-BXPk2P2w.js → Select-DAU6TuBu.js} +6 -6
  8. package/dist/es/{Switch-CN3M5pXb.js → Switch-CRJejHP9.js} +13 -13
  9. package/dist/es/{TemplateDialog-CO-4TmAd.js → TemplateDialog-dD8BcnbA.js} +11 -11
  10. package/dist/es/{Toast-BadlA1yD.js → Toast-CQEsbqUJ.js} +27 -27
  11. package/dist/es/{Tooltip-C5OFmxWo.js → Tooltip-j2AKREfX.js} +11 -11
  12. package/dist/es/VirtualList-w16-kBkT.js +65 -0
  13. package/dist/es/{Waterfall-a_c3urjB.js → Waterfall-CFVkuuCO.js} +17 -17
  14. package/dist/es/colorUtils.ts-DYuRvCXZ.js +145 -0
  15. package/dist/es/common.ts-DQOEx8k3.js +126 -0
  16. package/dist/es/fileFormatConversion.ts-tUlewYon.js +38 -0
  17. package/dist/es/formatTimeUtils.ts-CkdWJ_Sl.js +32 -0
  18. package/dist/es/index.js +96 -85
  19. package/dist/es/useClickOutSide.tsx-CMvd2uTW.js +15 -0
  20. package/dist/es/useCountdown.tsx-Btzj-keH.js +16 -0
  21. package/dist/es/useEventListener.tsx-BBGVcI5T.js +12 -0
  22. package/dist/es/useGetElementSize.tsx-Dtshth0Y.js +22 -0
  23. package/dist/es/useKeyPress.tsx-Db44HXXz.js +18 -0
  24. package/dist/es/useMouseClick.tsx-C7uAH4n4.js +12 -0
  25. package/dist/es/useTheme.tsx-C5b7BRYz.js +24 -0
  26. package/dist/es/useThemePro.tsx-DQuSI8J7.js +20 -0
  27. package/dist/es/viewTransitionUtils.ts-CHa9uBpi.js +19 -0
  28. package/dist/index.css +1 -1
  29. package/dist/style/Button.css +1 -1
  30. package/dist/style/Message.css +1 -1
  31. package/dist/style/Modal.css +1 -1
  32. package/dist/style/Toast.css +1 -1
  33. package/dist/style/index.css +1 -1
  34. package/dist/types/components/TemplateDialog/TemplateDialog.d.ts +1 -1
  35. package/dist/types/components/TemplateDialog/types.d.ts +1 -1
  36. package/dist/types/hooks/useClickOutSide.d.ts +2 -2
  37. package/dist/types/hooks/useCountdown.d.ts +2 -1
  38. package/dist/types/hooks/useEventListener.d.ts +2 -2
  39. package/dist/types/hooks/useGetElementSize.d.ts +2 -1
  40. package/dist/types/hooks/useKeyPress.d.ts +2 -2
  41. package/dist/types/hooks/useMouseClick.d.ts +9 -0
  42. package/dist/types/hooks/useTheme.d.ts +2 -2
  43. package/dist/types/hooks/useThemePro.d.ts +2 -2
  44. package/dist/types/index.d.ts +9 -2
  45. package/dist/umd/index.css +1 -1
  46. package/dist/umd/index.css.br +0 -0
  47. package/dist/umd/index.css.gz +0 -0
  48. package/dist/umd/index.umd.cjs +398 -392
  49. package/dist/umd/index.umd.cjs.br +0 -0
  50. package/dist/umd/index.umd.cjs.gz +0 -0
  51. package/package.json +3 -2
  52. package/dist/es/AutoSliderList-Dy-otnYu.js +0 -30
  53. package/dist/es/InjunctiveBox-D0V-K9Pn.js +0 -11
  54. package/dist/es/Message-GvTC61N0.js +0 -68
  55. package/dist/es/VirtualList-BeDq637Z.js +0 -65
  56. package/dist/es/hooks-Dew3_cmY.js +0 -103
  57. package/dist/es/utils-BxXROOPY.js +0 -394
  58. package/dist/types/hooks/index.d.ts +0 -7
@@ -1,394 +0,0 @@
1
- import { p as t } from "./PortalRenderer-CDAzQJgm.js";
2
- const e = { changeThemeClipPathCircle: (t2) => {
3
- const e2 = "ono-view-transition-clip-path-circle", { element: n2, duration: r2 = 300, themeRules: s2, onChangeTheme: a2 } = t2, o2 = (s2 == null ? void 0 : s2()) || document.documentElement.classList.contains("dark") ? "dark" : "light";
4
- if (!document.startViewTransition) return a2("dark" === o2 ? "light" : "dark");
5
- const i2 = document.startViewTransition(() => {
6
- const t3 = document.documentElement.classList.contains("dark");
7
- a2(t3 ? "light" : "dark");
8
- }), { top: c2, left: l2, width: h2, height: u2 } = n2.getBoundingClientRect(), d2 = l2 + h2 / 2, p2 = c2 + u2 / 2, g2 = [`circle(0% at ${d2}px ${p2}px)`, `circle(${Math.hypot(Math.max(d2, window.innerWidth - d2), Math.max(p2, window.innerHeight - p2))}px at ${d2}px ${p2}px)`];
9
- ((t3, e3) => {
10
- const n3 = document.createElement("style");
11
- n3.setAttribute("type", "text/css"), n3.setAttribute("data-style-tag", e3), n3.textContent = "\n ::view-transition-old(root),\n ::view-transition-new(root) {\n animation: none;\n }\n .dark::view-transition-old(root) {\n z-index: 1;\n }\n\n .dark::view-transition-new(root) {\n z-index: 999;\n }\n\n ::view-transition-old(root) {\n z-index: 999;\n }\n\n ::view-transition-new(root) {\n z-index: 1;\n }\n ", document.head.appendChild(n3);
12
- })(0, e2), i2.ready.then(() => {
13
- document.documentElement.animate({ clipPath: "light" === o2 ? g2 : g2.reverse() }, { duration: r2, easing: "ease-in-out", pseudoElement: "light" === o2 ? "::view-transition-new(root)" : "::view-transition-old(root)" }), setTimeout(() => ((t3) => {
14
- document.head.querySelectorAll("style").forEach((e3) => e3.getAttribute("data-style-tag") === t3 && e3.remove());
15
- })(e2), r2 + 100);
16
- });
17
- } }, n = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])[\da-zA-Z]{8,}$/, r = (t2) => t2 <= 11 ? Math.random().toString(36).substring(2, 2 + t2).padEnd(t2, "0") : r(11) + r(t2 - 11), s = ({ el: t2, str: e2 = "hello world", speed: n2 = 100, isExtendStr: r2 = true, onDone: s2 }) => {
18
- let a2 = 0, o2 = null;
19
- t2.textContent && r2 && (a2 = t2.textContent.length, e2 = t2.textContent + e2);
20
- const i2 = () => {
21
- clearTimeout(o2);
22
- const r3 = e2.substring(0, a2 + 1);
23
- t2.textContent = r3, a2++, a2 !== e2.length ? o2 = setTimeout(i2, n2) : s2 && s2();
24
- };
25
- i2();
26
- }, a = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), o = async (t2, e2) => {
27
- const n2 = (t3, e3) => {
28
- const n3 = window.URL.createObjectURL(t3), r2 = document.createElement("a");
29
- r2.href = n3, r2.download = encodeURIComponent(e3), document.body.appendChild(r2), r2.click(), document.body.removeChild(r2), window.URL.revokeObjectURL(n3);
30
- };
31
- try {
32
- if ("string" == typeof t2) {
33
- const r2 = await fetch(t2);
34
- if (!r2.ok) throw new Error(`Network response was not ok: ${r2.statusText}`);
35
- n2(await r2.blob(), e2);
36
- } else n2(t2, e2);
37
- } catch (t3) {
38
- console.error("文件下载失败:", t3 instanceof Error ? t3.message : String(t3));
39
- }
40
- }, i = (t2, e2) => {
41
- t2.toString().startsWith("2") ? e2.onSuccess && e2.onSuccess() : (t2.toString().startsWith("4") || t2.toString().startsWith("5")) && e2.onFail && e2.onFail();
42
- }, c = (t2) => {
43
- const e2 = t2.getBoundingClientRect();
44
- return { x: e2.left + e2.width / 2, y: e2.top + e2.height / 2 };
45
- }, l = (t2, e2, n2) => {
46
- const r2 = new IntersectionObserver(e2, n2);
47
- t2 instanceof HTMLElement ? r2.observe(t2) : t2.forEach((t3) => r2.observe(t3));
48
- }, h = (t2) => {
49
- const e2 = Math.floor(t2 / 3600), n2 = Math.floor(t2 % 3600 / 60), r2 = Math.floor(t2 % 60), s2 = (t3) => t3.toString().padStart(2, "0");
50
- return (e2 > 0 ? `${s2(e2)}:${s2(n2)}:${s2(r2)}` : `${s2(n2)}:${s2(r2)}`) + (t2 < 10 ? ".00" : t2 < 100 ? ".0" : "");
51
- }, u = (t2) => {
52
- if (t2.length < 2) return t2;
53
- const e2 = t2[0], n2 = t2.slice(1).filter((t3) => t3 <= e2), r2 = t2.slice(1).filter((t3) => t3 > e2);
54
- return [...u(n2), e2, ...u(r2)];
55
- }, d = (t2, e2) => {
56
- const n2 = ["B", "KB", "MB", "GB", "TB"], r2 = 1024;
57
- let s2 = n2.indexOf((e2 == null ? void 0 : e2.unit) ?? "B");
58
- if (-1 === s2) throw new Error("Invalid unit");
59
- if (!(e2 == null ? void 0 : e2.unit)) for (; t2 / Math.pow(r2, s2) >= r2; ) s2++;
60
- return `${(t2 / Math.pow(r2, s2)).toFixed((e2 == null ? void 0 : e2.decimalPlaces) ?? 0)} ${n2[s2]}`;
61
- }, p = (t2, e2) => `${Math.floor(t2 / g(t2, e2))}:${Math.floor(e2 / g(t2, e2))}`, g = (t2, e2) => {
62
- for (; 0 !== e2; ) {
63
- const n2 = e2;
64
- e2 = t2 % e2, t2 = n2;
65
- }
66
- return t2;
67
- }, m = (t2, e2, n2) => {
68
- t2.muted = true, t2.play();
69
- const r2 = new AudioContext(), s2 = "running" === r2.state;
70
- r2.close(), s2 ? (t2.muted = false, e2 == null ? void 0 : e2()) : n2 == null ? void 0 : n2();
71
- }, b = (t2) => new URLSearchParams(window.location.search).get(t2), f = (t2) => {
72
- let e2;
73
- const n2 = new Proxy(t2, { construct: (t3, n3) => (e2 || (e2 = Reflect.construct(t3, n3)), e2) });
74
- return n2.prototype.construct = n2, n2;
75
- }, w = (t2) => "string" != typeof t2 || 0 === t2.length ? "" : t2.charAt(0).toUpperCase() + t2.slice(1), M = (t2) => {
76
- if ("object" != typeof t2 || null === t2) return t2;
77
- const e2 = Array.isArray(t2) ? [] : {};
78
- for (const n2 in t2) Object.prototype.hasOwnProperty.call(t2, n2) && (e2[n2] = M(t2[n2]));
79
- return e2;
80
- }, $ = (t2) => new Promise((e2) => {
81
- const n2 = new Image();
82
- n2.src = "string" == typeof t2 ? t2 : URL.createObjectURL(t2), n2.onload = () => e2({ width: n2.width, height: n2.height });
83
- }), y = (t2, e2) => {
84
- let n2 = 0;
85
- const r2 = (s2) => {
86
- n2 || (n2 = s2), s2 - n2 >= e2 ? t2() : requestAnimationFrame(r2);
87
- };
88
- requestAnimationFrame(r2);
89
- }, x = (t2, e2, n2) => {
90
- const r2 = t2[e2];
91
- t2[e2] = function(t3) {
92
- r2 && "function" == typeof r2 && r2.call(this, t3), n2.call(this, t3);
93
- };
94
- }, S = (t2) => {
95
- if ("number" != typeof t2 || isNaN(t2)) throw new Error("请输入有效的数字");
96
- const e2 = t2.toString().split(".");
97
- return e2[0] = e2[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), e2.join(".");
98
- }, N = (t2) => parseFloat(t2.replace(/[^0-9.]/g, "")), I = (t2, e2, n2, r2) => Math.sqrt((t2 - n2) ** 2 + (e2 - r2) ** 2), k = (t2) => navigator.clipboard.writeText(t2), C = (t2) => Math.ceil((t2.getTime() - new Date(t2.getFullYear(), 0, 1).getTime()) / 864e5), v = (t2, e2, n2) => 0.2126 * t2 + 0.7152 * e2 + 0.0722 * n2, A = (t2) => {
99
- const e2 = {};
100
- return t2.replace(/([^?=&]+)=([^&]+)/g, (t3, n2, r2) => e2[n2] = r2), e2;
101
- }, O = (t2, ...e2) => Object.fromEntries(Object.entries(t2).filter(([t3]) => e2.includes(t3))), D = (t2) => {
102
- if (!t2) return "";
103
- const e2 = t2.lastIndexOf(".");
104
- return -1 === e2 ? D(t2.substring(t2.lastIndexOf("/") + 1)) : t2.substring(0, e2);
105
- }, E = (t2) => {
106
- if (!t2) return "";
107
- const e2 = t2.lastIndexOf(".");
108
- return t2.substring(e2 + 1);
109
- }, F = { addCommasToNumber: S, addEventWithOriginHandler: x, calculateAspectRatio: p, checkDeviceIsMobile: a, checkStatusCode: i, copy2Clipboard: k, createIntersectionObserver: l, dayOfYear: C, deepCopy: M, downloadFile: o, formatFileSize: d, formatSecondes: h, getElementCenterPosition: c, getFileName: D, getFileSuffix: E, getImageSIze: $, getPointDistance: I, getURLSearchParams: b, grayColor: v, mediaAutoplayPolicies: m, parseQuery: A, passwordStrength: n, pick: O, printStr: s, pureNumber: N, quickSort: u, rafTimeout: y, randomString: r, safeCapitalizeWord: w, singleton: f };
110
- let j = 1;
111
- const R = [], P = (t2, e2, n2) => (0 === R.length && (j = 1), Y(e2.instancesKey || "", t2, { id: `${n2}-${j++}`, key: e2.instancesKey || "", reactNode: t2, props: e2, offsetOptions: { topOffset: 0, height: 0, bottomOffset: 0 } }), R), T = (t2) => {
112
- const e2 = R.findIndex((e3) => e3.id === t2);
113
- -1 !== e2 && R.splice(e2, 1);
114
- }, U = (t2, e2) => {
115
- const n2 = R.findIndex((e3) => e3.id === t2);
116
- n2 < 0 || (R[n2].offsetOptions = e2);
117
- }, B = (t2) => {
118
- const e2 = R.findIndex((e3) => e3.id === t2);
119
- return e2 <= 0 ? 0 : R[e2 - 1].offsetOptions.topOffset;
120
- }, L = (t2) => {
121
- const e2 = R.findIndex((e3) => e3.id === t2);
122
- return e2 <= 0 ? 0 : R[e2 - 1].offsetOptions.bottomOffset;
123
- }, Y = (e2, n2, r2) => {
124
- const s2 = (e3) => t(n2, { zIndex: 999 + j - 1, ...e3.props, id: e3.id }, e3.id, "ono-message-root");
125
- if (!e2) {
126
- const t2 = s2(r2);
127
- R.push({ ...r2, props: { ...r2.props, id: r2.id, destroy: t2 }, destroy: t2 });
128
- }
129
- let a2 = false;
130
- const o2 = R.map((t2) => {
131
- if (t2.key === e2) {
132
- a2 = true;
133
- const e3 = { ...t2.props, ...r2.props };
134
- return { ...t2, props: e3 };
135
- }
136
- {
137
- const e3 = s2(t2);
138
- return { ...t2, props: { ...t2.props, id: t2.id, destroy: e3 }, destroy: e3 };
139
- }
140
- });
141
- if (Object.assign(R, o2), !a2) {
142
- const t2 = s2(r2);
143
- R.push({ ...r2, props: { ...r2.props, id: r2.id, destroy: t2 }, destroy: t2 });
144
- }
145
- }, z = (t2) => {
146
- var _a;
147
- return t2 ? (_a = R.find((e2) => e2.key === t2)) == null ? void 0 : _a.props : null;
148
- }, W = /\d+/g, q = (t2) => {
149
- const e2 = t2.match(W), n2 = (t3) => Number(t3).toString(16).padStart(2, "0"), r2 = (t3) => t3.reduce((t4, e3) => t4 + n2(e3), "#"), s2 = (t3) => {
150
- const e3 = t3, s3 = 1 !== Number(t3[t3.length - 1]) ? Number(t3[t3.length - 1]) : 100;
151
- return e3.pop(), r2(e3) + n2(2.56 * s3);
152
- };
153
- return 3 === e2.length ? r2(e2) : 5 === e2.length ? s2([e2[0], e2[1], e2[2], 10 * Number(e2[e2.length - 1])]) : s2(e2);
154
- }, H = (t2) => {
155
- const e2 = t2.split("#")[1], n2 = (t3) => [parseInt(t3.slice(0, 2), 16), parseInt(t3.slice(2, 4), 16), parseInt(t3.slice(4, 6), 16)];
156
- if (8 === e2.length) {
157
- const t3 = parseInt(e2.slice(-2), 16) / 256, r2 = n2(e2.slice(0, -2));
158
- return r2.push(t3), "rgba(" + r2.join(", ") + ")";
159
- }
160
- return "rgb(" + n2(e2).join(", ") + ")";
161
- }, J = (t2) => {
162
- const e2 = t2.match(W), n2 = Number(e2[0]) / 255, r2 = Number(e2[1]) / 255, s2 = Number(e2[2]) / 255, a2 = Math.min(n2, r2, s2), o2 = Math.max(n2, r2, s2);
163
- let i2 = 0, c2 = 0, l2 = (o2 + a2) / 2;
164
- if (o2 === a2) i2 = c2 = 0;
165
- else {
166
- const t3 = o2 - a2;
167
- switch (c2 = l2 > 0.5 ? t3 / (2 - o2 - a2) : t3 / (o2 + a2), o2) {
168
- case n2:
169
- i2 = (r2 - s2) / t3 + (r2 < s2 ? 6 : 0);
170
- break;
171
- case r2:
172
- i2 = (s2 - n2) / t3 + 2;
173
- break;
174
- case s2:
175
- i2 = (n2 - r2) / t3 + 4;
176
- }
177
- i2 /= 6;
178
- }
179
- return `hsl(${Math.round(360 * i2)}, ${Math.round(100 * c2)}%, ${Math.round(100 * l2)}%)`;
180
- }, K = (t2) => {
181
- const e2 = t2.match(W), n2 = Number(e2[0]) / 360, r2 = Number(e2[1]) / 100, s2 = Number(e2[2]) / 100;
182
- let a2, o2, i2;
183
- function c2(t3, e3, n3) {
184
- return n3 < 0 && (n3 += 1), n3 > 1 && (n3 -= 1), n3 < 1 / 6 ? t3 + 6 * (e3 - t3) * n3 : n3 < 0.5 ? e3 : n3 < 2 / 3 ? t3 + (e3 - t3) * (2 / 3 - n3) * 6 : t3;
185
- }
186
- let l2 = s2 < 0.5 ? s2 * (1 + r2) : s2 + r2 - s2 * r2, h2 = 2 * s2 - l2;
187
- return a2 = c2(h2, l2, n2 + 1 / 3), o2 = c2(h2, l2, n2), i2 = c2(h2, l2, n2 - 1 / 3), `rgb(${Math.round(255 * a2)}, ${Math.round(255 * o2)}, ${Math.round(255 * i2)})`;
188
- }, V = (t2) => J(H(t2)), Z = (t2) => q(K(t2)), G = (t2) => {
189
- const e2 = t2.match(W);
190
- let n2 = Number(e2[0]) / 255, r2 = Number(e2[1]) / 255, s2 = Number(e2[2]) / 255;
191
- const a2 = Math.max(n2, r2, s2), o2 = Math.min(n2, r2, s2);
192
- let i2 = 0, c2 = 0, l2 = a2;
193
- const h2 = a2 - o2;
194
- if (c2 = 0 === a2 ? 0 : h2 / a2, a2 === o2) i2 = 0;
195
- else {
196
- switch (a2) {
197
- case n2:
198
- i2 = (r2 - s2) / h2 + (r2 < s2 ? 6 : 0);
199
- break;
200
- case r2:
201
- i2 = (s2 - n2) / h2 + 2;
202
- break;
203
- case s2:
204
- i2 = (n2 - r2) / h2 + 4;
205
- }
206
- i2 /= 6;
207
- }
208
- return `hsv(${360 * i2}, ${100 * c2}, ${100 * l2})`;
209
- }, Q = (t2) => {
210
- const e2 = t2.match(W);
211
- let n2, r2, s2, a2, o2, i2, c2, l2, h2 = Number(e2[0]) / 360, u2 = Number(e2[1]) / 100, d2 = Number(e2[2]) / 100;
212
- if (h2 && 0 === u2) n2 = r2 = s2 = d2;
213
- else switch (h2 /= 60, a2 = Math.floor(h2), o2 = h2 - a2, i2 = d2 * (1 - u2), c2 = d2 * (1 - u2 * o2), l2 = d2 * (1 - u2 * (1 - o2)), a2) {
214
- case 0:
215
- n2 = d2, r2 = l2, s2 = i2;
216
- break;
217
- case 1:
218
- n2 = c2, r2 = d2, s2 = i2;
219
- break;
220
- case 2:
221
- n2 = i2, r2 = d2, s2 = l2;
222
- break;
223
- case 3:
224
- n2 = i2, r2 = c2, s2 = d2;
225
- break;
226
- case 4:
227
- n2 = l2, r2 = i2, s2 = d2;
228
- break;
229
- default:
230
- n2 = d2, r2 = i2, s2 = c2;
231
- }
232
- return `rgb(${Math.round(255 * n2)}, ${Math.round(255 * r2)}, ${Math.round(255 * s2)})`;
233
- }, _ = (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", X = (t2, e2, n2) => {
234
- let r2 = [];
235
- if (t2.includes("#")) r2 = V(t2).match(W);
236
- else if (t2.includes("rgb")) r2 = J(t2).match(W);
237
- else {
238
- if (!t2.includes("hsl")) throw new Error("颜色格式错误");
239
- r2 = t2.match(W);
240
- }
241
- return Z(`${r2[0]}, ${r2[1]}%, ${"light" === e2 ? Number(r2[2]) + n2 > 100 ? 100 : Number(r2[2]) + n2 : Number(r2[2]) - n2 < 0 ? 0 : Number(r2[2]) - n2}%`);
242
- }, tt = { randomColor: () => "#" + Math.random().toString(16).slice(2, 8).padEnd(6, "0"), rgb2hex: q, hex2rgb: H, rgb2rgba: (t2, e2) => {
243
- if (!e2) return t2;
244
- if (t2.includes("rgba")) {
245
- const n2 = t2.split(",");
246
- return n2.pop(), n2.push(e2 + ")"), n2.join(",");
247
- }
248
- if (t2.includes("rgb")) {
249
- const n2 = t2.split(","), r2 = "rgba(" + n2[0].split("(")[1], s2 = n2[n2.length - 1].split(")")[0];
250
- return [r2, n2[1], s2, " " + e2 + ")"].join(",");
251
- }
252
- }, rgb2hsl: J, hsl2rgb: K, hex2hsl: V, hsl2hex: Z, rgb2hsv: G, hsv2rgb: Q, hex2hsv: (t2) => G(H(t2)), hsv2hex: (t2) => q(Q(t2)), formatColor: (t2, e2, n2 = "rgba") => {
253
- const r2 = t2.match(W);
254
- let s2 = Number(r2[0]) / 255, a2 = Number(r2[1]) / 255, o2 = Number(r2[2]) / 255;
255
- return "rgba" === n2 ? `rgba(${s2},${a2},${o2},${e2})` : "rgb" === n2 ? t2 : "hex" === n2 ? q(t2) : "hsl" === n2 ? J(`rgba(${s2},${a2},${o2},${e2})`) : `rgba(${s2},${a2},${o2},${e2})`;
256
- }, getContrastColor: (t2) => {
257
- const e2 = (function(t3) {
258
- 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)];
259
- if (t3.startsWith("rgb")) {
260
- const e3 = t3.match(/\d+/g);
261
- return [parseInt(e3[0]), parseInt(e3[1]), parseInt(e3[2])];
262
- }
263
- return null;
264
- })(t2);
265
- return null === e2 ? null : (299 * (n2 = e2)[0] + 587 * n2[1] + 114 * n2[2]) / 1e3 > 128 ? "#000" : "#fff";
266
- var n2;
267
- }, adjustColor: (t2, e2, n2) => {
268
- const r2 = _(t2);
269
- if ("hex" === r2) {
270
- const r3 = t2.replace("#", ""), s2 = parseInt(r3.slice(0, 2), 16), a2 = parseInt(r3.slice(2, 4), 16), o2 = parseInt(r3.slice(4, 6), 16);
271
- if ("lighten" === e2) {
272
- const t3 = Math.min(255, Math.max(0, s2 + (255 - s2) * n2 / 100)), e3 = Math.min(255, Math.max(0, a2 + (255 - a2) * n2 / 100)), r4 = Math.min(255, Math.max(0, o2 + (255 - o2) * n2 / 100));
273
- return `#${t3.toString(16).padStart(2, "0")}${e3.toString(16).padStart(2, "0")}${r4.toString(16).padStart(2, "0")}`;
274
- }
275
- if ("darken" === e2) {
276
- const t3 = Math.min(255, Math.max(0, s2 - s2 * n2 / 100)), e3 = Math.min(255, Math.max(0, a2 - a2 * n2 / 100)), r4 = Math.min(255, Math.max(0, o2 - o2 * n2 / 100));
277
- return `#${t3.toString(16).padStart(2, "0")}${e3.toString(16).padStart(2, "0")}${r4.toString(16).padStart(2, "0")}`;
278
- }
279
- } else if ("rgb" === r2) {
280
- const r3 = t2.match(/\d+/g), s2 = parseInt(r3[0]), a2 = parseInt(r3[1]), o2 = parseInt(r3[2]);
281
- if ("lighten" === e2) return `rgb(${Math.min(255, Math.max(0, s2 + (255 - s2) * n2 / 100))},${Math.min(255, Math.max(0, a2 + (255 - a2) * n2 / 100))},${Math.min(255, Math.max(0, o2 + (255 - o2) * n2 / 100))})`;
282
- if ("darken" === e2) return `rgb(${Math.min(255, Math.max(0, s2 - s2 * n2 / 100))},${Math.min(255, Math.max(0, a2 - a2 * n2 / 100))},${Math.min(255, Math.max(0, o2 - o2 * n2 / 100))})`;
283
- }
284
- return t2;
285
- }, 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: _, hex3To6: (t2) => {
286
- const e2 = t2.replace("#", "").split("");
287
- return `#${e2[0] + e2[0] + e2[1] + e2[1] + e2[2] + e2[2]}`;
288
- }, adjustingColors: X }, et = (t2) => {
289
- const e2 = t2.split(","), n2 = e2[0].match(/:(.*?);/)[1], r2 = atob(e2[1]);
290
- let s2 = r2.length;
291
- const a2 = new Uint8Array(s2);
292
- for (; s2--; ) a2[s2] = r2.charCodeAt(s2);
293
- return new Blob([a2], { type: n2 });
294
- }, nt = (t2, e2) => {
295
- const n2 = t2.split(","), r2 = n2[0].match(/:(.*?);/u)[1], s2 = atob(n2[1]);
296
- let a2 = s2.length, o2 = "jpeg" === r2.split("/")[1] ? ".jpg" : "." + r2.split("/")[1];
297
- const i2 = new Uint8Array(a2);
298
- for (; a2--; ) i2[a2] = s2.charCodeAt(a2);
299
- const c2 = new Blob([i2], { type: r2 });
300
- return new File([c2], e2 + o2, { type: r2, lastModified: (/* @__PURE__ */ new Date()).getTime() });
301
- }, rt = (t2) => new Promise((e2) => {
302
- const n2 = new FileReader();
303
- n2.readAsDataURL(t2), n2.onload = (t3) => {
304
- var _a;
305
- const n3 = (_a = t3.target) == null ? void 0 : _a.result, r2 = n3.split(",")[1];
306
- e2(r2);
307
- };
308
- }), st = (t2, e2 = "abc.jpg") => new File([t2], e2, { type: t2.type }), at = (t2) => new Promise((e2) => {
309
- const n2 = new FileReader();
310
- n2.readAsDataURL(t2), n2.onload = (t3) => {
311
- var _a;
312
- return e2((_a = t3.target) == null ? void 0 : _a.result);
313
- };
314
- }), ot = (t2) => t2.slice(0, t2.size, t2.type), it = async (t2) => await (await fetch(t2)).blob(), ct = async (t2) => st(await it(t2)), lt = async (t2) => await rt(await it(t2)), ht = (t2) => t2 < 10 ? `0${t2}` : `${t2}`, ut = (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))), dt = (t2, e2 = "YY-MM-DD hh:mm:ss") => {
315
- const n2 = ["YY", "MM", "DD", "hh", "mm", "ss"], r2 = [], s2 = ut(t2);
316
- r2.push(s2.getFullYear().toString()), r2.push(ht(s2.getMonth() + 1)), r2.push(ht(s2.getDate())), r2.push(ht(s2.getHours())), r2.push(ht(s2.getMinutes())), r2.push(ht(s2.getSeconds()));
317
- for (let t3 in r2) e2 = e2.replace(n2[t3], r2[t3]);
318
- return e2;
319
- }, pt = (t2, e2 = "YY-MM-DD hh:mm:ss", n2 = "cn") => {
320
- const r2 = ["YY", "MM", "DD", "hh", "mm", "ss"], s2 = [], a2 = ut(t2);
321
- s2.push(((t3, e3) => {
322
- const n3 = { en: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], cn: ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"] };
323
- return t3.split("").map((t4) => n3[e3][Number(t4)]).join("");
324
- })(a2.getFullYear().toString(), n2)), s2.push(((t3, e3) => ({ en: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], cn: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"] })[e3][Number(t3) - 1])(ht(a2.getMonth() + 1), n2)), s2.push(((t3, e3) => {
325
- let n3;
326
- return "en" === e3 ? n3 = "01" === t3 || "21" === t3 || "31" === t3 ? Number(t3) + "st" : "02" === t3 || "22" === t3 ? Number(t3) + "nd" : "03" === t3 || "23" === t3 ? Number(t3) + "rd" : Number(t3) + "th" : "01" === t3 ? n3 = "一日" : "02" === t3 ? n3 = "二日" : "03" === t3 ? n3 = "三日" : "04" === t3 ? n3 = "四日" : "05" === t3 ? n3 = "五日" : "06" === t3 ? n3 = "六日" : "07" === t3 ? n3 = "七日" : "08" === t3 ? n3 = "八日" : "09" === t3 ? n3 = "九日" : "10" === t3 ? n3 = "十日" : "11" === t3 ? n3 = "十一日" : "12" === t3 ? n3 = "十二日" : "13" === t3 ? n3 = "十三日" : "14" === t3 ? n3 = "十四日" : "15" === t3 ? n3 = "十五日" : "16" === t3 ? n3 = "十六日" : "17" === t3 ? n3 = "十七日" : "18" === t3 ? n3 = "十八日" : "19" === t3 ? n3 = "十九日" : "20" === t3 ? n3 = "二十日" : "21" === t3 ? n3 = "二十一日" : "22" === t3 ? n3 = "二十二日" : "23" === t3 ? n3 = "二十三日" : "24" === t3 ? n3 = "二十四日" : "25" === t3 ? n3 = "二十五日" : "26" === t3 ? n3 = "二十六日" : "27" === t3 ? n3 = "二十七日" : "28" === t3 ? n3 = "二十八日" : "29" === t3 ? n3 = "二十九日" : "30" === t3 ? n3 = "三十日" : "31" === t3 && (n3 = "三十一日"), n3 ?? t3;
327
- })(ht(a2.getDate()), n2)), s2.push(ht(a2.getHours())), s2.push(ht(a2.getMinutes())), s2.push(ht(a2.getSeconds()));
328
- for (let t3 in s2) e2 = e2.replace(r2[t3], s2[t3]);
329
- return e2;
330
- }, gt = (t2, e2) => {
331
- const n2 = ["DD", "hh", "mm", "ss"], r2 = [];
332
- r2.push(Math.floor(t2 / 86400)), r2.push(ht(Math.floor(t2 % 86400 / 3600))), r2.push(ht(Math.floor(t2 % 3600 / 60))), r2.push(ht(t2 % 60));
333
- for (let t3 = 0; t3 < n2.length; t3++) e2 = e2.replace(n2[t3], r2[t3].toString());
334
- return e2;
335
- }, mt = (t2, e2) => {
336
- const n2 = { year: 31536e3, month: 2592e3, day: 86400, hour: 3600, minute: 60, second: 1 };
337
- if (!n2[e2]) throw new Error('Invalid type. Please use "day", "hour", "minute", or "second".');
338
- return Math.floor(t2 / n2[e2]);
339
- };
340
- export {
341
- o as A,
342
- at as B,
343
- ot as C,
344
- d as D,
345
- h as E,
346
- dt as F,
347
- D as G,
348
- E as H,
349
- $ as I,
350
- I as J,
351
- b as K,
352
- v as L,
353
- pt as M,
354
- m as N,
355
- A as O,
356
- n as P,
357
- O as Q,
358
- s as R,
359
- u as S,
360
- y as T,
361
- r as U,
362
- w as V,
363
- gt as W,
364
- f as X,
365
- lt as Y,
366
- it as Z,
367
- ct as _,
368
- z as a,
369
- U as b,
370
- P as c,
371
- L as d,
372
- T as e,
373
- X as f,
374
- B as g,
375
- c as h,
376
- S as i,
377
- x as j,
378
- et as k,
379
- nt as l,
380
- rt as m,
381
- st as n,
382
- p as o,
383
- N as p,
384
- a as q,
385
- i as r,
386
- tt as s,
387
- F as t,
388
- mt as u,
389
- e as v,
390
- k as w,
391
- l as x,
392
- C as y,
393
- M as z
394
- };
@@ -1,7 +0,0 @@
1
- export * from './useClickOutSide';
2
- export * from './useCountdown';
3
- export * from './useEventListener';
4
- export * from './useGetElementSize';
5
- export * from './useKeyPress';
6
- export * from './useTheme';
7
- export * from './useThemePro';