@ichaingo/header 1.3.80 → 1.3.82

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.
@@ -0,0 +1,23 @@
1
+ 'use client';
2
+ import { jsx as r } from "react/jsx-runtime";
3
+ import o from "@ichaingo/image";
4
+ import t from "@ichaingo/link";
5
+ import { twMerge as e } from "tailwind-merge";
6
+ function p() {
7
+ return /* @__PURE__ */ r(t, { suppressHydrationWarning: !0, href: "/", baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL, className: e(
8
+ "w-auto shrink-0 block"
9
+ ), children: /* @__PURE__ */ r(
10
+ o,
11
+ {
12
+ src: "https://cdn.ichaingo.com/uploads/logo_20250526_9aa337bef7.png",
13
+ width: 116,
14
+ height: 32,
15
+ alt: "logo",
16
+ objectFit: "contain",
17
+ priority: !0
18
+ }
19
+ ) });
20
+ }
21
+ export {
22
+ p as default
23
+ };
@@ -0,0 +1,325 @@
1
+ 'use client';
2
+ import { jsx as e, jsxs as a, Fragment as C } from "react/jsx-runtime";
3
+ import h from "@ichaingo/link";
4
+ import { DropdownMenu as z, DropdownMenuTrigger as M, DropdownMenuContent as X, DropdownMenuGroup as K, DropdownMenuItem as $ } from "@ichaingo/ui/dropdown-menu";
5
+ import d from "@ichaingo/translation";
6
+ import { useState as b, useMemo as O, useEffect as w, useCallback as N } from "react";
7
+ import y from "@ichaingo/better-link";
8
+ import { useLocale as v, useTranslations as k } from "next-intl";
9
+ import U from "@ichaingo/avatar";
10
+ import { logout as G, fetchUserProfile as F } from "@ichaingo/auth";
11
+ import { twMerge as m } from "tailwind-merge";
12
+ import { Accordion as E, AccordionItem as T, AccordionTrigger as P, AccordionContent as j } from "@ichaingo/ui/accordion";
13
+ import q from "@ichaingo/iconfont";
14
+ import { Popover as Q, PopoverTrigger as V, PopoverContent as W } from "@ichaingo/ui/popover";
15
+ import { PopoverArrow as J } from "@radix-ui/react-popover";
16
+ import { useSearchParams as Y, usePathname as R } from "next/navigation";
17
+ import Z from "@ichaingo/theme-toggle";
18
+ import { o as I, c as ee, U as L } from "./index-6LC2FFG_.js";
19
+ import le from "rc-drawer";
20
+ import { Menu as re, X as te } from "lucide-react";
21
+ function ne({
22
+ userInfo: r
23
+ }) {
24
+ const { gotoLogin: l } = y(), [n, t] = b(""), i = v(), o = O(() => r == null ? void 0 : r.id, [r]);
25
+ return w(() => {
26
+ t(l({
27
+ locale: i,
28
+ redirect: window.location.href
29
+ }));
30
+ }, [i, l]), o ? (
31
+ // userInfo?.profileUrl
32
+ // https://images.ichaingo.com/user-profile/100000201.png
33
+ /* @__PURE__ */ e(U, { userInfo: r, className: "w-8 h-8" })
34
+ ) : /* @__PURE__ */ e(
35
+ h,
36
+ {
37
+ href: n,
38
+ className: "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
39
+ replace: !0,
40
+ children: /* @__PURE__ */ e(d, { value: "signIn", parentKey: "account" })
41
+ }
42
+ );
43
+ }
44
+ function S({ className: r }) {
45
+ const l = N(async () => {
46
+ await G();
47
+ }, []);
48
+ return /* @__PURE__ */ e(
49
+ "button",
50
+ {
51
+ onClick: l,
52
+ className: m("cursor-pointer relative", r),
53
+ children: /* @__PURE__ */ e(d, { value: "logout", parentKey: "account" })
54
+ }
55
+ );
56
+ }
57
+ function ae({
58
+ list: r,
59
+ userInfo: l,
60
+ onClick: n
61
+ }) {
62
+ return /* @__PURE__ */ a(z, { children: [
63
+ /* @__PURE__ */ e(M, { className: "outline-none cursor-pointer", children: /* @__PURE__ */ e(ne, { userInfo: l }) }),
64
+ /* @__PURE__ */ e(X, { align: "end", className: "z-2000 w-75 p-0 border-transparent outline-none border border-stroke", children: /* @__PURE__ */ a(K, { className: "flex flex-col gap-2 p-3 bg-module rounded-md", children: [
65
+ /* @__PURE__ */ e("div", { className: "flex flex-col gap-3 w-full bg-background rounded-lg p-2", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
66
+ /* @__PURE__ */ e(U, { userInfo: l, className: "w-8 h-8" }),
67
+ /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
68
+ /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: (l == null ? void 0 : l.username) || "--" }),
69
+ /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground w-full truncate", children: (l == null ? void 0 : l.email) || (l == null ? void 0 : l.walletAddress) })
70
+ ] })
71
+ ] }) }),
72
+ r.map((t) => /* @__PURE__ */ e($, { className: "px-0 py-0 focus-visible:border-none focus-visible:outline-none", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 w-full", children: t.name === "logout" ? /* @__PURE__ */ e(S, { className: "flex-1 flex py-3 border-t border-stroke w-full px-2 hover:bg-background" }) : /* @__PURE__ */ e(h, { href: `/${t.href}`, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, className: "flex-1 flex py-3 h-full w-full px-2 hover:bg-background rounded-lg ", onClick: n, children: /* @__PURE__ */ e(d, { value: t.name, parentKey: "account" }) }) }) }, t.name))
73
+ ] }) })
74
+ ] });
75
+ }
76
+ function se({
77
+ list: r,
78
+ userInfo: l,
79
+ onClick: n
80
+ }) {
81
+ return /* @__PURE__ */ e(
82
+ E,
83
+ {
84
+ type: "single",
85
+ collapsible: !0,
86
+ className: "w-full",
87
+ defaultValue: "",
88
+ children: /* @__PURE__ */ a(T, { value: "item-1", className: "p-0 w-full border border-none", children: [
89
+ /* @__PURE__ */ e(P, { className: "w-full bg-background p-3 flex items-center justify-between", children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-3 w-full overflow-hidden", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
90
+ /* @__PURE__ */ e(U, { userInfo: l, className: "w-8 h-8 shrink-0" }),
91
+ /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
92
+ /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: l == null ? void 0 : l.username }),
93
+ /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground w-full truncate", children: (l == null ? void 0 : l.email) || (l == null ? void 0 : l.walletAddress) })
94
+ ] })
95
+ ] }) }) }),
96
+ /* @__PURE__ */ e(j, { className: "flex text-sm flex-col text-balance bg-background rounded-lg p-3 gap-3 mt-[10px]", children: /* @__PURE__ */ e("dl", { children: r.map((t) => /* @__PURE__ */ e(
97
+ "dd",
98
+ {
99
+ className: "flex justify-start items-center gap-2 py-2",
100
+ children: /* @__PURE__ */ e(h, { href: `/${t.href}`, className: "flex-1 py-2", onClick: n, suppressHydrationWarning: !0, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, children: /* @__PURE__ */ e(d, { value: t.name, parentKey: "account" }) })
101
+ },
102
+ t.name
103
+ )) }) })
104
+ ] })
105
+ }
106
+ );
107
+ }
108
+ function B({ onClick: r = () => {
109
+ }, className: l }) {
110
+ const n = v(), { gotoLogin: t } = y(), [i, o] = b("");
111
+ return w(() => {
112
+ o(t({
113
+ locale: n,
114
+ redirect: window.location.href
115
+ }));
116
+ }, [n, t]), /* @__PURE__ */ e(
117
+ h,
118
+ {
119
+ href: i,
120
+ onClick: r,
121
+ baseUrl: process.env.NEXT_PUBLIC_AUTH_URL,
122
+ replace: !0,
123
+ className: m(
124
+ "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
125
+ l
126
+ ),
127
+ children: /* @__PURE__ */ e(d, { value: "signIn", parentKey: "account" })
128
+ }
129
+ );
130
+ }
131
+ const _ = [
132
+ {
133
+ name: "overview",
134
+ href: "user-center"
135
+ },
136
+ {
137
+ name: "collect",
138
+ href: "user-center/collect"
139
+ },
140
+ {
141
+ name: "privateLabel",
142
+ href: "user-center/private-label"
143
+ },
144
+ {
145
+ name: "setting",
146
+ href: "user-center/setting"
147
+ },
148
+ {
149
+ name: "logout",
150
+ href: void 0
151
+ }
152
+ ];
153
+ function ie({ onClick: r = (t) => {
154
+ }, className: l, userInfo: n }) {
155
+ return console.log("userInfo", n), n != null && n.id ? /* @__PURE__ */ a(C, { children: [
156
+ /* @__PURE__ */ e("div", { className: m("hidden md:flex items-center", l), children: /* @__PURE__ */ e(ae, { list: _, userInfo: n, onClick: r }) }),
157
+ /* @__PURE__ */ e("div", { className: m("block md:hidden w-full", l), children: /* @__PURE__ */ e(se, { list: _.filter((t) => t.href), userInfo: n, onClick: r }) })
158
+ ] }) : /* @__PURE__ */ e(B, { onClick: r, className: m(
159
+ "hidden md:flex cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
160
+ "order-3"
161
+ ) });
162
+ }
163
+ function A({ onClick: r = () => {
164
+ } }) {
165
+ var u;
166
+ const l = v(), n = Y(), t = k("lang"), i = k("setting"), o = [
167
+ { name: t("en"), lang: "en" },
168
+ { name: t("zh-hant"), lang: "zh-hant" },
169
+ { name: t("zh-hans"), lang: "zh-hans" },
170
+ { name: t("ja"), lang: "ja" },
171
+ { name: t("ko"), lang: "ko" }
172
+ ], s = R(), g = N(
173
+ (c) => {
174
+ const x = s.replace(new RegExp(`/${l}(/|$)`), `/${c}$1`), f = n.toString();
175
+ return f ? `${x}?${f}` : x;
176
+ },
177
+ [s, l, n]
178
+ );
179
+ return /* @__PURE__ */ a("div", { className: "text-sm gap-2 flex flex-col justify-start items-start md:py-2", children: [
180
+ /* @__PURE__ */ e("div", { className: "flex w-full justify-between items-center", children: /* @__PURE__ */ e(E, { type: "single", className: "flex-1", collapsible: !0, children: /* @__PURE__ */ a(T, { value: l, className: "border-0", children: [
181
+ /* @__PURE__ */ e(P, { className: "p-2 bg-background rounded-lg h-11 md:h-auto text-gray-500 w-full flex py-2 justify-between items-center hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0", children: /* @__PURE__ */ a("div", { className: "flex w-full justify-between items-center", children: [
182
+ /* @__PURE__ */ e("span", { className: "text-title", children: i("language") }),
183
+ /* @__PURE__ */ e("span", { className: "text-title", children: (u = o.find((c) => c.lang === l)) == null ? void 0 : u.name })
184
+ ] }) }),
185
+ /* @__PURE__ */ e(j, { className: "bg-background mt-3 rounded-lg flex flex-col gap-2", children: o.map((c) => /* @__PURE__ */ e(
186
+ h,
187
+ {
188
+ prefetch: !1,
189
+ withLocale: !1,
190
+ className: m(
191
+ "p-2 rounded-lg flex w-full justify-between items-center",
192
+ l === c.lang ? "text-primary" : ""
193
+ ),
194
+ href: g(c.lang),
195
+ onClick: r,
196
+ children: c.name
197
+ },
198
+ c.lang
199
+ )) })
200
+ ] }) }) }),
201
+ /* @__PURE__ */ a("div", { className: "bg-background p-2 rounded-lg h-11 md:h-auto flex w-full justify-between items-center", children: [
202
+ /* @__PURE__ */ e("div", { children: i("theme") }),
203
+ /* @__PURE__ */ e(Z, {})
204
+ ] })
205
+ ] });
206
+ }
207
+ function oe({ onClick: r = () => {
208
+ } }) {
209
+ return /* @__PURE__ */ a("div", { className: "w-full md:w-auto order-3 md:order-0", children: [
210
+ /* @__PURE__ */ e("div", { className: "hidden md:flex items-center bg-module rounded-lg p-1.5 cursor-pointer", children: /* @__PURE__ */ a(Q, { children: [
211
+ /* @__PURE__ */ e(V, { asChild: !0, children: /* @__PURE__ */ e(q, { type: "icon-setting", className: "text-2xl" }) }),
212
+ /* @__PURE__ */ a(
213
+ W,
214
+ {
215
+ side: "bottom",
216
+ className: "relative top-[10px] rounded-xl border border-stroke bg-module p-2 w-72 z-1000",
217
+ children: [
218
+ /* @__PURE__ */ e(J, { className: "fill-module" }),
219
+ /* @__PURE__ */ e(A, { onClick: r })
220
+ ]
221
+ }
222
+ )
223
+ ] }) }),
224
+ /* @__PURE__ */ e("div", { className: "md:hidden", children: /* @__PURE__ */ e(A, {}) })
225
+ ] });
226
+ }
227
+ function H({ onClick: r = () => {
228
+ }, hideNews: l = !1, hideLogin: n = !1, user: t }) {
229
+ const { gotoAISQL: i, gotoChat: o } = y(), s = v(), g = R(), [u, c] = b(t), x = [
230
+ {
231
+ baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
232
+ href: "/explorer",
233
+ key: "/explorer",
234
+ label: /* @__PURE__ */ e("span", { className: "whitespace-nowrap leading-11 md:leading-[34px]", children: /* @__PURE__ */ e(d, { value: "title", parentKey: "browser" }) })
235
+ },
236
+ {
237
+ baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
238
+ href: o({ locale: s }),
239
+ key: "/chat",
240
+ label: /* @__PURE__ */ a("span", { className: "whitespace-nowrap leading-11 md:leading-[34px]", children: [
241
+ /* @__PURE__ */ e("span", { role: "img", "aria-label": "hot", children: "🔥" }),
242
+ /* @__PURE__ */ e("span", { children: "iGoChat" })
243
+ ] })
244
+ },
245
+ {
246
+ baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
247
+ href: i({ locale: s }),
248
+ key: "/sql",
249
+ label: "AISQL"
250
+ },
251
+ {
252
+ baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
253
+ href: "/etf/btc-us",
254
+ key: "/etf",
255
+ label: /* @__PURE__ */ e(d, { value: "etf", parentKey: "menu" })
256
+ },
257
+ {
258
+ baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
259
+ href: "/news",
260
+ key: "/news",
261
+ label: /* @__PURE__ */ e(d, { value: "news", parentKey: "menu" })
262
+ },
263
+ {
264
+ baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
265
+ href: "/ranking/token",
266
+ key: "/ranking",
267
+ label: /* @__PURE__ */ e(d, { value: "ranking", parentKey: "menu" })
268
+ }
269
+ ].filter((p) => l ? !["/explorer", "/chat", "/sql"].includes(p.key) : !0), f = N(() => {
270
+ F().then((p) => {
271
+ c(p);
272
+ });
273
+ }, []);
274
+ return w(() => (I(L.PROFILE_UPDATED, f), () => {
275
+ ee(L.PROFILE_UPDATED, f);
276
+ }), []), /* @__PURE__ */ a(
277
+ "nav",
278
+ {
279
+ className: m(
280
+ "flex flex-col justify-start items-start md:px-3",
281
+ "md:flex-row md:justify-end md:items-start md:px-0",
282
+ "md:gap-6"
283
+ ),
284
+ children: [
285
+ /* @__PURE__ */ e(
286
+ "ul",
287
+ {
288
+ className: m(
289
+ "flex flex-col justify-start items-start w-full h-full text-sm leading-[44px] z-1001 text-title",
290
+ "md:flex-row md:items-center md:w-auto md:h-[34px] md:leading-[34px] md:gap-6",
291
+ "order-2 md:order-0"
292
+ ),
293
+ children: x.map((p, D) => /* @__PURE__ */ e("li", { className: m("w-full md:w-auto h-11 md:h-auto cursor-pointer", g.includes(p.key) && "border-b-2 border-primary text-primary "), children: /* @__PURE__ */ e(h, { href: p.href, onClick: r, className: "h-full flex items-center justify-start", baseUrl: p.baseUrl, suppressHydrationWarning: !0, children: p.label }) }, D))
294
+ }
295
+ ),
296
+ /* @__PURE__ */ e(oe, { onClick: r }),
297
+ !g.includes("/login") && !n ? /* @__PURE__ */ a(C, { children: [
298
+ /* @__PURE__ */ e(ie, { onClick: r, userInfo: u }),
299
+ u != null && u.id ? /* @__PURE__ */ e("div", { className: "flex md:hidden h-11 md:h-auto cursor-pointer whitespace-nowrap order-3 bg-background rounded-lg p-2 mt-3 w-full items-center justify-center text-subtitle", children: /* @__PURE__ */ e(S, {}) }) : /* @__PURE__ */ e(B, { onClick: r, className: "flex md:hidden h-11 cursor-pointer whitespace-nowrap order-3 bg-primary text-white rounded-lg p-2 mt-3 w-full items-center justify-center" })
300
+ ] }) : null
301
+ ]
302
+ }
303
+ );
304
+ }
305
+ function ce({ hideLogin: r, hideNews: l, user: n }) {
306
+ const [t, i] = b(!1);
307
+ if (!t)
308
+ return /* @__PURE__ */ e(re, { onClick: () => i(!0), size: 32, style: { color: "var(--title)" }, className: "md:hidden ml-2.5 bg-module rounded-lg p-[4px] " });
309
+ const o = (s) => {
310
+ s == null || s.preventDefault(), s == null || s.stopPropagation(), i(!1);
311
+ };
312
+ return /* @__PURE__ */ e(le, { open: t, placement: "right", className: "block md:hidden fixed top-0 bottom-0 left-0 right-0 z-1001 bg-background p-2", children: /* @__PURE__ */ a("div", { className: "w-full max-h-full overflow-y-auto p-3 bg-module rounded-lg", children: [
313
+ /* @__PURE__ */ e("div", { className: "flex justify-end items-center p-2", children: /* @__PURE__ */ e(te, { size: 24, style: { color: "var(--title)" }, onClick: (s) => o(s) }) }),
314
+ /* @__PURE__ */ e(H, { onClick: (s) => o(s), hideLogin: r, hideNews: l, user: n })
315
+ ] }) });
316
+ }
317
+ function Ee({ hideNews: r, hideLogin: l, user: n }) {
318
+ return /* @__PURE__ */ a("div", { className: "flex justify-end items-center md:gap-10 z-1001 ", children: [
319
+ /* @__PURE__ */ e(ce, { hideLogin: l, hideNews: r, user: n }),
320
+ /* @__PURE__ */ e("div", { className: "hidden md:block", children: /* @__PURE__ */ e(H, { hideNews: r, hideLogin: l, user: n }) })
321
+ ] });
322
+ }
323
+ export {
324
+ Ee as default
325
+ };
@@ -0,0 +1,54 @@
1
+ import { jsxs as o, jsx as a } from "react/jsx-runtime";
2
+ import { twMerge as d } from "tailwind-merge";
3
+ import l from "@ichaingo/request";
4
+ import c from "next/dynamic";
5
+ const g = {
6
+ PROFILE_UPDATED: "user-profile-updated",
7
+ LOGGED_IN: "user-logged-in",
8
+ LOGGED_OUT: "user-logged-out"
9
+ };
10
+ function w(e, t) {
11
+ const s = new CustomEvent(e, { detail: t });
12
+ window.dispatchEvent(s);
13
+ }
14
+ function h(e, t) {
15
+ const s = (r) => {
16
+ t(r.detail);
17
+ };
18
+ return window.addEventListener(e, s), () => window.removeEventListener(e, s);
19
+ }
20
+ function U(e, t) {
21
+ window.removeEventListener(e, t);
22
+ }
23
+ const m = c(() => import("./Right-Bp1kiuv-.js"), { ssr: !1 }), u = c(() => import("./Logo-BwpYr4IY.js"), { ssr: !1 });
24
+ async function x({ extra: e, children: t, className: s, hideNews: r, hideLogin: i }) {
25
+ let n = {
26
+ data: {}
27
+ };
28
+ try {
29
+ n = await l.get("/v2/users/profile", {
30
+ baseURL: process.env.ICHAINGO_AUTH_INNER_API_URL
31
+ });
32
+ } catch {
33
+ n = {
34
+ data: {}
35
+ };
36
+ }
37
+ return /* @__PURE__ */ o("div", { className: d("sticky left-0 right-0 top-0 bg-background h-16 z-999", s), children: [
38
+ /* @__PURE__ */ o("div", { className: "md:bg-module h-13 text-center flex flex-wrap justify-between items-center gap-2 px-4", children: [
39
+ /* @__PURE__ */ o("div", { className: "flex items-center flex-1 gap-6", children: [
40
+ /* @__PURE__ */ a(u, {}),
41
+ t
42
+ ] }),
43
+ /* @__PURE__ */ a(m, { hideNews: r, hideLogin: i, user: (n == null ? void 0 : n.data) || {} })
44
+ ] }),
45
+ e
46
+ ] });
47
+ }
48
+ export {
49
+ x as H,
50
+ g as U,
51
+ U as c,
52
+ w as e,
53
+ h as o
54
+ };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { JSX } from 'react/jsx-runtime';
3
3
 
