@0xchain/header 1.1.0-beta.44 → 1.1.0-beta.46

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/lib/Nav.js CHANGED
@@ -14,6 +14,7 @@ import { fetchUserProfile } from "@0xchain/auth";
14
14
  import { onUserEvent, USER_EVENTS, cleanUserEvent } from "./events.js";
15
15
  import { usePathname } from "next/navigation";
16
16
  import Explorer from "./Explorer.js";
17
+ import Products from "./Products.js";
17
18
  import { useIsChaindigg } from "./context.js";
18
19
  function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user }) {
19
20
  const isChaindigg = useIsChaindigg();
@@ -22,7 +23,7 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
22
23
  const pathname = usePathname();
23
24
  const [userKey, setUserKey] = useState("");
24
25
  const [userInfo, setUserInfo] = useState(user);
25
- const [explorerExpanded, setExplorerExpanded] = useState(false);
26
+ const [, setExplorerExpanded] = useState(false);
26
27
  const ichaingoNavList = [
27
28
  {
28
29
  baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
@@ -36,21 +37,26 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
36
37
  {
37
38
  baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
38
39
  href: gotoAISQL({ locale }),
39
- key: "/sql",
40
- label: "iSQL",
40
+ key: "/query",
41
+ label: "iQuery",
41
42
  show: (pathname2) => {
42
- return pathname2.includes(`/${locale}/sql`);
43
+ return pathname2.includes(`/${locale}/query`);
43
44
  }
44
45
  },
45
46
  {
46
- baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
47
- href: `/explorer`,
48
47
  key: "/explorer",
49
48
  label: /* @__PURE__ */ jsx(Explorer, { onClick, onExpandChange: setExplorerExpanded }),
50
49
  show: (pathname2) => {
51
50
  return pathname2.includes(`/explorer`);
52
51
  }
53
52
  },
53
+ {
54
+ key: "/products",
55
+ label: /* @__PURE__ */ jsx(Products, { onClick }),
56
+ show: (pathname2) => {
57
+ return pathname2.includes("/widget");
58
+ }
59
+ },
54
60
  {
55
61
  baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
56
62
  href: `/learn`,
@@ -80,14 +86,12 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
80
86
  }
81
87
  ]?.filter((item) => {
82
88
  if (hideNews) {
83
- return !["/explorer", "/chat", "/sql"].includes(item.key);
89
+ return !["/explorer", "/chat", "/query"].includes(item.key);
84
90
  }
85
91
  return true;
86
92
  });
87
93
  const chaindiggNavList = [
88
94
  {
89
- baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
90
- href: `/explorer`,
91
95
  key: "/explorer",
92
96
  label: /* @__PURE__ */ jsx(Explorer, {}),
93
97
  show: (pathname2) => {
@@ -137,7 +141,7 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
137
141
  "w-full md:w-auto h-11 md:h-auto cursor-pointer hover:text-primary",
138
142
  item.show(pathname) && "border-b-2 border-primary text-primary"
139
143
  ),
140
- children: item.href === pathname ? item.label : /* @__PURE__ */ jsx(
144
+ children: !item.href || item.href === pathname ? item.label : /* @__PURE__ */ jsx(
141
145
  LinkBar,
142
146
  {
143
147
  href: item.href,
@@ -181,10 +185,10 @@ function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user
181
185
  {
182
186
  className: twMerge(
183
187
  "w-full md:px-4 md:py-1 md:h-auto font-bold md:w-auto cursor-pointer md:rounded-full",
184
- item.key === "/explorer" ? "h-auto" : "h-11",
188
+ item.key === "/explorer" || item.key === "/products" ? "h-auto" : "h-11",
185
189
  item.show(pathname) ? "md:text-primary md:bg-primary/10" : "md:hover:bg-border"
186
190
  ),
187
- children: item.href === pathname ? item.label : /* @__PURE__ */ jsx(
191
+ children: !item.href || item.href === pathname ? item.label : /* @__PURE__ */ jsx(
188
192
  LinkBar,
189
193
  {
190
194
  href: item.href,
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
3
+ import Translation from "@0xchain/translation";
4
+ import { useLocale } from "@0xchain/i18n/react";
5
+ import { Dropdown } from "antd";
6
+ import { useState } from "react";
7
+ import { Accordion, AccordionItem, AccordionTrigger } from "@0xchain/ui/accordion";
8
+ const PRODUCT_ITEMS = [
9
+ {
10
+ key: "widget",
11
+ href: "/widget",
12
+ label: /* @__PURE__ */ jsx(Translation, { value: "products.widget", parentKey: "menu" })
13
+ }
14
+ ];
15
+ function Products({
16
+ onClick,
17
+ onExpandChange
18
+ }) {
19
+ const locale = useLocale();
20
+ const [accordionValue, setAccordionValue] = useState("");
21
+ const handleClick = (e, href) => {
22
+ e?.preventDefault();
23
+ e?.stopPropagation();
24
+ onClick?.();
25
+ setAccordionValue("");
26
+ const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "";
27
+ window.location.href = `${baseUrl}/${locale}${href}`;
28
+ };
29
+ const renderItemContent = (item) => /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center gap-2 py-2 cursor-pointer font-medium", children: item.label });
30
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
31
+ /* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx(
32
+ Dropdown,
33
+ {
34
+ getPopupContainer: () => document.body,
35
+ classNames: {
36
+ root: "w-50"
37
+ },
38
+ arrow: { pointAtCenter: true },
39
+ placement: "bottom",
40
+ menu: {
41
+ items: PRODUCT_ITEMS.map((item) => ({
42
+ label: renderItemContent(item),
43
+ key: item.key,
44
+ onClick: (info) => handleClick(info.domEvent, item.href)
45
+ }))
46
+ },
47
+ children: /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap flex items-center gap-1 rounded-lg", children: /* @__PURE__ */ jsx(Translation, { value: "products.product", parentKey: "menu" }) })
48
+ }
49
+ ) }),
50
+ /* @__PURE__ */ jsx("div", { className: "md:hidden w-full", children: /* @__PURE__ */ jsxs("div", { onClick: (e) => {
51
+ e.preventDefault();
52
+ e.stopPropagation();
53
+ }, children: [
54
+ /* @__PURE__ */ jsx(
55
+ Accordion,
56
+ {
57
+ type: "single",
58
+ collapsible: true,
59
+ className: "w-full",
60
+ value: accordionValue,
61
+ onValueChange: (value) => {
62
+ setAccordionValue(value);
63
+ onExpandChange?.(!!value);
64
+ },
65
+ children: /* @__PURE__ */ jsx(AccordionItem, { value: "products", className: "border-0", children: /* @__PURE__ */ jsx(AccordionTrigger, { className: "rounded-lg font-medium h-11 w-full flex py-2 justify-between items-center hover:no-underline focus-visible:ring-0 focus-visible:ring-offset-0", children: /* @__PURE__ */ jsx("div", { className: "flex w-full justify-between items-center", children: /* @__PURE__ */ jsx("span", { className: "text-foreground", children: /* @__PURE__ */ jsx(Translation, { value: "products.product", parentKey: "menu" }) }) }) }) })
66
+ }
67
+ ),
68
+ /* @__PURE__ */ jsx(
69
+ "div",
70
+ {
71
+ className: "grid transition-[grid-template-rows] duration-300 ease-in-out",
72
+ style: { gridTemplateRows: accordionValue ? "1fr" : "0fr" },
73
+ children: /* @__PURE__ */ jsx("div", { className: "overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-3 rounded-lg flex flex-col gap-2 max-h-[60vh] overflow-auto", children: PRODUCT_ITEMS.map((item) => /* @__PURE__ */ jsx(
74
+ "div",
75
+ {
76
+ className: "w-full",
77
+ onClick: (e) => handleClick(e, item.href),
78
+ children: renderItemContent(item)
79
+ },
80
+ item.key
81
+ )) }) })
82
+ }
83
+ )
84
+ ] }) })
85
+ ] });
86
+ }
87
+ export {
88
+ Products as default
89
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xchain/header",
3
- "version": "1.1.0-beta.44",
3
+ "version": "1.1.0-beta.46",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -42,19 +42,19 @@
42
42
  "tailwind-merge": "3.3.1"
43
43
  },
