@redocly/theme 0.42.3 → 0.44.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.
Files changed (179) hide show
  1. package/lib/components/Buttons/CopyButton.js +2 -2
  2. package/lib/components/Buttons/EditPageButton.js +1 -1
  3. package/lib/components/Catalog/CatalogActions.js +1 -1
  4. package/lib/components/Dropdown/DropdownMenu.d.ts +2 -0
  5. package/lib/components/Dropdown/DropdownMenu.js +3 -1
  6. package/lib/components/Feedback/Comment.js +6 -6
  7. package/lib/components/Feedback/Mood.js +7 -7
  8. package/lib/components/Feedback/Rating.js +4 -4
  9. package/lib/components/Feedback/Reasons.js +3 -3
  10. package/lib/components/Feedback/Scale.js +10 -10
  11. package/lib/components/Feedback/Sentiment.js +5 -5
  12. package/lib/components/Filter/FilterContent.js +2 -2
  13. package/lib/components/Filter/FilterInput.js +1 -1
  14. package/lib/components/Filter/FilterPopover.js +2 -2
  15. package/lib/components/Filter/FilterSelect.js +1 -1
  16. package/lib/components/Footer/FooterCopyright.js +2 -2
  17. package/lib/components/LastUpdated/LastUpdated.js +1 -1
  18. package/lib/components/Loaders/SpinnerLoader.d.ts +5 -0
  19. package/lib/components/Loaders/SpinnerLoader.js +32 -0
  20. package/lib/components/PageNavigation/NextButton.js +1 -1
  21. package/lib/components/PageNavigation/PreviousButton.js +1 -1
  22. package/lib/components/Product/ProductPicker.js +1 -1
  23. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.d.ts +12 -0
  24. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +113 -0
  25. package/lib/components/Search/FilterFields/SearchFilterFieldTags.d.ts +10 -0
  26. package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +37 -0
  27. package/lib/components/Search/Search.js +1 -1
  28. package/lib/components/Search/SearchDialog.js +113 -31
  29. package/lib/components/Search/SearchFilter.d.ts +11 -0
  30. package/lib/components/Search/SearchFilter.js +71 -0
  31. package/lib/components/Search/SearchFilterField.d.ts +11 -0
  32. package/lib/components/Search/SearchFilterField.js +43 -0
  33. package/lib/components/Search/SearchGroups.d.ts +9 -0
  34. package/lib/components/Search/SearchGroups.js +69 -0
  35. package/lib/components/Search/SearchHighlight.d.ts +1 -1
  36. package/lib/components/Search/SearchHighlight.js +28 -5
  37. package/lib/components/Search/SearchInput.d.ts +1 -1
  38. package/lib/components/Search/SearchInput.js +5 -2
  39. package/lib/components/Search/SearchItem.d.ts +2 -2
  40. package/lib/components/Search/SearchItem.js +24 -15
  41. package/lib/components/Search/SearchRecent.js +1 -1
  42. package/lib/components/Search/SearchSuggestedPages.js +1 -1
  43. package/lib/components/Search/SearchTrigger.js +2 -2
  44. package/lib/components/Search/variables.js +48 -2
  45. package/lib/components/Segmented/Segmented.d.ts +2 -5
  46. package/lib/components/Select/Select.d.ts +2 -36
  47. package/lib/components/Select/Select.js +136 -98
  48. package/lib/components/Select/SelectInput.d.ts +23 -0
  49. package/lib/components/Select/SelectInput.js +129 -0
  50. package/lib/components/Select/variables.js +12 -1
  51. package/lib/components/SidebarActions/ChangeViewButton.js +1 -1
  52. package/lib/components/SidebarActions/SidebarActions.js +2 -2
  53. package/lib/components/TableOfContent/TableOfContent.js +1 -1
  54. package/lib/components/Tag/Tag.d.ts +4 -2
  55. package/lib/components/Tag/Tag.js +40 -4
  56. package/lib/components/Tag/variables.dark.js +20 -5
  57. package/lib/components/Tag/variables.js +49 -17
  58. package/lib/components/UserMenu/LoginButton.js +1 -1
  59. package/lib/components/UserMenu/LogoutMenuItem.js +1 -1
  60. package/lib/components/UserMenu/UserMenu.js +1 -1
  61. package/lib/components/VersionPicker/VersionPicker.d.ts +2 -3
  62. package/lib/components/VersionPicker/VersionPicker.js +14 -31
  63. package/lib/core/hooks/__mocks__/index.d.ts +2 -1
  64. package/lib/core/hooks/__mocks__/index.js +2 -1
  65. package/lib/core/hooks/__mocks__/search/use-search-filter.d.ts +9 -0
  66. package/lib/core/hooks/__mocks__/search/use-search-filter.js +14 -0
  67. package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +6 -1
  68. package/lib/core/hooks/__mocks__/use-theme-hooks.js +6 -1
  69. package/lib/core/hooks/feedback/use-report-dialog.js +3 -3
  70. package/lib/core/hooks/index.d.ts +2 -1
  71. package/lib/core/hooks/index.js +2 -1
  72. package/lib/core/hooks/menu/use-mobile-menu-items.js +1 -1
  73. package/lib/core/hooks/menu/use-mobile-menu-levels.js +2 -2
  74. package/lib/core/hooks/search/use-recent-searches.js +2 -0
  75. package/lib/core/hooks/{use-search.d.ts → search/use-search-dialog.d.ts} +1 -1
  76. package/lib/core/hooks/{use-search.js → search/use-search-dialog.js} +5 -5
  77. package/lib/core/hooks/search/use-search-filter.d.ts +9 -0
  78. package/lib/core/hooks/search/use-search-filter.js +50 -0
  79. package/lib/core/types/hooks.d.ts +17 -4
  80. package/lib/core/types/index.d.ts +1 -1
  81. package/lib/core/types/index.js +1 -1
  82. package/lib/core/types/l10n.d.ts +1 -2
  83. package/lib/core/types/search.d.ts +42 -2
  84. package/lib/core/types/select.d.ts +31 -0
  85. package/lib/core/types/{select-option.js → select.js} +1 -1
  86. package/lib/core/utils/index.d.ts +1 -0
  87. package/lib/core/utils/index.js +1 -0
  88. package/lib/core/utils/menu.js +1 -1
  89. package/lib/core/utils/text-trimmer.d.ts +1 -0
  90. package/lib/core/utils/text-trimmer.js +16 -0
  91. package/lib/icons/ResetIcon/ResetIcon.d.ts +9 -0
  92. package/lib/icons/ResetIcon/ResetIcon.js +22 -0
  93. package/lib/icons/SettingsIcon/SettingsIcon.d.ts +9 -0
  94. package/lib/icons/SettingsIcon/SettingsIcon.js +23 -0
  95. package/lib/index.d.ts +8 -1
  96. package/lib/index.js +8 -1
  97. package/lib/layouts/Forbidden.js +2 -2
  98. package/lib/layouts/NotFound.js +3 -3
  99. package/lib/layouts/OIDCForbidden.js +1 -1
  100. package/lib/markdoc/tags/partial.js +1 -1
  101. package/package.json +9 -9
  102. package/src/components/Buttons/CopyButton.tsx +2 -2
  103. package/src/components/Buttons/EditPageButton.tsx +2 -2
  104. package/src/components/Catalog/CatalogActions.tsx +2 -2
  105. package/src/components/Dropdown/DropdownMenu.tsx +2 -1
  106. package/src/components/Feedback/Comment.tsx +8 -8
  107. package/src/components/Feedback/Mood.tsx +8 -8
  108. package/src/components/Feedback/Rating.tsx +5 -5
  109. package/src/components/Feedback/Reasons.tsx +4 -4
  110. package/src/components/Feedback/Scale.tsx +13 -13
  111. package/src/components/Feedback/Sentiment.tsx +6 -6
  112. package/src/components/Filter/FilterContent.tsx +3 -3
  113. package/src/components/Filter/FilterInput.tsx +1 -1
  114. package/src/components/Filter/FilterPopover.tsx +3 -3
  115. package/src/components/Filter/FilterSelect.tsx +5 -5
  116. package/src/components/Footer/FooterCopyright.tsx +3 -3
  117. package/src/components/LastUpdated/LastUpdated.tsx +1 -2
  118. package/src/components/Loaders/SpinnerLoader.tsx +31 -0
  119. package/src/components/PageNavigation/NextButton.tsx +1 -1
  120. package/src/components/PageNavigation/PreviousButton.tsx +1 -1
  121. package/src/components/Product/ProductPicker.tsx +2 -2
  122. package/src/components/Search/FilterFields/SearchFilterFieldSelect.tsx +135 -0
  123. package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +61 -0
  124. package/src/components/Search/Search.tsx +2 -2
  125. package/src/components/Search/SearchDialog.tsx +190 -51
  126. package/src/components/Search/SearchFilter.tsx +90 -0
  127. package/src/components/Search/SearchFilterField.tsx +84 -0
  128. package/src/components/Search/SearchGroups.tsx +81 -0
  129. package/src/components/Search/SearchHighlight.tsx +29 -2
  130. package/src/components/Search/SearchInput.tsx +9 -3
  131. package/src/components/Search/SearchItem.tsx +39 -24
  132. package/src/components/Search/SearchRecent.tsx +2 -2
  133. package/src/components/Search/SearchSuggestedPages.tsx +2 -2
  134. package/src/components/Search/SearchTrigger.tsx +2 -2
  135. package/src/components/Search/variables.ts +48 -2
  136. package/src/components/Segmented/Segmented.tsx +2 -2
  137. package/src/components/Select/Select.tsx +208 -157
  138. package/src/components/Select/SelectInput.tsx +201 -0
  139. package/src/components/Select/variables.ts +12 -1
  140. package/src/components/SidebarActions/ChangeViewButton.tsx +1 -1
  141. package/src/components/SidebarActions/SidebarActions.tsx +2 -2
  142. package/src/components/TableOfContent/TableOfContent.tsx +2 -2
  143. package/src/components/Tag/Tag.tsx +57 -6
  144. package/src/components/Tag/variables.dark.ts +20 -5
  145. package/src/components/Tag/variables.ts +49 -17
  146. package/src/components/UserMenu/LoginButton.tsx +2 -2
  147. package/src/components/UserMenu/LogoutMenuItem.tsx +2 -2
  148. package/src/components/UserMenu/UserMenu.tsx +2 -2
  149. package/src/components/VersionPicker/VersionPicker.tsx +18 -42
  150. package/src/core/hooks/__mocks__/index.ts +2 -1
  151. package/src/core/hooks/__mocks__/search/use-search-filter.ts +10 -0
  152. package/src/core/hooks/__mocks__/use-theme-hooks.ts +6 -1
  153. package/src/core/hooks/feedback/use-report-dialog.ts +3 -3
  154. package/src/core/hooks/index.ts +2 -1
  155. package/src/core/hooks/menu/use-mobile-menu-items.ts +1 -1
  156. package/src/core/hooks/menu/use-mobile-menu-levels.ts +2 -2
  157. package/src/core/hooks/search/use-recent-searches.ts +3 -0
  158. package/src/core/hooks/{use-search.ts → search/use-search-dialog.ts} +1 -1
  159. package/src/core/hooks/search/use-search-filter.ts +57 -0
  160. package/src/core/types/hooks.ts +25 -4
  161. package/src/core/types/index.ts +1 -1
  162. package/src/core/types/l10n.ts +169 -97
  163. package/src/core/types/search.ts +53 -2
  164. package/src/core/types/select.ts +33 -0
  165. package/src/core/utils/index.ts +1 -0
  166. package/src/core/utils/menu.ts +1 -1
  167. package/src/core/utils/text-trimmer.ts +7 -0
  168. package/src/icons/ResetIcon/ResetIcon.tsx +26 -0
  169. package/src/icons/SettingsIcon/SettingsIcon.tsx +30 -0
  170. package/src/index.ts +8 -1
  171. package/src/layouts/Forbidden.tsx +4 -9
  172. package/src/layouts/NotFound.tsx +6 -6
  173. package/src/layouts/OIDCForbidden.tsx +2 -2
  174. package/src/markdoc/tags/partial.ts +1 -1
  175. package/lib/core/types/select-option.d.ts +0 -4
  176. package/src/core/types/select-option.ts +0 -4
  177. /package/lib/components/{Loading → Loaders}/Loading.d.ts +0 -0
  178. /package/lib/components/{Loading → Loaders}/Loading.js +0 -0
  179. /package/src/components/{Loading → Loaders}/Loading.tsx +0 -0
