@ichaingo/header 1.3.79 → 1.3.81

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