@ichaingo/header 1.4.51 → 1.4.53

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.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): Promise<JSX.Element>;
6
+ declare function HeaderBar({ extra, children, className, hideNews, hideLogin, source }: HeaderBarProps): Promise<JSX.Element>;
7
7
  export default HeaderBar;
8
8
 
9
9
  export declare interface HeaderBarProps extends default_2.HTMLAttributes<HTMLDivElement> {
@@ -11,6 +11,13 @@ export declare interface HeaderBarProps extends default_2.HTMLAttributes<HTMLDiv
11
11
  children?: default_2.ReactNode;
12
12
  hideNews?: boolean;
13
13
  hideLogin?: boolean;
14
+ source?: HeaderSource;
15
+ }
16
+
17
+ export declare enum HeaderSource {
18
+ EXPLORER = "explorer",
19
+ CHAT = "chat",
20
+ DEFAULT = "default"
14
21
  }
15
22
 
16
23
  export declare function onUserEvent(eventName: string, callback: (data?: any) => void): () => void;
package/dist/index.js CHANGED
@@ -1,42 +1,53 @@
1
- import { jsxs as t, jsx as a } from "react/jsx-runtime";
2
- import { twMerge as p } from "tailwind-merge";
3
- import d from "@ichaingo/request";
4
- import { cookies as l } from "next/headers";
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
5
  import x from "./lib/Right.js";
6
- import h from "./lib/Logo.js";
7
- import { USER_EVENTS as _, emitUserEvent as S, onUserEvent as T } from "./lib/events.js";
8
- async function b({ extra: i, children: s, className: c, hideNews: n, hideLogin: m }) {
9
- var r;
10
- let e = {
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 = {
11
20
  data: {}
12
21
  };
13
22
  try {
14
- const o = (r = (await l()).get("refresh_token")) == null ? void 0 : r.value;
15
- if (typeof o < "u" && o !== "")
23
+ const n = (s = (await h()).get("refresh_token")) == null ? void 0 : s.value;
24
+ if (typeof n < "u" && n !== "")
16
25
  try {
17
- e = await d.get("/v2/users/profile", {
26
+ t = await p.get("/v2/users/profile", {
18
27
  baseURL: process.env.AUTH_INNER_API_URL
19
28
  });
20
29
  } catch (f) {
21
- console.error(f), e = { data: {} };
30
+ console.error(f), t = { data: {} };
22
31
  }
23
32
  } catch {
24
- e = { data: {} };
33
+ t = { data: {} };
25
34
  }
26
- return /* @__PURE__ */ t("div", { className: p("sticky left-0 right-0 top-0 bg-background h-16 z-999", c), children: [
27
- /* @__PURE__ */ t("div", { className: "md:bg-module h-13 text-center flex flex-wrap justify-between items-center gap-2 px-4", children: [
28
- /* @__PURE__ */ t("div", { className: "flex items-center flex-1 gap-6", children: [
29
- /* @__PURE__ */ a(h, {}),
30
- s
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
31
40
  ] }),
32
- /* @__PURE__ */ a(x, { hideNews: n, hideLogin: m, user: (e == null ? void 0 : e.data) || {} })
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) || {} })
33
43
  ] }),
34
- i
44
+ e
35
45
  ] });
36
46
  }
37
47
  export {
48
+ g as HeaderSource,
38
49
  _ as USER_EVENTS,
39
50
  b as default,
40
- S as emitUserEvent,
41
- T as onUserEvent
51
+ A as emitUserEvent,
52
+ j as onUserEvent
42
53
  };
@@ -1,31 +1,30 @@
1
- import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
- import p from "@ichaingo/translation";
1
+ import { jsxs as a, Fragment as s, jsx as o } from "react/jsx-runtime";
2
+ import l from "@ichaingo/translation";
3
3
  import { twMerge as c } from "tailwind-merge";
4
- import { useLogin as l, OpenLoginType as m } from "@ichaingo/with-login";
5
- import { useCallback as u } from "react";
6
- function L({ onClick: o = () => {
7
- }, className: n }) {
8
- const t = async () => {
9
- window.location.reload();
10
- }, { openLogin: r, LoginModal: i } = l({ loginSuccessCallback: t }), s = u(() => {
11
- r(m.LOGIN), o == null || o();
12
- }, [r, o]);
13
- return /* @__PURE__ */ a(
14
- "div",
15
- {
16
- onClick: s,
17
- style: { cursor: "pointer" },
18
- className: c(
19
- "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
20
- n
21
- ),
22
- children: [
23
- /* @__PURE__ */ e(p, { value: "signIn", parentKey: "account" }),
24
- /* @__PURE__ */ e(i, {})
25
- ]
26
- }
27
- );
4
+ import { useLogin as p, OpenLoginType as d } from "@ichaingo/with-login";
5
+ function x({ onClick: n = () => {
6
+ }, className: e }) {
7
+ const r = async () => {
8
+ n == null || n(), window.location.reload();
9
+ }, { openLogin: t, LoginModal: i } = p({ loginSuccessCallback: r });
10
+ return /* @__PURE__ */ a(s, { children: [
11
+ /* @__PURE__ */ o(
12
+ "div",
13
+ {
14
+ onClick: () => {
15
+ t(d.LOGIN);
16
+ },
17
+ style: { cursor: "pointer" },
18
+ className: c(
19
+ "cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
20
+ e
21
+ ),
22
+ children: /* @__PURE__ */ o(l, { value: "signIn", parentKey: "account" })
23
+ }
24
+ ),
25
+ /* @__PURE__ */ o(i, {})
26
+ ] });
28
27
  }
29
28
  export {
30
- L as default
29
+ x as default
31
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/header",
3
- "version": "1.4.51",
3
+ "version": "1.4.53",
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.51",
33
- "@ichaingo/better-link": "1.4.51",
34
- "@ichaingo/image": "1.4.51",
35
- "@ichaingo/translation": "1.4.51",
36
- "@ichaingo/avatar": "1.4.51",
37
- "@ichaingo/providers": "1.4.51",
38
- "@ichaingo/ui": "1.4.51",
39
- "@ichaingo/with-login": "1.4.51",
40
- "@ichaingo/iconfont": "1.4.51",
41
- "@ichaingo/tooltip": "1.4.51",
42
- "@ichaingo/request": "1.4.51",
43
- "@ichaingo/link": "1.4.51",
44
- "@ichaingo/theme-toggle": "1.4.51",
45
- "@ichaingo/i18n": "1.4.51"
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"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/js-cookie": "^3.0.6"