ono-react-element 0.0.17 → 0.0.18
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-eb1CVc8b.js +30 -1
- package/dist/es/AvatarCrop-DrA-SARP.js +65 -1
- package/dist/es/Button-BsWI818a.js +29 -1
- package/dist/es/Card3D-DMvCSUhe.js +18 -1
- package/dist/es/Checkbox-daBabj14.js +19 -1
- package/dist/es/InjunctiveBox-DUNoNHCO.js +11 -1
- package/dist/es/Input-DLOeg2pz.js +80 -1
- package/dist/es/List-UAKCMuGC.js +19 -1
- package/dist/es/MenuButton-DHkU5Bq7.js +17 -1
- package/dist/es/Message-BGDILiLc.js +105 -1
- package/dist/es/Modal-BsI-8rap.js +37 -1
- package/dist/es/Pagination-m71H2tfS.js +17 -1
- package/dist/es/PortalRenderer-CDAzQJgm.js +19 -1
- package/dist/es/Radio-D_GKVoOC.js +25 -1
- package/dist/es/ScrollableTabs--449B73p.js +34 -1
- package/dist/es/Select-B11NvK-I.js +34 -1
- package/dist/es/SvgImg-CZwq2D7J.js +14 -1
- package/dist/es/Switch-BBHMaxoZ.js +34 -1
- package/dist/es/TemplateDialog-PQxjmAJa.js +45 -1
- package/dist/es/Toast-CQEsbqUJ.js +42 -1
- package/dist/es/Tooltip-CgttMIcX.js +29 -1
- package/dist/es/VirtualList-CdhqyHFQ.js +60 -1
- package/dist/es/Waterfall-CY3QkL5m.js +50 -1
- package/dist/es/colorUtils.ts-DYuRvCXZ.js +145 -1
- package/dist/es/common.ts-vX9A6Rye.js +154 -1
- package/dist/es/dependencies-CbQbPZZ-.js +15524 -1
- package/dist/es/event-CtX9rswE.js +28 -1
- package/dist/es/fileFormatConversion.ts-tUlewYon.js +38 -1
- package/dist/es/formatTimeUtils.ts-CkdWJ_Sl.js +32 -1
- package/dist/es/index.js +123 -1
- package/dist/es/useClickOutSide.tsx-CMvd2uTW.js +15 -1
- package/dist/es/useCountdown.tsx-Btzj-keH.js +16 -1
- package/dist/es/useEventListener.tsx-BBGVcI5T.js +12 -1
- package/dist/es/useGetElementSize.tsx-Dtshth0Y.js +22 -1
- package/dist/es/useKeyPress.tsx-Db44HXXz.js +18 -1
- package/dist/es/useMouseClick.tsx-C7uAH4n4.js +12 -1
- package/dist/es/useTheme.tsx-C5b7BRYz.js +24 -1
- package/dist/es/useThemePro.tsx-DQuSI8J7.js +20 -1
- package/dist/es/viewTransitionUtils.ts-CHa9uBpi.js +19 -1
- package/package.json +1 -1
|
@@ -1 +1,25 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { useState as r, useRef as o, useEffect as a } from "react";
|
|
3
|
+
const n = ({ name: n2, value: l2, style: c, checked: d, onChange: s, children: t, className: i, radioW: u = 16, radioGap: h = 4, checkedColor: m = "#532ce1", unCheckedColor: p = "transparent", disabled: C = false }) => {
|
|
4
|
+
const [v, k] = r(""), f = o(null), y = o(null), b = o(null), j = [{ value: u, name: "w" }, { value: h, name: "gap" }, { value: m, name: "checkedColor" }, { value: p, name: "unCheckedColor" }];
|
|
5
|
+
return a(() => {
|
|
6
|
+
(() => {
|
|
7
|
+
if (!b.current || !y.current) return;
|
|
8
|
+
j.forEach(({ value: e3, name: r2 }) => {
|
|
9
|
+
e3 && ((e4, r3, o2) => {
|
|
10
|
+
const a2 = "number" == typeof e4;
|
|
11
|
+
o2.style.setProperty(`--${r3}`, a2 ? `${e4}px` : e4);
|
|
12
|
+
})(e3, r2, y.current);
|
|
13
|
+
});
|
|
14
|
+
const e2 = getComputedStyle(b.current);
|
|
15
|
+
v || k(e2.borderColor), b.current.style.borderColor = d ? m : v;
|
|
16
|
+
})();
|
|
17
|
+
}, [y, b, d, v]), e.jsxs("div", { ref: y, className: ["ono-radio-box", i].join(" "), style: c, children: [e.jsx("div", { ref: b, className: "ono-radio", onClick: () => {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = f.current) == null ? void 0 : _a.click();
|
|
20
|
+
}, children: e.jsx("input", { type: "radio", name: n2, ref: f, value: l2 + "", checked: d, disabled: C, id: l2 + "" + t, onChange: s }) }), t && e.jsx("label", { htmlFor: l2 + "" + t || "", children: t })] });
|
|
21
|
+
}, l = ({ name: r2, style: o2, options: a2, onChange: l2, className: c, radioW: d = 16, radioGap: s = 4, labelPosition: t = "right", checkedColor: i = "#532ce1", unCheckedColor: u = "transparent", value: h }) => e.jsx("div", { className: ["ono-radio-group", c].join(" "), style: o2, children: a2.map(({ label: o3, value: a3, disabled: c2 }) => e.jsx(n, { name: r2, value: a3, radioW: d, radioGap: s, style: { flexDirection: "left" === t ? "row-reverse" : "row" }, checkedColor: i, unCheckedColor: u, onChange: () => l2(a3), checked: h + "" == a3 + "", disabled: "function" == typeof c2 ? c2(h) : c2 || false, children: o3 }, o3)) });
|
|
22
|
+
export {
|
|
23
|
+
n as R,
|
|
24
|
+
l as a
|
|
25
|
+
};
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { forwardRef as t, useState as r, useRef as n, useEffect as l } from "react";
|
|
3
|
+
const o = ({ children: t2, disabled: r2, className: n2, style: l2, onClick: o2 }) => e.jsx("li", { className: ["ono-scrollable-tab", n2].filter(Boolean).join(" "), style: l2, onClick: (e2) => !r2 && (o2 == null ? void 0 : o2(e2)), children: t2 }), s = t(({ activeIndex: t2, children: s2, className: c, style: a, position: i = "center", onChange: f }, d) => {
|
|
4
|
+
const [h, u] = r(0), m = n(null);
|
|
5
|
+
return l(() => {
|
|
6
|
+
const e2 = m.current;
|
|
7
|
+
if (!e2 || h < 0) return;
|
|
8
|
+
const r2 = e2.offsetWidth, n2 = Array.from(e2.children);
|
|
9
|
+
if (h >= n2.length) return;
|
|
10
|
+
const l2 = parseInt(((a == null ? void 0 : a.gap) || getComputedStyle(e2).gap || "0").toString(), 10) || 0;
|
|
11
|
+
let o2 = 0;
|
|
12
|
+
switch (n2.slice(0, h + 1).forEach((e3) => o2 += e3.offsetWidth + l2), i) {
|
|
13
|
+
case "start":
|
|
14
|
+
e2.scrollLeft = o2 - n2[h].offsetWidth - l2;
|
|
15
|
+
break;
|
|
16
|
+
case "end":
|
|
17
|
+
e2.scrollLeft = o2 - r2;
|
|
18
|
+
break;
|
|
19
|
+
default:
|
|
20
|
+
o2 -= n2[h].offsetWidth / 2 + (t2 !== n2.length - 1 ? l2 : 0), e2.scrollLeft = o2 - r2 / 2;
|
|
21
|
+
}
|
|
22
|
+
}, [m, s2, t2, i]), l(() => {
|
|
23
|
+
u(t2 || 0);
|
|
24
|
+
}, [t2]), l(() => {
|
|
25
|
+
d && ("function" == typeof d ? d(m.current) : d.current = m.current);
|
|
26
|
+
}, [d]), e.jsx("ul", { ref: m, className: ["ono-scrollable-tabs", c].filter(Boolean).join(" "), style: a, onClick: (e2) => {
|
|
27
|
+
m.current && Array.from(m.current.children).some((t3, r2) => {
|
|
28
|
+
if (t3.contains(e2.target)) return u(r2), f == null ? void 0 : f(r2), true;
|
|
29
|
+
});
|
|
30
|
+
}, children: s2(o) });
|
|
31
|
+
});
|
|
32
|
+
export {
|
|
33
|
+
s as S
|
|
34
|
+
};
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { useState as o, useEffect as n } from "react";
|
|
3
|
+
import { T as t } from "./Tooltip-CgttMIcX.js";
|
|
4
|
+
import { O as l } from "./Input-DLOeg2pz.js";
|
|
5
|
+
import { L as a } from "./List-UAKCMuGC.js";
|
|
6
|
+
const i = ({ label: o2, value: n2, disabled: t2, onChange: l2, selectValue: a2, optionRender: i2, currentValue: s2, onChangeCursor: r2 }) => e.jsx("button", { role: "option", "aria-label": o2, disabled: t2, className: "ono-option-item", onClick: () => l2 == null ? void 0 : l2(n2), onMouseEnter: () => !t2 && (r2 == null ? void 0 : r2(o2)), children: i2 ? i2({ label: o2, value: n2, disabled: t2 }, a2 === o2) : e.jsx("div", { className: ["ono-option-item-content", s2 === o2 && a2 !== o2 ? "ono-option-item-content-active" : "", a2 === o2 ? "ono-option-item-content-selected" : "", t2 ? "ono-option-item-content-disabled" : ""].filter(Boolean).join(" "), children: o2 }) }), s = ({ options: s2, defaultValue: c, placeholder: d, inputBorder: p, isShowArrow: m, disabled: u, clearable: f, selectClassName: h, optionsClassName: b, notFoundContent: j, optionRender: g, onClear: C, onChange: v, filterOption: x }) => {
|
|
7
|
+
const [w, N] = o(""), [L, V] = o(""), [B, S] = o(""), [k, M] = o(false), [O, y] = o(false), [R, A] = o(""), E = (e2) => {
|
|
8
|
+
const o2 = s2.find((o3) => o3.value === e2);
|
|
9
|
+
N(o2 ? o2.label : "");
|
|
10
|
+
}, F = (e2) => {
|
|
11
|
+
v == null ? void 0 : v(e2), A(e2), E(e2);
|
|
12
|
+
};
|
|
13
|
+
return n(() => {
|
|
14
|
+
c && E(c);
|
|
15
|
+
}, [c]), n(() => {
|
|
16
|
+
var _a;
|
|
17
|
+
if (s2.length > 0) {
|
|
18
|
+
if (c) {
|
|
19
|
+
const e2 = s2.find((e3) => e3.value === c);
|
|
20
|
+
e2 && V(e2.label);
|
|
21
|
+
} else e: for (let e2 = 0; e2 < s2.length; e2++) if (true !== ((_a = s2[e2]) == null ? void 0 : _a.disabled)) {
|
|
22
|
+
V(s2[0].label);
|
|
23
|
+
break e;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, [s2, c]), e.jsx(t, { sameWidth: true, trigger: "click", placement: "bottom", isShowArrow: m, className: ["ono-option-container", b].filter(Boolean).join(" "), onOpenChange: (e2) => {
|
|
27
|
+
y(e2), x && B && !e2 && S("");
|
|
28
|
+
}, content: e.jsx(a, { list: x ? "function" == typeof x ? x(B, s2) : s2.filter((e2) => e2.label.toLocaleLowerCase().includes(B.toLocaleLowerCase())) : s2, fallback: e.jsx("div", { className: "ono-option-item", children: e.jsx("div", { className: "ono-option-item-content-no-data", onClick: (e2) => e2.stopPropagation(), children: j ?? "No Data" }) }), children: (o2) => e.jsx(i, { ...o2, onChange: F, selectValue: w.toString(), currentValue: L.toString(), optionRender: g, onChangeCursor: V }, o2.value) }), children: e.jsx("div", { className: "ono-select", onMouseEnter: () => M(true), onMouseLeave: () => M(false), children: e.jsx(l, { className: [x ? "" : "ono-select-readonly", h].filter(Boolean).join(" "), border: p, disabled: u, placeholder: x && R ? w.toString() || "" : d, readonly: !x, value: x && O ? B : w.toString(), clearable: k && f, suffix: k && f && w || f && B && x ? e.jsx(e.Fragment, {}) : e.jsx(r, { isVisible: O }), onClear: () => {
|
|
29
|
+
C == null ? void 0 : C(), v == null ? void 0 : v(""), A(""), N(""), S("");
|
|
30
|
+
}, onChange: (e2) => S(e2.target.value) }) }) });
|
|
31
|
+
}, r = ({ isVisible: o2 }) => e.jsx("svg", { className: ["ono-select-arrow-down-icon", o2 ? "ono-select-arrow-down-active" : ""].filter(Boolean).join(" "), viewBox: "64 64 896 896", focusable: "false", "data-icon": "down", fill: "currentColor", "aria-hidden": "true", children: e.jsx("path", { d: "M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z" }) });
|
|
32
|
+
export {
|
|
33
|
+
s as O
|
|
34
|
+
};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { useRef as r, useEffect as s } from "react";
|
|
3
|
+
const a = ({ w: a2, h: n, src: t, clr: l, className: c, onClick: o }) => {
|
|
4
|
+
const m = r(null), i = [{ value: a2, name: "w" }, { value: n, name: "h" }, { value: l, name: "clr" }];
|
|
5
|
+
return s(() => {
|
|
6
|
+
m.current && i.forEach((e2) => {
|
|
7
|
+
var r2, s2, a3;
|
|
8
|
+
e2.value && (r2 = e2.value, s2 = e2.name, a3 = m.current, "string" == typeof r2 ? a3.style.setProperty(`--${s2}`, r2) : a3.style.setProperty(`--${s2}`, `${r2}px`));
|
|
9
|
+
});
|
|
10
|
+
}, [m, l]), e.jsx("div", { ref: m, className: ["ono-svg-img", c].join(" "), onClick: o, children: e.jsx("img", { src: t, alt: "" }) });
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
a as S
|
|
14
|
+
};
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { p as n } from "./common.ts-vX9A6Rye.js";
|
|
3
|
+
import { useRef as r, useEffect as c } from "react";
|
|
4
|
+
const t = ({ id: t2, text: i, style: s, color: l, checked: o, onChange: a, name: d = "", className: h, disabled: u = false }) => {
|
|
5
|
+
const m = r(null), f = r(null), v = r(null), p = r(null), j = r(null), x = r(null), w = [{ value: "string" == typeof l ? l : l == null ? void 0 : l.active, name: "checkedClr" }, { value: "string" == typeof l ? void 0 : l == null ? void 0 : l.inactive, name: "uncheckedClr" }];
|
|
6
|
+
return c(() => {
|
|
7
|
+
(() => {
|
|
8
|
+
if (!f.current || !m.current) return;
|
|
9
|
+
let e2 = 60, r2 = 32;
|
|
10
|
+
if (h || s) {
|
|
11
|
+
const c2 = getComputedStyle(f.current);
|
|
12
|
+
e2 = n(c2.width), r2 = n(c2.height);
|
|
13
|
+
}
|
|
14
|
+
[...w, { value: e2, name: "w" }, { value: r2, name: "h" }].forEach(({ value: e3, name: n2 }) => {
|
|
15
|
+
e3 && ((e4, n3, r3) => {
|
|
16
|
+
const c2 = "number" == typeof e4;
|
|
17
|
+
r3.style.setProperty(`--${n3}`, c2 ? `${e4}px` : e4);
|
|
18
|
+
})(e3, n2, m.current);
|
|
19
|
+
}), requestAnimationFrame(() => {
|
|
20
|
+
p.current && (p.current.style.transition = "transform 0.3s");
|
|
21
|
+
});
|
|
22
|
+
})();
|
|
23
|
+
}, [f, m, p, h, s, l, i, j, x]), c(() => {
|
|
24
|
+
v.current && (v.current.checked = o);
|
|
25
|
+
}, [v, o]), e.jsxs("div", { ref: m, className: ["ono-switch", u ? "ono-switch-is-disabled" : ""].filter(Boolean).join(" "), children: [e.jsx("input", { id: t2, name: d, role: "switch", ref: v, type: "checkbox", checked: o, onChange: (e2) => {
|
|
26
|
+
u || (a == null ? void 0 : a(e2.currentTarget.checked, e2));
|
|
27
|
+
} }), e.jsx("div", { ref: f, className: ["ono-switch-box", h || ""].filter(Boolean).join(" "), style: s, onClick: () => {
|
|
28
|
+
var _a;
|
|
29
|
+
return (_a = v.current) == null ? void 0 : _a.click();
|
|
30
|
+
}, children: e.jsxs("div", { ref: p, className: "ono-switch-children-bar", children: [(i == null ? void 0 : i.active) && e.jsx("div", { ref: j, className: "ono-switch-children", children: i == null ? void 0 : i.active }), e.jsx("div", { className: "ono-switch-slider" }), (i == null ? void 0 : i.inactive) && e.jsx("div", { ref: x, className: "ono-switch-children", children: i == null ? void 0 : i.inactive })] }) })] });
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
t as S
|
|
34
|
+
};
|
|
@@ -1 +1,45 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { g as t } from "./common.ts-vX9A6Rye.js";
|
|
3
|
+
import { useState as o, useRef as n, useEffect as r, useCallback as s } from "react";
|
|
4
|
+
const i = ({ children: i2, animation: a, className: l, duration: c = 300, style: d, maskColor: m = "rgba(0, 0, 0, 0.5)", disableContextMenu: p, maskClickClose: u = true, dialogClose: y }) => {
|
|
5
|
+
const [f, k] = o(false), g = n(null), x = () => {
|
|
6
|
+
if (g.current) if (k(true), a) {
|
|
7
|
+
const e2 = g.current;
|
|
8
|
+
e2.classList.remove(`ono-${a.type}-enter`), e2.classList.add(`ono-${a.type}-leave`), setTimeout(y, c);
|
|
9
|
+
} else y();
|
|
10
|
+
};
|
|
11
|
+
r(() => {
|
|
12
|
+
(() => {
|
|
13
|
+
if (!a || !g.current) return;
|
|
14
|
+
const e2 = g.current.parentElement.style, o2 = g.current.style;
|
|
15
|
+
switch (e2.setProperty("--duration", c / 1e3 + "s"), a.type) {
|
|
16
|
+
case "zoom": {
|
|
17
|
+
const { x: e3, y: n2 } = t(a.element), r2 = (e3 / window.innerWidth * 100).toFixed(2) + "%", s2 = (n2 / window.innerHeight * 100).toFixed(2) + "%";
|
|
18
|
+
o2.setProperty("--left", r2), o2.setProperty("--top", s2);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
case "fade": {
|
|
22
|
+
const e3 = "left-center" === a.direction ? "--left" : "--top";
|
|
23
|
+
o2.setProperty(e3, a.startPosition);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
}, [g, a]);
|
|
29
|
+
const C = s(() => {
|
|
30
|
+
if (!a) return "";
|
|
31
|
+
const e2 = `ono-${a.type}-enter`, t2 = `ono-${a.type}-leave`;
|
|
32
|
+
return f ? t2 : e2;
|
|
33
|
+
}, [a, f]);
|
|
34
|
+
return e.jsx("div", { className: `
|
|
35
|
+
ono-dialog-mask
|
|
36
|
+
ono-dialog-mask-${f ? "leave" : "enter"}
|
|
37
|
+
`, style: { background: m }, onClick: () => u && x(), onContextMenu: (e2) => p && e2.preventDefault(), children: e.jsx("div", { ref: g, className: `
|
|
38
|
+
ono-dialog
|
|
39
|
+
${l || ""}
|
|
40
|
+
${C()}
|
|
41
|
+
`, style: d, onClick: (e2) => e2.stopPropagation(), children: "function" == typeof i2 ? i2(x) : i2 }) });
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
i as T
|
|
45
|
+
};
|
|
@@ -1 +1,42 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { useEffect as s, useRef as t } from "react";
|
|
3
|
+
import { i } from "./InjunctiveBox-DUNoNHCO.js";
|
|
4
|
+
const a = "_enter_974ly_32";
|
|
5
|
+
let r = [];
|
|
6
|
+
const c = { success: { light: "#52c41a", dark: "#49aa19" }, error: { light: "#ff4d4f", dark: "#a61d24" }, warning: { light: "#faad14", dark: "#d89614" }, promise: { light: "", dark: "" } }, o = (e2, s2) => c[e2][s2], n = (s2) => {
|
|
7
|
+
switch (s2) {
|
|
8
|
+
case "success":
|
|
9
|
+
return e.jsx("svg", { viewBox: "0 0 1024 1024", focusable: "false", "data-icon": "check-circle", width: "24px", height: "24px", fill: o(s2, "light"), "aria-hidden": "true", children: e.jsx("path", { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" }) });
|
|
10
|
+
case "error":
|
|
11
|
+
return e.jsx("svg", { viewBox: "0 0 1024 1024", focusable: "false", "data-icon": "close-circle", width: "24px", height: "24px", fill: o(s2, "light"), "aria-hidden": "true", children: e.jsx("path", { d: "M512 64c247.4 0 448 200.6 448 448S759.4 960 512 960 64 759.4 64 512 264.6 64 512 64zm127.98 274.82h-.04l-.08.06L512 466.75 384.14 338.88c-.04-.05-.06-.06-.08-.06a.12.12 0 00-.07 0c-.03 0-.05.01-.09.05l-45.02 45.02a.2.2 0 00-.05.09.12.12 0 000 .07v.02a.27.27 0 00.06.06L466.75 512 338.88 639.86c-.05.04-.06.06-.06.08a.12.12 0 000 .07c0 .03.01.05.05.09l45.02 45.02a.2.2 0 00.09.05.12.12 0 00.07 0c.02 0 .04-.01.08-.05L512 557.25l127.86 127.87c.04.04.06.05.08.05a.12.12 0 00.07 0c.03 0 .05-.01.09-.05l45.02-45.02a.2.2 0 00.05-.09.12.12 0 000-.07v-.02a.27.27 0 00-.05-.06L557.25 512l127.87-127.86c.04-.04.05-.06.05-.08a.12.12 0 000-.07c0-.03-.01-.05-.05-.09l-45.02-45.02a.2.2 0 00-.09-.05.12.12 0 00-.07 0z" }) });
|
|
12
|
+
case "warning":
|
|
13
|
+
return e.jsx("svg", { viewBox: "0 0 1024 1024", focusable: "false", "data-icon": "exclamation-circle", width: "24px", height: "24px", fill: o(s2, "light"), "aria-hidden": "true", children: e.jsx("path", { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" }) });
|
|
14
|
+
}
|
|
15
|
+
}, l = ({ type: i2, speed: r2 = 200, message: c2, duration: o2 = 2e3, className: l2, style: m2, isUseEnterAnimation: d = true, promiseOptions: h, toastList: u, handleDestroy: g }) => {
|
|
16
|
+
const y = t(null);
|
|
17
|
+
return s(() => {
|
|
18
|
+
y.current && (y.current.style.setProperty("--speed", r2 / 1e3 + "s"), d && y.current.classList.add(a), "promise" !== i2 && setTimeout(() => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
(_a = y.current) == null ? void 0 : _a.classList.remove(a), (_b = y.current) == null ? void 0 : _b.classList.add("_leave_974ly_36");
|
|
21
|
+
}, o2 - r2));
|
|
22
|
+
}, [y]), s(() => {
|
|
23
|
+
"promise" === i2 ? ("function" == typeof c2 ? c2() : c2).then((e2) => setTimeout(() => {
|
|
24
|
+
g(), p({ type: "success", message: "function" == typeof (h == null ? void 0 : h.success) ? h.success(e2) : (h == null ? void 0 : h.success) || "", isUseEnterAnimation: false, toastList: u });
|
|
25
|
+
}, r2)).catch((e2) => setTimeout(() => {
|
|
26
|
+
g(), p({ type: "error", message: "function" == typeof (h == null ? void 0 : h.error) ? h.error(e2) : (h == null ? void 0 : h.error) || "", isUseEnterAnimation: false, toastList: u });
|
|
27
|
+
}, r2)) : setTimeout(() => g(() => u = []), o2);
|
|
28
|
+
}, [i2]), e.jsxs("div", { ref: y, className: ["promise" === i2 ? "_promise_974ly_15" : "_base_974ly_15", l2].join(" "), style: m2, onClick: () => {
|
|
29
|
+
}, children: [e.jsx("div", { className: "_icon_974ly_40", children: n(i2) }), e.jsx("p", { children: "string" == typeof c2 ? c2 : h && h.loading })] });
|
|
30
|
+
}, p = ({ type: t2, speed: a2 = 200, message: r2, duration: c2 = 2e3, zIndex: o2 = 9999, className: n2, style: p2, isUseEnterAnimation: m2 = true, promiseOptions: d, toastList: h }) => i({ className: "_container_974ly_1", isSingle: true, style: { zIndex: o2 }, content: (i2) => (s(() => {
|
|
31
|
+
}, [h]), e.jsx(l, { className: n2, style: p2, type: t2, message: r2, speed: a2, duration: c2, isUseEnterAnimation: m2, promiseOptions: d, handleDestroy: i2, toastList: h })) }), m = { success: (e2) => {
|
|
32
|
+
r.push({ type: "success", message: e2 }), p("string" == typeof e2 ? { type: "success", message: e2, toastList: r } : { type: "success", ...e2, toastList: r });
|
|
33
|
+
}, error: (e2) => {
|
|
34
|
+
r.push({ type: "error", message: e2 }), p("string" == typeof e2 ? { type: "error", message: e2, toastList: r } : { type: "error", ...e2, toastList: r });
|
|
35
|
+
}, warning: (e2) => {
|
|
36
|
+
r.push({ type: "warning", message: e2 }), p("string" == typeof e2 ? { type: "warning", message: e2, toastList: r } : { type: "warning", ...e2, toastList: r });
|
|
37
|
+
}, promise: (e2, s2) => {
|
|
38
|
+
r.push({ type: "promise", message: e2 }), p({ type: "promise", message: e2, promiseOptions: s2, toastList: r });
|
|
39
|
+
} };
|
|
40
|
+
export {
|
|
41
|
+
m as t
|
|
42
|
+
};
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { u as t } from "./useClickOutSide.tsx-CMvd2uTW.js";
|
|
3
|
+
import { createPopper as r } from "@popperjs/core";
|
|
4
|
+
import { useState as n, useRef as o, useEffect as c } from "react";
|
|
5
|
+
let s = null, l = null;
|
|
6
|
+
const i = ({ children: i2, content: p, onOpenChange: u, trigger: a = "hover", placement: m = "top", popperOptions: d = {}, className: f, style: h, isShowArrow: x = true, sameWidth: w, autoAdjustOverflow: j = true }) => {
|
|
7
|
+
const [v, y] = n(false), g = o(null), k = o(null), b = (e2) => {
|
|
8
|
+
u == null ? void 0 : u(e2), y(e2);
|
|
9
|
+
};
|
|
10
|
+
return t(k, () => {
|
|
11
|
+
"click" !== a && "contextmenu" !== a || b(false);
|
|
12
|
+
}, { event: ["click", "contextmenu"], deps: [a, u] }), c(() => {
|
|
13
|
+
(() => {
|
|
14
|
+
if (!k.current) return;
|
|
15
|
+
const e2 = Array.from(k.current.children);
|
|
16
|
+
if (e2.length > 1) throw new Error("Tooltip only support one child");
|
|
17
|
+
k.current.style.width = e2[0].getBoundingClientRect().width + "px";
|
|
18
|
+
})();
|
|
19
|
+
}, [k, i2]), c(() => {
|
|
20
|
+
k.current && ("hover" === a ? (k.current.onmouseenter = () => b(true), k.current.onmouseleave = () => b(false)) : "click" === a ? k.current.onclick = () => b(!v) : "focus" === a ? (k.current.onfocus = () => b(true), k.current.onblur = () => b(false)) : k.current.oncontextmenu = () => b(!v)), v && k.current && g.current ? l = r(k.current, g.current, { placement: m, modifiers: [{ name: "offset", options: { offset: [0, 6] } }, w ? { name: "sameWidth", enabled: true, phase: "beforeWrite", requires: ["computeStyles"], fn({ state: e2 }) {
|
|
21
|
+
e2.styles.popper.width = `${e2.rects.reference.width}px`;
|
|
22
|
+
}, effect({ state: e2 }) {
|
|
23
|
+
e2.elements.popper.style.width = `${e2.elements.reference.offsetWidth}px`;
|
|
24
|
+
} } : {}, j ? { name: "flip", enabled: true } : {}], ...d }) : l && (l.destroy(), l = null, s && s.remove(), s = null);
|
|
25
|
+
}, [v, k, g]), e.jsxs(e.Fragment, { children: [v && e.jsxs("div", { ref: g, style: h, className: ["ono-tooltip-popper", f].join(" "), "data-popper-placement": d.placement || m, children: [e.jsx("div", { children: p instanceof Function ? p() : p }), x && e.jsx("div", { className: "ono-tooltip-popper-arrow", "data-popper-arrow": true })] }), e.jsx("div", { ref: k, children: i2 instanceof Function ? i2() : i2 })] });
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
i as T
|
|
29
|
+
};
|
|
@@ -1 +1,60 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { u as t } from "./useEventListener.tsx-BBGVcI5T.js";
|
|
3
|
+
import { t as r } from "./common.ts-vX9A6Rye.js";
|
|
4
|
+
import { memo as i, useState as n, useMemo as l, useRef as a, useEffect as s } from "react";
|
|
5
|
+
const d = i(({ containerClassName: i2, dataSource: d2, containerStyle: c2 = {}, onEndCallback: o, refreshSpeed: h = 50, wrapperClassName: u, wrapperStyle: p = {}, estimatedSize: f = 35, updateDataSourceScroll2Top: v, direction: g = "vertical" }) => {
|
|
6
|
+
const [m, x] = n({ viewSize: 0, startIndex: 0, listSize: 0, renderCount: 0, prevLen: 0 }), [S, z] = n([]), w = "number" == typeof f ? f : f(), I = l(() => Math.min(d2.length, m.startIndex + m.renderCount), [d2, m]), y = l(() => {
|
|
7
|
+
var _a;
|
|
8
|
+
return m.startIndex > 0 ? (_a = S[m.startIndex - 1]) == null ? void 0 : _a.end : 0;
|
|
9
|
+
}, [m.startIndex, S]), j = l(() => d2.slice(m.startIndex, I).map(({ id: t2, data: r2 }) => e.jsx("li", { "data-virtual-id": t2, style: "vertical" === g ? { width: "100%" } : { height: "100%" }, children: r2 }, t2)), [I, d2, m.startIndex, g]), C = l(() => ({ display: "flex", listStyle: "none", flexDirection: "vertical" === g ? "column" : "row", height: "vertical" === g ? m.listSize - y + "px" : "100%", width: "vertical" === g ? "auto" : m.listSize - y + "px", transform: "vertical" === g ? `translate3d(0, ${y}px, 0)` : `translate3d(${y}px, 0, 0)` }), [m.listSize, y, g]), L = a(null), N = a(null), b = (e2) => x((t2) => ({ ...t2, ...e2 })), E = r(() => {
|
|
10
|
+
const { scrollTop: e2, clientHeight: t2, scrollHeight: r2, scrollLeft: i3, clientWidth: n2, scrollWidth: l2 } = L.current, a2 = "vertical" === g ? r2 - t2 - e2 : l2 - n2 - i3;
|
|
11
|
+
b({ startIndex: A(S, "vertical" === g ? e2 : i3) }), ("vertical" === g ? e2 === w / 2 : i3 === w / 2) && b({ startIndex: 0 }), a2 <= 20 && o && o();
|
|
12
|
+
}, h), A = (e2, t2) => {
|
|
13
|
+
let r2 = 0, i3 = e2.length - 1, n2 = -1;
|
|
14
|
+
for (; r2 <= i3; ) {
|
|
15
|
+
const l2 = r2 + Math.floor((i3 - r2) / 2), a2 = e2[l2].end;
|
|
16
|
+
if (a2 === t2) return l2 + 1;
|
|
17
|
+
a2 < t2 ? r2 = l2 + 1 : ((-1 === n2 || n2 > l2) && (n2 = l2), i3 = l2 - 1);
|
|
18
|
+
}
|
|
19
|
+
return n2;
|
|
20
|
+
};
|
|
21
|
+
return t("scroll", E, { target: L.current, deps: [S, g] }), s(() => {
|
|
22
|
+
(() => {
|
|
23
|
+
if (!L.current) return;
|
|
24
|
+
const e2 = ("vertical" === g ? L.current.offsetHeight : L.current.offsetWidth) || 0;
|
|
25
|
+
b({ viewSize: e2, renderCount: Math.ceil(e2 / w) + 1 });
|
|
26
|
+
})();
|
|
27
|
+
}, [L, g]), s(() => {
|
|
28
|
+
d2.length && N && (() => {
|
|
29
|
+
var _a;
|
|
30
|
+
const e2 = [], t2 = d2.length - m.prevLen, r2 = t2 > 0 ? S.length : 0, i3 = r2 > 0 ? S[r2 - 1].end : 0;
|
|
31
|
+
for (let r3 = 0; r3 < (t2 > 0 ? t2 : d2.length); r3++) {
|
|
32
|
+
const n2 = d2[(t2 > 0 ? m.prevLen : 0) + r3];
|
|
33
|
+
e2.push({ index: n2.id, size: w, start: i3 ? i3 + r3 * w : n2.id * w, end: i3 ? i3 + (r3 + 1) * w : (n2.id + 1) * w, dSize: 0 });
|
|
34
|
+
}
|
|
35
|
+
z((r3) => [...t2 > 0 ? r3 : [], ...e2]), b({ prevLen: d2.length }), v && ((_a = L.current) == null ? void 0 : _a.scrollTo(0, 0));
|
|
36
|
+
})();
|
|
37
|
+
}, [N, d2, v]), s(() => {
|
|
38
|
+
(() => {
|
|
39
|
+
if (!N.current || 0 === S.length) return;
|
|
40
|
+
const e2 = Array.from(N.current.childNodes);
|
|
41
|
+
if (!e2.length) return;
|
|
42
|
+
e2.forEach((e3) => {
|
|
43
|
+
const t3 = e3.getBoundingClientRect(), r3 = +e3.getAttribute("data-virtual-id"), i4 = S[r3], n2 = i4.size - ("vertical" === g ? t3.height : t3.width);
|
|
44
|
+
n2 && (i4.size = "vertical" === g ? t3.height : t3.width, i4.end = i4.end - n2, i4.dSize = n2);
|
|
45
|
+
});
|
|
46
|
+
const t2 = +e2[0].getAttribute("data-virtual-id"), r2 = S.length;
|
|
47
|
+
let i3 = S[t2].dSize;
|
|
48
|
+
S[t2].dSize = 0;
|
|
49
|
+
for (let e3 = t2 + 1; e3 < r2; e3++) {
|
|
50
|
+
const t3 = S[e3];
|
|
51
|
+
t3.start = S[e3 - 1].end, t3.end = t3.end - i3, t3.dSize && (i3 += t3.dSize, t3.dSize = 0);
|
|
52
|
+
}
|
|
53
|
+
b({ listSize: S[r2 - 1].end });
|
|
54
|
+
})();
|
|
55
|
+
}, [N, S, m.startIndex, g]), e.jsx("div", { ref: L, className: i2, style: { width: "100%", height: "100%", overflow: "auto", ...c2 }, children: e.jsx("ul", { ref: N, className: u, style: { ...C, ...p }, children: j }) });
|
|
56
|
+
}), c = (e2, t2) => e2.map((e3, r2) => ({ id: r2, data: t2(e3, r2) }));
|
|
57
|
+
export {
|
|
58
|
+
d as E,
|
|
59
|
+
c
|
|
60
|
+
};
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
import{j as e}from "./dependencies-CbQbPZZ-.js";
|
|
1
|
+
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
+
import { u as t } from "./useEventListener.tsx-BBGVcI5T.js";
|
|
3
|
+
import { t as a } from "./common.ts-vX9A6Rye.js";
|
|
4
|
+
import { useState as i, useRef as n, useCallback as o, useEffect as r } from "react";
|
|
5
|
+
const s = ({ options: s2, pageSize: l, children: d, request: m, reloadData: c, className: g, style: p, updateData: h, loading: u = true, bottomThreshold: f = 50 }) => {
|
|
6
|
+
const [x, y] = i({ page: 1, reloadData: c, loading: false, isFinish: false, gap: "number" == typeof s2 ? 0 : s2.gap, imageWidth: "number" == typeof s2 ? s2 : 0, columns: "number" == typeof s2 ? 0 : s2.columns, imageList: [] }), [w, W] = i([]), [j, b] = i([]), v = n(null), L = n(null), D = n(null), N = (e2) => y((t2) => ({ ...t2, ...e2 })), E = async (e2, t2) => {
|
|
7
|
+
const a2 = c && x.reloadData !== c;
|
|
8
|
+
if (x.isFinish) return;
|
|
9
|
+
N({ loading: true });
|
|
10
|
+
const i2 = await m(e2, t2);
|
|
11
|
+
F(i2), N({ isFinish: !i2.length, imageList: a2 ? [...i2] : [...x.imageList, ...i2], page: e2 + 1, loading: false });
|
|
12
|
+
}, F = (e2) => y((t2) => {
|
|
13
|
+
const a2 = c && x.reloadData !== c, i2 = a2 ? [] : [...j], n2 = a2 ? Array(t2.columns).fill(0) : [..."[]" !== JSON.stringify(w) ? w : Array(t2.columns).fill(0)];
|
|
14
|
+
return e2.forEach((e3) => {
|
|
15
|
+
const a3 = ((e4) => {
|
|
16
|
+
let t3 = 0, a4 = 0;
|
|
17
|
+
return t3 = e4.indexOf(Math.min(...e4)), a4 = e4[t3], { index: t3, height: a4 };
|
|
18
|
+
})(n2), o2 = Math.floor(e3.height * t2.imageWidth / e3.width);
|
|
19
|
+
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);
|
|
20
|
+
}), b(i2), t2;
|
|
21
|
+
}), M = o(() => {
|
|
22
|
+
if (!D.current) return;
|
|
23
|
+
const e2 = D.current.clientWidth;
|
|
24
|
+
let t2 = 0, a2 = x.page;
|
|
25
|
+
if (c && x.reloadData !== c && (y({ page: 1, reloadData: c, loading: false, isFinish: false, gap: "number" == typeof s2 ? 0 : s2.gap, imageWidth: "number" == typeof s2 ? s2 : 0, columns: "number" == typeof s2 ? 0 : s2.columns, imageList: [] }), W([]), b([]), a2 = 1), "number" == typeof s2) {
|
|
26
|
+
const a3 = Math.floor(e2 / x.imageWidth);
|
|
27
|
+
t2 = a3 - 1;
|
|
28
|
+
const i2 = t2 ? (e2 - a3 * x.imageWidth) / t2 : 0;
|
|
29
|
+
N({ columns: a3, gap: i2 });
|
|
30
|
+
} else {
|
|
31
|
+
t2 = x.columns - 1;
|
|
32
|
+
const a3 = (e2 - t2 * x.gap) / x.columns;
|
|
33
|
+
N({ imageWidth: a3 });
|
|
34
|
+
}
|
|
35
|
+
E(a2, l);
|
|
36
|
+
}, [x, c]), T = () => {
|
|
37
|
+
v.current && clearTimeout(v.current), v.current = setTimeout(M, 50);
|
|
38
|
+
}, z = a(() => {
|
|
39
|
+
const { scrollTop: e2, clientHeight: t2, scrollHeight: a2 } = L.current;
|
|
40
|
+
a2 - t2 - e2 > f || !x.loading && E(x.page, l);
|
|
41
|
+
}, 50);
|
|
42
|
+
return t("scroll", z, { target: L.current, deps: [x.loading, x.page] }), r(() => (M(), window.addEventListener("resize", T), () => {
|
|
43
|
+
window.removeEventListener("resize", T);
|
|
44
|
+
}), [D, c]), r(() => {
|
|
45
|
+
h && E(x.page, l);
|
|
46
|
+
}, [h, x.loading, x.page, L.current]), e.jsxs("div", { className: "ono-waterfall-container", children: [e.jsx("div", { ref: L, className: [g, "ono-waterfall-content"].join(" ").trim(), style: p, children: e.jsx("div", { ref: D, className: "ono-waterfall-wrapper", style: { height: Math.max(...w) - x.gap + "px" }, children: x.imageList.map((t2, a2) => e.jsx("div", { className: "ono-waterfall-item", style: { width: `${x.imageWidth}px`, transform: `translate(${j[a2].x}px,${j[a2].y}px)` }, children: d(t2, a2) }, t2.id)) }) }), x.loading && ("function" == typeof u ? u() : u && "boolean" == typeof u ? e.jsx("div", { className: "ono-waterfall-loading", children: "loading..." }) : u)] });
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
s as W
|
|
50
|
+
};
|
|
@@ -1 +1,145 @@
|
|
|
1
|
-
const t
|
|
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
|
+
};
|