@redocly/theme 0.41.0-rc.4 → 0.41.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 (103) hide show
  1. package/lib/components/CodeBlock/CodeBlockControls.js +2 -1
  2. package/lib/components/Dropdown/DropdownMenu.d.ts +0 -2
  3. package/lib/components/Dropdown/DropdownMenu.js +1 -3
  4. package/lib/components/Search/Search.js +1 -1
  5. package/lib/components/Search/SearchDialog.js +26 -103
  6. package/lib/components/Search/SearchHighlight.d.ts +1 -1
  7. package/lib/components/Search/SearchHighlight.js +5 -28
  8. package/lib/components/Search/SearchInput.d.ts +2 -3
  9. package/lib/components/Search/SearchInput.js +3 -11
  10. package/lib/components/Search/SearchItem.d.ts +2 -2
  11. package/lib/components/Search/SearchItem.js +15 -23
  12. package/lib/components/Search/variables.js +2 -48
  13. package/lib/components/Segmented/Segmented.d.ts +5 -2
  14. package/lib/components/Select/Select.d.ts +36 -2
  15. package/lib/components/Select/Select.js +98 -134
  16. package/lib/components/Select/variables.js +1 -11
  17. package/lib/components/Tag/Tag.d.ts +2 -4
  18. package/lib/components/Tag/Tag.js +4 -40
  19. package/lib/components/Tag/variables.dark.js +5 -20
  20. package/lib/components/Tag/variables.js +17 -49
  21. package/lib/components/VersionPicker/VersionPicker.d.ts +3 -2
  22. package/lib/components/VersionPicker/VersionPicker.js +30 -13
  23. package/lib/core/hooks/__mocks__/index.d.ts +1 -1
  24. package/lib/core/hooks/__mocks__/index.js +1 -1
  25. package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +1 -1
  26. package/lib/core/hooks/__mocks__/use-theme-hooks.js +1 -1
  27. package/lib/core/hooks/index.d.ts +1 -2
  28. package/lib/core/hooks/index.js +1 -2
  29. package/lib/core/hooks/search/use-recent-searches.js +0 -2
  30. package/lib/core/hooks/{search/use-search-dialog.d.ts → use-search.d.ts} +1 -1
  31. package/lib/core/hooks/{search/use-search-dialog.js → use-search.js} +5 -5
  32. package/lib/core/types/hooks.d.ts +4 -16
  33. package/lib/core/types/index.d.ts +1 -1
  34. package/lib/core/types/index.js +1 -1
  35. package/lib/core/types/l10n.d.ts +2 -1
  36. package/lib/core/types/search.d.ts +2 -43
  37. package/lib/core/types/select-option.d.ts +4 -0
  38. package/lib/core/types/{select.js → select-option.js} +1 -1
  39. package/lib/index.d.ts +1 -7
  40. package/lib/index.js +1 -7
  41. package/package.json +2 -2
  42. package/src/components/CodeBlock/CodeBlockControls.tsx +1 -1
  43. package/src/components/Dropdown/DropdownMenu.tsx +1 -2
  44. package/src/components/Filter/FilterSelect.tsx +3 -3
  45. package/src/components/Search/Search.tsx +2 -2
  46. package/src/components/Search/SearchDialog.tsx +42 -168
  47. package/src/components/Search/SearchHighlight.tsx +2 -29
  48. package/src/components/Search/SearchInput.tsx +3 -17
  49. package/src/components/Search/SearchItem.tsx +24 -38
  50. package/src/components/Search/variables.ts +2 -48
  51. package/src/components/Segmented/Segmented.tsx +2 -2
  52. package/src/components/Select/Select.tsx +157 -200
  53. package/src/components/Select/variables.ts +1 -11
  54. package/src/components/Tag/Tag.tsx +6 -57
  55. package/src/components/Tag/variables.dark.ts +5 -20
  56. package/src/components/Tag/variables.ts +17 -49
  57. package/src/components/VersionPicker/VersionPicker.tsx +39 -15
  58. package/src/core/hooks/__mocks__/index.ts +1 -1
  59. package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -1
  60. package/src/core/hooks/index.ts +1 -2
  61. package/src/core/hooks/search/use-recent-searches.ts +0 -3
  62. package/src/core/hooks/{search/use-search-dialog.ts → use-search.ts} +1 -1
  63. package/src/core/types/hooks.ts +4 -24
  64. package/src/core/types/index.ts +1 -1
  65. package/src/core/types/l10n.ts +37 -7
  66. package/src/core/types/search.ts +2 -54
  67. package/src/core/types/select-option.ts +4 -0
  68. package/src/index.ts +1 -7
  69. package/lib/components/Loaders/SpinnerLoader.d.ts +0 -5
  70. package/lib/components/Loaders/SpinnerLoader.js +0 -32
  71. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.d.ts +0 -12
  72. package/lib/components/Search/FilterFields/SearchFilterFieldSelect.js +0 -113
  73. package/lib/components/Search/FilterFields/SearchFilterFieldTags.d.ts +0 -10
  74. package/lib/components/Search/FilterFields/SearchFilterFieldTags.js +0 -37
  75. package/lib/components/Search/SearchFilter.d.ts +0 -11
  76. package/lib/components/Search/SearchFilter.js +0 -71
  77. package/lib/components/Search/SearchFilterField.d.ts +0 -11
  78. package/lib/components/Search/SearchFilterField.js +0 -43
  79. package/lib/components/Search/SearchGroups.d.ts +0 -9
  80. package/lib/components/Search/SearchGroups.js +0 -69
  81. package/lib/components/Select/SelectInput.d.ts +0 -23
  82. package/lib/components/Select/SelectInput.js +0 -129
  83. package/lib/core/hooks/search/use-search-filter.d.ts +0 -9
  84. package/lib/core/hooks/search/use-search-filter.js +0 -50
  85. package/lib/core/types/select.d.ts +0 -30
  86. package/lib/icons/ResetIcon/ResetIcon.d.ts +0 -9
  87. package/lib/icons/ResetIcon/ResetIcon.js +0 -22
  88. package/lib/icons/SettingsIcon/SettingsIcon.d.ts +0 -9
  89. package/lib/icons/SettingsIcon/SettingsIcon.js +0 -23
  90. package/src/components/Loaders/SpinnerLoader.tsx +0 -31
  91. package/src/components/Search/FilterFields/SearchFilterFieldSelect.tsx +0 -134
  92. package/src/components/Search/FilterFields/SearchFilterFieldTags.tsx +0 -61
  93. package/src/components/Search/SearchFilter.tsx +0 -90
  94. package/src/components/Search/SearchFilterField.tsx +0 -84
  95. package/src/components/Search/SearchGroups.tsx +0 -80
  96. package/src/components/Select/SelectInput.tsx +0 -201
  97. package/src/core/hooks/search/use-search-filter.ts +0 -57
  98. package/src/core/types/select.ts +0 -32
  99. package/src/icons/ResetIcon/ResetIcon.tsx +0 -26
  100. package/src/icons/SettingsIcon/SettingsIcon.tsx +0 -30
  101. /package/lib/components/{Loaders → Loading}/Loading.d.ts +0 -0
  102. /package/lib/components/{Loaders → Loading}/Loading.js +0 -0
  103. /package/src/components/{Loaders → Loading}/Loading.tsx +0 -0
