@redocly/theme 0.17.1 → 0.18.1
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/lib/I18n/LanguagePicker.js +53 -85
- package/lib/components/Catalog/Catalog.d.ts +1 -1
- package/lib/components/Catalog/useCatalog.d.ts +2 -1
- package/lib/components/Dropdown/Dropdown.d.ts +16 -0
- package/lib/components/Dropdown/Dropdown.js +113 -0
- package/lib/components/Dropdown/index.d.ts +1 -0
- package/lib/components/Dropdown/index.js +18 -0
- package/lib/components/Menu/MenuGroup.js +2 -0
- package/lib/components/Menu/MenuItem.js +2 -0
- package/lib/components/Menu/MobileMenu.d.ts +2 -9
- package/lib/components/Menu/MobileMenu.js +35 -65
- package/lib/components/Menu/MobileMenuGroup.js +2 -0
- package/lib/components/Menu/constants.d.ts +5 -0
- package/lib/components/Menu/constants.js +10 -0
- package/lib/components/Menu/hooks/use-mobile-menu-items.d.ts +2 -0
- package/lib/components/Menu/hooks/use-mobile-menu-items.js +83 -0
- package/lib/components/Menu/hooks/use-mobile-menu-levels.d.ts +5 -0
- package/lib/components/Menu/hooks/use-mobile-menu-levels.js +50 -0
- package/lib/components/Menu/types.d.ts +3 -0
- package/lib/components/Menu/types.js +3 -0
- package/lib/components/Menu/utils.d.ts +7 -0
- package/lib/components/Menu/utils.js +76 -0
- package/lib/components/Navbar/MobileUserProfile.d.ts +1 -1
- package/lib/components/Navbar/MobileUserProfile.js +4 -7
- package/lib/components/Navbar/Navbar.d.ts +0 -3
- package/lib/components/Navbar/Navbar.js +9 -12
- package/lib/components/Navbar/NavbarItem.d.ts +5 -1
- package/lib/components/Navbar/NavbarItem.js +15 -16
- package/lib/components/Navbar/NavbarMenu.js +1 -1
- package/lib/components/OpenApiDocs/Dropdown.js +5 -5
- package/lib/components/Product/Product.d.ts +7 -0
- package/lib/components/Product/Product.js +23 -0
- package/lib/components/Product/ProductPicker.d.ts +2 -0
- package/lib/components/Product/ProductPicker.js +83 -0
- package/lib/components/Product/index.d.ts +2 -0
- package/lib/components/Product/index.js +19 -0
- package/lib/components/Profile/UserProfile.js +54 -6
- package/lib/components/Search/InputWrapper.js +1 -7
- package/lib/components/Search/ProductTag.d.ts +6 -0
- package/lib/components/Search/ProductTag.js +61 -0
- package/lib/components/Search/SearchDialog.js +19 -4
- package/lib/components/Search/SearchItem.d.ts +2 -1
- package/lib/components/Search/SearchItem.js +13 -2
- package/lib/components/Search/index.d.ts +1 -0
- package/lib/components/Search/index.js +1 -0
- package/lib/components/Select/Select.d.ts +18 -0
- package/lib/components/Select/Select.js +118 -0
- package/lib/components/Select/index.d.ts +1 -0
- package/lib/components/Select/index.js +18 -0
- package/lib/components/Sidebar/DrilldownMenuItem.js +2 -9
- package/lib/components/Sidebar/SidebarItemIcon.d.ts +1 -0
- package/lib/components/Sidebar/SidebarItemIcon.js +16 -0
- package/lib/components/Sidebar/VersionPicker.d.ts +7 -0
- package/lib/components/Sidebar/VersionPicker.js +51 -0
- package/lib/components/Sidebar/index.d.ts +2 -0
- package/lib/components/Sidebar/index.js +2 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +3 -0
- package/lib/config.d.ts +952 -25
- package/lib/config.js +115 -2
- package/lib/globalStyle.js +177 -16
- package/lib/hooks/useThemeConfig.d.ts +1 -1
- package/lib/hooks/useThemeConfig.js +7 -2
- package/lib/mocks/hooks/index.d.ts +4 -3
- package/lib/mocks/hooks/index.js +6 -2
- package/lib/mocks/search.d.ts +1 -1
- package/lib/mocks/search.js +1 -1
- package/lib/types/portal/src/shared/types/catalog.d.ts +2 -24
- package/lib/types/portal/src/shared/types/nav.d.ts +4 -0
- package/lib/types/portal/src/shared/types/searchDocument.d.ts +2 -0
- package/lib/ui/darkColors.js +2 -0
- package/lib/ui/index.d.ts +0 -1
- package/lib/ui/index.js +0 -1
- package/package.json +1 -1
- package/src/I18n/LanguagePicker.tsx +62 -89
- package/src/components/Catalog/Catalog.tsx +1 -1
- package/src/components/Catalog/useCatalog.ts +2 -3
- package/src/components/Dropdown/Dropdown.tsx +138 -0
- package/src/components/Dropdown/index.ts +1 -0
- package/src/components/Menu/MenuGroup.tsx +2 -0
- package/src/components/Menu/MenuItem.tsx +2 -0
- package/src/components/Menu/MobileMenu.tsx +43 -96
- package/src/components/Menu/MobileMenuGroup.tsx +2 -0
- package/src/components/Menu/constants.ts +5 -0
- package/src/components/Menu/hooks/use-mobile-menu-items.ts +100 -0
- package/src/components/Menu/hooks/use-mobile-menu-levels.ts +55 -0
- package/src/components/Menu/types.ts +3 -0
- package/src/components/Menu/utils.ts +109 -0
- package/src/components/Navbar/MobileUserProfile.tsx +19 -20
- package/src/components/Navbar/Navbar.tsx +12 -22
- package/src/components/Navbar/NavbarItem.tsx +20 -15
- package/src/components/Navbar/NavbarMenu.tsx +1 -1
- package/src/components/OpenApiDocs/Dropdown.tsx +5 -5
- package/src/components/Product/Product.tsx +28 -0
- package/src/components/Product/ProductPicker.tsx +97 -0
- package/src/components/Product/index.ts +2 -0
- package/src/components/Profile/UserProfile.tsx +80 -21
- package/src/components/Search/InputWrapper.tsx +1 -7
- package/src/components/Search/ProductTag.tsx +46 -0
- package/src/components/Search/SearchDialog.tsx +21 -5
- package/src/components/Search/SearchItem.tsx +17 -3
- package/src/components/Search/index.ts +1 -0
- package/src/components/Select/Select.tsx +140 -0
- package/src/components/Select/index.ts +1 -0
- package/src/components/Sidebar/DrilldownMenuItem.tsx +2 -10
- package/src/components/Sidebar/SidebarItemIcon.tsx +10 -0
- package/src/components/Sidebar/VersionPicker.tsx +48 -0
- package/src/components/Sidebar/index.ts +2 -0
- package/src/components/index.ts +3 -0
- package/src/config.ts +140 -6
- package/src/globalStyle.ts +181 -16
- package/src/hooks/useThemeConfig.ts +18 -3
- package/src/mocks/hooks/index.ts +9 -3
- package/src/mocks/search.ts +1 -1
- package/src/types/portal/src/shared/types/catalog.ts +2 -26
- package/src/types/portal/src/shared/types/i18n.d.ts +3 -1
- package/src/types/portal/src/shared/types/nav.ts +41 -37
- package/src/types/portal/src/shared/types/searchDocument.ts +7 -4
- package/src/ui/darkColors.tsx +2 -0
- package/src/ui/index.tsx +0 -1
- package/lib/components/Navbar/NavbarDropdown.d.ts +0 -9
- package/lib/components/Navbar/NavbarDropdown.js +0 -40
- package/lib/components/Profile/UserProfileMenu.d.ts +0 -8
- package/lib/components/Profile/UserProfileMenu.js +0 -93
- package/src/components/Navbar/NavbarDropdown.tsx +0 -48
- package/src/components/Profile/UserProfileMenu.tsx +0 -97
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMobileMenuItems = void 0;
|
|
4
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
5
|
+
const hooks_1 = require("../../../mocks/hooks");
|
|
6
|
+
const useSidebarItems_1 = require("../../../mocks/Sidebar/useSidebarItems");
|
|
7
|
+
const hooks_2 = require("../../../hooks");
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
const MENU_SEPARATOR = {
|
|
11
|
+
type: 'separator',
|
|
12
|
+
separatorLine: true,
|
|
13
|
+
};
|
|
14
|
+
const TRANSLATION_KEYS = {
|
|
15
|
+
products: 'theme.mobileMenu.products',
|
|
16
|
+
};
|
|
17
|
+
const useMobileMenuItems = (menuType) => {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
const { versions = [] } = (0, hooks_1.usePageVersions)() || {};
|
|
20
|
+
const { defaultLocale, currentLocale, locales } = (0, hooks_1.useI18nConfig)();
|
|
21
|
+
const { translate } = (0, hooks_1.useTranslate)();
|
|
22
|
+
const activeVersion = versions.find((version) => version.active);
|
|
23
|
+
const sidebarItems = (0, useSidebarItems_1.useSidebarItems)(activeVersion);
|
|
24
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
25
|
+
const currentProduct = (0, hooks_1.useCurrentProduct)();
|
|
26
|
+
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.themeOverride) === null || _a === void 0 ? void 0 : _a.navbar;
|
|
27
|
+
const productThemeConfig = (0, hooks_2.useThemeConfig)();
|
|
28
|
+
const baseThemeConfig = (0, hooks_2.useThemeConfig)(false);
|
|
29
|
+
const baseNavItems = (((_b = baseThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || []);
|
|
30
|
+
const productNavItems = (hasProductNavbarOverride ? ((_c = productThemeConfig.navbar) === null || _c === void 0 ? void 0 : _c.items) || [] : []);
|
|
31
|
+
const menuItems = [];
|
|
32
|
+
if (menuType === constants_1.MenuType.PAGE) {
|
|
33
|
+
if (activeVersion) {
|
|
34
|
+
// TODO: consider to refactor
|
|
35
|
+
const versionsSection = (0, utils_1.buildVersionSection)(translate, versions, activeVersion);
|
|
36
|
+
menuItems.push(...versionsSection);
|
|
37
|
+
}
|
|
38
|
+
if (menuItems.length && sidebarItems.length) {
|
|
39
|
+
menuItems.push(MENU_SEPARATOR);
|
|
40
|
+
}
|
|
41
|
+
menuItems.push(...sidebarItems);
|
|
42
|
+
}
|
|
43
|
+
else if (menuType === constants_1.MenuType.PRODUCT) {
|
|
44
|
+
menuItems.push(...productNavItems);
|
|
45
|
+
if (menuItems.length && baseNavItems.length) {
|
|
46
|
+
menuItems.push(MENU_SEPARATOR);
|
|
47
|
+
}
|
|
48
|
+
if (baseNavItems.length) {
|
|
49
|
+
menuItems.push(...baseNavItems);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (menuType === constants_1.MenuType.MAIN_MENU) {
|
|
53
|
+
const productMenuItems = Object.values(baseThemeConfig.products || {}).map((product) => ({
|
|
54
|
+
label: product.name,
|
|
55
|
+
link: product.link,
|
|
56
|
+
icon: product.icon,
|
|
57
|
+
type: 'link',
|
|
58
|
+
}));
|
|
59
|
+
if (productMenuItems.length) {
|
|
60
|
+
menuItems.push({
|
|
61
|
+
type: 'separator',
|
|
62
|
+
label: translate(TRANSLATION_KEYS.products, 'Products'),
|
|
63
|
+
});
|
|
64
|
+
menuItems.push(...productMenuItems);
|
|
65
|
+
}
|
|
66
|
+
if (menuItems.length && baseNavItems.length) {
|
|
67
|
+
menuItems.push(MENU_SEPARATOR);
|
|
68
|
+
}
|
|
69
|
+
if (baseNavItems.length) {
|
|
70
|
+
menuItems.push(...baseNavItems);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const languagesMenu = (0, utils_1.buildLanguagesGroup)(locales, defaultLocale, currentLocale);
|
|
74
|
+
if (menuItems.length && languagesMenu) {
|
|
75
|
+
menuItems.push(MENU_SEPARATOR);
|
|
76
|
+
}
|
|
77
|
+
if (languagesMenu) {
|
|
78
|
+
menuItems.push(languagesMenu);
|
|
79
|
+
}
|
|
80
|
+
return (0, utils_1.mapNavbarItems)(menuItems, defaultLocale, currentLocale, locales, location);
|
|
81
|
+
};
|
|
82
|
+
exports.useMobileMenuItems = useMobileMenuItems;
|
|
83
|
+
//# sourceMappingURL=use-mobile-menu-items.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMobileMenuLevels = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
+
const hooks_1 = require("../../../mocks/hooks");
|
|
7
|
+
const useSidebarItems_1 = require("../../../mocks/Sidebar/useSidebarItems");
|
|
8
|
+
const constants_1 = require("../../../components/Menu/constants");
|
|
9
|
+
const hooks_2 = require("../../../hooks");
|
|
10
|
+
const TRANSLATION_KEYS = {
|
|
11
|
+
mainMenu: 'theme.mobileMenu.mainMenu',
|
|
12
|
+
previous: 'theme.mobileMenu.previous',
|
|
13
|
+
};
|
|
14
|
+
const useMobileMenuLevels = () => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const { versions = [] } = (0, hooks_1.usePageVersions)() || {};
|
|
17
|
+
const activeVersion = versions.find((version) => version === null || version === void 0 ? void 0 : version.active);
|
|
18
|
+
const sidebarItems = (0, useSidebarItems_1.useSidebarItems)(activeVersion);
|
|
19
|
+
const { translate } = (0, hooks_1.useTranslate)();
|
|
20
|
+
const currentProduct = (0, hooks_1.useCurrentProduct)();
|
|
21
|
+
const productThemeConfig = (0, hooks_2.useThemeConfig)();
|
|
22
|
+
const location = (0, react_router_dom_1.useLocation)();
|
|
23
|
+
const hasProductNavbarOverride = (_a = currentProduct === null || currentProduct === void 0 ? void 0 : currentProduct.themeOverride) === null || _a === void 0 ? void 0 : _a.navbar;
|
|
24
|
+
const productNavItems = (hasProductNavbarOverride ? ((_b = productThemeConfig.navbar) === null || _b === void 0 ? void 0 : _b.items) || [] : []);
|
|
25
|
+
const menuLevels = (0, react_1.useMemo)(() => {
|
|
26
|
+
const menuLevels = [
|
|
27
|
+
{
|
|
28
|
+
label: translate(TRANSLATION_KEYS.mainMenu, 'Main Menu'),
|
|
29
|
+
type: constants_1.MenuType.MAIN_MENU,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
if (currentProduct && productNavItems.length) {
|
|
33
|
+
menuLevels.push({
|
|
34
|
+
label: currentProduct.name,
|
|
35
|
+
type: constants_1.MenuType.PRODUCT,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (sidebarItems.length || activeVersion) {
|
|
39
|
+
menuLevels.push({
|
|
40
|
+
label: translate(TRANSLATION_KEYS.previous, 'Previous'),
|
|
41
|
+
type: constants_1.MenuType.PAGE,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return menuLevels;
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
}, [location]);
|
|
47
|
+
return menuLevels;
|
|
48
|
+
};
|
|
49
|
+
exports.useMobileMenuLevels = useMobileMenuLevels;
|
|
50
|
+
//# sourceMappingURL=use-mobile-menu-levels.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Location } from 'react-router-dom';
|
|
2
|
+
import type { ItemState } from '../../components/Sidebar/types';
|
|
3
|
+
import type { Locale, ResolvedNavItem, TFunction, Version } from '../../types/portal';
|
|
4
|
+
export declare const mapNavbarItems: (items: ResolvedNavItem[], defaultLocale: string, currentLocale: string, locales: Locale[], location: Location) => ItemState[];
|
|
5
|
+
export declare const isItemActive: (item: ResolvedNavItem, defaultLocale: string, currentLocale: string, locales: Locale[], location: Location) => boolean;
|
|
6
|
+
export declare const buildLanguagesGroup: (locales: Locale[], currentLocale: string, defaultLocale: string) => ResolvedNavItem | undefined;
|
|
7
|
+
export declare const buildVersionSection: (translate: TFunction, versions: Version[], activeVersion?: Version) => ResolvedNavItem[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildVersionSection = exports.buildLanguagesGroup = exports.isItemActive = exports.mapNavbarItems = void 0;
|
|
4
|
+
const utils_1 = require("../../mocks/utils");
|
|
5
|
+
const urls_1 = require("../../utils/urls");
|
|
6
|
+
const TRANSLATION_KEYS = {
|
|
7
|
+
version: 'theme.mobileMenu.version',
|
|
8
|
+
};
|
|
9
|
+
const mapNavbarItems = (items, defaultLocale, currentLocale, locales, location) => {
|
|
10
|
+
return items.map((navItem) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return (Object.assign(Object.assign(Object.assign(Object.assign({}, navItem), (navItem.items && {
|
|
13
|
+
items: (0, exports.mapNavbarItems)(navItem.items, defaultLocale, currentLocale, locales, location),
|
|
14
|
+
})), ('link' in navItem && { link: navItem.link || '/' })), { active: 'link' in navItem &&
|
|
15
|
+
(0, exports.isItemActive)(navItem, defaultLocale, currentLocale, locales, location), hasActiveSubItem: !!((_a = navItem.items) === null || _a === void 0 ? void 0 : _a.find((item) => (0, exports.isItemActive)(item, defaultLocale, currentLocale, locales, location))) }));
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.mapNavbarItems = mapNavbarItems;
|
|
19
|
+
const isItemActive = (item, defaultLocale, currentLocale, locales, location) => {
|
|
20
|
+
const pathHash = location.pathname + location.hash;
|
|
21
|
+
const link = item.languageInsensitive
|
|
22
|
+
? item.link || ''
|
|
23
|
+
: (0, utils_1.getPathnameForLocale)(item.link || '/', defaultLocale, currentLocale, locales);
|
|
24
|
+
return pathHash === (0, urls_1.withPathPrefix)(link);
|
|
25
|
+
};
|
|
26
|
+
exports.isItemActive = isItemActive;
|
|
27
|
+
const buildLanguagesGroup = (locales, currentLocale, defaultLocale) => {
|
|
28
|
+
if (locales.length < 2) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const locale = locales.find((l) => l.code === currentLocale);
|
|
32
|
+
return {
|
|
33
|
+
type: 'group',
|
|
34
|
+
label: (locale === null || locale === void 0 ? void 0 : locale.name) || (locale === null || locale === void 0 ? void 0 : locale.code),
|
|
35
|
+
items: locales
|
|
36
|
+
.filter((locale) => locale.code !== currentLocale)
|
|
37
|
+
.map((locale) => {
|
|
38
|
+
const newLangPathname = (0, urls_1.withPathPrefix)((0, utils_1.getPathnameForLocale)(location.pathname, defaultLocale, locale.code, locales));
|
|
39
|
+
const newUrlWithLanguage = `${newLangPathname}${location.search}${location.hash}`;
|
|
40
|
+
return {
|
|
41
|
+
type: 'link',
|
|
42
|
+
label: locale.name || locale.code || '',
|
|
43
|
+
link: newUrlWithLanguage,
|
|
44
|
+
active: false,
|
|
45
|
+
hasActiveSubItem: false,
|
|
46
|
+
languageInsensitive: true,
|
|
47
|
+
};
|
|
48
|
+
}),
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
exports.buildLanguagesGroup = buildLanguagesGroup;
|
|
52
|
+
const buildVersionSection = (translate, versions, activeVersion) => {
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
type: 'separator',
|
|
56
|
+
label: translate(TRANSLATION_KEYS.version, 'Version'),
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'group',
|
|
60
|
+
label: activeVersion === null || activeVersion === void 0 ? void 0 : activeVersion.label,
|
|
61
|
+
items: versions
|
|
62
|
+
.filter((version) => !version.active)
|
|
63
|
+
.map((version) => {
|
|
64
|
+
return {
|
|
65
|
+
type: 'link',
|
|
66
|
+
label: version.label,
|
|
67
|
+
link: version.link,
|
|
68
|
+
active: false,
|
|
69
|
+
hasActiveSubItem: false,
|
|
70
|
+
};
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
};
|
|
75
|
+
exports.buildVersionSection = buildVersionSection;
|
|
76
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function MobileUserProfile(): JSX.Element;
|
|
2
|
+
export declare function MobileUserProfile(): JSX.Element | null;
|
|
@@ -18,17 +18,15 @@ function MobileUserProfile() {
|
|
|
18
18
|
const translationKeys = {
|
|
19
19
|
login: 'theme.profile.login',
|
|
20
20
|
};
|
|
21
|
-
if (!(userData === null || userData === void 0 ? void 0 : userData.isAuthenticated))
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return (react_1.default.createElement(MobileProfileWrapper, { "data-component-name": "Navbar/MobileUserProfile" },
|
|
21
|
+
if (!(userData === null || userData === void 0 ? void 0 : userData.isAuthenticated) && !loginUrl)
|
|
22
|
+
return null;
|
|
23
|
+
return (react_1.default.createElement(MobileProfileWrapper, { "data-component-name": "Navbar/MobileUserProfile" }, !(userData === null || userData === void 0 ? void 0 : userData.isAuthenticated) ? (react_1.default.createElement(LoginButton, { href: loginUrl, "data-cy": "login-btn" }, translate(translationKeys.login, (userProfile === null || userProfile === void 0 ? void 0 : userProfile.loginLabel) || 'Login'))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
26
24
|
react_1.default.createElement(UserDataWrapper, null,
|
|
27
25
|
react_1.default.createElement(ProfilePicture, null,
|
|
28
26
|
react_1.default.createElement(Profile_1.Profile, { name: userData.name, imageUrl: userData.picture })),
|
|
29
27
|
react_1.default.createElement(UserName, null, userData.name)),
|
|
30
28
|
react_1.default.createElement(LogoutButton, { onClick: () => handleLogout() },
|
|
31
|
-
react_1.default.createElement(LogoutIcon_1.LogoutIcon, null))));
|
|
29
|
+
react_1.default.createElement(LogoutIcon_1.LogoutIcon, null))))));
|
|
32
30
|
}
|
|
33
31
|
exports.MobileUserProfile = MobileUserProfile;
|
|
34
32
|
const LoginButton = styled_components_1.default.a `
|
|
@@ -49,7 +47,6 @@ const MobileProfileWrapper = styled_components_1.default.div `
|
|
|
49
47
|
justify-content: space-between;
|
|
50
48
|
align-items: center;
|
|
51
49
|
width: 100%;
|
|
52
|
-
position: fixed;
|
|
53
50
|
bottom: 0;
|
|
54
51
|
padding: 18px 16px;
|
|
55
52
|
border-top: 1px solid var(--mobile-menu-profile-border-color);
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { NavbarLogoProps } from '../../components/NavbarLogo';
|
|
3
|
-
import type { ResolvedConfigLinks } from '../../types/portal';
|
|
4
3
|
export declare function Navbar(): JSX.Element | null;
|
|
5
4
|
interface NavbarPresentationalProps extends NavbarLogoProps {
|
|
6
|
-
menuItemsExist: boolean;
|
|
7
5
|
closeMobileMenu: () => void;
|
|
8
6
|
openMobileMenu: () => void;
|
|
9
7
|
isOpen: boolean;
|
|
10
8
|
hideSearch: boolean;
|
|
11
|
-
menu: ResolvedConfigLinks;
|
|
12
9
|
hideUserProfile: boolean | string | undefined;
|
|
13
10
|
changeLanguage: (value: string) => void;
|
|
14
11
|
className?: string;
|
|
@@ -31,7 +31,6 @@ const react_1 = __importDefault(require("react"));
|
|
|
31
31
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
32
32
|
const Navbar_1 = require("../../components/Navbar");
|
|
33
33
|
const useMobileMenu_1 = require("../../hooks/useMobileMenu");
|
|
34
|
-
const utils_1 = require("../../utils");
|
|
35
34
|
const NavbarLogo_1 = require("../../components/NavbarLogo");
|
|
36
35
|
const MobileMenu_1 = require("../../components/Menu/MobileMenu");
|
|
37
36
|
const ColorModeSwitcher_1 = require("../../components/ColorModeSwitcher/ColorModeSwitcher");
|
|
@@ -39,9 +38,9 @@ const useThemeConfig_1 = require("../../hooks/useThemeConfig");
|
|
|
39
38
|
const Search_1 = require("../../components/Search/Search");
|
|
40
39
|
const AuthUserProfile_1 = require("../../components/Profile/AuthUserProfile");
|
|
41
40
|
const hooks_1 = require("../../mocks/hooks");
|
|
42
|
-
const BurgerButton_1 = require("../../components/Navbar/BurgerButton");
|
|
43
|
-
const useSidebarItems_1 = require("../../mocks/Sidebar/useSidebarItems");
|
|
44
41
|
const LanguagePicker_1 = require("../../I18n/LanguagePicker");
|
|
42
|
+
const Product_1 = require("../../components/Product");
|
|
43
|
+
const BurgerButton_1 = require("../../components/Navbar/BurgerButton");
|
|
45
44
|
const EmptyNavbarHack = (0, styled_components_1.createGlobalStyle) `
|
|
46
45
|
:root {
|
|
47
46
|
--navbar-height: 0px !important;
|
|
@@ -62,17 +61,14 @@ function Navbar() {
|
|
|
62
61
|
}
|
|
63
62
|
const openMobileMenu = () => setIsOpen(true);
|
|
64
63
|
const closeMobileMenu = () => setIsOpen(false);
|
|
65
|
-
const menuItemsExist = !(0, utils_1.isPrimitive)(menu) && !(0, utils_1.isEmptyArray)(menu);
|
|
66
64
|
if (!menu && !logo) {
|
|
67
65
|
return react_1.default.createElement(EmptyNavbarHack, null);
|
|
68
66
|
}
|
|
69
67
|
return (react_1.default.createElement(NavbarPresentational, Object.assign({}, {
|
|
70
|
-
menuItemsExist,
|
|
71
68
|
closeMobileMenu,
|
|
72
69
|
openMobileMenu,
|
|
73
70
|
isOpen,
|
|
74
71
|
hideSearch: Boolean(hideSearch),
|
|
75
|
-
menu: menu,
|
|
76
72
|
logo: logo,
|
|
77
73
|
hideUserProfile,
|
|
78
74
|
changeLanguage,
|
|
@@ -80,15 +76,16 @@ function Navbar() {
|
|
|
80
76
|
}
|
|
81
77
|
exports.Navbar = Navbar;
|
|
82
78
|
function NavbarPresentational(props) {
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
const
|
|
79
|
+
var _a;
|
|
80
|
+
const { closeMobileMenu, openMobileMenu, isOpen, hideSearch, logo, hideUserProfile, changeLanguage, className, } = props;
|
|
81
|
+
const themeConfig = (0, useThemeConfig_1.useThemeConfig)();
|
|
82
|
+
const menu = (_a = themeConfig.navbar) === null || _a === void 0 ? void 0 : _a.items;
|
|
87
83
|
return (react_1.default.createElement(exports.NavbarContainer, { "data-component-name": "Navbar/Navbar", className: className },
|
|
88
|
-
isOpen && react_1.default.createElement(MobileMenu_1.MobileMenu,
|
|
84
|
+
isOpen && react_1.default.createElement(MobileMenu_1.MobileMenu, null),
|
|
89
85
|
react_1.default.createElement(exports.NavbarRow, null,
|
|
90
|
-
|
|
86
|
+
react_1.default.createElement(BurgerButton_1.BurgerButton, { onClick: isOpen ? closeMobileMenu : openMobileMenu, isOpen: isOpen }),
|
|
91
87
|
react_1.default.createElement(NavbarLogo_1.NavbarLogo, { logo: logo }),
|
|
88
|
+
react_1.default.createElement(Product_1.ProductPicker, null),
|
|
92
89
|
react_1.default.createElement(Navbar_1.NavbarMenu, { menuItems: menu }),
|
|
93
90
|
hideSearch ? null : react_1.default.createElement(Search_1.Search, null),
|
|
94
91
|
react_1.default.createElement(LanguagePicker_1.LanguagePicker, { onChangeLanguage: changeLanguage }),
|
|
@@ -6,7 +6,11 @@ export interface NavbarItemProps {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function NavbarItem({ navItem, className }: NavbarItemProps): JSX.Element | null;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const NavbarMenuItemDropdown: import("styled-components").StyledComponent<({ children, className, items, withArrow, triggerEvent, onChange, dataAttributes, }: import("../../components/Dropdown").DropdownProps) => JSX.Element, any, {
|
|
10
|
+
dataAttributes: {
|
|
11
|
+
'data-component-name': string;
|
|
12
|
+
};
|
|
13
|
+
}, "dataAttributes">;
|
|
10
14
|
export declare const NavbarLink: import("styled-components").StyledComponent<typeof Link, any, {}, never>;
|
|
11
15
|
export declare const NavbarMenuItem: import("styled-components").StyledComponent<"li", any, {
|
|
12
16
|
active?: boolean | undefined;
|
|
@@ -26,15 +26,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.NavbarIcon = exports.NavbarMenuItem = exports.NavbarLink = exports.
|
|
29
|
+
exports.NavbarIcon = exports.NavbarMenuItem = exports.NavbarLink = exports.NavbarMenuItemDropdown = exports.NavbarItem = void 0;
|
|
30
30
|
const react_1 = __importDefault(require("react"));
|
|
31
31
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
32
32
|
const react_router_dom_1 = require("react-router-dom");
|
|
33
33
|
const Link_1 = require("../../mocks/Link");
|
|
34
34
|
const utils_1 = require("../../mocks/utils");
|
|
35
|
-
const NavbarDropdown_1 = require("../../components/Navbar/NavbarDropdown");
|
|
36
35
|
const hooks_1 = require("../../mocks/hooks");
|
|
37
36
|
const utils_2 = require("../../utils");
|
|
37
|
+
const Dropdown_1 = require("../../components/Dropdown");
|
|
38
38
|
function NavbarItem({ navItem, className }) {
|
|
39
39
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
40
40
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
@@ -50,24 +50,24 @@ function NavbarItem({ navItem, className }) {
|
|
|
50
50
|
}
|
|
51
51
|
if (navItem.items) {
|
|
52
52
|
const item = navItem;
|
|
53
|
-
|
|
53
|
+
const groupItems = item.items;
|
|
54
|
+
const groupItemsComponents = groupItems.map((item, index) => (react_1.default.createElement(Link_1.Link, { key: `${item.label}_${index}`, to: item.link }, translate(item.labelTranslationKey, item.label))));
|
|
55
|
+
return (react_1.default.createElement(exports.NavbarMenuItemDropdown, { items: groupItemsComponents, triggerEvent: "hover" },
|
|
54
56
|
react_1.default.createElement(exports.NavbarMenuItem, { active: false, "data-component-name": "Navbar/NavbarItem", className: className },
|
|
55
57
|
react_1.default.createElement(exports.NavbarIcon, { url: item.icon }),
|
|
56
|
-
react_1.default.createElement(NavbarLabel, null, translate(item.labelTranslationKey, item.label)))
|
|
57
|
-
react_1.default.createElement(NavbarDropdown_1.NavbarDropdown, { items: item.items })));
|
|
58
|
+
react_1.default.createElement(NavbarLabel, null, translate(item.labelTranslationKey, item.label)))));
|
|
58
59
|
}
|
|
59
60
|
return null;
|
|
60
61
|
}
|
|
61
62
|
exports.NavbarItem = NavbarItem;
|
|
62
|
-
exports.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
63
|
+
exports.NavbarMenuItemDropdown = (0, styled_components_1.default)(Dropdown_1.Dropdown).attrs(() => ({
|
|
64
|
+
dataAttributes: {
|
|
65
|
+
'data-component-name': 'Navbar/NavbarItemDropdown',
|
|
66
|
+
},
|
|
67
|
+
})) `
|
|
68
|
+
:hover {
|
|
69
|
+
text-decoration: var(--navbar-item-hover-text-decoration);
|
|
70
|
+
background: var(--navbar-item-hover-background-color);
|
|
71
71
|
}
|
|
72
72
|
`;
|
|
73
73
|
exports.NavbarLink = (0, styled_components_1.default)(Link_1.Link) `
|
|
@@ -77,14 +77,13 @@ exports.NavbarLink = (0, styled_components_1.default)(Link_1.Link) `
|
|
|
77
77
|
exports.NavbarMenuItem = styled_components_1.default.li `
|
|
78
78
|
display: inline-block;
|
|
79
79
|
padding: var(--navbar-item-padding-vertical) var(--navbar-item-padding-horizontal);
|
|
80
|
-
margin-left: var(--navbar-item-margin-horizontal);
|
|
81
80
|
text-align: center;
|
|
82
81
|
line-height: 1;
|
|
83
82
|
font-size: var(--navbar-item-font-size);
|
|
84
83
|
border-radius: var(--navbar-item-border-radius);
|
|
85
84
|
font-weight: var(--navbar-item-font-weight);
|
|
86
85
|
background: ${({ active }) => active && 'var(--navbar-item-active-background-color)'};
|
|
87
|
-
color: ${({ active }) => active
|
|
86
|
+
color: ${({ active }) => active ? 'var(--navbar-item-active-text-color)' : 'var(--navbar-text-color)'};
|
|
88
87
|
&:hover {
|
|
89
88
|
color: var(--navbar-item-hover-text-color);
|
|
90
89
|
text-decoration: var(--navbar-item-hover-text-decoration);
|
|
@@ -19,13 +19,13 @@ function NavbarMenu({ menuItems, className, }) {
|
|
|
19
19
|
exports.NavbarMenu = NavbarMenu;
|
|
20
20
|
const NavItemsContainer = styled_components_1.default.ul `
|
|
21
21
|
list-style: none;
|
|
22
|
-
margin: 0 var(--navbar-item-margin-horizontal);
|
|
23
22
|
padding: 0;
|
|
24
23
|
display: none;
|
|
25
24
|
flex-wrap: nowrap;
|
|
26
25
|
align-items: center;
|
|
27
26
|
justify-content: flex-end;
|
|
28
27
|
flex: 1;
|
|
28
|
+
gap: var(--navbar-item-gap);
|
|
29
29
|
|
|
30
30
|
${({ theme }) => theme.mediaQueries.medium} {
|
|
31
31
|
display: flex;
|
|
@@ -87,15 +87,15 @@ box-sizing: border-box;
|
|
|
87
87
|
height: 36px;
|
|
88
88
|
outline: none;
|
|
89
89
|
display: inline-block;
|
|
90
|
-
color: var(--dropdown-text-color);
|
|
90
|
+
color: var(--docs-dropdown-text-color);
|
|
91
91
|
border-radius: var(--border-radius);
|
|
92
|
-
border: var(--dropdown-border);
|
|
93
|
-
padding: var(--dropdown-padding);
|
|
92
|
+
border: var(--docs-dropdown-border);
|
|
93
|
+
padding: var(--docs-dropdown-padding);
|
|
94
94
|
vertical-align: bottom;
|
|
95
95
|
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
96
96
|
text-transform: none;
|
|
97
97
|
line-height: inherit;
|
|
98
|
-
font-size: var(--dropdown-font-size);
|
|
98
|
+
font-size: var(--docs-dropdown-font-size);
|
|
99
99
|
font-family: inherit;
|
|
100
100
|
text-overflow: ellipsis;
|
|
101
101
|
overflow: hidden;
|
|
@@ -126,7 +126,7 @@ box-sizing: border-box;
|
|
|
126
126
|
line-height: inherit;
|
|
127
127
|
font-size: 14px;
|
|
128
128
|
font-family: inherit;
|
|
129
|
-
padding: var(--dropdown-padding);
|
|
129
|
+
padding: var(--docs-dropdown-padding);
|
|
130
130
|
${({ variant }) => (variant === 'dark' ? darkDropdownStyle : '')};
|
|
131
131
|
|
|
132
132
|
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Product = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const Product = ({ product, className }) => {
|
|
10
|
+
return (react_1.default.createElement(ProductWrapper, { "data-component-name": "Product/Product", className: className },
|
|
11
|
+
react_1.default.createElement(ProductLogo, { src: product.icon }),
|
|
12
|
+
react_1.default.createElement("span", null, product.name)));
|
|
13
|
+
};
|
|
14
|
+
exports.Product = Product;
|
|
15
|
+
const ProductWrapper = styled_components_1.default.div `
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
`;
|
|
19
|
+
const ProductLogo = styled_components_1.default.img `
|
|
20
|
+
margin-right: var(--product-logo-margin);
|
|
21
|
+
max-height: var(--select-line-height);
|
|
22
|
+
`;
|
|
23
|
+
//# sourceMappingURL=Product.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProductPicker = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const hooks_1 = require("../../mocks/hooks");
|
|
10
|
+
const Link_1 = require("../../mocks/Link");
|
|
11
|
+
const icons_1 = require("../../icons");
|
|
12
|
+
const Select_1 = require("../Select");
|
|
13
|
+
const Product_1 = require("./Product");
|
|
14
|
+
const ProductPicker = () => {
|
|
15
|
+
var _a;
|
|
16
|
+
const globalData = (0, hooks_1.useGlobalData)();
|
|
17
|
+
const currentProduct = (0, hooks_1.useCurrentProduct)();
|
|
18
|
+
const currentProductComponent = currentProduct ? (react_1.default.createElement(Product_1.Product, { product: currentProduct })) : ('Products');
|
|
19
|
+
const products = Object.values(((_a = globalData === null || globalData === void 0 ? void 0 : globalData.theme) === null || _a === void 0 ? void 0 : _a.products) || {});
|
|
20
|
+
const productComponents = products.map((product) => (react_1.default.createElement(Link_1.Link, { key: product.slug, to: product.link },
|
|
21
|
+
react_1.default.createElement(Product_1.Product, { product: product }))));
|
|
22
|
+
return products.length ? (react_1.default.createElement(ProductSelect, { selected: currentProductComponent, options: productComponents, withArrow: true, triggerEvent: "hover" })) : null;
|
|
23
|
+
};
|
|
24
|
+
exports.ProductPicker = ProductPicker;
|
|
25
|
+
const ProductSelect = (0, styled_components_1.default)(Select_1.Select).attrs(() => ({
|
|
26
|
+
dataAttributes: {
|
|
27
|
+
'data-component-name': 'Product/ProductPicker',
|
|
28
|
+
},
|
|
29
|
+
})) `
|
|
30
|
+
display: none;
|
|
31
|
+
font-size: var(--product-picker-font-size);
|
|
32
|
+
font-weight: var(--product-picker-font-weight);
|
|
33
|
+
line-height: var(--product-picker-line-height);
|
|
34
|
+
border-radius: var(--product-picker-border-radius);
|
|
35
|
+
color: var(--product-picker-text-color);
|
|
36
|
+
|
|
37
|
+
${Select_1.SelectInput} {
|
|
38
|
+
border-radius: var(--product-picker-input-border-radius);
|
|
39
|
+
padding: var(--product-picker-input-padding-vertical)
|
|
40
|
+
var(--product-picker-input-padding-horizontal);
|
|
41
|
+
color: var(--navbar-text-color);
|
|
42
|
+
|
|
43
|
+
a {
|
|
44
|
+
color: var(--navbar-text-color);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
${Select_1.SelectList} {
|
|
49
|
+
min-width: var(--product-picker-list-min-width);
|
|
50
|
+
max-width: var(--product-picker-list-max-width);
|
|
51
|
+
padding: var(--product-picker-list-padding);
|
|
52
|
+
background-color: var(--product-picker-list-background-color);
|
|
53
|
+
border-radius: var(--product-picker-list-border-radius);
|
|
54
|
+
box-shadow: var(--product-picker-list-box-shadow);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
${Select_1.SelectListItem} {
|
|
58
|
+
border-radius: var(--product-picker-list-item-border-radius);
|
|
59
|
+
|
|
60
|
+
& > * {
|
|
61
|
+
padding: var(--product-picker-list-item-vertical-padding)
|
|
62
|
+
var(--product-picker-list-item-horizontal-padding);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:hover {
|
|
66
|
+
background-color: var(--product-picker-list-item-active-background-color);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
${({ theme }) => theme.mediaQueries.medium} {
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
:hover {
|
|
75
|
+
text-decoration: var(--navbar-item-hover-text-decoration);
|
|
76
|
+
background: var(--navbar-item-hover-background-color);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
${icons_1.ArrowIcon} {
|
|
80
|
+
fill: var(--navbar-text-color);
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
//# sourceMappingURL=ProductPicker.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("../../components/Product/ProductPicker"), exports);
|
|
18
|
+
__exportStar(require("../../components/Product/Product"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|