ono-react-element 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/es/AutoSliderList-w9mw0JCN.js +30 -0
  3. package/dist/es/InjunctiveBox-DUNoNHCO.js +11 -0
  4. package/dist/es/{Input-Z3uL5-nj.js → Input-DLOeg2pz.js} +32 -32
  5. package/dist/es/Message-BGDILiLc.js +105 -0
  6. package/dist/es/{Modal-C-c_S_VM.js → Modal-BIFxRjSt.js} +10 -10
  7. package/dist/es/{Select-BXPk2P2w.js → Select-DAU6TuBu.js} +6 -6
  8. package/dist/es/{Switch-CN3M5pXb.js → Switch-CRJejHP9.js} +13 -13
  9. package/dist/es/{TemplateDialog-CO-4TmAd.js → TemplateDialog-dD8BcnbA.js} +11 -11
  10. package/dist/es/{Toast-BadlA1yD.js → Toast-CQEsbqUJ.js} +27 -27
  11. package/dist/es/{Tooltip-C5OFmxWo.js → Tooltip-j2AKREfX.js} +11 -11
  12. package/dist/es/VirtualList-w16-kBkT.js +65 -0
  13. package/dist/es/{Waterfall-a_c3urjB.js → Waterfall-CFVkuuCO.js} +17 -17
  14. package/dist/es/colorUtils.ts-DYuRvCXZ.js +145 -0
  15. package/dist/es/common.ts-DQOEx8k3.js +126 -0
  16. package/dist/es/fileFormatConversion.ts-tUlewYon.js +38 -0
  17. package/dist/es/formatTimeUtils.ts-CkdWJ_Sl.js +32 -0
  18. package/dist/es/index.js +96 -85
  19. package/dist/es/useClickOutSide.tsx-CMvd2uTW.js +15 -0
  20. package/dist/es/useCountdown.tsx-Btzj-keH.js +16 -0
  21. package/dist/es/useEventListener.tsx-BBGVcI5T.js +12 -0
  22. package/dist/es/useGetElementSize.tsx-Dtshth0Y.js +22 -0
  23. package/dist/es/useKeyPress.tsx-Db44HXXz.js +18 -0
  24. package/dist/es/useMouseClick.tsx-C7uAH4n4.js +12 -0
  25. package/dist/es/useTheme.tsx-C5b7BRYz.js +24 -0
  26. package/dist/es/useThemePro.tsx-DQuSI8J7.js +20 -0
  27. package/dist/es/viewTransitionUtils.ts-CHa9uBpi.js +19 -0
  28. package/dist/index.css +1 -1
  29. package/dist/style/Button.css +1 -1
  30. package/dist/style/Message.css +1 -1
  31. package/dist/style/Modal.css +1 -1
  32. package/dist/style/Toast.css +1 -1
  33. package/dist/style/index.css +1 -1
  34. package/dist/types/components/TemplateDialog/TemplateDialog.d.ts +1 -1
  35. package/dist/types/components/TemplateDialog/types.d.ts +1 -1
  36. package/dist/types/hooks/useClickOutSide.d.ts +2 -2
  37. package/dist/types/hooks/useCountdown.d.ts +2 -1
  38. package/dist/types/hooks/useEventListener.d.ts +2 -2
  39. package/dist/types/hooks/useGetElementSize.d.ts +2 -1
  40. package/dist/types/hooks/useKeyPress.d.ts +2 -2
  41. package/dist/types/hooks/useMouseClick.d.ts +9 -0
  42. package/dist/types/hooks/useTheme.d.ts +2 -2
  43. package/dist/types/hooks/useThemePro.d.ts +2 -2
  44. package/dist/types/index.d.ts +9 -2
  45. package/dist/umd/index.css +1 -1
  46. package/dist/umd/index.css.br +0 -0
  47. package/dist/umd/index.css.gz +0 -0
  48. package/dist/umd/index.umd.cjs +398 -392
  49. package/dist/umd/index.umd.cjs.br +0 -0
  50. package/dist/umd/index.umd.cjs.gz +0 -0
  51. package/package.json +3 -2
  52. package/dist/es/AutoSliderList-Dy-otnYu.js +0 -30
  53. package/dist/es/InjunctiveBox-D0V-K9Pn.js +0 -11
  54. package/dist/es/Message-GvTC61N0.js +0 -68
  55. package/dist/es/VirtualList-BeDq637Z.js +0 -65
  56. package/dist/es/hooks-Dew3_cmY.js +0 -103
  57. package/dist/es/utils-BxXROOPY.js +0 -394
  58. package/dist/types/hooks/index.d.ts +0 -7