4
4
  export declare function emitUserEvent(eventName: string, data?: any): void;
5
5
 
6
- declare function HeaderBar({ extra, children, className, hideNews, hideLogin }: HeaderBarProps): JSX.Element;
6
+ declare function HeaderBar({ extra, children, className, hideNews, hideLogin }: HeaderBarProps): Promise<JSX.Element>;
7
7
  export default HeaderBar;
8
8
 
9
9
  export declare interface HeaderBarProps extends default_2.HTMLAttributes<HTMLDivElement> {
package/dist/index.js CHANGED
@@ -1,375 +1,11 @@
1
- 'use client';
2
- import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
3
- import p from "@ichaingo/link";
4
- import { DropdownMenu as D, DropdownMenuTrigger as z, DropdownMenuContent as O, DropdownMenuGroup as G, DropdownMenuItem as X } from "@ichaingo/ui/dropdown-menu";
5
- import m from "@ichaingo/translation";
6
- import { useState as b, useMemo as M, useEffect as x, useCallback as w } from "react";
7
- import N from "@ichaingo/better-link";
8
- import { useLocale as v, useTranslations as U } from "next-intl";
9
- import y from "@ichaingo/avatar";
10
- import { logout as K, fetchUserProfile as $ } from "@ichaingo/auth";
11
- import { twMerge as c } from "tailwind-merge";
12
- import { Accordion as A, AccordionItem as C, AccordionTrigger as T, AccordionContent as P } from "@ichaingo/ui/accordion";
13
- import F from "@ichaingo/iconfont";
14
- import { Popover as W, PopoverTrigger as q, PopoverContent as Q } from "@ichaingo/ui/popover";
15
- import { PopoverArrow as V } from "@radix-ui/react-popover";
16
- import { useSearchParams as J, usePathname as j } from "next/navigation";
17
- import Y from "@ichaingo/theme-toggle";
18
- import Z from "rc-drawer";
19
- import { Menu as I, X as ee } from "lucide-react";
20
- import re from "@ichaingo/image";
21
- function te({
22
- userInfo: t
23
- }) {
24
- const { gotoLogin: r } = N(), [n, l] = b(""), s = v(), i = M(() => t == null ? void 0 : t.id, [t]);
25
- return x(() => {
26
- l(r({
27
- locale: s,
28
- redirect: window.location.href
29
- }));
30
- }, [s, r]), i ? (
31
- // userInfo?.profileUrl
32
- // https://images.ichaingo.com/user-profile/100000201.png
33
- /* @__PURE__ */ e(y, { userInfo: t, className: "w-8 h-8" })
34
- ) : /* @__PURE__ */ e(
35
- p,
36
- {
37
- href: n,
38
- className: "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
39
- replace: !0,
40
- children: /* @__PURE__ */ e(m, { value: "signIn", parentKey: "account" })
41
- }
42
- );
43
- }
44
- function R({ className: t }) {
45
- const r = w(async () => {
46
- await K();
47
- }, []);
48
- return /* @__PURE__ */ e(
49
- "button",
50
- {
51
- onClick: r,
52
- className: c("cursor-pointer relative", t),
53
- children: /* @__PURE__ */ e(m, { value: "logout", parentKey: "account" })
54
- }
55
- );
56
- }
57
- function le({
58
- list: t,
59
- userInfo: r,
60
- onClick: n
61
- }) {
62
- return /* @__PURE__ */ a(D, { children: [
63
- /* @__PURE__ */ e(z, { className: "outline-none cursor-pointer", children: /* @__PURE__ */ e(te, { userInfo: r }) }),
64
- /* @__PURE__ */ e(O, { align: "end", className: "z-2000 w-75 p-0 border-transparent outline-none border border-stroke", children: /* @__PURE__ */ a(G, { className: "flex flex-col gap-2 p-3 bg-module rounded-md", children: [
65
- /* @__PURE__ */ e("div", { className: "flex flex-col gap-3 w-full bg-background rounded-lg p-2", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
66
- /* @__PURE__ */ e(y, { userInfo: r, className: "w-8 h-8" }),
67
- /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
68
- /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: (r == null ? void 0 : r.username) || "--" }),
69
- /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground w-full truncate", children: (r == null ? void 0 : r.email) || (r == null ? void 0 : r.walletAddress) })
70
- ] })
71
- ] }) }),
72
- t.map((l) => /* @__PURE__ */ e(X, { className: "px-0 py-0 focus-visible:border-none focus-visible:outline-none", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 w-full", children: l.name === "logout" ? /* @__PURE__ */ e(R, { className: "flex-1 flex py-3 border-t border-stroke w-full px-2 hover:bg-background" }) : /* @__PURE__ */ e(p, { href: `/${l.href}`, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, className: "flex-1 flex py-3 h-full w-full px-2 hover:bg-background rounded-lg ", onClick: n, children: /* @__PURE__ */ e(m, { value: l.name, parentKey: "account" }) }) }) }, l.name))
73
- ] }) })
74
- ] });
75
- }
76
- function ne({
77
- list: t,
78
- userInfo: r,
79
- onClick: n
80
- }) {
81
- return /* @__PURE__ */ e(
82
- A,
83
- {
84
- type: "single",
85
- collapsible: !0,
86
- className: "w-full",
87
- defaultValue: "",
88
- children: /* @__PURE__ */ a(C, { value: "item-1", className: "p-0 w-full border border-none", children: [
89
- /* @__PURE__ */ e(T, { className: "w-full bg-background p-3 flex items-center justify-between", children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-3 w-full overflow-hidden", children: /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
90
- /* @__PURE__ */ e(y, { userInfo: r, className: "w-8 h-8 shrink-0" }),
91
- /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
92
- /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: r == null ? void 0 : r.username }),
93
- /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground w-full truncate", children: (r == null ? void 0 : r.email) || (r == null ? void 0 : r.walletAddress) })
94
- ] })
95
- ] }) }) }),
96
- /* @__PURE__ */ e(P, { className: "flex text-sm flex-col text-balance bg-background rounded-lg p-3 gap-3 mt-[10px]", children: /* @__PURE__ */ e("dl", { children: t.map((l) => /* @__PURE__ */ e(
97
- "dd",
98
- {
99
- className: "flex justify-start items-center gap-2 py-2",
100
- children: /* @__PURE__ */ e(p, { href: `/${l.href}`, className: "flex-1 py-2", onClick: n, suppressHydrationWarning: !0, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, children: /* @__PURE__ */ e(m, { value: l.name, parentKey: "account" }) })
101
- },
102
- l.name
103
- )) }) })
104
- ] })
105
- }
106
- );
107
- }
108
- function S({ onClick: t = () => {
109
- }, className: r }) {
110
- const n = v(), { gotoLogin: l } = N(), [s, i] = b("");
111
- return x(() => {
112
- i(l({
113
- locale: n,
114
- redirect: window.location.href
115
- }));
116
- }, [n, l]), /* @__PURE__ */ e(
117
- p,
118
- {
119
- href: s,
120
- onClick: t,
121
- baseUrl: process.env.NEXT_PUBLIC_AUTH_URL,
122
- replace: !0,
123
- className: c(
124
- "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
125
- r
126
- ),
127
- children: /* @__PURE__ */ e(m, { value: "signIn", parentKey: "account" })
128
- }
129
- );
130
- }
131
- const L = [
132
- {
133
- name: "overview",
134
- href: "user-center"
135
- },
136
- {
137
- name: "collect",
138
- href: "user-center/collect"
139
- },
140
- {
141
- name: "privateLabel",
142
- href: "user-center/private-label"
143
- },
144
- {
145
- name: "setting",
146
- href: "user-center/setting"
147
- },
148
- {
149
- name: "logout",
150
- href: void 0
151
- }
152
- ];
153
- function ae({ onClick: t = (l) => {
154
- }, className: r, userInfo: n }) {
155
- return n != null && n.id ? /* @__PURE__ */ a(k, { children: [
156
- /* @__PURE__ */ e("div", { className: c("hidden md:flex items-center", r), children: /* @__PURE__ */ e(le, { list: L, userInfo: n, onClick: t }) }),
157
- /* @__PURE__ */ e("div", { className: c("block md:hidden w-full", r), children: /* @__PURE__ */ e(ne, { list: L.filter((l) => l.href), userInfo: n, onClick: t }) })
158
- ] }) : /* @__PURE__ */ e(S, { onClick: t, className: c(
159
- "hidden md:flex cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
160
- "order-3"
161
- ) });
162
- }
163
- function E({ onClick: t = () => {
164
- } }) {
165
- var g;
166
- const r = v(), n = J(), l = U("lang"), s = U("setting"), i = [
167
- { name: l("en"), lang: "en" },
168
- { name: l("zh-hant"), lang: "zh-hant" },
169
- { name: l("zh-hans"), lang: "zh-hans" },
170
- { name: l("ja"), lang: "ja" },
171
- { name: l("ko"), lang: "ko" }
172
- ], f = j(), h = w(
173
- (d) => {
174
- const u = f.replace(new RegExp(`/${r}(/|$)`), `/${d}$1`), o = n.toString();
175
- return o ? `${u}?${o}` : u;
176
- },
177
- [f, r, n]
178
- );
179
- return /* @__PURE__ */ a("div", { className: "text-sm gap-2 flex flex-col justify-start items-start md:py-2", children: [
180
- /* @__PURE__ */ e("div", { className: "flex w-full justify-between items-center", children: /* @__PURE__ */ e(A, { type: "single", className: "flex-1", collapsible: !0, children: /* @__PURE__ */ a(C, { value: r, className: "border-0", children: [
181
- /* @__PURE__ */ e(T, { className: "p-2 bg-background rounded-lg h-11 md:h-auto text-gray-500 w-full flex py-2 justify-between items-center hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0", children: /* @__PURE__ */ a("div", { className: "flex w-full justify-between items-center", children: [
182
- /* @__PURE__ */ e("span", { className: "text-title", children: s("language") }),
183
- /* @__PURE__ */ e("span", { className: "text-title", children: (g = i.find((d) => d.lang === r)) == null ? void 0 : g.name })
184
- ] }) }),
185
- /* @__PURE__ */ e(P, { className: "bg-background mt-3 rounded-lg flex flex-col gap-2", children: i.map((d) => /* @__PURE__ */ e(
186
- p,
187
- {
188
- prefetch: !1,
189
- withLocale: !1,
190
- className: c(
191
- "p-2 rounded-lg flex w-full justify-between items-center",
192
- r === d.lang ? "text-primary" : ""
193
- ),
194
- href: h(d.lang),
195
- onClick: t,
196
- children: d.name
197
- },
198
- d.lang
199
- )) })
200
- ] }) }) }),
201
- /* @__PURE__ */ a("div", { className: "bg-background p-2 rounded-lg h-11 md:h-auto flex w-full justify-between items-center", children: [
202
- /* @__PURE__ */ e("div", { children: s("theme") }),
203
- /* @__PURE__ */ e(Y, {})
204
- ] })
205
- ] });
206
- }
207
- function ie({ onClick: t = () => {
208
- } }) {
209
- return /* @__PURE__ */ a("div", { className: "w-full md:w-auto order-3 md:order-0", children: [
210
- /* @__PURE__ */ e("div", { className: "hidden md:flex items-center bg-module rounded-lg p-1.5 cursor-pointer", children: /* @__PURE__ */ a(W, { children: [
211
- /* @__PURE__ */ e(q, { asChild: !0, children: /* @__PURE__ */ e(F, { type: "icon-setting", className: "text-2xl" }) }),
212
- /* @__PURE__ */ a(
213
- Q,
214
- {
215
- side: "bottom",
216
- className: "relative top-[10px] rounded-xl border border-stroke bg-module p-2 w-72 z-1000",
217
- children: [
218
- /* @__PURE__ */ e(V, { className: "fill-module" }),
219
- /* @__PURE__ */ e(E, { onClick: t })
220
- ]
221
- }
222
- )
223
- ] }) }),
224
- /* @__PURE__ */ e("div", { className: "md:hidden", children: /* @__PURE__ */ e(E, {}) })
225
- ] });
226
- }
227
- const _ = {
228
- PROFILE_UPDATED: "user-profile-updated",
229
- LOGGED_IN: "user-logged-in",
230
- LOGGED_OUT: "user-logged-out"
231
- };
232
- function Pe(t, r) {
233
- const n = new CustomEvent(t, { detail: r });
234
- window.dispatchEvent(n);
235
- }
236
- function se(t, r) {
237
- const n = (l) => {
238
- r(l.detail);
239
- };
240
- return window.addEventListener(t, n), () => window.removeEventListener(t, n);
241
- }
242
- function oe(t, r) {
243
- window.removeEventListener(t, r);
244
- }
245
- function B({ onClick: t = () => {
246
- }, hideNews: r = !1, hideLogin: n = !1 }) {
247
- const { gotoAISQL: l, gotoChat: s } = N(), i = v(), f = j(), [h, g] = b(null), d = [
248
- {
249
- baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
250
- href: "/explorer",
251
- key: "/explorer",
252
- label: /* @__PURE__ */ e("span", { className: "whitespace-nowrap leading-11 md:leading-[34px]", children: /* @__PURE__ */ e(m, { value: "title", parentKey: "browser" }) })
253
- },
254
- {
255
- baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
256
- href: s({ locale: i }),
257
- key: "/chat",
258
- label: /* @__PURE__ */ a("span", { className: "whitespace-nowrap leading-11 md:leading-[34px]", children: [
259
- /* @__PURE__ */ e("span", { role: "img", "aria-label": "hot", children: "🔥" }),
260
- /* @__PURE__ */ e("span", { children: "iGoChat" })
261
- ] })
262
- },
263
- {
264
- baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
265
- href: l({ locale: i }),
266
- key: "/sql",
267
- label: "AISQL"
268
- },
269
- {
270
- baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
271
- href: "/etf/btc-us",
272
- key: "/etf",
273
- label: /* @__PURE__ */ e(m, { value: "etf", parentKey: "menu" })
274
- },
275
- {
276
- baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
277
- href: "/news",
278
- key: "/news",
279
- label: /* @__PURE__ */ e(m, { value: "news", parentKey: "menu" })
280
- },
281
- {
282
- baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
283
- href: "/ranking/token",
284
- key: "/ranking",
285
- label: /* @__PURE__ */ e(m, { value: "ranking", parentKey: "menu" })
286
- }
287
- ].filter((o) => r ? !["/explorer", "/chat", "/sql"].includes(o.key) : !0), u = w(() => {
288
- $().then((o) => {
289
- g(o);
290
- });
291
- }, []);
292
- return x(() => {
293
- u();
294
- }, [u]), x(() => (se(_.PROFILE_UPDATED, u), () => {
295
- oe(_.PROFILE_UPDATED, u);
296
- }), [u]), /* @__PURE__ */ a(
297
- "nav",
298
- {
299
- className: c(
300
- "flex flex-col justify-start items-start md:px-3",
301
- "md:flex-row md:justify-end md:items-start md:px-0",
302
- "md:gap-6"
303
- ),
304
- children: [
305
- /* @__PURE__ */ e(
306
- "ul",
307
- {
308
- className: c(
309
- "flex flex-col justify-start items-start w-full h-full text-sm leading-[44px] z-1001 text-title",
310
- "md:flex-row md:items-center md:w-auto md:h-[34px] md:leading-[34px] md:gap-6",
311
- "order-2 md:order-0"
312
- ),
313
- children: d.map((o, H) => /* @__PURE__ */ e("li", { className: c("w-full md:w-auto h-11 md:h-auto cursor-pointer", f.includes(o.key) && "border-b-2 border-primary text-primary "), children: /* @__PURE__ */ e(p, { href: o.href, onClick: t, className: "h-full flex items-center justify-start", baseUrl: o.baseUrl, suppressHydrationWarning: !0, children: o.label }) }, H))
314
- }
315
- ),
316
- /* @__PURE__ */ e(ie, { onClick: t }),
317
- !f.includes("/login") && !n ? /* @__PURE__ */ a(k, { children: [
318
- /* @__PURE__ */ e(ae, { onClick: t, userInfo: h }),
319
- h != null && h.id ? /* @__PURE__ */ e("div", { className: "flex md:hidden h-11 md:h-auto cursor-pointer whitespace-nowrap order-3 bg-background rounded-lg p-2 mt-3 w-full items-center justify-center text-subtitle", children: /* @__PURE__ */ e(R, {}) }) : /* @__PURE__ */ e(S, { onClick: t, className: "flex md:hidden h-11 cursor-pointer whitespace-nowrap order-3 bg-primary text-[#fff] rounded-lg p-2 mt-3 w-full items-center justify-center" })
320
- ] }) : null
321
- ]
322
- }
323
- );
324
- }
325
- function ce({ hideLogin: t, hideNews: r }) {
326
- const [n, l] = b(!1);
327
- if (!n)
328
- return /* @__PURE__ */ e(I, { onClick: () => l(!0), size: 32, style: { color: "var(--title)" }, className: "md:hidden ml-2.5 bg-module rounded-lg p-[4px] " });
329
- const s = (i) => {
330
- i == null || i.preventDefault(), i == null || i.stopPropagation(), l(!1);
331
- };
332
- return /* @__PURE__ */ e(Z, { open: n, placement: "right", className: "block md:hidden fixed top-0 bottom-0 left-0 right-0 z-1001 bg-background p-2", children: /* @__PURE__ */ a("div", { className: "w-full max-h-full overflow-y-auto p-3 bg-module rounded-lg", children: [
333
- /* @__PURE__ */ e("div", { className: "flex justify-end items-center p-2", children: /* @__PURE__ */ e(ee, { size: 24, style: { color: "var(--title)" }, onClick: (i) => s(i) }) }),
334
- /* @__PURE__ */ e(B, { onClick: (i) => s(i), hideLogin: t, hideNews: r })
335
- ] }) });
336
- }
337
- function de({ hideNews: t, hideLogin: r }) {
338
- return /* @__PURE__ */ a("div", { className: "flex justify-end items-center md:gap-10 z-1001 ", children: [
339
- /* @__PURE__ */ e(ce, { hideLogin: r, hideNews: t }),
340
- /* @__PURE__ */ e("div", { className: "hidden md:block", children: /* @__PURE__ */ e(B, { hideNews: t, hideLogin: r }) })
341
- ] });
342
- }
343
- function me() {
344
- return /* @__PURE__ */ e(p, { suppressHydrationWarning: !0, href: "/", baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL, className: c(
345
- "w-auto shrink-0 block"
346
- ), children: /* @__PURE__ */ e(
347
- re,
348
- {
349
- src: "https://cdn.ichaingo.com/uploads/logo_20250526_9aa337bef7.png",
350
- width: 116,
351
- height: 32,
352
- alt: "logo",
353
- objectFit: "contain",
354
- priority: !0
355
- }
356
- ) });
357
- }
358
- function je({ extra: t, children: r, className: n, hideNews: l, hideLogin: s }) {
359
- return /* @__PURE__ */ a("div", { className: c("sticky left-0 right-0 top-0 bg-background h-16 z-999", n), children: [
360
- /* @__PURE__ */ a("div", { className: "md:bg-module h-13 text-center flex flex-wrap justify-between items-center gap-2 px-4", children: [
361
- /* @__PURE__ */ a("div", { className: "flex items-center flex-1 gap-6", children: [
362
- /* @__PURE__ */ e(me, {}),
363
- r
364
- ] }),
365
- /* @__PURE__ */ e(de, { hideNews: l, hideLogin: s })
366
- ] }),
367
- t
368
- ] });
369
- }
1
+ import "react/jsx-runtime";
2
+ import "tailwind-merge";
3
+ import "@ichaingo/request";
4
+ import "next/dynamic";
5
+ import { U as a, H as i, e as p, o as E } from "./index-6LC2FFG_.js";
370
6
  export {
371
- _ as USER_EVENTS,
372
- je as default,
373
- Pe as emitUserEvent,
374
- se as onUserEvent
7
+ a as USER_EVENTS,
8
+ i as default,
9
+ p as emitUserEvent,
10
+ E as onUserEvent
375
11
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/header",
3
- "version": "1.3.80",
3
+ "version": "1.3.82",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -29,17 +29,18 @@
29
29
  "rollup-plugin-preserve-use-client": "^1.0.0",
30
30
  "tailwind-merge": "^2.5.5",
31
31
  "next": "15.1.6",
32
- "@ichaingo/link": "1.3.80",
33
- "@ichaingo/translation": "1.3.80",
34
- "@ichaingo/image": "1.3.80",
35
- "@ichaingo/ui": "1.3.80",
36
- "@ichaingo/avatar": "1.3.80",
37
- "@ichaingo/theme-toggle": "1.3.80",
38
- "@ichaingo/i18n": "1.3.80",
39
- "@ichaingo/auth": "1.3.80",
40
- "@ichaingo/better-link": "1.3.80",
41
- "@ichaingo/iconfont": "1.3.80",
42
- "@ichaingo/providers": "1.3.80"
32
+ "@ichaingo/avatar": "1.3.82",
33
+ "@ichaingo/auth": "1.3.82",
34
+ "@ichaingo/better-link": "1.3.82",
35
+ "@ichaingo/image": "1.3.82",
36
+ "@ichaingo/link": "1.3.82",
37
+ "@ichaingo/translation": "1.3.82",
38
+ "@ichaingo/theme-toggle": "1.3.82",
39
+ "@ichaingo/i18n": "1.3.82",
40
+ "@ichaingo/request": "1.3.82",
41
+ "@ichaingo/ui": "1.3.82",
42
+ "@ichaingo/iconfont": "1.3.82",
43
+ "@ichaingo/providers": "1.3.82"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/js-cookie": "^3.0.6"