ono-react-element 0.0.7 → 0.0.8
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-Dy-otnYu.js +30 -0
- package/dist/es/AvatarCrop-DrA-SARP.js +65 -0
- package/dist/es/Button-C89izu2m.js +26 -0
- package/dist/es/Card3D-DMvCSUhe.js +18 -0
- package/dist/es/Checkbox-daBabj14.js +19 -0
- package/dist/es/InjunctiveBox-D0V-K9Pn.js +11 -0
- package/dist/es/Input-Z3uL5-nj.js +80 -0
- package/dist/es/List-UAKCMuGC.js +19 -0
- package/dist/es/MenuButton-DHkU5Bq7.js +17 -0
- package/dist/es/Message-GvTC61N0.js +68 -0
- package/dist/es/Modal-C-c_S_VM.js +32 -0
- package/dist/es/Pagination-m71H2tfS.js +17 -0
- package/dist/es/PortalRenderer-CDAzQJgm.js +19 -0
- package/dist/es/Radio-D_GKVoOC.js +25 -0
- package/dist/es/Select-y-aAIqxg.js +23 -0
- package/dist/es/SvgImg-CZwq2D7J.js +14 -0
- package/dist/es/Switch-CN3M5pXb.js +34 -0
- package/dist/es/TemplateDialog-fX7Ie-xU.js +45 -0
- package/dist/es/Toast-BadlA1yD.js +42 -0
- package/dist/es/Tooltip-C5OFmxWo.js +29 -0
- package/dist/es/VirtualList-BeDq637Z.js +65 -0
- package/dist/es/Waterfall-a_c3urjB.js +55 -0
- package/dist/es/dependencies-CbQbPZZ-.js +15524 -0
- package/dist/es/hooks-Dew3_cmY.js +103 -0
- package/dist/es/index.js +106 -231
- package/dist/es/utils-BxXROOPY.js +394 -0
- package/dist/index.css +1 -1
- package/dist/style/AutoSliderList.css +1 -0
- package/dist/style/AvatarCrop.css +1 -0
- package/dist/style/Button.css +1 -0
- package/dist/style/Card3D.css +1 -0
- package/dist/style/Checkbox.css +1 -0
- package/dist/style/Input.css +1 -0
- package/dist/style/MenuButton.css +1 -0
- package/dist/style/Message.css +1 -0
- package/dist/style/Modal.css +1 -0
- package/dist/style/Pagination.css +1 -0
- package/dist/style/Radio.css +1 -0
- package/dist/style/Select.css +1 -0
- package/dist/style/SvgImg.css +1 -0
- package/dist/style/Switch.css +1 -0
- package/dist/style/TemplateDialog.css +1 -0
- package/dist/style/Toast.css +1 -0
- package/dist/style/Tooltip.css +1 -0
- package/dist/style/Waterfall.css +1 -0
- package/dist/style/index.css +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/printLogo.d.ts +1 -0
- package/dist/types/utils/common.d.ts +36 -20
- 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 +16583 -295
- package/dist/umd/index.umd.cjs.br +0 -0
- package/dist/umd/index.umd.cjs.gz +0 -0
- package/package.json +56 -49
- package/dist/es/AutoSliderList-DN4Sec6L.js +0 -106
- package/dist/es/AvatarCrop-DzGw2FVQ.js +0 -225
- package/dist/es/Button-CdxyXFF4.js +0 -72
- package/dist/es/Card3D-sf3zmiHk.js +0 -41
- package/dist/es/Checkbox-BN7rT73n.js +0 -62
- package/dist/es/InjunctiveBox-CGpy0PxH.js +0 -39
- package/dist/es/Input-DoY3kR7J.js +0 -301
- package/dist/es/List-B9mP7VjN.js +0 -35
- package/dist/es/MenuButton-CuOdVlg0.js +0 -62
- package/dist/es/Message-TfweOOpK.js +0 -219
- package/dist/es/Modal-CHgTYu-I.js +0 -154
- package/dist/es/Pagination-BtmtUkVw.js +0 -110
- package/dist/es/PortalRenderer-8Iur-eZp.js +0 -38
- package/dist/es/Radio-BmSpqdK8.js +0 -113
- package/dist/es/SvgImg-Bcmzdjzl.js +0 -38
- package/dist/es/Switch-DwDBR0sG.js +0 -110
- package/dist/es/TemplateDialog-SXrElzoR.js +0 -75
- package/dist/es/Toast-C7ybVNyd.js +0 -174
- package/dist/es/Tooltip-BtzG0TSW.js +0 -94
- package/dist/es/VirtualList-OG7kqLe0.js +0 -160
- package/dist/es/Waterfall-GHdJxww4.js +0 -131
- package/dist/es/dependencies-DWmdjl5u.js +0 -25491
- package/dist/es/hooks-CQN6qu4t.js +0 -159
- package/dist/es/utils-BLV_TQU3.js +0 -585
|
@@ -1,585 +0,0 @@
|
|
|
1
|
-
import { p as R } from "./PortalRenderer-8Iur-eZp.js";
|
|
2
|
-
const E = (t, n) => {
|
|
3
|
-
const e = document.createElement("style");
|
|
4
|
-
e.setAttribute("type", "text/css"), e.setAttribute("data-style-tag", n), e.textContent = t, document.head.appendChild(e);
|
|
5
|
-
}, U = (t) => {
|
|
6
|
-
document.head.querySelectorAll("style").forEach(
|
|
7
|
-
(e) => e.getAttribute("data-style-tag") === t && e.remove()
|
|
8
|
-
);
|
|
9
|
-
}, L = (t) => {
|
|
10
|
-
const n = "ono-view-transition-clip-path-circle", { element: e, duration: s = 300, themeRules: r, onChangeTheme: o } = t, i = r != null && r() || document.documentElement.classList.contains("dark") ? "dark" : "light";
|
|
11
|
-
if (!document.startViewTransition)
|
|
12
|
-
return o(i === "dark" ? "light" : "dark");
|
|
13
|
-
const a = document.startViewTransition(() => {
|
|
14
|
-
const j = document.documentElement.classList.contains("dark");
|
|
15
|
-
o(j ? "light" : "dark");
|
|
16
|
-
}), { top: l, left: u, width: c, height: g } = e.getBoundingClientRect(), d = u + c / 2, f = l + g / 2, F = Math.hypot(
|
|
17
|
-
Math.max(d, window.innerWidth - d),
|
|
18
|
-
Math.max(f, window.innerHeight - f)
|
|
19
|
-
), S = [
|
|
20
|
-
`circle(0% at ${d}px ${f}px)`,
|
|
21
|
-
`circle(${F}px at ${d}px ${f}px)`
|
|
22
|
-
];
|
|
23
|
-
E(
|
|
24
|
-
`
|
|
25
|
-
::view-transition-old(root),
|
|
26
|
-
::view-transition-new(root) {
|
|
27
|
-
animation: none;
|
|
28
|
-
}
|
|
29
|
-
.dark::view-transition-old(root) {
|
|
30
|
-
z-index: 1;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.dark::view-transition-new(root) {
|
|
34
|
-
z-index: 999;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
::view-transition-old(root) {
|
|
38
|
-
z-index: 999;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
::view-transition-new(root) {
|
|
42
|
-
z-index: 1;
|
|
43
|
-
}
|
|
44
|
-
`,
|
|
45
|
-
n
|
|
46
|
-
), a.ready.then(() => {
|
|
47
|
-
document.documentElement.animate(
|
|
48
|
-
{
|
|
49
|
-
clipPath: i === "light" ? S : S.reverse()
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
duration: s,
|
|
53
|
-
easing: "ease-in-out",
|
|
54
|
-
pseudoElement: i === "light" ? "::view-transition-new(root)" : "::view-transition-old(root)"
|
|
55
|
-
}
|
|
56
|
-
), setTimeout(() => U(n), s + 100);
|
|
57
|
-
});
|
|
58
|
-
}, xt = {
|
|
59
|
-
changeThemeClipPathCircle: L
|
|
60
|
-
}, Mt = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])[\da-zA-Z]{8,}$/, x = (t) => t <= 11 ? Math.random().toString(36).substring(2, 2 + t).padEnd(t, "0") : x(11) + x(t - 11), z = ({
|
|
61
|
-
el: t,
|
|
62
|
-
str: n = "hello world",
|
|
63
|
-
speed: e = 100,
|
|
64
|
-
isExtendStr: s = !0,
|
|
65
|
-
onDone: r
|
|
66
|
-
}) => {
|
|
67
|
-
let o = 0, i = null;
|
|
68
|
-
t.textContent && s && (o = t.textContent.length, n = t.textContent + n);
|
|
69
|
-
const a = () => {
|
|
70
|
-
clearTimeout(i);
|
|
71
|
-
const l = n.substring(0, o + 1);
|
|
72
|
-
t.textContent = l, o++, o !== n.length ? i = setTimeout(a, e) : r && r();
|
|
73
|
-
};
|
|
74
|
-
a();
|
|
75
|
-
}, Y = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
76
|
-
navigator.userAgent
|
|
77
|
-
), W = async (t, n) => {
|
|
78
|
-
const e = (s, r) => {
|
|
79
|
-
const o = window.URL.createObjectURL(s), i = document.createElement("a");
|
|
80
|
-
i.href = o, i.download = encodeURIComponent(r), document.body.appendChild(i), i.click(), document.body.removeChild(i), window.URL.revokeObjectURL(o);
|
|
81
|
-
};
|
|
82
|
-
try {
|
|
83
|
-
if (typeof t == "string") {
|
|
84
|
-
const s = await fetch(t);
|
|
85
|
-
if (!s.ok)
|
|
86
|
-
throw new Error(`Network response was not ok: ${s.statusText}`);
|
|
87
|
-
const r = await s.blob();
|
|
88
|
-
e(r, n);
|
|
89
|
-
} else e(t, n);
|
|
90
|
-
} catch (s) {
|
|
91
|
-
console.error(
|
|
92
|
-
"文件下载失败:",
|
|
93
|
-
s instanceof Error ? s.message : String(s)
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
}, H = (t, n) => {
|
|
97
|
-
t.toString().startsWith("2") ? n.onSuccess && n.onSuccess() : t.toString().startsWith("4") || t.toString().startsWith("5") ? n.onFail && n.onFail() : console.log("未知状态码");
|
|
98
|
-
}, yt = (t) => {
|
|
99
|
-
const n = t.getBoundingClientRect();
|
|
100
|
-
return { x: n.left + n.width / 2, y: n.top + n.height / 2 };
|
|
101
|
-
}, K = (t, n, e) => {
|
|
102
|
-
const s = new IntersectionObserver(n, e);
|
|
103
|
-
t instanceof HTMLElement ? s.observe(t) : t.forEach((r) => s.observe(r));
|
|
104
|
-
}, q = (t) => {
|
|
105
|
-
const n = Math.floor(t / 3600), e = Math.floor(t % 3600 / 60), s = Math.floor(t % 60), r = (o) => o.toString().padStart(2, "0");
|
|
106
|
-
return (n > 0 ? `${r(n)}:${r(e)}:${r(s)}` : `${r(e)}:${r(s)}`) + (t < 10 ? ".00" : t < 100 ? ".0" : "");
|
|
107
|
-
}, M = (t) => {
|
|
108
|
-
if (t.length < 2) return t;
|
|
109
|
-
const n = t[0], e = t.slice(1).filter((r) => r <= n), s = t.slice(1).filter((r) => r > n);
|
|
110
|
-
return [...M(e), n, ...M(s)];
|
|
111
|
-
}, V = (t, n) => {
|
|
112
|
-
const e = ["B", "KB", "MB", "GB", "TB"];
|
|
113
|
-
let r = e.indexOf((n == null ? void 0 : n.unit) ?? "B");
|
|
114
|
-
if (r === -1)
|
|
115
|
-
throw new Error("Invalid unit");
|
|
116
|
-
if (!(n != null && n.unit))
|
|
117
|
-
for (; t / Math.pow(1024, r) >= 1024; )
|
|
118
|
-
r++;
|
|
119
|
-
return `${(t / Math.pow(1024, r)).toFixed(
|
|
120
|
-
(n == null ? void 0 : n.decimalPlaces) ?? 0
|
|
121
|
-
)} ${e[r]}`;
|
|
122
|
-
}, J = (t, n) => {
|
|
123
|
-
const e = Math.floor(t / A(t, n)), s = Math.floor(n / A(t, n));
|
|
124
|
-
return `${e}:${s}`;
|
|
125
|
-
}, A = (t, n) => {
|
|
126
|
-
for (; n !== 0; ) {
|
|
127
|
-
const e = n;
|
|
128
|
-
n = t % n, t = e;
|
|
129
|
-
}
|
|
130
|
-
return t;
|
|
131
|
-
}, $t = (t, n, e) => {
|
|
132
|
-
t.muted = !0, t.play();
|
|
133
|
-
const s = new AudioContext(), r = s.state === "running";
|
|
134
|
-
s.close(), r ? (t.muted = !1, n == null || n()) : e == null || e();
|
|
135
|
-
}, Z = (t) => new URLSearchParams(window.location.search).get(t), G = (t) => {
|
|
136
|
-
let n;
|
|
137
|
-
const e = new Proxy(t, {
|
|
138
|
-
construct(s, r) {
|
|
139
|
-
return n || (n = Reflect.construct(s, r)), n;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return e.prototype.construct = e, e;
|
|
143
|
-
}, Q = (t) => typeof t != "string" || t.length === 0 ? "" : t.charAt(0).toUpperCase() + t.slice(1), I = (t) => {
|
|
144
|
-
if (typeof t != "object" || t === null) return t;
|
|
145
|
-
const n = Array.isArray(t) ? [] : {};
|
|
146
|
-
for (const e in t)
|
|
147
|
-
Object.prototype.hasOwnProperty.call(t, e) && (n[e] = I(
|
|
148
|
-
t[e]
|
|
149
|
-
));
|
|
150
|
-
return n;
|
|
151
|
-
}, _ = (t) => new Promise((n) => {
|
|
152
|
-
const e = new Image();
|
|
153
|
-
e.src = typeof t == "string" ? t : URL.createObjectURL(t), e.onload = () => n({ width: e.width, height: e.height });
|
|
154
|
-
}), St = (t) => {
|
|
155
|
-
if (typeof t != "number" || isNaN(t))
|
|
156
|
-
throw new Error("请输入有效的数字");
|
|
157
|
-
const n = t.toString().split(".");
|
|
158
|
-
return n[0] = n[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), n.join(".");
|
|
159
|
-
}, At = (t) => parseFloat(t.replace(/[^0-9.]/g, "")), X = (t, n, e, s) => Math.sqrt((t - e) ** 2 + (n - s) ** 2), tt = (t) => navigator.clipboard.writeText(t), It = (t, n, e) => 0.2126 * t + 0.7152 * n + 0.0722 * e, Tt = (t) => {
|
|
160
|
-
const n = {};
|
|
161
|
-
return t.replace(/([^?=&]+)=([^&]+)/g, (e, s, r) => n[s] = r), n;
|
|
162
|
-
}, Ct = (t, ...n) => Object.fromEntries(Object.entries(t).filter(([e]) => n.includes(e))), T = (t) => {
|
|
163
|
-
if (!t) return "";
|
|
164
|
-
const n = t.lastIndexOf(".");
|
|
165
|
-
return n === -1 ? T(t.substring(t.lastIndexOf("/") + 1)) : t.substring(0, n);
|
|
166
|
-
}, et = (t) => {
|
|
167
|
-
if (!t) return "";
|
|
168
|
-
const n = t.lastIndexOf(".");
|
|
169
|
-
return t.substring(n + 1);
|
|
170
|
-
}, kt = {
|
|
171
|
-
randomString: x,
|
|
172
|
-
printStr: z,
|
|
173
|
-
downloadFile: W,
|
|
174
|
-
createIntersectionObserver: K,
|
|
175
|
-
checkDeviceIsMobile: Y,
|
|
176
|
-
checkStatusCode: H,
|
|
177
|
-
formatSecondes: q,
|
|
178
|
-
quickSort: M,
|
|
179
|
-
formatFileSize: V,
|
|
180
|
-
calculateAspectRatio: J,
|
|
181
|
-
getURLSearchParams: Z,
|
|
182
|
-
singleton: G,
|
|
183
|
-
safeCapitalizeWord: Q,
|
|
184
|
-
deepCopy: I,
|
|
185
|
-
getImageSIze: _,
|
|
186
|
-
getPointDistance: X,
|
|
187
|
-
copy2Clipboard: tt,
|
|
188
|
-
getFileName: T,
|
|
189
|
-
getFileSuffix: et
|
|
190
|
-
};
|
|
191
|
-
let y = 1;
|
|
192
|
-
const h = [], Nt = (t, n, e) => (h.length === 0 && (y = 1), nt(n.instancesKey || "", t, {
|
|
193
|
-
id: `${e}-${y++}`,
|
|
194
|
-
key: n.instancesKey || "",
|
|
195
|
-
reactNode: t,
|
|
196
|
-
props: n,
|
|
197
|
-
offsetOptions: {
|
|
198
|
-
topOffset: 0,
|
|
199
|
-
height: 0,
|
|
200
|
-
bottomOffset: 0
|
|
201
|
-
}
|
|
202
|
-
}), h), vt = (t) => {
|
|
203
|
-
const n = h.findIndex((e) => e.id === t);
|
|
204
|
-
n !== -1 && h.splice(n, 1);
|
|
205
|
-
}, Ot = (t, n) => {
|
|
206
|
-
const e = h.findIndex((s) => s.id === t);
|
|
207
|
-
e < 0 || (h[e].offsetOptions = n);
|
|
208
|
-
}, Bt = (t) => {
|
|
209
|
-
const n = h.findIndex((e) => e.id === t);
|
|
210
|
-
return n <= 0 ? 0 : h[n - 1].offsetOptions.topOffset;
|
|
211
|
-
}, Dt = (t) => {
|
|
212
|
-
const n = h.findIndex((e) => e.id === t);
|
|
213
|
-
return n <= 0 ? 0 : h[n - 1].offsetOptions.bottomOffset;
|
|
214
|
-
}, nt = (t, n, e) => {
|
|
215
|
-
const s = (i) => R(
|
|
216
|
-
n,
|
|
217
|
-
{
|
|
218
|
-
zIndex: 999 + y - 1,
|
|
219
|
-
...i.props,
|
|
220
|
-
id: i.id
|
|
221
|
-
},
|
|
222
|
-
i.id,
|
|
223
|
-
"ono-message-root"
|
|
224
|
-
);
|
|
225
|
-
if (!t) {
|
|
226
|
-
const i = s(e);
|
|
227
|
-
h.push({
|
|
228
|
-
...e,
|
|
229
|
-
props: { ...e.props, id: e.id, destroy: i },
|
|
230
|
-
destroy: i
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
let r = !1;
|
|
234
|
-
const o = h.map((i) => {
|
|
235
|
-
if (i.key === t) {
|
|
236
|
-
r = !0;
|
|
237
|
-
const a = { ...i.props, ...e.props };
|
|
238
|
-
return { ...i, props: a };
|
|
239
|
-
} else {
|
|
240
|
-
const a = s(i);
|
|
241
|
-
return {
|
|
242
|
-
...i,
|
|
243
|
-
props: { ...i.props, id: i.id, destroy: a },
|
|
244
|
-
destroy: a
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
if (Object.assign(h, o), !r) {
|
|
249
|
-
const i = s(e);
|
|
250
|
-
h.push({
|
|
251
|
-
...e,
|
|
252
|
-
props: { ...e.props, id: e.id, destroy: i },
|
|
253
|
-
destroy: i
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}, Pt = (t) => {
|
|
257
|
-
var n;
|
|
258
|
-
return t ? (n = h.find((e) => e.key === t)) == null ? void 0 : n.props : null;
|
|
259
|
-
}, m = /\d+/g, rt = () => "#" + Math.random().toString(16).slice(2, 8).padEnd(6, "0"), p = (t) => {
|
|
260
|
-
const n = t.match(m), e = (o) => Number(o).toString(16).padStart(2, "0"), s = (o) => o.reduce((i, a) => i + e(a), "#"), r = (o) => {
|
|
261
|
-
const i = o, a = Number(o[o.length - 1]) !== 1 ? Number(o[o.length - 1]) : 100;
|
|
262
|
-
return i.pop(), s(i) + e(a * 2.56);
|
|
263
|
-
};
|
|
264
|
-
if (n.length === 3) return s(n);
|
|
265
|
-
if (n.length === 5) {
|
|
266
|
-
const o = [
|
|
267
|
-
n[0],
|
|
268
|
-
n[1],
|
|
269
|
-
n[2],
|
|
270
|
-
Number(n[n.length - 1]) * 10
|
|
271
|
-
];
|
|
272
|
-
return r(o);
|
|
273
|
-
}
|
|
274
|
-
return r(n);
|
|
275
|
-
}, $ = (t) => {
|
|
276
|
-
const n = t.split("#")[1], e = (s) => {
|
|
277
|
-
const r = parseInt(s.slice(0, 2), 16), o = parseInt(s.slice(2, 4), 16), i = parseInt(s.slice(4, 6), 16);
|
|
278
|
-
return [r, o, i];
|
|
279
|
-
};
|
|
280
|
-
if (n.length === 8) {
|
|
281
|
-
const s = parseInt(n.slice(-2), 16) / 256, r = n.slice(0, -2), o = e(r);
|
|
282
|
-
return o.push(s), "rgba(" + o.join(", ") + ")";
|
|
283
|
-
}
|
|
284
|
-
return "rgb(" + e(n).join(", ") + ")";
|
|
285
|
-
}, st = (t, n) => {
|
|
286
|
-
if (!n) return t;
|
|
287
|
-
if (t.includes("rgba")) {
|
|
288
|
-
const e = t.split(",");
|
|
289
|
-
return e.pop(), e.push(n + ")"), e.join(",");
|
|
290
|
-
}
|
|
291
|
-
if (t.includes("rgb")) {
|
|
292
|
-
const e = t.split(","), s = "rgba(" + e[0].split("(")[1], r = e[e.length - 1].split(")")[0];
|
|
293
|
-
return [s, e[1], r, " " + n + ")"].join(",");
|
|
294
|
-
}
|
|
295
|
-
}, w = (t) => {
|
|
296
|
-
const n = t.match(m), e = Number(n[0]) / 255, s = Number(n[1]) / 255, r = Number(n[2]) / 255, o = Math.min(e, s, r), i = Math.max(e, s, r);
|
|
297
|
-
let a = 0, l = 0, u = (i + o) / 2;
|
|
298
|
-
if (i === o) a = l = 0;
|
|
299
|
-
else {
|
|
300
|
-
const c = i - o;
|
|
301
|
-
switch (l = u > 0.5 ? c / (2 - i - o) : c / (i + o), i) {
|
|
302
|
-
case e:
|
|
303
|
-
a = (s - r) / c + (s < r ? 6 : 0);
|
|
304
|
-
break;
|
|
305
|
-
case s:
|
|
306
|
-
a = (r - e) / c + 2;
|
|
307
|
-
break;
|
|
308
|
-
case r:
|
|
309
|
-
a = (e - s) / c + 4;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
a /= 6;
|
|
313
|
-
}
|
|
314
|
-
return `hsl(${Math.round(a * 360)}, ${Math.round(l * 100)}%, ${Math.round(u * 100)}%)`;
|
|
315
|
-
}, C = (t) => {
|
|
316
|
-
const n = t.match(m), e = Number(n[0]) / 360, s = Number(n[1]) / 100, r = Number(n[2]) / 100;
|
|
317
|
-
let o, i, a;
|
|
318
|
-
function l(g, d, f) {
|
|
319
|
-
return f < 0 && (f += 1), f > 1 && (f -= 1), f < 1 / 6 ? g + (d - g) * 6 * f : f < 1 / 2 ? d : f < 2 / 3 ? g + (d - g) * (2 / 3 - f) * 6 : g;
|
|
320
|
-
}
|
|
321
|
-
let u = r < 0.5 ? r * (1 + s) : r + s - r * s, c = 2 * r - u;
|
|
322
|
-
return o = l(c, u, e + 1 / 3), i = l(c, u, e), a = l(c, u, e - 1 / 3), `rgb(${Math.round(o * 255)}, ${Math.round(i * 255)}, ${Math.round(a * 255)})`;
|
|
323
|
-
}, k = (t) => w($(t)), N = (t) => p(C(t)), v = (t) => {
|
|
324
|
-
const n = t.match(m);
|
|
325
|
-
let e = Number(n[0]) / 255, s = Number(n[1]) / 255, r = Number(n[2]) / 255;
|
|
326
|
-
const o = Math.max(e, s, r), i = Math.min(e, s, r);
|
|
327
|
-
let a = 0, l = 0, u = o;
|
|
328
|
-
const c = o - i;
|
|
329
|
-
if (l = o === 0 ? 0 : c / o, o === i)
|
|
330
|
-
a = 0;
|
|
331
|
-
else {
|
|
332
|
-
switch (o) {
|
|
333
|
-
case e:
|
|
334
|
-
a = (s - r) / c + (s < r ? 6 : 0);
|
|
335
|
-
break;
|
|
336
|
-
case s:
|
|
337
|
-
a = (r - e) / c + 2;
|
|
338
|
-
break;
|
|
339
|
-
case r:
|
|
340
|
-
a = (e - s) / c + 4;
|
|
341
|
-
break;
|
|
342
|
-
}
|
|
343
|
-
a /= 6;
|
|
344
|
-
}
|
|
345
|
-
return `hsv(${a * 360}, ${l * 100}, ${u * 100})`;
|
|
346
|
-
}, O = (t) => {
|
|
347
|
-
const n = t.match(m);
|
|
348
|
-
let e = Number(n[0]) / 360, s = Number(n[1]) / 100, r = Number(n[2]) / 100, o, i, a, l, u, c, g, d;
|
|
349
|
-
if (e && s === 0)
|
|
350
|
-
o = i = a = r;
|
|
351
|
-
else
|
|
352
|
-
switch (e /= 60, l = Math.floor(e), u = e - l, c = r * (1 - s), g = r * (1 - s * u), d = r * (1 - s * (1 - u)), l) {
|
|
353
|
-
case 0:
|
|
354
|
-
o = r, i = d, a = c;
|
|
355
|
-
break;
|
|
356
|
-
case 1:
|
|
357
|
-
o = g, i = r, a = c;
|
|
358
|
-
break;
|
|
359
|
-
case 2:
|
|
360
|
-
o = c, i = r, a = d;
|
|
361
|
-
break;
|
|
362
|
-
case 3:
|
|
363
|
-
o = c, i = g, a = r;
|
|
364
|
-
break;
|
|
365
|
-
case 4:
|
|
366
|
-
o = d, i = c, a = r;
|
|
367
|
-
break;
|
|
368
|
-
default:
|
|
369
|
-
o = r, i = c, a = g;
|
|
370
|
-
}
|
|
371
|
-
return `rgb(${Math.round(o * 255)}, ${Math.round(i * 255)}, ${Math.round(a * 255)})`;
|
|
372
|
-
}, ot = (t) => v($(t)), it = (t) => p(O(t)), at = (t, n, e = "rgba") => {
|
|
373
|
-
const s = t.match(m);
|
|
374
|
-
let r = Number(s[0]) / 255, o = Number(s[1]) / 255, i = Number(s[2]) / 255;
|
|
375
|
-
return e === "rgba" ? `rgba(${r},${o},${i},${n})` : e === "rgb" ? t : e === "hex" ? p(t) : e === "hsl" ? w(`rgba(${r},${o},${i},${n})`) : `rgba(${r},${o},${i},${n})`;
|
|
376
|
-
}, ct = (t) => {
|
|
377
|
-
const n = /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/, e = /^rgb\((1?\d{1,3},\s*1?\d{1,3},\s*1?\d{1,3})\)$/;
|
|
378
|
-
return !!(n.test(t) || e.test(t));
|
|
379
|
-
}, B = (t) => {
|
|
380
|
-
const n = /^#([0-9A-Fa-f]{6}|[0-9A-Fa-f]{3})$/, e = /^rgb\((1?\d{1,3},\s*1?\d{1,3},\s*1?\d{1,3})\)$/;
|
|
381
|
-
return n.test(t) ? "hex" : e.test(t) ? "rgb" : "unknown";
|
|
382
|
-
}, lt = (t, n, e) => {
|
|
383
|
-
const s = B(t);
|
|
384
|
-
if (s === "hex") {
|
|
385
|
-
const r = t.replace("#", ""), o = parseInt(r.slice(0, 2), 16), i = parseInt(r.slice(2, 4), 16), a = parseInt(r.slice(4, 6), 16);
|
|
386
|
-
if (n === "lighten") {
|
|
387
|
-
const l = Math.min(255, Math.max(0, o + (255 - o) * e / 100)), u = Math.min(255, Math.max(0, i + (255 - i) * e / 100)), c = Math.min(255, Math.max(0, a + (255 - a) * e / 100));
|
|
388
|
-
return `#${l.toString(16).padStart(2, "0")}${u.toString(16).padStart(2, "0")}${c.toString(16).padStart(2, "0")}`;
|
|
389
|
-
} else if (n === "darken") {
|
|
390
|
-
const l = Math.min(255, Math.max(0, o - o * e / 100)), u = Math.min(255, Math.max(0, i - i * e / 100)), c = Math.min(255, Math.max(0, a - a * e / 100));
|
|
391
|
-
return `#${l.toString(16).padStart(2, "0")}${u.toString(16).padStart(2, "0")}${c.toString(16).padStart(2, "0")}`;
|
|
392
|
-
}
|
|
393
|
-
} else if (s === "rgb") {
|
|
394
|
-
const r = t.match(/\d+/g), o = parseInt(r[0]), i = parseInt(r[1]), a = parseInt(r[2]);
|
|
395
|
-
if (n === "lighten") {
|
|
396
|
-
const l = Math.min(255, Math.max(0, o + (255 - o) * e / 100)), u = Math.min(255, Math.max(0, i + (255 - i) * e / 100)), c = Math.min(255, Math.max(0, a + (255 - a) * e / 100));
|
|
397
|
-
return `rgb(${l},${u},${c})`;
|
|
398
|
-
} else if (n === "darken") {
|
|
399
|
-
const l = Math.min(255, Math.max(0, o - o * e / 100)), u = Math.min(255, Math.max(0, i - i * e / 100)), c = Math.min(255, Math.max(0, a - a * e / 100));
|
|
400
|
-
return `rgb(${l},${u},${c})`;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
return t;
|
|
404
|
-
}, ut = (t) => {
|
|
405
|
-
const n = t.replace("#", "").split("");
|
|
406
|
-
return `#${n[0] + n[0] + n[1] + n[1] + n[2] + n[2]}`;
|
|
407
|
-
}, ht = (t) => {
|
|
408
|
-
function n(a) {
|
|
409
|
-
if (a.startsWith("#")) {
|
|
410
|
-
a.length === 4 && (a = `#${a.slice(1).repeat(2)}`);
|
|
411
|
-
const l = parseInt(a.substr(1, 2), 16), u = parseInt(a.substr(3, 2), 16), c = parseInt(a.substr(5, 2), 16);
|
|
412
|
-
return [l, u, c];
|
|
413
|
-
} else if (a.startsWith("rgb")) {
|
|
414
|
-
const l = a.match(/\d+/g), u = parseInt(l[0]), c = parseInt(l[1]), g = parseInt(l[2]);
|
|
415
|
-
return [u, c, g];
|
|
416
|
-
}
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
const e = (a) => (a[0] * 299 + a[1] * 587 + a[2] * 114) / 1e3, s = (a) => a > 128 ? "#000" : "#fff", r = n(t);
|
|
420
|
-
if (r === null)
|
|
421
|
-
return null;
|
|
422
|
-
const o = e(r);
|
|
423
|
-
return s(o);
|
|
424
|
-
}, gt = (t, n, e) => {
|
|
425
|
-
let s = [];
|
|
426
|
-
if (t.includes("#")) s = k(t).match(m);
|
|
427
|
-
else if (t.includes("rgb")) s = w(t).match(m);
|
|
428
|
-
else if (t.includes("hsl")) s = t.match(m);
|
|
429
|
-
else throw new Error("颜色格式错误");
|
|
430
|
-
const r = () => n === "light" ? Number(s[2]) + e > 100 ? 100 : Number(s[2]) + e : Number(s[2]) - e < 0 ? 0 : Number(s[2]) - e;
|
|
431
|
-
return N(
|
|
432
|
-
`${s[0]}, ${s[1]}%, ${r()}%`
|
|
433
|
-
);
|
|
434
|
-
}, Ft = { randomColor: rt, rgb2hex: p, hex2rgb: $, rgb2rgba: st, rgb2hsl: w, hsl2rgb: C, hex2hsl: k, hsl2hex: N, rgb2hsv: v, hsv2rgb: O, hex2hsv: ot, hsv2hex: it, formatColor: at, getContrastColor: ht, adjustColor: lt, isValidColor: ct, getColorType: B, hex3To6: ut, adjustingColors: gt }, jt = (t) => {
|
|
435
|
-
const n = t.split(","), e = n[0].match(/:(.*?);/)[1], s = atob(n[1]);
|
|
436
|
-
let r = s.length;
|
|
437
|
-
const o = new Uint8Array(r);
|
|
438
|
-
for (; r--; ) o[r] = s.charCodeAt(r);
|
|
439
|
-
return new Blob([o], { type: e });
|
|
440
|
-
}, Rt = (t, n) => {
|
|
441
|
-
const e = t.split(","), s = e[0].match(/:(.*?);/u)[1], r = atob(e[1]);
|
|
442
|
-
let o = r.length, i = s.split("/")[1] === "jpeg" ? ".jpg" : "." + s.split("/")[1];
|
|
443
|
-
const a = new Uint8Array(o);
|
|
444
|
-
for (; o--; ) a[o] = r.charCodeAt(o);
|
|
445
|
-
const l = new Blob([a], { type: s });
|
|
446
|
-
return new File([l], n + i, {
|
|
447
|
-
type: s,
|
|
448
|
-
lastModified: (/* @__PURE__ */ new Date()).getTime()
|
|
449
|
-
});
|
|
450
|
-
}, ft = (t) => new Promise((n) => {
|
|
451
|
-
const e = new FileReader();
|
|
452
|
-
e.readAsDataURL(t), e.onload = (s) => {
|
|
453
|
-
var i;
|
|
454
|
-
const o = ((i = s.target) == null ? void 0 : i.result).split(",")[1];
|
|
455
|
-
n(o);
|
|
456
|
-
};
|
|
457
|
-
}), dt = (t, n = "abc.jpg") => new File([t], n, { type: t.type }), Et = (t) => new Promise((n) => {
|
|
458
|
-
const e = new FileReader();
|
|
459
|
-
e.readAsDataURL(t), e.onload = (s) => {
|
|
460
|
-
var r;
|
|
461
|
-
return n((r = s.target) == null ? void 0 : r.result);
|
|
462
|
-
};
|
|
463
|
-
}), Ut = (t) => t.slice(0, t.size, t.type), D = async (t) => await (await fetch(t)).blob(), Lt = async (t) => dt(await D(t)), zt = async (t) => await ft(await D(t)), b = (t) => t < 10 ? `0${t}` : `${t}`, P = (t) => t.toString().length > 13 ? new Date(Number(t.toString().substring(0, 13))) : t.toString().length === 13 ? new Date(t) : t.toString().length < 13 && t.toString().length > 10 ? new Date(Number((t.toString() + "000").substring(0, 13))) : t.toString().length === 10 ? new Date(t * 1e3) : new Date(
|
|
464
|
-
Number((t.toString() + "000000000000").substring(0, 13))
|
|
465
|
-
), bt = (t, n) => {
|
|
466
|
-
const e = {
|
|
467
|
-
en: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
|
|
468
|
-
cn: ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"]
|
|
469
|
-
};
|
|
470
|
-
return t.split("").map((s) => e[n][Number(s)]).join("");
|
|
471
|
-
}, mt = (t, n) => ({
|
|
472
|
-
en: [
|
|
473
|
-
"Jan",
|
|
474
|
-
"Feb",
|
|
475
|
-
"Mar",
|
|
476
|
-
"Apr",
|
|
477
|
-
"May",
|
|
478
|
-
"Jun",
|
|
479
|
-
"Jul",
|
|
480
|
-
"Aug",
|
|
481
|
-
"Sept",
|
|
482
|
-
"Oct",
|
|
483
|
-
"Nov",
|
|
484
|
-
"Dec"
|
|
485
|
-
],
|
|
486
|
-
cn: [
|
|
487
|
-
"一月",
|
|
488
|
-
"二月",
|
|
489
|
-
"三月",
|
|
490
|
-
"四月",
|
|
491
|
-
"五月",
|
|
492
|
-
"六月",
|
|
493
|
-
"七月",
|
|
494
|
-
"八月",
|
|
495
|
-
"九月",
|
|
496
|
-
"十月",
|
|
497
|
-
"十一月",
|
|
498
|
-
"十二月"
|
|
499
|
-
]
|
|
500
|
-
})[n][Number(t) - 1], pt = (t, n) => {
|
|
501
|
-
let e;
|
|
502
|
-
return n === "en" ? t === "01" || t === "21" || t === "31" ? e = Number(t) + "st" : t === "02" || t === "22" ? e = Number(t) + "nd" : t === "03" || t === "23" ? e = Number(t) + "rd" : e = Number(t) + "th" : t === "01" ? e = "一日" : t === "02" ? e = "二日" : t === "03" ? e = "三日" : t === "04" ? e = "四日" : t === "05" ? e = "五日" : t === "06" ? e = "六日" : t === "07" ? e = "七日" : t === "08" ? e = "八日" : t === "09" ? e = "九日" : t === "10" ? e = "十日" : t === "11" ? e = "十一日" : t === "12" ? e = "十二日" : t === "13" ? e = "十三日" : t === "14" ? e = "十四日" : t === "15" ? e = "十五日" : t === "16" ? e = "十六日" : t === "17" ? e = "十七日" : t === "18" ? e = "十八日" : t === "19" ? e = "十九日" : t === "20" ? e = "二十日" : t === "21" ? e = "二十一日" : t === "22" ? e = "二十二日" : t === "23" ? e = "二十三日" : t === "24" ? e = "二十四日" : t === "25" ? e = "二十五日" : t === "26" ? e = "二十六日" : t === "27" ? e = "二十七日" : t === "28" ? e = "二十八日" : t === "29" ? e = "二十九日" : t === "30" ? e = "三十日" : t === "31" && (e = "三十一日"), e ?? t;
|
|
503
|
-
}, Yt = (t, n = "YY-MM-DD hh:mm:ss") => {
|
|
504
|
-
const e = ["YY", "MM", "DD", "hh", "mm", "ss"], s = [], r = P(t);
|
|
505
|
-
s.push(r.getFullYear().toString()), s.push(b(r.getMonth() + 1)), s.push(b(r.getDate())), s.push(b(r.getHours())), s.push(b(r.getMinutes())), s.push(b(r.getSeconds()));
|
|
506
|
-
for (let o in s) n = n.replace(e[o], s[o]);
|
|
507
|
-
return n;
|
|
508
|
-
}, Wt = (t, n = "YY-MM-DD hh:mm:ss", e = "cn") => {
|
|
509
|
-
const s = ["YY", "MM", "DD", "hh", "mm", "ss"], r = [], o = P(t);
|
|
510
|
-
r.push(bt(o.getFullYear().toString(), e)), r.push(mt(b(o.getMonth() + 1), e)), r.push(pt(b(o.getDate()), e)), r.push(b(o.getHours())), r.push(b(o.getMinutes())), r.push(b(o.getSeconds()));
|
|
511
|
-
for (let i in r) n = n.replace(s[i], r[i]);
|
|
512
|
-
return n;
|
|
513
|
-
}, Ht = (t, n) => {
|
|
514
|
-
const e = ["DD", "hh", "mm", "ss"], s = [];
|
|
515
|
-
s.push(Math.floor(t / (3600 * 24))), s.push(b(Math.floor(t % (3600 * 24) / 3600))), s.push(b(Math.floor(t % 3600 / 60))), s.push(b(t % 60));
|
|
516
|
-
for (let r = 0; r < e.length; r++)
|
|
517
|
-
n = n.replace(e[r], s[r].toString());
|
|
518
|
-
return n;
|
|
519
|
-
}, Kt = (t, n) => {
|
|
520
|
-
const e = {
|
|
521
|
-
year: 31536e3,
|
|
522
|
-
month: 2592e3,
|
|
523
|
-
day: 86400,
|
|
524
|
-
hour: 3600,
|
|
525
|
-
minute: 60,
|
|
526
|
-
second: 1
|
|
527
|
-
};
|
|
528
|
-
if (!e[n])
|
|
529
|
-
throw new Error(
|
|
530
|
-
'Invalid type. Please use "day", "hour", "minute", or "second".'
|
|
531
|
-
);
|
|
532
|
-
return Math.floor(t / e[n]);
|
|
533
|
-
};
|
|
534
|
-
export {
|
|
535
|
-
q as A,
|
|
536
|
-
Yt as B,
|
|
537
|
-
yt as C,
|
|
538
|
-
T as D,
|
|
539
|
-
et as E,
|
|
540
|
-
_ as F,
|
|
541
|
-
X as G,
|
|
542
|
-
Z as H,
|
|
543
|
-
It as I,
|
|
544
|
-
Wt as J,
|
|
545
|
-
$t as K,
|
|
546
|
-
Tt as L,
|
|
547
|
-
Mt as M,
|
|
548
|
-
Ct as N,
|
|
549
|
-
z as O,
|
|
550
|
-
M as P,
|
|
551
|
-
x as Q,
|
|
552
|
-
Q as R,
|
|
553
|
-
Ht as S,
|
|
554
|
-
G as T,
|
|
555
|
-
zt as U,
|
|
556
|
-
D as V,
|
|
557
|
-
Lt as W,
|
|
558
|
-
xt as X,
|
|
559
|
-
Pt as a,
|
|
560
|
-
Ot as b,
|
|
561
|
-
Nt as c,
|
|
562
|
-
Dt as d,
|
|
563
|
-
vt as e,
|
|
564
|
-
gt as f,
|
|
565
|
-
Bt as g,
|
|
566
|
-
St as h,
|
|
567
|
-
jt as i,
|
|
568
|
-
Rt as j,
|
|
569
|
-
ft as k,
|
|
570
|
-
dt as l,
|
|
571
|
-
J as m,
|
|
572
|
-
Y as n,
|
|
573
|
-
H as o,
|
|
574
|
-
At as p,
|
|
575
|
-
Ft as q,
|
|
576
|
-
kt as r,
|
|
577
|
-
Kt as s,
|
|
578
|
-
tt as t,
|
|
579
|
-
K as u,
|
|
580
|
-
I as v,
|
|
581
|
-
W as w,
|
|
582
|
-
Et as x,
|
|
583
|
-
Ut as y,
|
|
584
|
-
V as z
|
|
585
|
-
};
|