@redocly/theme 0.58.0-next.0 → 0.58.0-next.10

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 (163) hide show
  1. package/lib/components/Buttons/CopyButton.d.ts +1 -0
  2. package/lib/components/Buttons/CopyButton.js +3 -3
  3. package/lib/components/Catalog/Catalog.d.ts +2 -2
  4. package/lib/components/Catalog/Catalog.js +19 -5
  5. package/lib/components/Catalog/CatalogCardView/CatalogCard.js +15 -14
  6. package/lib/components/Catalog/CatalogEntitiesEmptyState.d.ts +2 -1
  7. package/lib/components/Catalog/CatalogEntitiesEmptyState.js +32 -11
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntity.d.ts +7 -7
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +13 -7
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityLinks.js +0 -1
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +6 -7
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.js +0 -1
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.js +6 -10
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.js +1 -1
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.js +5 -1
  16. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.d.ts +23 -0
  17. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +27 -0
  18. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +3 -2
  19. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +2 -2
  20. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +11 -2
  21. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +2 -1
  22. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +1 -1
  23. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.d.ts +2 -1
  24. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +2 -8
  25. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.d.ts +9 -2
  26. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +66 -30
  27. package/lib/components/Catalog/CatalogEntityIcon.d.ts +2 -0
  28. package/lib/components/Catalog/CatalogEntityIcon.js +31 -14
  29. package/lib/components/Catalog/CatalogEntityTypeIcon.js +19 -6
  30. package/lib/components/Catalog/CatalogEntityTypeTag.js +9 -3
  31. package/lib/components/Catalog/CatalogSelector.d.ts +1 -1
  32. package/lib/components/Catalog/CatalogTableView/CatalogEntityCell.js +1 -1
  33. package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.d.ts +1 -1
  34. package/lib/components/Catalog/CatalogTableView/CatalogEntityRelationCell.js +2 -2
  35. package/lib/components/Catalog/CatalogViewModeToggle.d.ts +1 -1
  36. package/lib/components/Catalog/variables.js +10 -7
  37. package/lib/components/CatalogClassic/CatalogClassic.js +9 -2
  38. package/lib/components/CodeBlock/CodeBlock.d.ts +5 -12
  39. package/lib/components/CodeBlock/CodeBlockControls.d.ts +3 -3
  40. package/lib/components/CodeBlock/CodeBlockDropdown.d.ts +2 -2
  41. package/lib/components/CodeBlock/CodeBlockDropdown.js +4 -13
  42. package/lib/components/CodeBlock/CodeBlockTabs.d.ts +2 -2
  43. package/lib/components/CodeBlock/CodeBlockTabs.js +4 -3
  44. package/lib/components/Filter/FilterContent.d.ts +1 -1
  45. package/lib/components/Search/SearchDialog.js +12 -6
  46. package/lib/components/Search/SearchFilter.js +2 -1
  47. package/lib/components/Tooltip/Tooltip.js +7 -9
  48. package/lib/components/Tooltip/TooltipWrapper.js +1 -1
  49. package/lib/core/constants/catalog.d.ts +2 -1
  50. package/lib/core/constants/catalog.js +40 -27
  51. package/lib/core/contexts/CodeSnippetContext.d.ts +14 -6
  52. package/lib/core/contexts/CodeSnippetContext.js +57 -14
  53. package/lib/core/hooks/catalog/useCatalogEntitySchema.d.ts +11 -0
  54. package/lib/core/hooks/catalog/useCatalogEntitySchema.js +39 -0
  55. package/lib/core/hooks/catalog/useCatalogTableViewRow.js +1 -1
  56. package/lib/core/hooks/use-active-section-id.js +4 -0
  57. package/lib/core/hooks/use-codeblock-tabs-controls.d.ts +2 -2
  58. package/lib/core/hooks/use-control.js +17 -2
  59. package/lib/core/hooks/use-local-state.js +22 -18
  60. package/lib/core/hooks/use-telemetry-fallback.d.ts +5 -0
  61. package/lib/core/hooks/use-telemetry-fallback.js +5 -0
  62. package/lib/core/openapi/index.d.ts +8 -4
  63. package/lib/core/openapi/index.js +9 -9
  64. package/lib/core/styles/global.js +19 -0
  65. package/lib/core/types/catalog.d.ts +8 -1
  66. package/lib/core/types/filter.d.ts +1 -1
  67. package/lib/core/types/hooks.d.ts +2 -2
  68. package/lib/core/types/index.d.ts +1 -0
  69. package/lib/core/types/index.js +1 -0
  70. package/lib/core/types/l10n.d.ts +1 -1
  71. package/lib/core/types/open-api-info.d.ts +34 -0
  72. package/lib/core/types/open-api-info.js +3 -0
  73. package/lib/core/types/open-api-server.d.ts +1 -0
  74. package/lib/core/types/search.d.ts +2 -3
  75. package/lib/core/utils/change-text-casing.d.ts +1 -1
  76. package/lib/core/utils/change-text-casing.js +3 -0
  77. package/lib/core/utils/urls.js +1 -1
  78. package/lib/ext/configure.d.ts +1 -0
  79. package/lib/ext/configure.js +4 -1
  80. package/lib/ext/useConfigureReplay.d.ts +19 -0
  81. package/lib/ext/useConfigureReplay.js +64 -0
  82. package/lib/icons/HierarchyIcon/HierarchyIcon.d.ts +9 -0
  83. package/lib/icons/HierarchyIcon/HierarchyIcon.js +23 -0
  84. package/lib/icons/NoteIcon/NoteIcon.d.ts +9 -0
  85. package/lib/icons/NoteIcon/NoteIcon.js +24 -0
  86. package/lib/icons/ShareIcon/ShareIcon.d.ts +9 -0
  87. package/lib/icons/ShareIcon/ShareIcon.js +22 -0
  88. package/lib/index.d.ts +2 -0
  89. package/lib/index.js +2 -0
  90. package/lib/layouts/DocumentationLayout.js +1 -3
  91. package/lib/markdoc/components/CodeGroup/CodeGroup.js +49 -27
  92. package/lib/markdoc/components/Tabs/Tabs.d.ts +2 -1
  93. package/lib/markdoc/components/Tabs/Tabs.js +3 -2
  94. package/package.json +5 -4
  95. package/src/components/Buttons/CopyButton.tsx +4 -1
  96. package/src/components/Catalog/Catalog.tsx +32 -7
  97. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +20 -19
  98. package/src/components/Catalog/CatalogEntitiesEmptyState.tsx +39 -16
  99. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +53 -12
  100. package/src/components/Catalog/CatalogEntity/CatalogEntityLinks.tsx +0 -1
  101. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +8 -7
  102. package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +0 -1
  103. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.tsx +15 -14
  104. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +1 -1
  105. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.tsx +6 -1
  106. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +125 -0
  107. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +5 -1
  108. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +30 -3
  109. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +4 -3
  110. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTableContent.tsx +3 -1
  111. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +1 -13
  112. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +84 -23
  113. package/src/components/Catalog/CatalogEntityIcon.tsx +53 -18
  114. package/src/components/Catalog/CatalogEntityTypeIcon.tsx +19 -8
  115. package/src/components/Catalog/CatalogEntityTypeTag.tsx +11 -3
  116. package/src/components/Catalog/CatalogSelector.tsx +1 -1
  117. package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +1 -1
  118. package/src/components/Catalog/CatalogTableView/CatalogEntityRelationCell.tsx +3 -3
  119. package/src/components/Catalog/CatalogViewModeToggle.tsx +1 -1
  120. package/src/components/Catalog/variables.ts +10 -7
  121. package/src/components/CatalogClassic/CatalogClassic.tsx +26 -10
  122. package/src/components/CodeBlock/CodeBlock.tsx +5 -11
  123. package/src/components/CodeBlock/CodeBlockControls.tsx +3 -6
  124. package/src/components/CodeBlock/CodeBlockDropdown.tsx +11 -20
  125. package/src/components/CodeBlock/CodeBlockTabs.tsx +8 -8
  126. package/src/components/Filter/FilterContent.tsx +3 -1
  127. package/src/components/Search/SearchDialog.tsx +14 -5
  128. package/src/components/Search/SearchFilter.tsx +2 -1
  129. package/src/components/Tooltip/Tooltip.tsx +6 -8
  130. package/src/components/Tooltip/TooltipWrapper.tsx +1 -1
  131. package/src/core/constants/catalog.ts +41 -27
  132. package/src/core/contexts/CodeSnippetContext.tsx +54 -18
  133. package/src/core/hooks/catalog/useCatalogEntitySchema.ts +46 -0
  134. package/src/core/hooks/catalog/useCatalogTableViewRow.ts +1 -1
  135. package/src/core/hooks/use-active-section-id.ts +6 -0
  136. package/src/core/hooks/use-codeblock-tabs-controls.ts +2 -2
  137. package/src/core/hooks/use-control.ts +21 -3
  138. package/src/core/hooks/use-local-state.ts +28 -19
  139. package/src/core/hooks/use-telemetry-fallback.ts +5 -0
  140. package/src/core/openapi/index.ts +8 -4
  141. package/src/core/styles/global.ts +19 -0
  142. package/src/core/types/catalog.ts +10 -2
  143. package/src/core/types/filter.ts +3 -1
  144. package/src/core/types/hooks.ts +6 -1
  145. package/src/core/types/index.ts +1 -0
  146. package/src/core/types/l10n.ts +3 -0
  147. package/src/core/types/open-api-info.ts +34 -0
  148. package/src/core/types/open-api-server.ts +1 -0
  149. package/src/core/types/search.ts +3 -3
  150. package/src/core/utils/change-text-casing.ts +8 -1
  151. package/src/core/utils/urls.ts +2 -1
  152. package/src/ext/configure.ts +5 -1
  153. package/src/ext/useConfigureReplay.ts +84 -0
  154. package/src/icons/HierarchyIcon/HierarchyIcon.tsx +32 -0
  155. package/src/icons/NoteIcon/NoteIcon.tsx +35 -0
  156. package/src/icons/ShareIcon/ShareIcon.tsx +23 -0
  157. package/src/index.ts +2 -0
  158. package/src/layouts/DocumentationLayout.tsx +3 -10
  159. package/src/markdoc/components/CodeGroup/CodeGroup.tsx +81 -52
  160. package/src/markdoc/components/Tabs/Tabs.tsx +10 -2
  161. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.d.ts +0 -6
  162. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.js +0 -32
  163. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.tsx +0 -46
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
 