@@ -39,12 +39,17 @@ const SearchSuggestedPages_1 = require("../../components/Search/SearchSuggestedP
39
39
  const hooks_1 = require("../../core/hooks");
40
40
  const Tag_1 = require("../../components/Tag/Tag");
41
41
  const CloseIcon_1 = require("../../icons/CloseIcon/CloseIcon");
42
+ const SearchFilter_1 = require("../../components/Search/SearchFilter");
43
+ const SearchGroups_1 = require("../../components/Search/SearchGroups");
44
+ const SpinnerLoader_1 = require("../../components/Loaders/SpinnerLoader");
45
+ const SettingsIcon_1 = require("../../icons/SettingsIcon/SettingsIcon");
42
46
  function SearchDialog({ onClose, className }) {
43
- const { useTranslate, useCurrentProduct, useFuseSearch, useProducts } = (0, hooks_1.useThemeHooks)();
47
+ const { useTranslate, useCurrentProduct, useSearch, useProducts } = (0, hooks_1.useThemeHooks)();
44
48
  const products = useProducts();
45
49
  const currentProduct = useCurrentProduct();
46
50
  const [product, setProduct] = (0, react_1.useState)(currentProduct);
47
- const { query, setQuery, items, isLoading } = useFuseSearch(product === null || product === void 0 ? void 0 : product.name);
51
+ const { query, setQuery, filter, setFilter, items, isSearchLoading, facets, setLoadMore, advancedSearch, } = useSearch(product === null || product === void 0 ? void 0 : product.name);
52
+ const { isFilterOpen, onFilterToggle, onFilterChange, onFilterReset, onFacetReset, onTopFacetsReset, } = (0, hooks_1.useSearchFilter)(filter, setFilter);
48
53
  const modalRef = (0, react_1.useRef)(null);
49
54
  const { translate } = useTranslate();
50
55
  (0, hooks_1.useDialogHotKeys)(modalRef, onClose);
@@ -57,32 +62,68 @@ function SearchDialog({ onClose, className }) {
57
62
  onClose();
58
63
  }
59
64
  };
60
- const mapItem = (item) => {
65
+ const mapItem = (item, index) => {
61
66
  let itemProduct;
62
- if (!product && item.product) {
63
- const resolvedProduct = products.find((product) => { var _a; return product.slug.match(`/${(_a = item.product) === null || _a === void 0 ? void 0 : _a.folder}/`); });
67
+ if (!product && item.document.product) {
68
+ const resolvedProduct = products.find((product) => { var _a; return product.slug.match(`/${(_a = item.document.product) === null || _a === void 0 ? void 0 : _a.folder}/`); });
64
69
  itemProduct = resolvedProduct
65
70
  ? { name: resolvedProduct.name, icon: resolvedProduct.icon }
66
71
  : undefined;
67
72
  }
68
- return react_1.default.createElement(SearchItem_1.SearchItem, { key: item.id, item: item, product: itemProduct });
73
+ return react_1.default.createElement(SearchItem_1.SearchItem, { key: `${index}-${item.document.id}`, item: item, product: itemProduct });
69
74
  };
75
+ const showLoadMore = (groupKey, currentCount = 0) => {
76
+ const topFacet = facets.find((facet) => facet.isTop);
77
+ let needLoadMore = false;
78
+ if (topFacet) {
79
+ const groupValue = topFacet.values.find((value) => {
80
+ if (typeof value === 'object') {
81
+ return value.value === groupKey;
82
+ }
83
+ else
84
+ return false;
85
+ });
86
+ needLoadMore = groupValue ? groupValue.count > currentCount : false;
87
+ }
88
+ return needLoadMore;
89
+ };
90
+ const showResults = !!((filter && filter.length) || query);
70
91
  return (react_1.default.createElement(SearchOverlay, { "data-component-name": "Search/SearchDialog", ref: modalRef, onClick: handleOverlayClick, className: (0, utils_1.concatClassNames)('overlay', className) },
71
92
  react_1.default.createElement(SearchDialogWrapper, { className: "scroll-lock", role: "dialog" },
72
93
  react_1.default.createElement(SearchDialogHeader, null,
73
- react_1.default.createElement(SearchInput_1.SearchInput, { value: query, onChange: setQuery, placeholder: translate('theme.search.label', 'Search docs...'), isLoading: isLoading, "data-translation-key": "theme.search.label" }),
74
- product && (react_1.default.createElement(SearchProductTag, { color: "product" },
75
- product.name,
76
- react_1.default.createElement(CloseIcon_1.CloseIcon, { onClick: () => setProduct(undefined), color: "--icon-color-additional" })))),
77
- react_1.default.createElement(SearchDialogBody, null, items !== null ? (items.length ? (items.map(mapItem)) : (react_1.default.createElement(SearchMessage, { "data-translation-key": "theme.search.noResults" }, translate('theme.search.noResults', 'No results')))) : (react_1.default.createElement(react_1.default.Fragment, null,
78
- react_1.default.createElement(SearchRecent_1.SearchRecent, { onSelect: setQuery }),
79
- react_1.default.createElement(SearchSuggestedPages_1.SearchSuggestedPages, null)))),
94
+ product && (react_1.default.createElement(react_1.default.Fragment, null,
95
+ react_1.default.createElement(SearchProductTag, { color: "product" },
96
+ product.name,
97
+ react_1.default.createElement(CloseIcon_1.CloseIcon, { onClick: () => setProduct(undefined), color: "--icon-color-additional" })))),
98
+ react_1.default.createElement(SearchInput_1.SearchInput, { value: query, onChange: setQuery, placeholder: translate('search.label', 'Search docs...'), isLoading: isSearchLoading, "data-translation-key": "search.label" }),
99
+ advancedSearch && (react_1.default.createElement(SearchFilterToggleButton, { icon: react_1.default.createElement(SettingsIcon_1.SettingsIcon, null), onClick: onFilterToggle }))),
100
+ react_1.default.createElement(SearchDialogBody, null,
101
+ react_1.default.createElement(SearchDialogBodyMainView, null,
102
+ react_1.default.createElement(SearchGroups_1.SearchGroups, { facets: facets, searchFilter: filter, onFilterChange: onFilterChange, onTopFacetsReset: onTopFacetsReset }),
103
+ showResults ? (items && Object.keys(items).some((key) => { var _a; return (_a = items[key]) === null || _a === void 0 ? void 0 : _a.length; }) ? (Object.keys(items).map((key) => {
104
+ var _a, _b, _c;
105
+ return ((_a = items[key]) === null || _a === void 0 ? void 0 : _a.length) ? (react_1.default.createElement(react_1.Fragment, { key: key },
106
+ react_1.default.createElement(SearchGroupTitle, null, key), (_b = items[key]) === null || _b === void 0 ? void 0 :
107
+ _b.map(mapItem),
108
+ showLoadMore(key, ((_c = items[key]) === null || _c === void 0 ? void 0 : _c.length) || 0) && (react_1.default.createElement(SearchGroupFooter, { "data-translation-key": "search.showMore", onClick: () => { var _a; return setLoadMore({ groupKey: key, offset: ((_a = items[key]) === null || _a === void 0 ? void 0 : _a.length) || 0 }); } }, translate('search.showMore', 'Show more'))))) : null;
109
+ })) : isSearchLoading ? (react_1.default.createElement(SearchMessage, null,
110
+ react_1.default.createElement(SpinnerLoader_1.SpinnerLoader, { size: "26px", color: "var(--search-input-icon-color)" }),
111
+ translate('search.loading', 'Loading...'))) : (react_1.default.createElement(SearchMessage, { "data-translation-key": "search.noResults" },
112
+ react_1.default.createElement("b", null, translate('search.noResults.title', 'No results')),
113
+ translate('search.noResults.description', 'Prease, try with a different query.')))) : (react_1.default.createElement(react_1.default.Fragment, null,
114
+ react_1.default.createElement(SearchRecent_1.SearchRecent, { onSelect: setQuery }),
115
+ react_1.default.createElement(SearchSuggestedPages_1.SearchSuggestedPages, null)))),
116
+ advancedSearch && isFilterOpen && (react_1.default.createElement(SearchDialogBodyFilterView, null,
117
+ react_1.default.createElement(SearchFilter_1.SearchFilter, { facets: facets, filter: filter, query: query, onFilterChange: onFilterChange, onFilterReset: onFilterReset, onFacetReset: onFacetReset })))),
80
118
  react_1.default.createElement(SearchDialogFooter, null,
81
119
  react_1.default.createElement(SearchShortcuts, null,
82
- react_1.default.createElement(SearchShortcut_1.SearchShortcut, { "data-translation-key": "theme.search.keys.navigate", combination: "Tab", text: translate('theme.search.keys.navigate', 'to navigate') }),
83
- react_1.default.createElement(SearchShortcut_1.SearchShortcut, { "data-translation-key": "theme.search.keys.select", combination: "\u23CE", text: translate('theme.search.keys.select', 'to select') }),
84
- react_1.default.createElement(SearchShortcut_1.SearchShortcut, { "data-translation-key": "theme.search.keys.exit", combination: "Esc", text: translate('theme.search.keys.exit', 'to exit') })),
85
- react_1.default.createElement(SearchCancelButton, { "data-translation-key": "theme.search.cancel", variant: "secondary", size: "small", onClick: onClose }, translate('theme.search.cancel', 'Cancel'))))));
120
+ react_1.default.createElement(SearchShortcut_1.SearchShortcut, { "data-translation-key": "search.keys.navigate", combination: "Tab", text: translate('search.keys.navigate', 'to navigate') }),
121
+ react_1.default.createElement(SearchShortcut_1.SearchShortcut, { "data-translation-key": "search.keys.select", combination: "\u23CE", text: translate('search.keys.select', 'to select') }),
122
+ react_1.default.createElement(SearchShortcut_1.SearchShortcut, { "data-translation-key": "search.keys.exit", combination: "Esc", text: translate('search.keys.exit', 'to exit') })),
123
+ isSearchLoading && (react_1.default.createElement(SearchLoading, null,
124
+ react_1.default.createElement(SpinnerLoader_1.SpinnerLoader, { size: "16px", color: "var(--search-input-icon-color)" }),
125
+ translate('search.loading', 'Loading...'))),
126
+ react_1.default.createElement(SearchCancelButton, { "data-translation-key": "search.cancel", variant: "secondary", size: "small", onClick: onClose }, translate('search.cancel', 'Cancel'))))));
86
127
  }