44
44
  "dependencies": {
45
- "@0xchain/i18n": "1.1.0-beta.44",
46
- "@0xchain/auth": "1.1.0-beta.44",
47
- "@0xchain/avatar": "1.1.0-beta.44",
48
- "@0xchain/image": "1.1.0-beta.44",
49
- "@0xchain/link": "1.1.0-beta.44",
50
- "@0xchain/ui": "1.1.0-beta.44",
51
- "@0xchain/translation": "1.1.0-beta.44",
52
- "@0xchain/theme-toggle": "1.1.0-beta.44",
53
- "@0xchain/request": "1.1.0-beta.44",
54
- "@0xchain/iconfont": "1.1.0-beta.44",
55
- "@0xchain/with-login": "1.1.0-beta.44",
56
- "@0xchain/tooltip": "1.1.0-beta.44",
57
- "@0xchain/better-link": "1.1.0-beta.44"
45
+ "@0xchain/i18n": "1.1.0-beta.46",
46
+ "@0xchain/auth": "1.1.0-beta.46",
47
+ "@0xchain/better-link": "1.1.0-beta.46",
48
+ "@0xchain/translation": "1.1.0-beta.46",
49
+ "@0xchain/image": "1.1.0-beta.46",
50
+ "@0xchain/ui": "1.1.0-beta.46",
51
+ "@0xchain/theme-toggle": "1.1.0-beta.46",
52
+ "@0xchain/iconfont": "1.1.0-beta.46",
53
+ "@0xchain/link": "1.1.0-beta.46",
54
+ "@0xchain/with-login": "1.1.0-beta.46",
55
+ "@0xchain/request": "1.1.0-beta.46",
56
+ "@0xchain/tooltip": "1.1.0-beta.46",
57
+ "@0xchain/avatar": "1.1.0-beta.46"
58
58
  },
59
59
  "nx": {
60
60
  "tags": [