@@ -39,8 +39,9 @@ function CodeBlockControls({ children, className, title, controls, tabs, }) {
39
39
  select ? (react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "select-all", icon: controlsType === 'icon' ? react_1.default.createElement(SelectIcon_1.SelectIcon, null) : undefined, onClick: select === null || select === void 0 ? void 0 : select.onClick }, controlsType !== 'icon' && (select === null || select === void 0 ? void 0 : select.label) ? select.label : 'Select all')) : null,
40
40
  deselect ? (react_1.default.createElement(ControlButton, { variant: "text", size: "small", "data-testid": "clear-all", icon: controlsType === 'icon' ? react_1.default.createElement(DeselectIcon_1.DeselectIcon, null) : undefined, onClick: deselect === null || deselect === void 0 ? void 0 : deselect.onClick }, controlsType !== 'icon' && (deselect === null || deselect === void 0 ? void 0 : deselect.label) ? deselect.label : 'Clear all')) : null,
41
41
  copy && !((_e = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.copy) === null || _e === void 0 ? void 0 : _e.hide) ? (react_1.default.createElement(CopyButton_1.CopyButton, { data: copy.data, "data-source": copy.dataSource, "data-hash": copy.dataHash, type: controlsType, toasterPlacement: copy.toasterPlacement, toasterDuration: copy.toasterDuration, buttonText: copy.label, onCopyClick: () => {
42
+ var _a;
42
43
  copy === null || copy === void 0 ? void 0 : copy.onClick;
43
- telemetry.send('code_snippet_copied', {});
44
+ (_a = telemetry === null || telemetry === void 0 ? void 0 : telemetry.send) === null || _a === void 0 ? void 0 : _a.call(telemetry, 'code_snippet_copied', {});
44
45
  } })) : null))) : null;
45
46
  return children || controls ? (react_1.default.createElement(ContainerWrapper, { "data-component-name": "CodeBlock/CodeBlockControls", className: className }, children ? children : defaultControls)) : null;
46
47
  }
@@ -1,10 +1,8 @@
1
- import React from 'react';
2
1
  import type { ReactNode } from 'react';
3
2
  import type { DropdownMenuItemProps } from '../../components/Dropdown/DropdownMenuItem';
