ono-react-element 0.0.18 → 0.0.19
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-tkaOmfnx.js +1 -0
- package/dist/es/AvatarCrop-DrA-SARP.js +1 -65
- package/dist/es/Button-QIC7QPK9.js +1 -0
- package/dist/es/Card3D-DMvCSUhe.js +1 -18
- package/dist/es/Checkbox-daBabj14.js +1 -19
- package/dist/es/InjunctiveBox-DUNoNHCO.js +1 -11
- package/dist/es/Input-DLOeg2pz.js +1 -80
- package/dist/es/List-UAKCMuGC.js +1 -19
- package/dist/es/MenuButton-DHkU5Bq7.js +1 -17
- package/dist/es/Message-BGDILiLc.js +1 -105
- package/dist/es/Modal-D2289ZPX.js +1 -0
- package/dist/es/Pagination-m71H2tfS.js +1 -17
- package/dist/es/PortalRenderer-CDAzQJgm.js +1 -19
- package/dist/es/Radio-D_GKVoOC.js +1 -25
- package/dist/es/ScrollableTabs--449B73p.js +1 -34
- package/dist/es/Select-B11NvK-I.js +1 -34
- package/dist/es/SvgImg-CZwq2D7J.js +1 -14
- package/dist/es/Switch-C61q7rR5.js +1 -0
- package/dist/es/TemplateDialog-CAimG5cv.js +1 -0
- package/dist/es/Toast-CQEsbqUJ.js +1 -42
- package/dist/es/Tooltip-CgttMIcX.js +1 -29
- package/dist/es/VirtualList-BAiIymCF.js +1 -0
- package/dist/es/Waterfall-C7SWCxJ1.js +1 -0
- package/dist/es/colorUtils.ts-DYuRvCXZ.js +1 -145
- package/dist/es/common.ts-BbDnZ7vC.js +1 -0
- package/dist/es/dependencies-CbQbPZZ-.js +1 -15524
- package/dist/es/event-CtX9rswE.js +1 -28
- package/dist/es/fileFormatConversion.ts-tUlewYon.js +1 -38
- package/dist/es/formatTimeUtils.ts-CkdWJ_Sl.js +1 -32
- package/dist/es/index.js +1 -123
- package/dist/es/useClickOutSide.tsx-CMvd2uTW.js +1 -15
- package/dist/es/useCountdown.tsx-Btzj-keH.js +1 -16
- package/dist/es/useEventListener.tsx-BBGVcI5T.js +1 -12
- package/dist/es/useGetElementSize.tsx-Dtshth0Y.js +1 -22
- package/dist/es/useKeyPress.tsx-Db44HXXz.js +1 -18
- package/dist/es/useMouseClick.tsx-C7uAH4n4.js +1 -12
- package/dist/es/useTheme.tsx-C5b7BRYz.js +1 -24
- package/dist/es/useThemePro.tsx-DQuSI8J7.js +1 -20
- package/dist/es/viewTransitionUtils.ts-CHa9uBpi.js +1 -19
- package/dist/style/AutoSliderList.css +1 -1
- package/dist/style/AvatarCrop.css +1 -1
- package/dist/style/Button.css +1 -1
- package/dist/style/Card3D.css +1 -1
- package/dist/style/Checkbox.css +1 -1
- package/dist/style/Input.css +1 -1
- package/dist/style/MenuButton.css +1 -1
- package/dist/style/Message.css +1 -1
- package/dist/style/Modal.css +1 -1
- package/dist/style/Pagination.css +1 -1
- package/dist/style/Radio.css +1 -1
- package/dist/style/ScrollableTabs.css +1 -1
- package/dist/style/Select.css +1 -1
- package/dist/style/SvgImg.css +1 -1
- package/dist/style/Switch.css +1 -1
- package/dist/style/TemplateDialog.css +1 -1
- package/dist/style/Toast.css +1 -1
- package/dist/style/Tooltip.css +1 -1
- package/dist/style/Waterfall.css +1 -1
- package/dist/style/index.css +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils/common.d.ts +4 -0
- package/dist/umd/index.umd.cjs +1 -1
- package/dist/umd/index.umd.cjs.br +0 -0
- package/dist/umd/index.umd.cjs.gz +0 -0
- package/package.json +1 -1
- package/dist/es/AutoSliderList-eb1CVc8b.js +0 -30
- package/dist/es/Button-BsWI818a.js +0 -29
- package/dist/es/Modal-BsI-8rap.js +0 -37
- package/dist/es/Switch-BBHMaxoZ.js +0 -34
- package/dist/es/TemplateDialog-PQxjmAJa.js +0 -45
- package/dist/es/VirtualList-CdhqyHFQ.js +0 -60
- package/dist/es/Waterfall-CY3QkL5m.js +0 -50
- package/dist/es/common.ts-vX9A6Rye.js +0 -154
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { j as t } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
-
import { u as e } from "./useGetElementSize.tsx-Dtshth0Y.js";
|
|
3
|
-
import { p as i } from "./common.ts-vX9A6Rye.js";
|
|
4
|
-
import { useState as o, useRef as r, useMemo as n, useEffect as s, cloneElement as l } from "react";
|
|
5
|
-
var a = ((t2) => (t2.Horizontal = "Horizontal", t2.Vertical = "Vertical", t2))(a || {});
|
|
6
|
-
const c = ({ list: c2, style: d, disable: f, children: m, sliderBox: u, className: p, sliderStyle: h, duration: x = 300, sliderClassName: w, currentIndex: y = 0, direction: j = a.Horizontal, sliderTransitionTimingFunction: z = "ease-in-out" }) => {
|
|
7
|
-
const [g, H] = o(false), [T, $] = o(0), [v, A] = o({ t: 0, l: 0 }), [C, N] = o({ w: 0, h: 0 }), b = r(null), B = r(null), S = n(() => ["width", "height", "transform"].map((t2) => `${t2} ${x / 1e3}s ${z}`).join(","), [j, x, z]), k = n(() => ({ width: C.w, height: C.h, transition: g ? S : "initial", transform: `translate(${v.l}px, ${v.t}px)` }), [C, v]), { w: D, h: E } = e();
|
|
8
|
-
return s(() => {
|
|
9
|
-
$(y);
|
|
10
|
-
}, [y]), s(() => {
|
|
11
|
-
(() => {
|
|
12
|
-
if ("number" != typeof T) return;
|
|
13
|
-
if (!b.current || !B.current) return;
|
|
14
|
-
const t2 = Array.from(b.current.children).slice(1);
|
|
15
|
-
t2.forEach((t3) => {
|
|
16
|
-
t3.style.position = "relative", t3.style.cursor = f ? "not-allowed" : "pointer", t3.style.zIndex = "1";
|
|
17
|
-
});
|
|
18
|
-
const e2 = window.getComputedStyle(b.current), o2 = { t: "Horizontal" === j ? i(e2.paddingTop) : t2[T].offsetTop, l: "Horizontal" === j ? t2[T].offsetLeft : i(e2.paddingLeft) };
|
|
19
|
-
A(o2), N({ w: t2[T].offsetWidth, h: t2[T].offsetHeight }), setTimeout(() => H(true), x);
|
|
20
|
-
})();
|
|
21
|
-
}, [T, D, E, f]), t.jsxs("ul", { ref: b, className: ["ono-auto-slider-list-container", p, f ? "ono-auto-slider-list-is-disable" : ""].filter(Boolean).join(" "), style: { flexDirection: "Horizontal" === j ? "row" : "column", ...d }, children: [t.jsx("li", { ref: B, className: ["ono-auto-slider-list-slider", w].filter(Boolean).join(" "), style: { ...h, ...k }, children: u }), c2.map((t2, e2) => l(m({ item: t2, index: e2, isActive: e2 === T }), { onClick: (i2) => {
|
|
22
|
-
if (f) return;
|
|
23
|
-
const o2 = m({ item: t2, index: e2, isActive: e2 === T }).props.onClick;
|
|
24
|
-
o2 && o2(i2), $(e2);
|
|
25
|
-
} }))] });
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
c as A,
|
|
29
|
-
a as D
|
|
30
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { j as n } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
-
import { t as o } from "./common.ts-vX9A6Rye.js";
|
|
3
|
-
import { forwardRef as t, useState as e, useRef as i, useEffect as r } from "react";
|
|
4
|
-
const s = t(({ onClick: t2, children: s2, disabled: c, loading: a, plain: l, shape: d = "default", htmlType: u = "button", type: p = "primary", throttleDuration: m, className: f, style: h, icon: g }, b) => {
|
|
5
|
-
const [j, y] = e(false), x = i(null), C = i(null), v = t2 ? o(t2, m ? "number" == typeof m ? m : 500 : 0) : void 0;
|
|
6
|
-
return r(() => {
|
|
7
|
-
(() => {
|
|
8
|
-
if (!C.current) return;
|
|
9
|
-
const n2 = C.current;
|
|
10
|
-
a ? (y(true), n2.classList.add("ono-loading-start")) : (setTimeout(() => {
|
|
11
|
-
y(false);
|
|
12
|
-
}, 300), n2.classList.remove("ono-loading-start"), n2.classList.add("ono-loading-end"));
|
|
13
|
-
})();
|
|
14
|
-
}, [a, C]), r(() => {
|
|
15
|
-
(() => {
|
|
16
|
-
if (!x.current) return;
|
|
17
|
-
const n2 = x.current, o2 = n2.getBoundingClientRect();
|
|
18
|
-
n2.style.setProperty("--btn-height", o2.height + "px");
|
|
19
|
-
})();
|
|
20
|
-
}, [x]), r(() => {
|
|
21
|
-
b && x && ("function" == typeof b ? b(x.current) : b.current = x.current);
|
|
22
|
-
}, [b, x]), n.jsxs("button", { ref: x, className: [`ono-btn-${p}`, a || j ? "ono-is-loading" : "", a || g ? "ono-is-icon" : "", c ? "ono-btn-is-disabled" : "", "round" === d ? "ono-is-round" : "circle" === d ? "ono-is-circle" : "", l ? "ono-is-plain" : "", f ?? ""].filter(Boolean).join(" "), type: u, disabled: ("function" == typeof c ? c() : c) || !!a, style: h, onClick: v, children: [(() => {
|
|
23
|
-
const o2 = n.jsx("span", { ref: C, className: "ono-btn-icon", children: n.jsx("span", { children: "object" == typeof a ? a.icon : n.jsx("svg", { viewBox: "0 0 1024 1024", focusable: "false", "data-icon": "loading", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": "true", children: n.jsx("path", { d: "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" }) }) }) });
|
|
24
|
-
return a || j ? o2 : g ? n.jsx("span", { children: g }) : n.jsx(n.Fragment, {});
|
|
25
|
-
})(), s2] });
|
|
26
|
-
});
|
|
27
|
-
export {
|
|
28
|
-
s as B
|
|
29
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { j as o } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
-
import { a as e } from "./colorUtils.ts-DYuRvCXZ.js";
|
|
3
|
-
import { useState as n, useRef as l, useEffect as a } from "react";
|
|
4
|
-
import { p as t } from "./PortalRenderer-CDAzQJgm.js";
|
|
5
|
-
import { B as r } from "./Button-BsWI818a.js";
|
|
6
|
-
const s = ({ title: t2 = "This is a modal title", icon: s2, content: i2 = "This is a modal content", okText: c = "confirm", cancelText: d = "cancel", confirmDisabled: m, cancelDisabled: h, position: x, onConfirm: b, onCancel: f, mask: u = true, maskClosable: p = false, width: j, btnClr: C, footer: v = ({ OkBtn: e2, CancelBtn: n2 }) => o.jsxs(o.Fragment, { children: [o.jsx(n2, {}), o.jsx(e2, {})] }), modalBody: y, destroy: B }) => {
|
|
7
|
-
const [g, w] = n(false), k = l(null), N = l(null), P = [{ label: "themeColor", value: C || "" }, { label: "themeHoverColor", value: C && e(C, "light", 10) || "" }, { label: "themeActiveColor", value: C && e(C, "dark", 20) || "" }, { label: "themeDisabledClr", value: C && e(C, "light", 20) || "" }], T = () => {
|
|
8
|
-
if (x) {
|
|
9
|
-
if (!N.current) return;
|
|
10
|
-
N.current.classList.remove("ono-modal-enter"), N.current.classList.add("ono-modal-leave"), setTimeout(() => {
|
|
11
|
-
B();
|
|
12
|
-
}, 300);
|
|
13
|
-
} else B();
|
|
14
|
-
};
|
|
15
|
-
return a(() => (k.current && (u ? k.current.showModal() : k.current.show()), () => {
|
|
16
|
-
k.current && k.current.close();
|
|
17
|
-
}), [k.current, u]), a(() => {
|
|
18
|
-
(() => {
|
|
19
|
-
if (!N.current) return;
|
|
20
|
-
const o2 = N.current.style;
|
|
21
|
-
j && o2.setProperty("--width", j + "px"), x && (o2.setProperty("--left", (x.x / window.innerWidth * 100).toFixed(2) + "%"), o2.setProperty("--top", (x.y / window.innerHeight * 100).toFixed(2) + "%")), C && P.forEach((e2) => o2.setProperty(`--${e2.label}`, e2.value));
|
|
22
|
-
})();
|
|
23
|
-
}, [N]), o.jsx("dialog", { ref: k, className: "ono-modal", onClick: () => p && T(), children: y ? y(T) : o.jsxs("div", { ref: N, className: ["ono-modal-box", x ? "ono-modal-enter" : ""].join(" "), onClick: (o2) => o2.stopPropagation(), children: [o.jsxs("div", { className: "ono-modal-box-body", children: [s2 ?? o.jsx("div", { className: "ono-modal-box-body-icon", children: o.jsx("svg", { color: "#faad14", viewBox: "64 64 896 896", focusable: "false", "data-icon": "exclamation-circle", width: "22px", height: "22px", fill: "currentColor", "aria-hidden": "true", style: { marginInlineEnd: "12px" }, children: o.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" }) }) }), o.jsxs("div", { className: "ono-modal-box-body-contentBar", children: [o.jsx("h1", { className: "ono-modal-box-body-contentBar-title", children: t2 }), o.jsx("p", { className: "ono-modal-box-body-contentBar-content", children: i2 })] })] }), v && o.jsx("div", { className: "ono-modal-box-footer", children: v({ OkBtn: () => o.jsx(r, { className: "ono-modal-box-footer-confirmBtn", loading: g, disabled: m, onClick: async () => {
|
|
24
|
-
w(true);
|
|
25
|
-
try {
|
|
26
|
-
const o2 = b == null ? void 0 : b();
|
|
27
|
-
o2 instanceof Promise && await o2;
|
|
28
|
-
} finally {
|
|
29
|
-
w(false), T();
|
|
30
|
-
}
|
|
31
|
-
}, children: c ?? "Confirm" }), CancelBtn: () => o.jsx(r, { className: "ono-modal-box-footer-cancelBtn", disabled: h || g, onClick: () => {
|
|
32
|
-
f == null ? void 0 : f(), T();
|
|
33
|
-
}, children: d ?? "Cancel" }), handleClose: () => T() }) })] }) });
|
|
34
|
-
}, i = (o2) => t(s, o2, "ono-modal");
|
|
35
|
-
export {
|
|
36
|
-
i as M
|
|
37
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
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,45 +0,0 @@
|
|
|
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,60 +0,0 @@
|
|
|
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,50 +0,0 @@
|
|
|
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,154 +0,0 @@
|
|
|
1
|
-
const t = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+])[\da-zA-Z]{8,}$/, e = (t2) => t2 <= 11 ? Math.random().toString(36).substring(2, 2 + t2).padEnd(t2, "0") : e(11) + e(t2 - 11), n = ({ el: t2, str: e2 = "hello world", speed: n2 = 100, isExtendStr: o2 = true, onDone: r2 }) => {
|
|
2
|
-
let s2 = 0, a2 = null;
|
|
3
|
-
t2.textContent && o2 && (s2 = t2.textContent.length, e2 = t2.textContent + e2);
|
|
4
|
-
const i2 = () => {
|
|
5
|
-
clearTimeout(a2);
|
|
6
|
-
const o3 = e2.substring(0, s2 + 1);
|
|
7
|
-
t2.textContent = o3, s2++, s2 !== e2.length ? a2 = setTimeout(i2, n2) : r2 && r2();
|
|
8
|
-
};
|
|
9
|
-
i2();
|
|
10
|
-
}, o = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent), r = async (t2, e2) => {
|
|
11
|
-
const n2 = (t3, e3) => {
|
|
12
|
-
const n3 = window.URL.createObjectURL(t3), o2 = document.createElement("a");
|
|
13
|
-
o2.href = n3, o2.download = encodeURIComponent(e3), document.body.appendChild(o2), o2.click(), document.body.removeChild(o2), window.URL.revokeObjectURL(n3);
|
|
14
|
-
};
|
|
15
|
-
try {
|
|
16
|
-
if ("string" == typeof t2) {
|
|
17
|
-
const o2 = await fetch(t2);
|
|
18
|
-
if (!o2.ok) throw new Error(`Network response was not ok: ${o2.statusText}`);
|
|
19
|
-
n2(await o2.blob(), e2);
|
|
20
|
-
} else n2(t2, e2);
|
|
21
|
-
} catch (t3) {
|
|
22
|
-
console.error("文件下载失败:", t3 instanceof Error ? t3.message : String(t3));
|
|
23
|
-
}
|
|
24
|
-
}, s = (t2, e2) => {
|
|
25
|
-
t2.toString().startsWith("2") ? e2.onSuccess && e2.onSuccess() : (t2.toString().startsWith("4") || t2.toString().startsWith("5")) && e2.onFail && e2.onFail();
|
|
26
|
-
}, a = (t2) => {
|
|
27
|
-
const e2 = t2.getBoundingClientRect();
|
|
28
|
-
return { x: e2.left + e2.width / 2, y: e2.top + e2.height / 2 };
|
|
29
|
-
}, i = (t2, e2, n2) => {
|
|
30
|
-
const o2 = new IntersectionObserver(e2, n2);
|
|
31
|
-
t2 instanceof HTMLElement ? o2.observe(t2) : t2.forEach((t3) => o2.observe(t3));
|
|
32
|
-
}, c = (t2) => {
|
|
33
|
-
const e2 = Math.floor(t2 / 3600), n2 = Math.floor(t2 % 3600 / 60), o2 = Math.floor(t2 % 60), r2 = (t3) => t3.toString().padStart(2, "0");
|
|
34
|
-
return (e2 > 0 ? `${r2(e2)}:${r2(n2)}:${r2(o2)}` : `${r2(n2)}:${r2(o2)}`) + (t2 < 10 ? ".00" : t2 < 100 ? ".0" : "");
|
|
35
|
-
}, l = (t2) => {
|
|
36
|
-
if (t2.length < 2) return t2;
|
|
37
|
-
const e2 = t2[0], n2 = t2.slice(1).filter((t3) => t3 <= e2), o2 = t2.slice(1).filter((t3) => t3 > e2);
|
|
38
|
-
return [...l(n2), e2, ...l(o2)];
|
|
39
|
-
}, u = (t2, e2) => {
|
|
40
|
-
const n2 = ["B", "KB", "MB", "GB", "TB"], o2 = 1024;
|
|
41
|
-
let r2 = n2.indexOf((e2 == null ? void 0 : e2.unit) ?? "B");
|
|
42
|
-
if (-1 === r2) throw new Error("Invalid unit");
|
|
43
|
-
if (!(e2 == null ? void 0 : e2.unit)) for (; t2 / Math.pow(o2, r2) >= o2; ) r2++;
|
|
44
|
-
return `${(t2 / Math.pow(o2, r2)).toFixed((e2 == null ? void 0 : e2.decimalPlaces) ?? 0)} ${n2[r2]}`;
|
|
45
|
-
}, d = (t2, e2) => `${Math.floor(t2 / f(t2, e2))}:${Math.floor(e2 / f(t2, e2))}`, f = (t2, e2) => {
|
|
46
|
-
for (; 0 !== e2; ) {
|
|
47
|
-
const n2 = e2;
|
|
48
|
-
e2 = t2 % e2, t2 = n2;
|
|
49
|
-
}
|
|
50
|
-
return t2;
|
|
51
|
-
}, g = (t2, e2, n2) => {
|
|
52
|
-
t2.muted = true, t2.play();
|
|
53
|
-
const o2 = new AudioContext(), r2 = "running" === o2.state;
|
|
54
|
-
o2.close(), r2 ? (t2.muted = false, e2 == null ? void 0 : e2()) : n2 == null ? void 0 : n2();
|
|
55
|
-
}, h = (t2) => new URLSearchParams(window.location.search).get(t2), p = (t2) => {
|
|
56
|
-
let e2;
|
|
57
|
-
const n2 = new Proxy(t2, { construct: (t3, n3) => (e2 || (e2 = Reflect.construct(t3, n3)), e2) });
|
|
58
|
-
return n2.prototype.construct = n2, n2;
|
|
59
|
-
}, m = (t2) => "string" != typeof t2 || 0 === t2.length ? "" : t2.charAt(0).toUpperCase() + t2.slice(1), w = (t2) => {
|
|
60
|
-
if ("object" != typeof t2 || null === t2) return t2;
|
|
61
|
-
const e2 = Array.isArray(t2) ? [] : {};
|
|
62
|
-
for (const n2 in t2) Object.prototype.hasOwnProperty.call(t2, n2) && (e2[n2] = w(t2[n2]));
|
|
63
|
-
return e2;
|
|
64
|
-
}, b = (t2) => new Promise((e2) => {
|
|
65
|
-
const n2 = new Image();
|
|
66
|
-
n2.src = "string" == typeof t2 ? t2 : URL.createObjectURL(t2), n2.onload = () => e2({ width: n2.width, height: n2.height });
|
|
67
|
-
}), y = (t2, e2) => {
|
|
68
|
-
let n2 = 0;
|
|
69
|
-
const o2 = (r2) => {
|
|
70
|
-
n2 || (n2 = r2), r2 - n2 >= e2 ? t2() : requestAnimationFrame(o2);
|
|
71
|
-
};
|
|
72
|
-
requestAnimationFrame(o2);
|
|
73
|
-
}, S = (t2, e2, n2) => {
|
|
74
|
-
const o2 = t2[e2];
|
|
75
|
-
t2[e2] = function(t3) {
|
|
76
|
-
o2 && "function" == typeof o2 && o2.call(this, t3), n2.call(this, t3);
|
|
77
|
-
};
|
|
78
|
-
}, x = (t2) => {
|
|
79
|
-
if ("number" != typeof t2 || isNaN(t2)) throw new Error("请输入有效的数字");
|
|
80
|
-
const e2 = t2.toString().split(".");
|
|
81
|
-
return e2[0] = e2[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","), e2.join(".");
|
|
82
|
-
}, C = (t2) => parseFloat(t2.replace(/[^0-9.]/g, "")), O = (t2, e2, n2, o2) => Math.sqrt((t2 - n2) ** 2 + (e2 - o2) ** 2), T = (t2) => navigator.clipboard.writeText(t2), M = (t2) => Math.ceil((t2.getTime() - new Date(t2.getFullYear(), 0, 1).getTime()) / 864e5), E = (t2, e2, n2) => 0.2126 * t2 + 0.7152 * e2 + 0.0722 * n2, A = (t2) => {
|
|
83
|
-
const e2 = {};
|
|
84
|
-
return t2.replace(/([^?=&]+)=([^&]+)/g, (t3, n2, o2) => e2[n2] = o2), e2;
|
|
85
|
-
}, v = (t2, ...e2) => Object.fromEntries(Object.entries(t2).filter(([t3]) => e2.includes(t3))), F = (t2) => {
|
|
86
|
-
if (!t2) return "";
|
|
87
|
-
const e2 = t2.lastIndexOf(".");
|
|
88
|
-
return -1 === e2 ? F(t2.substring(t2.lastIndexOf("/") + 1)) : t2.substring(0, e2);
|
|
89
|
-
}, I = (t2) => {
|
|
90
|
-
if (!t2) return "";
|
|
91
|
-
const e2 = t2.lastIndexOf(".");
|
|
92
|
-
return t2.substring(e2 + 1);
|
|
93
|
-
}, P = (t2, e2) => {
|
|
94
|
-
let n2 = null;
|
|
95
|
-
return (...o2) => {
|
|
96
|
-
n2 && clearTimeout(n2), n2 = setTimeout(() => {
|
|
97
|
-
t2(...o2), n2 = null;
|
|
98
|
-
}, e2);
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
function R(t2, e2, n2 = {}) {
|
|
102
|
-
let o2, r2 = null, s2 = null, a2 = 0;
|
|
103
|
-
const i2 = false !== n2.leading, c2 = false !== n2.trailing;
|
|
104
|
-
function l2() {
|
|
105
|
-
s2 && (t2.apply(o2, s2), s2 = null);
|
|
106
|
-
}
|
|
107
|
-
function u2() {
|
|
108
|
-
const t3 = Date.now();
|
|
109
|
-
t3 - a2 >= e2 ? (c2 && s2 && l2(), r2 = null) : r2 = setTimeout(u2, e2 - (t3 - a2));
|
|
110
|
-
}
|
|
111
|
-
const d2 = function(...t3) {
|
|
112
|
-
const n3 = Date.now();
|
|
113
|
-
s2 = t3, o2 = this, n3 - a2 >= e2 ? r2 || (a2 = n3, i2 ? l2() : c2 && (r2 = setTimeout(u2, e2))) : !r2 && c2 && (r2 = setTimeout(u2, e2 - (n3 - a2)));
|
|
114
|
-
};
|
|
115
|
-
return d2.cancel = function() {
|
|
116
|
-
r2 && (clearTimeout(r2), r2 = null), a2 = 0, s2 = null;
|
|
117
|
-
}, d2;
|
|
118
|
-
}
|
|
119
|
-
const $ = { addCommasToNumber: x, addEventWithOriginHandler: S, calculateAspectRatio: d, checkDeviceIsMobile: o, checkStatusCode: s, copy2Clipboard: T, createIntersectionObserver: i, dayOfYear: M, deepCopy: w, downloadFile: r, formatFileSize: u, formatSecondes: c, getElementCenterPosition: a, getFileName: F, getFileSuffix: I, getImageSIze: b, getPointDistance: O, getURLSearchParams: h, grayColor: E, mediaAutoplayPolicies: g, parseQuery: A, passwordStrength: t, pick: v, printStr: n, pureNumber: C, quickSort: l, rafTimeout: y, randomString: e, safeCapitalizeWord: m, singleton: p, throttle: R, debounce: P };
|
|
120
|
-
export {
|
|
121
|
-
v as A,
|
|
122
|
-
n as B,
|
|
123
|
-
l as C,
|
|
124
|
-
y as D,
|
|
125
|
-
e as E,
|
|
126
|
-
m as F,
|
|
127
|
-
p as G,
|
|
128
|
-
x as a,
|
|
129
|
-
S as b,
|
|
130
|
-
d as c,
|
|
131
|
-
o as d,
|
|
132
|
-
s as e,
|
|
133
|
-
$ as f,
|
|
134
|
-
a as g,
|
|
135
|
-
T as h,
|
|
136
|
-
i,
|
|
137
|
-
M as j,
|
|
138
|
-
P as k,
|
|
139
|
-
w as l,
|
|
140
|
-
r as m,
|
|
141
|
-
u as n,
|
|
142
|
-
c as o,
|
|
143
|
-
C as p,
|
|
144
|
-
F as q,
|
|
145
|
-
I as r,
|
|
146
|
-
b as s,
|
|
147
|
-
R as t,
|
|
148
|
-
O as u,
|
|
149
|
-
h as v,
|
|
150
|
-
E as w,
|
|
151
|
-
g as x,
|
|
152
|
-
A as y,
|
|
153
|
-
t as z
|
|
154
|
-
};
|