@redocly/theme 0.6.4 → 0.7.0
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/Feedback/Comment.d.ts +3 -0
- package/lib/Feedback/Comment.js +80 -0
- package/lib/Feedback/Rating.d.ts +3 -0
- package/lib/Feedback/Rating.js +82 -0
- package/lib/Feedback/Reasons.d.ts +3 -0
- package/lib/Feedback/Reasons.js +85 -0
- package/lib/Feedback/Sentiment.d.ts +3 -0
- package/lib/Feedback/Sentiment.js +79 -0
- package/lib/Feedback/Thumbs.d.ts +7 -0
- package/lib/Feedback/Thumbs.js +79 -0
- package/lib/Feedback/index.d.ts +5 -0
- package/lib/Feedback/index.js +27 -0
- package/lib/Feedback/types.d.ts +71 -0
- package/lib/Feedback/types.js +3 -0
- package/lib/Markdown/MarkdownLayout.d.ts +2 -1
- package/lib/Markdown/MarkdownLayout.js +8 -2
- package/lib/Markdown/Tabs/Tab.js +11 -5
- package/lib/Markdown/Tabs/Tabs.js +14 -5
- package/lib/Navbar/Navbar.js +6 -3
- package/lib/Pages/Forbidden.d.ts +2 -0
- package/lib/Pages/Forbidden.js +39 -0
- package/lib/Pages/NotFound.d.ts +2 -0
- package/lib/Pages/NotFound.js +39 -0
- package/lib/Pages/index.d.ts +1 -0
- package/lib/Pages/index.js +18 -0
- package/lib/Profile/LoginLink.d.ts +5 -0
- package/lib/Profile/LoginLink.js +30 -0
- package/lib/Profile/Profile.js +3 -1
- package/lib/Profile/UserProfile.d.ts +13 -0
- package/lib/Profile/UserProfile.js +82 -0
- package/lib/Profile/index.d.ts +4 -0
- package/lib/Profile/index.js +5 -1
- package/lib/Search/Autocomplete.d.ts +4 -1
- package/lib/Search/Autocomplete.js +19 -3
- package/lib/Search/ClearIcon.js +1 -1
- package/lib/Search/Input.js +1 -1
- package/lib/Search/Search.js +6 -1
- package/lib/Search/SearchIcon.js +1 -1
- package/lib/Search/ShortcutKey.d.ts +7 -0
- package/lib/Search/ShortcutKey.js +35 -0
- package/lib/config.d.ts +61 -0
- package/lib/config.js +19 -0
- package/lib/globalStyle.js +62 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/mocks/Link.js +1 -1
- package/lib/mocks/hooks/index.js +11 -1
- package/lib/mocks/search.js +18 -5
- package/lib/ui/Box.d.ts +2 -2
- package/lib/ui/Box.js +1 -0
- package/lib/ui/darkColors.js +5 -0
- package/package.json +9 -5
- package/src/Feedback/Comment.tsx +64 -0
- package/src/Feedback/Rating.tsx +107 -0
- package/src/Feedback/Reasons.tsx +81 -0
- package/src/Feedback/Sentiment.tsx +75 -0
- package/src/Feedback/Thumbs.tsx +116 -0
- package/src/Feedback/index.ts +5 -0
- package/src/Feedback/types.ts +63 -0
- package/src/Markdown/MarkdownLayout.tsx +10 -1
- package/src/Markdown/Tabs/Tab.tsx +11 -5
- package/src/Markdown/Tabs/Tabs.tsx +14 -5
- package/src/Navbar/Navbar.tsx +8 -3
- package/src/Pages/Forbidden.tsx +42 -0
- package/src/Pages/NotFound.tsx +42 -0
- package/src/Pages/index.ts +1 -0
- package/src/Profile/LoginLink.tsx +29 -0
- package/src/Profile/Profile.tsx +3 -1
- package/src/Profile/UserProfile.tsx +101 -0
- package/src/Profile/index.ts +4 -0
- package/src/Search/Autocomplete.tsx +26 -2
- package/src/Search/ClearIcon.tsx +1 -1
- package/src/Search/Input.tsx +1 -1
- package/src/Search/Search.tsx +3 -0
- package/src/Search/SearchIcon.tsx +1 -1
- package/src/Search/ShortcutKey.tsx +35 -0
- package/src/config.ts +23 -0
- package/src/globalStyle.ts +64 -0
- package/src/index.ts +2 -0
- package/src/mocks/Link.tsx +2 -1
- package/src/mocks/hooks/index.ts +11 -1
- package/src/mocks/search.ts +20 -5
- package/src/settings.yaml +2 -0
- package/src/types/portal/index.d.ts +1 -1
- package/src/ui/Box.tsx +5 -2
- package/src/ui/darkColors.tsx +5 -0
package/lib/Navbar/Navbar.js
CHANGED
|
@@ -8,27 +8,30 @@ const react_1 = __importDefault(require("react"));
|
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const Navbar_1 = require("../Navbar");
|
|
10
10
|
const useMobileMenu_1 = require("../hooks/useMobileMenu");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
11
12
|
const MobileNavbarMenuButton_1 = require("../Navbar/MobileNavbarMenuButton");
|
|
12
13
|
const MobileNavbarMenu_1 = require("../Navbar/MobileNavbarMenu");
|
|
13
14
|
const ColorModeSwitcher_1 = require("../ColorModeSwitcher/ColorModeSwitcher");
|
|
14
15
|
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
15
16
|
function Navbar({ menu, logo, search, profile }) {
|
|
16
17
|
const [isOpen, setIsOpen] = (0, useMobileMenu_1.useMobileMenu)(false);
|
|
17
|
-
const { search: searchSettings, navbar } = (0, useThemeConfig_1.useThemeConfig)();
|
|
18
|
+
const { search: searchSettings, navbar, userProfile: userProfileSettings } = (0, useThemeConfig_1.useThemeConfig)();
|
|
18
19
|
const hideSearch = (searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.hide) || ((searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.placement) && (searchSettings === null || searchSettings === void 0 ? void 0 : searchSettings.placement) !== 'navbar');
|
|
20
|
+
const hideUserProfile = userProfileSettings === null || userProfileSettings === void 0 ? void 0 : userProfileSettings.hide;
|
|
19
21
|
if (navbar === null || navbar === void 0 ? void 0 : navbar.hide) {
|
|
20
22
|
return null;
|
|
21
23
|
}
|
|
22
24
|
const openMobileMenu = () => setIsOpen(true);
|
|
23
25
|
const closeMobileMenu = () => setIsOpen(false);
|
|
26
|
+
const menuItemsExist = !(0, utils_1.isPrimitive)(menu) && !(0, utils_1.isEmptyArray)(menu);
|
|
24
27
|
return (react_1.default.createElement(exports.NavbarContainer, { "data-component-name": "Navbar/Navbar" },
|
|
25
|
-
react_1.default.createElement(MobileNavbarMenuButton_1.MobileNavbarMenuButton, { onClick: openMobileMenu }),
|
|
28
|
+
menuItemsExist && react_1.default.createElement(MobileNavbarMenuButton_1.MobileNavbarMenuButton, { onClick: openMobileMenu }),
|
|
26
29
|
isOpen && (react_1.default.createElement(MobileNavbarMenu_1.MobileNavbarMenu, { closeMenu: closeMobileMenu, menuItems: menu, search: hideSearch ? null : search })),
|
|
27
30
|
react_1.default.createElement(exports.NavbarRow, null,
|
|
28
31
|
logo,
|
|
29
32
|
react_1.default.createElement(Navbar_1.NavbarMenu, { menuItems: menu }),
|
|
30
33
|
hideSearch ? null : search,
|
|
31
|
-
profile,
|
|
34
|
+
hideUserProfile ? null : profile,
|
|
32
35
|
react_1.default.createElement(ColorModeSwitcher_1.ColorModeSwitcher, null))));
|
|
33
36
|
}
|
|
34
37
|
exports.Navbar = Navbar;
|
|
@@ -0,0 +1,39 @@
|
|
|
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.Forbidden = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const Button_1 = require("../Button");
|
|
10
|
+
function Forbidden() {
|
|
11
|
+
return (react_1.default.createElement(Wrapper, { "data-component-name": "Pages/Forbidden" },
|
|
12
|
+
react_1.default.createElement(Header, null, "403"),
|
|
13
|
+
react_1.default.createElement(Description, null, "Access forbidden"),
|
|
14
|
+
react_1.default.createElement(HomeButton, { color: "primary", size: "large", to: "/" }, "Open Homepage")));
|
|
15
|
+
}
|
|
16
|
+
exports.Forbidden = Forbidden;
|
|
17
|
+
const Wrapper = styled_components_1.default.div `
|
|
18
|
+
margin: 25px auto;
|
|
19
|
+
font-family: var(--page-403-font-family);
|
|
20
|
+
text-align: center;
|
|
21
|
+
`;
|
|
22
|
+
const Header = styled_components_1.default.div `
|
|
23
|
+
color: var(--page-403-header-text-color);
|
|
24
|
+
margin: var(--page-403-header-margin);
|
|
25
|
+
font-size: var(--page-403-header-font-size);
|
|
26
|
+
line-height: var(--page-403-header-line-height);
|
|
27
|
+
font-weight: var(--page-403-header-font-weight);
|
|
28
|
+
`;
|
|
29
|
+
const Description = styled_components_1.default.div `
|
|
30
|
+
color: var(--page-403-description-text-color);
|
|
31
|
+
margin: var(--page-403-description-margin);
|
|
32
|
+
font-size: var(--page-403-description-font-size);
|
|
33
|
+
line-height: var(--page-403-description-line-height);
|
|
34
|
+
font-weight: var(--page-403-description-font-weight);
|
|
35
|
+
`;
|
|
36
|
+
const HomeButton = (0, styled_components_1.default)(Button_1.Button) `
|
|
37
|
+
margin-top: var(--page-403-button-margin);
|
|
38
|
+
`;
|
|
39
|
+
//# sourceMappingURL=Forbidden.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
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.NotFound = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const Button_1 = require("../Button");
|
|
10
|
+
function NotFound() {
|
|
11
|
+
return (react_1.default.createElement(Wrapper, { "data-component-name": "Pages/NotFound" },
|
|
12
|
+
react_1.default.createElement(Header, null, "404"),
|
|
13
|
+
react_1.default.createElement(Description, null, "It looks like you're lost"),
|
|
14
|
+
react_1.default.createElement(HomeButton, { color: "primary", size: "large", to: "/" }, "Open Homepage")));
|
|
15
|
+
}
|
|
16
|
+
exports.NotFound = NotFound;
|
|
17
|
+
const Wrapper = styled_components_1.default.div `
|
|
18
|
+
margin: 25px auto;
|
|
19
|
+
font-family: var(--page-404-font-family);
|
|
20
|
+
text-align: center;
|
|
21
|
+
`;
|
|
22
|
+
const Header = styled_components_1.default.div `
|
|
23
|
+
color: var(--page-404-header-text-color);
|
|
24
|
+
margin: var(--page-404-header-margin);
|
|
25
|
+
font-size: var(--page-404-header-font-size);
|
|
26
|
+
line-height: var(--page-404-header-line-height);
|
|
27
|
+
font-weight: var(--page-404-header-font-weight);
|
|
28
|
+
`;
|
|
29
|
+
const Description = styled_components_1.default.div `
|
|
30
|
+
color: var(--page-404-description-text-color);
|
|
31
|
+
margin: var(--page-404-description-margin);
|
|
32
|
+
font-size: var(--page-404-description-font-size);
|
|
33
|
+
line-height: var(--page-404-description-line-height);
|
|
34
|
+
font-weight: var(--page-404-description-font-weight);
|
|
35
|
+
`;
|
|
36
|
+
const HomeButton = (0, styled_components_1.default)(Button_1.Button) `
|
|
37
|
+
margin-top: var(--page-404-button-margin);
|
|
38
|
+
`;
|
|
39
|
+
//# sourceMappingURL=NotFound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../Pages/NotFound';
|
|
@@ -0,0 +1,18 @@
|
|
|
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("../Pages/NotFound"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
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.LoginLink = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
10
|
+
function LoginLink({ href }) {
|
|
11
|
+
const { userProfile } = (0, useThemeConfig_1.useThemeConfig)();
|
|
12
|
+
return react_1.default.createElement(StyledLink, { href: href }, (userProfile === null || userProfile === void 0 ? void 0 : userProfile.loginLabel) || 'Login');
|
|
13
|
+
}
|
|
14
|
+
exports.LoginLink = LoginLink;
|
|
15
|
+
const StyledLink = styled_components_1.default.a.attrs(() => ({
|
|
16
|
+
'data-component-name': 'Profile/LoginLink',
|
|
17
|
+
})) `
|
|
18
|
+
display: inline-block;
|
|
19
|
+
color: var(--navbar-text-color);
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
padding: 0 var(--navbar-item-padding-horizontal);
|
|
22
|
+
text-align: center;
|
|
23
|
+
line-height: 1;
|
|
24
|
+
font-size: var(--navbar-item-font-size);
|
|
25
|
+
font-weight: var(--navbar-item-font-weight);
|
|
26
|
+
&:hover {
|
|
27
|
+
color: var(--navbar-item-hover-text-color);
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
//# sourceMappingURL=LoginLink.js.map
|
package/lib/Profile/Profile.js
CHANGED
|
@@ -42,7 +42,9 @@ function ProfileComponent({ name, imageUrl, onClick, color }) {
|
|
|
42
42
|
react_1.default.createElement("span", null, avatarLetters))));
|
|
43
43
|
}
|
|
44
44
|
exports.Profile = (0, react_1.memo)(ProfileComponent);
|
|
45
|
-
const ProfileWrapper = styled_components_1.default.div
|
|
45
|
+
const ProfileWrapper = styled_components_1.default.div.attrs(() => ({
|
|
46
|
+
'data-component-name': 'Profile/Profile',
|
|
47
|
+
})) `
|
|
46
48
|
display: flex;
|
|
47
49
|
align-items: center;
|
|
48
50
|
cursor: pointer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface UserProfileProps {
|
|
3
|
+
userInfo: {
|
|
4
|
+
isAuthenticated: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
picture: string;
|
|
7
|
+
logoutDisabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
handleLogout: (logoutRedirect?: string) => void;
|
|
10
|
+
hasDeveloperOnboarding?: boolean;
|
|
11
|
+
hasApiLogs?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function UserProfile({ userInfo, handleLogout, hasDeveloperOnboarding, hasApiLogs, }: UserProfileProps): JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.UserProfile = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const Link_1 = require("../mocks/Link");
|
|
33
|
+
const Profile_1 = require("../Profile/Profile");
|
|
34
|
+
const Tooltip_1 = require("../Tooltip/Tooltip");
|
|
35
|
+
const useThemeConfig_1 = require("../hooks/useThemeConfig");
|
|
36
|
+
function UserProfile({ userInfo, handleLogout, hasDeveloperOnboarding = false, hasApiLogs = false, }) {
|
|
37
|
+
const [isOpened, setIsOpened] = (0, react_1.useState)(false);
|
|
38
|
+
const { userProfile: userProfileSettings } = (0, useThemeConfig_1.useThemeConfig)();
|
|
39
|
+
const logoutRedirect = (userProfileSettings === null || userProfileSettings === void 0 ? void 0 : userProfileSettings.logoutRedirect) || '/';
|
|
40
|
+
return (react_1.default.createElement(StyledTooltip, { isOpen: isOpened, withArrow: false, className: "copy-button", placement: "bottom", width: "100%", tip: react_1.default.createElement(StyledUl, null,
|
|
41
|
+
hasDeveloperOnboarding ? (react_1.default.createElement(Link_1.Link, { to: "/apps" },
|
|
42
|
+
react_1.default.createElement(StyledLi, null, "My Apps"))) : null,
|
|
43
|
+
hasApiLogs ? (react_1.default.createElement(Link_1.Link, { to: "/api-logs" },
|
|
44
|
+
react_1.default.createElement(StyledLi, null, "API logs"))) : null,
|
|
45
|
+
react_1.default.createElement(StyledLi, { onClick: () => handleLogout(logoutRedirect) }, (userProfileSettings === null || userProfileSettings === void 0 ? void 0 : userProfileSettings.logoutLabel) || 'Log out')) },
|
|
46
|
+
react_1.default.createElement(Profile_1.Profile, { name: userInfo.name, imageUrl: userInfo.picture, onClick: userInfo.logoutDisabled ? undefined : () => setIsOpened(!isOpened) })));
|
|
47
|
+
}
|
|
48
|
+
exports.UserProfile = UserProfile;
|
|
49
|
+
const StyledTooltip = (0, styled_components_1.default)(Tooltip_1.Tooltip) `
|
|
50
|
+
> span {
|
|
51
|
+
padding: 0;
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const StyledUl = styled_components_1.default.ul `
|
|
55
|
+
margin: 0;
|
|
56
|
+
padding: 0;
|
|
57
|
+
list-style: none;
|
|
58
|
+
text-align: left;
|
|
59
|
+
background-color: var(--search-modal-background);
|
|
60
|
+
color: var(--search-modal-text-color);
|
|
61
|
+
min-width: 100px;
|
|
62
|
+
a {
|
|
63
|
+
text-decoration: none;
|
|
64
|
+
&:hover {
|
|
65
|
+
color: inherit;
|
|
66
|
+
}
|
|
67
|
+
&:visited {
|
|
68
|
+
color: inherit;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
const StyledLi = styled_components_1.default.li `
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
font-size: 16px;
|
|
75
|
+
list-style: none;
|
|
76
|
+
padding: 15px 20px;
|
|
77
|
+
transition: background-color 0.25s ease 0s;
|
|
78
|
+
&:hover {
|
|
79
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
//# sourceMappingURL=UserProfile.js.map
|
package/lib/Profile/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { Profile } from './Profile';
|
|
2
2
|
export type { ProfileProps } from './Profile';
|
|
3
|
+
export { LoginLink } from './LoginLink';
|
|
4
|
+
export type { LoginLinkProps } from './LoginLink';
|
|
5
|
+
export { UserProfile } from './UserProfile';
|
|
6
|
+
export type { UserProfileProps } from './UserProfile';
|
package/lib/Profile/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Profile = void 0;
|
|
3
|
+
exports.UserProfile = exports.LoginLink = exports.Profile = void 0;
|
|
4
4
|
var Profile_1 = require("./Profile");
|
|
5
5
|
Object.defineProperty(exports, "Profile", { enumerable: true, get: function () { return Profile_1.Profile; } });
|
|
6
|
+
var LoginLink_1 = require("./LoginLink");
|
|
7
|
+
Object.defineProperty(exports, "LoginLink", { enumerable: true, get: function () { return LoginLink_1.LoginLink; } });
|
|
8
|
+
var UserProfile_1 = require("./UserProfile");
|
|
9
|
+
Object.defineProperty(exports, "UserProfile", { enumerable: true, get: function () { return UserProfile_1.UserProfile; } });
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
import type { ActiveItem } from '../mocks/types';
|
|
3
4
|
interface AutocompleteProps<T> {
|
|
@@ -8,6 +9,8 @@ interface AutocompleteProps<T> {
|
|
|
8
9
|
change(value: string): void;
|
|
9
10
|
select(item: T): void;
|
|
10
11
|
children?(isOpen: boolean, close: () => void): ReactNode;
|
|
12
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
|
13
|
+
keyShortcuts?: string[];
|
|
11
14
|
}
|
|
12
|
-
export declare function Autocomplete<T>({ placeholder, value, items, change, select, renderItem, children, }: AutocompleteProps<T>): JSX.Element;
|
|
15
|
+
export declare function Autocomplete<T>({ placeholder, value, items, change, select, renderItem, children, keyShortcuts, }: AutocompleteProps<T>): JSX.Element;
|
|
13
16
|
export {};
|
|
@@ -30,12 +30,26 @@ exports.Autocomplete = void 0;
|
|
|
30
30
|
const react_1 = __importStar(require("react"));
|
|
31
31
|
const react_router_dom_1 = require("react-router-dom");
|
|
32
32
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const hotkeys_js_1 = __importDefault(require("hotkeys-js"));
|
|
33
34
|
const Input_1 = require("../Search/Input");
|
|
34
35
|
const Popover_1 = require("../Search/Popover");
|
|
35
|
-
|
|
36
|
+
const ShortcutKey_1 = require("../Search/ShortcutKey");
|
|
37
|
+
function Autocomplete({ placeholder, value, items, change, select, renderItem, children, keyShortcuts, }) {
|
|
36
38
|
const location = (0, react_router_dom_1.useLocation)();
|
|
37
39
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
38
40
|
const [activeIdx, setActiveIdx] = (0, react_1.useState)(-1);
|
|
41
|
+
const refInput = (0, react_1.useRef)(null);
|
|
42
|
+
const hotkeysKeys = keyShortcuts === null || keyShortcuts === void 0 ? void 0 : keyShortcuts.join(',');
|
|
43
|
+
(0, react_1.useEffect)(() => {
|
|
44
|
+
if (hotkeysKeys) {
|
|
45
|
+
(0, hotkeys_js_1.default)(hotkeysKeys, (ev) => {
|
|
46
|
+
var _a;
|
|
47
|
+
(_a = refInput.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
48
|
+
ev.preventDefault();
|
|
49
|
+
});
|
|
50
|
+
return () => hotkeys_js_1.default.unbind(hotkeysKeys);
|
|
51
|
+
}
|
|
52
|
+
}, [hotkeysKeys]);
|
|
39
53
|
const open = () => setIsOpen(true);
|
|
40
54
|
const close = () => {
|
|
41
55
|
setIsOpen(false);
|
|
@@ -66,6 +80,7 @@ function Autocomplete({ placeholder, value, items, change, select, renderItem, c
|
|
|
66
80
|
break;
|
|
67
81
|
case 'Enter':
|
|
68
82
|
if (activeIdx > -1) {
|
|
83
|
+
reset();
|
|
69
84
|
select(items[activeIdx]);
|
|
70
85
|
}
|
|
71
86
|
break;
|
|
@@ -78,9 +93,10 @@ function Autocomplete({ placeholder, value, items, change, select, renderItem, c
|
|
|
78
93
|
(0, react_1.useEffect)(close, [location]);
|
|
79
94
|
return (react_1.default.createElement(Wrapper, { "data-component-name": "Search/Autocomplete" },
|
|
80
95
|
isOpen ? react_1.default.createElement(Overlay, { onClick: close }) : null,
|
|
81
|
-
react_1.default.createElement(AutocompleteBox, { onKeyDown: onKeydown },
|
|
82
|
-
react_1.default.createElement(Input_1.FormInput, { value: value, placeholder: placeholder, onChange: onChange, onFocus: open, onClick: stopPropagation }), children === null || children === void 0 ? void 0 :
|
|
96
|
+
react_1.default.createElement(AutocompleteBox, { onKeyDown: onKeydown }, children === null || children === void 0 ? void 0 :
|
|
83
97
|
children(isOpen, reset),
|
|
98
|
+
react_1.default.createElement(Input_1.FormInput, { value: value, placeholder: placeholder, onChange: onChange, onFocus: open, onClick: stopPropagation, ref: refInput }),
|
|
99
|
+
!isOpen && react_1.default.createElement(ShortcutKey_1.ShortcutKey, { keyShortcuts: keyShortcuts }),
|
|
84
100
|
isOpen && value ? (react_1.default.createElement(Popover_1.Popover, null, items.length ? items.map(mapItem) : react_1.default.createElement(Message, null, "No results"))) : null)));
|
|
85
101
|
}
|
|
86
102
|
exports.Autocomplete = Autocomplete;
|
package/lib/Search/ClearIcon.js
CHANGED
package/lib/Search/Input.js
CHANGED
|
@@ -8,7 +8,7 @@ const styled_components_1 = __importDefault(require("styled-components"));
|
|
|
8
8
|
exports.FormInput = styled_components_1.default.input.attrs(() => ({
|
|
9
9
|
'data-component-name': 'Search/Input',
|
|
10
10
|
})) `
|
|
11
|
-
padding: 1em 2.5em 1em
|
|
11
|
+
padding: 1em 2.5em 1em 2.5em;
|
|
12
12
|
background-color: var(--search-input-background-color);
|
|
13
13
|
border-radius: var(--search-input-border-radius);
|
|
14
14
|
border: var(--search-input-border);
|
package/lib/Search/Search.js
CHANGED
|
@@ -35,12 +35,17 @@ const Autocomplete_1 = require("../Search/Autocomplete");
|
|
|
35
35
|
const ClearIcon_1 = require("../Search/ClearIcon");
|
|
36
36
|
const SearchIcon_1 = require("../Search/SearchIcon");
|
|
37
37
|
const SearchItem_1 = require("../Search/SearchItem");
|
|
38
|
+
const hooks_1 = require("../hooks");
|
|
38
39
|
function Search() {
|
|
39
40
|
const history = (0, usePreloadHistory_1.usePreloadHistory)();
|
|
40
41
|
const { query, setQuery, items } = (0, search_1.useFuseSearch)();
|
|
42
|
+
const themeSettings = (0, hooks_1.useThemeConfig)();
|
|
41
43
|
// TODO: ask somebody about typings
|
|
42
44
|
const navigate = (item) => history.push(item.url);
|
|
43
|
-
const renderAutocomplete = () =>
|
|
45
|
+
const renderAutocomplete = () => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return (React.createElement(Autocomplete_1.Autocomplete, { items: items, value: query, change: setQuery, select: navigate, placeholder: "Search the docs", keyShortcuts: (_b = (_a = themeSettings === null || themeSettings === void 0 ? void 0 : themeSettings.search) === null || _a === void 0 ? void 0 : _a.shortcuts) !== null && _b !== void 0 ? _b : ['/'], renderItem: (item) => React.createElement(SearchItem_1.SearchItem, { key: item.id, item: item }) }, (isOpen, reset) => (isOpen ? React.createElement(ClearIcon_1.ClearIcon, { onClick: reset }) : React.createElement(SearchIcon_1.SearchIcon, null))));
|
|
48
|
+
};
|
|
44
49
|
return React.createElement(Wrapper, { "data-component-name": "Search/Search" }, renderAutocomplete());
|
|
45
50
|
}
|
|
46
51
|
exports.Search = Search;
|
package/lib/Search/SearchIcon.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ShortcutKeyProps {
|
|
3
|
+
keyShortcuts?: string | string[];
|
|
4
|
+
}
|
|
5
|
+
export declare function ShortcutKey(props: ShortcutKeyProps): JSX.Element;
|
|
6
|
+
export declare const Wrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
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.Wrapper = exports.ShortcutKey = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
function ShortcutKey(props) {
|
|
10
|
+
let mainShortcutKey = null;
|
|
11
|
+
if (props.keyShortcuts) {
|
|
12
|
+
if (Array.isArray(props.keyShortcuts)) {
|
|
13
|
+
mainShortcutKey = props.keyShortcuts[0];
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
mainShortcutKey = props.keyShortcuts;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
mainShortcutKey = mainShortcutKey === null || mainShortcutKey === void 0 ? void 0 : mainShortcutKey.toUpperCase();
|
|
20
|
+
return react_1.default.createElement(exports.Wrapper, null, mainShortcutKey);
|
|
21
|
+
}
|
|
22
|
+
exports.ShortcutKey = ShortcutKey;
|
|
23
|
+
exports.Wrapper = styled_components_1.default.div `
|
|
24
|
+
position: absolute;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
font-size: 0.8em;
|
|
27
|
+
height: 2em;
|
|
28
|
+
line-height: 2em;
|
|
29
|
+
right: 1em;
|
|
30
|
+
fill: var(--search-input-text-color);
|
|
31
|
+
color: var(--search-input-placeholder-color);
|
|
32
|
+
opacity: 0.5;
|
|
33
|
+
z-index: -1;
|
|
34
|
+
`;
|
|
35
|
+
//# sourceMappingURL=ShortcutKey.js.map
|
package/lib/config.d.ts
CHANGED
|
@@ -228,16 +228,33 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
|
|
|
228
228
|
title?: string | undefined;
|
|
229
229
|
href: string;
|
|
230
230
|
}>, "many">>;
|
|
231
|
+
feedback: z.ZodOptional<z.ZodDefault<z.ZodObject<z.extendShape<{
|
|
232
|
+
type: z.ZodDefault<z.ZodString>;
|
|
233
|
+
settings: z.ZodOptional<z.ZodString>;
|
|
234
|
+
}, {
|
|
235
|
+
hide: z.ZodOptional<z.ZodBoolean>;
|
|
236
|
+
}>, "strict", z.ZodTypeAny, {
|
|
237
|
+
hide?: boolean | undefined;
|
|
238
|
+
settings?: string | undefined;
|
|
239
|
+
type: string;
|
|
240
|
+
}, {
|
|
241
|
+
type?: string | undefined;
|
|
242
|
+
hide?: boolean | undefined;
|
|
243
|
+
settings?: string | undefined;
|
|
244
|
+
}>>>;
|
|
231
245
|
search: z.ZodOptional<z.ZodDefault<z.ZodObject<z.extendShape<{
|
|
232
246
|
placement: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
247
|
+
shortcuts: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
|
|
233
248
|
}, {
|
|
234
249
|
hide: z.ZodOptional<z.ZodBoolean>;
|
|
235
250
|
}>, "strict", z.ZodTypeAny, {
|
|
236
251
|
hide?: boolean | undefined;
|
|
237
252
|
placement?: string | undefined;
|
|
253
|
+
shortcuts?: string[] | undefined;
|
|
238
254
|
}, {
|
|
239
255
|
hide?: boolean | undefined;
|
|
240
256
|
placement?: string | undefined;
|
|
257
|
+
shortcuts?: string[] | undefined;
|
|
241
258
|
}>>>;
|
|
242
259
|
colorMode: z.ZodDefault<z.ZodOptional<z.ZodObject<z.extendShape<{
|
|
243
260
|
ignoreDetection: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -415,6 +432,23 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
|
|
|
415
432
|
}>>>;
|
|
416
433
|
openapi: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
|
|
417
434
|
graphql: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, {}, {}>>;
|
|
435
|
+
userProfile: z.ZodDefault<z.ZodOptional<z.ZodObject<z.extendShape<{
|
|
436
|
+
loginLabel: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
437
|
+
logoutLabel: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
438
|
+
logoutRedirect: z.ZodOptional<z.ZodDefault<z.ZodString>>;
|
|
439
|
+
}, {
|
|
440
|
+
hide: z.ZodOptional<z.ZodBoolean>;
|
|
441
|
+
}>, "strip", z.ZodTypeAny, {
|
|
442
|
+
hide?: boolean | undefined;
|
|
443
|
+
loginLabel?: string | undefined;
|
|
444
|
+
logoutLabel?: string | undefined;
|
|
445
|
+
logoutRedirect?: string | undefined;
|
|
446
|
+
}, {
|
|
447
|
+
hide?: boolean | undefined;
|
|
448
|
+
loginLabel?: string | undefined;
|
|
449
|
+
logoutLabel?: string | undefined;
|
|
450
|
+
logoutRedirect?: string | undefined;
|
|
451
|
+
}>>>;
|
|
418
452
|
}, "passthrough", z.ZodTypeAny, {
|
|
419
453
|
imports?: string[] | undefined;
|
|
420
454
|
logo?: {
|
|
@@ -480,9 +514,15 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
|
|
|
480
514
|
title?: string | undefined;
|
|
481
515
|
href: string;
|
|
482
516
|
}[] | undefined;
|
|
517
|
+
feedback?: {
|
|
518
|
+
hide?: boolean | undefined;
|
|
519
|
+
settings?: string | undefined;
|
|
520
|
+
type: string;
|
|
521
|
+
} | undefined;
|
|
483
522
|
search?: {
|
|
484
523
|
hide?: boolean | undefined;
|
|
485
524
|
placement?: string | undefined;
|
|
525
|
+
shortcuts?: string[] | undefined;
|
|
486
526
|
} | undefined;
|
|
487
527
|
markdown?: {
|
|
488
528
|
frontMatterKeysToResolve?: string[] | undefined;
|
|
@@ -527,6 +567,12 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
|
|
|
527
567
|
text: string;
|
|
528
568
|
};
|
|
529
569
|
};
|
|
570
|
+
userProfile: {
|
|
571
|
+
hide?: boolean | undefined;
|
|
572
|
+
loginLabel?: string | undefined;
|
|
573
|
+
logoutLabel?: string | undefined;
|
|
574
|
+
logoutRedirect?: string | undefined;
|
|
575
|
+
};
|
|
530
576
|
}, {
|
|
531
577
|
imports?: string[] | undefined;
|
|
532
578
|
logo?: {
|
|
@@ -592,9 +638,15 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
|
|
|
592
638
|
title?: string | undefined;
|
|
593
639
|
href: string;
|
|
594
640
|
}[] | undefined;
|
|
641
|
+
feedback?: {
|
|
642
|
+
type?: string | undefined;
|
|
643
|
+
hide?: boolean | undefined;
|
|
644
|
+
settings?: string | undefined;
|
|
645
|
+
} | undefined;
|
|
595
646
|
search?: {
|
|
596
647
|
hide?: boolean | undefined;
|
|
597
648
|
placement?: string | undefined;
|
|
649
|
+
shortcuts?: string[] | undefined;
|
|
598
650
|
} | undefined;
|
|
599
651
|
colorMode?: {
|
|
600
652
|
hide?: boolean | undefined;
|
|
@@ -639,6 +691,12 @@ export declare const ThemeConfig: z.ZodDefault<z.ZodObject<{
|
|
|
639
691
|
} | undefined;
|
|
640
692
|
openapi?: {} | undefined;
|
|
641
693
|
graphql?: {} | undefined;
|
|
694
|
+
userProfile?: {
|
|
695
|
+
hide?: boolean | undefined;
|
|
696
|
+
loginLabel?: string | undefined;
|
|
697
|
+
logoutLabel?: string | undefined;
|
|
698
|
+
logoutRedirect?: string | undefined;
|
|
699
|
+
} | undefined;
|
|
642
700
|
}>>;
|
|
643
701
|
export type ThemeConfig = z.infer<typeof ThemeConfig>;
|
|
644
702
|
export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 'scripts'> & {
|
|
@@ -652,4 +710,7 @@ export type ThemeUIConfig = Omit<ThemeConfig, 'navbar' | 'footer' | 'links' | 's
|
|
|
652
710
|
}[];
|
|
653
711
|
devLogin?: boolean;
|
|
654
712
|
};
|
|
713
|
+
search?: {
|
|
714
|
+
shortcuts?: string[];
|
|
715
|
+
};
|
|
655
716
|
};
|
package/lib/config.js
CHANGED
|
@@ -74,9 +74,19 @@ exports.ThemeConfig = zod_1.z
|
|
|
74
74
|
})
|
|
75
75
|
.optional(),
|
|
76
76
|
links: zod_1.z.array(LinksConfig).optional(),
|
|
77
|
+
feedback: zod_1.z
|
|
78
|
+
.object({
|
|
79
|
+
type: zod_1.z.string().default('sentiment'),
|
|
80
|
+
settings: zod_1.z.string().optional(),
|
|
81
|
+
})
|
|
82
|
+
.extend(HideConfig.shape)
|
|
83
|
+
.strict()
|
|
84
|
+
.default({})
|
|
85
|
+
.optional(),
|
|
77
86
|
search: zod_1.z
|
|
78
87
|
.object({
|
|
79
88
|
placement: zod_1.z.string().default('navbar').optional(),
|
|
89
|
+
shortcuts: zod_1.z.array(zod_1.z.string()).default(['/']).optional(),
|
|
80
90
|
})
|
|
81
91
|
.extend(HideConfig.shape)
|
|
82
92
|
.strict()
|
|
@@ -151,6 +161,15 @@ exports.ThemeConfig = zod_1.z
|
|
|
151
161
|
.optional(),
|
|
152
162
|
openapi: zod_1.z.object({}).passthrough().optional(),
|
|
153
163
|
graphql: zod_1.z.object({}).passthrough().optional(),
|
|
164
|
+
userProfile: zod_1.z
|
|
165
|
+
.object({
|
|
166
|
+
loginLabel: zod_1.z.string().default('Login').optional(),
|
|
167
|
+
logoutLabel: zod_1.z.string().default('Logout').optional(),
|
|
168
|
+
logoutRedirect: zod_1.z.string().default('/').optional(),
|
|
169
|
+
})
|
|
170
|
+
.extend(HideConfig.shape)
|
|
171
|
+
.optional()
|
|
172
|
+
.default({}),
|
|
154
173
|
})
|
|
155
174
|
.passthrough()
|
|
156
175
|
.default({});
|