4
3
  export type DropdownMenuProps = {
5
4
  className?: string;
6
5
  role?: string;
7
- footer?: React.ReactNode;
8
6
  } & ({
9
7
  items: DropdownMenuItemProps[];
10
8
  } | {
@@ -15,9 +15,7 @@ function DropdownMenu(props) {
15
15
  if ('items' in props) {
16
16
  content = props.items.map((item, idx) => (react_1.default.createElement(DropdownMenuItem_1.DropdownMenuItem, Object.assign({ key: idx }, item), item.content)));
17
17
  }
18
- return (react_1.default.createElement(DropdownMenuWrapper, { "data-component-name": "Dropdown/DropdownMenu", "data-testid": "dropdown-menu", className: props.className, role: props.role || 'menu' },
19
- content,
20
- props.footer || null));
18
+ return (react_1.default.createElement(DropdownMenuWrapper, { "data-component-name": "Dropdown/DropdownMenu", "data-testid": "dropdown-menu", className: props.className, role: props.role || 'menu' }, content));
21
19
  }
22
20
  exports.DropdownMenu = DropdownMenu;
23
21
  const DropdownMenuWrapper = styled_components_1.default.ul `
@@ -10,7 +10,7 @@ const SearchTrigger_1 = require("../../components/Search/SearchTrigger");
10
10
  const SearchDialog_1 = require("../../components/Search/SearchDialog");
11
11
  const hooks_1 = require("../../core/hooks");
12
12
  function Search({ className }) {
13
- const { isOpen, onOpen, onClose } = (0, hooks_1.useSearchDialog)();
13
+ const { isOpen, onOpen, onClose } = (0, hooks_1.useSearch)();
14
14
  return (react_1.default.createElement(SearchWrapper, { "data-component-name": "Search/Search", className: className },
15
15
  react_1.default.createElement(SearchTrigger_1.SearchTrigger, { onClick: onOpen }),
16
16
  isOpen && react_1.default.createElement(SearchDialog_1.SearchDialog, { onClose: onClose })));
@@ -39,16 +39,12 @@ 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
42
  function SearchDialog({ onClose, className }) {
46
- const { useTranslate, useCurrentProduct, useSearch, useProducts } = (0, hooks_1.useThemeHooks)();
43
+ const { useTranslate, useCurrentProduct, useFuseSearch, useProducts } = (0, hooks_1.useThemeHooks)();
47
44
  const products = useProducts();
48
45
  const currentProduct = useCurrentProduct();
49
46
  const [product, setProduct] = (0, react_1.useState)(currentProduct);
50
- const { query, setQuery, filter, setFilter, items, isSearchLoading, facets, setLoadMore } = useSearch(product === null || product === void 0 ? void 0 : product.name);
51
- const { isFilterOpen, onFilterToggle, onFilterChange, onFilterReset, onFacetReset, onTopFacetsReset, } = (0, hooks_1.useSearchFilter)(filter, setFilter);
47
+ const { query, setQuery, items, isLoading } = useFuseSearch(product === null || product === void 0 ? void 0 : product.name);
52
48
  const modalRef = (0, react_1.useRef)(null);
53
49
  const { translate } = useTranslate();
54
50
  (0, hooks_1.useDialogHotKeys)(modalRef, onClose);
@@ -63,64 +59,29 @@ function SearchDialog({ onClose, className }) {
63
59
  };
64
60
  const mapItem = (item) => {
65
61
  let itemProduct;
66
- if (!product && item.document.product) {
67
- const resolvedProduct = products.find((product) => { var _a; return product.slug.match(`/${(_a = item.document.product) === null || _a === void 0 ? void 0 : _a.folder}/`); });
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}/`); });
68
64
  itemProduct = resolvedProduct
69
65
  ? { name: resolvedProduct.name, icon: resolvedProduct.icon }
70
66
  : undefined;
71
67
  }
72
- return react_1.default.createElement(SearchItem_1.SearchItem, { key: item.document.id, item: item, product: itemProduct });
68
+ return react_1.default.createElement(SearchItem_1.SearchItem, { key: item.id, item: item, product: itemProduct });
73
69
  };