87
128
  exports.SearchDialog = SearchDialog;
88
129
  const SearchOverlay = styled_components_1.default.div `
@@ -100,7 +141,6 @@ const SearchOverlay = styled_components_1.default.div `
100
141
  const SearchDialogWrapper = styled_components_1.default.div `
101
142
  display: flex;
102
143
  flex-direction: column;
103
- justify-content: space-between;
104
144
  overflow: auto;
105
145
  width: 100vw;
106
146
  height: 100vh;
@@ -116,49 +156,70 @@ const SearchDialogWrapper = styled_components_1.default.div `
116
156
  max-height: 95vh;
117
157
  height: auto;
118
158
  resize: both;
119
- min-width: 300px;
120
- min-height: 200px;
121
159
  }
122
160
  `;
123
161
  const SearchDialogHeader = styled_components_1.default.header `
124
162
  display: flex;
125
163
  align-items: center;
126
- border-bottom: 1px solid var(--border-color-secondary);
127
- background-color: var(--search-input-bg-color);
128
- padding: var(--spacing-sm);
164
+ border-bottom: var(--search-modal-border);
165
+ background-color: var(--search-modal-header-bg-color);
166
+ padding: var(--search-modal-header-padding);
129
167
  `;
130
168
  const SearchDialogBody = styled_components_1.default.div `