4
4
  import { TableIcon } from '@redocly/theme/icons/TableIcon/TableIcon';
5
5
  import { CardsIcon } from '@redocly/theme/icons/CardsIcon/CardsIcon';
6
- import { CatalogViewMode } from '@redocly/theme/core/types/catalog';
6
+ import { CatalogViewMode } from '@redocly/theme/core/types';
7
7
 
8
8
  function useViewMode(initialViewMode: CatalogViewMode) {
9
9
  const [viewMode, setViewMode] = useState<CatalogViewMode | null>(null);
@@ -13,7 +13,7 @@ export const catalog = css`
13
13
  --catalog-filter-padding-vertical-mobile: 0;
14
14
  --catalog-filter-padding-horizontal-mobile: var(--spacing-base);
15
15
 
16
- --catalog-heading-margin: 0 0 var(--spacing-xl) 0;
16
+ --catalog-heading-margin: 0 0 var(--spacing-sm) 0;
17
17
  --catalog-sidebar-width: 285px;
18
18
 
19
19
  /**
@@ -130,10 +130,14 @@ export const catalog = css`
130
130
  --catalog-entity-border-color-api-operation: var(--color-raspberry-3);
131
131
  --catalog-entity-bg-color-api-operation: var(--color-raspberry-1);
132
132
 
133
+ --catalog-entity-icon-color-custom: var(--color-persian-green-8);
134
+ --catalog-entity-border-color-custom: var(--color-persian-green-5);
135
+ --catalog-entity-bg-color-custom: var(--color-persian-green-1);
136
+
133
137
  /**
134
138
  * @tokens Catalog tags
135
139
  */
136
- --catalog-tags-wrapper-gap: 4px;
140
+ --catalog-tags-wrapper-gap: var(--spacing-xs) calc(var(--spacing-xs) - 5px);
137
141
  --catalog-tags-more-button-font-size: var(--font-size-base);
138
142
  --catalog-tags-more-button-margin-left: 4px;
139
143
  --catalog-tags-placeholder-bg-color: var(--bg-color);
@@ -193,7 +197,7 @@ export const catalog = css`
193
197
  */
194
198
  --catalog-card-height: 241px;
195
199
  --catalog-card-min-width: 400px;
196
- --catalog-card-padding-vertical: var(--spacing-md);
200
+ --catalog-card-padding-vertical: var(--spacing-base);
197
201
  --catalog-card-padding-horizontal: var(--spacing-md);
198
202
  --catalog-card-gap: var(--spacing-sm);
199
203
  --catalog-card-text-color: var(--text-color-secondary);
@@ -223,12 +227,11 @@ export const catalog = css`
223
227
  /**
224
228
  * @tokens Catalog metadata
225
229
  */
226
- --catalog-metadata-section-margin-top: var(--spacing-md);
227
- --catalog-metadata-section-gap: var(--spacing-lg);
230
+ --catalog-metadata-section-margin-top: var(--spacing-base);
231
+ --catalog-metadata-section-gap: var(--spacing-xs);
228
232
  --catalog-metadata-label-font-size: var(--font-size-base);
229
233
  --catalog-metadata-label-font-weight: var(--font-weight-medium);
230
234
  --catalog-metadata-label-color: var(--text-color-secondary);
231
- --catalog-metadata-label-margin-bottom: var(--spacing-unit);
232
235
  --catalog-metadata-column-half-gap: var(--spacing-sm);
233
236
  --catalog-metadata-heading-size: var(--font-size-md);
234
237
 
@@ -263,7 +266,7 @@ export const catalog = css`
263
266
  --catalog-card-description-line-height: var(--line-height-base);
264
267
  --catalog-card-description-font-weight: var(--font-weight-regular);
265
268
  --catalog-card-description-height: 62px;
266
- --catalog-card-description-margin-top: 2px;
269
+ --catalog-card-description-margin-top: 8px;
267
270
 
268
271
  --catalog-card-content-gap: var(--spacing-xs);
269
272
  --catalog-card-content-gap-vertical: var(--spacing-sm);
@@ -8,6 +8,7 @@ import { breakpoints } from '@redocly/theme/core/utils';
8
8
  import { useThemeHooks, useModalScrollLock } from '@redocly/theme/core/hooks';
9
9
  import { H2 } from '@redocly/theme/components/Typography/H2';
10
10
  import { FilterContent } from '@redocly/theme/components/Filter/FilterContent';
11
+ import { FilterInput } from '@redocly/theme/components/Filter/FilterInput';
11
12
  import { FilterPopover } from '@redocly/theme/components/Filter/FilterPopover';
12
13
  import { HighlightContext } from '@redocly/theme/components/CatalogClassic/CatalogClassicHighlight';
13
14
  import { CatalogClassicActions } from '@redocly/theme/components/CatalogClassic/CatalogClassicActions';
@@ -37,16 +38,18 @@ export default function CatalogClassic(props: CatalogClassicProps): JSX.Element
37
38
  data-component-name="CatalogClassic/CatalogClassic"
38
39
  withoutFilters={!filters.length}
39
40
  >
40
- <FiltersSidebar
41
- menu={
42
- <FilterContent
43
- setFilterTerm={setFilterTerm}
44
- filters={filters}
45
- filterTerm={filterTerm}
46
- filterValuesCasing={catalogConfig.filterValuesCasing}
47
- />
48
- }
49
- />
41
+ {Boolean(filters.length) && (
42
+ <FiltersSidebar
43
+ menu={
44
+ <FilterContent
45
+ setFilterTerm={setFilterTerm}
46
+ filters={filters}
47
+ filterTerm={filterTerm}
48
+ filterValuesCasing={catalogConfig.filterValuesCasing}
49
+ />
50
+ }
51
+ />
52
+ )}
50
53
  {filterPopoverVisible && (
51
54
  <FilterPopover
52
55
  onClose={() => setFilterPopoverVisible(false)}
@@ -75,6 +78,14 @@ export default function CatalogClassic(props: CatalogClassicProps): JSX.Element
75
78
  {translate(catalogConfig.descriptionTranslationKey, catalogConfig.description)}{' '}
76
79
  </CatalogDescription>
77
80
  ) : null}
81
+ {!filters.length && (
82
+ <CatalogSearchWrapper>
83
+ <FilterInput
84
+ value={filterTerm}
85
+ onChange={(updatedTerm) => setFilterTerm(updatedTerm)}
86
+ />
87
+ </CatalogSearchWrapper>
88
+ )}
78
89
  </CatalogPageDescriptionWrapper>
79
90
 
80
91
  <CatalogClassicVirtualizedGroups
@@ -163,3 +174,8 @@ const FiltersSidebar = styled(Sidebar)`
163
174
  }
