@hokkiai/discord-emoji-selector 1.1.3 → 1.1.5
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/index.cjs +48 -42
- package/dist/index.js +48 -42
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -57,33 +57,33 @@ var import_react = require("react");
|
|
|
57
57
|
function useSkin({ pickerId }) {
|
|
58
58
|
const [skin, setSkin] = (0, import_react.useState)(0);
|
|
59
59
|
(0, import_react.useEffect)(() => {
|
|
60
|
-
|
|
60
|
+
let raf;
|
|
61
|
+
const loop = () => {
|
|
61
62
|
const newSkin = window["emojipicker-" + pickerId]?.skin;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}, 100);
|
|
63
|
+
setSkin(newSkin || 0);
|
|
64
|
+
raf = requestAnimationFrame(loop);
|
|
65
|
+
};
|
|
66
|
+
raf = requestAnimationFrame(loop);
|
|
67
67
|
return () => {
|
|
68
|
-
|
|
68
|
+
cancelAnimationFrame(raf);
|
|
69
69
|
};
|
|
70
|
-
}, [
|
|
70
|
+
}, [pickerId]);
|
|
71
71
|
return skin;
|
|
72
72
|
}
|
|
73
73
|
function useSearchValue({ pickerId }) {
|
|
74
74
|
const [searchValue, setSearchValue] = (0, import_react.useState)("");
|
|
75
75
|
(0, import_react.useEffect)(() => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
let raf;
|
|
77
|
+
const loop = () => {
|
|
78
|
+
const newSearchValue = window["emojipicker-" + pickerId]?.searchValue || "";
|
|
79
|
+
setSearchValue(newSearchValue);
|
|
80
|
+
raf = requestAnimationFrame(loop);
|
|
81
|
+
};
|
|
82
|
+
raf = requestAnimationFrame(loop);
|
|
83
83
|
return () => {
|
|
84
|
-
|
|
84
|
+
cancelAnimationFrame(raf);
|
|
85
85
|
};
|
|
86
|
-
}, [
|
|
86
|
+
}, [pickerId]);
|
|
87
87
|
return searchValue;
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -17122,7 +17122,6 @@ function SidebarCategory({
|
|
|
17122
17122
|
}) {
|
|
17123
17123
|
const searchValue = useSearchValue({ pickerId: id });
|
|
17124
17124
|
const [isActive, setIsActive] = (0, import_react5.useState)(false);
|
|
17125
|
-
const [scrollTop, setScrollTop] = (0, import_react5.useState)(0);
|
|
17126
17125
|
(0, import_react5.useEffect)(() => {
|
|
17127
17126
|
if ((searchValue || "").length > 0) {
|
|
17128
17127
|
setIsActive(false);
|
|
@@ -17136,16 +17135,18 @@ function SidebarCategory({
|
|
|
17136
17135
|
);
|
|
17137
17136
|
if (!header) return;
|
|
17138
17137
|
const categoryContainer = header.parentElement;
|
|
17139
|
-
const
|
|
17140
|
-
const scrollEnd = categoryContainer.offsetTop + categoryContainer.offsetHeight - header.offsetHeight * 5.5;
|
|
17141
|
-
const actualScroll = elem.querySelector(
|
|
17138
|
+
const scrollElem = elem.querySelector(
|
|
17142
17139
|
".HOKKIEMOJIPICKER-emojidisplay"
|
|
17143
|
-
)
|
|
17144
|
-
if (
|
|
17145
|
-
|
|
17146
|
-
|
|
17147
|
-
|
|
17148
|
-
|
|
17140
|
+
);
|
|
17141
|
+
if (!scrollElem) return;
|
|
17142
|
+
const containerRect = scrollElem.getBoundingClientRect();
|
|
17143
|
+
const categoryRect = categoryContainer.getBoundingClientRect();
|
|
17144
|
+
const headerHeight = header.offsetHeight;
|
|
17145
|
+
const categoryTop = categoryRect.top - containerRect.top + scrollElem.scrollTop;
|
|
17146
|
+
const categoryBottom = categoryTop + categoryContainer.offsetHeight;
|
|
17147
|
+
const sTop = scrollElem.scrollTop;
|
|
17148
|
+
const inView = sTop >= categoryTop - headerHeight && sTop < categoryBottom - headerHeight;
|
|
17149
|
+
setIsActive(inView);
|
|
17149
17150
|
};
|
|
17150
17151
|
elem.querySelector(".HOKKIEMOJIPICKER-emojidisplay").addEventListener("scroll", updateActive);
|
|
17151
17152
|
updateActive();
|
|
@@ -17153,28 +17154,34 @@ function SidebarCategory({
|
|
|
17153
17154
|
elem.querySelector(".HOKKIEMOJIPICKER-emojidisplay").removeEventListener("scroll", updateActive);
|
|
17154
17155
|
};
|
|
17155
17156
|
}, [picker, searchValue]);
|
|
17156
|
-
(0, import_react5.useEffect)(() => {
|
|
17157
|
-
const elem = picker.current;
|
|
17158
|
-
if (!elem) return;
|
|
17159
|
-
const header = elem.querySelector(
|
|
17160
|
-
".HOKKIEMOJIPICKER-categoryHeader." + categoryName
|
|
17161
|
-
);
|
|
17162
|
-
const categoryContainer = header.parentElement;
|
|
17163
|
-
const scrollTop2 = categoryContainer.offsetTop - header.offsetHeight * 5.5;
|
|
17164
|
-
setScrollTop(scrollTop2);
|
|
17165
|
-
}, []);
|
|
17166
17157
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
17167
17158
|
"button",
|
|
17168
17159
|
{
|
|
17169
17160
|
onClick: () => {
|
|
17170
17161
|
const elem = picker.current;
|
|
17162
|
+
if (!elem) return;
|
|
17163
|
+
const doScroll = () => {
|
|
17164
|
+
const header = elem.querySelector(
|
|
17165
|
+
".HOKKIEMOJIPICKER-categoryHeader." + categoryName
|
|
17166
|
+
);
|
|
17167
|
+
if (!header) return;
|
|
17168
|
+
const categoryContainer = header.parentElement;
|
|
17169
|
+
const scrollElem = elem.querySelector(
|
|
17170
|
+
".HOKKIEMOJIPICKER-emojidisplay"
|
|
17171
|
+
);
|
|
17172
|
+
if (!scrollElem) return;
|
|
17173
|
+
const containerRect = scrollElem.getBoundingClientRect();
|
|
17174
|
+
const categoryRect = categoryContainer.getBoundingClientRect();
|
|
17175
|
+
const headerHeight = header.offsetHeight;
|
|
17176
|
+
const targetTop = categoryRect.top - containerRect.top + scrollElem.scrollTop - headerHeight;
|
|
17177
|
+
scrollElem.scrollTo({ top: Math.max(0, targetTop), behavior: "smooth" });
|
|
17178
|
+
};
|
|
17171
17179
|
if ((searchValue || "").length > 0) {
|
|
17172
17180
|
window["emojipicker-" + id].setSearchValue("");
|
|
17173
|
-
setTimeout(
|
|
17174
|
-
|
|
17175
|
-
|
|
17181
|
+
setTimeout(doScroll, 50);
|
|
17182
|
+
} else {
|
|
17183
|
+
doScroll();
|
|
17176
17184
|
}
|
|
17177
|
-
elem.querySelector(".HOKKIEMOJIPICKER-emojidisplay").scrollTop = scrollTop;
|
|
17178
17185
|
},
|
|
17179
17186
|
"data-active": isActive ? "true" : "false",
|
|
17180
17187
|
className: "!outline-0 HOKKIEMOJIPICKER-sidebarButton cursor-pointer size-8 data-[active=true]:bg-white/5 hover:bg-white/10 overflow-hidden *:!size-6.5 transition-all hover:*:!opacity-85 data-[active=true]:*:!opacity-100 flex items-center justify-center rounded-sm *:opacity-50",
|
|
@@ -17522,7 +17529,6 @@ function EmojiSelector({
|
|
|
17522
17529
|
const navHeight = showNav ? Math.floor(height / 7) : 0;
|
|
17523
17530
|
const id = Math.random().toString(36).substring(2, 15);
|
|
17524
17531
|
const picker = (0, import_react7.useRef)(null);
|
|
17525
|
-
console.log(id);
|
|
17526
17532
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "HOKKIEMOJIPICKER-emojiContainer", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
17527
17533
|
"div",
|
|
17528
17534
|
{
|
package/dist/index.js
CHANGED
|
@@ -23,33 +23,33 @@ import { useEffect, useState } from "react";
|
|
|
23
23
|
function useSkin({ pickerId }) {
|
|
24
24
|
const [skin, setSkin] = useState(0);
|
|
25
25
|
useEffect(() => {
|
|
26
|
-
|
|
26
|
+
let raf;
|
|
27
|
+
const loop = () => {
|
|
27
28
|
const newSkin = window["emojipicker-" + pickerId]?.skin;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, 100);
|
|
29
|
+
setSkin(newSkin || 0);
|
|
30
|
+
raf = requestAnimationFrame(loop);
|
|
31
|
+
};
|
|
32
|
+
raf = requestAnimationFrame(loop);
|
|
33
33
|
return () => {
|
|
34
|
-
|
|
34
|
+
cancelAnimationFrame(raf);
|
|
35
35
|
};
|
|
36
|
-
}, [
|
|
36
|
+
}, [pickerId]);
|
|
37
37
|
return skin;
|
|
38
38
|
}
|
|
39
39
|
function useSearchValue({ pickerId }) {
|
|
40
40
|
const [searchValue, setSearchValue] = useState("");
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
let raf;
|
|
43
|
+
const loop = () => {
|
|
44
|
+
const newSearchValue = window["emojipicker-" + pickerId]?.searchValue || "";
|
|
45
|
+
setSearchValue(newSearchValue);
|
|
46
|
+
raf = requestAnimationFrame(loop);
|
|
47
|
+
};
|
|
48
|
+
raf = requestAnimationFrame(loop);
|
|
49
49
|
return () => {
|
|
50
|
-
|
|
50
|
+
cancelAnimationFrame(raf);
|
|
51
51
|
};
|
|
52
|
-
}, [
|
|
52
|
+
}, [pickerId]);
|
|
53
53
|
return searchValue;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -17088,7 +17088,6 @@ function SidebarCategory({
|
|
|
17088
17088
|
}) {
|
|
17089
17089
|
const searchValue = useSearchValue({ pickerId: id });
|
|
17090
17090
|
const [isActive, setIsActive] = useState5(false);
|
|
17091
|
-
const [scrollTop, setScrollTop] = useState5(0);
|
|
17092
17091
|
useEffect5(() => {
|
|
17093
17092
|
if ((searchValue || "").length > 0) {
|
|
17094
17093
|
setIsActive(false);
|
|
@@ -17102,16 +17101,18 @@ function SidebarCategory({
|
|
|
17102
17101
|
);
|
|
17103
17102
|
if (!header) return;
|
|
17104
17103
|
const categoryContainer = header.parentElement;
|
|
17105
|
-
const
|
|
17106
|
-
const scrollEnd = categoryContainer.offsetTop + categoryContainer.offsetHeight - header.offsetHeight * 5.5;
|
|
17107
|
-
const actualScroll = elem.querySelector(
|
|
17104
|
+
const scrollElem = elem.querySelector(
|
|
17108
17105
|
".HOKKIEMOJIPICKER-emojidisplay"
|
|
17109
|
-
)
|
|
17110
|
-
if (
|
|
17111
|
-
|
|
17112
|
-
|
|
17113
|
-
|
|
17114
|
-
|
|
17106
|
+
);
|
|
17107
|
+
if (!scrollElem) return;
|
|
17108
|
+
const containerRect = scrollElem.getBoundingClientRect();
|
|
17109
|
+
const categoryRect = categoryContainer.getBoundingClientRect();
|
|
17110
|
+
const headerHeight = header.offsetHeight;
|
|
17111
|
+
const categoryTop = categoryRect.top - containerRect.top + scrollElem.scrollTop;
|
|
17112
|
+
const categoryBottom = categoryTop + categoryContainer.offsetHeight;
|
|
17113
|
+
const sTop = scrollElem.scrollTop;
|
|
17114
|
+
const inView = sTop >= categoryTop - headerHeight && sTop < categoryBottom - headerHeight;
|
|
17115
|
+
setIsActive(inView);
|
|
17115
17116
|
};
|
|
17116
17117
|
elem.querySelector(".HOKKIEMOJIPICKER-emojidisplay").addEventListener("scroll", updateActive);
|
|
17117
17118
|
updateActive();
|
|
@@ -17119,28 +17120,34 @@ function SidebarCategory({
|
|
|
17119
17120
|
elem.querySelector(".HOKKIEMOJIPICKER-emojidisplay").removeEventListener("scroll", updateActive);
|
|
17120
17121
|
};
|
|
17121
17122
|
}, [picker, searchValue]);
|
|
17122
|
-
useEffect5(() => {
|
|
17123
|
-
const elem = picker.current;
|
|
17124
|
-
if (!elem) return;
|
|
17125
|
-
const header = elem.querySelector(
|
|
17126
|
-
".HOKKIEMOJIPICKER-categoryHeader." + categoryName
|
|
17127
|
-
);
|
|
17128
|
-
const categoryContainer = header.parentElement;
|
|
17129
|
-
const scrollTop2 = categoryContainer.offsetTop - header.offsetHeight * 5.5;
|
|
17130
|
-
setScrollTop(scrollTop2);
|
|
17131
|
-
}, []);
|
|
17132
17123
|
return /* @__PURE__ */ jsx5(
|
|
17133
17124
|
"button",
|
|
17134
17125
|
{
|
|
17135
17126
|
onClick: () => {
|
|
17136
17127
|
const elem = picker.current;
|
|
17128
|
+
if (!elem) return;
|
|
17129
|
+
const doScroll = () => {
|
|
17130
|
+
const header = elem.querySelector(
|
|
17131
|
+
".HOKKIEMOJIPICKER-categoryHeader." + categoryName
|
|
17132
|
+
);
|
|
17133
|
+
if (!header) return;
|
|
17134
|
+
const categoryContainer = header.parentElement;
|
|
17135
|
+
const scrollElem = elem.querySelector(
|
|
17136
|
+
".HOKKIEMOJIPICKER-emojidisplay"
|
|
17137
|
+
);
|
|
17138
|
+
if (!scrollElem) return;
|
|
17139
|
+
const containerRect = scrollElem.getBoundingClientRect();
|
|
17140
|
+
const categoryRect = categoryContainer.getBoundingClientRect();
|
|
17141
|
+
const headerHeight = header.offsetHeight;
|
|
17142
|
+
const targetTop = categoryRect.top - containerRect.top + scrollElem.scrollTop - headerHeight;
|
|
17143
|
+
scrollElem.scrollTo({ top: Math.max(0, targetTop), behavior: "smooth" });
|
|
17144
|
+
};
|
|
17137
17145
|
if ((searchValue || "").length > 0) {
|
|
17138
17146
|
window["emojipicker-" + id].setSearchValue("");
|
|
17139
|
-
setTimeout(
|
|
17140
|
-
|
|
17141
|
-
|
|
17147
|
+
setTimeout(doScroll, 50);
|
|
17148
|
+
} else {
|
|
17149
|
+
doScroll();
|
|
17142
17150
|
}
|
|
17143
|
-
elem.querySelector(".HOKKIEMOJIPICKER-emojidisplay").scrollTop = scrollTop;
|
|
17144
17151
|
},
|
|
17145
17152
|
"data-active": isActive ? "true" : "false",
|
|
17146
17153
|
className: "!outline-0 HOKKIEMOJIPICKER-sidebarButton cursor-pointer size-8 data-[active=true]:bg-white/5 hover:bg-white/10 overflow-hidden *:!size-6.5 transition-all hover:*:!opacity-85 data-[active=true]:*:!opacity-100 flex items-center justify-center rounded-sm *:opacity-50",
|
|
@@ -17488,7 +17495,6 @@ function EmojiSelector({
|
|
|
17488
17495
|
const navHeight = showNav ? Math.floor(height / 7) : 0;
|
|
17489
17496
|
const id = Math.random().toString(36).substring(2, 15);
|
|
17490
17497
|
const picker = useRef2(null);
|
|
17491
|
-
console.log(id);
|
|
17492
17498
|
return /* @__PURE__ */ jsx7("div", { className: "HOKKIEMOJIPICKER-emojiContainer", children: /* @__PURE__ */ jsxs6(
|
|
17493
17499
|
"div",
|
|
17494
17500
|
{
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hokkiai/discord-emoji-selector",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "A lightweight & powerful discord-style emoji picker",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
|
-
"homepage": "https://github.com/
|
|
7
|
+
"homepage": "https://github.com/hokkiai/discord-emoji-selector",
|
|
8
8
|
"module": "dist/index.js",
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"keywords": [
|
|
@@ -28,9 +28,6 @@
|
|
|
28
28
|
"files": [
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
|
-
"scripts": {
|
|
32
|
-
"build": "tsup src/index.tsx --dts --format esm,cjs"
|
|
33
|
-
},
|
|
34
31
|
"peerDependencies": {
|
|
35
32
|
"react": ">=18"
|
|
36
33
|
},
|
|
@@ -44,5 +41,8 @@
|
|
|
44
41
|
"@types/react": "^19.1.10",
|
|
45
42
|
"tsup": "^8.5.0",
|
|
46
43
|
"typescript": "^5.9.2"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup src/index.tsx --dts --format esm,cjs"
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
}
|