169
+ display: flex;
170
+ flex-direction: row;
131
171
  flex-grow: 1;
132
- overflow-y: scroll;
133
- overscroll-behavior: contain;
134
172
 
135
173
  @media screen and (min-width: ${utils_1.breakpoints.small}) {
136
174
  height: var(--search-modal-min-height);
137
175
  }
138
176
  `;
177
+ const SearchDialogBodyMainView = styled_components_1.default.div `
178
+ flex: 2;
179
+ flex-grow: 2;
180
+ overflow-y: scroll;
181
+ overscroll-behavior: contain;
182
+ border-right: var(--search-modal-border);
183
+ `;
184
+ const SearchDialogBodyFilterView = styled_components_1.default.div `
185
+ overflow: scroll;
186
+ `;
139
187
  const SearchDialogFooter = styled_components_1.default.footer `
140
- padding: var(--spacing-sm);
141
- border-top: 1px solid var(--border-color-secondary);
188
+ display: flex;
189
+ gap: var(--search-modal-footer-gap);
190
+ padding: var(--search-modal-footer-padding);
191
+ border-top: var(--search-modal-border);
142
192
  `;
143
193
  const SearchShortcuts = styled_components_1.default.div `
144
194
  display: none;
145
195
  justify-content: flex-start;
146
196
  align-items: center;
