ono-react-element 0.0.10 → 0.0.12
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/LICENSE.md +21 -0
- package/dist/es/{AutoSliderList-Dy-otnYu.js → AutoSliderList-DCpCHe1X.js} +6 -6
- package/dist/es/InjunctiveBox-DsntB_UW.js +11 -0
- package/dist/es/{Input-Z3uL5-nj.js → Input-CYA8Q8B5.js} +26 -26
- package/dist/es/{Modal-C-c_S_VM.js → Modal-D4gV43Cy.js} +4 -4
- package/dist/es/{Select-y-aAIqxg.js → Select-CJuIMAoG.js} +6 -6
- package/dist/es/{TemplateDialog-fX7Ie-xU.js → TemplateDialog-DKEBuvXA.js} +13 -13
- package/dist/es/{Toast-BadlA1yD.js → Toast-DHu6WOZ0.js} +1 -1
- package/dist/es/Tooltip-Dj8ZeMVG.js +29 -0
- package/dist/es/{VirtualList-BeDq637Z.js → VirtualList-BBvdkGKk.js} +25 -25
- package/dist/es/{Waterfall-a_c3urjB.js → Waterfall-Ce9ZeKxm.js} +1 -1
- package/dist/es/index.js +117 -17
- package/dist/index.css +1 -1
- package/dist/style/Modal.css +1 -1
- package/dist/style/Select.css +1 -1
- package/dist/style/TemplateDialog.css +1 -1
- package/dist/style/Tooltip.css +1 -1
- package/dist/types/components/TemplateDialog/TemplateDialog.d.ts +1 -1
- package/dist/types/components/TemplateDialog/types.d.ts +1 -1
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useMouseClick.d.ts +8 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/umd/index.css +1 -1
- package/dist/umd/index.css.br +0 -0
- package/dist/umd/index.css.gz +0 -0
- package/dist/umd/index.umd.cjs +11 -5
- package/dist/umd/index.umd.cjs.br +0 -0
- package/dist/umd/index.umd.cjs.gz +0 -0
- package/package.json +57 -56
- package/dist/es/InjunctiveBox-D0V-K9Pn.js +0 -11
- package/dist/es/Tooltip-C5OFmxWo.js +0 -29
- package/dist/es/hooks-Dew3_cmY.js +0 -103
|
@@ -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,29 +0,0 @@
|
|
|
1
|
-
import { j as e } from "./dependencies-CbQbPZZ-.js";
|
|
2
|
-
import { createPopper as r } from "@popperjs/core";
|
|
3
|
-
import { useState as t, useRef as n, useEffect as o } from "react";
|
|
4
|
-
import { c } from "./hooks-Dew3_cmY.js";
|
|
5
|
-
let s = null, l = null;
|
|
6
|
-
const p = ({ children: p2, content: i, onOpenChange: u, trigger: a = "hover", placement: m = "top", popperOptions: d = {}, className: f, style: h, isShowArrow: w = true, sameWidth: x, autoAdjustOverflow: j = true }) => {
|
|
7
|
-
const [v, y] = t(false), g = n(null), k = n(null), b = (e2) => {
|
|
8
|
-
u == null ? void 0 : u(e2), y(e2);
|
|
9
|
-
};
|
|
10
|
-
return c(k, () => {
|
|
11
|
-
"click" !== a && "contextmenu" !== a || b(false);
|
|
12
|
-
}, { event: ["click", "contextmenu"], deps: [a, u] }), o(() => {
|
|
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, p2]), o(() => {
|
|
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] } }, x ? { 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: i instanceof Function ? i() : i }), w && e.jsx("div", { className: "ono-tooltip-popper-arrow", "data-popper-arrow": true })] }), e.jsx("div", { ref: k, children: p2 instanceof Function ? p2() : p2 })] });
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
p as T
|
|
29
|
-
};
|
|
@@ -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
|
-
};
|