@graphprotocol/go 10.5.2
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/AnnouncementBanner/AnnouncementBanner.d.ts +19 -0
- package/dist/AnnouncementBanner/AnnouncementBanner.d.ts.map +1 -0
- package/dist/AnnouncementBanner/AnnouncementBanner.js +116 -0
- package/dist/AnnouncementBanner/index.d.ts +2 -0
- package/dist/AnnouncementBanner/index.d.ts.map +1 -0
- package/dist/CookieBanner/CookieBanner.d.ts +17 -0
- package/dist/CookieBanner/CookieBanner.d.ts.map +1 -0
- package/dist/CookieBanner/CookieBanner.js +195 -0
- package/dist/CookieBanner/index.d.ts +2 -0
- package/dist/CookieBanner/index.d.ts.map +1 -0
- package/dist/FeaturedSubgraphs/FeaturedSubgraphsGrid.d.ts +4 -0
- package/dist/FeaturedSubgraphs/FeaturedSubgraphsGrid.d.ts.map +1 -0
- package/dist/FeaturedSubgraphs/FeaturedSubgraphsGrid.js +42 -0
- package/dist/FeaturedSubgraphs/generated/gql.d.ts +42 -0
- package/dist/FeaturedSubgraphs/generated/gql.d.ts.map +1 -0
- package/dist/FeaturedSubgraphs/generated/gql.js +11 -0
- package/dist/FeaturedSubgraphs/generated/graphql.d.ts +10835 -0
- package/dist/FeaturedSubgraphs/generated/graphql.d.ts.map +1 -0
- package/dist/FeaturedSubgraphs/generated/graphql.js +403 -0
- package/dist/FeaturedSubgraphs/generated/index.d.ts +2 -0
- package/dist/FeaturedSubgraphs/generated/index.d.ts.map +1 -0
- package/dist/FeaturedSubgraphs/index.d.ts +3 -0
- package/dist/FeaturedSubgraphs/index.d.ts.map +1 -0
- package/dist/FeaturedSubgraphs/useFeaturedSubgrahsQuery.d.ts +28 -0
- package/dist/FeaturedSubgraphs/useFeaturedSubgrahsQuery.d.ts.map +1 -0
- package/dist/FeaturedSubgraphs/useFeaturedSubgrahsQuery.js +109 -0
- package/dist/GlobalFooter/GlobalFooter.d.ts +28 -0
- package/dist/GlobalFooter/GlobalFooter.d.ts.map +1 -0
- package/dist/GlobalFooter/GlobalFooter.js +300 -0
- package/dist/GlobalFooter/index.d.ts +2 -0
- package/dist/GlobalFooter/index.d.ts.map +1 -0
- package/dist/GlobalHeader/GlobalHeader.d.ts +4477 -0
- package/dist/GlobalHeader/GlobalHeader.d.ts.map +1 -0
- package/dist/GlobalHeader/GlobalHeader.js +1045 -0
- package/dist/GlobalHeader/index.d.ts +2 -0
- package/dist/GlobalHeader/index.d.ts.map +1 -0
- package/dist/MarketingNavbar/MarketingNavbar.d.ts +9 -0
- package/dist/MarketingNavbar/MarketingNavbar.d.ts.map +1 -0
- package/dist/MarketingNavbar/MarketingNavbar.js +566 -0
- package/dist/MarketingNavbar/index.d.ts +2 -0
- package/dist/MarketingNavbar/index.d.ts.map +1 -0
- package/dist/NPSForm/NPSForm.d.ts +20 -0
- package/dist/NPSForm/NPSForm.d.ts.map +1 -0
- package/dist/NPSForm/NPSForm.js +205 -0
- package/dist/NPSForm/index.d.ts +2 -0
- package/dist/NPSForm/index.d.ts.map +1 -0
- package/dist/NetworkIcon/NetworkIcon.d.ts +11 -0
- package/dist/NetworkIcon/NetworkIcon.d.ts.map +1 -0
- package/dist/NetworkIcon/NetworkIcon.js +443 -0
- package/dist/NetworkIcon/index.d.ts +2 -0
- package/dist/NetworkIcon/index.d.ts.map +1 -0
- package/dist/SupportModal/SupportModal.d.ts +6 -0
- package/dist/SupportModal/SupportModal.d.ts.map +1 -0
- package/dist/SupportModal/SupportModal.js +310 -0
- package/dist/SupportModal/index.d.ts +2 -0
- package/dist/SupportModal/index.d.ts.map +1 -0
- package/dist/SupportModal/submitToZendesk.d.ts +12 -0
- package/dist/SupportModal/submitToZendesk.d.ts.map +1 -0
- package/dist/SupportModal/submitToZendesk.js +26 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/jsx/src/jsx-runtime.js +10 -0
- package/dist/jsx/src/parseProps.js +48 -0
- package/package.json +95 -0
|
@@ -0,0 +1,1045 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "../jsx/src/jsx-runtime.js";
|
|
3
|
+
import { keyframes } from "@emotion/react";
|
|
4
|
+
import { GDSContext, useI18n, normalizePath, usePrevious, translatable, Text, Flex, Spacing, Icon, buildTransition, Duration, BorderRadius, Link, Transition, Responsive, Button, LocaleSwitcher, createIdGenerator, reactNodeToString, Opacity, ButtonOrLink } from "@graphprotocol/gds";
|
|
5
|
+
import { ChatDots } from "@graphprotocol/gds/dist/icons/ChatDots.js";
|
|
6
|
+
import * as Dialog from "@radix-ui/react-dialog";
|
|
7
|
+
import * as NavigationMenu from "@radix-ui/react-navigation-menu";
|
|
8
|
+
import * as Portal from "@radix-ui/react-portal";
|
|
9
|
+
import { inertValue } from "@react-aria/utils";
|
|
10
|
+
import escapeStringRegexp from "escape-string-regexp";
|
|
11
|
+
import { forwardRef, useContext, useState, useRef, useEffect, Fragment, createContext } from "react";
|
|
12
|
+
import { SupportModal } from "../SupportModal/SupportModal.js";
|
|
13
|
+
const DEFAULT_PRODUCTS = translatable(
|
|
14
|
+
(t, locale) => ({
|
|
15
|
+
THE_GRAPH: {
|
|
16
|
+
isDefault: true,
|
|
17
|
+
name: "The Graph",
|
|
18
|
+
description: "Learn about the network and how to get involved.",
|
|
19
|
+
href: `/${locale}/`,
|
|
20
|
+
navItems: [
|
|
21
|
+
{
|
|
22
|
+
label: t("components.globalHeader.pricing"),
|
|
23
|
+
href: "/studio-pricing/"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: t("components.globalHeader.ecosystem"),
|
|
27
|
+
subItems: [
|
|
28
|
+
{
|
|
29
|
+
label: "Governance",
|
|
30
|
+
description: "Participate in The Graph Governance.",
|
|
31
|
+
href: "/governance/"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: "Grants",
|
|
35
|
+
description: "Learn about Grants & Open RFPs.",
|
|
36
|
+
href: "/grants/"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: "Learn",
|
|
40
|
+
description: "Learn about The Graph.",
|
|
41
|
+
href: "/learn/"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
label: "Supported Networks",
|
|
45
|
+
description: "Learn about which networks The Graph supports.",
|
|
46
|
+
href: `/docs/${locale}/supported-networks/`
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: t("components.globalHeader.blog"),
|
|
52
|
+
href: "/blog/"
|
|
53
|
+
},
|
|
54
|
+
/*
|
|
55
|
+
{
|
|
56
|
+
label: t('components.globalHeader.jobs'),
|
|
57
|
+
href: '/jobs/',
|
|
58
|
+
},
|
|
59
|
+
*/
|
|
60
|
+
{
|
|
61
|
+
id: "docs",
|
|
62
|
+
label: t("components.globalHeader.docs"),
|
|
63
|
+
href: `/docs/${locale}/`,
|
|
64
|
+
active: /^\/docs($|\?|\/)/i
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
EXPLORER: {
|
|
69
|
+
name: "Graph Explorer",
|
|
70
|
+
description: "Explore subgraphs and interact with the protocol.",
|
|
71
|
+
href: "/explorer/",
|
|
72
|
+
navItems: [
|
|
73
|
+
{
|
|
74
|
+
label: "Subgraphs",
|
|
75
|
+
href: "/explorer/",
|
|
76
|
+
active: /^\/explorer($|\?|\/($|\?)|\/subgraphs($|\?|\/))/i
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: "Delegate",
|
|
80
|
+
href: "/explorer/delegate/"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "Participants",
|
|
84
|
+
href: "/explorer/participants/"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: "Network",
|
|
88
|
+
href: "/explorer/network/"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "docs",
|
|
92
|
+
label: t("components.globalHeader.docs"),
|
|
93
|
+
href: `/docs/${locale}/subgraphs/explorer/`,
|
|
94
|
+
active: /^\/docs($|\?|\/)/i
|
|
95
|
+
}
|
|
96
|
+
]
|
|
97
|
+
},
|
|
98
|
+
SUBGRAPH_STUDIO: {
|
|
99
|
+
name: "Subgraph Studio",
|
|
100
|
+
description: "Create, manage and publish subgraphs and API keys.",
|
|
101
|
+
href: "/studio/",
|
|
102
|
+
navItems: [
|
|
103
|
+
{
|
|
104
|
+
label: "My Dashboard",
|
|
105
|
+
href: "/studio/",
|
|
106
|
+
active: /^\/studio($|\?|\/($|\?)|\/subgraph($|\?|\/))/i
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: "API Keys",
|
|
110
|
+
href: "/studio/apikeys/"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
label: "Billing",
|
|
114
|
+
href: "/studio/billing/"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: "docs",
|
|
118
|
+
label: t("components.globalHeader.docs"),
|
|
119
|
+
href: `/docs/${locale}/deploying/subgraph-studio/`,
|
|
120
|
+
active: /^\/docs($|\?|\/)/i
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
const animationSlideDown = keyframes({
|
|
127
|
+
from: { opacity: 0, transform: `translateY(-${Spacing["8px"]})` },
|
|
128
|
+
to: { opacity: 1, transform: "translateY(0)" }
|
|
129
|
+
});
|
|
130
|
+
const animationSlideUp = keyframes({
|
|
131
|
+
from: { opacity: 1, transform: "translateY(0)" },
|
|
132
|
+
to: { opacity: 0, transform: `translateY(-${Spacing["8px"]})` }
|
|
133
|
+
});
|
|
134
|
+
const animationSlideFromLeft = keyframes({
|
|
135
|
+
from: { transform: "translateX(-100%)" },
|
|
136
|
+
to: { transform: "translateX(0)" }
|
|
137
|
+
});
|
|
138
|
+
const animationSlideToLeft = keyframes({
|
|
139
|
+
from: { transform: "translateX(0)" },
|
|
140
|
+
to: { transform: "translateX(-100%)" }
|
|
141
|
+
});
|
|
142
|
+
const animationFadeIn = keyframes({
|
|
143
|
+
from: { opacity: 0 },
|
|
144
|
+
to: { opacity: 1 }
|
|
145
|
+
});
|
|
146
|
+
const animationFadeOut = keyframes({
|
|
147
|
+
from: { opacity: 1 },
|
|
148
|
+
to: { opacity: 0 }
|
|
149
|
+
});
|
|
150
|
+
const GlobalHeaderContext = createContext({
|
|
151
|
+
supportNavItem: null
|
|
152
|
+
});
|
|
153
|
+
const GlobalHeaderComponent = ({
|
|
154
|
+
products: passedProducts,
|
|
155
|
+
activeProduct: passedActiveProductKey,
|
|
156
|
+
activePath: passedActivePath,
|
|
157
|
+
basePath: passedBasePath,
|
|
158
|
+
baseUrl = process.env.ENVIRONMENT === "staging" ? "https://staging.thegraph.com/" : "https://thegraph.com/",
|
|
159
|
+
navItems: customNavItems = (items) => items,
|
|
160
|
+
mobileNavItems: customMobileNavItems = (items) => items,
|
|
161
|
+
showLocaleSwitcher = false,
|
|
162
|
+
showSupportButton = false,
|
|
163
|
+
leftContent: customLeftContent,
|
|
164
|
+
rightContent: customRightContent,
|
|
165
|
+
className,
|
|
166
|
+
...props
|
|
167
|
+
}) => {
|
|
168
|
+
const { useRouter } = useContext(GDSContext);
|
|
169
|
+
const router = useRouter();
|
|
170
|
+
const { t, locale, localeDetails, supportedLocales, supportedLocalesDetails, pathWithoutLocale, setLocale } = useI18n();
|
|
171
|
+
let basePath = passedBasePath !== void 0 ? passedBasePath : (router == null ? void 0 : router.basePath) ?? null;
|
|
172
|
+
if (basePath !== null) {
|
|
173
|
+
basePath = normalizePath(basePath);
|
|
174
|
+
}
|
|
175
|
+
let activePath = passedActivePath !== void 0 ? passedActivePath : (router == null ? void 0 : router.pathname) ?? null;
|
|
176
|
+
if (activePath !== null) {
|
|
177
|
+
activePath = normalizePath(activePath, {
|
|
178
|
+
leadingSlash: true,
|
|
179
|
+
trailingSlash: false,
|
|
180
|
+
slashIfEmpty: true
|
|
181
|
+
});
|
|
182
|
+
if (basePath !== null) {
|
|
183
|
+
activePath = `${basePath}${activePath}`;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const previousActivePath = usePrevious(activePath);
|
|
187
|
+
const products = passedProducts ?? t(DEFAULT_PRODUCTS);
|
|
188
|
+
const activeProductKey = passedActiveProductKey ?? Object.keys(products).find((key) => {
|
|
189
|
+
var _a;
|
|
190
|
+
return (_a = products[key]) == null ? void 0 : _a.isDefault;
|
|
191
|
+
}) ?? null;
|
|
192
|
+
const activeProduct = activeProductKey && activeProductKey in products ? products[activeProductKey] : null;
|
|
193
|
+
const activeProductIsDefault = (activeProduct == null ? void 0 : activeProduct.isDefault) ?? false;
|
|
194
|
+
const getProductLabel = (product) => {
|
|
195
|
+
return product.tag ? /* @__PURE__ */ jsxs(Flex.Row, { align: "center", gap: Spacing["8px"], children: [
|
|
196
|
+
product.name,
|
|
197
|
+
product.tag
|
|
198
|
+
] }) : product.name;
|
|
199
|
+
};
|
|
200
|
+
const mutableDesktopNavItems = typeof customNavItems === "function" ? customNavItems([...(activeProduct == null ? void 0 : activeProduct.navItems) ?? []]) : [...customNavItems];
|
|
201
|
+
const productEntries = Object.entries(products);
|
|
202
|
+
const homeNavItem = {
|
|
203
|
+
id: "home",
|
|
204
|
+
label: t("components.globalHeader.home"),
|
|
205
|
+
href: `/${locale}/`,
|
|
206
|
+
active: /^\/([a-zA-Z][a-zA-Z])?($|\?|\/($|\?))/i
|
|
207
|
+
};
|
|
208
|
+
let docsNavItem = null;
|
|
209
|
+
const [supportModalOpen, setSupportModalOpen] = useState(false);
|
|
210
|
+
const supportNavItem = showSupportButton ? {
|
|
211
|
+
id: "support",
|
|
212
|
+
label: t("components.globalHeader.support"),
|
|
213
|
+
onClick: () => setSupportModalOpen(true)
|
|
214
|
+
} : null;
|
|
215
|
+
const localeNavItem = showLocaleSwitcher ? {
|
|
216
|
+
id: "locale",
|
|
217
|
+
label: localeDetails.displayName,
|
|
218
|
+
active: false,
|
|
219
|
+
subItems: supportedLocales.map((supportedLocale) => {
|
|
220
|
+
const supportedLocaleDetails = supportedLocalesDetails[supportedLocale];
|
|
221
|
+
return {
|
|
222
|
+
id: `locale-${supportedLocale}`,
|
|
223
|
+
label: supportedLocaleDetails.displayName,
|
|
224
|
+
active: supportedLocale === locale,
|
|
225
|
+
href: `/${supportedLocale}${pathWithoutLocale}`,
|
|
226
|
+
onClick: (event) => {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
setLocale(supportedLocale);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
})
|
|
232
|
+
} : null;
|
|
233
|
+
const defaultMobileNavItems = productEntries.length === 0 ? [...mutableDesktopNavItems] : productEntries.map(([productKey, product]) => {
|
|
234
|
+
const productIsActive = productKey === activeProductKey;
|
|
235
|
+
const baseProperties = {
|
|
236
|
+
label: getProductLabel(product),
|
|
237
|
+
description: product.description,
|
|
238
|
+
active: productIsActive
|
|
239
|
+
};
|
|
240
|
+
const subItems = (productIsActive ? mutableDesktopNavItems : product.navItems ?? []).filter((subItem) => {
|
|
241
|
+
if (subItem.id === "docs") {
|
|
242
|
+
if (productIsActive) {
|
|
243
|
+
docsNavItem = subItem;
|
|
244
|
+
}
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
return true;
|
|
248
|
+
});
|
|
249
|
+
if (product.isDefault) {
|
|
250
|
+
subItems.unshift(homeNavItem);
|
|
251
|
+
}
|
|
252
|
+
if (subItems.length > 0) {
|
|
253
|
+
return {
|
|
254
|
+
...baseProperties,
|
|
255
|
+
subItems
|
|
256
|
+
};
|
|
257
|
+
} else {
|
|
258
|
+
return {
|
|
259
|
+
...baseProperties,
|
|
260
|
+
href: product.href
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
if (docsNavItem) {
|
|
265
|
+
defaultMobileNavItems.push(docsNavItem);
|
|
266
|
+
}
|
|
267
|
+
if (supportNavItem) {
|
|
268
|
+
defaultMobileNavItems.push(supportNavItem);
|
|
269
|
+
}
|
|
270
|
+
if (localeNavItem) {
|
|
271
|
+
defaultMobileNavItems.push(localeNavItem);
|
|
272
|
+
}
|
|
273
|
+
const mutableMobileNavItems = typeof customMobileNavItems === "function" ? customMobileNavItems(defaultMobileNavItems) : customMobileNavItems;
|
|
274
|
+
if (productEntries.length > 0) {
|
|
275
|
+
mutableDesktopNavItems.unshift({
|
|
276
|
+
label: activeProduct && !activeProductIsDefault ? activeProduct.name : t("components.globalHeader.products"),
|
|
277
|
+
active: false,
|
|
278
|
+
subItems: productEntries.filter(([, product]) => !product.isDefault).map(([productKey, product]) => ({
|
|
279
|
+
label: getProductLabel(product),
|
|
280
|
+
description: product.description,
|
|
281
|
+
href: product.href,
|
|
282
|
+
active: productKey === activeProductKey
|
|
283
|
+
}))
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const desktopNavItems = addIds(mutableDesktopNavItems);
|
|
287
|
+
const mobileNavItems = addIds(mutableMobileNavItems);
|
|
288
|
+
const getHref = (navItem) => {
|
|
289
|
+
if (navItem.href === void 0) {
|
|
290
|
+
return void 0;
|
|
291
|
+
}
|
|
292
|
+
if (typeof navItem.href === "object" || !navItem.href.startsWith("/") || navItem.href.startsWith("//")) {
|
|
293
|
+
return navItem.href;
|
|
294
|
+
}
|
|
295
|
+
if (basePath !== null && new RegExp(`^${escapeStringRegexp(basePath)}($|/)`, "i").test(navItem.href)) {
|
|
296
|
+
return navItem.href.substring(basePath.length) || "/";
|
|
297
|
+
}
|
|
298
|
+
return `${baseUrl.replace(/\/$/, "")}${navItem.href}`;
|
|
299
|
+
};
|
|
300
|
+
const getActive = (navItem) => {
|
|
301
|
+
if (typeof navItem.active === "boolean") {
|
|
302
|
+
return navItem.active;
|
|
303
|
+
}
|
|
304
|
+
const checkActivePath = navItem.active !== void 0 || navItem.href !== void 0;
|
|
305
|
+
if (checkActivePath && activePath !== null) {
|
|
306
|
+
const regex = (() => {
|
|
307
|
+
switch (true) {
|
|
308
|
+
case navItem.active !== void 0:
|
|
309
|
+
return navItem.active;
|
|
310
|
+
case navItem.href !== void 0:
|
|
311
|
+
if (typeof navItem.href === "object" || !navItem.href.startsWith("/") || navItem.href.startsWith("//")) {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
return new RegExp(`^${escapeStringRegexp(navItem.href.replace(/\/?(\?.*)?$/, ""))}($|/|\\?)`, "i");
|
|
315
|
+
default:
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
})();
|
|
319
|
+
if (regex === null) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
return regex.test(activePath);
|
|
323
|
+
}
|
|
324
|
+
if (navItem.subItems !== void 0) {
|
|
325
|
+
return navItem.subItems.some(getActive);
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
};
|
|
329
|
+
const [mobileNavOpen, setMobileNavOpen] = useState(false);
|
|
330
|
+
const [openTopLevelMobileNavItemId, setOpenTopLevelMobileNavItemId] = useState(null);
|
|
331
|
+
const [openSecondLevelMobileNavItemId, setOpenSecondLevelMobileNavItemId] = useState(null);
|
|
332
|
+
const thirdLevelMobileNavRef = useRef(null);
|
|
333
|
+
useEffect(() => {
|
|
334
|
+
if (activePath !== previousActivePath && previousActivePath !== void 0) {
|
|
335
|
+
setMobileNavOpen(false);
|
|
336
|
+
}
|
|
337
|
+
}, [activePath, previousActivePath]);
|
|
338
|
+
const defaultLeftContentDesktop = /* @__PURE__ */ jsx(NavigationMenu.Root, { "aria-label": t("components.globalHeader.mainNavigation"), children: /* @__PURE__ */ jsx(Text.H14, { as: "child", color: "inherit", children: /* @__PURE__ */ jsx(Flex.Row, { as: "child", align: "center", gap: Spacing["24px"], children: /* @__PURE__ */ jsxs(NavigationMenu.List, { children: [
|
|
339
|
+
/* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, active: getActive(homeNavItem), children: /* @__PURE__ */ jsxs(NavLink, { href: getHref(homeNavItem), sx: { pl: Spacing["4px"] }, children: [
|
|
340
|
+
/* @__PURE__ */ jsx(
|
|
341
|
+
Icon.LogoTheGraph,
|
|
342
|
+
{
|
|
343
|
+
size: "32px",
|
|
344
|
+
sx: { ml: "0", height: "20px", svg: { height: "32px", top: "-6px" } }
|
|
345
|
+
}
|
|
346
|
+
),
|
|
347
|
+
activeProduct && activeProductIsDefault ? activeProduct.name : null
|
|
348
|
+
] }) }) }),
|
|
349
|
+
desktopNavItems.map((navItem) => /* @__PURE__ */ jsx(NavigationMenu.Item, { value: navItem.id, children: navItem.subItems === void 0 ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, active: getActive(navItem), children: /* @__PURE__ */ jsx(
|
|
350
|
+
NavLink,
|
|
351
|
+
{
|
|
352
|
+
activeIndicator: true,
|
|
353
|
+
href: getHref(navItem),
|
|
354
|
+
disabled: navItem.disabled,
|
|
355
|
+
onClick: navItem.onClick,
|
|
356
|
+
children: navItem.label
|
|
357
|
+
}
|
|
358
|
+
) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
359
|
+
/* @__PURE__ */ jsx(
|
|
360
|
+
NavigationMenu.Trigger,
|
|
361
|
+
{
|
|
362
|
+
asChild: true,
|
|
363
|
+
onPointerMove: (event) => event.preventDefault(),
|
|
364
|
+
onPointerLeave: (event) => event.preventDefault(),
|
|
365
|
+
children: /* @__PURE__ */ jsxs(
|
|
366
|
+
NavLink,
|
|
367
|
+
{
|
|
368
|
+
activeIndicator: true,
|
|
369
|
+
"data-active": getActive(navItem) ? "" : void 0,
|
|
370
|
+
disabled: navItem.disabled,
|
|
371
|
+
onClick: navItem.onClick,
|
|
372
|
+
children: [
|
|
373
|
+
navItem.label,
|
|
374
|
+
/* @__PURE__ */ jsx(
|
|
375
|
+
Icon.CaretDown,
|
|
376
|
+
{
|
|
377
|
+
title: "",
|
|
378
|
+
size: "12px",
|
|
379
|
+
sx: {
|
|
380
|
+
'.gds-ButtonOrLink[data-state="open"] &': { transform: "rotate(-180deg)" },
|
|
381
|
+
transition: buildTransition("TRANSFORM")
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
]
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
/* @__PURE__ */ jsx(
|
|
391
|
+
NavigationMenu.Content,
|
|
392
|
+
{
|
|
393
|
+
onPointerMove: (event) => event.preventDefault(),
|
|
394
|
+
onPointerLeave: (event) => event.preventDefault(),
|
|
395
|
+
sx: {
|
|
396
|
+
position: "absolute",
|
|
397
|
+
left: `-${Spacing["40px"]}`,
|
|
398
|
+
top: "100%",
|
|
399
|
+
pt: Spacing["16px"],
|
|
400
|
+
width: "max-content",
|
|
401
|
+
maxWidth: "448px",
|
|
402
|
+
'&[data-state="open"]': {
|
|
403
|
+
animation: `${animationSlideDown} ${Duration["200ms"]}`
|
|
404
|
+
},
|
|
405
|
+
'&[data-state="closed"]': {
|
|
406
|
+
animation: `${animationSlideUp} ${Duration["200ms"]}`
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
children: /* @__PURE__ */ jsx(
|
|
410
|
+
NavigationMenu.Sub,
|
|
411
|
+
{
|
|
412
|
+
sx: {
|
|
413
|
+
maxHeight: "calc(100vh - 80px)",
|
|
414
|
+
borderRadius: BorderRadius.S,
|
|
415
|
+
border: "White8",
|
|
416
|
+
bg: "Panes",
|
|
417
|
+
overflowX: "clip",
|
|
418
|
+
overflowY: "auto"
|
|
419
|
+
},
|
|
420
|
+
children: /* @__PURE__ */ jsx(NavigationMenu.List, { children: navItem.subItems.map(
|
|
421
|
+
(subItem) => subItem.subItems === void 0 ? /* @__PURE__ */ jsx(NavigationMenu.Item, { value: subItem.id, children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, active: getActive(subItem), children: /* @__PURE__ */ jsxs(
|
|
422
|
+
StackedNavButtonOrLink,
|
|
423
|
+
{
|
|
424
|
+
href: getHref(subItem),
|
|
425
|
+
disabled: subItem.disabled,
|
|
426
|
+
onClick: subItem.onClick,
|
|
427
|
+
children: [
|
|
428
|
+
subItem.label,
|
|
429
|
+
subItem.description ? /* @__PURE__ */ jsx(Text.P14, { as: "span", color: "White64", sx: { mt: Spacing["4px"], display: "block" }, children: subItem.description }) : null
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
) }) }, subItem.id) : null
|
|
433
|
+
) })
|
|
434
|
+
}
|
|
435
|
+
)
|
|
436
|
+
}
|
|
437
|
+
)
|
|
438
|
+
] }) }, navItem.id))
|
|
439
|
+
] }) }) }) });
|
|
440
|
+
const defaultLeftContentMobile = /* @__PURE__ */ jsxs(
|
|
441
|
+
Dialog.Root,
|
|
442
|
+
{
|
|
443
|
+
open: mobileNavOpen,
|
|
444
|
+
onOpenChange: (open) => {
|
|
445
|
+
var _a;
|
|
446
|
+
setMobileNavOpen(open);
|
|
447
|
+
if (open) {
|
|
448
|
+
setOpenTopLevelMobileNavItemId(((_a = mobileNavItems.find((navItem) => navItem.active)) == null ? void 0 : _a.id) ?? null);
|
|
449
|
+
setOpenSecondLevelMobileNavItemId(null);
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
children: [
|
|
453
|
+
/* @__PURE__ */ jsx(Dialog.Trigger, { asChild: true, "aria-label": t("components.globalHeader.mainNavigation"), children: /* @__PURE__ */ jsxs(Link, { wrap: false, children: [
|
|
454
|
+
/* @__PURE__ */ jsx(Icon.LogoTheGraph, { size: "32px" }),
|
|
455
|
+
/* @__PURE__ */ jsx(Icon.CaretDown, { title: "", size: "12px", sx: { ml: Spacing["4px"] } })
|
|
456
|
+
] }) }),
|
|
457
|
+
/* @__PURE__ */ jsxs(Dialog.Portal, { children: [
|
|
458
|
+
/* @__PURE__ */ jsx(
|
|
459
|
+
Dialog.Overlay,
|
|
460
|
+
{
|
|
461
|
+
sx: {
|
|
462
|
+
position: "fixed",
|
|
463
|
+
inset: 0,
|
|
464
|
+
bg: "Midnight88",
|
|
465
|
+
'&[data-state="open"]': {
|
|
466
|
+
animation: `${animationFadeIn} ${Duration["400ms"]}`
|
|
467
|
+
},
|
|
468
|
+
'&[data-state="closed"]': {
|
|
469
|
+
animation: `${animationFadeOut} ${Duration["400ms"]}`
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
),
|
|
474
|
+
/* @__PURE__ */ jsx(
|
|
475
|
+
Dialog.Content,
|
|
476
|
+
{
|
|
477
|
+
sx: {
|
|
478
|
+
position: "fixed",
|
|
479
|
+
left: 0,
|
|
480
|
+
top: 0,
|
|
481
|
+
width: "290px",
|
|
482
|
+
maxWidth: "100%",
|
|
483
|
+
height: "100%",
|
|
484
|
+
borderRight: "White8",
|
|
485
|
+
bg: "Panes",
|
|
486
|
+
overflow: "clip",
|
|
487
|
+
outline: "none",
|
|
488
|
+
'&[data-state="open"]': {
|
|
489
|
+
animation: `${animationSlideFromLeft} ${Duration["400ms"]}`
|
|
490
|
+
},
|
|
491
|
+
'&[data-state="closed"]': {
|
|
492
|
+
animation: `${animationSlideToLeft} ${Duration["400ms"]}`
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
children: /* @__PURE__ */ jsxs(
|
|
496
|
+
"div",
|
|
497
|
+
{
|
|
498
|
+
sx: {
|
|
499
|
+
width: "calc(100% + 1px)",
|
|
500
|
+
height: "100%",
|
|
501
|
+
transform: openSecondLevelMobileNavItemId !== null ? "translateX(-100%)" : "translateX(0)",
|
|
502
|
+
transition: buildTransition("TRANSFORM", "400ms")
|
|
503
|
+
},
|
|
504
|
+
children: [
|
|
505
|
+
/* @__PURE__ */ jsx(
|
|
506
|
+
NavigationMenu.Root,
|
|
507
|
+
{
|
|
508
|
+
inert: inertValue(openSecondLevelMobileNavItemId !== null),
|
|
509
|
+
value: openTopLevelMobileNavItemId ?? "",
|
|
510
|
+
onValueChange: (navItemId) => {
|
|
511
|
+
setOpenTopLevelMobileNavItemId(navItemId || null);
|
|
512
|
+
},
|
|
513
|
+
"aria-label": t("components.globalHeader.mainNavigation"),
|
|
514
|
+
sx: {
|
|
515
|
+
width: "100%",
|
|
516
|
+
height: "100%",
|
|
517
|
+
overflowX: "clip",
|
|
518
|
+
overflowY: "auto",
|
|
519
|
+
borderRight: "White8"
|
|
520
|
+
},
|
|
521
|
+
children: /* @__PURE__ */ jsx(NavigationMenu.List, { sx: { borderBottom: "White8" }, children: mobileNavItems.map((navItem) => {
|
|
522
|
+
const navItemState = navItem.id === openTopLevelMobileNavItemId ? "open" : "closed";
|
|
523
|
+
const navItemIsSupport = navItem.id === (supportNavItem == null ? void 0 : supportNavItem.id);
|
|
524
|
+
const navItemIsLocale = navItem.id === (localeNavItem == null ? void 0 : localeNavItem.id);
|
|
525
|
+
return /* @__PURE__ */ jsx(NavigationMenu.Item, { value: navItem.id, children: navItem.subItems === void 0 ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, active: getActive(navItem), children: /* @__PURE__ */ jsx(
|
|
526
|
+
StackedNavButtonOrLink,
|
|
527
|
+
{
|
|
528
|
+
href: getHref(navItem),
|
|
529
|
+
disabled: navItem.disabled,
|
|
530
|
+
onClick: (event) => {
|
|
531
|
+
var _a;
|
|
532
|
+
(_a = navItem.onClick) == null ? void 0 : _a.call(navItem, event);
|
|
533
|
+
setMobileNavOpen(false);
|
|
534
|
+
},
|
|
535
|
+
children: navItemIsSupport ? /* @__PURE__ */ jsxs(Flex.Row, { as: "span", align: "center", gap: Spacing["8px"], children: [
|
|
536
|
+
/* @__PURE__ */ jsx(ChatDots, { alt: "", variant: "fill", size: 5 }),
|
|
537
|
+
navItem.label
|
|
538
|
+
] }) : navItem.label
|
|
539
|
+
}
|
|
540
|
+
) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
541
|
+
/* @__PURE__ */ jsx(
|
|
542
|
+
NavigationMenu.Trigger,
|
|
543
|
+
{
|
|
544
|
+
asChild: true,
|
|
545
|
+
onPointerMove: (event) => event.preventDefault(),
|
|
546
|
+
onPointerLeave: (event) => event.preventDefault(),
|
|
547
|
+
children: /* @__PURE__ */ jsx(
|
|
548
|
+
StackedNavButtonOrLink,
|
|
549
|
+
{
|
|
550
|
+
"data-active": getActive(navItem) ? "" : void 0,
|
|
551
|
+
disabled: navItem.disabled,
|
|
552
|
+
"aria-expanded": navItemState === "open" ? "true" : "false",
|
|
553
|
+
onClick: navItem.onClick,
|
|
554
|
+
sx: { zIndex: 1 },
|
|
555
|
+
children: navItemIsLocale ? /* @__PURE__ */ jsxs(Flex.Row, { as: "span", align: "center", gap: Spacing["8px"], children: [
|
|
556
|
+
/* @__PURE__ */ jsx(Icon.World, { title: t("components.globalHeader.language"), size: "20px" }),
|
|
557
|
+
navItem.label
|
|
558
|
+
] }) : navItem.label
|
|
559
|
+
}
|
|
560
|
+
)
|
|
561
|
+
}
|
|
562
|
+
),
|
|
563
|
+
/* @__PURE__ */ jsx(
|
|
564
|
+
NavigationMenu.Content,
|
|
565
|
+
{
|
|
566
|
+
forceMount: true,
|
|
567
|
+
onPointerMove: (event) => event.preventDefault(),
|
|
568
|
+
onPointerLeave: (event) => event.preventDefault(),
|
|
569
|
+
onInteractOutside: (event) => event.preventDefault(),
|
|
570
|
+
children: /* @__PURE__ */ jsx(Transition, { effect: "collapse", children: /* @__PURE__ */ jsx(
|
|
571
|
+
NavigationMenu.Sub,
|
|
572
|
+
{
|
|
573
|
+
"data-state": navItemState,
|
|
574
|
+
sx: {
|
|
575
|
+
'&[data-state="open"]': { pointerEvents: "auto" },
|
|
576
|
+
'&[data-state="closed"]': { display: "none" }
|
|
577
|
+
},
|
|
578
|
+
children: /* @__PURE__ */ jsx(Flex.Column, { as: "child", gap: Spacing["16px"], sx: { pb: Spacing["20px"] }, children: /* @__PURE__ */ jsx(NavigationMenu.List, { children: navItem.subItems.map((subItem) => {
|
|
579
|
+
const subItemState = subItem.id === openSecondLevelMobileNavItemId ? "open" : "closed";
|
|
580
|
+
return /* @__PURE__ */ jsx(NavigationMenu.Item, { value: subItem.id, children: subItem.subItems === void 0 ? /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, active: getActive(subItem), children: /* @__PURE__ */ jsx(
|
|
581
|
+
StackedNavButtonOrLink,
|
|
582
|
+
{
|
|
583
|
+
variant: "sub",
|
|
584
|
+
href: getHref(subItem),
|
|
585
|
+
disabled: subItem.disabled,
|
|
586
|
+
onClick: (event) => {
|
|
587
|
+
var _a;
|
|
588
|
+
(_a = subItem.onClick) == null ? void 0 : _a.call(subItem, event);
|
|
589
|
+
setMobileNavOpen(false);
|
|
590
|
+
},
|
|
591
|
+
children: subItem.label
|
|
592
|
+
}
|
|
593
|
+
) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
594
|
+
/* @__PURE__ */ jsx(
|
|
595
|
+
NavigationMenu.Link,
|
|
596
|
+
{
|
|
597
|
+
asChild: true,
|
|
598
|
+
onPointerMove: (event) => event.preventDefault(),
|
|
599
|
+
onPointerLeave: (event) => event.preventDefault(),
|
|
600
|
+
onSelect: (event) => event.preventDefault(),
|
|
601
|
+
children: /* @__PURE__ */ jsx(
|
|
602
|
+
StackedNavButtonOrLink,
|
|
603
|
+
{
|
|
604
|
+
variant: "sub",
|
|
605
|
+
"data-active": getActive(subItem) ? "" : void 0,
|
|
606
|
+
disabled: subItem.disabled,
|
|
607
|
+
onClick: (event) => {
|
|
608
|
+
var _a;
|
|
609
|
+
(_a = subItem.onClick) == null ? void 0 : _a.call(subItem, event);
|
|
610
|
+
setOpenSecondLevelMobileNavItemId(subItem.id);
|
|
611
|
+
},
|
|
612
|
+
children: /* @__PURE__ */ jsxs(
|
|
613
|
+
Flex.Row,
|
|
614
|
+
{
|
|
615
|
+
as: "span",
|
|
616
|
+
justify: "space-between",
|
|
617
|
+
align: "center",
|
|
618
|
+
gap: Spacing["8px"],
|
|
619
|
+
children: [
|
|
620
|
+
subItem.label,
|
|
621
|
+
/* @__PURE__ */ jsx(
|
|
622
|
+
Icon.CaretRight,
|
|
623
|
+
{
|
|
624
|
+
title: "",
|
|
625
|
+
size: "14px",
|
|
626
|
+
sx: { mr: `-${Spacing["24px"]}` }
|
|
627
|
+
}
|
|
628
|
+
)
|
|
629
|
+
]
|
|
630
|
+
}
|
|
631
|
+
)
|
|
632
|
+
}
|
|
633
|
+
)
|
|
634
|
+
}
|
|
635
|
+
),
|
|
636
|
+
/* @__PURE__ */ jsx(Portal.Root, { asChild: true, container: thirdLevelMobileNavRef.current, children: /* @__PURE__ */ jsxs(
|
|
637
|
+
NavigationMenu.Root,
|
|
638
|
+
{
|
|
639
|
+
inert: inertValue(subItemState === "closed"),
|
|
640
|
+
"aria-labelledby": `go-GlobalHeader-itemLabel-${subItem.id}}`,
|
|
641
|
+
sx: {
|
|
642
|
+
position: "absolute",
|
|
643
|
+
left: 0,
|
|
644
|
+
top: 0,
|
|
645
|
+
width: "100%",
|
|
646
|
+
"&[inert]": {
|
|
647
|
+
opacity: 0,
|
|
648
|
+
transition: buildTransition(
|
|
649
|
+
"OPACITY",
|
|
650
|
+
"0ms",
|
|
651
|
+
"EASE_IN_OUT",
|
|
652
|
+
"400ms"
|
|
653
|
+
)
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
children: [
|
|
657
|
+
/* @__PURE__ */ jsxs("div", { id: `go-GlobalHeader-itemLabel-${subItem.id}}`, hidden: true, children: [
|
|
658
|
+
subItem.label,
|
|
659
|
+
" navigation"
|
|
660
|
+
] }),
|
|
661
|
+
/* @__PURE__ */ jsx(
|
|
662
|
+
Flex.Column,
|
|
663
|
+
{
|
|
664
|
+
as: "child",
|
|
665
|
+
gap: Spacing["16px"],
|
|
666
|
+
sx: { pb: Spacing["20px"] },
|
|
667
|
+
children: /* @__PURE__ */ jsxs(NavigationMenu.List, { children: [
|
|
668
|
+
/* @__PURE__ */ jsx(NavigationMenu.Item, { sx: { mb: `-${Spacing["16px"]}` }, children: /* @__PURE__ */ jsx(
|
|
669
|
+
NavigationMenu.Link,
|
|
670
|
+
{
|
|
671
|
+
asChild: true,
|
|
672
|
+
onPointerMove: (event) => event.preventDefault(),
|
|
673
|
+
onPointerLeave: (event) => event.preventDefault(),
|
|
674
|
+
children: /* @__PURE__ */ jsx(
|
|
675
|
+
StackedNavButtonOrLink,
|
|
676
|
+
{
|
|
677
|
+
variant: "back",
|
|
678
|
+
onClick: () => {
|
|
679
|
+
setOpenSecondLevelMobileNavItemId(null);
|
|
680
|
+
},
|
|
681
|
+
children: subItem.label
|
|
682
|
+
}
|
|
683
|
+
)
|
|
684
|
+
}
|
|
685
|
+
) }),
|
|
686
|
+
subItem.subItems.map(
|
|
687
|
+
(subSubItem) => subSubItem.subItems === void 0 ? /* @__PURE__ */ jsx(NavigationMenu.Item, { children: /* @__PURE__ */ jsx(NavigationMenu.Link, { asChild: true, active: getActive(subSubItem), children: /* @__PURE__ */ jsx(
|
|
688
|
+
StackedNavButtonOrLink,
|
|
689
|
+
{
|
|
690
|
+
variant: "sub",
|
|
691
|
+
href: getHref(subSubItem),
|
|
692
|
+
disabled: subSubItem.disabled,
|
|
693
|
+
onClick: (event) => {
|
|
694
|
+
var _a;
|
|
695
|
+
(_a = subSubItem.onClick) == null ? void 0 : _a.call(subSubItem, event);
|
|
696
|
+
setMobileNavOpen(false);
|
|
697
|
+
},
|
|
698
|
+
children: subSubItem.label
|
|
699
|
+
}
|
|
700
|
+
) }) }, subSubItem.id) : null
|
|
701
|
+
)
|
|
702
|
+
] })
|
|
703
|
+
}
|
|
704
|
+
)
|
|
705
|
+
]
|
|
706
|
+
}
|
|
707
|
+
) })
|
|
708
|
+
] }) }, subItem.id);
|
|
709
|
+
}) }) })
|
|
710
|
+
},
|
|
711
|
+
navItemState
|
|
712
|
+
) })
|
|
713
|
+
}
|
|
714
|
+
)
|
|
715
|
+
] }) }, navItem.id);
|
|
716
|
+
}) })
|
|
717
|
+
}
|
|
718
|
+
),
|
|
719
|
+
/* @__PURE__ */ jsx(
|
|
720
|
+
"div",
|
|
721
|
+
{
|
|
722
|
+
ref: thirdLevelMobileNavRef,
|
|
723
|
+
sx: {
|
|
724
|
+
position: "absolute",
|
|
725
|
+
left: 0,
|
|
726
|
+
top: 0,
|
|
727
|
+
width: "100%",
|
|
728
|
+
height: "100%",
|
|
729
|
+
overflowX: "clip",
|
|
730
|
+
overflowY: "auto",
|
|
731
|
+
transform: "translateX(100%)",
|
|
732
|
+
outline: "none"
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
)
|
|
736
|
+
]
|
|
737
|
+
}
|
|
738
|
+
)
|
|
739
|
+
}
|
|
740
|
+
)
|
|
741
|
+
] })
|
|
742
|
+
]
|
|
743
|
+
}
|
|
744
|
+
);
|
|
745
|
+
const defaultLeftContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
746
|
+
/* @__PURE__ */ jsx("div", { sx: { display: ["none", null, "contents"] }, children: defaultLeftContentDesktop }),
|
|
747
|
+
/* @__PURE__ */ jsx("div", { sx: { display: ["contents", null, "none"] }, children: defaultLeftContentMobile })
|
|
748
|
+
] });
|
|
749
|
+
let leftContent = defaultLeftContent;
|
|
750
|
+
if (typeof customLeftContent === "function") {
|
|
751
|
+
leftContent = customLeftContent(defaultLeftContent);
|
|
752
|
+
if (Array.isArray(leftContent)) {
|
|
753
|
+
leftContent = leftContent.map((_, breakpointIndex) => {
|
|
754
|
+
return customLeftContent(
|
|
755
|
+
breakpointIndex < 2 ? defaultLeftContentMobile : defaultLeftContentDesktop
|
|
756
|
+
)[breakpointIndex];
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
} else if (customLeftContent !== void 0) {
|
|
760
|
+
leftContent = customLeftContent;
|
|
761
|
+
}
|
|
762
|
+
const hideDefaultRightContentOnMobile = customLeftContent === void 0 || typeof customLeftContent === "function";
|
|
763
|
+
const defaultRightContent = /* @__PURE__ */ jsxs(Text.P14, { as: "div", sx: { display: hideDefaultRightContentOnMobile ? ["none", null, "contents"] : "contents" }, children: [
|
|
764
|
+
showLocaleSwitcher ? /* @__PURE__ */ jsx(GlobalHeaderLocaleSwitcher, {}) : null,
|
|
765
|
+
showSupportButton ? /* @__PURE__ */ jsx(GlobalHeaderSupportButton, {}) : null
|
|
766
|
+
] });
|
|
767
|
+
let rightContent = defaultRightContent;
|
|
768
|
+
if (typeof customRightContent === "function") {
|
|
769
|
+
rightContent = customRightContent(defaultRightContent);
|
|
770
|
+
} else if (customRightContent !== void 0) {
|
|
771
|
+
rightContent = customRightContent;
|
|
772
|
+
}
|
|
773
|
+
return /* @__PURE__ */ jsx(GlobalHeaderContext.Provider, { value: { supportNavItem }, children: /* @__PURE__ */ jsxs(
|
|
774
|
+
Flex.Row,
|
|
775
|
+
{
|
|
776
|
+
justify: "space-between",
|
|
777
|
+
align: "center",
|
|
778
|
+
gap: [Spacing["24px"], null, null, Spacing["32px"]],
|
|
779
|
+
className,
|
|
780
|
+
sx: { direction: "ltr", height: "var(--gds-header-height, 80px)" },
|
|
781
|
+
...props,
|
|
782
|
+
children: [
|
|
783
|
+
/* @__PURE__ */ jsx(Flex.Row, { align: "center", gap: Spacing["24px"], sx: { direction: "var(--gds-direction)" }, children: /* @__PURE__ */ jsx(Responsive.Multiple, { children: () => Array.isArray(leftContent) ? leftContent : [leftContent] }) }),
|
|
784
|
+
/* @__PURE__ */ jsx(
|
|
785
|
+
Flex.Row,
|
|
786
|
+
{
|
|
787
|
+
align: "center",
|
|
788
|
+
gap: [Spacing["24px"], null, null, Spacing["32px"]],
|
|
789
|
+
sx: { direction: "var(--gds-direction)" },
|
|
790
|
+
children: /* @__PURE__ */ jsx(Responsive.Multiple, { children: () => Array.isArray(rightContent) ? rightContent : [rightContent] })
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
showSupportButton ? /* @__PURE__ */ jsx(
|
|
794
|
+
SupportModal,
|
|
795
|
+
{
|
|
796
|
+
open: supportModalOpen,
|
|
797
|
+
onClose: setSupportModalOpen,
|
|
798
|
+
defaultEmail: typeof showSupportButton === "object" && "defaultEmail" in showSupportButton ? showSupportButton.defaultEmail : void 0
|
|
799
|
+
}
|
|
800
|
+
) : null
|
|
801
|
+
]
|
|
802
|
+
}
|
|
803
|
+
) });
|
|
804
|
+
};
|
|
805
|
+
GlobalHeaderComponent.displayName = "GlobalHeader";
|
|
806
|
+
function addIds(navItems, createIdFunction) {
|
|
807
|
+
const createId = createIdFunction ?? createIdGenerator();
|
|
808
|
+
return navItems.map((navItem) => {
|
|
809
|
+
const navItemWithId = {
|
|
810
|
+
id: createId(reactNodeToString(navItem.label)),
|
|
811
|
+
...navItem
|
|
812
|
+
};
|
|
813
|
+
if (navItem.subItems) {
|
|
814
|
+
navItemWithId.subItems = addIds(navItem.subItems, createId);
|
|
815
|
+
}
|
|
816
|
+
return navItemWithId;
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
const NavLink = forwardRef(
|
|
820
|
+
({ activeIndicator = false, children, ...props }, ref) => {
|
|
821
|
+
return /* @__PURE__ */ jsxs(
|
|
822
|
+
Link,
|
|
823
|
+
{
|
|
824
|
+
ref,
|
|
825
|
+
wrap: false,
|
|
826
|
+
autoIcon: false,
|
|
827
|
+
color: "White64",
|
|
828
|
+
sx: { "&[data-active]": { color: "White88" } },
|
|
829
|
+
...props,
|
|
830
|
+
children: [
|
|
831
|
+
activeIndicator ? /* @__PURE__ */ jsx(
|
|
832
|
+
"span",
|
|
833
|
+
{
|
|
834
|
+
sx: {
|
|
835
|
+
position: "absolute",
|
|
836
|
+
left: 0,
|
|
837
|
+
right: 0,
|
|
838
|
+
mx: "auto",
|
|
839
|
+
bottom: "-16px",
|
|
840
|
+
width: "min-content",
|
|
841
|
+
opacity: Opacity["0%"],
|
|
842
|
+
".gds-ButtonOrLink[data-active] &": {
|
|
843
|
+
opacity: Opacity["100%"]
|
|
844
|
+
},
|
|
845
|
+
transition: buildTransition("OPACITY"),
|
|
846
|
+
pointerEvents: "none"
|
|
847
|
+
},
|
|
848
|
+
children: /* @__PURE__ */ jsx(Icon.DiamondSolid, { size: "8px" })
|
|
849
|
+
}
|
|
850
|
+
) : null,
|
|
851
|
+
children
|
|
852
|
+
]
|
|
853
|
+
}
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
);
|
|
857
|
+
NavLink.displayName = "GlobalHeader._NavLink";
|
|
858
|
+
const StackedNavButtonOrLink = forwardRef(({ variant = "default", children, ...props }, ref) => {
|
|
859
|
+
const { t } = useI18n();
|
|
860
|
+
const IconElement = variant === "back" ? Icon.CaretLeft : Icon.DiamondSolid;
|
|
861
|
+
const TextElement = variant === "sub" ? Text.P14 : Text.H14;
|
|
862
|
+
return /* @__PURE__ */ jsx(
|
|
863
|
+
ButtonOrLink,
|
|
864
|
+
{
|
|
865
|
+
ref,
|
|
866
|
+
"aria-label": variant === "back" ? t("components.globalHeader.goBackToMainNavigation") : void 0,
|
|
867
|
+
sx: {
|
|
868
|
+
display: "block",
|
|
869
|
+
width: "100%",
|
|
870
|
+
py: Spacing["20px"],
|
|
871
|
+
pl: Spacing["12px"],
|
|
872
|
+
pr: Spacing["40px"],
|
|
873
|
+
...(() => {
|
|
874
|
+
switch (variant) {
|
|
875
|
+
case "default":
|
|
876
|
+
return {
|
|
877
|
+
"li + li > &": { borderTop: "White8" },
|
|
878
|
+
"&:hover, &:focus-visible": { bg: "White4" },
|
|
879
|
+
'&[data-state="open"]': { bg: "transparent" },
|
|
880
|
+
backgroundClip: "padding-box",
|
|
881
|
+
transition: buildTransition("COLORS")
|
|
882
|
+
};
|
|
883
|
+
case "sub":
|
|
884
|
+
return {
|
|
885
|
+
my: `-${Spacing["8px"]}`,
|
|
886
|
+
py: Spacing["8px"]
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
})(),
|
|
890
|
+
"&:focus-visible": { outline: "none" },
|
|
891
|
+
'&:is(:disabled, [aria-disabled="true"])': { pointerEvents: "none" }
|
|
892
|
+
},
|
|
893
|
+
...props,
|
|
894
|
+
children: /* @__PURE__ */ jsxs(Flex.Row, { as: "span", gap: Spacing["12px"], sx: { color: "White" }, children: [
|
|
895
|
+
/* @__PURE__ */ jsx(
|
|
896
|
+
Flex.Center,
|
|
897
|
+
{
|
|
898
|
+
as: "span",
|
|
899
|
+
sx: {
|
|
900
|
+
mt: Spacing["2px"],
|
|
901
|
+
width: Spacing["16px"],
|
|
902
|
+
height: Spacing["16px"],
|
|
903
|
+
flexShrink: 0,
|
|
904
|
+
...(() => {
|
|
905
|
+
switch (variant) {
|
|
906
|
+
default:
|
|
907
|
+
return {
|
|
908
|
+
opacity: Opacity["0%"],
|
|
909
|
+
".gds-ButtonOrLink:focus-visible &": {
|
|
910
|
+
opacity: Opacity["32%"]
|
|
911
|
+
},
|
|
912
|
+
'.gds-ButtonOrLink[data-active]:not([data-state="open"]) &': {
|
|
913
|
+
opacity: Opacity["88%"]
|
|
914
|
+
},
|
|
915
|
+
'.gds-ButtonOrLink[data-active]:not([data-state="open"]):is(:hover, :focus-visible) &': {
|
|
916
|
+
opacity: Opacity["100%"]
|
|
917
|
+
},
|
|
918
|
+
'.gds-ButtonOrLink[data-active]:is(:disabled, [aria-disabled="true"]) &': {
|
|
919
|
+
opacity: Opacity["32%"]
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
case "back":
|
|
923
|
+
return {
|
|
924
|
+
opacity: Opacity["64%"],
|
|
925
|
+
".gds-ButtonOrLink:is(:hover, :focus-visible) &": {
|
|
926
|
+
opacity: Opacity["100%"]
|
|
927
|
+
},
|
|
928
|
+
'.gds-ButtonOrLink:is(:disabled, [aria-disabled="true"]) &': {
|
|
929
|
+
opacity: Opacity["32%"]
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
})(),
|
|
934
|
+
transition: buildTransition("OPACITY")
|
|
935
|
+
},
|
|
936
|
+
children: /* @__PURE__ */ jsx(IconElement, { size: "14px" })
|
|
937
|
+
}
|
|
938
|
+
),
|
|
939
|
+
/* @__PURE__ */ jsx(
|
|
940
|
+
TextElement,
|
|
941
|
+
{
|
|
942
|
+
as: "span",
|
|
943
|
+
sx: {
|
|
944
|
+
flexGrow: 1,
|
|
945
|
+
opacity: variant === "sub" ? Opacity["48%"] : Opacity["64%"],
|
|
946
|
+
".gds-ButtonOrLink[data-active] &": {
|
|
947
|
+
opacity: Opacity["88%"]
|
|
948
|
+
},
|
|
949
|
+
".gds-ButtonOrLink:is(:hover, :focus-visible) &": {
|
|
950
|
+
opacity: Opacity["100%"]
|
|
951
|
+
},
|
|
952
|
+
'.gds-ButtonOrLink:is(:disabled, [aria-disabled="true"]) &': {
|
|
953
|
+
opacity: Opacity["32%"]
|
|
954
|
+
},
|
|
955
|
+
transition: buildTransition("OPACITY")
|
|
956
|
+
},
|
|
957
|
+
children
|
|
958
|
+
}
|
|
959
|
+
)
|
|
960
|
+
] })
|
|
961
|
+
}
|
|
962
|
+
);
|
|
963
|
+
});
|
|
964
|
+
StackedNavButtonOrLink.displayName = "GlobalHeader._StackedNavButtonOrLink";
|
|
965
|
+
const GlobalHeaderLocaleSwitcher = forwardRef(
|
|
966
|
+
(props, ref) => {
|
|
967
|
+
const { t, localeDetails } = useI18n();
|
|
968
|
+
return /* @__PURE__ */ jsx(LocaleSwitcher, { ref, ...props, children: /* @__PURE__ */ jsxs(Link, { wrap: false, autoIcon: false, children: [
|
|
969
|
+
/* @__PURE__ */ jsx(Icon.World, { title: t("components.globalHeader.language"), size: "20px" }),
|
|
970
|
+
/* @__PURE__ */ jsx("span", { sx: { display: ["none", null, null, "inline"] }, children: localeDetails.displayName }),
|
|
971
|
+
/* @__PURE__ */ jsx(
|
|
972
|
+
Icon.CaretDown,
|
|
973
|
+
{
|
|
974
|
+
title: "",
|
|
975
|
+
size: "12px",
|
|
976
|
+
sx: {
|
|
977
|
+
display: ["none", null, null, "inline-block"],
|
|
978
|
+
'.gds-ButtonOrLink[data-state="open"] &': { transform: "rotate(-180deg)" },
|
|
979
|
+
transition: buildTransition("TRANSFORM")
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
)
|
|
983
|
+
] }) });
|
|
984
|
+
}
|
|
985
|
+
);
|
|
986
|
+
GlobalHeaderLocaleSwitcher.displayName = "GlobalHeader.LocaleSwitcher";
|
|
987
|
+
const GlobalHeaderSupportButton = forwardRef(
|
|
988
|
+
({ href, onClick, ...props }, ref) => {
|
|
989
|
+
const { supportNavItem } = useContext(GlobalHeaderContext);
|
|
990
|
+
const { t } = useI18n();
|
|
991
|
+
const finalProps = {
|
|
992
|
+
...props,
|
|
993
|
+
href: href ?? (supportNavItem == null ? void 0 : supportNavItem.href),
|
|
994
|
+
onClick: (event) => {
|
|
995
|
+
var _a;
|
|
996
|
+
onClick == null ? void 0 : onClick(event);
|
|
997
|
+
(_a = supportNavItem == null ? void 0 : supportNavItem.onClick) == null ? void 0 : _a.call(supportNavItem, event);
|
|
998
|
+
}
|
|
999
|
+
};
|
|
1000
|
+
return /* @__PURE__ */ jsxs(Link, { ref, wrap: false, autoIcon: false, ...finalProps, children: [
|
|
1001
|
+
/* @__PURE__ */ jsx(ChatDots, { alt: "", variant: "fill", size: 5 }),
|
|
1002
|
+
/* @__PURE__ */ jsx("span", { sx: { display: ["none", null, null, "inline"] }, children: (supportNavItem == null ? void 0 : supportNavItem.label) ?? t("components.globalHeader.support") })
|
|
1003
|
+
] });
|
|
1004
|
+
}
|
|
1005
|
+
);
|
|
1006
|
+
GlobalHeaderSupportButton.displayName = "GlobalHeader.SupportButton";
|
|
1007
|
+
const GlobalHeaderConnectButton = forwardRef(
|
|
1008
|
+
(props, ref) => {
|
|
1009
|
+
const { t } = useI18n();
|
|
1010
|
+
return /* @__PURE__ */ jsx(Button.Secondary, { ref, size: ["small", null, null, "medium"], ...props, children: t("components.globalHeader.connect") });
|
|
1011
|
+
}
|
|
1012
|
+
);
|
|
1013
|
+
GlobalHeaderConnectButton.displayName = "GlobalHeader.ConnectButton";
|
|
1014
|
+
const GlobalHeaderBackButton = forwardRef(
|
|
1015
|
+
(props, ref) => {
|
|
1016
|
+
const { t } = useI18n();
|
|
1017
|
+
return /* @__PURE__ */ jsx(Link, { ref, wrap: false, autoIcon: false, ...props, children: /* @__PURE__ */ jsx(Icon.ArrowLeft, { title: t("components.globalHeader.back"), size: "20px" }) });
|
|
1018
|
+
}
|
|
1019
|
+
);
|
|
1020
|
+
GlobalHeaderBackButton.displayName = "GlobalHeader.BackButton";
|
|
1021
|
+
const GlobalHeader = Object.assign(GlobalHeaderComponent, {
|
|
1022
|
+
/**
|
|
1023
|
+
* Locale switcher part of the global header. Rendered automatically if `showLocaleSwitcher` is `true`, but can be used
|
|
1024
|
+
* in either `leftContent` or `rightContent` to customize the appearance, position, or behavior of the locale switcher.
|
|
1025
|
+
*/
|
|
1026
|
+
LocaleSwitcher: GlobalHeaderLocaleSwitcher,
|
|
1027
|
+
/**
|
|
1028
|
+
* Support button part of the global header. Rendered automatically if `showSupportButton` is `true` or an options object, but
|
|
1029
|
+
* can be used in either `leftContent` or `rightContent` to customize the appearance, position, or behavior of the support button.
|
|
1030
|
+
*/
|
|
1031
|
+
SupportButton: GlobalHeaderSupportButton,
|
|
1032
|
+
/**
|
|
1033
|
+
* Connect button part of the global header. Should be added to `rightContent` in apps that support connecting a wallet.
|
|
1034
|
+
* Doesn't have any built-in functionality at the moment (i.e. a `onClick` handler must be provided).
|
|
1035
|
+
*/
|
|
1036
|
+
ConnectButton: GlobalHeaderConnectButton,
|
|
1037
|
+
/**
|
|
1038
|
+
* A simple back button component that can be rendered in `leftContent` for "full screen flows".
|
|
1039
|
+
* Doesn't have any built-in functionality at the moment (i.e. a `href` or `onClick` handler must be provided).
|
|
1040
|
+
*/
|
|
1041
|
+
BackButton: GlobalHeaderBackButton
|
|
1042
|
+
});
|
|
1043
|
+
export {
|
|
1044
|
+
GlobalHeader
|
|
1045
|
+
};
|