147
- gap: var(--spacing-xs);
197
+ gap: var(--search-shortcuts-gap);
148
198
 
149
199
  @media screen and (min-width: ${utils_1.breakpoints.small}) {
150
200
  display: flex;
151
201
  }
152
202
  `;
153
203
  const SearchMessage = styled_components_1.default.div `
154
- padding: var(--spacing-lg);
155
- color: var(--search-item-title-text-color);
204
+ display: flex;
205
+ height: 40%;
206
+ justify-content: center;
207
+ align-items: center;
208
+ flex-direction: column;
209
+ font-size: var(--search-message-font-size);
210
+ font-weight: var(--search-message-font-weight);
211
+ line-height: var(--search-message-line-height);
212
+ color: var(--search-message-text-color);
213
+ gap: var(--search-message-gap);
156
214
  `;
157
215
  const SearchProductTag = (0, styled_components_1.default)(Tag_1.Tag) `
158
216
  --tag-border-radius: var(--border-radius);
159
-
217
+ border: none;
160
218
  margin: var(--spacing-xs) var(--spacing-sm) !important;
161
219
  `;
220
+ const SearchFilterToggleButton = (0, styled_components_1.default)(Button_1.Button) `
221
+ margin-left: 0;
222
+ `;
162
223
  const SearchCancelButton = (0, styled_components_1.default)(Button_1.Button) `
163
224
  width: 100%;
164
225
 
@@ -166,4 +227,25 @@ const SearchCancelButton = (0, styled_components_1.default)(Button_1.Button) `
166
227
  display: none;
167
228
  }
168
229
  `;
230
+ const SearchGroupTitle = styled_components_1.default.div `
231
+ border-bottom: var(--search-modal-border);
232
+ padding: var(--search-group-title-padding);
233
+ background-color: var(--search-group-title-bg-color);
234
+ `;
235
+ const SearchGroupFooter = styled_components_1.default.div `
236
+ display: flex;
237
+ justify-content: center;
238
+ padding: var(--search-group-footer-padding);
239
+ color: var(--search-group-footer-text-color);
240
+ cursor: pointer;
241
+ `;
242
+ const SearchLoading = styled_components_1.default.div `
243
+ display: none;
244
+ align-items: center;
245
+ gap: var(--spacing-xs);
246
+
247
+ @media screen and (min-width: ${utils_1.breakpoints.small}) {
248
+ display: flex;
249
+ }
250
+ `;
169
251
  //# sourceMappingURL=SearchDialog.js.map
