@jetbrains/kotlin-web-site-ui 4.0.0 → 4.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/out/components/header/full-search/chapters/chapters.js +59 -0
  2. package/out/components/header/full-search/chapters/chapters.module.pcss.js +11 -0
  3. package/out/components/header/full-search/empty/empty.js +22 -0
  4. package/out/components/header/full-search/empty/empty.module.pcss.js +6 -0
  5. package/out/components/header/full-search/empty/full-search-empty.svg.js +1539 -0
  6. package/out/components/header/full-search/full-search.js +70 -0
  7. package/out/components/header/full-search/full-search.module.pcss.js +9 -0
  8. package/out/components/header/full-search/hit-list/get-extended-hits.js +55 -0
  9. package/out/components/header/full-search/hit-list/hit-list.js +47 -0
  10. package/out/components/header/full-search/hit-list/hit-list.module.pcss.js +5 -0
  11. package/out/components/header/full-search/loading/loading.js +11 -0
  12. package/out/components/header/full-search/loading/loading.module.pcss.js +4 -0
  13. package/out/components/header/full-search/results-list/results-list.js +25 -0
  14. package/out/components/header/header.js +53 -7
  15. package/out/components/header/index.css +259 -0
  16. package/out/components/header/is-macos.js +5 -0
  17. package/out/components/header/key-codes.js +3 -0
  18. package/out/components/header/quick-search/empty/empty.js +16 -0
  19. package/out/components/header/quick-search/empty/empty.module.pcss.js +4 -0
  20. package/out/components/header/quick-search/list/list.js +32 -0
  21. package/out/components/header/quick-search/list/list.module.pcss.js +7 -0
  22. package/out/components/header/quick-search/loading/loading.js +14 -0
  23. package/out/components/header/quick-search/loading/loading.module.pcss.js +4 -0
  24. package/out/components/header/quick-search/quick-search.js +41 -0
  25. package/out/components/header/quick-search/quick-search.module.pcss.js +4 -0
  26. package/out/components/header/quick-search/result/result.js +30 -0
  27. package/out/components/header/quick-search/result/result.module.pcss.js +6 -0
  28. package/out/components/header/search-box/search-box.js +69 -0
  29. package/out/components/header/search-box/search-box.module.pcss.js +4 -0
  30. package/out/components/header/search-wrapper/init-search.js +60 -0
  31. package/out/components/header/search-wrapper/search-const.js +13 -0
  32. package/out/components/header/search-wrapper/search-context.js +18 -0
  33. package/out/components/header/search-wrapper/search-with-algolia.js +58 -0
  34. package/out/components/header/search-wrapper/search-wrapper.js +40 -0
  35. package/out/components/header/search-wrapper/use-search.js +85 -0
  36. package/package.json +10 -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,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,47 @@