74
- const showLoadMore = (groupKey, currentCount = 0) => {
75
- const topFacet = facets.find((facet) => facet.isTop);
76
- let needLoadMore = false;
77
- if (topFacet) {
78
- const groupValue = topFacet.values.find((value) => {
79
- if (typeof value === 'object') {
80
- return value.value === groupKey;
81
- }
82
- else
83
- return false;
84
- });
85
- needLoadMore = groupValue ? groupValue.count > currentCount : false;
86
- }
87
- return needLoadMore;
88
- };
89
- const showResults = !!((filter && filter.length) || query);
90
70
  return (react_1.default.createElement(SearchOverlay, { "data-component-name": "Search/SearchDialog", ref: modalRef, onClick: handleOverlayClick, className: (0, utils_1.concatClassNames)('overlay', className) },
91
71
  react_1.default.createElement(SearchDialogWrapper, { className: "scroll-lock", role: "dialog" },
92
72
  react_1.default.createElement(SearchDialogHeader, null,
93
- product && (react_1.default.createElement(react_1.default.Fragment, null,
94
- react_1.default.createElement(SearchProductTag, { color: "product" },
95
- product.name,
96
- react_1.default.createElement(CloseIcon_1.CloseIcon, { onClick: () => setProduct(undefined), color: "--icon-color-additional" })))),
97
- react_1.default.createElement(SearchInput_1.SearchInput, { value: query, onChange: setQuery, onFilterToggle: onFilterToggle, placeholder: translate('theme.search.label', 'Search docs...'), isLoading: isSearchLoading, "data-translation-key": "theme.search.label" })),
98
- react_1.default.createElement(SearchDialogBody, null,
99
- react_1.default.createElement(SearchDialogBodyMainView, null,
100
- react_1.default.createElement(SearchGroups_1.SearchGroups, { facets: facets, searchFilter: filter, onFilterChange: onFilterChange, onTopFacetsReset: onTopFacetsReset }),
101
- 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) => {
102
- var _a, _b, _c;
103
- return ((_a = items[key]) === null || _a === void 0 ? void 0 : _a.length) ? (react_1.default.createElement(react_1.Fragment, { key: key },
104
- react_1.default.createElement(SearchGroupTitle, null, key), (_b = items[key]) === null || _b === void 0 ? void 0 :
105
- _b.map(mapItem),
106
- showLoadMore(key, ((_c = items[key]) === null || _c === void 0 ? void 0 : _c.length) || 0) && (react_1.default.createElement(SearchGroupFooter, { "data-translation-key": "theme.search.showMore", onClick: () => { var _a; return setLoadMore({ groupKey: key, offset: ((_a = items[key]) === null || _a === void 0 ? void 0 : _a.length) || 0 }); } }, translate('theme.search.showMore', 'Show more'))))) : null;
107
- })) : isSearchLoading ? (react_1.default.createElement(SearchMessage, null,
108
- react_1.default.createElement(SpinnerLoader_1.SpinnerLoader, { size: "26px", color: "var(--search-input-icon-color)" }),
109
- translate('theme.search.loading', 'Loading...'))) : (react_1.default.createElement(SearchMessage, { "data-translation-key": "theme.search.noResults" },
110
- react_1.default.createElement("b", null, translate('theme.search.noResults.title', 'No results')),
111
- translate('theme.search.noResults.description', 'Prease, try with a different query.')))) : (react_1.default.createElement(react_1.default.Fragment, null,
112
- react_1.default.createElement(SearchRecent_1.SearchRecent, { onSelect: setQuery }),
113
- react_1.default.createElement(SearchSuggestedPages_1.SearchSuggestedPages, null)))),
114
- isFilterOpen && (react_1.default.createElement(SearchDialogBodyFilterView, null,
115
- react_1.default.createElement(SearchFilter_1.SearchFilter, { facets: facets, filter: filter, query: query, onFilterChange: onFilterChange, onFilterReset: onFilterReset, onFacetReset: onFacetReset })))),
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)))),
116
80
  react_1.default.createElement(SearchDialogFooter, null,
117
81
  react_1.default.createElement(SearchShortcuts, null,
118
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') }),
119
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') }),
120
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') })),
121
- isSearchLoading && (react_1.default.createElement(SearchLoading, null,
122
- react_1.default.createElement(SpinnerLoader_1.SpinnerLoader, { size: "16px", color: "var(--search-input-icon-color)" }),
123
- translate('theme.search.loading', 'Loading...'))),
124
85
  react_1.default.createElement(SearchCancelButton, { "data-translation-key": "theme.search.cancel", variant: "secondary", size: "small", onClick: onClose }, translate('theme.search.cancel', 'Cancel'))))));
125
86
  }
126
87
  exports.SearchDialog = SearchDialog;
@@ -139,6 +100,7 @@ const SearchOverlay = styled_components_1.default.div `
139
100
  const SearchDialogWrapper = styled_components_1.default.div `
140
101
  display: flex;
141
102
  flex-direction: column;
103
+ justify-content: space-between;
142
104
  overflow: auto;
143
105
  width: 100vw;
144
106
  height: 100vh;
@@ -154,65 +116,47 @@ const SearchDialogWrapper = styled_components_1.default.div `
154
116
  max-height: 95vh;
155
117
  height: auto;
156
118
  resize: both;
119
+ min-width: 300px;
120
+ min-height: 200px;
157
121
  }
158
122
  `;