@@ -0,0 +1,11 @@
1
+ import type { SearchFilterItem, SearchFacet } from '../../core/types';
2
+ export type SearchFilterProps = {
3
+ className?: string;
4
+ facets: SearchFacet[];
5
+ filter: SearchFilterItem[];
6
+ query: string;
7
+ onFilterChange: (field: string, value: string | string[], isTop?: boolean) => void;
8
+ onFilterReset: () => void;
9
+ onFacetReset: (field: string) => void;
10
+ };
11
+ export declare function SearchFilter({ className, facets, filter, query, onFilterChange, onFilterReset, onFacetReset, }: SearchFilterProps): JSX.Element;
@@ -0,0 +1,71 @@
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.SearchFilter = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Button_1 = require("../../components/Button/Button");
33
+ const CleanIcon_1 = require("../../icons/CleanIcon/CleanIcon");
34
+ const SearchFilterField_1 = require("../../components/Search/SearchFilterField");
35
+ const hooks_1 = require("../../core/hooks");
36
+ function SearchFilter({ className, facets, filter, query, onFilterChange, onFilterReset, onFacetReset, }) {
37
+ const { useTranslate } = (0, hooks_1.useThemeHooks)();
38
+ const { translate } = useTranslate();
39
+ return (React.createElement(SearchFilterWrapper, { "data-component-name": "Search/SearchFilter", className: className },
40
+ React.createElement(SearchFilterHeader, null,
41
+ React.createElement("span", { "data-translation-key": "search.filter.title" }, translate('search.filter.title', 'Advanced filter')),
42
+ React.createElement(Button_1.Button, { "data-translation-key": "search.filter.reset", onClick: onFilterReset, variant: "ghost", icon: React.createElement(CleanIcon_1.CleanIcon, null) }, translate('search.filter.reset', 'Reset filters'))),
43
+ React.createElement(SearchFilterFields, null, facets.map((facet, index) => (React.createElement(SearchFilterField_1.SearchFilterField, { key: `${facet.field}-${index}`, facet: facet, onFilterChange: onFilterChange, onFacetReset: onFacetReset, filter: filter, query: query }))))));
44
+ }
45
+ exports.SearchFilter = SearchFilter;
46
+ const SearchFilterWrapper = styled_components_1.default.div `
47
+ width: var(--search-filter-width);
48
+ display: flex;
49
+ flex-direction: column;
50
+ padding: var(--search-filter-padding);
51
+ font-size: var(--search-filter-font-size);
52
+ font-weight: var(--search-filter-font-weight);
53
+ line-height: var(--search-filter-line-height);
54
+ `;
55
+ const SearchFilterHeader = styled_components_1.default.div `
56
+ position: sticky;
57
+ top: 0px;
58
+ display: flex;
59
+ justify-content: space-between;
60
+ align-items: center;
61
+ padding: var(--search-filter-header-padding);
62
+ color: var(--search-filter-header-text-color);
63
+ background-color: var(--search-filter-bg-color);
64
+ z-index: var(--search-filter-header-z-index);
65
+ `;
66
+ const SearchFilterFields = styled_components_1.default.div `
67
+ display: flex;
68
+ flex-direction: column;
69
+ gap: var(--search-filter-fields-gap);
70
+ `;
71
+ //# sourceMappingURL=SearchFilter.js.map
@@ -0,0 +1,11 @@
1
+ import type { SearchFacet, SearchFilterItem } from '../../core/types';
2
+ type SearchFilterFieldProps = {
3
+ className?: string;
4
+ facet: SearchFacet;
5
+ filter: SearchFilterItem[];
6
+ query: string;
7
+ onFilterChange: (field: string, value: string | string[], isTop?: boolean) => void;
8
+ onFacetReset: (filed: string) => void;
9
+ };
10
+ export declare function SearchFilterField({ className, facet, filter, query, onFilterChange, onFacetReset, }: SearchFilterFieldProps): JSX.Element;
11
+ export {};
@@ -0,0 +1,43 @@
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.SearchFilterField = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const Button_1 = require("../../components/Button/Button");
10
+ const ResetIcon_1 = require("../../icons/ResetIcon/ResetIcon");
11
+ const core_1 = require("../../core");
12
+ const SearchFilterFieldSelect_1 = require("../../components/Search/FilterFields/SearchFilterFieldSelect");
13
+ const SearchFilterFieldTags_1 = require("../../components/Search/FilterFields/SearchFilterFieldTags");
14
+ function SearchFilterField({ className, facet, filter, query, onFilterChange, onFacetReset, }) {
15
+ var _a;
16
+ const { useTranslate } = (0, core_1.useThemeHooks)();
17
+ const { translate } = useTranslate();
18
+ const selectedValues = ((_a = filter.find((item) => item.field === facet.field)) === null || _a === void 0 ? void 0 : _a.values) || [];
19
+ const onChange = (value) => {
20
+ onFilterChange(facet.field, value, facet.isTop);
21
+ };
22
+ const onReset = () => {
23
+ onFacetReset(facet.field);
24
+ };
25
+ return (react_1.default.createElement(FilterFieldWrapper, { "data-component-name": "Search/SearchFilterField", className: className },
26
+ react_1.default.createElement(FilterFieldLabel, null,
27
+ facet.name,
28
+ selectedValues.length > 0 && (react_1.default.createElement(Button_1.Button, { "data-translation-key": "search.filter.field.reset", icon: react_1.default.createElement(ResetIcon_1.ResetIcon, null), variant: "ghost", size: "small", onClick: onReset }, translate('search.filter.field.reset', 'Reset')))),
29
+ ['select', 'multi-select'].includes(facet.type) && (react_1.default.createElement(SearchFilterFieldSelect_1.SearchFilterFieldSelect, { facet: facet, filter: filter, query: query, selectedValues: selectedValues, onChange: onChange })),
30
+ facet.type === 'tags' && (react_1.default.createElement(SearchFilterFieldTags_1.SearchFilterFieldTags, { facet: facet, selectedValues: selectedValues, onChange: onChange }))));
31
+ }
32
+ exports.SearchFilterField = SearchFilterField;
33
+ const FilterFieldWrapper = styled_components_1.default.div `
34
+ display: flex;
35
+ flex-direction: column;
36
+ gap: 4px;
37
+ `;
38
+ const FilterFieldLabel = styled_components_1.default.div `
39
+ display: flex;
40
+ justify-content: space-between;
41
+ align-items: center;
42
+ `;
43
+ //# sourceMappingURL=SearchFilterField.js.map
@@ -0,0 +1,9 @@
1
+ import type { SearchFacet, SearchFilterItem } from '../../index.js';
2
+ type SearchGroupsProps = {
3
+ facets: SearchFacet[];
4
+ searchFilter: SearchFilterItem[];
5
+ onFilterChange: (field: string, value: string[], isTop?: boolean) => void;
6
+ onTopFacetsReset: () => void;
7
+ };
8
+ export declare function SearchGroups({ facets, searchFilter, onFilterChange, onTopFacetsReset, }: SearchGroupsProps): JSX.Element;
9
+ export {};
@@ -0,0 +1,69 @@
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.SearchGroups = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Tag_1 = require("../../components/Tag/Tag");
33
+ function SearchGroups({ facets, searchFilter, onFilterChange, onTopFacetsReset, }) {
34
+ const groupFacets = facets.filter((facet) => facet.isTop);
35
+ const handleGroupTagClick = (value, fieldId, active, currentValues) => {
36
+ const values = active
37
+ ? currentValues.filter((item) => item !== value)
38
+ : [...currentValues, value];
39
+ onFilterChange(fieldId, values, true);
40
+ };
41
+ return (React.createElement(SearchGroupsWrapper, null,
42
+ React.createElement(GroupTag, { borderless: true, active: !searchFilter.some((item) => item.isTop), onClick: () => searchFilter.some((item) => item.isTop) && onTopFacetsReset() }, "All"),
43
+ React.createElement(Divider, null),
44
+ groupFacets.flatMap((facet) => facet.values.map((facetCount, index) => {
45
+ var _a;
46
+ const { value, count, isCounterVisible } = facetCount;
47
+ const currentValues = ((_a = searchFilter.find((item) => item.field === facet.field)) === null || _a === void 0 ? void 0 : _a.values) || [];
48
+ const active = currentValues === null || currentValues === void 0 ? void 0 : currentValues.includes(value);
49
+ return (React.createElement(GroupTag, { key: `${facet.field}-${index}`, onClick: () => handleGroupTagClick(value, facet.field, active, currentValues), active: active, borderless: true },
50
+ value,
51
+ " ",
52
+ isCounterVisible && React.createElement("span", null, count)));
53
+ }))));
54
+ }
55
+ exports.SearchGroups = SearchGroups;
56
+ const SearchGroupsWrapper = styled_components_1.default.div `
57
+ display: flex;
58
+ gap: 4px;
59
+ padding: var(--spacing-md);
60
+ `;
61
+ const GroupTag = (0, styled_components_1.default)(Tag_1.Tag) `
62
+ cursor: pointer;
63
+ gap: 4px;
64
+ `;
65
+ const Divider = styled_components_1.default.div `
66
+ border-right: 1px solid var(--border-color-secondary);
67
+ margin: 5px 5px 5px 0;
68
+ `;
69
+ //# sourceMappingURL=SearchGroups.js.map
@@ -1 +1 @@
1
- export declare function highlight(text: string | string[]): JSX.Element | string;
1
+ export declare function searchHighlight(text: string | string[]): JSX.Element | string;
@@ -26,19 +26,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.highlight = void 0;
29
+ exports.searchHighlight = void 0;
30
30
  const React = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