Binary file
Binary file
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "ono-react-element",
3
3
  "private": false,
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "description": "Component library by React + Typescript",
6
6
  "type": "module",
7
7
  "main": "./dist/umd/index.umd.cjs",
8
8
  "module": "./dist/es/index.js",
9
9
  "types": "./dist/index.d.ts",
10
10
  "files": [
11
- "dist"
11
+ "dist",
12
+ "LICENSE.md"
12
13
  ],
13
14
  "exports": {
14
15
  ".": {
@@ -1,30 +0,0 @@
1
- import { j as t } from "./dependencies-CbQbPZZ-.js";
2
- import { p as e } from "./utils-BxXROOPY.js";
3
- import { useState as i, useRef as o, useMemo as r, useEffect as n, cloneElement as s } from "react";
4
- import { u as l } from "./hooks-Dew3_cmY.js";
5
- var a = ((t2) => (t2.Horizontal = "Horizontal", t2.Vertical = "Vertical", t2))(a || {});
6
- const c = ({ list: c2, style: d, disable: f, children: u, sliderBox: m, className: p, sliderStyle: h, duration: x = 300, sliderClassName: w, currentIndex: y = 0, direction: j = a.Horizontal, sliderTransitionTimingFunction: g = "ease-in-out" }) => {
7
- const [z, H] = i(false), [T, $] = i(0), [v, A] = i({ t: 0, l: 0 }), [C, N] = i({ w: 0, h: 0 }), b = o(null), k = o(null), B = r(() => ["width", "height", "transform"].map((t2) => `${t2} ${x / 1e3}s ${g}`).join(","), [j, x, g]), D = r(() => ({ width: C.w, height: C.h, transition: z ? B : "initial", transform: `translate(${v.l}px, ${v.t}px)` }), [C, v]), { w: I, h: L } = l();
8
- return n(() => {
9
- $(y);
10
- }, [y]), n(() => {
11
- (() => {
12
- if ("number" != typeof T) return;
13
- if (!b.current || !k.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 i2 = window.getComputedStyle(b.current), o2 = { t: "Horizontal" === j ? e(i2.paddingTop) : t2[T].offsetTop, l: "Horizontal" === j ? t2[T].offsetLeft : e(i2.paddingLeft) };
19
- A(o2), N({ w: t2[T].offsetWidth, h: t2[T].offsetHeight }), setTimeout(() => H(true), x);
20
- })();
21
- }, [T, I, L, 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: k, className: ["ono-auto-slider-list-slider", w].filter(Boolean).join(" "), style: { ...h, ...D }, children: m }), c2.map((t2, e2) => s(u({ item: t2, index: e2, isActive: e2 === T }), { onClick: (i2) => {
22
- if (f) return;
23
- const o2 = u({ 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,11 +0,0 @@
1
- import { j as o, R as e } from "./dependencies-CbQbPZZ-.js";
2
- import { a as n } from "./hooks-Dew3_cmY.js";
3
- let s, l = null;
4
- const t = ({ className: e2, content: s2, style: t2, onClick: u2, onDoubleClick: c2, onContextMenu: i, onMouseDown: a, onMouseUp: r, onMouseEnter: M, onMouseLeave: d, onMouseMove: m, isClickBoxToClose: p }) => (n("click", () => {
5
- p && l && (l.remove(), l = null);
6
- }), o.jsx("div", { className: e2, style: t2, onClick: u2, onDoubleClick: c2, onContextMenu: i, onMouseDown: a, onMouseUp: r, onMouseEnter: M, onMouseLeave: d, onMouseMove: m, children: "function" == typeof s2 ? s2((o2) => {
7
- l && (l.remove(), l = null, o2 && o2());
8
- }) : s2 })), u = (e2) => (c(e2.isSingle || false).render(o.jsx(t, { ...e2 })), l), c = (o2) => (o2 && l && s || (l = document.createElement("div"), document.body.appendChild(l), s = e.createRoot(l)), s);
9
- export {
10
- u as i
11
- };
@@ -1,68 +0,0 @@
1
- import { j as e } from "./dependencies-CbQbPZZ-.js";
2
- import { useState as s, useRef as a, useMemo as o, useCallback as n, useEffect as t } from "react";
3
- import { c as r, g as c, a as l, b as i, d, e as u } from "./utils-BxXROOPY.js";
4
- const f = { info: { light: "#1677ff", dark: "#1677ff" }, success: { light: "#52c41a", dark: "#49aa19" }, error: { light: "#ff4d4f", dark: "#a61d24" }, warning: { light: "#faad14", dark: "#d89614" }, loading: { light: "#9254de", dark: "#f5f5f5" } }, m = (e2, s2) => f[e2][s2], g = (s2) => {
5
- switch (s2) {
6
- case "success":
7
- return e.jsx("svg", { className: "ono-type-icon", viewBox: "0 0 1024 1024", focusable: "false", "data-icon": "check-circle", fill: m(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" }) });
8
- case "error":
9
- return e.jsx("svg", { className: "ono-type-icon", viewBox: "0 0 1024 1024", focusable: "false", "data-icon": "close-circle", fill: m(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" }) });
10
- case "loading":
11
- return e.jsx("svg", { className: ["ono-info-icon", "ono-loading"].join(" "), viewBox: "0 0 1024 1024", focusable: "false", "data-icon": "loading", fill: m(s2, "light"), "aria-hidden": "true", children: e.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" }) });
12
- default:
13
- return e.jsx("svg", { className: "ono-info-icon", viewBox: "64 64 896 896", focusable: "false", "data-icon": "exclamation-circle", fill: m(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
- }, h = ({ handleDestroy: s2 }) => e.jsx("button", { onClick: s2, children: e.jsx("svg", { className: "ono-clear-icon", viewBox: "64 64 896 896", focusable: "false", "data-icon": "close-circle", fill: "currentColor", "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" }) }) }), p = ({ id: r2, instancesKey: f2, duration: m2 = 3e3, speed: p2 = 300, offset: y2 = 20, message: x2, type: j, plain: v = true, showClose: C = false, zIndex: w, onClose: z = () => {
16
- }, destroy: L }) => {
17
- const [, k] = s(false), [b, B] = s(0), [M, N] = s(c(r2)), [$, S] = s({ duration: m2, speed: p2, message: x2, type: j, showClose: C, onClose: z }), T = a(null), D = a(null), F = a(null), I = M + b, K = o(() => ({ transform: `translate(-50%, ${M}px)`, transition: `transform ${p2}ms ease-in-out`, zIndex: w }), [M, p2]), O = () => {
18
- F.current && (F.current.classList.remove("ono-message-enter"), F.current.classList.add("ono-message-leave"), F.current.style.transform = `translate(-50%, ${d(r2) - b}px)`, u(r2), setTimeout(() => L($.onClose), p2));
19
- }, q = (e2, s2, a2) => {
20
- "loading" !== e2 && (T.current = setTimeout(O, s2 - a2));
21
- }, A = () => {
22
- const e2 = d(r2);
23
- k((s2) => (s2 && N(e2 + y2), true)), requestAnimationFrame(A);
24
- }, E = n(() => {
25
- if ("loading" === $.type) {
26
- if (D.current) return;
27
- D.current = setTimeout(() => {
28
- D.current = null;
29
- const e2 = l(f2 || "");
30
- e2 && (((e3) => {
31
- S((s2) => ({ ...s2, ...e3 }));
32
- })({ ...e2 }), q($.type, e2.duration || $.duration, e2.speed || $.speed), E());
33
- }, 100);
34
- }
35
- }, [$]);
36
- return t(() => {
37
- q($.type, $.duration, $.speed), A(), E();
38
- }, [$.type, $.duration, $.speed]), t(() => {
39
- (() => {
40
- if (!F.current) return;
41
- const { height: e2 } = F.current.getBoundingClientRect();
42
- F.current.style.setProperty("--speed", `${$.speed}ms`), B(e2);
43
- })();
44
- }, [F]), t(() => {
45
- i(r2, { topOffset: M, height: b, bottomOffset: I });
46
- }, [I]), e.jsx("div", { ref: F, className: ["ono-message", `ono-message-${$.type}`, "ono-message-enter", v ? "" : "ono-message-color"].filter(Boolean).join(" "), style: K, onMouseEnter: () => {
47
- T.current && (clearTimeout(T.current), T.current = null);
48
- }, onMouseLeave: () => q($.type, $.duration, $.speed), children: "function" == typeof $.message ? $.message(g($.type), $.showClose && e.jsx(h, { handleDestroy: O })) : e.jsxs(e.Fragment, { children: [g($.type), e.jsx("div", { children: $.message }), $.showClose && e.jsx(h, { handleDestroy: O })] }) });
49
- }, y = (e2) => {
50
- if ("string" == typeof e2) return { message: e2 };
51
- {
52
- const s2 = { ...e2, instancesKey: e2.key };
53
- return delete s2.key, { ...s2 };
54
- }
55
- }, x = { info: (e2) => {
56
- r(p, { ...y(e2), type: "info" }, "ono-message");
57
- }, success: (e2) => {
58
- r(p, { ...y(e2), type: "success" }, "ono-message");
59
- }, warning: (e2) => {
60
- r(p, { ...y(e2), type: "warning" }, "ono-message");
61
- }, error: (e2) => {
62
- r(p, { ...y(e2), type: "error" }, "ono-message");
63
- }, loading: (e2) => {
64
- r(p, { ...y(e2), type: "loading" }, "ono-message");
65
- } };
66
- export {
67
- x as m
68
- };
@@ -1,65 +0,0 @@
1
- import { j as e } from "./dependencies-CbQbPZZ-.js";
2
- import { memo as t, useState as r, useMemo as i, useRef as n, useEffect as l } from "react";
3
- import { a } from "./hooks-Dew3_cmY.js";
4
- const s = t(({ containerClassName: t2, dataSource: s2, containerStyle: d2 = {}, onEndCallback: c, refreshSpeed: o = 50, wrapperClassName: h, wrapperStyle: u = {}, estimatedSize: p = 35, updateDataSourceScroll2Top: f, direction: g = "vertical" }) => {
5
- const [v, S] = r({ viewSize: 0, startIndex: 0, listSize: 0, renderCount: 0, prevLen: 0 }), [x, m] = r([]), z = "number" == typeof p ? p : p(), w = i(() => Math.min(s2.length, v.startIndex + v.renderCount), [s2, v]), I = i(() => {
6
- var _a;
7
- return v.startIndex > 0 ? (_a = x[v.startIndex - 1]) == null ? void 0 : _a.end : 0;
8
- }, [v.startIndex, x]), y = i(() => s2.slice(v.startIndex, w).map(({ id: t3, data: r2 }) => e.jsx("li", { "data-virtual-id": t3, style: "vertical" === g ? { width: "100%" } : { height: "100%" }, children: r2 }, t3)), [w, s2, v.startIndex, g]), C = i(() => ({ display: "flex", listStyle: "none", flexDirection: "vertical" === g ? "column" : "row", height: "vertical" === g ? v.listSize - I + "px" : "100%", width: "vertical" === g ? "auto" : v.listSize - I + "px", transform: "vertical" === g ? `translate3d(0, ${I}px, 0)` : `translate3d(${I}px, 0, 0)` }), [v.listSize, I, g]), j = n(null), L = n(null), N = (e2) => S((t3) => ({ ...t3, ...e2 })), b = /* @__PURE__ */ ((e2, t3 = 300) => {
9
- let r2 = 0;
10
- return () => {
11
- const i2 = Date.now();
12
- i2 - r2 >= t3 && (e2(), r2 = i2);
13
- };
14
- })(() => {
15
- const { scrollTop: e2, clientHeight: t3, scrollHeight: r2, scrollLeft: i2, clientWidth: n2, scrollWidth: l2 } = j.current, a2 = "vertical" === g ? r2 - t3 - e2 : l2 - n2 - i2;
16
- N({ startIndex: A(x, "vertical" === g ? e2 : i2) }), ("vertical" === g ? e2 === z / 2 : i2 === z / 2) && N({ startIndex: 0 }), a2 <= 20 && c && c();
17
- }, o), A = (e2, t3) => {
18
- let r2 = 0, i2 = e2.length - 1, n2 = -1;
19
- for (; r2 <= i2; ) {
20
- const l2 = r2 + Math.floor((i2 - r2) / 2), a2 = e2[l2].end;
21
- if (a2 === t3) return l2 + 1;
22
- a2 < t3 ? r2 = l2 + 1 : ((-1 === n2 || n2 > l2) && (n2 = l2), i2 = l2 - 1);
23
- }
24
- return n2;
25
- };
26
- return a("scroll", b, { target: j.current, deps: [x, g] }), l(() => {
27
- (() => {
28
- if (!j.current) return;
29
- const e2 = ("vertical" === g ? j.current.offsetHeight : j.current.offsetWidth) || 0;
30
- N({ viewSize: e2, renderCount: Math.ceil(e2 / z) + 1 });
31
- })();
32
- }, [j, g]), l(() => {
33
- s2.length && L && (() => {
34
- var _a;
35
- const e2 = [], t3 = s2.length - v.prevLen, r2 = t3 > 0 ? x.length : 0, i2 = r2 > 0 ? x[r2 - 1].end : 0;
36
- for (let r3 = 0; r3 < (t3 > 0 ? t3 : s2.length); r3++) {
37
- const n2 = s2[(t3 > 0 ? v.prevLen : 0) + r3];
38
- e2.push({ index: n2.id, size: z, start: i2 ? i2 + r3 * z : n2.id * z, end: i2 ? i2 + (r3 + 1) * z : (n2.id + 1) * z, dSize: 0 });
39
- }
40
- m((r3) => [...t3 > 0 ? r3 : [], ...e2]), N({ prevLen: s2.length }), f && ((_a = j.current) == null ? void 0 : _a.scrollTo(0, 0));
41
- })();
42
- }, [L, s2, f]), l(() => {
43
- (() => {
44
- if (!L.current || 0 === x.length) return;
45
- const e2 = Array.from(L.current.childNodes);
46
- if (!e2.length) return;
47
- e2.forEach((e3) => {
48
- const t4 = e3.getBoundingClientRect(), r3 = +e3.getAttribute("data-virtual-id"), i3 = x[r3], n2 = i3.size - ("vertical" === g ? t4.height : t4.width);
49
- n2 && (i3.size = "vertical" === g ? t4.height : t4.width, i3.end = i3.end - n2, i3.dSize = n2);
50
- });
51
- const t3 = +e2[0].getAttribute("data-virtual-id"), r2 = x.length;
52
- let i2 = x[t3].dSize;
53
- x[t3].dSize = 0;
54
- for (let e3 = t3 + 1; e3 < r2; e3++) {
55
- const t4 = x[e3];
56
- t4.start = x[e3 - 1].end, t4.end = t4.end - i2, t4.dSize && (i2 += t4.dSize, t4.dSize = 0);
57
- }
58
- N({ listSize: x[r2 - 1].end });
59
- })();
60
- }, [L, x, v.startIndex, g]), e.jsx("div", { ref: j, className: t2, style: { width: "100%", height: "100%", overflow: "auto", ...d2 }, children: e.jsx("ul", { ref: L, className: h, style: { ...C, ...u }, children: y }) });
61
- }), d = (e2, t2) => e2.map((e3, r2) => ({ id: r2, data: t2(e3, r2) }));
62
- export {
63
- s as E,
64
- d as c
65
- };
@@ -1,103 +0,0 @@
1
- import { useEffect as e, useState as t, useRef as n, useCallback as r } from "react";
2
- import { v as o } from "./utils-BxXROOPY.js";
3
- const i = (t2, n2, r2) => {
4
- const { target: o2, deps: i2, isDeferred: s2 } = r2 || {}, c2 = (e2) => n2(e2);
5
- return e(() => ("string" == typeof t2 ? !s2 && (o2 || window).addEventListener(t2, c2) : t2.forEach((e2) => !s2 && (o2 || window).addEventListener(e2, c2)), () => {
6
- "string" == typeof t2 ? (o2 || window).removeEventListener(t2, c2) : t2.forEach((e2) => (o2 || window).removeEventListener(e2, c2));
7
- }), [o2, ...i2 || []]), s2 ? () => {
8
- "string" == typeof t2 ? (o2 || window).addEventListener(t2, c2) : t2.forEach((e2) => (o2 || window).addEventListener(e2, c2));
9
- } : void 0;
10
- }, s = (e2, t2, n2) => i(((e3) => {
11
- const t3 = "string" == typeof e3 ? [e3] : e3;
12
- if (new Set(t3).size !== t3.length) throw new Error("there are duplicates in the event type");
13
- return t3;
14
- })((n2 == null ? void 0 : n2.event) || "click"), (n3) => {
15
- if (e2) if (e2 instanceof Array) e2.map((e3) => e3 instanceof HTMLElement ? e3 : e3.current).some((e3) => !!e3 && e3.contains(n3.target)) || t2(n3);
16
- else {
17
- const r2 = e2 instanceof HTMLElement ? e2 : e2.current;
18
- r2 && !r2.contains(n3.target) && t2(n3);
19
- }
20
- }, { deps: [e2, ...(n2 == null ? void 0 : n2.deps) || []] }), c = (o2 = 60, i2) => {
21
- const [s2, c2] = t(o2), [a2, l2] = t(false), d2 = n(null), u2 = r(() => l2(true), []), m2 = r(() => {
22
- l2(false), c2(o2), d2.current && (clearTimeout(d2.current), d2.current = null), i2 == null ? void 0 : i2();
23
- }, [o2, i2]);
24
- return e(() => {
25
- if (a2) return s2 > 0 ? d2.current = setTimeout(() => {
26
- c2((e2) => e2 - 1);
27
- }, 1e3) : m2(), () => {
28
- d2.current && (clearTimeout(d2.current), d2.current = null);
29
- };
30
- }, [a2, s2, m2]), [s2, u2, m2];
31
- }, a = (n2) => {
32
- const [r2, o2] = t({ w: 0, h: 0 }), i2 = new ResizeObserver((e2) => {
33
- for (const t2 of e2) o2({ w: t2.borderBoxSize[0].inlineSize, h: t2.borderBoxSize[0].blockSize });
34
- }), s2 = () => {
35
- if (n2 && "function" != typeof n2) i2.observe(n2 instanceof HTMLElement ? n2 : n2.current);
36
- else if (n2 && "function" == typeof n2) {
37
- const e2 = n2();
38
- i2.observe(e2 instanceof HTMLElement ? e2 : e2.current);
39
- } else o2({ w: window.innerWidth, h: window.innerHeight });
40
- };
41
- return e(() => (s2(), window.addEventListener("resize", s2), () => {
42
- if (window.removeEventListener("resize", s2), n2 && "function" != typeof n2) i2.unobserve(n2 instanceof HTMLElement ? n2 : n2.current);
43
- else if (n2 && "function" == typeof n2) {
44
- const e2 = n2();
45
- i2.unobserve(e2 instanceof HTMLElement ? e2 : e2.current);
46
- }
47
- }), [n2]), r2;
48
- }, l = (e2) => e2.toString().toLocaleLowerCase(), d = (e2, t2, n2) => {
49
- const r2 = (r3) => i(r3, (r4) => ((e3, n3, r5) => {
50
- e3.forEach((e4) => {
51
- if (e4.includes("+") && e4.length > 1) {
52
- const r6 = e4.split("+"), o2 = n3.ctrlKey && r6.includes("ctrl"), i2 = n3.shiftKey && r6.includes("shift"), s2 = n3.altKey && r6.includes("alt"), c2 = n3.metaKey && r6.includes("meta"), a2 = (n3.ctrlKey || n3.metaKey) && r6.includes("commandorcontrol");
53
- 2 === r6.length ? (o2 || i2 || s2 || c2 || a2) && n3.key.toLocaleLowerCase() === r6[r6.length - 1] && t2(n3, e4) : 3 === r6.length && (o2 && i2 || o2 && s2 || o2 && c2 || o2 && a2 || i2 && s2 || i2 && c2 || i2 && a2 || s2 && c2 || s2 && a2 || c2 && a2) && n3.key.toLocaleLowerCase() === r6[r6.length - 1] && t2(n3, e4);
54
- } else if (e4.includes(l(n3.key))) {
55
- if (r5) e4 === l(n3.key) && t2(n3, e4);
56
- else if (!(n3.ctrlKey || n3.metaKey || n3.shiftKey || n3.altKey)) return t2(n3, e4);
57
- }
58
- });
59
- })(e2 instanceof Array ? e2.map((e3) => l(e3)) : [l(e2)], r4, (n2 == null ? void 0 : n2.exactMatch) || false), { deps: [n2 == null ? void 0 : n2.target, ...(n2 == null ? void 0 : n2.deps) || []] });
60
- (n2 == null ? void 0 : n2.events) instanceof Array ? n2.events.forEach((e3) => r2(e3)) : r2((n2 == null ? void 0 : n2.events) || "keydown");
61
- };
62
- let u = false;
63
- const m = ({ theme: t2, onDark: n2, onLight: r2 }) => {
64
- const o2 = window.matchMedia("(prefers-color-scheme: dark)"), i2 = () => {
65
- o2.matches ? n2() : r2();
66
- };
67
- e(() => {
68
- (() => {
69
- switch (u && (u = false, o2.removeEventListener("change", i2)), t2) {
70
- case "light":
71
- r2();
72
- break;
73
- case "dark":
74
- n2();
75
- break;
76
- default:
77
- i2(), u = true, o2.addEventListener("change", i2);
78
- }
79
- })();
80
- }, [t2]);
81
- }, f = (e2) => {
82
- const { initTheme: r2 = "light", themeRules: i2 = (e3) => {
83
- e3 ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark");
84
- } } = e2 || Object.assign({}), [s2, c2] = t(r2), a2 = n(null);
85
- return m({ theme: s2, onDark: () => {
86
- a2.current ? o.changeThemeClipPathCircle({ element: a2.current, onChangeTheme: () => i2(true) }) : i2(true);
87
- }, onLight: () => {
88
- a2.current ? o.changeThemeClipPathCircle({ element: a2.current, onChangeTheme: () => i2(false) }) : i2(false);
89
- } }), [s2, ({ targetTheme: e3, element: t2, onChange: n2 }) => {
90
- a2.current = t2 || null, requestAnimationFrame(() => {
91
- n2 == null ? void 0 : n2(), c2(e3);
92
- });
93
- }];
94
- };
95
- export {
96
- i as a,
97
- d as b,
98
- s as c,
99
- c as d,
100
- m as e,
101
- f,
102
- a as u
103
- };