159
123
  const SearchDialogHeader = styled_components_1.default.header `
160
124
  display: flex;
161
125
  align-items: center;
162
- border-bottom: var(--search-modal-border);
163
- background-color: var(--search-modal-header-bg-color);
164
- padding: var(--search-modal-header-padding);
126
+ border-bottom: 1px solid var(--border-color-secondary);
127
+ background-color: var(--search-input-bg-color);
128
+ padding: var(--spacing-sm);
165
129
  `;
166
130
  const SearchDialogBody = styled_components_1.default.div `
167
- display: flex;
168
- flex-direction: row;
169
131
  flex-grow: 1;
132
+ overflow-y: scroll;
133
+ overscroll-behavior: contain;
170
134
 
171
135
  @media screen and (min-width: ${utils_1.breakpoints.small}) {
172
136
  height: var(--search-modal-min-height);
173
137
  }
174
138
  `;
175
- const SearchDialogBodyMainView = styled_components_1.default.div `
176
- flex: 2;
177
- flex-grow: 2;
178
- overflow-y: scroll;
179
- overscroll-behavior: contain;
180
- border-right: var(--search-modal-border);
181
- `;
182
- const SearchDialogBodyFilterView = styled_components_1.default.div `
183
- overflow: scroll;
184
- `;
185
139
  const SearchDialogFooter = styled_components_1.default.footer `
186
- display: flex;
187
- gap: var(--search-modal-footer-gap);
188
- padding: var(--search-modal-footer-padding);
189
- border-top: var(--search-modal-border);
140
+ padding: var(--spacing-sm);
141
+ border-top: 1px solid var(--border-color-secondary);
190
142
  `;
191
143
  const SearchShortcuts = styled_components_1.default.div `
192
144
  display: none;
193
145
  justify-content: flex-start;
194
146
  align-items: center;
195
- gap: var(--search-shortcuts-gap);
147
+ gap: var(--spacing-xs);
196
148
 
197
149
  @media screen and (min-width: ${utils_1.breakpoints.small}) {
198
150
  display: flex;
199
151
  }
200
152
  `;
201
153
  const SearchMessage = styled_components_1.default.div `
202
- display: flex;
203
- height: 40%;
204
- justify-content: center;
205
- align-items: center;
206
- flex-direction: column;
207
- font-size: var(--search-message-font-size);
208
- font-weight: var(--search-message-font-weight);
209
- line-height: var(--search-message-line-height);
210
- color: var(--search-message-text-color);
211
- gap: var(--search-message-gap);
154
+ padding: var(--spacing-lg);
155
+ color: var(--search-item-title-text-color);
212
156
  `;
213
157
  const SearchProductTag = (0, styled_components_1.default)(Tag_1.Tag) `
214
158
  --tag-border-radius: var(--border-radius);
215
- border: none;
159
+
216
160
  margin: var(--spacing-xs) var(--spacing-sm) !important;
217
161
  `;
218
162
  const SearchCancelButton = (0, styled_components_1.default)(Button_1.Button) `
@@ -222,25 +166,4 @@ const SearchCancelButton = (0, styled_components_1.default)(Button_1.Button) `
222
166
  display: none;
223
167
  }
224
168
  `;
225
- const SearchGroupTitle = styled_components_1.default.div `
226
- border-bottom: var(--search-modal-border);
227
- padding: var(--search-group-title-padding);
228
- background-color: var(--search-group-title-bg-color);
229
- `;
230
- const SearchGroupFooter = styled_components_1.default.div `
231
- display: flex;
232
- justify-content: center;
233
- padding: var(--search-group-footer-padding);
234
- color: var(--search-group-footer-text-color);
235
- cursor: pointer;
236
- `;
237
- const SearchLoading = styled_components_1.default.div `
238
- display: none;
239
- align-items: center;
240
- gap: var(--spacing-xs);
241
-
242
- @media screen and (min-width: ${utils_1.breakpoints.small}) {
243
- display: flex;
244
- }
245
- `;
246
169
  //# sourceMappingURL=SearchDialog.js.map
@@ -1 +1 @@
1
- export declare function searchHighlight(text: string | string[]): JSX.Element | string;
1
+ export declare function highlight(text: string | string[]): JSX.Element | string;
@@ -26,42 +26,19 @@ 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.searchHighlight = void 0;
29
+ exports.highlight = void 0;
30
30
  const React = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
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
- }
32
+ function highlight(text) {
33
+ if (!Array.isArray(text))
34
+ return text;
58
35
  const [pre, entry, suf] = text;
59
36
  return (React.createElement("span", { "data-component-name": "Search/SearchHighlight" },
60
37
  pre,
61
38
  React.createElement(Highlight, null, entry),
62
39
  suf));
63
40
  }
64
- exports.searchHighlight = searchHighlight;
41
+ exports.highlight = highlight;
65
42
  const Highlight = styled_components_1.default.span `
66
43
  background-color: var(--search-highlight-bg-color);
67
44
  color: var(--search-highlight-text-color);
