@ichaingo/header 1.3.80 → 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 +138 -127
  3. package/package.json +13 -12
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,49 +1,50 @@
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 D, DropdownMenuTrigger as z, DropdownMenuContent as O, DropdownMenuGroup as G, DropdownMenuItem as X } 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 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";
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
+ import { logout as $, fetchUserProfile as F } from "@ichaingo/auth";
11
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({
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({
22
23
  userInfo: t
23
24
  }) {
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,
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,
28
29
  redirect: window.location.href
29
30
  }));
30
- }, [s, r]), i ? (
31
+ }, [o, r]), s ? (
31
32
  // userInfo?.profileUrl
32
33
  // https://images.ichaingo.com/user-profile/100000201.png
33
- /* @__PURE__ */ e(y, { userInfo: t, className: "w-8 h-8" })
34
+ /* @__PURE__ */ e(U, { userInfo: t, className: "w-8 h-8" })
34
35
  ) : /* @__PURE__ */ e(
35
- p,
36
+ h,
36
37
  {
37
- href: n,
38
+ href: l,
38
39
  className: "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
39
40
  replace: !0,
40
41
  children: /* @__PURE__ */ e(m, { value: "signIn", parentKey: "account" })
41
42
  }
42
43
  );
43
44
  }
44
- function R({ className: t }) {
45
- const r = w(async () => {
46
- await K();
45
+ function H({ className: t }) {
46
+ const r = N(async () => {
47
+ await $();
47
48
  }, []);
48
49
  return /* @__PURE__ */ e(
49
50
  "button",
@@ -54,52 +55,52 @@ function R({ className: t }) {
54
55
  }
55
56
  );
56
57
  }
57
- function le({
58
+ function ae({
58
59
  list: t,
59
60
  userInfo: r,
60
- onClick: n
61
+ onClick: l
61
62
  }) {
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: [
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: [
65
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: [
66
- /* @__PURE__ */ e(y, { userInfo: r, className: "w-8 h-8" }),
67
+ /* @__PURE__ */ e(U, { userInfo: r, className: "w-8 h-8" }),
67
68
  /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
68
69
  /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: (r == null ? void 0 : r.username) || "--" }),
69
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) })
70
71
  ] })
71
72
  ] }) }),
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
+ 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))
73
74
  ] }) })
74
75
  ] });
75
76
  }
76
- function ne({
77
+ function se({
77
78
  list: t,
78
79
  userInfo: r,
79
- onClick: n
80
+ onClick: l
80
81
  }) {
81
82
  return /* @__PURE__ */ e(
82
- A,
83
+ C,
83
84
  {
84
85
  type: "single",
85
86
  collapsible: !0,
86
87
  className: "w-full",
87
88
  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" }),
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" }),
91
92
  /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
92
93
  /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: r == null ? void 0 : r.username }),
93
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) })
94
95
  ] })
95
96
  ] }) }) }),
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
+ /* @__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(
97
98
  "dd",
98
99
  {
99
100
  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
+ 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" }) })
101
102
  },
102
- l.name
103
+ n.name
103
104
  )) }) })
104
105
  ] })
105
106
  }
@@ -107,16 +108,16 @@ function ne({
107
108
  }
108
109
  function S({ onClick: t = () => {
109
110
  }, className: r }) {
110
- const n = v(), { gotoLogin: l } = N(), [s, i] = b("");
111
- return x(() => {
112
- i(l({
113
- locale: n,
111
+ const l = b(), { gotoLogin: n } = y(), [o, s] = v("");
112
+ return w(() => {
113
+ s(n({
114
+ locale: l,
114
115
  redirect: window.location.href
115
116
  }));
116
- }, [n, l]), /* @__PURE__ */ e(
117
- p,
117
+ }, [l, n]), /* @__PURE__ */ e(
118
+ h,
118
119
  {
119
- href: s,
120
+ href: o,
120
121
  onClick: t,
121
122
  baseUrl: process.env.NEXT_PUBLIC_AUTH_URL,
122
123
  replace: !0,
@@ -150,11 +151,11 @@ const L = [
150
151
  href: void 0
151
152
  }
152
153
  ];
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 }) })
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 }) })
158
159
  ] }) : /* @__PURE__ */ e(S, { onClick: t, className: c(
159
160
  "hidden md:flex cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
160
161
  "order-3"
@@ -162,28 +163,28 @@ function ae({ onClick: t = (l) => {
162
163
  }
163
164
  function E({ onClick: t = () => {
164
165
  } }) {
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(
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(
173
174
  (d) => {
174
- const u = f.replace(new RegExp(`/${r}(/|$)`), `/${d}$1`), o = n.toString();
175
- return o ? `${u}?${o}` : u;
175
+ const x = i.replace(new RegExp(`/${r}(/|$)`), `/${d}$1`), f = l.toString();
176
+ return f ? `${x}?${f}` : x;
176
177
  },
177
- [f, r, n]
178
+ [i, r, l]
178
179
  );
179
180
  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 })
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 })
184
185
  ] }) }),
