@0xchain/header 1.1.0-beta.1 → 1.1.0-beta.100
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 +10 -1
- package/dist/index.js +45 -37
- package/dist/lib/Drawer.js +41 -16
- package/dist/lib/Explorer.js +62 -52
- package/dist/lib/Logo.js +74 -17
- package/dist/lib/Nav.js +187 -68
- package/dist/lib/PointsEntry.js +121 -0
- package/dist/lib/Products.js +102 -0
- package/dist/lib/Right.js +24 -16
- package/dist/lib/Setting/SettingBody.js +44 -36
- package/dist/lib/Setting/index.js +45 -14
- package/dist/lib/User/Logout.js +13 -13
- package/dist/lib/User/MainTrigger.js +33 -23
- package/dist/lib/User/Mobile.js +22 -22
- package/dist/lib/User/Pc.js +24 -22
- package/dist/lib/User/SignIn.js +16 -15
- package/dist/lib/User/index.js +27 -20
- package/dist/lib/authProfile.js +34 -0
- package/dist/lib/context.js +24 -0
- package/dist/lib/events.js +13 -15
- package/dist/lib/headerPoints.js +102 -0
- package/dist/lib/headerSource.js +13 -0
- package/dist/lib/loadHeaderBarUser.js +42 -0
- package/dist/lib/useHeaderUser.js +44 -0
- package/package.json +41 -24
package/dist/lib/Nav.js
CHANGED
|
@@ -1,102 +1,221 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { twMerge
|
|
8
|
-
import
|
|
9
|
-
import { useLocale
|
|
10
|
-
import
|
|
11
|
-
import { useState
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import LinkBar from "@0xchain/link";
|
|
4
|
+
import UserControl from "./User/index.js";
|
|
5
|
+
import Setting from "./Setting/index.js";
|
|
6
|
+
import Translation from "@0xchain/translation";
|
|
7
|
+
import { twMerge } from "tailwind-merge";
|
|
8
|
+
import BetterLink from "@0xchain/better-link";
|
|
9
|
+
import { useLocale } from "@0xchain/i18n/react";
|
|
10
|
+
import Logout from "./User/Logout.js";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import SignIn from "./User/SignIn.js";
|
|
13
|
+
import { usePathname } from "next/navigation";
|
|
14
|
+
import Explorer from "./Explorer.js";
|
|
15
|
+
import Products from "./Products.js";
|
|
16
|
+
import PointsEntry from "./PointsEntry.js";
|
|
17
|
+
import { useIsChaindigg } from "./context.js";
|
|
18
|
+
import { useHeaderUser } from "./useHeaderUser.js";
|
|
19
|
+
function Nav({ onClick = () => void 0, hideNews = false, hideLogin = false, user }) {
|
|
20
|
+
const isChaindigg = useIsChaindigg();
|
|
21
|
+
const { gotoAISQL, gotoChat } = BetterLink();
|
|
22
|
+
const locale = useLocale();
|
|
23
|
+
const pathname = usePathname();
|
|
24
|
+
const { userInfo, hasUserProfile, userKey } = useHeaderUser(user);
|
|
25
|
+
const [, setExplorerExpanded] = useState(false);
|
|
26
|
+
const ichaingoNavList = [
|
|
20
27
|
{
|
|
21
28
|
baseUrl: process.env.NEXT_PUBLIC_CHAT_URL,
|
|
22
|
-
href:
|
|
23
|
-
key: `/${
|
|
24
|
-
label: /* @__PURE__ */
|
|
25
|
-
show: (
|
|
29
|
+
href: gotoChat({ locale }),
|
|
30
|
+
key: `/${locale}`,
|
|
31
|
+
label: /* @__PURE__ */ jsx("span", { children: "iSearch" }),
|
|
32
|
+
show: (pathname2) => {
|
|
33
|
+
return pathname2 === `/${locale}` || pathname2.includes(`/${locale}/conversation`);
|
|
34
|
+
}
|
|
26
35
|
},
|
|
27
36
|
{
|
|
28
|
-
baseUrl: process.env.
|
|
29
|
-
href:
|
|
30
|
-
key: "/
|
|
31
|
-
label: "
|
|
32
|
-
show: (
|
|
37
|
+
baseUrl: process.env.NEXT_PUBLIC_APP_URL,
|
|
38
|
+
href: gotoAISQL({ locale }),
|
|
39
|
+
key: "/query",
|
|
40
|
+
label: "iQuery",
|
|
41
|
+
show: (pathname2) => {
|
|
42
|
+
return pathname2.includes(`/${locale}/query`);
|
|
43
|
+
}
|
|
33
44
|
},
|
|
34
45
|
{
|
|
35
|
-
baseUrl: process.env.
|
|
36
|
-
href: "/explorer",
|
|
46
|
+
baseUrl: process.env.NEXT_PUBLIC_APP_URL,
|
|
37
47
|
key: "/explorer",
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
href: "/explorer",
|
|
49
|
+
label: /* @__PURE__ */ jsx(Explorer, { onClick, onExpandChange: setExplorerExpanded }),
|
|
50
|
+
show: (pathname2) => {
|
|
51
|
+
return pathname2.includes(`/explorer`);
|
|
52
|
+
}
|
|
40
53
|
},
|
|
41
|
-
// {
|
|
42
|
-
// baseUrl: process.env.NEXT_PUBLIC_BASE_URL,
|
|
43
|
-
// href: `/etf/btc-us`,
|
|
44
|
-
// key: '/etf',
|
|
45
|
-
// label: <Translation value="etf" parentKey="menu" />,
|
|
46
|
-
// show: (pathname: string) => {
|
|
47
|
-
// return pathname.includes(`/etf`)
|
|
48
|
-
// }
|
|
49
|
-
// },
|
|
50
54
|
{
|
|
51
|
-
baseUrl: process.env.
|
|
52
|
-
href:
|
|
55
|
+
baseUrl: process.env.NEXT_PUBLIC_APP_URL,
|
|
56
|
+
href: `/news`,
|
|
53
57
|
key: "/news",
|
|
54
|
-
label: /* @__PURE__ */
|
|
55
|
-
show: (
|
|
58
|
+
label: /* @__PURE__ */ jsx(Translation, { value: "news", parentKey: "menu" }),
|
|
59
|
+
show: (pathname2) => {
|
|
60
|
+
return pathname2.includes(`/news`);
|
|
61
|
+
}
|
|
56
62
|
},
|
|
57
63
|
{
|
|
58
|
-
baseUrl: process.env.
|
|
59
|
-
href:
|
|
64
|
+
baseUrl: process.env.NEXT_PUBLIC_APP_URL,
|
|
65
|
+
href: `/ranking`,
|
|
60
66
|
key: "/ranking",
|
|
61
|
-
label: /* @__PURE__ */
|
|
62
|
-
show: (
|
|
67
|
+
label: /* @__PURE__ */ jsx(Translation, { value: "ranking", parentKey: "menu" }),
|
|
68
|
+
show: (pathname2) => {
|
|
69
|
+
return pathname2.includes(`/ranking`);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
baseUrl: process.env.NEXT_PUBLIC_APP_URL,
|
|
74
|
+
href: `/learn`,
|
|
75
|
+
key: "/learn",
|
|
76
|
+
label: /* @__PURE__ */ jsx(Translation, { value: "learn", parentKey: "menu" }),
|
|
77
|
+
show: (pathname2) => {
|
|
78
|
+
return pathname2.includes(`/learn`);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
baseUrl: process.env.NEXT_PUBLIC_APP_URL,
|
|
83
|
+
key: "/products",
|
|
84
|
+
label: /* @__PURE__ */ jsx(Products, { onClick }),
|
|
85
|
+
show: (pathname2) => {
|
|
86
|
+
return pathname2.includes("/widget");
|
|
87
|
+
}
|
|
63
88
|
}
|
|
64
|
-
]
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
89
|
+
]?.filter((item) => {
|
|
90
|
+
if (hideNews) {
|
|
91
|
+
return !["/explorer", "/chat", "/query"].includes(item.key);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
});
|
|
95
|
+
const chaindiggNavList = [
|
|
96
|
+
{
|
|
97
|
+
key: "/explorer",
|
|
98
|
+
label: /* @__PURE__ */ jsx(Explorer, {}),
|
|
99
|
+
show: (pathname2) => {
|
|
100
|
+
return pathname2.includes(`/explorer`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
const NavList = isChaindigg ? chaindiggNavList : ichaingoNavList;
|
|
105
|
+
if (isChaindigg) {
|
|
106
|
+
return /* @__PURE__ */ jsxs(
|
|
107
|
+
"nav",
|
|
108
|
+
{
|
|
109
|
+
className: twMerge(
|
|
110
|
+
"flex flex-col justify-start items-start md:px-3",
|
|
111
|
+
"md:flex-row md:justify-start md:items-start md:px-0",
|
|
112
|
+
"md:gap-6"
|
|
113
|
+
),
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
"ul",
|
|
117
|
+
{
|
|
118
|
+
className: twMerge(
|
|
119
|
+
"flex flex-col flex-1 justify-start items-start w-full h-full text-sm leading-[44px] z-1001 text-foreground",
|
|
120
|
+
"md:flex-row md:items-center md:w-auto md:h-[34px] md:leading-[34px] md:gap-5",
|
|
121
|
+
"order-2 md:order-0"
|
|
122
|
+
),
|
|
123
|
+
children: NavList.map((item, index) => /* @__PURE__ */ jsx(
|
|
124
|
+
"li",
|
|
125
|
+
{
|
|
126
|
+
className: twMerge(
|
|
127
|
+
"w-full md:w-auto h-11 md:h-auto cursor-pointer hover:text-primary",
|
|
128
|
+
item.show(pathname) && "border-b-2 border-primary text-primary"
|
|
129
|
+
),
|
|
130
|
+
children: !item.href || item.href === pathname ? item.label : /* @__PURE__ */ jsx(
|
|
131
|
+
LinkBar,
|
|
132
|
+
{
|
|
133
|
+
href: item.href,
|
|
134
|
+
onClick,
|
|
135
|
+
className: twMerge(
|
|
136
|
+
"w-full md:w-auto h-11 md:h-auto cursor-pointer hover:text-primary",
|
|
137
|
+
item.show(pathname) && "border-b-2 border-primary text-primary",
|
|
138
|
+
"h-full flex items-center justify-start"
|
|
139
|
+
),
|
|
140
|
+
baseUrl: item.baseUrl,
|
|
141
|
+
suppressHydrationWarning: true,
|
|
142
|
+
children: item.label
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
},
|
|
146
|
+
index
|
|
147
|
+
))
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
/* @__PURE__ */ jsx(Setting, { onClick })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsxs(
|
|
72
156
|
"nav",
|
|
73
157
|
{
|
|
74
|
-
className:
|
|
158
|
+
className: twMerge(
|
|
75
159
|
"flex flex-col justify-start items-start md:px-3",
|
|
76
|
-
"md:flex-row md:justify-end md:items-center
|
|
160
|
+
"md:flex-row md:justify-end md:items-center md:px-0 md:flex-1",
|
|
77
161
|
"md:gap-4"
|
|
78
162
|
),
|
|
79
163
|
children: [
|
|
80
|
-
/* @__PURE__ */
|
|
164
|
+
/* @__PURE__ */ jsx(
|
|
81
165
|
"ul",
|
|
82
166
|
{
|
|
83
|
-
className:
|
|
84
|
-
"flex flex-col justify-start items-start w-full
|
|
85
|
-
"md:flex-row md:items-center md:w-auto md:h-[34px]
|
|
167
|
+
className: twMerge(
|
|
168
|
+
"flex flex-col justify-start items-start w-full h-full text-sm z-1001 text-foreground",
|
|
169
|
+
"md:flex-row md:items-center md:w-auto md:h-[34px] md:gap-6 md:flex-1",
|
|
86
170
|
"order-2 md:order-0"
|
|
87
171
|
),
|
|
88
|
-
children:
|
|
172
|
+
children: NavList.map((item, index) => {
|
|
173
|
+
return /* @__PURE__ */ jsx(
|
|
174
|
+
"li",
|
|
175
|
+
{
|
|
176
|
+
className: twMerge(
|
|
177
|
+
"w-full md:h-auto font-bold md:w-auto cursor-pointer md:rounded-full",
|
|
178
|
+
item.key === "/explorer" || item.key === "/products" ? "h-auto" : "h-11",
|
|
179
|
+
item.show(pathname) ? "md:text-primary md:bg-primary/10" : "md:hover:bg-border"
|
|
180
|
+
),
|
|
181
|
+
children: !item.href || item.href === pathname ? item.label : /* @__PURE__ */ jsx(
|
|
182
|
+
LinkBar,
|
|
183
|
+
{
|
|
184
|
+
href: item.href,
|
|
185
|
+
onClick,
|
|
186
|
+
className: twMerge(
|
|
187
|
+
"w-full md:px-4 md:py-1 md:h-auto font-bold md:w-auto cursor-pointer md:rounded-full",
|
|
188
|
+
item.key === "/explorer" || item.key === "/products" ? "h-auto" : "h-11",
|
|
189
|
+
item.show(pathname) ? "md:text-primary md:bg-primary/10" : "md:hover:bg-border",
|
|
190
|
+
"h-full flex items-center justify-start"
|
|
191
|
+
),
|
|
192
|
+
baseUrl: item.baseUrl,
|
|
193
|
+
suppressHydrationWarning: true,
|
|
194
|
+
children: item.label
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
},
|
|
198
|
+
index
|
|
199
|
+
);
|
|
200
|
+
})
|
|
89
201
|
}
|
|
90
202
|
),
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
203
|
+
!pathname.includes("/login") && !hideLogin ? /* @__PURE__ */ jsx(PointsEntry, { userInfo, className: "hidden md:inline-flex", onClick }) : null,
|
|
204
|
+
/* @__PURE__ */ jsx(Setting, { onClick }),
|
|
205
|
+
!pathname.includes("/login") && !hideLogin ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
206
|
+
/* @__PURE__ */ jsx(UserControl, { onClick, userInfo }, userKey),
|
|
207
|
+
hasUserProfile ? /* @__PURE__ */ jsx("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-muted-foreground", children: /* @__PURE__ */ jsx(Logout, {}) }) : /* @__PURE__ */ jsx(
|
|
208
|
+
SignIn,
|
|
209
|
+
{
|
|
210
|
+
onClick,
|
|
211
|
+
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"
|
|
212
|
+
}
|
|
213
|
+
)
|
|
95
214
|
] }) : null
|
|
96
215
|
]
|
|
97
216
|
}
|
|
98
217
|
);
|
|
99
218
|
}
|
|
100
219
|
export {
|
|
101
|
-
|
|
220
|
+
Nav as default
|
|
102
221
|
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import LinkBar from "@0xchain/link";
|
|
5
|
+
import Translation from "@0xchain/translation";
|
|
6
|
+
import ImageBar from "@0xchain/image";
|
|
7
|
+
import request from "@0xchain/request";
|
|
8
|
+
import { useLogin, OpenLoginType } from "@0xchain/with-login";
|
|
9
|
+
import { twMerge } from "tailwind-merge";
|
|
10
|
+
import { headerPointsShowAmount, hasTrustedHeaderPoints, formatHeaderPoints, HEADER_POINTS_OVERVIEW_PATH, pointsTextFromOverview, HEADER_POINTS_ICON } from "./headerPoints.js";
|
|
11
|
+
import { useIsChaindigg } from "./context.js";
|
|
12
|
+
function PointsEntry({
|
|
13
|
+
userInfo,
|
|
14
|
+
className,
|
|
15
|
+
onClick
|
|
16
|
+
}) {
|
|
17
|
+
const isChaindigg = useIsChaindigg();
|
|
18
|
+
const { openLogin } = useLogin();
|
|
19
|
+
const showAmount = headerPointsShowAmount(userInfo);
|
|
20
|
+
const trustedFromProfile = showAmount && hasTrustedHeaderPoints(userInfo);
|
|
21
|
+
const [pointsText, setPointsText] = useState(
|
|
22
|
+
() => trustedFromProfile ? formatHeaderPoints(userInfo) : ""
|
|
23
|
+
);
|
|
24
|
+
const [balanceReady, setBalanceReady] = useState(() => !showAmount || trustedFromProfile);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (trustedFromProfile) {
|
|
27
|
+
setPointsText(formatHeaderPoints(userInfo));
|
|
28
|
+
setBalanceReady(true);
|
|
29
|
+
}
|
|
30
|
+
}, [trustedFromProfile, userInfo]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (isChaindigg || !showAmount || trustedFromProfile) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let cancelled = false;
|
|
36
|
+
setBalanceReady(false);
|
|
37
|
+
const load = () => {
|
|
38
|
+
request.get(HEADER_POINTS_OVERVIEW_PATH).then((res) => {
|
|
39
|
+
if (cancelled) return;
|
|
40
|
+
const next = pointsTextFromOverview(res);
|
|
41
|
+
setPointsText(next ?? formatHeaderPoints({}));
|
|
42
|
+
}).catch(() => {
|
|
43
|
+
if (!cancelled) {
|
|
44
|
+
setPointsText(formatHeaderPoints({}));
|
|
45
|
+
}
|
|
46
|
+
}).finally(() => {
|
|
47
|
+
if (!cancelled) {
|
|
48
|
+
setBalanceReady(true);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
load();
|
|
53
|
+
const onRefresh = () => load();
|
|
54
|
+
window.addEventListener("user-profile-updated", onRefresh);
|
|
55
|
+
window.addEventListener("xchain-response-toast", onRefresh);
|
|
56
|
+
window.addEventListener("focus", onRefresh);
|
|
57
|
+
return () => {
|
|
58
|
+
cancelled = true;
|
|
59
|
+
window.removeEventListener("user-profile-updated", onRefresh);
|
|
60
|
+
window.removeEventListener("xchain-response-toast", onRefresh);
|
|
61
|
+
window.removeEventListener("focus", onRefresh);
|
|
62
|
+
};
|
|
63
|
+
}, [isChaindigg, showAmount, trustedFromProfile, userInfo?.id, userInfo?.userId]);
|
|
64
|
+
if (isChaindigg) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const classNames = twMerge(
|
|
68
|
+
"inline-flex shrink-0 items-center gap-1 h-8 px-3 rounded-full border border-primary/30 bg-background hover:bg-primary/5 text-sm whitespace-nowrap cursor-pointer",
|
|
69
|
+
className
|
|
70
|
+
);
|
|
71
|
+
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
72
|
+
/* @__PURE__ */ jsx(
|
|
73
|
+
ImageBar,
|
|
74
|
+
{
|
|
75
|
+
src: HEADER_POINTS_ICON,
|
|
76
|
+
width: 16,
|
|
77
|
+
height: 16,
|
|
78
|
+
alt: "",
|
|
79
|
+
className: "shrink-0"
|
|
80
|
+
}
|
|
81
|
+
),
|
|
82
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground", children: /* @__PURE__ */ jsx(Translation, { value: "points", parentKey: "account" }) }),
|
|
83
|
+
showAmount && balanceReady ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
84
|
+
/* @__PURE__ */ jsx("span", { className: "text-foreground", children: ": " }),
|
|
85
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-[1.5em] text-primary font-medium tabular-nums", children: pointsText })
|
|
86
|
+
] }) : showAmount ? /* @__PURE__ */ jsx(
|
|
87
|
+
"span",
|
|
88
|
+
{
|
|
89
|
+
className: "inline-block h-4 w-10 shrink-0 animate-pulse rounded bg-primary/15",
|
|
90
|
+
"aria-hidden": true
|
|
91
|
+
}
|
|
92
|
+
) : null
|
|
93
|
+
] });
|
|
94
|
+
if (!showAmount) {
|
|
95
|
+
return /* @__PURE__ */ jsx(
|
|
96
|
+
"button",
|
|
97
|
+
{
|
|
98
|
+
type: "button",
|
|
99
|
+
className: classNames,
|
|
100
|
+
onClick: (e) => {
|
|
101
|
+
onClick?.(e);
|
|
102
|
+
openLogin(OpenLoginType.LOGIN);
|
|
103
|
+
},
|
|
104
|
+
children: content
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
return /* @__PURE__ */ jsx(
|
|
109
|
+
LinkBar,
|
|
110
|
+
{
|
|
111
|
+
href: "/user-center/credits",
|
|
112
|
+
baseUrl: process.env.NEXT_PUBLIC_AUTH_URL,
|
|
113
|
+
onClick,
|
|
114
|
+
className: classNames,
|
|
115
|
+
children: content
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
PointsEntry as default
|
|
121
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, jsxs, Fragment } 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 ImageBar from "@0xchain/image";
|
|
8
|
+
import { Accordion, AccordionItem, AccordionTrigger } from "@0xchain/ui/accordion";
|
|
9
|
+
const PRODUCT_ITEMS = [
|
|
10
|
+
{
|
|
11
|
+
key: "widget",
|
|
12
|
+
href: "/widget",
|
|
13
|
+
iconUrl: `${process.env.NEXT_PUBLIC_CDN_URL}/uploads/2026/09/03/6a98d602a1c18.png`,
|
|
14
|
+
label: /* @__PURE__ */ jsx(Translation, { value: "products.widget", parentKey: "menu" })
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
function Products({
|
|
18
|
+
onClick,
|
|
19
|
+
onExpandChange
|
|
20
|
+
}) {
|
|
21
|
+
const locale = useLocale();
|
|
22
|
+
const [accordionValue, setAccordionValue] = useState("");
|
|
23
|
+
const handleClick = (e, href) => {
|
|
24
|
+
e?.preventDefault();
|
|
25
|
+
e?.stopPropagation();
|
|
26
|
+
onClick?.();
|
|
27
|
+
setAccordionValue("");
|
|
28
|
+
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || "";
|
|
29
|
+
window.location.href = `${baseUrl}/${locale}${href}`;
|
|
30
|
+
};
|
|
31
|
+
const renderItemContent = (item) => /* @__PURE__ */ jsxs("div", { className: "w-full h-full flex items-center gap-2 py-2 cursor-pointer font-medium", children: [
|
|
32
|
+
/* @__PURE__ */ jsx(
|
|
33
|
+
ImageBar,
|
|
34
|
+
{
|
|
35
|
+
src: item.iconUrl,
|
|
36
|
+
className: "w-6 h-6 shrink-0",
|
|
37
|
+
objectFit: "contain",
|
|
38
|
+
alt: ""
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
/* @__PURE__ */ jsx("div", { className: "flex-1", children: item.label })
|
|
42
|
+
] });
|
|
43
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
44
|
+
/* @__PURE__ */ jsx("div", { className: "hidden md:block", children: /* @__PURE__ */ jsx(
|
|
45
|
+
Dropdown,
|
|
46
|
+
{
|
|
47
|
+
getPopupContainer: () => document.body,
|
|
48
|
+
classNames: {
|
|
49
|
+
root: "w-50"
|
|
50
|
+
},
|
|
51
|
+
arrow: { pointAtCenter: true },
|
|
52
|
+
placement: "bottom",
|
|
53
|
+
menu: {
|
|
54
|
+
items: PRODUCT_ITEMS.map((item) => ({
|
|
55
|
+
label: renderItemContent(item),
|
|
56
|
+
key: item.key,
|
|
57
|
+
onClick: (info) => handleClick(info.domEvent, item.href)
|
|
58
|
+
}))
|
|
59
|
+
},
|
|
60
|
+
children: /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap flex items-center gap-1 rounded-lg md:px-4 md:py-1 ", children: /* @__PURE__ */ jsx(Translation, { value: "products.product", parentKey: "menu" }) })
|
|
61
|
+
}
|
|
62
|
+
) }),
|
|
63
|
+
/* @__PURE__ */ jsx("div", { className: "md:hidden w-full", children: /* @__PURE__ */ jsxs("div", { onClick: (e) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
e.stopPropagation();
|
|
66
|
+
}, children: [
|
|
67
|
+
/* @__PURE__ */ jsx(
|
|
68
|
+
Accordion,
|
|
69
|
+
{
|
|
70
|
+
type: "single",
|
|
71
|
+
collapsible: true,
|
|
72
|
+
className: "w-full",
|
|
73
|
+
value: accordionValue,
|
|
74
|
+
onValueChange: (value) => {
|
|
75
|
+
setAccordionValue(value);
|
|
76
|
+
onExpandChange?.(!!value);
|
|
77
|
+
},
|
|
78
|
+
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" }) }) }) }) })
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ jsx(
|
|
82
|
+
"div",
|
|
83
|
+
{
|
|
84
|
+
className: "grid transition-[grid-template-rows] duration-300 ease-in-out",
|
|
85
|
+
style: { gridTemplateRows: accordionValue ? "1fr" : "0fr" },
|
|
86
|
+
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(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
className: "w-full",
|
|
90
|
+
onClick: (e) => handleClick(e, item.href),
|
|
91
|
+
children: renderItemContent(item)
|
|
92
|
+
},
|
|
93
|
+
item.key
|
|
94
|
+
)) }) })
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
] }) })
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
Products as default
|
|
102
|
+
};
|
package/dist/lib/Right.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import Nav from "./Nav.js";
|
|
4
|
+
import Drawer from "./Drawer.js";
|
|
5
|
+
import PointsEntry from "./PointsEntry.js";
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import { useHeaderUser } from "./useHeaderUser.js";
|
|
8
|
+
import { isChatHeaderSource, HeaderSource } from "./headerSource.js";
|
|
9
|
+
function Right({
|
|
10
|
+
hideNews = false,
|
|
11
|
+
hideLogin = false,
|
|
12
|
+
user,
|
|
13
|
+
source = HeaderSource.DEFAULT
|
|
12
14
|
}) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const { userInfo } = useHeaderUser(user);
|
|
16
|
+
const showPoints = !hideLogin;
|
|
17
|
+
return /* @__PURE__ */ jsxs("div", { className: twMerge(
|
|
18
|
+
"flex items-center justify-end gap-2 z-1001 ml-auto shrink-0",
|
|
19
|
+
isChatHeaderSource(source) ? "" : "md:flex-1 md:ml-0 md:justify-start md:gap-10"
|
|
20
|
+
), children: [
|
|
21
|
+
showPoints ? /* @__PURE__ */ jsx(PointsEntry, { userInfo, className: "md:hidden" }) : null,
|
|
22
|
+
/* @__PURE__ */ jsx(Drawer, { hideLogin, hideNews, user: userInfo }),
|
|
23
|
+
/* @__PURE__ */ jsx("div", { className: "hidden md:block flex-1", children: /* @__PURE__ */ jsx(Nav, { hideNews, hideLogin, user: userInfo }) })
|
|
16
24
|
] });
|
|
17
25
|
}
|
|
18
26
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
HeaderSource,
|
|
28
|
+
Right as default
|
|
21
29
|
};
|