@ichaingo/header 1.3.89 → 1.3.91

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.
@@ -1,325 +0,0 @@
1
- 'use client';
2
- import { jsx as e, jsxs as a, Fragment as T } from "react/jsx-runtime";
3
- import h from "@ichaingo/link";
4
- import { DropdownMenu as M, DropdownMenuTrigger as X, DropdownMenuContent as $, DropdownMenuGroup as O, DropdownMenuItem as G } from "@ichaingo/ui/dropdown-menu";
5
- import d from "@ichaingo/translation";
6
- import { useState as f, useMemo as F, useEffect as N, useCallback as y } from "react";
7
- import U from "@ichaingo/better-link";
8
- import { useLocale as w, useTranslations as _ } from "next-intl";
9
- import k from "@ichaingo/avatar";
10
- import { logout as q, fetchUserProfile as Q } from "@ichaingo/auth";
11
- import { twMerge as m } from "tailwind-merge";
12
- import { Accordion as P, AccordionItem as j, AccordionTrigger as S, AccordionContent as R } from "@ichaingo/ui/accordion";
13
- import V from "@ichaingo/iconfont";
14
- import { Popover as W, PopoverTrigger as J, PopoverContent as Y } from "@ichaingo/ui/popover";
15
- import { PopoverArrow as Z } from "@radix-ui/react-popover";
16
- import { useSearchParams as I, usePathname as B } from "next/navigation";
17
- import ee from "@ichaingo/theme-toggle";
18
- import { o as re, c as le, U as A } from "./index-CeUO6r-I.js";
19
- import te from "rc-drawer";
20
- import { Menu as ne, X as ae } from "lucide-react";
21
- function se({
22
- userInfo: l
23
- }) {
24
- const { gotoLogin: r } = U(), [n, t] = f(""), i = w(), o = F(() => l == null ? void 0 : l.id, [l]);
25
- return N(() => {
26
- t(r({
27
- locale: i,
28
- redirect: window.location.href
29
- }));
30
- }, [i, r]), o ? (
31
- // userInfo?.profileUrl
32
- // https://images.ichaingo.com/user-profile/100000201.png
33
- /* @__PURE__ */ e(k, { userInfo: l, 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 H({ className: l }) {
45
- const r = y(async () => {
46
- await q();
47
- }, []);
48
- return /* @__PURE__ */ e(
49
- "button",
50
- {
51
- onClick: r,
52
- className: m("cursor-pointer relative", l),
53
- children: /* @__PURE__ */ e(d, { value: "logout", parentKey: "account" })
54
- }
55
- );
56
- }
57
- function ie({
58
- list: l,
59
- userInfo: r,
60
- onClick: n
61
- }) {
62
- return /* @__PURE__ */ a(M, { children: [
63
- /* @__PURE__ */ e(X, { className: "outline-none cursor-pointer", children: /* @__PURE__ */ e(se, { userInfo: r }) }),
64
- /* @__PURE__ */ e($, { align: "end", className: "z-2000 w-75 p-0 border-transparent outline-none border border-stroke", children: /* @__PURE__ */ a(O, { 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(k, { 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
- l.map((t) => /* @__PURE__ */ e(G, { 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(H, { 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 oe({
77
- list: l,
78
- userInfo: r,
79
- onClick: n
80
- }) {
81
- return /* @__PURE__ */ e(
82
- P,
83
- {
84
- type: "single",
85
- collapsible: !0,
86
- className: "w-full",
87
- defaultValue: "",
88
- children: /* @__PURE__ */ a(j, { value: "item-1", className: "p-0 w-full border border-none", children: [
89
- /* @__PURE__ */ e(S, { 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(k, { 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(R, { className: "flex text-sm flex-col text-balance bg-background rounded-lg p-3 gap-3 mt-[10px]", children: /* @__PURE__ */ e("dl", { children: l.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 D({ onClick: l = () => {
109
- }, className: r }) {
110
- const n = w(), { gotoLogin: t } = U(), [i, o] = f("");
111
- return N(() => {
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: l,
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
- r
126
- ),
127
- children: /* @__PURE__ */ e(d, { value: "signIn", parentKey: "account" })
128
- }
129
- );
130
- }
131
- const C = [
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 ce({ onClick: l = (t) => {
154
- }, className: r, userInfo: n }) {
155
- return n != null && n.id ? /* @__PURE__ */ a(T, { children: [
156
- /* @__PURE__ */ e("div", { className: m("hidden md:flex items-center", r), children: /* @__PURE__ */ e(ie, { list: C, userInfo: n, onClick: l }) }),
157
- /* @__PURE__ */ e("div", { className: m("block md:hidden w-full", r), children: /* @__PURE__ */ e(oe, { list: C.filter((t) => t.href), userInfo: n, onClick: l }) })
158
- ] }) : /* @__PURE__ */ e(D, { onClick: l, 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 E({ onClick: l = () => {
164
- } }) {
165
- var x;
166
- const r = w(), n = I(), t = _("lang"), i = _("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 = B(), g = y(
173
- (c) => {
174
- const u = s.replace(new RegExp(`/${r}(/|$)`), `/${c}$1`), b = n.toString();
175
- return b ? `${u}?${b}` : u;
176
- },
177
- [s, 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(P, { type: "single", className: "flex-1", collapsible: !0, children: /* @__PURE__ */ a(j, { value: r, className: "border-0", children: [
181
- /* @__PURE__ */ e(S, { 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: (x = o.find((c) => c.lang === r)) == null ? void 0 : x.name })
184
- ] }) }),
185
- /* @__PURE__ */ e(R, { 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
- r === c.lang ? "text-primary" : ""
193
- ),
194
- href: g(c.lang),
195
- onClick: l,
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(ee, {})
204
- ] })
205
- ] });
206
- }
207
- function de({ onClick: l = () => {
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(J, { asChild: !0, children: /* @__PURE__ */ e(V, { type: "icon-setting", className: "text-2xl" }) }),
212
- /* @__PURE__ */ a(
213
- Y,
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(Z, { className: "fill-module" }),
219
- /* @__PURE__ */ e(E, { onClick: l })
220
- ]
221
- }
222
- )
223
- ] }) }),
224
- /* @__PURE__ */ e("div", { className: "md:hidden", children: /* @__PURE__ */ e(E, {}) })
225
- ] });
226
- }
227
- function z({ onClick: l = () => {
228
- }, hideNews: r = !1, hideLogin: n = !1, user: t }) {
229
- const { gotoAISQL: i, gotoChat: o } = U(), s = w(), g = B(), [x, c] = f(""), [u, b] = f(t), K = [
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) => r ? !["/explorer", "/chat", "/sql"].includes(p.key) : !0), L = y(() => new Promise((p) => {
270
- Q().then((v) => {
271
- b(v), c((/* @__PURE__ */ new Date()).getTime().toString()), p(v);
272
- });
273
- }), []);
274
- return N(() => (re(A.PROFILE_UPDATED, L), () => {
275
- le(A.PROFILE_UPDATED, L);
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: K.map((p, v) => /* @__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: l, className: "h-full flex items-center justify-start", baseUrl: p.baseUrl, suppressHydrationWarning: !0, children: p.label }) }, v))
294
- }
295
- ),
296
- /* @__PURE__ */ e(de, { onClick: l }),
297
- !g.includes("/login") && !n ? /* @__PURE__ */ a(T, { children: [
298
- /* @__PURE__ */ e(ce, { onClick: l, userInfo: u }, x),
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(H, {}) }) : /* @__PURE__ */ e(D, { onClick: l, 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 me({ hideLogin: l, hideNews: r, user: n }) {
306
- const [t, i] = f(!1);
307
- if (!t)
308
- return /* @__PURE__ */ e(ne, { 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(te, { 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(ae, { size: 24, style: { color: "var(--title)" }, onClick: (s) => o(s) }) }),
314
- /* @__PURE__ */ e(z, { onClick: (s) => o(s), hideLogin: l, hideNews: r, user: n })
315
- ] }) });
316
- }
317
- function Pe({ hideNews: l, hideLogin: r, user: n }) {
318
- return /* @__PURE__ */ a("div", { className: "flex justify-end items-center md:gap-10 z-1001 ", children: [
319
- /* @__PURE__ */ e(me, { hideLogin: r, hideNews: l, user: n }),
320
- /* @__PURE__ */ e("div", { className: "hidden md:block", children: /* @__PURE__ */ e(z, { hideNews: l, hideLogin: r, user: n }) })
321
- ] });
322
- }
323
- export {
324
- Pe as default
325
- };