185
- /* @__PURE__ */ e(P, { className: "bg-background mt-3 rounded-lg flex flex-col gap-2", children: i.map((d) => /* @__PURE__ */ e(
186
- 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,
187
188
  {
188
189
  prefetch: !1,
189
190
  withLocale: !1,
@@ -191,7 +192,7 @@ function E({ onClick: t = () => {
191
192
  "p-2 rounded-lg flex w-full justify-between items-center",
192
193
  r === d.lang ? "text-primary" : ""
193
194
  ),
194
- href: h(d.lang),
195
+ href: g(d.lang),
195
196
  onClick: t,
196
197
  children: d.name
197
198
  },
@@ -199,23 +200,23 @@ function E({ onClick: t = () => {
199
200
  )) })
200
201
  ] }) }) }),
201
202
  /* @__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, {})
203
+ /* @__PURE__ */ e("div", { children: o("theme") }),
204
+ /* @__PURE__ */ e(Z, {})
204
205
  ] })
205
206
  ] });
206
207
  }
207
- function ie({ onClick: t = () => {
208
+ function oe({ onClick: t = () => {
208
209
  } }) {
209
210
  return /* @__PURE__ */ a("div", { className: "w-full md:w-auto order-3 md:order-0", children: [
210
211
  /* @__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__ */ e(Q, { asChild: !0, children: /* @__PURE__ */ e(q, { type: "icon-setting", className: "text-2xl" }) }),
212
213
  /* @__PURE__ */ a(
213
- Q,
214
+ V,
214
215
  {
215
216
  side: "bottom",
216
217
  className: "relative top-[10px] rounded-xl border border-stroke bg-module p-2 w-72 z-1000",
217
218
  children: [
218
- /* @__PURE__ */ e(V, { className: "fill-module" }),
219
+ /* @__PURE__ */ e(J, { className: "fill-module" }),
219
220
  /* @__PURE__ */ e(E, { onClick: t })
220
221
  ]
221
222
  }
@@ -224,27 +225,27 @@ function ie({ onClick: t = () => {
224
225
  /* @__PURE__ */ e("div", { className: "md:hidden", children: /* @__PURE__ */ e(E, {}) })
225
226
  ] });
226
227
  }
227
- const _ = {
228
+ const k = {
228
229
  PROFILE_UPDATED: "user-profile-updated",
229
230
  LOGGED_IN: "user-logged-in",
230
231
  LOGGED_OUT: "user-logged-out"
231
232
  };
232
- function Pe(t, r) {
233
- const n = new CustomEvent(t, { detail: r });
234
- window.dispatchEvent(n);
233
+ function He(t, r) {
234
+ const l = new CustomEvent(t, { detail: r });
235
+ window.dispatchEvent(l);
235
236
  }
236
- function se(t, r) {
237
- const n = (l) => {
238
- r(l.detail);
237
+ function ce(t, r) {
238
+ const l = (n) => {
239
+ r(n.detail);
239
240
  };
240
- return window.addEventListener(t, n), () => window.removeEventListener(t, n);
241
+ return window.addEventListener(t, l), () => window.removeEventListener(t, l);
241
242
  }
242
- function oe(t, r) {
243
+ function de(t, r) {
243
244
  window.removeEventListener(t, r);
244
245
  }
245
246
  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 = [
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 = [
248
249
  {
249
250
  baseUrl: process.env.NEXT_PUBLIC_ICHAINGO_SEARCH_BASEURL,
250
251
  href: "/explorer",
@@ -262,7 +263,7 @@ function B({ onClick: t = () => {
262
263
  },
263
264
  {
264
265
  baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
265
- href: l({ locale: i }),
266
+ href: o({ locale: i }),
266
267
  key: "/sql",
267
268
  label: "AISQL"
268
269
  },
@@ -284,16 +285,14 @@ function B({ onClick: t = () => {
284
285
  key: "/ranking",
285
286
  label: /* @__PURE__ */ e(m, { value: "ranking", parentKey: "menu" })
286
287
  }
287
- ].filter((o) => r ? !["/explorer", "/chat", "/sql"].includes(o.key) : !0), u = w(() => {
288
- $().then((o) => {
289
- g(o);
288
+ ].filter((u) => r ? !["/explorer", "/chat", "/sql"].includes(u.key) : !0), f = N(() => {
289
+ F().then((u) => {
290
+ d(u);
290
291
  });
291
292
  }, []);
292
- return x(() => {
293
- u();
294
- }, [u]), x(() => (se(_.PROFILE_UPDATED, u), () => {
295
- oe(_.PROFILE_UPDATED, u);
296
- }), [u]), /* @__PURE__ */ a(
293
+ return w(() => (ce(k.PROFILE_UPDATED, f), () => {
294
+ de(k.PROFILE_UPDATED, f);
295
+ }), []), /* @__PURE__ */ a(
297
296
  "nav",
298
297
  {
299
298
  className: c(
@@ -310,41 +309,41 @@ function B({ onClick: t = () => {
310
309
  "md:flex-row md:items-center md:w-auto md:h-[34px] md:leading-[34px] md:gap-6",
311
310
  "order-2 md:order-0"
312
311
  ),
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))
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))
314
313
  }
315
314
  ),
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" })
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" })
320
319
  ] }) : null
321
320
  ]
322
321
  }
323
322
  );
324
323
  }
325
- function ce({ hideLogin: t, hideNews: r }) {
326
- const [n, l] = b(!1);
324
+ function me({ hideLogin: t, hideNews: r, user: l }) {
325
+ const [n, o] = v(!1);
327
326
  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] " });
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] " });
329
328
  const s = (i) => {
330
- i == null || i.preventDefault(), i == null || i.stopPropagation(), l(!1);
329
+ i == null || i.preventDefault(), i == null || i.stopPropagation(), o(!1);
331
330
  };
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 })
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 })
335
334
  ] }) });
336
335
  }
337
- function de({ hideNews: t, hideLogin: r }) {
336
+ function ue({ hideNews: t, hideLogin: r, user: l }) {
338
337
  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 }) })
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 }) })
341
340
  ] });
