@jetbrains/kotlin-web-site-ui 4.0.0 → 4.1.0-alpha.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/out/components/header/{consts.js → components/header/consts.js} +0 -0
- package/out/components/header/components/header/full-search/chapters/chapters.js +56 -0
- package/out/components/header/components/header/full-search/chapters/chapters.module.pcss.js +11 -0
- package/out/components/header/components/header/full-search/empty/empty.js +22 -0
- package/out/components/header/components/header/full-search/empty/empty.module.pcss.js +6 -0
- package/out/components/header/components/header/full-search/empty/full-search-empty.svg.js +1539 -0
- package/out/components/header/components/header/full-search/full-search.js +70 -0
- package/out/components/header/components/header/full-search/full-search.module.pcss.js +9 -0
- package/out/components/header/components/header/full-search/hit-list/hit-list.js +44 -0
- package/out/components/header/components/header/full-search/hit-list/hit-list.module.pcss.js +5 -0
- package/out/components/header/components/header/full-search/loading/loading.js +11 -0
- package/out/components/header/components/header/full-search/loading/loading.module.pcss.js +4 -0
- package/out/components/header/components/header/full-search/result/get-extended-hits.js +55 -0
- package/out/components/header/components/header/full-search/results-list/results-list.js +25 -0
- package/out/components/header/{header.js → components/header/header.js} +49 -7
- package/out/components/header/{header.module.pcss.js → components/header/header.module.pcss.js} +0 -0
- package/out/components/header/{horizontal-menu → components/header/horizontal-menu}/horizontal-menu.js +0 -0
- package/out/components/header/{horizontal-menu → components/header/horizontal-menu}/horizontal-menu.module.pcss.js +0 -0
- package/out/components/header/{index.js → components/header/index.js} +0 -0
- package/out/components/header/{logo-large → components/header/logo-large}/kotlin-logo-large.svg.js +0 -0
- package/out/components/header/{logo-large → components/header/logo-large}/logo-large.js +0 -0
- package/out/components/header/{logo-large → components/header/logo-large}/logo-large.module.pcss.js +0 -0
- package/out/components/header/{logo-small → components/header/logo-small}/kotlin-logo-small.svg.js +0 -0
- package/out/components/header/{logo-small → components/header/logo-small}/logo-small.js +0 -0
- package/out/components/header/{logo-small → components/header/logo-small}/logo-small.module.pcss.js +0 -0
- package/out/components/header/{menu-popup → components/header/menu-popup}/menu-button/close-icon.svg.js +0 -0
- package/out/components/header/{menu-popup → components/header/menu-popup}/menu-button/hamburger-icon.svg.js +0 -0
- package/out/components/header/{menu-popup → components/header/menu-popup}/menu-button/menu-button.js +0 -0
- package/out/components/header/{menu-popup → components/header/menu-popup}/menu-button/menu-button.module.pcss.js +0 -0
- package/out/components/header/{menu-popup → components/header/menu-popup}/menu-popup.js +0 -0
- package/out/components/header/{menu-popup → components/header/menu-popup}/menu-popup.module.pcss.js +0 -0
- package/out/components/header/{nav-scheme.js → components/header/nav-scheme.js} +0 -0
- package/out/components/header/components/header/quick-search/empty/empty.js +16 -0
- package/out/components/header/components/header/quick-search/empty/empty.module.pcss.js +4 -0
- package/out/components/header/components/header/quick-search/list/list.js +31 -0
- package/out/components/header/components/header/quick-search/list/list.module.pcss.js +6 -0
- package/out/components/header/components/header/quick-search/loading/loading.js +14 -0
- package/out/components/header/components/header/quick-search/loading/loading.module.pcss.js +4 -0
- package/out/components/header/components/header/quick-search/quick-search.js +41 -0
- package/out/components/header/components/header/quick-search/quick-search.module.pcss.js +4 -0
- package/out/components/header/components/header/quick-search/result/result.js +30 -0
- package/out/components/header/components/header/quick-search/result/result.module.pcss.js +6 -0
- package/out/components/header/components/header/search-box/search-box.js +69 -0
- package/out/components/header/components/header/search-box/search-box.module.pcss.js +4 -0
- package/out/components/header/{search-button → components/header/search-button}/search-button.js +0 -0
- package/out/components/header/{search-button → components/header/search-button}/search-button.module.pcss.js +0 -0
- package/out/components/header/{search-button → components/header/search-button}/search.svg.js +0 -0
- package/out/components/header/components/header/search-wrapper/init-search.js +60 -0
- package/out/components/header/components/header/search-wrapper/search-const.js +13 -0
- package/out/components/header/components/header/search-wrapper/search-context.js +18 -0
- package/out/components/header/components/header/search-wrapper/search-with-algolia.js +58 -0
- package/out/components/header/components/header/search-wrapper/search-wrapper.js +40 -0
- package/out/components/header/components/header/search-wrapper/use-search.js +85 -0
- package/out/components/header/helper/is-macos.js +5 -0
- package/out/components/header/helper/key-codes.js +3 -0
- package/out/components/header/index.css +253 -0
- package/package.json +8 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React__default, { useState, useContext, useCallback } from 'react';
|
|
2
|
+
import { ThemeProvider } from '@rescui/ui-contexts';
|
|
3
|
+
import Input from '@rescui/input';
|
|
4
|
+
import Switcher from '@rescui/switcher';
|
|
5
|
+
import { CloseIcon, ErrorIcon } from '@rescui/icons';
|
|
6
|
+
import styles from './full-search.module.pcss.js';
|
|
7
|
+
import { useSearch } from '../search-wrapper/use-search.js';
|
|
8
|
+
import { ResultsList } from './results-list/results-list.js';
|
|
9
|
+
import SearchContext from '../search-wrapper/search-context.js';
|
|
10
|
+
|
|
11
|
+
const FullSearch = ({
|
|
12
|
+
searchString,
|
|
13
|
+
killSearch
|
|
14
|
+
}) => {
|
|
15
|
+
const [inputValue, setInputValue] = useState(searchString);
|
|
16
|
+
const {
|
|
17
|
+
hits,
|
|
18
|
+
placeholder
|
|
19
|
+
} = useSearch(inputValue, 75);
|
|
20
|
+
const {
|
|
21
|
+
matching,
|
|
22
|
+
matchingOptions,
|
|
23
|
+
setMatching
|
|
24
|
+
} = useContext(SearchContext);
|
|
25
|
+
const clearSearch = useCallback(() => {
|
|
26
|
+
setInputValue('');
|
|
27
|
+
}, []);
|
|
28
|
+
const handleSwitcherChange = useCallback(value => {
|
|
29
|
+
setMatching(value);
|
|
30
|
+
}, []);
|
|
31
|
+
const handleInputChange = useCallback(e => {
|
|
32
|
+
setInputValue(e.target.value);
|
|
33
|
+
}, [inputValue]);
|
|
34
|
+
return React__default.createElement(ThemeProvider, {
|
|
35
|
+
theme: 'light'
|
|
36
|
+
}, React__default.createElement("div", {
|
|
37
|
+
className: styles.fullSearch
|
|
38
|
+
}, React__default.createElement("div", {
|
|
39
|
+
className: styles.header
|
|
40
|
+
}, React__default.createElement("button", {
|
|
41
|
+
className: styles.closeSearch,
|
|
42
|
+
onClick: killSearch
|
|
43
|
+
}, React__default.createElement(CloseIcon, {
|
|
44
|
+
size: 'l'
|
|
45
|
+
})), React__default.createElement("div", {
|
|
46
|
+
className: styles.wrapper
|
|
47
|
+
}, React__default.createElement(Input, {
|
|
48
|
+
placeholder: 'Search',
|
|
49
|
+
value: inputValue,
|
|
50
|
+
onClear: clearSearch,
|
|
51
|
+
onChange: handleInputChange,
|
|
52
|
+
clearIcon: React__default.createElement(ErrorIcon, null),
|
|
53
|
+
size: 'l',
|
|
54
|
+
autoFocus: true
|
|
55
|
+
}), React__default.createElement("div", {
|
|
56
|
+
className: styles.switcher
|
|
57
|
+
}, React__default.createElement(Switcher, {
|
|
58
|
+
value: matching,
|
|
59
|
+
onChange: handleSwitcherChange,
|
|
60
|
+
options: matchingOptions,
|
|
61
|
+
size: 'xs'
|
|
62
|
+
})))), React__default.createElement("div", {
|
|
63
|
+
className: styles.wrapper
|
|
64
|
+
}, inputValue && React__default.createElement(ResultsList, {
|
|
65
|
+
placeholder: placeholder,
|
|
66
|
+
hits: hits
|
|
67
|
+
}))));
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export { FullSearch };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
var styles = {
|
|
2
|
+
"fullSearch": "ktl-full-search-module_fullSearch_MTU8t",
|
|
3
|
+
"closeSearch": "ktl-full-search-module_closeSearch_5vYDG",
|
|
4
|
+
"wrapper": "ktl-full-search-module_wrapper_9rxXb",
|
|
5
|
+
"header": "ktl-full-search-module_header_Wltw0",
|
|
6
|
+
"switcher": "ktl-full-search-module_switcher_o1RgM",
|
|
7
|
+
"results": "ktl-full-search-module_results_svcSE"
|
|
8
|
+
};
|
|
9
|
+
export { styles as default };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { useTextStyles } from '@rescui/typography';
|
|
3
|
+
import getExtendedHits from '../result/get-extended-hits.js';
|
|
4
|
+
import { Chapters } from '../chapters/chapters.js';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import styles from './hit-list.module.pcss.js';
|
|
7
|
+
|
|
8
|
+
const HitList = ({
|
|
9
|
+
hits
|
|
10
|
+
}) => {
|
|
11
|
+
const textCn = useTextStyles();
|
|
12
|
+
const extendedHits = getExtendedHits(hits);
|
|
13
|
+
return React__default.createElement(React__default.Fragment, null, extendedHits.map(({
|
|
14
|
+
title,
|
|
15
|
+
snippet,
|
|
16
|
+
chapters = [],
|
|
17
|
+
url,
|
|
18
|
+
breadcrumb
|
|
19
|
+
}, pageIndex) => {
|
|
20
|
+
const isHitWithChapters = chapters.length > 0;
|
|
21
|
+
return React__default.createElement("div", {
|
|
22
|
+
className: styles.hitList,
|
|
23
|
+
key: pageIndex
|
|
24
|
+
}, React__default.createElement("h3", {
|
|
25
|
+
className: textCn('rs-h3')
|
|
26
|
+
}, React__default.createElement("a", {
|
|
27
|
+
className: classNames(styles.titleLink, textCn('rs-link')),
|
|
28
|
+
href: url,
|
|
29
|
+
dangerouslySetInnerHTML: {
|
|
30
|
+
__html: title
|
|
31
|
+
}
|
|
32
|
+
})), isHitWithChapters ? React__default.createElement(Chapters, {
|
|
33
|
+
chapters: chapters,
|
|
34
|
+
hitIndex: pageIndex
|
|
35
|
+
}) : React__default.createElement("div", {
|
|
36
|
+
className: classNames(textCn('rs-text-2')),
|
|
37
|
+
dangerouslySetInnerHTML: {
|
|
38
|
+
__html: snippet
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { HitList };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { LoadingIcon } from '@rescui/icons';
|
|
3
|
+
import styles from './loading.module.pcss.js';
|
|
4
|
+
|
|
5
|
+
const FullSearchLoader = () => {
|
|
6
|
+
return React__default.createElement("div", {
|
|
7
|
+
className: styles.loader
|
|
8
|
+
}, React__default.createElement(LoadingIcon, null));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { FullSearchLoader };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const groupHitsByPageId = ungroupedHits => ungroupedHits.reduce((groups, currentHit) => {
|
|
2
|
+
const currentGroup = groups.find(group => group.name === currentHit.mainTitle);
|
|
3
|
+
|
|
4
|
+
if (currentGroup) {
|
|
5
|
+
currentGroup.hits.push(currentHit);
|
|
6
|
+
return groups;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const newGroup = {
|
|
10
|
+
name: currentHit.mainTitle,
|
|
11
|
+
hits: [currentHit]
|
|
12
|
+
};
|
|
13
|
+
return [...groups, newGroup];
|
|
14
|
+
}, []);
|
|
15
|
+
|
|
16
|
+
const getChapterName = fullName => fullName.split(':')[1] || fullName;
|
|
17
|
+
|
|
18
|
+
const highlightChaptersTitles = chapters => chapters.map(chapter => ({ ...chapter,
|
|
19
|
+
highlightedTitle: getChapterName(chapter.highlightedTitle)
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
const getExtendedHits = hits => {
|
|
23
|
+
try {
|
|
24
|
+
const groupedHits = groupHitsByPageId(hits);
|
|
25
|
+
return groupedHits.map(group => {
|
|
26
|
+
const mainHit = group.hits.find(hit => hit.title === group.name);
|
|
27
|
+
|
|
28
|
+
if (mainHit) {
|
|
29
|
+
const chapters = group.hits.filter(hit => hit.title !== group.name);
|
|
30
|
+
return { ...mainHit,
|
|
31
|
+
title: mainHit.highlightedTitle,
|
|
32
|
+
chapters: highlightChaptersTitles(chapters)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const {
|
|
37
|
+
url,
|
|
38
|
+
breadcrumb,
|
|
39
|
+
...restHitProps
|
|
40
|
+
} = group.hits[0];
|
|
41
|
+
return { ...restHitProps,
|
|
42
|
+
title: group.name,
|
|
43
|
+
url: url.split('#')[0],
|
|
44
|
+
breadcrumb,
|
|
45
|
+
chapters: highlightChaptersTitles(group.hits)
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
} catch (error) {
|
|
49
|
+
// reportError(error, { func: 'getExtendedHits' });
|
|
50
|
+
console.log('error');
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export { getExtendedHits as default };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { FullSearchLoader } from '../loading/loading.js';
|
|
3
|
+
import { FullSearchEmpty } from '../empty/empty.js';
|
|
4
|
+
import { HitList } from '../hit-list/hit-list.js';
|
|
5
|
+
|
|
6
|
+
const ResultsList = ({
|
|
7
|
+
placeholder,
|
|
8
|
+
hits
|
|
9
|
+
}) => {
|
|
10
|
+
if (placeholder) {
|
|
11
|
+
return React__default.createElement(FullSearchEmpty, {
|
|
12
|
+
placeholder: placeholder
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (hits.length) {
|
|
17
|
+
return React__default.createElement(HitList, {
|
|
18
|
+
hits: hits
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return React__default.createElement(FullSearchLoader, null);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { ResultsList };
|
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import React__default, { forwardRef, useState, useMemo, useRef, useImperativeHandle, useLayoutEffect } from 'react';
|
|
1
|
+
import React__default, { forwardRef, useState, useMemo, useRef, useImperativeHandle, useLayoutEffect, useCallback, useEffect } from 'react';
|
|
2
2
|
import { ThemeProvider } from '@rescui/ui-contexts';
|
|
3
3
|
import useResizeObserver from '@react-hook/resize-observer';
|
|
4
|
+
import OutsideClickHandler from 'react-outside-click-handler';
|
|
4
5
|
import { LogoLarge } from './logo-large/logo-large.js';
|
|
5
6
|
import styles from './header.module.pcss.js';
|
|
6
7
|
import { getNavScheme } from './nav-scheme.js';
|
|
7
8
|
import { HorizontalMenu } from './horizontal-menu/horizontal-menu.js';
|
|
8
9
|
import { SearchButton } from './search-button/search-button.js';
|
|
10
|
+
import { SearchBox } from './search-box/search-box.js';
|
|
9
11
|
import { MenuPopup } from './menu-popup/menu-popup.js';
|
|
10
12
|
import { LogoSmall } from './logo-small/logo-small.js';
|
|
11
13
|
import classNames from 'classnames';
|
|
14
|
+
import { SearchWrapper } from './search-wrapper/search-wrapper.js';
|
|
15
|
+
import { isMacOs } from '../../helper/is-macos.js';
|
|
16
|
+
import { KEY_K_CODE } from '../../helper/key-codes.js';
|
|
12
17
|
const MENU_POPUP_BREAKPOINT = 640;
|
|
13
18
|
const Header = forwardRef(({
|
|
14
19
|
productWebUrl,
|
|
15
20
|
hasSearch = false,
|
|
16
|
-
onSearchClick,
|
|
17
21
|
currentUrl,
|
|
18
22
|
currentTitle,
|
|
19
23
|
className,
|
|
@@ -21,10 +25,13 @@ const Header = forwardRef(({
|
|
|
21
25
|
dropdownTheme = 'dark',
|
|
22
26
|
linkHandler,
|
|
23
27
|
isPlayground,
|
|
24
|
-
isUrlActive
|
|
28
|
+
isUrlActive,
|
|
29
|
+
searchConfig
|
|
25
30
|
}, forwardedRef) => {
|
|
26
31
|
const [menuPopupExpanded, setMenuPopupExpanded] = useState(false);
|
|
27
32
|
const [isMenuPopupVisible, setIsMenuPopupVisible] = useState(false);
|
|
33
|
+
const [isSearchBoxVisible, setSearchBoxVisible] = useState(false);
|
|
34
|
+
const [fullSearchActive, setFullSearchActive] = useState(false);
|
|
28
35
|
const items = useMemo(() => getNavScheme(isUrlActive, currentUrl, isPlayground), [isUrlActive, currentUrl, isPlayground]);
|
|
29
36
|
const headerRef = useRef(null);
|
|
30
37
|
useImperativeHandle(forwardedRef, () => headerRef.current);
|
|
@@ -32,8 +39,36 @@ const Header = forwardRef(({
|
|
|
32
39
|
setIsMenuPopupVisible((headerRef.current?.getBoundingClientRect?.().width ?? 0) <= MENU_POPUP_BREAKPOINT);
|
|
33
40
|
}, [headerRef]);
|
|
34
41
|
useResizeObserver(headerRef, entry => setIsMenuPopupVisible(entry.contentRect.width <= MENU_POPUP_BREAKPOINT));
|
|
42
|
+
const handleSearchButtonClick = useCallback(() => {
|
|
43
|
+
setSearchBoxVisible(!isSearchBoxVisible);
|
|
44
|
+
}, []);
|
|
45
|
+
const handleSearchClose = useCallback(() => {
|
|
46
|
+
setSearchBoxVisible(false);
|
|
47
|
+
setFullSearchActive(false);
|
|
48
|
+
}, []);
|
|
49
|
+
const fullSearchKeyHandler = useCallback(event => {
|
|
50
|
+
const isMacOsHotkeyPressed = isMacOs() && event.keyCode === KEY_K_CODE && event.metaKey;
|
|
51
|
+
const isOtherPlatformsHotkeyPressed = !isMacOs() && event.keyCode === KEY_K_CODE && event.ctrlKey;
|
|
52
|
+
|
|
53
|
+
if (isMacOsHotkeyPressed || isOtherPlatformsHotkeyPressed) {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
event.stopPropagation();
|
|
56
|
+
setSearchBoxVisible(true);
|
|
57
|
+
setFullSearchActive(true);
|
|
58
|
+
}
|
|
59
|
+
}, []);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (typeof document !== `undefined`) {
|
|
62
|
+
document.addEventListener('keydown', fullSearchKeyHandler);
|
|
63
|
+
return () => {
|
|
64
|
+
document.removeEventListener('keydown', fullSearchKeyHandler);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}, [fullSearchKeyHandler]);
|
|
35
68
|
return React__default.createElement(ThemeProvider, {
|
|
36
69
|
theme: 'dark'
|
|
70
|
+
}, React__default.createElement(SearchWrapper, {
|
|
71
|
+
searchConfig: searchConfig
|
|
37
72
|
}, React__default.createElement("header", {
|
|
38
73
|
ref: headerRef,
|
|
39
74
|
className: classNames(styles.headerMenu, className, {
|
|
@@ -45,19 +80,26 @@ const Header = forwardRef(({
|
|
|
45
80
|
homeUrl: currentUrl
|
|
46
81
|
}) : React__default.createElement(LogoLarge, {
|
|
47
82
|
productWebUrl: productWebUrl
|
|
48
|
-
}),
|
|
83
|
+
}), isSearchBoxVisible ? React__default.createElement(OutsideClickHandler, {
|
|
84
|
+
onOutsideClick: handleSearchClose
|
|
85
|
+
}, React__default.createElement(SearchBox, {
|
|
86
|
+
closeHandler: handleSearchClose,
|
|
87
|
+
isMobile: isMenuPopupVisible,
|
|
88
|
+
fullSearchActive: fullSearchActive,
|
|
89
|
+
setFullSearchActive: setFullSearchActive
|
|
90
|
+
})) : React__default.createElement(React__default.Fragment, null, !isMenuPopupVisible && React__default.createElement(HorizontalMenu, {
|
|
49
91
|
items: items,
|
|
50
92
|
theme: dropdownTheme,
|
|
51
93
|
linkHandler: linkHandler
|
|
52
94
|
}), React__default.createElement(SearchButton, {
|
|
53
|
-
onClick:
|
|
54
|
-
isActive: hasSearch
|
|
95
|
+
onClick: handleSearchButtonClick,
|
|
96
|
+
isActive: hasSearch
|
|
55
97
|
}), isMenuPopupVisible && React__default.createElement(MenuPopup, {
|
|
56
98
|
items: items,
|
|
57
99
|
setExpand: setMenuPopupExpanded,
|
|
58
100
|
isExpanded: menuPopupExpanded,
|
|
59
101
|
headerRef: headerRef,
|
|
60
102
|
linkHandler: linkHandler
|
|
61
|
-
})));
|
|
103
|
+
})))));
|
|
62
104
|
});
|
|
63
105
|
export { Header };
|
package/out/components/header/{header.module.pcss.js → components/header/header.module.pcss.js}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/out/components/header/{logo-large → components/header/logo-large}/kotlin-logo-large.svg.js
RENAMED
|
File without changes
|
|
File without changes
|
package/out/components/header/{logo-large → components/header/logo-large}/logo-large.module.pcss.js
RENAMED
|
File without changes
|
package/out/components/header/{logo-small → components/header/logo-small}/kotlin-logo-small.svg.js
RENAMED
|
File without changes
|
|
File without changes
|
package/out/components/header/{logo-small → components/header/logo-small}/logo-small.module.pcss.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/out/components/header/{menu-popup → components/header/menu-popup}/menu-button/menu-button.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/out/components/header/{menu-popup → components/header/menu-popup}/menu-popup.module.pcss.js
RENAMED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { useTextStyles } from '@rescui/typography';
|
|
3
|
+
import styles from './empty.module.pcss.js';
|
|
4
|
+
|
|
5
|
+
const EmptyResult = ({
|
|
6
|
+
placeholder
|
|
7
|
+
}) => {
|
|
8
|
+
const textCn = useTextStyles();
|
|
9
|
+
return React__default.createElement("div", {
|
|
10
|
+
className: styles.empty
|
|
11
|
+
}, React__default.createElement("div", {
|
|
12
|
+
className: textCn('rs-h4')
|
|
13
|
+
}, placeholder));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { EmptyResult };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React__default, { useMemo } from 'react';
|
|
2
|
+
import { Result } from '../result/result.js';
|
|
3
|
+
import { useTextStyles } from '@rescui/typography';
|
|
4
|
+
import { isMacOs } from '../../../../helper/is-macos.js';
|
|
5
|
+
import styles from './list.module.pcss.js';
|
|
6
|
+
|
|
7
|
+
const ResultsList = ({
|
|
8
|
+
results,
|
|
9
|
+
searchString,
|
|
10
|
+
toggleFullSearch
|
|
11
|
+
}) => {
|
|
12
|
+
const textCn = useTextStyles();
|
|
13
|
+
const controlledSearchString = useMemo(() => searchString.length > 5 ? `${searchString.substring(0, 5)}...` : searchString, [searchString]);
|
|
14
|
+
return React__default.createElement("div", {
|
|
15
|
+
className: styles.results
|
|
16
|
+
}, results.length ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
17
|
+
className: styles.topBar
|
|
18
|
+
}, React__default.createElement("div", {
|
|
19
|
+
className: textCn('rs-text-3')
|
|
20
|
+
}, "Showing results for \u00AB", controlledSearchString, "\u00BB"), React__default.createElement("button", {
|
|
21
|
+
className: styles.advancedSearch,
|
|
22
|
+
onClick: toggleFullSearch
|
|
23
|
+
}, React__default.createElement("div", {
|
|
24
|
+
className: textCn('rs-text-3')
|
|
25
|
+
}, "Advanced search ", isMacOs() ? '⌘K' : 'Ctrl+K'))), results.map((searchResult, index) => React__default.createElement(Result, {
|
|
26
|
+
key: index,
|
|
27
|
+
hit: searchResult
|
|
28
|
+
}))) : null);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { ResultsList };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { LoadingIcon } from '@rescui/icons';
|
|
3
|
+
import styles from './loading.module.pcss.js';
|
|
4
|
+
|
|
5
|
+
const LoadingResults = () => {
|
|
6
|
+
return React__default.createElement("div", {
|
|
7
|
+
className: styles.loading
|
|
8
|
+
}, React__default.createElement(LoadingIcon, {
|
|
9
|
+
theme: 'dark',
|
|
10
|
+
size: 'l'
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { LoadingResults };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { ThemeProvider } from '@rescui/ui-contexts';
|
|
3
|
+
import { ResultsList } from './list/list.js';
|
|
4
|
+
import { EmptyResult } from './empty/empty.js';
|
|
5
|
+
import { LoadingResults } from './loading/loading.js';
|
|
6
|
+
import styles from './quick-search.module.pcss.js';
|
|
7
|
+
|
|
8
|
+
const QuickSearch = ({
|
|
9
|
+
results,
|
|
10
|
+
searchString,
|
|
11
|
+
toggleFullSearch,
|
|
12
|
+
placeholder
|
|
13
|
+
}) => {
|
|
14
|
+
if (placeholder) {
|
|
15
|
+
return React__default.createElement(ThemeProvider, {
|
|
16
|
+
theme: 'dark'
|
|
17
|
+
}, React__default.createElement("div", {
|
|
18
|
+
className: styles.wrapper
|
|
19
|
+
}, React__default.createElement(EmptyResult, {
|
|
20
|
+
placeholder: placeholder
|
|
21
|
+
})));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (results.length > 0) {
|
|
25
|
+
return React__default.createElement(ThemeProvider, {
|
|
26
|
+
theme: 'dark'
|
|
27
|
+
}, React__default.createElement("div", {
|
|
28
|
+
className: styles.wrapper
|
|
29
|
+
}, React__default.createElement(ResultsList, {
|
|
30
|
+
results: results,
|
|
31
|
+
searchString: searchString,
|
|
32
|
+
toggleFullSearch: toggleFullSearch
|
|
33
|
+
})));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return React__default.createElement("div", {
|
|
37
|
+
className: styles.wrapper
|
|
38
|
+
}, React__default.createElement(LoadingResults, null));
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { QuickSearch };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { useTextStyles } from '@rescui/typography';
|
|
3
|
+
import styles from './result.module.pcss.js';
|
|
4
|
+
|
|
5
|
+
const Result = ({
|
|
6
|
+
hit
|
|
7
|
+
}) => {
|
|
8
|
+
const textCn = useTextStyles();
|
|
9
|
+
const hitTitle = hit.title === hit.mainTitle ? hit.highlightedTitle : `${hit.mainTitle}: ${hit.highlightedTitle}`;
|
|
10
|
+
return React__default.createElement("a", {
|
|
11
|
+
className: styles.result,
|
|
12
|
+
href: hit.url
|
|
13
|
+
}, React__default.createElement("div", {
|
|
14
|
+
className: styles.resultTitle
|
|
15
|
+
}, React__default.createElement("div", {
|
|
16
|
+
className: textCn('rs-h4'),
|
|
17
|
+
dangerouslySetInnerHTML: {
|
|
18
|
+
__html: hitTitle
|
|
19
|
+
}
|
|
20
|
+
})), React__default.createElement("div", {
|
|
21
|
+
className: styles.text
|
|
22
|
+
}, React__default.createElement("div", {
|
|
23
|
+
className: textCn('rs-text-3'),
|
|
24
|
+
dangerouslySetInnerHTML: {
|
|
25
|
+
__html: hit.snippet
|
|
26
|
+
}
|
|
27
|
+
})));
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { Result };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React__default, { useState, useCallback, useEffect } from 'react';
|
|
2
|
+
import Input from '@rescui/input';
|
|
3
|
+
import { SearchIcon, CloseIcon, ErrorIcon } from '@rescui/icons';
|
|
4
|
+
import { QuickSearch } from '../quick-search/quick-search.js';
|
|
5
|
+
import { FullSearch } from '../full-search/full-search.js';
|
|
6
|
+
import styles from './search-box.module.pcss.js';
|
|
7
|
+
import { useSearch } from '../search-wrapper/use-search.js';
|
|
8
|
+
import { isMacOs } from '../../../helper/is-macos.js';
|
|
9
|
+
import { ESC_CODE } from '../../../helper/key-codes.js';
|
|
10
|
+
|
|
11
|
+
const SearchBox = ({
|
|
12
|
+
closeHandler,
|
|
13
|
+
isMobile,
|
|
14
|
+
fullSearchActive,
|
|
15
|
+
setFullSearchActive
|
|
16
|
+
}) => {
|
|
17
|
+
const [searchInput, setSearchInput] = useState('');
|
|
18
|
+
const {
|
|
19
|
+
hits,
|
|
20
|
+
placeholder
|
|
21
|
+
} = useSearch(searchInput, 25);
|
|
22
|
+
const escHandler = useCallback(event => {
|
|
23
|
+
if (event.keyCode === ESC_CODE) {
|
|
24
|
+
closeHandler();
|
|
25
|
+
}
|
|
26
|
+
}, [closeHandler]);
|
|
27
|
+
const handleInput = useCallback(e => {
|
|
28
|
+
setSearchInput(e.target.value);
|
|
29
|
+
}, []);
|
|
30
|
+
const handleClear = useCallback(() => {
|
|
31
|
+
setSearchInput('');
|
|
32
|
+
}, []);
|
|
33
|
+
const toggleFullSearch = useCallback(() => {
|
|
34
|
+
setFullSearchActive(!fullSearchActive);
|
|
35
|
+
}, [fullSearchActive]);
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (typeof document !== `undefined`) {
|
|
38
|
+
document.addEventListener('keydown', escHandler);
|
|
39
|
+
return () => {
|
|
40
|
+
document.removeEventListener('keydown', escHandler);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}, [escHandler]);
|
|
44
|
+
const QuickSearchPlaceholder = isMobile ? 'Search' : `${isMacOs() ? '⌘K' : 'Ctrl+K'} for advanced search`;
|
|
45
|
+
return React__default.createElement("div", {
|
|
46
|
+
className: styles.searchBox
|
|
47
|
+
}, React__default.createElement(Input, {
|
|
48
|
+
placeholder: QuickSearchPlaceholder,
|
|
49
|
+
iconType: 'left',
|
|
50
|
+
value: searchInput,
|
|
51
|
+
onChange: handleInput,
|
|
52
|
+
onClear: isMobile ? closeHandler : handleClear,
|
|
53
|
+
icon: React__default.createElement(SearchIcon, null),
|
|
54
|
+
clearIcon: isMobile ? React__default.createElement(CloseIcon, null) : React__default.createElement(ErrorIcon, null),
|
|
55
|
+
autoFocus: true
|
|
56
|
+
}), searchInput && React__default.createElement(QuickSearch, {
|
|
57
|
+
results: hits,
|
|
58
|
+
searchString: searchInput,
|
|
59
|
+
toggleFullSearch: toggleFullSearch,
|
|
60
|
+
placeholder: placeholder
|
|
61
|
+
}), fullSearchActive && React__default.createElement(FullSearch, {
|
|
62
|
+
toggleFullSearch: toggleFullSearch,
|
|
63
|
+
searchString: searchInput,
|
|
64
|
+
results: hits,
|
|
65
|
+
killSearch: closeHandler
|
|
66
|
+
}));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { SearchBox };
|
package/out/components/header/{search-button → components/header/search-button}/search-button.js
RENAMED
|
File without changes
|
|
File without changes
|
package/out/components/header/{search-button → components/header/search-button}/search.svg.js
RENAMED
|
File without changes
|