@redocly/theme 0.13.1 → 0.14.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/components/Navbar/MobileNavbarMenu.d.ts +2 -3
- package/lib/components/Navbar/MobileNavbarMenu.js +4 -16
- package/lib/components/Navbar/Navbar.js +1 -1
- package/lib/components/Search/CancelSearch.d.ts +4 -0
- package/lib/components/Search/CancelSearch.js +63 -0
- package/lib/components/Search/ClearIcon.js +0 -1
- package/lib/components/Search/ClockBackwardsIcon.d.ts +5 -0
- package/lib/components/Search/ClockBackwardsIcon.js +26 -0
- package/lib/components/Search/Input.js +1 -5
- package/lib/components/Search/InputWrapper.d.ts +10 -0
- package/lib/components/Search/InputWrapper.js +86 -0
- package/lib/components/Search/MobileSearchTrigger.d.ts +4 -0
- package/lib/components/Search/MobileSearchTrigger.js +51 -0
- package/lib/components/Search/RecentSearches.d.ts +4 -0
- package/lib/components/Search/RecentSearches.js +129 -0
- package/lib/components/Search/Search.js +28 -26
- package/lib/components/Search/SearchDialog.d.ts +4 -0
- package/lib/components/Search/SearchDialog.js +136 -0
- package/lib/components/Search/SearchIcon.js +0 -2
- package/lib/components/Search/SearchItem.js +31 -7
- package/lib/components/Search/SearchTrigger.d.ts +4 -0
- package/lib/components/Search/SearchTrigger.js +80 -0
- package/lib/components/Search/Shortcut.d.ts +5 -0
- package/lib/components/Search/Shortcut.js +51 -0
- package/lib/components/Search/ShortcutKey.js +2 -7
- package/lib/components/Search/SuggestedPages.d.ts +2 -0
- package/lib/components/Search/SuggestedPages.js +107 -0
- package/lib/components/Search/index.d.ts +8 -2
- package/lib/components/Search/index.js +8 -2
- package/lib/components/Search/utils.js +2 -2
- package/lib/components/Tabs/Tab.d.ts +2 -1
- package/lib/components/Tabs/Tab.js +2 -2
- package/lib/components/Tabs/Tabs.d.ts +1 -0
- package/lib/components/Tabs/Tabs.js +1 -1
- package/lib/config.d.ts +19 -0
- package/lib/config.js +12 -0
- package/lib/globalStyle.js +22 -11
- package/lib/hooks/useDialogHotKeys.d.ts +2 -0
- package/lib/hooks/useDialogHotKeys.js +45 -0
- package/lib/icons/SpinnerIcon/SpinnerIcon.js +0 -2
- package/lib/mocks/search.d.ts +10 -1
- package/lib/mocks/search.js +19 -1
- package/lib/types/portal/src/shared/types/activeItem.d.ts +1 -1
- package/lib/ui/darkColors.js +6 -1
- package/package.json +3 -3
- package/src/components/Navbar/MobileNavbarMenu.tsx +0 -14
- package/src/components/Navbar/Navbar.tsx +1 -5
- package/src/components/Search/CancelSearch.tsx +42 -0
- package/src/components/Search/ClearIcon.tsx +0 -1
- package/src/components/Search/ClockBackwardsIcon.tsx +26 -0
- package/src/components/Search/Input.tsx +1 -5
- package/src/components/Search/InputWrapper.tsx +93 -0
- package/src/components/Search/MobileSearchTrigger.tsx +27 -0
- package/src/components/Search/RecentSearches.tsx +127 -0
- package/src/components/Search/Search.tsx +35 -37
- package/src/components/Search/SearchDialog.tsx +162 -0
- package/src/components/Search/SearchIcon.tsx +0 -2
- package/src/components/Search/SearchItem.tsx +59 -10
- package/src/components/Search/SearchTrigger.tsx +62 -0
- package/src/components/Search/Shortcut.tsx +32 -0
- package/src/components/Search/ShortcutKey.tsx +2 -7
- package/src/components/Search/SuggestedPages.tsx +101 -0
- package/src/components/Search/index.ts +8 -2
- package/src/components/Search/utils.tsx +2 -2
- package/src/components/Tabs/Tab.tsx +3 -1
- package/src/components/Tabs/Tabs.tsx +2 -2
- package/src/config.ts +15 -0
- package/src/globalStyle.ts +22 -11
- package/src/hooks/useDialogHotKeys.ts +48 -0
- package/src/icons/SpinnerIcon/SpinnerIcon.tsx +0 -2
- package/src/mocks/search.ts +19 -1
- package/src/types/portal/src/shared/types/activeItem.ts +1 -1
- package/src/ui/darkColors.tsx +6 -1
- package/lib/components/Search/Autocomplete.d.ts +0 -16
- package/lib/components/Search/Autocomplete.js +0 -132
- package/lib/components/Search/Parameters.d.ts +0 -7
- package/lib/components/Search/Parameters.js +0 -55
- package/src/components/Search/Autocomplete.tsx +0 -162
- package/src/components/Search/Parameters.tsx +0 -61
|
@@ -0,0 +1,136 @@
|
|
|
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.SearchDialog = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const search_1 = require("../../mocks/search");
|
|
33
|
+
const InputWrapper_1 = require("../../components/Search/InputWrapper");
|
|
34
|
+
const SearchItem_1 = require("../../components/Search/SearchItem");
|
|
35
|
+
const hooks_1 = require("../../mocks/hooks");
|
|
36
|
+
const Shortcut_1 = require("../../components/Search/Shortcut");
|
|
37
|
+
const RecentSearches_1 = require("../../components/Search/RecentSearches");
|
|
38
|
+
const SuggestedPages_1 = require("../../components/Search/SuggestedPages");
|
|
39
|
+
const CancelSearch_1 = require("../../components/Search/CancelSearch");
|
|
40
|
+
const useDialogHotKeys_1 = require("../../hooks/useDialogHotKeys");
|
|
41
|
+
const SearchDialog = ({ onClose }) => {
|
|
42
|
+
const { query, setQuery, items, isLoading } = (0, search_1.useFuseSearch)();
|
|
43
|
+
const modalRef = (0, react_1.useRef)(null);
|
|
44
|
+
const { translate } = (0, hooks_1.useTranslate)();
|
|
45
|
+
(0, useDialogHotKeys_1.useDialogHotKeys)(modalRef, onClose);
|
|
46
|
+
const handleOverlayClick = (event) => {
|
|
47
|
+
var _a;
|
|
48
|
+
const target = event.target;
|
|
49
|
+
if (typeof target.className !== 'string')
|
|
50
|
+
return;
|
|
51
|
+
if ((_a = target.className) === null || _a === void 0 ? void 0 : _a.includes(' overlay')) {
|
|
52
|
+
onClose();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const translationKeys = {
|
|
56
|
+
noResults: 'theme.search.noResults',
|
|
57
|
+
navigate: 'theme.search.keys.navigate',
|
|
58
|
+
select: 'theme.search.keys.select',
|
|
59
|
+
exit: 'theme.search.keys.exit',
|
|
60
|
+
};
|
|
61
|
+
const mapItem = (item) => {
|
|
62
|
+
return react_1.default.createElement(SearchItem_1.SearchItem, { key: item.id, item: item });
|
|
63
|
+
};
|
|
64
|
+
return (react_1.default.createElement(Overlay, { "data-component-name": "Search/SearchDialog", ref: modalRef, onClick: handleOverlayClick, className: "overlay" },
|
|
65
|
+
react_1.default.createElement(Container, null,
|
|
66
|
+
react_1.default.createElement(TopContainer, null,
|
|
67
|
+
react_1.default.createElement(InputWrapper_1.InputWrapper, { value: query, change: setQuery, placeholder: translate('theme.search.label', 'Search all products...'), isLoading: isLoading })),
|
|
68
|
+
react_1.default.createElement(Results, null, items !== null ? (items.length ? (items.map(mapItem)) : (react_1.default.createElement(Message, { "data-translation-key": translationKeys.noResults }, translate(translationKeys.noResults, 'No results')))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
69
|
+
react_1.default.createElement(RecentSearches_1.RecentSearches, { onSelect: setQuery }),
|
|
70
|
+
react_1.default.createElement(SuggestedPages_1.SuggestedPages, null)))),
|
|
71
|
+
react_1.default.createElement(BottomContainer, null,
|
|
72
|
+
react_1.default.createElement(Shortcuts, null,
|
|
73
|
+
react_1.default.createElement(Shortcut_1.Shortcut, { "data-translation-key": translationKeys.navigate, combination: "Tab", text: translate(translationKeys.navigate, 'to navigate') }),
|
|
74
|
+
react_1.default.createElement(Shortcut_1.Shortcut, { "data-translation-key": translationKeys.select, combination: "\u21B5", text: translate(translationKeys.select, 'to select') }),
|
|
75
|
+
react_1.default.createElement(Shortcut_1.Shortcut, { "data-translation-key": translationKeys.exit, combination: "Esc", text: translate(translationKeys.exit, 'to exit') })),
|
|
76
|
+
react_1.default.createElement(CancelSearch_1.CancelSearch, { onClick: onClose })))));
|
|
77
|
+
};
|
|
78
|
+
exports.SearchDialog = SearchDialog;
|
|
79
|
+
const Overlay = styled_components_1.default.div `
|
|
80
|
+
font-family: var(--font-family-base);
|
|
81
|
+
position: fixed;
|
|
82
|
+
top: 0;
|
|
83
|
+
left: 0;
|
|
84
|
+
width: 100vw;
|
|
85
|
+
height: 100vh;
|
|
86
|
+
background: var(--modal-overlay-background-color);
|
|
87
|
+
z-index: 10000;
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: center;
|
|
90
|
+
justify-content: center;
|
|
91
|
+
|
|
92
|
+
& > * {
|
|
93
|
+
background: var(--modal-background-color);
|
|
94
|
+
box-shadow: var(--modal-box-shadow);
|
|
95
|
+
border-radius: 0;
|
|
96
|
+
width: 100vw;
|
|
97
|
+
height: 100vh;
|
|
98
|
+
|
|
99
|
+
${({ theme }) => theme.mediaQueries.small} {
|
|
100
|
+
border-radius: 8px;
|
|
101
|
+
width: 600px;
|
|
102
|
+
height: auto;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
`;
|
|
106
|
+
const Container = styled_components_1.default.div `
|
|
107
|
+
display: flex;
|
|
108
|
+
flex-direction: column;
|
|
109
|
+
justify-content: space-between;
|
|
110
|
+
`;
|
|
111
|
+
const Results = styled_components_1.default.div `
|
|
112
|
+
flex-grow: 1;
|
|
113
|
+
overflow-y: scroll;
|
|
114
|
+
|
|
115
|
+
${({ theme }) => theme.mediaQueries.small} {
|
|
116
|
+
height: 224px;
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
const BottomContainer = styled_components_1.default.footer ``;
|
|
120
|
+
const Shortcuts = styled_components_1.default.div `
|
|
121
|
+
display: none;
|
|
122
|
+
justify-content: flex-end;
|
|
123
|
+
align-items: center;
|
|
124
|
+
padding: 8px 16px 12px;
|
|
125
|
+
gap: 16px;
|
|
126
|
+
|
|
127
|
+
${({ theme }) => { var _a; return (_a = theme.mediaQueries) === null || _a === void 0 ? void 0 : _a.small; }} {
|
|
128
|
+
display: flex;
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
const Message = styled_components_1.default.div `
|
|
132
|
+
padding: 24px;
|
|
133
|
+
color: var(--search-item-title-text-color);
|
|
134
|
+
`;
|
|
135
|
+
const TopContainer = styled_components_1.default.header ``;
|
|
136
|
+
//# sourceMappingURL=SearchDialog.js.map
|
|
@@ -11,13 +11,11 @@ const Icon = (props) => (react_1.default.createElement("svg", Object.assign({ xm
|
|
|
11
11
|
exports.SearchIcon = (0, styled_components_1.default)(Icon).attrs(() => ({
|
|
12
12
|
'data-component-name': 'Search/SearchIcon',
|
|
13
13
|
})) `
|
|
14
|
-
position: absolute;
|
|
15
14
|
cursor: pointer;
|
|
16
15
|
width: 1em;
|
|
17
16
|
height: 1em;
|
|
18
17
|
left: 0.8em;
|
|
19
18
|
fill: var(--search-input-text-color);
|
|
20
|
-
z-index: -1;
|
|
21
19
|
|
|
22
20
|
${({ theme }) => theme.mediaQueries.medium} {
|
|
23
21
|
width: 1.2em;
|
|
@@ -31,7 +31,6 @@ const react_1 = __importStar(require("react"));
|
|
|
31
31
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
32
|
const OperationBadge_1 = require("../../components/OperationBadge");
|
|
33
33
|
const Link_1 = require("../../mocks/Link");
|
|
34
|
-
const Parameters_1 = require("../../components/Search/Parameters");
|
|
35
34
|
const utils_1 = require("../../components/Search/utils");
|
|
36
35
|
function SearchItem({ item }) {
|
|
37
36
|
var _a, _b;
|
|
@@ -42,18 +41,31 @@ function SearchItem({ item }) {
|
|
|
42
41
|
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
43
42
|
}
|
|
44
43
|
}, [item.active]);
|
|
45
|
-
|
|
44
|
+
const header = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
46
45
|
item.httpVerb ? (react_1.default.createElement(Operation, null,
|
|
47
46
|
react_1.default.createElement(OperationBadge_1.OperationBadge, { type: item.httpVerb }, item.httpVerb),
|
|
48
47
|
item.pathName ? (0, utils_1.highlight)(item.pathName) : null)) : null,
|
|
49
48
|
react_1.default.createElement(Title, null, (0, utils_1.highlight)(item.title)),
|
|
50
|
-
react_1.default.createElement(Description, null, (0, utils_1.highlight)(item.text))
|
|
51
|
-
|
|
49
|
+
Array.isArray(item.text) ? react_1.default.createElement(Description, null, (0, utils_1.highlight)(item.text)) : null));
|
|
50
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, ((_a = item.parameters) === null || _a === void 0 ? void 0 : _a.length) ? (react_1.default.createElement(react_1.default.Fragment, null, item.parameters.map((param, index) => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const path = `${param.place} → ${((_a = param.path) === null || _a === void 0 ? void 0 : _a.length) ? ((_b = param.path) === null || _b === void 0 ? void 0 : _b.join(' → ')) + ' → ' : ''}`;
|
|
53
|
+
return (react_1.default.createElement(SearchLink, { key: `${item.id}-${index}`, to: item.url, tabIndex: 0, innerRef: ref, "data-component-name": "Search/SearchItem" },
|
|
54
|
+
header,
|
|
55
|
+
react_1.default.createElement(Place, null,
|
|
56
|
+
react_1.default.createElement("div", null,
|
|
57
|
+
path,
|
|
58
|
+
(0, utils_1.highlight)(param.name)),
|
|
59
|
+
react_1.default.createElement("div", null, (0, utils_1.highlight)(param.description)))));
|
|
60
|
+
}))) : (react_1.default.createElement(SearchLink, { to: item.url, tabIndex: 0, innerRef: ref, "data-component-name": "Search/SearchItem" },
|
|
61
|
+
header,
|
|
62
|
+
react_1.default.createElement(Path, null, (_b = item.path) === null || _b === void 0 ? void 0 : _b.join(' → '))))));
|
|
52
63
|
}
|
|
53
64
|
exports.SearchItem = SearchItem;
|
|
54
65
|
const Title = styled_components_1.default.div `
|
|
55
|
-
font-weight: var(--font-weight-
|
|
66
|
+
font-weight: var(--font-weight-regular);
|
|
56
67
|
color: var(--search-item-title-text-color);
|
|
68
|
+
padding: 6px 0 2px 0;
|
|
57
69
|
overflow: hidden;
|
|
58
70
|
text-overflow: ellipsis;
|
|
59
71
|
line-height: var(--line-height-base);
|
|
@@ -79,8 +91,8 @@ const SearchLink = (0, styled_components_1.default)(Link_1.Link) `
|
|
|
79
91
|
`;
|
|
80
92
|
const Operation = styled_components_1.default.div `
|
|
81
93
|
font-weight: var(--font-weight-regular);
|
|
82
|
-
font-size: var(--font-size-
|
|
83
|
-
color: var(--search-item-
|
|
94
|
+
font-size: var(--font-size-base);
|
|
95
|
+
color: var(--search-item-path-text-color);
|
|
84
96
|
overflow: hidden;
|
|
85
97
|
text-overflow: ellipsis;
|
|
86
98
|
`;
|
|
@@ -95,4 +107,16 @@ const Path = styled_components_1.default.div `
|
|
|
95
107
|
text-overflow: ellipsis;
|
|
96
108
|
line-height: 22px;
|
|
97
109
|
`;
|
|
110
|
+
const Place = styled_components_1.default.div `
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-direction: column;
|
|
113
|
+
gap: 5px;
|
|
114
|
+
font-size: var(--font-size-small);
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
text-overflow: ellipsis;
|
|
117
|
+
|
|
118
|
+
&:first-child {
|
|
119
|
+
padding-top: 0;
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
98
122
|
//# sourceMappingURL=SearchItem.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SearchTrigger = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const styled_components_1 = __importStar(require("styled-components"));
|
|
29
|
+
const hooks_1 = require("../../hooks");
|
|
30
|
+
const hooks_2 = require("../../mocks/hooks");
|
|
31
|
+
const SearchIcon_1 = require("../../components/Search/SearchIcon");
|
|
32
|
+
const ShortcutKey_1 = require("../../components/Search/ShortcutKey");
|
|
33
|
+
function SearchTrigger({ onClick }) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
const themeSettings = (0, hooks_1.useThemeConfig)();
|
|
36
|
+
const { translate } = (0, hooks_2.useTranslate)();
|
|
37
|
+
const translationKeys = {
|
|
38
|
+
label: 'theme.search.navbar.label',
|
|
39
|
+
};
|
|
40
|
+
const 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 : ['/'];
|
|
41
|
+
return (React.createElement(Wrapper, { "data-component-name": "Search/SearchTrigger", onClick: onClick },
|
|
42
|
+
React.createElement(SearchIconSmall, null),
|
|
43
|
+
React.createElement(Label, { "data-translation-key": translationKeys.label }, translate(translationKeys.label, 'Search')),
|
|
44
|
+
React.createElement(ShortcutKey_1.ShortcutKey, { keyShortcuts: keyShortcuts })));
|
|
45
|
+
}
|
|
46
|
+
exports.SearchTrigger = SearchTrigger;
|
|
47
|
+
const Wrapper = styled_components_1.default.div `
|
|
48
|
+
display: none;
|
|
49
|
+
align-items: center;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
color: var(--search-trigger-text-color);
|
|
52
|
+
background-color: var(--search-trigger-background-color);
|
|
53
|
+
border: var(--search-trigger-border);
|
|
54
|
+
border-radius: var(--search-trigger-border-radius);
|
|
55
|
+
padding: 5px 10px 5px 14px;
|
|
56
|
+
user-select: none;
|
|
57
|
+
|
|
58
|
+
:hover {
|
|
59
|
+
background-color: var(--search-trigger-hover-background-color);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
${({ theme }) => {
|
|
63
|
+
return (0, styled_components_1.css) `
|
|
64
|
+
${theme.mediaQueries.small} {
|
|
65
|
+
display: flex;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
}}
|
|
69
|
+
`;
|
|
70
|
+
const Label = styled_components_1.default.span `
|
|
71
|
+
padding-left: 10px;
|
|
72
|
+
padding-right: 16px;
|
|
73
|
+
font-size: var(--search-trigger-font-size);
|
|
74
|
+
`;
|
|
75
|
+
const SearchIconSmall = (0, styled_components_1.default)(SearchIcon_1.SearchIcon) `
|
|
76
|
+
width: 13px;
|
|
77
|
+
height: 13px;
|
|
78
|
+
fill: var(--search-trigger-text-color);
|
|
79
|
+
`;
|
|
80
|
+
//# sourceMappingURL=SearchTrigger.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
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.Shortcut = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
function Shortcut({ combination, text, }) {
|
|
33
|
+
return (React.createElement(Wrapper, { "data-component-name": "Search/Shortcut" },
|
|
34
|
+
React.createElement(Key, null, combination),
|
|
35
|
+
text));
|
|
36
|
+
}
|
|
37
|
+
exports.Shortcut = Shortcut;
|
|
38
|
+
const Wrapper = styled_components_1.default.div `
|
|
39
|
+
display: flex;
|
|
40
|
+
padding: 2px 4px;
|
|
41
|
+
gap: 8px;
|
|
42
|
+
color: var(--search-item-text-color);
|
|
43
|
+
`;
|
|
44
|
+
const Key = styled_components_1.default.span `
|
|
45
|
+
background: rgba(150, 150, 150, 0.1);
|
|
46
|
+
border: 1px solid rgba(100, 100, 100, 0.2);
|
|
47
|
+
border-radius: 3px;
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
padding: 2px 6px;
|
|
50
|
+
`;
|
|
51
|
+
//# sourceMappingURL=Shortcut.js.map
|
|
@@ -21,15 +21,10 @@ function ShortcutKey(props) {
|
|
|
21
21
|
}
|
|
22
22
|
exports.ShortcutKey = ShortcutKey;
|
|
23
23
|
exports.Wrapper = styled_components_1.default.div `
|
|
24
|
-
position: absolute;
|
|
25
24
|
cursor: pointer;
|
|
26
|
-
font-size: 0.
|
|
27
|
-
height: 2em;
|
|
28
|
-
line-height: 2em;
|
|
25
|
+
font-size: 0.75em;
|
|
29
26
|
right: 1em;
|
|
30
|
-
|
|
31
|
-
color: var(--search-input-placeholder-color);
|
|
27
|
+
color: var(--search-trigger-shortcut-text-color);
|
|
32
28
|
opacity: 0.5;
|
|
33
|
-
z-index: -1;
|
|
34
29
|
`;
|
|
35
30
|
//# sourceMappingURL=ShortcutKey.js.map
|
|
@@ -0,0 +1,107 @@
|
|
|
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.SuggestedPages = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const ClockBackwardsIcon_1 = require("../../components/Search/ClockBackwardsIcon");
|
|
33
|
+
const search_1 = require("../../mocks/search");
|
|
34
|
+
const Link_1 = require("../../mocks/Link");
|
|
35
|
+
const hooks_1 = require("../../mocks/hooks");
|
|
36
|
+
function SuggestedPages() {
|
|
37
|
+
const pages = (0, search_1.useSuggestedPages)();
|
|
38
|
+
const { translate } = (0, hooks_1.useTranslate)();
|
|
39
|
+
const translationKeys = {
|
|
40
|
+
title: 'theme.search.suggested',
|
|
41
|
+
};
|
|
42
|
+
if (!pages.length)
|
|
43
|
+
return null;
|
|
44
|
+
return (React.createElement(Wrapper, { "data-component-name": "Search/SuggestedPages" },
|
|
45
|
+
React.createElement(Title, { "data-translation-key": translationKeys.title }, translate(translationKeys.title, 'Suggested pages')),
|
|
46
|
+
React.createElement(SuggestedItems, null, pages.map((page) => page.link && (React.createElement(Item, { key: page.label },
|
|
47
|
+
React.createElement(PageLink, Object.assign({ to: page.link }, page),
|
|
48
|
+
React.createElement(Group, null,
|
|
49
|
+
React.createElement(ClockBackwardsIcon, null),
|
|
50
|
+
page.label))))))));
|
|
51
|
+
}
|
|
52
|
+
exports.SuggestedPages = SuggestedPages;
|
|
53
|
+
const Wrapper = styled_components_1.default.div `
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
`;
|
|
57
|
+
const Title = styled_components_1.default.div `
|
|
58
|
+
color: var(--search-item-title-text-color);
|
|
59
|
+
font-weight: var(--font-weight-bold);
|
|
60
|
+
font-size: var(--font-size-small);
|
|
61
|
+
line-height: 20px;
|
|
62
|
+
padding: 8px 24px;
|
|
63
|
+
`;
|
|
64
|
+
const SuggestedItems = styled_components_1.default.div `
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: flex-start;
|
|
68
|
+
order: 1;
|
|
69
|
+
`;
|
|
70
|
+
const ClockBackwardsIcon = (0, styled_components_1.default)(ClockBackwardsIcon_1.ClockBackwardsIcon) `
|
|
71
|
+
width: 16px;
|
|
72
|
+
height: 16px;
|
|
73
|
+
fill: #8d8d8d;
|
|
74
|
+
`;
|
|
75
|
+
const Item = styled_components_1.default.div `
|
|
76
|
+
display: flex;
|
|
77
|
+
font-size: var(--font-size-base);
|
|
78
|
+
align-items: center;
|
|
79
|
+
padding: 0 12px 4px;
|
|
80
|
+
width: 100%;
|
|
81
|
+
`;
|
|
82
|
+
const PageLink = (0, styled_components_1.default)(Link_1.Link) `
|
|
83
|
+
text-decoration: none;
|
|
84
|
+
color: var(--search-item-text-color);
|
|
85
|
+
width: 100%;
|
|
86
|
+
padding: 8px 12px;
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
|
|
89
|
+
:hover {
|
|
90
|
+
background-color: var(--search-item-active-background-color);
|
|
91
|
+
color: var(--search-item-active-text-color);
|
|
92
|
+
|
|
93
|
+
${ClockBackwardsIcon} {
|
|
94
|
+
fill: var(--search-item-active-text-color);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
:focus-visible {
|
|
98
|
+
outline: 2px solid var(--color-primary-200);
|
|
99
|
+
border-radius: 2px;
|
|
100
|
+
}
|
|
101
|
+
`;
|
|
102
|
+
const Group = styled_components_1.default.div `
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
gap: 8px;
|
|
106
|
+
`;
|
|
107
|
+
//# sourceMappingURL=SuggestedPages.js.map
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
export * from '../../components/Search/
|
|
1
|
+
export * from '../../components/Search/InputWrapper';
|
|
2
2
|
export * from '../../components/Search/ClearIcon';
|
|
3
3
|
export * from '../../components/Search/Input';
|
|
4
|
-
export * from '../../components/Search/Parameters';
|
|
5
4
|
export * from '../../components/Search/Popover';
|
|
6
5
|
export * from '../../components/Search/Search';
|
|
7
6
|
export * from '../../components/Search/SearchIcon';
|
|
8
7
|
export * from '../../components/Search/SearchItem';
|
|
8
|
+
export * from '../../components/Search/SearchTrigger';
|
|
9
|
+
export * from '../../components/Search/Shortcut';
|
|
10
|
+
export * from '../../components/Search/RecentSearches';
|
|
11
|
+
export * from '../../components/Search/ClockBackwardsIcon';
|
|
12
|
+
export * from '../../components/Search/SuggestedPages';
|
|
13
|
+
export * from '../../components/Search/MobileSearchTrigger';
|
|
14
|
+
export * from '../../components/Search/CancelSearch';
|
|
9
15
|
export * from '../../components/Search/utils';
|
|
@@ -14,13 +14,19 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("../../components/Search/
|
|
17
|
+
__exportStar(require("../../components/Search/InputWrapper"), exports);
|
|
18
18
|
__exportStar(require("../../components/Search/ClearIcon"), exports);
|
|
19
19
|
__exportStar(require("../../components/Search/Input"), exports);
|
|
20
|
-
__exportStar(require("../../components/Search/Parameters"), exports);
|
|
21
20
|
__exportStar(require("../../components/Search/Popover"), exports);
|
|
22
21
|
__exportStar(require("../../components/Search/Search"), exports);
|
|
23
22
|
__exportStar(require("../../components/Search/SearchIcon"), exports);
|
|
24
23
|
__exportStar(require("../../components/Search/SearchItem"), exports);
|
|
24
|
+
__exportStar(require("../../components/Search/SearchTrigger"), exports);
|
|
25
|
+
__exportStar(require("../../components/Search/Shortcut"), exports);
|
|
26
|
+
__exportStar(require("../../components/Search/RecentSearches"), exports);
|
|
27
|
+
__exportStar(require("../../components/Search/ClockBackwardsIcon"), exports);
|
|
28
|
+
__exportStar(require("../../components/Search/SuggestedPages"), exports);
|
|
29
|
+
__exportStar(require("../../components/Search/MobileSearchTrigger"), exports);
|
|
30
|
+
__exportStar(require("../../components/Search/CancelSearch"), exports);
|
|
25
31
|
__exportStar(require("../../components/Search/utils"), exports);
|
|
26
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -40,7 +40,7 @@ const highlight = (text) => {
|
|
|
40
40
|
};
|
|
41
41
|
exports.highlight = highlight;
|
|
42
42
|
const Highlight = styled_components_1.default.span `
|
|
43
|
-
background-color: var(--search-highlight-
|
|
44
|
-
color: var(--
|
|
43
|
+
background-color: var(--search-highlight-background-color);
|
|
44
|
+
color: var(--search-highlight-text-color);
|
|
45
45
|
`;
|
|
46
46
|
//# sourceMappingURL=utils.js.map
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
type TabProps = {
|
|
3
3
|
activeTab: string;
|
|
4
4
|
label: string;
|
|
5
|
+
className?: string;
|
|
5
6
|
onClick: (e: string) => void;
|
|
6
7
|
};
|
|
7
|
-
export declare function Tab({ activeTab, label, onClick }: TabProps): JSX.Element;
|
|
8
|
+
export declare function Tab({ activeTab, label, onClick, className }: TabProps): JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Tab = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
function Tab({ activeTab, label, onClick }) {
|
|
9
|
+
function Tab({ activeTab, label, onClick, className }) {
|
|
10
10
|
const isActive = activeTab === label;
|
|
11
|
-
return (react_1.default.createElement(TabItem, { active: isActive, onClick: () => onClick(label), "data-component-name": "Markdown/Tabs/Tab" }, label));
|
|
11
|
+
return (react_1.default.createElement(TabItem, { active: isActive, onClick: () => onClick(label), "data-component-name": "Markdown/Tabs/Tab", className: className }, label));
|
|
12
12
|
}
|
|
13
13
|
exports.Tab = Tab;
|
|
14
14
|
const TabItem = styled_components_1.default.li `
|
|
@@ -35,7 +35,7 @@ function Tabs(props) {
|
|
|
35
35
|
const children = react_1.default.Children.toArray(props.children);
|
|
36
36
|
const [activeTab, setActiveTab] = (0, react_1.useState)((_a = children[0]) === null || _a === void 0 ? void 0 : _a.props.label);
|
|
37
37
|
const onTabSelect = (label) => setActiveTab(label);
|
|
38
|
-
return (react_1.default.createElement(TabsContainer, { "data-component-name": "Markdown/Tabs/Tabs" },
|
|
38
|
+
return (react_1.default.createElement(TabsContainer, { "data-component-name": "Markdown/Tabs/Tabs", className: props.className },
|
|
39
39
|
react_1.default.createElement(TabList, null, children.map((child) => {
|
|
40
40
|
const { label } = child.props;
|
|
41
41
|
return react_1.default.createElement(Tabs_1.Tab, { activeTab: activeTab, key: label, label: label, onClick: onTabSelect });
|
package/lib/config.d.ts
CHANGED
|
@@ -553,6 +553,24 @@ export declare const themeConfigSchema: {
|
|
|
553
553
|
};
|
|
554
554
|
readonly default: readonly ["/"];
|
|
555
555
|
};
|
|
556
|
+
readonly suggestedPages: {
|
|
557
|
+
readonly type: "array";
|
|
558
|
+
readonly items: {
|
|
559
|
+
readonly type: "object";
|
|
560
|
+
readonly properties: {
|
|
561
|
+
readonly page: {
|
|
562
|
+
readonly type: "string";
|
|
563
|
+
};
|
|
564
|
+
readonly label: {
|
|
565
|
+
readonly type: "string";
|
|
566
|
+
};
|
|
567
|
+
readonly labelTranslationKey: {
|
|
568
|
+
readonly type: "string";
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
readonly required: readonly ["page"];
|
|
572
|
+
};
|
|
573
|
+
};
|
|
556
574
|
};
|
|
557
575
|
readonly additionalProperties: false;
|
|
558
576
|
readonly default: {};
|
|
@@ -802,6 +820,7 @@ export type ThemeUIConfig = ThemeConfig & {
|
|
|
802
820
|
};
|
|
803
821
|
search?: {
|
|
804
822
|
shortcuts?: string[];
|
|
823
|
+
suggestedPages?: any[];
|
|
805
824
|
};
|
|
806
825
|
};
|
|
807
826
|
export type MarkdownConfig = FromSchema<typeof markdownConfigSchema>;
|
package/lib/config.js
CHANGED
|
@@ -112,6 +112,15 @@ const navItemsSchema = {
|
|
|
112
112
|
type: 'array',
|
|
113
113
|
items: Object.assign(Object.assign({}, navItemSchema), { properties: Object.assign(Object.assign({}, navItemSchema.properties), { items: { type: 'array', items: navItemSchema } }) }),
|
|
114
114
|
};
|
|
115
|
+
const suggestedPageSchema = {
|
|
116
|
+
type: 'object',
|
|
117
|
+
properties: {
|
|
118
|
+
page: { type: 'string' },
|
|
119
|
+
label: { type: 'string' },
|
|
120
|
+
labelTranslationKey: { type: 'string' },
|
|
121
|
+
},
|
|
122
|
+
required: ['page'],
|
|
123
|
+
};
|
|
115
124
|
exports.themeConfigSchema = {
|
|
116
125
|
type: 'object',
|
|
117
126
|
properties: {
|
|
@@ -194,6 +203,9 @@ exports.themeConfigSchema = {
|
|
|
194
203
|
type: 'array',
|
|
195
204
|
items: { type: 'string' },
|
|
196
205
|
default: ['/'],
|
|
206
|
+
}, suggestedPages: {
|
|
207
|
+
type: 'array',
|
|
208
|
+
items: suggestedPageSchema,
|
|
197
209
|
} }, hideConfigSchema.properties),
|
|
198
210
|
additionalProperties: false,
|
|
199
211
|
default: {},
|