- function highlight(text) {
33
- if (!Array.isArray(text))
34
- return text;
32
+ function slicer(str, arr) {
33
+ const markOpenIndex = str.indexOf('<mark>');
34
+ const markCloseIndex = str.indexOf('</mark>');
35
+ if (markOpenIndex !== -1 && markCloseIndex !== -1) {
36
+ const pre = str.slice(0, markOpenIndex);
37
+ const entry = str.slice(markOpenIndex + 6, markCloseIndex);
38
+ const suf = str.slice(markCloseIndex + 7, str.length);
39
+ return (arr = [...arr, pre, { entry }, ...slicer(suf, arr)]);
40
+ }
41
+ else
42
+ return [...arr, str];
43
+ }
44
+ function searchHighlight(text) {
45
+ if (!Array.isArray(text)) {
46
+ const arr = slicer(text, []);
47
+ if (arr.length === 1)
48
+ return text;
49
+ return (React.createElement("span", null, arr.map((item, index) => {
50
+ if (typeof item === 'object') {
51
+ return React.createElement(Highlight, { key: index }, item.entry);
52
+ }
53
+ else {
54
+ return item;
55
+ }
56
+ })));
57
+ }
35
58
  const [pre, entry, suf] = text;
36
59
  return (React.createElement("span", { "data-component-name": "Search/SearchHighlight" },
37
60
  pre,
38
61
  React.createElement(Highlight, null, entry),
39
62
  suf));
40
63
  }
41
- exports.highlight = highlight;
64
+ exports.searchHighlight = searchHighlight;
42
65
  const Highlight = styled_components_1.default.span `
43
66
  background-color: var(--search-highlight-bg-color);
44
67
  color: var(--search-highlight-text-color);
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  export type SearchInputProps = {
3
3
  placeholder?: string;
4
4
  value: string;
5
- onChange(value: string): void;
5
+ onChange: (value: string) => void;
6
6
  inputRef?: React.RefObject<HTMLInputElement>;
7
7
  isLoading: boolean;
8
8
  className?: string;
@@ -8,9 +8,9 @@ const react_1 = __importDefault(require("react"));
8
8
  const styled_components_1 = __importDefault(require("styled-components"));
9
9
  const SearchIcon_1 = require("../../icons/SearchIcon/SearchIcon");
10
10
  const Spinner_1 = require("../../icons/Spinner/Spinner");
11
- const CloseIcon_1 = require("../../icons/CloseIcon/CloseIcon");
12
11
  const Button_1 = require("../../components/Button/Button");
13
12
  const hooks_1 = require("../../core/hooks");
13
+ const CloseFilledIcon_1 = require("../../icons/CloseFilledIcon/CloseFilledIcon");
14
14
  function SearchInput({ placeholder, value, onChange, isLoading, className, }) {
15
15
  const { useTelemetry } = (0, hooks_1.useThemeHooks)();
16
16
  const telemetry = useTelemetry();
@@ -25,7 +25,7 @@ function SearchInput({ placeholder, value, onChange, isLoading, className, }) {
25
25
  return (react_1.default.createElement(SearchInputWrapper, { "data-component-name": "Search/SearchInput", className: className },
26
26
  value && isLoading ? (react_1.default.createElement(Spinner_1.Spinner, { size: "18px", color: "--search-input-icon-color" })) : (react_1.default.createElement(SearchIcon_1.SearchIcon, { size: "18px", color: "--search-input-icon-color" })),
27
27
  react_1.default.createElement(SearchInputField, { value: value, placeholder: placeholder, onChange: handleOnChange, onClick: stopPropagation }),
28
- !!value && react_1.default.createElement(Button_1.Button, { variant: "ghost", onClick: handleOnReset, icon: react_1.default.createElement(CloseIcon_1.CloseIcon, null) })));
28
+ !!value && (react_1.default.createElement(ResetButton, { variant: "ghost", onClick: handleOnReset, icon: react_1.default.createElement(CloseFilledIcon_1.CloseFilledIcon, null) }))));
29
29
  }
30
30
  exports.SearchInput = SearchInput;
31
31
  const SearchInputWrapper = styled_components_1.default.div `
@@ -52,4 +52,7 @@ const SearchInputField = styled_components_1.default.input `
52
52
  color: var(--search-input-placeholder-color);
53
53
  }
54
54
  `;
55
+ const ResetButton = (0, styled_components_1.default)(Button_1.Button) `
56
+ color: var(--color-warm-grey-5);
57
+ `;
55
58
  //# sourceMappingURL=SearchInput.js.map
@@ -1,9 +1,9 @@
1
- import type { SearchDocument } from '../../core/types';
1
+ import type { SearchItemData } from '../../core/types';
2
2
  type ActiveItem<T> = T & {
3
3
  active?: boolean;
4
4
  };
5
5
  export type SearchItemProps = {
6
- item: ActiveItem<SearchDocument>;
6
+ item: ActiveItem<SearchItemData>;
7
7
  product?: {
8
8
  name: string;
9
9
  icon?: string;
@@ -34,6 +34,7 @@ const Link_1 = require("../../components/Link/Link");
34
34
  const Image_1 = require("../../components/Image/Image");
35
35
  const SearchHighlight_1 = require("../../components/Search/SearchHighlight");
36
36
  const Badge_1 = require("../../components/Badge/Badge");
37
+ const utils_1 = require("../../core/utils");
37
38
  function SearchItem({ item, className, product }) {
38
39
  var _a, _b, _c, _d;
39
40
  const ref = (0, react_1.useRef)();
@@ -43,27 +44,33 @@ function SearchItem({ item, className, product }) {
43
44
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
44
45
  }
45
46
  }, [item.active]);
46
- const itemParam = (_a = item.parameters) === null || _a === void 0 ? void 0 : _a[0];
47
- return (react_1.default.createElement(SearchItemWrapper, { className: className, to: item.url, tabIndex: 0, innerRef: ref, "data-component-name": "Search/SearchItem" },
47
+ const { document, highlight } = item;
48
+ const parameter = highlight.parameters && highlight.parameters.length ? highlight.parameters[0] : null;
49
+ const shouldShowPath = document.path && ((_a = document.path) === null || _a === void 0 ? void 0 : _a.length) > 1;
50
+ return (react_1.default.createElement(SearchItemWrapper, { className: className, to: document.url, tabIndex: 0, innerRef: ref, "data-component-name": "Search/SearchItem" },
48
51
  react_1.default.createElement(SearchItemHeader, null,
49
52
  product && (react_1.default.createElement(SearchItemProductTag, { "data-testid": "search-item-product-tag" },
50
53
  react_1.default.createElement(Image_1.Image, { src: product.icon }),
51
54
  product.name)),
52
- item.httpVerb ? (react_1.default.createElement(SearchItemOperation, null,
53
- react_1.default.createElement(SearchItemOperationTag, { color: item.httpVerb }, item.httpVerb.toUpperCase()),
54
- item.pathName ? (0, SearchHighlight_1.highlight)(item.pathName) : null)) : null,
55
+ document.httpMethod ? (react_1.default.createElement(SearchItemOperation, null,
56
+ react_1.default.createElement(SearchItemOperationTag, { color: document.httpMethod }, document.httpMethod.toUpperCase()),
57
+ highlight.httpPath ? (0, SearchHighlight_1.searchHighlight)(highlight.httpPath) : document.httpPath)) : null,
55
58
  react_1.default.createElement(SearchItemTitleWrapper, null,
56
- react_1.default.createElement(SearchItemTitle, null, (0, SearchHighlight_1.highlight)(item.title)),
57
- item.deprecated ? react_1.default.createElement(SearchItemBadge, { deprecated: true }, "Deprecated") : null,
58
- item.badges
59
- ? item.badges.map(({ name, color }) => (react_1.default.createElement(SearchItemBadge, { color: color || 'var(--color-info-base)', key: name }, name)))
59
+ react_1.default.createElement(SearchItemTitle, null, highlight.title ? (0, SearchHighlight_1.searchHighlight)(highlight.title) : document.title),
60
+ document.deprecated ? react_1.default.createElement(SearchItemBadge, { deprecated: true }, "Deprecated") : null,
61
+ document.badges
62
+ ? document.badges.map(({ name, color }) => (react_1.default.createElement(SearchItemBadge, { color: color || 'var(--color-info-base)', key: name }, name)))
60
63
  : null),
61
- Array.isArray(item.text) ? (react_1.default.createElement(SearchItemDescription, null, (0, SearchHighlight_1.highlight)(item.text))) : null),
62
- itemParam ? (react_1.default.createElement(SearchItemPlace, null,
64
+ react_1.default.createElement(SearchItemDescription, null, highlight.text ? (0, SearchHighlight_1.searchHighlight)(highlight.text) : (0, utils_1.trimText)(document.text))),
65
+ parameter ? (react_1.default.createElement(SearchItemPlace, null,
63
66
  react_1.default.createElement("div", null,
64
- `${itemParam.place} → ${((_b = itemParam.path) === null || _b === void 0 ? void 0 : _b.length) ? ((_c = itemParam.path) === null || _c === void 0 ? void 0 : _c.join(' → ')) + ' → ' : ''}`,
65
- (0, SearchHighlight_1.highlight)(itemParam.name)),
66
- react_1.default.createElement("div", null, (0, SearchHighlight_1.highlight)(itemParam.description)))) : (react_1.default.createElement(SearchItemPath, null, (_d = item.path) === null || _d === void 0 ? void 0 : _d.join(' → ')))));
67
+ (0, SearchHighlight_1.searchHighlight)(parameter.place),
68
+ ` → `,
69
+ ((_b = parameter.path) === null || _b === void 0 ? void 0 : _b.length) ? (0, SearchHighlight_1.searchHighlight)((_c = parameter.path) === null || _c === void 0 ? void 0 : _c.join(' → ')) + ' → ' : '',
70
+ (0, SearchHighlight_1.searchHighlight)(parameter.name)),
71
+ react_1.default.createElement("div", null, (0, SearchHighlight_1.searchHighlight)(parameter.description)))) : (shouldShowPath && (react_1.default.createElement(SearchItemPath, null, highlight.path && highlight.path.length
72
+ ? (0, SearchHighlight_1.searchHighlight)(highlight.path.join(' → '))
73
+ : (_d = document.path) === null || _d === void 0 ? void 0 : _d.join(' → '))))));
67
74
  }