1
+ import React__default from 'react';
2
+ import { useTextStyles } from '@rescui/typography';
3
+ import getExtendedHits from './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
+ mode: 'clear',
29
+ hardness: 'hard'
30
+ })),
31
+ href: url,
32
+ dangerouslySetInnerHTML: {
33
+ __html: title
34
+ }
35
+ })), isHitWithChapters ? React__default.createElement(Chapters, {
36
+ chapters: chapters,
37
+ hitIndex: pageIndex
38
+ }) : React__default.createElement("div", {
39
+ className: classNames(textCn('rs-text-2')),
40
+ dangerouslySetInnerHTML: {
41
+ __html: snippet
42
+ }
43
+ }));
44
+ }));
45
+ };
46
+
47
+ export { HitList };
@@ -0,0 +1,5 @@
1
+ var styles = {
2
+ "hitList": "ktl-hit-list-module_hitList_1MP6m",
3
+ "titleLink": "ktl-hit-list-module_titleLink_rdJ6u"
4
+ };
5
+ export { styles as default };
@@ -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,4 @@
1
+ var styles = {
2
+ "loader": "ktl-loading-module_loader_B2IQl"
3
+ };
4
+ export { styles 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,24 @@
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
+ import FocusManager from '@rescui/focus-manager';
3
4
  import useResizeObserver from '@react-hook/resize-observer';
5
+ import OutsideClickHandler from 'react-outside-click-handler';
4
6
  import { LogoLarge } from './logo-large/logo-large.js';
5
7
  import styles from './header.module.pcss.js';
6
8
  import { getNavScheme } from './nav-scheme.js';
7
9
  import { HorizontalMenu } from './horizontal-menu/horizontal-menu.js';
8
10
  import { SearchButton } from './search-button/search-button.js';
11
+ import { SearchBox } from './search-box/search-box.js';
9
12
  import { MenuPopup } from './menu-popup/menu-popup.js';
10
13
  import { LogoSmall } from './logo-small/logo-small.js';
11
14
  import classNames from 'classnames';
15
+ import { SearchWrapper } from './search-wrapper/search-wrapper.js';
16
+ import { isMacOs } from './is-macos.js';
17
+ import { KEY_K_CODE } from './key-codes.js';
12
18
  const MENU_POPUP_BREAKPOINT = 640;
13
19
  const Header = forwardRef(({
14
20
  productWebUrl,
15
21
  hasSearch = false,
16
- onSearchClick,
17
22
  currentUrl,
18
23
  currentTitle,
19
24
  className,
@@ -21,10 +26,13 @@ const Header = forwardRef(({
21
26
  dropdownTheme = 'dark',
22
27
  linkHandler,
23
28
  isPlayground,
24
- isUrlActive
29
+ isUrlActive,
30
+ searchConfig
25
31
  }, forwardedRef) => {
26
32
  const [menuPopupExpanded, setMenuPopupExpanded] = useState(false);
27
33
  const [isMenuPopupVisible, setIsMenuPopupVisible] = useState(false);
34
+ const [isSearchBoxVisible, setSearchBoxVisible] = useState(false);
35
+ const [fullSearchActive, setFullSearchActive] = useState(false);
28
36
  const items = useMemo(() => getNavScheme(isUrlActive, currentUrl, isPlayground), [isUrlActive, currentUrl, isPlayground]);
29
37
  const headerRef = useRef(null);
30
38
  useImperativeHandle(forwardedRef, () => headerRef.current);
@@ -32,8 +40,39 @@ const Header = forwardRef(({
32
40
  setIsMenuPopupVisible((headerRef.current?.getBoundingClientRect?.().width ?? 0) <= MENU_POPUP_BREAKPOINT);
33
41
  }, [headerRef]);
34
42
  useResizeObserver(headerRef, entry => setIsMenuPopupVisible(entry.contentRect.width <= MENU_POPUP_BREAKPOINT));
43
+ const handleSearchButtonClick = useCallback(() => {
44
+ setSearchBoxVisible(!isSearchBoxVisible);
45
+ }, []);
46
+ const handleSearchClose = useCallback(() => {
47
+ setSearchBoxVisible(false);
48
+ setFullSearchActive(false);
49
+ }, []);
50
+ const fullSearchKeyHandler = useCallback(event => {
51
+ const isMacOsHotkeyPressed = isMacOs() && event.keyCode === KEY_K_CODE && event.metaKey;
52
+ const isOtherPlatformsHotkeyPressed = !isMacOs() && event.keyCode === KEY_K_CODE && event.ctrlKey;
53
+
54
+ if (isMacOsHotkeyPressed || isOtherPlatformsHotkeyPressed) {
55
+ event.preventDefault();
56
+ event.stopPropagation();
57
+ setSearchBoxVisible(true);
58
+ setFullSearchActive(true);
59
+ }
60
+ }, []);
61
+ useEffect(() => {
62
+ if (typeof document !== `undefined`) {
63
+ document.addEventListener('keydown', fullSearchKeyHandler);
64
+ document.addEventListener('DOMContentLoaded', () => {
65
+ new FocusManager();
66
+ });
67
+ return () => {
68
+ document.removeEventListener('keydown', fullSearchKeyHandler);
69
+ };
70
+ }
71
+ }, [fullSearchKeyHandler]);
35
72
  return React__default.createElement(ThemeProvider, {
36
73
  theme: 'dark'
74
+ }, React__default.createElement(SearchWrapper, {
75
+ searchConfig: searchConfig
37
76
  }, React__default.createElement("header", {
38
77
  ref: headerRef,
39
78
  className: classNames(styles.headerMenu, className, {
@@ -45,19 +84,26 @@ const Header = forwardRef(({
45
84
  homeUrl: currentUrl
46
85
  }) : React__default.createElement(LogoLarge, {
47
86
  productWebUrl: productWebUrl
48
- }), !isMenuPopupVisible && React__default.createElement(HorizontalMenu, {
87
+ }), isSearchBoxVisible ? React__default.createElement(OutsideClickHandler, {
88
+ onOutsideClick: handleSearchClose
89
+ }, React__default.createElement(SearchBox, {
90
+ closeHandler: handleSearchClose,
91
+ isMobile: isMenuPopupVisible,
92
+ fullSearchActive: fullSearchActive,
93
+ setFullSearchActive: setFullSearchActive
94
+ })) : React__default.createElement(React__default.Fragment, null, !isMenuPopupVisible && React__default.createElement(HorizontalMenu, {
49
95
  items: items,
50
96
  theme: dropdownTheme,
51
97
  linkHandler: linkHandler
52
98
  }), React__default.createElement(SearchButton, {
53
- onClick: onSearchClick,
54
- isActive: hasSearch && !!onSearchClick
99
+ onClick: handleSearchButtonClick,
100
+ isActive: hasSearch
55
101
  }), isMenuPopupVisible && React__default.createElement(MenuPopup, {
56
102
  items: items,
57
103
  setExpand: setMenuPopupExpanded,
58
104
  isExpanded: menuPopupExpanded,
59
105
  headerRef: headerRef,
60
106
  linkHandler: linkHandler
61
- })));
107
+ })))));
62
108
  });
63
109
  export { Header };
@@ -272,6 +272,265 @@
272
272
  }
273
273
  }
274
274
 
275
+ .ktl-result-module_result_EKhUw {
276
+ box-sizing: border-box;
277
+ display: block;
278
+ padding: 16px 32px;
279
+ text-decoration: none;
280
+ }
281
+ .ktl-result-module_result_EKhUw:hover {
282
+ background: rgba(255, 255, 255, 0.1);
283
+ text-decoration: none;
284
+ }
285
+ .ktl-result-module_result_EKhUw:focus {
286
+ outline: none;
287
+ background: rgba(255, 255, 255, 0.1);
288
+ }
289
+ .ktl-result-module_result_EKhUw em {
290
+ background-color: rgba(127,82,255,0.3);
291
+ font-style: normal;
292
+ }
293
+
294
+ .ktl-result-module_resultTitle_DSpAT {
295
+ margin-bottom: 6px;
296
+ }
297
+
298
+ .ktl-result-module_text_fWBKG {
299
+ display: -webkit-box;
300
+ -webkit-line-clamp: 2;
301
+ -webkit-box-orient: vertical;
302
+ overflow: hidden;
303
+ }
304
+ .ktl-list-module_results_LlxqY {
305
+ box-sizing: border-box;
306
+ max-height: 305px;
307
+ border: 1px solid rgba(255, 255, 255, 0.2);
308
+ background: #323236;
309
+ color: #fff;
310
+ overflow-y: scroll;
311
+ }
312
+
313
+ .ktl-list-module_topBar_OO0XT {
314
+ display: none;
315
+ }
316
+
317
+ .ktl-list-module_advancedSearch_XNy88 {
318
+ display: inline-block;
319
+ background: transparent;
320
+ border: 0;
321
+ padding: 6px 16px;
322
+ border-radius: 24px;
323
+ cursor: pointer;
324
+ flex-shrink: 0;
325
+ }
326
+
327
+ .ktl-list-module_advancedSearch_XNy88:hover {
328
+ background: rgba(255, 255, 255, .1);
329
+ }
330
+
331
+ .ktl-list-module_advancedSearch_XNy88:focus {
332
+ outline: none;
333
+ box-shadow: rgba(107, 87, 255, 0.8) 0 0 0 4px;
334
+ }
335
+
336
+ .ktl-list-module_advancedSearchTitle_sHR3T {
337
+ color: #ffffff;
338
+ }
339
+
340
+ @media (min-width: 768px) {
341
+ .ktl-list-module_results_LlxqY {
342
+ max-height: 434px;
343
+ }
344
+
345
+ .ktl-list-module_topBar_OO0XT {
346
+ display: flex;
347
+ align-items: center;
348
+ justify-content: space-between;
349
+ padding: 34px 32px 14px 32px;
350
+ }
351
+ }
352
+ .ktl-empty-module_empty_xh1i- {
353
+ box-sizing: border-box;
354
+ border: 1px solid rgba(255, 255, 255, 0.2);
355
+ background: #323236;
356
+ padding: 32px;
357
+ }
358
+ .ktl-loading-module_loading_CtOhW {
359
+ box-sizing: border-box;
360
+ height: 92px;
361
+ border: 1px solid rgba(255, 255, 255, 0.2);
362
+ background: #323236;
363
+ display: flex;
364
+ justify-content: center;
365
+ align-items: center;
366
+ text-align: left;
367
+ }
368
+ .ktl-loading-module_loading_CtOhW > svg {
369
+ fill: #6B57FF;
370
+ }
371
+ .ktl-quick-search-module_wrapper_kkbQQ {
372
+ box-sizing: border-box;
373
+ position: absolute;
374
+ left: 8px;
375
+ right: 8px;
376
+ bottom: -8px;
377
+ transform: translateY(100%);
378
+ }
379
+
380
+ @media (min-width: 768px) {
381
+ .ktl-quick-search-module_wrapper_kkbQQ {
382
+ left: 0;
383
+ right: 0;
384
+ }
385
+ }
386
+ .ktl-full-search-module_fullSearch_MTU8t {
387
+ display: none;
388
+ box-sizing: border-box;
389
+ position: fixed;
390
+ width: 100%;
391
+ height: 100%;
392
+ top: 0;
393
+ left: 0;
394
+ background: #ffffff;
395
+ overflow: scroll;
396
+ }
397
+
398
+ .ktl-full-search-module_closeSearch_5vYDG {
399
+ padding: 0;
400
+ margin: 0;
401
+ border: 0;
402
+ background: none;
403
+ cursor: pointer;
404
+ position: absolute;
405
+ top: 40px;
406
+ right: 40px;
407
+ }
408
+
409
+ .ktl-full-search-module_wrapper_9rxXb {
410
+ max-width: 704px;
411
+ margin: 0 auto;
412
+ }
413
+
414
+ .ktl-full-search-module_header_Wltw0 {
415
+ width: 100%;
416
+ padding-top: 120px;
417
+ padding-bottom: 24px;
418
+ position: sticky;
419
+ top: 0;
420
+ left: 0;
421
+ background: #ffffff;
422
+ z-index: 10;
423
+ }
424
+
425
+ .ktl-full-search-module_switcher_o1RgM {
426
+ margin-top: 14px;
427
+ display: flex;
428
+ justify-content: flex-end;
429
+ }
430
+
431
+ .ktl-full-search-module_results_svcSE {
432
+ margin-top: 14px;
433
+ }
434
+
435
+ @media (min-width: 768px) {
436
+ .ktl-full-search-module_fullSearch_MTU8t {
437
+ display: block;
438
+ }
439
+ }
440
+ .ktl-loading-module_loader_B2IQl {
441
+ margin: 24px 0;
442
+ }
443
+ .ktl-loading-module_loader_B2IQl > svg {
444
+ fill: #6B57FF;
445
+ }
446
+ .ktl-empty-module_wrapper_cNB8Y {
447
+ display: block;
448
+ }
449
+
450
+ .ktl-empty-module_title_p2FMj {
451
+ margin-bottom: 24px;
452
+ }
453
+
454
+ .ktl-empty-module_image_6Xr6L {
455
+ display: flex;
456
+ justify-content: flex-end;
457
+ margin-top: 16px;
458
+ }
459
+ .ktl-chapters-module_chapters_J0wLB {
460
+ border-left: 1px solid var(--ktl-light-dark-20);
461
+ padding-left: 12px;
462
+ margin-top: 24px;
463
+ }
464
+
465
+ .ktl-chapters-module_chapterTitle_b6Rdz {
466
+ //border-bottom-color: transparent;
467
+ }
468
+
469
+ .ktl-chapters-module_chapterTitle_b6Rdz:hover {
470
+ //border-bottom-color: #19191C;
471
+ }
472
+
473
+ .ktl-chapters-module_chapterTitle_b6Rdz em {
474
+ background: rgba(127, 82, 255, 0.2);
475
+ font-style: normal;
476
+ }
477
+
478
+ .ktl-chapters-module_singleChapter_zSmx2:not(:last-child) {
479
+ margin-bottom: 12px;
480
+ }
481
+
482
+ .ktl-chapters-module_headliner_ZBuf9 {
483
+ margin: 0;
484
+ }
485
+
486
+ .ktl-chapters-module_snippet_yROJo {
487
+ margin-top: 8px;
488
+ color: rgba(39, 40, 44, 0.7);
489
+ }
490
+
491
+ .ktl-chapters-module_snippet_yROJo em {
492
+ background: rgba(127, 82, 255, 0.2);
493
+ font-style: normal;
494
+ }
495
+
496
+ .ktl-chapters-module_extraSection_lsZfw {
497
+ display: none;
498
+ }
499
+
500
+ .ktl-chapters-module_visibleSection_wQyvM {
501
+ display: block;
502
+ }
503
+
504
+ .ktl-chapters-module_moreButton_98oqy {
505
+ margin-top: 12px;
506
+ }
507
+ .ktl-hit-list-module_hitList_1MP6m {
508
+ margin: 24px 0;
509
+ }
510
+
511
+ .ktl-hit-list-module_titleLink_rdJ6u em {
512
+ background: rgba(127, 82, 255, 0.2);
513
+ font-style: normal;
514
+ }
515
+
516
+ .ktl-search-box-module_searchBox_0SgE9 {
517
+ position: relative;
518
+ width: 408px;
519
+ }
520
+
521
+ @media (max-width: 767px) {
522
+ .ktl-search-box-module_searchBox_0SgE9 {
523
+ background: var(--ktl-dark-100);
524
+ width: auto;
525
+ position: absolute;
526
+ top: 0;
527
+ left: 0;
528
+ right: 0;
529
+ bottom: 0;
530
+ padding: 4px;
531
+ }
532
+ }
533
+
275
534
  :root {
276
535
  --ktl-light-grey: #f4f4f4;
277
536
  --ktl-dark-100: rgba(39, 40, 44, 1);
@@ -0,0 +1,5 @@
1
+ function isMacOs() {
2
+ return window.navigator.appVersion.indexOf('Mac') !== -1;
3
+ }
4
+
5
+ export { isMacOs };
@@ -0,0 +1,3 @@
1
+ const ESC_CODE = 27;
2
+ const KEY_K_CODE = 75;
3
+ export { ESC_CODE, KEY_K_CODE };
@@ -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,4 @@
1
+ var styles = {
2
+ "empty": "ktl-empty-module_empty_xh1i-"
3
+ };
4
+ export { styles as default };
@@ -0,0 +1,32 @@
1
+ import React__default, { useMemo } from 'react';
2
+ import { Result } from '../result/result.js';
3
+ import { useTextStyles } from '@rescui/typography';
4
+ import classNames from 'classnames';
5
+ import { isMacOs } from '../../is-macos.js';
6
+ import styles from './list.module.pcss.js';
7
+
8
+ const ResultsList = ({
9
+ results,
10
+ searchString,
11
+ toggleFullSearch
12
+ }) => {
13
+ const textCn = useTextStyles();
14
+ const controlledSearchString = useMemo(() => searchString.length > 5 ? `${searchString.substring(0, 5)}...` : searchString, [searchString]);
15
+ return React__default.createElement("div", {
16
+ className: styles.results
17
+ }, results.length ? React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
18
+ className: styles.topBar
19
+ }, React__default.createElement("div", {
20
+ className: textCn('rs-text-3')
21
+ }, "Showing results for \u00AB", controlledSearchString, "\u00BB"), React__default.createElement("button", {
22
+ className: styles.advancedSearch,
23
+ onClick: toggleFullSearch
24
+ }, React__default.createElement("div", {
25
+ className: classNames(textCn('rs-text-3'), styles.advancedSearchTitle)
26
+ }, "Advanced search ", isMacOs() ? '⌘K' : 'Ctrl+K'))), results.map((searchResult, index) => React__default.createElement(Result, {
27
+ key: index,
28
+ hit: searchResult
29
+ }))) : null);
30
+ };
31
+
32
+ export { ResultsList };
@@ -0,0 +1,7 @@
1
+ var styles = {
2
+ "results": "ktl-list-module_results_LlxqY",
3
+ "topBar": "ktl-list-module_topBar_OO0XT",
4
+ "advancedSearch": "ktl-list-module_advancedSearch_XNy88",
5
+ "advancedSearchTitle": "ktl-list-module_advancedSearchTitle_sHR3T"
6
+ };
7
+ export { styles as default };