@0xchain/header 1.1.0-beta.4 → 1.1.0-beta.41

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,41 +1,41 @@
1
1
  'use client';
2
- import { jsx as e, jsxs as r } from "react/jsx-runtime";
3
- import i from "@0xchain/link";
4
- import { Accordion as d, AccordionItem as m, AccordionTrigger as n, AccordionContent as s } from "@0xchain/ui/accordion";
5
- import o from "@0xchain/translation";
6
- import p from "@0xchain/avatar";
7
- function u({
8
- list: c,
9
- userInfo: l,
10
- onClick: t
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import LinkBar from "@0xchain/link";
4
+ import { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from "@0xchain/ui/accordion";
5
+ import Translation from "@0xchain/translation";
6
+ import Avatar from "@0xchain/avatar";
7
+ function Mobile({
8
+ list,
9
+ userInfo,
10
+ onClick
11
11
  }) {
12
- return /* @__PURE__ */ e(
13
- d,
12
+ return /* @__PURE__ */ jsx(
13
+ Accordion,
14
14
  {
15
15
  type: "single",
16
- collapsible: !0,
16
+ collapsible: true,
17
17
  className: "w-full",
18
18
  defaultValue: "",
19
- children: /* @__PURE__ */ r(m, { value: "item-1", className: "p-0 w-full border border-none", children: [
20
- /* @__PURE__ */ e(n, { 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__ */ r("div", { className: "flex items-center gap-2", children: [
21
- /* @__PURE__ */ e(p, { userInfo: l, className: "w-8 h-8 shrink-0" }),
22
- /* @__PURE__ */ r("div", { className: "flex flex-col overflow-hidden", children: [
23
- /* @__PURE__ */ e("div", { className: "text-sm font-medium", children: l == null ? void 0 : l.username }),
24
- /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground w-full truncate", children: (l == null ? void 0 : l.email) || (l == null ? void 0 : l.walletAddress) })
19
+ children: /* @__PURE__ */ jsxs(AccordionItem, { value: "item-1", className: "p-0 w-full border border-none", children: [
20
+ /* @__PURE__ */ jsx(AccordionTrigger, { className: "w-full bg-background p-3 flex items-center justify-between", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 w-full overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
21
+ /* @__PURE__ */ jsx(Avatar, { userInfo, className: "w-8 h-8 shrink-0" }),
22
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden", children: [
23
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: userInfo?.username }),
24
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground w-full truncate", children: userInfo?.email || userInfo?.walletAddress })
25
25
  ] })
26
26
  ] }) }) }),
27
- /* @__PURE__ */ e(s, { className: "flex text-sm flex-col text-balance bg-background rounded-lg p-3 gap-3 mt-[10px]", children: /* @__PURE__ */ e("ul", { children: c.map((a) => /* @__PURE__ */ e(
27
+ /* @__PURE__ */ jsx(AccordionContent, { className: "flex text-sm flex-col text-balance bg-background rounded-lg p-3 gap-3 mt-[10px]", children: /* @__PURE__ */ jsx("ul", { children: list.map((item) => /* @__PURE__ */ jsx(
28
28
  "li",
29
29
  {
30
30
  className: "flex justify-start items-center gap-2 py-2",
31
- children: /* @__PURE__ */ e(i, { href: `/${a.href}`, className: "flex-1 py-2", onClick: t, suppressHydrationWarning: !0, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, children: /* @__PURE__ */ e(o, { value: a.name, parentKey: "account" }) })
31
+ children: /* @__PURE__ */ jsx(LinkBar, { href: `/${item.href}`, className: "flex-1 py-2", onClick, suppressHydrationWarning: true, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, children: /* @__PURE__ */ jsx(Translation, { value: item.name, parentKey: "account" }) })
32
32
  },
33
- a.name
33
+ item.name
34
34
  )) }) })
35
35
  ] })
36
36
  }
37
37
  );
38
38
  }
39
39
  export {
40
- u as default
40
+ Mobile as default
41
41
  };
@@ -1,31 +1,33 @@
1
1
  'use client';
2
- import { jsx as l, jsxs as a } from "react/jsx-runtime";
3
- import d from "@0xchain/link";
4
- import c from "@0xchain/translation";
5
- import n from "./MainTrigger.js";
6
- import m from "./Logout.js";
7
- import s from "@0xchain/avatar";
8
- import p from "@0xchain/tooltip";
9
- function y({
10
- list: o,
11
- userInfo: e,
12
- onClick: t
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import LinkBar from "@0xchain/link";
4
+ import Translation from "@0xchain/translation";
5
+ import MainTrigger from "./MainTrigger.js";
6
+ import Logout from "./Logout.js";
7
+ import Avatar from "@0xchain/avatar";
8
+ import Tooltip from "@0xchain/tooltip";
9
+ function PC({
10
+ list,
11
+ userInfo,
12
+ onClick
13
13
  }) {
14
- return /* @__PURE__ */ l(p, { onChange: (r) => {
15
- document.querySelectorAll("iframe").forEach((i) => {
16
- i.style.pointerEvents = r ? "none" : "auto";
14
+ const onChange = (open) => {
15
+ const iframes = document.querySelectorAll("iframe");
16
+ iframes.forEach((iframe) => {
17
+ iframe.style.pointerEvents = open ? "none" : "auto";
17
18
  });
18
- }, trigger: /* @__PURE__ */ l(n, { userInfo: e }), arrowClassName: "fill-card", contentClassName: "text-foreground w-75 p-0 border-transparent outline-none ", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-2 p-3 bg-card rounded-md", children: [
19
- /* @__PURE__ */ l("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: [
20
- /* @__PURE__ */ l(s, { userInfo: e, className: "w-8 h-8" }),
21
- /* @__PURE__ */ a("div", { className: "flex flex-col overflow-hidden", children: [
22
- /* @__PURE__ */ l("div", { className: "text-sm font-medium", children: (e == null ? void 0 : e.username) || "--" }),
23
- /* @__PURE__ */ l("div", { className: "text-xs text-muted-foreground w-full truncate", children: (e == null ? void 0 : e.email) || (e == null ? void 0 : e.walletAddress) })
19
+ };
20
+ return /* @__PURE__ */ jsx(Tooltip, { onChange, trigger: /* @__PURE__ */ jsx(MainTrigger, { userInfo }), arrowClassName: "fill-card", contentClassName: "text-foreground w-75 p-0 border-transparent outline-none ", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 p-3 bg-card rounded-md", children: [
21
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 w-full bg-background rounded-lg p-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
22
+ /* @__PURE__ */ jsx(Avatar, { userInfo, className: "w-8 h-8" }),
23
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col overflow-hidden", children: [
24
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: userInfo?.username || "--" }),
25
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground w-full truncate", children: userInfo?.email || userInfo?.walletAddress })
24
26
  ] })
25
27
  ] }) }),
26
- o.map((r) => /* @__PURE__ */ l("div", { className: "px-0 py-0 focus-visible:border-none focus-visible:outline-none", children: /* @__PURE__ */ l("div", { className: "flex items-center gap-2 w-full", children: r.name === "logout" ? /* @__PURE__ */ l(m, { className: "flex-1 flex py-3 border-t border-border w-full px-2 hover:bg-background" }) : /* @__PURE__ */ l(d, { href: `/${r.href}`, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, className: "flex-1 flex py-3 h-full w-full px-2 hover:bg-background hover:text-primary rounded-lg ", onClick: t, children: /* @__PURE__ */ l(c, { value: r.name, parentKey: "account" }) }) }) }, r.name))
28
+ list.map((item) => /* @__PURE__ */ jsx("div", { className: "px-0 py-0 focus-visible:border-none focus-visible:outline-none", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 w-full", children: item.name === "logout" ? /* @__PURE__ */ jsx(Logout, { className: "flex-1 flex py-3 border-t border-border w-full px-2 hover:bg-background" }) : /* @__PURE__ */ jsx(LinkBar, { href: `/${item.href}`, baseUrl: process.env.NEXT_PUBLIC_AUTH_URL, className: "flex-1 flex py-3 h-full w-full px-2 hover:bg-background hover:text-primary rounded-lg ", onClick, children: /* @__PURE__ */ jsx(Translation, { value: item.name, parentKey: "account" }) }) }) }, item.name))
27
29
  ] }) });
28
30
  }
29
31
  export {
30
- y as default
32
+ PC as default
31
33
  };
@@ -1,25 +1,26 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import o from "@0xchain/translation";
3
- import { twMerge as i } from "tailwind-merge";
4
- import { useLogin as p, OpenLoginType as s } from "@0xchain/with-login";
5
- function g({ onClick: r = () => {
6
- }, className: t }) {
7
- const { openLogin: n } = p();
8
- return /* @__PURE__ */ e(
1
+ import { jsx } from "react/jsx-runtime";
2
+ import Translation from "@0xchain/translation";
3
+ import { twMerge } from "tailwind-merge";
4
+ import { useLogin, OpenLoginType } from "@0xchain/with-login";
5
+ function SignIn({ onClick = () => void 0, className }) {
6
+ const { openLogin } = useLogin();
7
+ const handleClick = () => {
8
+ onClick?.();
9
+ openLogin(OpenLoginType.LOGIN);
10
+ };
11
+ return /* @__PURE__ */ jsx(
9
12
  "div",
10
13
  {
11
- onClick: () => {
12
- r == null || r(), n(s.LOGIN);
13
- },
14
+ onClick: handleClick,
14
15
  style: { cursor: "pointer" },
15
- className: i(
16
+ className: twMerge(
16
17
  "cursor-pointer text-sm text-white! bg-primary! py-2 px-3 rounded-lg",
17
- t
18
+ className
18
19
  ),
19
- children: /* @__PURE__ */ e(o, { value: "signIn", parentKey: "account" })
20
+ children: /* @__PURE__ */ jsx(Translation, { value: "signIn", parentKey: "account" })
20
21
  }
21
22
  );
22
23
  }
23
24
  export {
24
- g as default
25
+ SignIn as default
25
26
  };
@@ -1,41 +1,43 @@
1
1
  'use client';
2
- import { jsx as r, jsxs as n, Fragment as o } from "react/jsx-runtime";
3
- import a from "./Pc.js";
4
- import c from "./Mobile.js";
5
- import { twMerge as i } from "tailwind-merge";
6
- import s from "./SignIn.js";
7
- const d = [
2
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import PC from "./Pc.js";
4
+ import Mobile from "./Mobile.js";
5
+ import { twMerge } from "tailwind-merge";
6
+ import SignIn from "./SignIn.js";
7
+ const list = [
8
8
  {
9
9
  name: "overview",
10
- href: "user-center"
10
+ href: `user-center`
11
11
  },
12
12
  {
13
13
  name: "collect",
14
- href: "user-center/collect"
14
+ href: `user-center/collect`
15
15
  },
16
16
  {
17
17
  name: "privateLabel",
18
- href: "user-center/private-label"
18
+ href: `user-center/private-label`
19
19
  },
20
20
  {
21
21
  name: "setting",
22
- href: "user-center/setting"
22
+ href: `user-center/setting`
23
23
  },
24
24
  {
25
25
  name: "logout",
26
26
  href: void 0
27
27
  }
28
28
  ];
29
- function x({ onClick: t = (l) => {
30
- }, className: m, userInfo: e }) {
31
- return e != null && e.id ? /* @__PURE__ */ n(o, { children: [
32
- /* @__PURE__ */ r("div", { className: i("hidden md:flex items-center", m), children: /* @__PURE__ */ r(a, { list: d, userInfo: e, onClick: t }) }),
33
- /* @__PURE__ */ r("div", { className: i("block md:hidden w-full", m), children: /* @__PURE__ */ r(c, { list: d.filter((l) => l.href), userInfo: e, onClick: t }) })
34
- ] }) : /* @__PURE__ */ r(s, { onClick: t, className: i(
35
- "hidden md:flex cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
36
- "order-3"
37
- ) });
29
+ function UserControl({ onClick = (e) => void 0, className, userInfo }) {
30
+ if (!userInfo?.id) {
31
+ return /* @__PURE__ */ jsx(SignIn, { onClick, className: twMerge(
32
+ "hidden md:flex cursor-pointer text-sm text-white bg-primary py-2 px-3 rounded-lg",
33
+ "order-3"
34
+ ) });
35
+ }
36
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
37
+ /* @__PURE__ */ jsx("div", { className: twMerge("hidden md:flex items-center", className), children: /* @__PURE__ */ jsx(PC, { list, userInfo, onClick }) }),
38
+ /* @__PURE__ */ jsx("div", { className: twMerge("block md:hidden w-full", className), children: /* @__PURE__ */ jsx(Mobile, { list: list.filter((item) => item.href), userInfo, onClick }) })
39
+ ] });
38
40
  }
39
41
  export {
40
- x as default
42
+ UserControl as default
41
43
  };
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { createContext, useContext } from "react";
4
+ const HeaderContext = createContext({
5
+ brand: "iChatGo"
6
+ });
7
+ function HeaderProvider({
8
+ children,
9
+ brand = "iChatGo"
10
+ }) {
11
+ return /* @__PURE__ */ jsx(HeaderContext.Provider, { value: { brand }, children });
12
+ }
13
+ function useHeaderContext() {
14
+ return useContext(HeaderContext);
15
+ }
16
+ function useIsChaindigg() {
17
+ const { brand } = useHeaderContext();
18
+ return brand === "CHAINDIGG";
19
+ }
20
+ export {
21
+ HeaderProvider,
22
+ useHeaderContext,
23
+ useIsChaindigg
24
+ };
@@ -1,24 +1,26 @@
1
- const E = {
1
+ const USER_EVENTS = {
2
2
  PROFILE_UPDATED: "user-profile-updated",
3
3
  LOGGED_IN: "user-logged-in",
4
4
  LOGGED_OUT: "user-logged-out"
5
5
  };
6
- function i(e, n) {
7
- const t = new CustomEvent(e, { detail: n });
8
- window.dispatchEvent(t);
6
+ function emitUserEvent(eventName, data) {
7
+ const event = new CustomEvent(eventName, { detail: data });
8
+ window.dispatchEvent(event);
9
9
  }
10
- function r(e, n) {
11
- const t = (o) => {
12
- n(o.detail);
10
+ function onUserEvent(eventName, callback) {
11
+ const handler = (event) => {
12
+ const customEvent = event;
13
+ callback(customEvent.detail);
13
14
  };
14
- return window.addEventListener(e, t), () => window.removeEventListener(e, t);
15
+ window.addEventListener(eventName, handler);
16
+ return () => window.removeEventListener(eventName, handler);
15
17
  }
16
- function d(e, n) {
17
- window.removeEventListener(e, n);
18
+ function cleanUserEvent(type, handler) {
19
+ window.removeEventListener(type, handler);
18
20
  }
19
21
  export {
20
- E as USER_EVENTS,
21
- d as cleanUserEvent,
22
- i as emitUserEvent,
23
- r as onUserEvent
22
+ USER_EVENTS,
23
+ cleanUserEvent,
24
+ emitUserEvent,
25
+ onUserEvent
24
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xchain/header",
3
- "version": "1.1.0-beta.4",
3
+ "version": "1.1.0-beta.41",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -17,34 +17,49 @@
17
17
  "dist",
18
18
  "!**/*.tsbuildinfo"
19
19
  ],
20
- "devDependencies": {
21
- "rollup-plugin-preserve-use-client": "3.0.1",
22
- "@types/js-cookie": "3.0.6"
20
+ "peerDependencies": {
21
+ "antd": "6.1.1",
22
+ "lucide-react": "0.539.0",
23
+ "next": "16.1.6",
24
+ "next-intl": "4.13.0",
25
+ "rc-drawer": "7.3.0",
26
+ "react": "19.1.1",
27
+ "react-dom": "19.1.1",
28
+ "tailwind-merge": "3.3.1"
23
29
  },
24
- "dependencies": {
30
+ "devDependencies": {
31
+ "@0xchain/next-themes": "1.0.0",
32
+ "@types/js-cookie": "3.0.6",
33
+ "antd": "6.1.1",
25
34
  "js-cookie": "3.0.5",
26
35
  "lucide-react": "0.539.0",
27
- "next-intl": "4.6.1",
28
- "@0xchain/next-themes": "1.0.0",
36
+ "next": "16.1.6",
37
+ "next-intl": "4.13.0",
29
38
  "rc-drawer": "7.3.0",
30
39
  "react": "19.1.1",
31
40
  "react-dom": "19.1.1",
32
- "tailwind-merge": "3.3.1",
33
- "next": "15.5.6",
34
- "antd": "6.1.1",
35
- "@0xchain/auth": "1.1.0-beta.4",
36
- "@0xchain/image": "1.1.0-beta.4",
37
- "@0xchain/translation": "1.1.0-beta.4",
38
- "@0xchain/better-link": "1.1.0-beta.4",
39
- "@0xchain/link": "1.1.0-beta.4",
40
- "@0xchain/avatar": "1.1.0-beta.4",
41
- "@0xchain/iconfont": "1.1.0-beta.4",
42
- "@0xchain/request": "1.1.0-beta.4",
43
- "@0xchain/with-login": "1.1.0-beta.4",
44
- "@0xchain/tooltip": "1.1.0-beta.4",
45
- "@0xchain/token": "1.1.0-beta.4",
46
- "@0xchain/ui": "1.1.0-beta.4",
47
- "@0xchain/theme-toggle": "1.1.0-beta.4"
41
+ "rollup-plugin-preserve-use-client": "3.0.1",
42
+ "tailwind-merge": "3.3.1"
43
+ },
44
+ "dependencies": {
45
+ "@0xchain/i18n": "1.1.0-beta.41",
46
+ "@0xchain/auth": "1.1.0-beta.41",
47
+ "@0xchain/link": "1.1.0-beta.41",
48
+ "@0xchain/avatar": "1.1.0-beta.41",
49
+ "@0xchain/better-link": "1.1.0-beta.41",
50
+ "@0xchain/image": "1.1.0-beta.41",
51
+ "@0xchain/theme-toggle": "1.1.0-beta.41",
52
+ "@0xchain/iconfont": "1.1.0-beta.41",
53
+ "@0xchain/with-login": "1.1.0-beta.41",
54
+ "@0xchain/translation": "1.1.0-beta.41",
55
+ "@0xchain/tooltip": "1.1.0-beta.41",
56
+ "@0xchain/request": "1.1.0-beta.41",
57
+ "@0xchain/ui": "1.1.0-beta.41"
58
+ },
59
+ "nx": {
60
+ "tags": [
61
+ "type:feature"
62
+ ]
48
63
  },
49
64
  "publishConfig": {
50
65
  "access": "public"