164
175
  --menu-container-padding-top: 0;
165
176
  `;
177
+
178
+ const CatalogSearchWrapper = styled.div`
179
+ margin-top: var(--spacing-base);
180
+ max-width: 300px;
181
+ `;
@@ -18,8 +18,8 @@ export type CodeBlockProps = {
18
18
  header?: CodeBlockControlsProps;
19
19
  dataTestId?: string;
20
20
  className?: string;
21
- tabs?: CodeBlockTabItems;
22
- dropdown?: CodeBlockDropdownItems;
21
+ tabs?: CodeBlockItems;
22
+ dropdown?: CodeBlockItems;
23
23
  withLineNumbers?: boolean;
24
24
  startLineNumber?: number;
25
25
  highlightedHtml?: string;
@@ -37,15 +37,9 @@ type UnstableExternalCodeSample = {
37
37
  get: (source: ExternalSource) => string;
38
38
  };
39
39
 
40
- export type CodeBlockTabItems = {
41
- items: { name: string; lang?: string }[];
42
- onChange: (name: string) => void;
43
- value: string;
44
- };
45
-
46
- export type CodeBlockDropdownItems = {
47
- items: { name: string; lang?: string }[];
48
- onChange: (name: string | string[]) => void;
40
+ export type CodeBlockItems = {
41
+ items: { name: string; lang?: string; id: string }[];
42
+ onChange: (id: string) => void;
49
43
  value: string;
50
44
  };
51
45
 
@@ -2,10 +2,7 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import type { JSX } from 'react';
5
- import type {
6
- CodeBlockDropdownItems,
7
- CodeBlockTabItems,
8
- } from '@redocly/theme/components/CodeBlock/CodeBlock';
5
+ import type { CodeBlockItems } from '@redocly/theme/components/CodeBlock/CodeBlock';
9
6
 
10
7
  import { CodeBlockTabs } from '@redocly/theme/components/CodeBlock/CodeBlockTabs';
11
8
  import { CopyButton } from '@redocly/theme/components/Buttons/CopyButton';
@@ -24,8 +21,8 @@ export type CodeBlockControlsProps = {
24
21
  className?: string;
25
22
  title?: React.ReactNode | string;
26
23
  controls?: ControlItems | false;
27
- tabs?: CodeBlockTabItems;
28
- dropdown?: CodeBlockDropdownItems;
24
+ tabs?: CodeBlockItems;
25
+ dropdown?: CodeBlockItems;
29
26
  };
30
27
 
31
28
  type ControlItems = {
@@ -1,24 +1,23 @@
1
1
  import React, { type JSX } from 'react';
2
- import styled from 'styled-components';
3
2
 
4
- import type { CodeBlockDropdownItems } from '@redocly/theme/components/CodeBlock/CodeBlock';
3
+ import type { CodeBlockItems } from '@redocly/theme/components/CodeBlock/CodeBlock';
5
4
 
6
5
  import { Dropdown } from '@redocly/theme/components/Dropdown/Dropdown';
7
6
  import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
8
7
  import { DropdownMenuItem } from '@redocly/theme/components/Dropdown/DropdownMenuItem';
9
8
  import { Button } from '@redocly/theme/components/Button/Button';
10
- import { ChevronSortIcon } from '@redocly/theme/icons/ChevronSortIcon/ChevronSortIcon';
11
9
  import { NoneIcon } from '@redocly/theme/icons/NoneIcon/NoneIcon';
12
10
  import { getFileIconByLanguage } from '@redocly/theme/core/utils';
13
11
 
14
- export function CodeBlockDropdown({ items, onChange, value }: CodeBlockDropdownItems): JSX.Element {
15
- const activeItem = items.find((item) => item.name === value) || items[0];
12
+ export function CodeBlockDropdown({ items, onChange, value }: CodeBlockItems): JSX.Element {
13
+ const activeItem = items.find((item) => item.id === value) || items[0];
16
14
  const icon = activeItem?.lang ? getFileIconByLanguage(activeItem?.lang) : null;
17
15
  return (
18
- <StyledDropdown
16
+ <Dropdown
17
+ withArrow
19
18
  alignment="end"
20
19
  trigger={
21
- <Button icon={<ChevronSortIcon />} iconPosition="right" variant="text" size="small">
20
+ <Button iconPosition="right" variant="ghost" size="small">
22
21
  {icon}
23
22
  {activeItem.name}
24
23
  </Button>
@@ -27,11 +26,12 @@ export function CodeBlockDropdown({ items, onChange, value }: CodeBlockDropdownI
27
26
  <DropdownMenu>
28
27
  {items.map((item) => {
29
28
  const icon = getFileIconByLanguage(item.lang || '');
29
+ const isActive = item.id === value;
30
30
  return (
31
31
  <DropdownMenuItem
32
- key={item.lang}
33
- onAction={() => onChange(item.name)}
34
- active={item.name === activeItem.name}
32
+ key={item.id}
33
+ onAction={() => onChange(item.id)}
34
+ active={isActive}
35
35
  prefix={item.lang ? icon : <NoneIcon size="var(--icon-size)" />}
36
36
  >
37
37
  {item.name}
@@ -39,15 +39,6 @@ export function CodeBlockDropdown({ items, onChange, value }: CodeBlockDropdownI
39
39
  );
40
40
  })}
41
41
  </DropdownMenu>
42
- </StyledDropdown>
42
+ </Dropdown>
43
43
  );
44
44
  }
45
-
46
- const StyledDropdown = styled(Dropdown)`
47
- margin-left: auto;
48
- --icon-size: 18px;
49
- --button-color: var(--text-color-secondary);
50
- button.button-size-small {
51
- --button-icon-size: 18px;
52
- }
53
- `;
@@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
2
  import styled, { css } from 'styled-components';
3
3
 
4
4
  import type { JSX } from 'react';
5
- import type { CodeBlockTabItems } from '@redocly/theme/components/CodeBlock/CodeBlock';
5
+ import type { CodeBlockItems } from '@redocly/theme/components/CodeBlock/CodeBlock';
6
6
 
7
7
  import { useCodeBlockTabsControls } from '@redocly/theme/core/hooks';
8
8
  import { Button } from '@redocly/theme/components/Button/Button';
@@ -11,7 +11,7 @@ import { ChevronRightIcon } from '@redocly/theme/icons/ChevronRightIcon/ChevronR
11
11
  import { getFileIconByExt, getFileIconByLanguage } from '@redocly/theme/core/utils/get-file-icon';
12
12
 
13
13
  export type CodeBlockTabsProps = {
14
- tabs: CodeBlockTabItems;
14
+ tabs: CodeBlockItems;
15
15
  };
16
16
 
17
17
  export function CodeBlockTabs({ tabs }: CodeBlockTabsProps): JSX.Element {
@@ -24,7 +24,7 @@ export function CodeBlockTabs({ tabs }: CodeBlockTabsProps): JSX.Element {
24
24
  });
25
25
 
26
26
  useEffect(() => {
27
- const activeTab = tabRefs.current.find((tab) => tab?.dataset.name === tabs.value);
27
+ const activeTab = tabRefs.current.find((tab) => tab?.dataset.id === tabs.value);
28
28
 
29
29
  if (activeTab) {
30
30
  activeTab.scrollIntoView({ block: 'nearest', inline: 'center' });
@@ -35,23 +35,23 @@ export function CodeBlockTabs({ tabs }: CodeBlockTabsProps): JSX.Element {
35
35
  <CodeBlockTabsWrapper ref={containerRef} data-component-name="CodeBlock/CodeBlockTabs">
36
36
  <ShadowWrapper>
37
37
  <Tabs>
38
- {tabs.items.map(({ name, lang }, i) => {
38
+ {tabs.items.map((item, i) => {
39
+ const { name, lang, id } = item;
39
40
  const ext = name.match(/\.([^.]+)$/)?.[1];
40
41
  const fileIcon = lang
41
42
  ? getFileIconByLanguage(lang)
42
43
  : ext
43
44
  ? getFileIconByExt(ext)
44
45
  : null;
45
-
46
46
  return (
47
47
  <Tab
48
48
  ref={(el: HTMLButtonElement | null) => {
49
49
  tabRefs.current[i] = el as HTMLButtonElement;
50
50
  }}
51
51
  data-name={name}
52
- active={name === tabs.value}
53
- key={name + i}
54
- onClick={() => tabs.onChange(name)}
52
+ active={id === tabs.value}
53
+ key={id}
54
+ onClick={() => tabs.onChange(id)}
55
55
  >
56
56
  {fileIcon}
57
57
  {name}
@@ -15,7 +15,9 @@ export type FilterContentProps = {
15
15
  setFilterTerm: (value: string) => void;
16
16
  filters: ResolvedFilter[];
17
17
  filterTerm: string;
18
- filterValuesCasing?: NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing'];
18
+ filterValuesCasing?:
19
+ | NonNullable<RedoclyConfig['catalog']>[string]['filterValuesCasing']
20
+ | ((str: string) => string);
19
21
  hideSearch?: boolean;
20
22
  showCounter?: boolean;
21
23
  };
@@ -306,13 +306,16 @@ export function SearchDialog({ onClose, className }: SearchDialogProps): JSX.Ele
306
306
  aria-selected="true"
307
307
  >
308
308
  <AiStarsIcon
309
+ style={{ flexShrink: 0 }}
309
310
  color="var(--search-ai-icon-color)"
310
311
  size="36px"
311
312
  background="var(--search-ai-icon-bg-color)"
312
313
  margin="0 var(--spacing-md) 0 0"
313
314
  borderRadius="var(--border-radius-lg)"
314
315
  />
315
- <Typography fontWeight="var(--font-weight-semibold)">{query}</Typography>
316
+ <QueryWrapper>
317
+ <Typography fontWeight="var(--font-weight-semibold)">{query}</Typography>
318
+ </QueryWrapper>
316
319
  <Typography>- {translate('search.ai.label', 'Ask AI assistant')}</Typography>
317
320
  <ReturnKeyIcon color="var(--search-item-text-color)" />
318
321
  </SearchWithAI>
@@ -484,10 +487,10 @@ const SearchDialogWrapper = styled.div`
484
487
  border-radius: 0;