68
75
  exports.SearchItem = SearchItem;
69
76
  const SearchItemWrapper = (0, styled_components_1.default)(Link_1.Link) `
@@ -73,7 +80,7 @@ const SearchItemWrapper = (0, styled_components_1.default)(Link_1.Link) `
73
80
  background-color: var(--search-item-bg-color);
74
81
  transition: background-color 0.3s ease;
75
82
  text-decoration: none;
76
- white-space: nowrap;
83
+ white-space: normal;
77
84
  outline: none;
78
85
  border-top: 1px solid var(--search-item-border-color);
79
86
  border-bottom: 1px solid var(--search-item-border-color);
@@ -134,6 +141,7 @@ const SearchItemPath = styled_components_1.default.div `
134
141
  font-size: var(--font-size-sm);
135
142
  line-height: var(--line-height-sm);
136
143
  font-weight: var(--font-weight-regular);
144
+ margin-top: var(--spacing-sm);
137
145
  `;
138
146
  const SearchItemPlace = styled_components_1.default.div `
139
147
  display: flex;
@@ -143,6 +151,7 @@ const SearchItemPlace = styled_components_1.default.div `
143
151
  font-size: var(--font-size-sm);
144
152
  line-height: var(--line-height-sm);
145
153
  font-weight: var(--font-weight-regular);
154
+ margin-top: var(--spacing-sm);
146
155
 
147
156
  &:first-child {
148
157
  padding-top: 0;