@ichaingo/header 1.4.53 → 1.4.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,53 +1,46 @@
1
- import { jsxs as r, jsx as o } from "react/jsx-runtime";
2
- import { twMerge as a } from "tailwind-merge";
3
- import p from "@ichaingo/request";
4
- import { cookies as h } from "next/headers";
5
- import x from "./lib/Right.js";
1
+ import { jsxs as r, Fragment as x, jsx as o } from "react/jsx-runtime";
2
+ import { twMerge as i } from "tailwind-merge";
3
+ import k from "@ichaingo/request";
4
+ import { cookies as g } from "next/headers";
5
+ import m, { HeaderSource as a } from "./lib/Right.js";
6
6
  import E from "./lib/Logo.js";
7
- import { USER_EVENTS as _, emitUserEvent as A, onUserEvent as j } from "./lib/events.js";
8
- var g = /* @__PURE__ */ ((e) => (e.EXPLORER = "explorer", e.CHAT = "chat", e.DEFAULT = "default", e))(g || {});
9
- async function b({
10
- extra: e,
11
- children: c,
12
- className: d,
13
- hideNews: l,
14
- hideLogin: m,
15
- source: i = "default"
16
- /* DEFAULT */
17
- }) {
18
- var s;
19
- let t = {
7
+ import { USER_EVENTS as _, emitUserEvent as w, onUserEvent as j } from "./lib/events.js";
8
+ async function N({ extra: l, children: p, className: f, hideNews: d, hideLogin: c, source: t = a.DEFAULT }) {
9
+ var n;
10
+ let e = {
20
11
  data: {}
21
12
  };
22
13
  try {
23
- const n = (s = (await h()).get("refresh_token")) == null ? void 0 : s.value;
24
- if (typeof n < "u" && n !== "")
14
+ const s = (n = (await g()).get("refresh_token")) == null ? void 0 : n.value;
15
+ if (typeof s < "u" && s !== "")
25
16
  try {
26
- t = await p.get("/v2/users/profile", {
17
+ e = await k.get("/v2/users/profile", {
27
18
  baseURL: process.env.AUTH_INNER_API_URL
28
19
  });
29
- } catch (f) {
30
- console.error(f), t = { data: {} };
20
+ } catch (h) {
21
+ console.error(h), e = { data: {} };
31
22
  }
32
23
  } catch {
33
- t = { data: {} };
24
+ e = { data: {} };
34
25
  }
35
- return /* @__PURE__ */ r("div", { className: a("sticky left-0 right-0 top-0 bg-background h-16 z-999", d), children: [
36
- /* @__PURE__ */ r("div", { className: "md:bg-module h-13 text-center flex flex-wrap justify-between items-center gap-2 px-4", children: [
37
- /* @__PURE__ */ r("div", { className: a("items-center flex-1 gap-6", i === "chat" ? "hidden md:flex" : "flex"), children: [
38
- /* @__PURE__ */ o(E, {}),
39
- c
26
+ return /* @__PURE__ */ r(x, { children: [
27
+ /* @__PURE__ */ r("div", { className: i("sticky left-0 right-0 top-0 bg-background h-16 z-999", t === a.CHAT ? "hidden md:block" : "block", f), children: [
28
+ /* @__PURE__ */ r("div", { className: "md:bg-module h-13 text-center flex flex-wrap justify-between items-center gap-2 px-4", children: [
29
+ /* @__PURE__ */ r("div", { className: i("items-center flex-1 gap-6", t === a.CHAT ? "hidden md:flex" : "flex"), children: [
30
+ /* @__PURE__ */ o(E, {}),
31
+ p
32
+ ] }),
33
+ /* @__PURE__ */ o(m, { hideNews: d, hideLogin: c, user: (e == null ? void 0 : e.data) || {} })
40
34
  ] }),
41
- /* @__PURE__ */ o("div", { className: a(i === "chat" ? "flex-1 md:hidden" : "hidden"), children: " " }),
42
- /* @__PURE__ */ o(x, { hideNews: l, hideLogin: m, user: (t == null ? void 0 : t.data) || {} })
35
+ l
43
36
  ] }),
44
- e
37
+ /* @__PURE__ */ o("div", { className: i(t === a.CHAT ? "block md:hidden" : "hidden"), children: /* @__PURE__ */ o(m, { hideNews: d, source: t, hideLogin: c, user: (e == null ? void 0 : e.data) || {} }) })
45
38
  ] });
46
39
  }
47
40
  export {
48
- g as HeaderSource,
41
+ a as HeaderSource,
49
42
  _ as USER_EVENTS,
50
- b as default,
51
- A as emitUserEvent,
43
+ N as default,
44
+ w as emitUserEvent,
52
45
  j as onUserEvent
53
46
  };
@@ -1,19 +1,19 @@
1
1
  'use client';
2
2
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
3
- import m from "rc-drawer";
4
- import { Menu as d, X as c } from "lucide-react";
3
+ import d from "rc-drawer";
4
+ import { Menu as m, X as c } from "lucide-react";
5
5
  import f from "./Nav.js";
6
6
  import { useState as p } from "react";
7
7
  function b({ hideLogin: i, hideNews: a, user: n }) {
8
- const [t, l] = p(!1);
8
+ const [t, r] = p(!1);
9
9
  if (!t)
10
- return /* @__PURE__ */ o(d, { onClick: () => l(!0), size: 32, style: { color: "var(--title)" }, className: "md:hidden ml-2.5 bg-module rounded-lg p-[4px] " });
11
- const r = (e) => {
12
- e == null || e.preventDefault(), e == null || e.stopPropagation(), l(!1);
10
+ return /* @__PURE__ */ o(m, { onClick: () => r(!0), size: 32, style: { color: "var(--title)" }, className: "md:hidden bg-module rounded-lg p-[4px] " });
11
+ const l = (e) => {
12
+ e == null || e.preventDefault(), e == null || e.stopPropagation(), r(!1);
13
13
  };
14
- return /* @__PURE__ */ o(m, { 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__ */ s("div", { className: "w-full max-h-full overflow-y-auto p-3 bg-module rounded-lg", children: [
15
- /* @__PURE__ */ o("div", { className: "flex justify-end items-center p-2", children: /* @__PURE__ */ o(c, { size: 24, style: { color: "var(--title)" }, onClick: (e) => r(e) }) }),
16
- /* @__PURE__ */ o(f, { onClick: (e) => r(e), hideLogin: i, hideNews: a, user: n })
14
+ return /* @__PURE__ */ o(d, { 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__ */ s("div", { className: "w-full max-h-full overflow-y-auto p-3 bg-module rounded-lg", children: [
15
+ /* @__PURE__ */ o("div", { className: "flex justify-end items-center p-2", children: /* @__PURE__ */ o(c, { size: 24, style: { color: "var(--title)" }, onClick: (e) => l(e) }) }),
16
+ /* @__PURE__ */ o(f, { onClick: (e) => l(e), hideLogin: i, hideNews: a, user: n })
17
17
  ] }) });
18
18
  }
19
19
  export {
package/dist/lib/Nav.js CHANGED
@@ -1,24 +1,25 @@
1
1
  'use client';
2
2
  import { jsxs as o, jsx as r, Fragment as E } from "react/jsx-runtime";
3
- import L from "@ichaingo/link";
4
- import _ from "./User/index.js";
5
- import v from "./Setting/index.js";
3
+ import _ from "@ichaingo/link";
4
+ import v from "./User/index.js";
5
+ import N from "./Setting/index.js";
6
6
  import a from "@ichaingo/translation";
7
7
  import { twMerge as i } from "tailwind-merge";
8
- import N from "@ichaingo/better-link";
8
+ import P from "@ichaingo/better-link";
9
9
  import { useLocale as S } from "next-intl";
10
10
  import k from "./User/Logout.js";
11
- import { useState as u, useCallback as B, useEffect as P } from "react";
12
- import I from "./User/SignIn.js";
13
- import { fetchUserProfile as T } from "@ichaingo/auth";
14
- import { onUserEvent as A, cleanUserEvent as R, USER_EVENTS as c } from "./events.js";
15
- import { usePathname as j } from "next/navigation";
16
- function G({ onClick: s = () => {
11
+ import { useState as d, useCallback as B, useEffect as I } from "react";
12
+ import T from "./User/SignIn.js";
13
+ import { fetchUserProfile as A } from "@ichaingo/auth";
14
+ import { onUserEvent as R, cleanUserEvent as j, USER_EVENTS as u } from "./events.js";
15
+ import { usePathname as C } from "next/navigation";
16
+ import { useLogin as K } from "@ichaingo/with-login";
17
+ function Z({ onClick: s = () => {
17
18
  }, hideNews: p = !1, hideLogin: f = !1, user: h }) {
18
- const { gotoAISQL: w, gotoChat: U } = N(), t = S(), m = j(), [g, x] = u(""), [n, b] = u(h), y = [
19
+ const { gotoAISQL: w, gotoChat: g } = P(), t = S(), m = C(), [U, x] = d(""), [n, b] = d(h), { Prefetch: y } = K({}), L = [
19
20
  {
20
21
  baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
21
- href: U({ locale: t }),
22
+ href: g({ locale: t }),
22
23
  key: `/${t}`,
23
24
  label: /* @__PURE__ */ o("span", { className: "whitespace-nowrap leading-11 md:leading-[34px]", children: [
24
25
  /* @__PURE__ */ r("span", { role: "img", "aria-label": "hot", children: "🔥" }),
@@ -61,13 +62,13 @@ function G({ onClick: s = () => {
61
62
  label: /* @__PURE__ */ r(a, { value: "ranking", parentKey: "menu" }),
62
63
  show: (e) => e.includes("/ranking")
63
64
  }
64
- ].filter((e) => p ? !["/explorer", "/chat", "/sql"].includes(e.key) : !0), d = B(() => new Promise((e) => {
65
- T().then((l) => {
65
+ ].filter((e) => p ? !["/explorer", "/chat", "/sql"].includes(e.key) : !0), c = B(() => new Promise((e) => {
66
+ A().then((l) => {
66
67
  b(l), x((/* @__PURE__ */ new Date()).getTime().toString()), e(l);
67
68
  });
68
69
  }), []);
69
- return P(() => (A(c.PROFILE_UPDATED, d), () => {
70
- R(c.PROFILE_UPDATED, d);
70
+ return I(() => (R(u.PROFILE_UPDATED, c), () => {
71
+ j(u.PROFILE_UPDATED, c);
71
72
  }), []), /* @__PURE__ */ o(
72
73
  "nav",
73
74
  {
@@ -85,18 +86,19 @@ function G({ onClick: s = () => {
85
86
  "md:flex-row md:items-center md:w-auto md:h-[34px] md:leading-[34px] md:gap-6",
86
87
  "order-2 md:order-0"
87
88
  ),
88
- children: y.map((e, l) => /* @__PURE__ */ r("li", { className: i("w-full md:w-auto h-11 md:h-auto cursor-pointer hover:text-primary", e.show(m) && "border-b-2 border-primary text-primary "), children: /* @__PURE__ */ r(L, { href: e.href, onClick: s, className: "h-full flex items-center justify-start", baseUrl: e.baseUrl, suppressHydrationWarning: !0, children: e.label }) }, l))
89
+ children: L.map((e, l) => /* @__PURE__ */ r("li", { className: i("w-full md:w-auto h-11 md:h-auto cursor-pointer hover:text-primary", e.show(m) && "border-b-2 border-primary text-primary "), children: /* @__PURE__ */ r(_, { href: e.href, onClick: s, className: "h-full flex items-center justify-start", baseUrl: e.baseUrl, suppressHydrationWarning: !0, children: e.label }) }, l))
89
90
  }
90
91
  ),
91
- /* @__PURE__ */ r(v, { onClick: s }),
92
+ /* @__PURE__ */ r(N, { onClick: s }),
92
93
  !m.includes("/login") && !f ? /* @__PURE__ */ o(E, { children: [
93
- /* @__PURE__ */ r(_, { onClick: s, userInfo: n }, g),
94
- n != null && n.id ? /* @__PURE__ */ r("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__ */ r(k, {}) }) : /* @__PURE__ */ r(I, { onClick: s, 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" })
95
- ] }) : null
94
+ /* @__PURE__ */ r(v, { onClick: s, userInfo: n }, U),
95
+ n != null && n.id ? /* @__PURE__ */ r("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__ */ r(k, {}) }) : /* @__PURE__ */ r(T, { onClick: s, 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" })
96
+ ] }) : null,
97
+ /* @__PURE__ */ r(y, {})
96
98
  ]
97
99
  }
98
100
  );
99
101
  }
100
102
  export {
101
- G as default
103
+ Z as default
102
104
  };
package/dist/lib/Right.js CHANGED
@@ -1,12 +1,21 @@
1
- import { jsxs as a, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as r } from "react/jsx-runtime";
2
2
  import i from "./Nav.js";
3
- import d from "./Drawer.js";
4
- function f({ hideNews: m, hideLogin: t, user: e }) {
5
- return /* @__PURE__ */ a("div", { className: "flex justify-end items-center md:gap-10 z-1001 ", children: [
6
- /* @__PURE__ */ r(d, { hideLogin: t, hideNews: m, user: e }),
7
- /* @__PURE__ */ r("div", { className: "hidden md:block", children: /* @__PURE__ */ r(i, { hideNews: m, hideLogin: t, user: e }) })
3
+ import l from "./Drawer.js";
4
+ import { twMerge as o } from "tailwind-merge";
5
+ var d = /* @__PURE__ */ ((t) => (t.EXPLORER = "explorer", t.CHAT = "chat", t.DEFAULT = "default", t))(d || {});
6
+ function x({
7
+ hideNews: t,
8
+ hideLogin: m,
9
+ user: a,
10
+ source: e = "default"
11
+ /* DEFAULT */
12
+ }) {
13
+ return /* @__PURE__ */ f("div", { className: o(e === "chat" ? "" : "flex justify-end items-center md:gap-10 z-1001"), children: [
14
+ /* @__PURE__ */ r(l, { hideLogin: m, hideNews: t, user: a }),
15
+ /* @__PURE__ */ r("div", { className: "hidden md:block", children: /* @__PURE__ */ r(i, { hideNews: t, hideLogin: m, user: a }) })
8
16
  ] });
9
17
  }
10
18
  export {
11
- f as default
19
+ d as HeaderSource,
20
+ x as default
12
21
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/header",
3
- "version": "1.4.53",
3
+ "version": "1.4.55",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -29,20 +29,20 @@
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/auth": "1.4.53",
33
- "@ichaingo/image": "1.4.53",
34
- "@ichaingo/better-link": "1.4.53",
35
- "@ichaingo/link": "1.4.53",
36
- "@ichaingo/translation": "1.4.53",
37
- "@ichaingo/ui": "1.4.53",
38
- "@ichaingo/i18n": "1.4.53",
39
- "@ichaingo/theme-toggle": "1.4.53",
40
- "@ichaingo/with-login": "1.4.53",
41
- "@ichaingo/avatar": "1.4.53",
42
- "@ichaingo/iconfont": "1.4.53",
43
- "@ichaingo/providers": "1.4.53",
44
- "@ichaingo/tooltip": "1.4.53",
45
- "@ichaingo/request": "1.4.53"
32
+ "@ichaingo/auth": "1.4.55",
33
+ "@ichaingo/image": "1.4.55",
34
+ "@ichaingo/better-link": "1.4.55",
35
+ "@ichaingo/avatar": "1.4.55",
36
+ "@ichaingo/link": "1.4.55",
37
+ "@ichaingo/translation": "1.4.55",
38
+ "@ichaingo/ui": "1.4.55",
39
+ "@ichaingo/theme-toggle": "1.4.55",
40
+ "@ichaingo/request": "1.4.55",
41
+ "@ichaingo/with-login": "1.4.55",
42
+ "@ichaingo/i18n": "1.4.55",
43
+ "@ichaingo/providers": "1.4.55",
44
+ "@ichaingo/tooltip": "1.4.55",
45
+ "@ichaingo/iconfont": "1.4.55"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/js-cookie": "^3.0.6"