485
488
 
486
489
  @media screen and (max-width: ${breakpoints.small}) {
487
- min-height: -webkit-fill-available !important;
488
- min-height: 100dvh !important;
489
- height: auto !important;
490
- width: 100vw !important;
490
+ min-height: -webkit-fill-available;
491
+ min-height: 100dvh;
492
+ height: 100dvh;
493
+ width: 100vw;
491
494
  }
492
495
 
493
496
  @media screen and (min-width: ${breakpoints.small}) {
@@ -539,6 +542,8 @@ const SearchDialogBodyMainView = styled.div`
539
542
 
540
543
  const SearchDialogBodyFilterView = styled.div`
541
544
  overflow: scroll;
545
+ max-width: var(--search-filter-width);
546
+ width: 100%;
542
547
  `;
543
548
 
544
549
  const SearchDialogFooter = styled.footer`
@@ -673,3 +678,7 @@ const SearchWithAI = styled.div`
673
678
  margin-right: var(--spacing-xs);
674
679
  }
675
680
  `;
681
+
682
+ const QueryWrapper = styled.div`
683
+ word-break: break-word;
684
+ `;
@@ -66,7 +66,8 @@ export function SearchFilter({
66
66
  }
67
67
 
68
68
  const SearchFilterWrapper = styled.div`
69
- width: var(--search-filter-width);
69
+ width: 100%;
70
+ max-width: var(--search-filter-width);
70
71
  display: flex;
71
72
  flex-direction: column;
72
73
  padding: var(--search-filter-padding);
@@ -98,14 +98,12 @@ export function TooltipComponent({
98
98
  }, [isOpened, placement, updateTooltipPosition]);
99
99
 
100
100
  useEffect(() => {
101
- if (isControlled && !disabled) {
102
- if (isOpen) {
103
- handleOpen();
104
- } else {
105
- handleClose();
106
- }
101
+ if (isOpen && !disabled) {
102
+ handleOpen();
103
+ } else {
104
+ handleClose();
107
105
  }
108
- }, [isOpen, isControlled, handleOpen, handleClose, disabled]);
106
+ }, [isOpen, handleOpen, handleClose, disabled]);
109
107
 
110
108
  const controllers = !isControlled &&
111
109
  !disabled && {
@@ -268,7 +266,7 @@ const TooltipBody = styled.span<
268
266
  display: inline-block;
269
267
 
270
268
  padding: var(--tooltip-padding);
271
- max-width: var(--tooltip-max-width);
269
+ max-width: ${({ width }) => width || 'var(--tooltip-max-width)'};
272
270
  white-space: normal;
273
271
  word-break: normal;
274
272
  overflow-wrap: break-word;
@@ -26,7 +26,7 @@ export function TooltipWrapper({
26
26
  showOnHover = true,
27
27
  disabled = false,
28
28
  }: TooltipWrapperProps): JSX.Element {
29
- const tooltip = useControl();
29
+ const tooltip = useControl(false);
30
30
 
31
31
  const handleMouseEnter = (): void => {
32
32
  if (showOnHover && !disabled) {
@@ -2,33 +2,15 @@ import type { EntityRelationType } from '../types/catalog';
2
2
 
3
3
  export const CATALOG_TAG_MAX_LENGTH = 15;
4
4
 
5
- export const ENTITY_RELATION_TYPES = [
6
- 'partOf',
7
- 'hasParts',
8
- 'creates',
9
- 'createdBy',
10
- 'owns',
11
- 'ownedBy',
12
- 'implements',
13
- 'implementedBy',
14
- 'dependsOn',
15
- 'dependencyOf',
16
- 'uses',
17
- 'usedBy',
18
- 'produces',
19
- 'consumes',
20
- 'linksTo',
21
- 'supersedes',
22
- 'supersededBy',
23
- 'compatibleWith',
24
- 'extends',
25
- 'extendedBy',
26
- 'relatesTo',
27
- 'hasMember',
28
- 'memberOf',
29
- 'triggers',
30
- 'triggeredBy',
31
- ] as const;
5
+ export const PREDEFINED_ENTITY_TYPES = [
6
+ 'service',
7
+ 'domain',
8
+ 'team',
9
+ 'user',
10
+ 'api-description',
11
+ 'data-schema',
12
+ 'api-operation',
13
+ ];
32
14
 
33
15
  export const reverseRelationMap: Record<EntityRelationType, EntityRelationType> = {
34
16
  partOf: 'hasParts',
@@ -56,8 +38,40 @@ export const reverseRelationMap: Record<EntityRelationType, EntityRelationType>
56
38
  memberOf: 'hasMember',
57
39
  triggers: 'triggeredBy',
58
40
  triggeredBy: 'triggers',
41
+ returns: 'returnedBy',
42
+ returnedBy: 'returns',
59
43
  } as const;
60
44
 
45
+ export const relationTypeMap: Record<EntityRelationType, string> = {
46
+ partOf: 'Part of',
47
+ hasParts: 'Has parts',
48
+ creates: 'Creates',
49
+ createdBy: 'Created by',
50
+ owns: 'Owns',
51
+ ownedBy: 'Owned by',
52
+ implements: 'Implements',
53
+ implementedBy: 'Implemented by',
54
+ dependsOn: 'Depends on',
55
+ dependencyOf: 'Dependency of',
56
+ uses: 'Uses',
57
+ usedBy: 'Used by',
58
+ produces: 'Produces',
59
+ consumes: 'Consumes',
60
+ linksTo: 'Links to',
61
+ supersedes: 'Supersedes',
62
+ supersededBy: 'Superseded by',
63
+ compatibleWith: 'Compatible with',
64
+ extends: 'Extends',
65
+ extendedBy: 'Extended by',
66
+ relatesTo: 'Relates to',
67
+ hasMember: 'Has member',
68
+ memberOf: 'Member of',
69
+ triggers: 'Triggers',
70
+ triggeredBy: 'Triggered by',
71
+ returns: 'Returns',
72
+ returnedBy: 'Returned by',
73
+ };
74
+
61
75
  export enum GraphHandleType {
62
76
  Target = 'target',
63
77
  Source = 'source',
@@ -1,31 +1,67 @@
1
- import { createContext, useContext, useState } from 'react';
1
+ import React, { createContext, useContext, useCallback, useMemo } from 'react';
2
2
 
3
- export type CodeSnippetContextType = {
4
- activeSnippetName: string;
5
- setActiveSnippetName: (name: string) => void;
6
- };
3
+ import { useLocalState } from '../hooks/use-local-state';
7
4
 
8
5
  export const CODE_GROUP_SNIPPET_NAME_KEY = 'redocly:codeGroupSnippetName';
9
6
 
7
+ type CodeSnippetContextType = {
8
+ activeSnippets: Record<string, string>;
9
+ setActiveSnippet: (groupId: string, snippetId: string) => void;
10
+ };
11
+
10
12
  export const CodeSnippetContext = createContext<CodeSnippetContextType | null>(null);
11
13
 
12
- export function useActiveCodeSnippetName(
13
- mode: 'tabs' | 'dropdown',
14
- ): [string, (name: string) => void] {
14
+ export function CodeSnippetProvider({ children }: { children: React.ReactNode }) {
15
+ const [activeSnippets, setActiveSnippets] = useLocalState<Record<string, string>>(
16
+ CODE_GROUP_SNIPPET_NAME_KEY,
17
+ {},
18
+ );
19
+
20
+ const setActiveSnippet = useCallback(
21
+ (groupId: string, snippetId: string) => {
22
+ setActiveSnippets({ ...activeSnippets, [groupId]: snippetId });
23
+ },
24
+ [activeSnippets, setActiveSnippets],
25
+ );
26
+
27
+ const contextValue = { activeSnippets, setActiveSnippet };
28
+
29
+ return <CodeSnippetContext.Provider value={contextValue}>{children}</CodeSnippetContext.Provider>;
30
+ }
31
+
32
+ export const useCodeSnippetContext = (): CodeSnippetContextType => {
15
33
  const context = useContext(CodeSnippetContext);
34
+
16
35
  if (!context) {
17
36
  throw new Error('useCodeSnippetContext must be used within a CodeSnippetContext');
18
37
  }
19
38
 
20
- const [activeSnippetName, setActiveSnippetName] = useState(
21
- mode === 'tabs' ? '' : context.activeSnippetName,
39
+ return context;
40
+ };
41
+
42
+ export const useActiveCodeSnippetId = (
43
+ groupId?: string,
44
+ availableSnippets?: { id: string }[],
45
+ ): [string, (id: string) => void] => {
46
+ const { activeSnippets, setActiveSnippet } = useCodeSnippetContext();
47
+
48
+ const storedSnippetId = groupId ? activeSnippets[groupId] || '' : '';
49
+
50
+ const activeId = useMemo(() => {
51
+ if (!availableSnippets?.length) return storedSnippetId;
52
+
53
+ const found = storedSnippetId && availableSnippets.find((s) => s.id === storedSnippetId);
54
+ return found ? storedSnippetId : availableSnippets[0]?.id || '';
55
+ }, [storedSnippetId, availableSnippets]);
56
+
57
+ const setActiveSnippetId = useCallback(
58
+ (id: string) => {
59
+ if (groupId) {
60
+ setActiveSnippet(groupId, id);
61
+ }
62
+ },
63
+ [groupId, setActiveSnippet],
22
64
  );
23
65
 
24
- if (mode === 'tabs') {
25
- // use non-synced state for tabs mode
26
- return [activeSnippetName, setActiveSnippetName];
27
- } else {
28
- // use global synced state for dropdown mode
29
- return [context.activeSnippetName, context.setActiveSnippetName];
30
- }
31
- }
66
+ return [activeId, setActiveSnippetId];
67
+ };
@@ -0,0 +1,46 @@
1
+ import { BffCatalogEntity, BffCatalogRelatedEntity } from '../../types';
2
+
3
+ type CatalogEntitySchemaProps = {
4
+ entity: BffCatalogEntity;
5
+ relatedEntity: BffCatalogRelatedEntity | null;
6
+ };
7
+
8
+ export function useCatalogEntitySchema({ entity, relatedEntity }: CatalogEntitySchemaProps) {
9
+ const { schema } = entity.metadata || {};
10
+
11
+ let parsedSchema;
12
+
13
+ try {
14
+ parsedSchema = JSON.parse(schema);
15
+ } catch (error) {
16
+ parsedSchema = undefined;
17
+ }
18
+
19
+ let parsedApiDefinition: any | undefined;
20
+
21
+ try {
22
+ parsedApiDefinition = relatedEntity?.metadata?.schema
23
+ ? JSON.parse(relatedEntity.metadata.schema)
24
+ : undefined;
25
+ } catch (err) {
26
+ parsedApiDefinition = undefined;
27
+ }
28
+
29
+ const definition: any =
30
+ !parsedApiDefinition || relatedEntity?.metadata?.specType !== 'openapi'
31
+ ? {
32
+ openapi: '3.0.0',
33
+ info: { version: '1', description: 'test', title: 'test' },
34
+ paths: {},
35
+ components: {
36
+ schemas: {},
37
+ },
38
+ }
39
+ : parsedApiDefinition;
40
+
41
+ return {
42
+ definition,
43
+ parsedSchema,
44
+ rawSchema: schema,
45
+ };
46
+ }
@@ -21,7 +21,7 @@ export function useCatalogTableViewRow({
21
21
  }
22
22
 
23
23
  return Object.values(entitiesCatalogConfig.catalogs ?? {}).find((catalog) => {
24
- return catalog.includes?.some((include) => include.type === entityType);
24
+ return catalog?.includes?.some((include) => include.type === entityType);
25
25
  });
26
26
  };
27
27
 
@@ -25,6 +25,12 @@ export function useActiveSectionId(
25
25
  setItemId('');
26
26
  return;
27
27
  }
28
+
29
+ if (window.scrollY <= 0) {
30
+ setItemId(sections[0].getAttribute('data-section-id') || '');
31
+ return;
32
+ }
33
+
28
34
  for (let i = 0; i < sections.length; i++) {
29
35
  const section = sections[i];
30
36
  const rect = section.getBoundingClientRect();
@@ -1,9 +1,9 @@
1
1
  import { useEffect, useState, useCallback, useMemo } from 'react';
2
2
 
3
- import type { CodeBlockTabItems } from '../../components/CodeBlock/CodeBlock';
3
+ import type { CodeBlockItems } from '../../components/CodeBlock/CodeBlock';
4
4
 
5
5
  type CodeBlockTabsProps = {
6
- tabs: CodeBlockTabItems;
6
+ tabs: CodeBlockItems;
7
7
  containerRef: React.RefObject<HTMLDivElement | null>;
8
8
  tabRefs: React.RefObject<HTMLButtonElement[]>;
9
9
  };