342
341
  }
343
- function me() {
344
- 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(
345
344
  "w-auto shrink-0 block"
346
345
  ), children: /* @__PURE__ */ e(
347
- re,
346
+ te,
348
347
  {
349
348
  src: "https://cdn.ichaingo.com/uploads/logo_20250526_9aa337bef7.png",
350
349
  width: 116,
@@ -355,21 +354,33 @@ function me() {
355
354
  }
356
355
  ) });
357
356
  }
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: [
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: [
360
371
  /* @__PURE__ */ a("div", { className: "md:bg-module h-13 text-center flex flex-wrap justify-between items-center gap-2 px-4", children: [
361
372
  /* @__PURE__ */ a("div", { className: "flex items-center flex-1 gap-6", children: [
362
- /* @__PURE__ */ e(me, {}),
373
+ /* @__PURE__ */ e(pe, {}),
363
374
  r
364
375
  ] }),
365
- /* @__PURE__ */ e(de, { hideNews: l, hideLogin: s })
376
+ /* @__PURE__ */ e(ue, { hideNews: n, hideLogin: o, user: (s == null ? void 0 : s.data) || {} })
366
377
  ] }),
367
378
  t
368
379
  ] });
369
380
  }
370
381
  export {
371
- _ as USER_EVENTS,
372
- je as default,
373
- Pe as emitUserEvent,
374
- se as onUserEvent
382
+ k as USER_EVENTS,
383
+ Se as default,
384
+ He as emitUserEvent,
385
+ ce as onUserEvent
375
386
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/header",
3
- "version": "1.3.80",
3
+ "version": "1.3.81",
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/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"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@types/js-cookie": "^3.0.6"