@@ -2,10 +2,9 @@ import React from 'react';
2
2
  export type SearchInputProps = {
3
3
  placeholder?: string;
4
4
  value: string;
5
- onChange: (value: string) => void;
6
- onFilterToggle: () => void;
5
+ onChange(value: string): void;
7
6
  inputRef?: React.RefObject<HTMLInputElement>;
8
7
  isLoading: boolean;
9
8
  className?: string;
10
9
  };
11
- export declare function SearchInput({ placeholder, value, onChange, onFilterToggle, isLoading, className, }: SearchInputProps): JSX.Element;
10
+ export declare function SearchInput({ placeholder, value, onChange, isLoading, className, }: SearchInputProps): JSX.Element;
@@ -8,11 +8,10 @@ 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");
11
12
  const Button_1 = require("../../components/Button/Button");
12
13
  const hooks_1 = require("../../core/hooks");
13
- const CloseFilledIcon_1 = require("../../icons/CloseFilledIcon/CloseFilledIcon");
14
- const SettingsIcon_1 = require("../../icons/SettingsIcon/SettingsIcon");
15
- function SearchInput({ placeholder, value, onChange, onFilterToggle, isLoading, className, }) {
14
+ function SearchInput({ placeholder, value, onChange, isLoading, className, }) {
16
15
  const { useTelemetry } = (0, hooks_1.useThemeHooks)();
17
16
  const telemetry = useTelemetry();
18
17
  const stopPropagation = (event) => event.stopPropagation();
@@ -26,8 +25,7 @@ function SearchInput({ placeholder, value, onChange, onFilterToggle, isLoading,
26
25
  return (react_1.default.createElement(SearchInputWrapper, { "data-component-name": "Search/SearchInput", className: className },
27
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" })),
28
27
  react_1.default.createElement(SearchInputField, { value: value, placeholder: placeholder, onChange: handleOnChange, onClick: stopPropagation }),
29
- !!value && (react_1.default.createElement(ResetButton, { variant: "ghost", onClick: handleOnReset, icon: react_1.default.createElement(CloseFilledIcon_1.CloseFilledIcon, null) })),
30
- react_1.default.createElement(FilterToggleButton, { icon: react_1.default.createElement(SettingsIcon_1.SettingsIcon, null), onClick: onFilterToggle })));
28
+ !!value && react_1.default.createElement(Button_1.Button, { variant: "ghost", onClick: handleOnReset, icon: react_1.default.createElement(CloseIcon_1.CloseIcon, null) })));
31
29
  }
32
30
  exports.SearchInput = SearchInput;
33
31
  const SearchInputWrapper = styled_components_1.default.div `
@@ -54,10 +52,4 @@ const SearchInputField = styled_components_1.default.input `
54
52
  color: var(--search-input-placeholder-color);
55
53
  }
56
54
  `;
57
- const ResetButton = (0, styled_components_1.default)(Button_1.Button) `
58
- color: var(--color-warm-grey-5);
59
- `;
60
- const FilterToggleButton = (0, styled_components_1.default)(Button_1.Button) `
61
- margin-left: 0;
62
- `;
63
55
  //# sourceMappingURL=SearchInput.js.map
@@ -1,9 +1,9 @@
1
- import type { SearchItemData } from '../../core/types';
1
+ import type { SearchDocument } from '../../core/types';
2
2
  type ActiveItem<T> = T & {
3
3
  active?: boolean;
4
4
  };
5
5
  export type SearchItemProps = {
6
- item: ActiveItem<SearchItemData>;
6
+ item: ActiveItem<SearchDocument>;
7
7
  product?: {
8
8
  name: string;
9
9
  icon?: string;
@@ -43,33 +43,27 @@ function SearchItem({ item, className, product }) {
43
43
  (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
44
44
  }
45
45
  }, [item.active]);
46
- const { document, highlight } = item;
47
- const parameter = highlight.parameters && highlight.parameters.length ? highlight.parameters[0] : null;
48
- const shouldShowPath = document.path && ((_a = document.path) === null || _a === void 0 ? void 0 : _a.length) > 1;
49
- return (react_1.default.createElement(SearchItemWrapper, { className: className, to: document.url, tabIndex: 0, innerRef: ref, "data-component-name": "Search/SearchItem" },
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" },
50
48
  react_1.default.createElement(SearchItemHeader, null,
51
49
  product && (react_1.default.createElement(SearchItemProductTag, { "data-testid": "search-item-product-tag" },
52
50
  react_1.default.createElement(Image_1.Image, { src: product.icon }),
53
51
  product.name)),
54
- document.httpMethod ? (react_1.default.createElement(SearchItemOperation, null,
55
- react_1.default.createElement(SearchItemOperationTag, { color: document.httpMethod }, document.httpMethod.toUpperCase()),
56
- highlight.httpPath ? (0, SearchHighlight_1.searchHighlight)(highlight.httpPath) : document.httpPath)) : null,
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,
57
55
  react_1.default.createElement(SearchItemTitleWrapper, null,
58
- react_1.default.createElement(SearchItemTitle, null, highlight.title ? (0, SearchHighlight_1.searchHighlight)(highlight.title) : document.title),
59
- document.deprecated ? react_1.default.createElement(SearchItemBadge, { deprecated: true }, "Deprecated") : null,
60
- document.badges
61
- ? document.badges.map(({ name, color }) => (react_1.default.createElement(SearchItemBadge, { color: color || 'var(--color-info-base)', key: name }, name)))
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)))
62
60
  : null),
63
- react_1.default.createElement(SearchItemDescription, null, highlight.text ? (0, SearchHighlight_1.searchHighlight)(highlight.text) : document.text)),
64
- parameter ? (react_1.default.createElement(SearchItemPlace, 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,
65
63
  react_1.default.createElement("div", null,
66
- (0, SearchHighlight_1.searchHighlight)(parameter.place),
67
- ` → `,
68
- ((_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(' → ')) + ' → ' : '',
69
- (0, SearchHighlight_1.searchHighlight)(parameter.name)),
70
- react_1.default.createElement("div", null, (0, SearchHighlight_1.searchHighlight)(parameter.description)))) : (shouldShowPath && (react_1.default.createElement(SearchItemPath, null, highlight.path && highlight.path.length
71
- ? (0, SearchHighlight_1.searchHighlight)(highlight.path.join(' → '))
72
- : (_d = document.path) === null || _d === void 0 ? void 0 : _d.join(' → '))))));
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(' → ')))));
73
67
  }
74
68
  exports.SearchItem = SearchItem;
75
69
  const SearchItemWrapper = (0, styled_components_1.default)(Link_1.Link) `
@@ -79,7 +73,7 @@ const SearchItemWrapper = (0, styled_components_1.default)(Link_1.Link) `
79
73
  background-color: var(--search-item-bg-color);
80
74
  transition: background-color 0.3s ease;
81
75
  text-decoration: none;
82
- white-space: normal;
76
+ white-space: nowrap;
83
77
  outline: none;
84
78
  border-top: 1px solid var(--search-item-border-color);
85
79
  border-bottom: 1px solid var(--search-item-border-color);
@@ -140,7 +134,6 @@ const SearchItemPath = styled_components_1.default.div `
140
134
  font-size: var(--font-size-sm);
141
135
  line-height: var(--line-height-sm);
142
136
  font-weight: var(--font-weight-regular);
143
- margin-top: var(--spacing-sm);
144
137
  `;
145
138
  const SearchItemPlace = styled_components_1.default.div `
146
139
  display: flex;
@@ -150,7 +143,6 @@ const SearchItemPlace = styled_components_1.default.div `
150
143
  font-size: var(--font-size-sm);
151
144
  line-height: var(--line-height-sm);
152
145
  font-weight: var(--font-weight-regular);
153
- margin-top: var(--spacing-sm);
154
146
 
155
147
  &:first-child {
156
148
  padding-top: 0;
@@ -6,18 +6,11 @@ exports.search = (0, styled_components_1.css) `
6
6
  /**
7
7
  * @tokens Search
8
8
  */
9
- --search-modal-width: 1100px;
10
- --search-modal-min-height: 705px;
9
+ --search-modal-width: 700px;
10
+ --search-modal-min-height: 530px;
11
11
  --search-modal-bg-color: var(--modal-bg-color);
12
12
  --search-modal-box-shadow: var(--modal-box-shadow);
13
13
  --search-modal-border-radius: var(--border-radius-lg);
14
- --search-modal-border: 1px solid var(--border-color-secondary);
15
-
16
- --search-modal-header-bg-color: var(--bg-color-tonal); // @presenter Color
17
- --search-modal-header-padding: var(--spacing-sm);
18
-
19
- --search-modal-footer-padding: var(--spacing-sm);
20
- --search-modal-footer-gap: var(--spacing-md);
21
14
 
22
15
  --search-highlight-bg-color: none; // @presenter Color
23
16
  --search-highlight-text-color: var(--color-info-base); // @presenter Color
@@ -36,11 +29,6 @@ exports.search = (0, styled_components_1.css) `
36
29
  --search-input-border: none;
37
30
  --search-input-border-radius: var(--border-radius); // @presenter BorderRadius
38
31
 
39
- --search-group-title-padding: var(--spacing-sm);
40
- --search-group-title-bg-color: var(--bg-color-tonal); // @presenter Color
41
- --search-group-footer-padding: var(--spacing-sm);
42
- --search-group-footer-text-color: var(--link-color-primary); // @presenter Color
43
-
44
32
  --search-item-text-color: var(--text-color-secondary); // @presenter Color
45
33
  --search-item-text-color-hover: var(--text-color-primary); // @presenter Color
46
34
  --search-item-title-font-size: var(--font-size-base); // @presenter FontSize
@@ -88,40 +76,6 @@ exports.search = (0, styled_components_1.css) `
88
76
  --search-suggested-item-bg-color-active: var(--layer-color); // @presenter Color
89
77
  --search-suggested-item-border-color-focused: var(--color-blue-4); // @presenter Color
90
78
 
91
- --search-shortcuts-gap: var(--spacing-xs);
92
-
93
- --search-message-font-size: var(--font-size-lg); // @presenter FontSize
94
- --search-message-font-weight: var(--font-weight-regular); // @presenter FontWeight
95
- --search-message-line-height: var(--line-height-lg); // @presenter LineHeight
96
- --search-message-text-color: var(--text-color-secondary); // @presenter Color
97
- --search-message-gap: var(--spacing-md);
98
-
99
- /**
100
- * @tokens Search filter
101
- */
102
- --search-filter-width: 450px;
103
- --search-filter-bg-color: var(--search-modal-bg-color);
104
- --search-filter-padding: var(--spacing-lg);
105
- --search-filter-font-size: var(--font-size-base);
106
- --search-filter-font-weight: var(--font-weight-regular);
107
- --search-filter-line-height: var(--line-height-base);
108
-
109
- --search-filter-header-padding: var(--spacing-md) 0;
110
- --search-filter-header-text-color: var(--text-color-helper);
111
- --search-filter-header-z-index: var(--z-index-raised);
112
-
113
- --search-filter-fields-gap: var(--spacing-base);
114
-
115
- --search-filter-field-select-option-gap: var(--spacing-unit);
116
- --search-filter-field-select-option-text-padding: 0 0 0 var(--spacing-unit);
117
- --search-filter-field-select-footer-padding: 0 0 0 var(--spacing-unit);
118
- --search-filter-field-select-footer-text-color: var(--text-color-helper);
119
-
120
- --search-filter-field-tags-gap: var(--spacing-unit);
121
- --search-filter-field-tags-tag-margin: var(--spacing-unit) 0 0 0;
122
-
123
- // @tokens End
124
-
125
79
  /**
126
80
  * @tokens Navbar Search Trigger
127
81
  */
@@ -1,9 +1,12 @@
1
1
  import type { ReactElement } from 'react';
2
- import type { SelectOption } from '../../core/types/select';
2
+ import type { SelectOption } from '../../core/types/select-option';
3
3
  export type SegmentedProps<T> = {
4
4
  options: SelectOption<T>[];
5
5
  value: T;
6
- onChange: ({ label, value }: SelectOption<T>) => void;
6
+ onChange: ({ label, value }: {
7
+ label: string;
8
+ value: T;
9
+ }) => void;
7
10
  className?: string;
8
11
  size?: 'regular' | 'small';
9
12
  };
@@ -1,5 +1,39 @@
1
- import type { SelectProps } from '../../core/types/select';
1
+ import React from 'react';
2
+ export type SelectProps<T = any> = {
3
+ value: T;
4
+ options: {
5
+ element: React.ReactNode | JSX.Element | string;
6
+ value: T;
7
+ label?: string;
8
+ }[];
9
+ dataAttributes?: Record<string, string>;
10
+ className?: string;
11
+ withArrow?: boolean;
12
+ triggerEvent?: 'click' | 'hover';
13
+ onChange?: (value: any) => void;
14
+ placement?: 'top' | 'bottom';
15
+ alignment?: 'start' | 'end';
16
+ icon?: React.ReactNode;
17
+ onlyIcon?: boolean;
18
+ placeholder?: string;
19
+ disabled?: boolean;
20
+ hideCheckmarkIcon?: boolean;
21
+ dataTestId?: string;
22
+ renderInput?: (props: {
23
+ isOpen: boolean;
24
+ }) => React.ReactElement;
25
+ renderDivider?: () => React.ReactElement;
26
+ };
2
27
  export declare function Select<T>(props: SelectProps<T>): JSX.Element;
3
- export declare const SelectWrapper: import("styled-components").StyledComponent<"div", any, {
28
+ export declare const SelectContainer: import("styled-components").StyledComponent<"div", any, {
4
29
  disabled?: boolean | undefined;
5
30
  }, never>;
31
+ export declare const SelectInput: import("styled-components").StyledComponent<"div", any, {}, never>;
32
+ export declare const SelectInputValue: import("styled-components").StyledComponent<"div", any, {}, never>;
33
+ export declare const SelectList: import("styled-components").StyledComponent<"ul", any, {
34
+ placement?: string | undefined;
35
+ alignment?: string | undefined;
36
+ }, never>;
37
+ export declare const SelectListItem: import("styled-components").StyledComponent<"li", any, {
38
+ selected: boolean;
39
+ }, never>;