@redocly/theme 0.58.0-next.1 → 0.58.0-next.11

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 (135) hide show
  1. package/lib/components/Catalog/Catalog.d.ts +2 -2
  2. package/lib/components/Catalog/Catalog.js +6 -4
  3. package/lib/components/Catalog/CatalogCardView/CatalogCard.js +15 -14
  4. package/lib/components/Catalog/CatalogEntity/CatalogEntity.d.ts +5 -1
  5. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +4 -4
  6. package/lib/components/Catalog/CatalogEntity/CatalogEntityLinks.js +0 -1
  7. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +3 -4
  8. package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.js +0 -1
  9. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.js +1 -1
  10. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +1 -1
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.d.ts +5 -1
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +9 -7
  13. package/lib/components/Catalog/CatalogEntityIcon.d.ts +2 -0
  14. package/lib/components/Catalog/CatalogEntityIcon.js +31 -14
  15. package/lib/components/Catalog/CatalogEntityTypeIcon.js +19 -6
  16. package/lib/components/Catalog/CatalogEntityTypeTag.js +9 -3
  17. package/lib/components/Catalog/CatalogSelector.d.ts +1 -1
  18. package/lib/components/Catalog/CatalogTableView/CatalogEntityCell.js +1 -1
  19. package/lib/components/Catalog/CatalogViewModeToggle.d.ts +1 -1
  20. package/lib/components/Catalog/variables.js +9 -6
  21. package/lib/components/CatalogClassic/CatalogClassic.js +9 -2
  22. package/lib/components/CodeBlock/CodeBlock.d.ts +5 -12
  23. package/lib/components/CodeBlock/CodeBlockControls.d.ts +3 -3
  24. package/lib/components/CodeBlock/CodeBlockControls.js +1 -1
  25. package/lib/components/CodeBlock/CodeBlockDropdown.d.ts +2 -2
  26. package/lib/components/CodeBlock/CodeBlockDropdown.js +4 -13
  27. package/lib/components/CodeBlock/CodeBlockTabs.d.ts +2 -2
  28. package/lib/components/CodeBlock/CodeBlockTabs.js +4 -3
  29. package/lib/components/JsonViewer/JsonViewer.d.ts +1 -1
  30. package/lib/components/JsonViewer/JsonViewer.js +9 -10
  31. package/lib/components/PageActions/PageActions.d.ts +4 -1
  32. package/lib/components/PageActions/PageActions.js +2 -2
  33. package/lib/components/Search/SearchDialog.js +12 -6
  34. package/lib/components/Search/SearchFilter.js +2 -1
  35. package/lib/components/Tooltip/Tooltip.js +7 -9
  36. package/lib/components/Tooltip/TooltipWrapper.js +1 -1
  37. package/lib/core/constants/catalog.d.ts +1 -1
  38. package/lib/core/constants/catalog.js +13 -27
  39. package/lib/core/contexts/CodeSnippetContext.d.ts +14 -6
  40. package/lib/core/contexts/CodeSnippetContext.js +57 -14
  41. package/lib/core/hooks/catalog/useCatalogTableViewRow.js +1 -1
  42. package/lib/core/hooks/use-active-section-id.js +4 -0
  43. package/lib/core/hooks/use-codeblock-tabs-controls.d.ts +2 -2
  44. package/lib/core/hooks/use-control.js +17 -2
  45. package/lib/core/hooks/use-local-state.js +22 -18
  46. package/lib/core/hooks/use-page-actions.d.ts +2 -1
  47. package/lib/core/hooks/use-page-actions.js +48 -6
  48. package/lib/core/hooks/use-telemetry-fallback.d.ts +5 -0
  49. package/lib/core/hooks/use-telemetry-fallback.js +5 -0
  50. package/lib/core/openapi/index.d.ts +9 -4
  51. package/lib/core/openapi/index.js +11 -9
  52. package/lib/core/styles/global.js +19 -0
  53. package/lib/core/types/catalog.d.ts +1 -1
  54. package/lib/core/types/hooks.d.ts +2 -2
  55. package/lib/core/types/index.d.ts +1 -0
  56. package/lib/core/types/index.js +1 -0
  57. package/lib/core/types/l10n.d.ts +1 -1
  58. package/lib/core/types/open-api-info.d.ts +34 -0
  59. package/lib/core/types/open-api-info.js +3 -0
  60. package/lib/core/types/open-api-server.d.ts +1 -0
  61. package/lib/core/types/search.d.ts +2 -3
  62. package/lib/core/utils/urls.js +1 -1
  63. package/lib/ext/useConfigureReplay.d.ts +2 -1
  64. package/lib/icons/CursorIcon/CursorIcon.d.ts +9 -0
  65. package/lib/icons/CursorIcon/CursorIcon.js +22 -0
  66. package/lib/icons/HierarchyIcon/HierarchyIcon.d.ts +9 -0
  67. package/lib/icons/HierarchyIcon/HierarchyIcon.js +23 -0
  68. package/lib/icons/NoteIcon/NoteIcon.d.ts +9 -0
  69. package/lib/icons/NoteIcon/NoteIcon.js +24 -0
  70. package/lib/icons/ShareIcon/ShareIcon.d.ts +9 -0
  71. package/lib/icons/ShareIcon/ShareIcon.js +22 -0
  72. package/lib/index.d.ts +2 -0
  73. package/lib/index.js +2 -0
  74. package/lib/layouts/DocumentationLayout.js +1 -3
  75. package/lib/markdoc/components/CodeGroup/CodeGroup.js +49 -27
  76. package/lib/markdoc/components/Tabs/TabList.js +2 -0
  77. package/lib/markdoc/components/Tabs/Tabs.d.ts +2 -1
  78. package/lib/markdoc/components/Tabs/Tabs.js +3 -2
  79. package/package.json +4 -4
  80. package/src/components/Catalog/Catalog.tsx +18 -6
  81. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +20 -19
  82. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +15 -2
  83. package/src/components/Catalog/CatalogEntity/CatalogEntityLinks.tsx +0 -1
  84. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +3 -4
  85. package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +0 -1
  86. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +1 -1
  87. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +1 -1
  88. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +27 -18
  89. package/src/components/Catalog/CatalogEntityIcon.tsx +53 -18
  90. package/src/components/Catalog/CatalogEntityTypeIcon.tsx +19 -8
  91. package/src/components/Catalog/CatalogEntityTypeTag.tsx +11 -3
  92. package/src/components/Catalog/CatalogSelector.tsx +1 -1
  93. package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +1 -1
  94. package/src/components/Catalog/CatalogViewModeToggle.tsx +1 -1
  95. package/src/components/Catalog/variables.ts +9 -6
  96. package/src/components/CatalogClassic/CatalogClassic.tsx +26 -10
  97. package/src/components/CodeBlock/CodeBlock.tsx +5 -11
  98. package/src/components/CodeBlock/CodeBlockControls.tsx +4 -7
  99. package/src/components/CodeBlock/CodeBlockDropdown.tsx +11 -20
  100. package/src/components/CodeBlock/CodeBlockTabs.tsx +8 -8
  101. package/src/components/JsonViewer/JsonViewer.tsx +16 -9
  102. package/src/components/PageActions/PageActions.tsx +6 -4
  103. package/src/components/Search/SearchDialog.tsx +14 -5
  104. package/src/components/Search/SearchFilter.tsx +2 -1
  105. package/src/components/Tooltip/Tooltip.tsx +6 -8
  106. package/src/components/Tooltip/TooltipWrapper.tsx +1 -1
  107. package/src/core/constants/catalog.ts +13 -27
  108. package/src/core/contexts/CodeSnippetContext.tsx +54 -18
  109. package/src/core/hooks/catalog/useCatalogTableViewRow.ts +1 -1
  110. package/src/core/hooks/use-active-section-id.ts +6 -0
  111. package/src/core/hooks/use-codeblock-tabs-controls.ts +2 -2
  112. package/src/core/hooks/use-control.ts +21 -3
  113. package/src/core/hooks/use-local-state.ts +28 -19
  114. package/src/core/hooks/use-page-actions.ts +63 -6
  115. package/src/core/hooks/use-telemetry-fallback.ts +5 -0
  116. package/src/core/openapi/index.ts +9 -4
  117. package/src/core/styles/global.ts +19 -0
  118. package/src/core/types/catalog.ts +1 -2
  119. package/src/core/types/hooks.ts +6 -1
  120. package/src/core/types/index.ts +1 -0
  121. package/src/core/types/l10n.ts +16 -0
  122. package/src/core/types/open-api-info.ts +34 -0
  123. package/src/core/types/open-api-server.ts +1 -0
  124. package/src/core/types/search.ts +3 -3
  125. package/src/core/utils/urls.ts +2 -1
  126. package/src/ext/useConfigureReplay.ts +2 -1
  127. package/src/icons/CursorIcon/CursorIcon.tsx +35 -0
  128. package/src/icons/HierarchyIcon/HierarchyIcon.tsx +32 -0
  129. package/src/icons/NoteIcon/NoteIcon.tsx +35 -0
  130. package/src/icons/ShareIcon/ShareIcon.tsx +23 -0
  131. package/src/index.ts +2 -0
  132. package/src/layouts/DocumentationLayout.tsx +3 -10
  133. package/src/markdoc/components/CodeGroup/CodeGroup.tsx +81 -52
  134. package/src/markdoc/components/Tabs/TabList.tsx +1 -0
  135. package/src/markdoc/components/Tabs/Tabs.tsx +10 -2
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { CatalogEntityIcon } from '@redocly/theme/components/Catalog/CatalogEntityIcon';
5
+ import { PREDEFINED_ENTITY_TYPES } from '@redocly/theme/core';
5
6
 
6
7
  export type CatalogEntityTypeIconProps = {
7
8
  entityType: string;
@@ -30,14 +31,24 @@ const IconContainer = styled.div<{ entityType: string; defaultColor: boolean }>`
30
31
  width: var(--catalog-table-icon-width);
31
32
  height: var(--catalog-table-icon-height);
32
33
  border-radius: var(--catalog-table-icon-border-radius);
33
- background-color: ${({ defaultColor, entityType }) =>
34
- defaultColor
35
- ? 'var(--catalog-entity-bg-color)'
36
- : `var(--catalog-entity-bg-color-${entityType})`};
34
+ background-color: ${({ defaultColor, entityType }) => {
35
+ if (defaultColor) {
36
+ return 'var(--catalog-entity-bg-color)';
37
+ }
38
+ if (PREDEFINED_ENTITY_TYPES.includes(entityType)) {
39
+ return `var(--catalog-entity-bg-color-${entityType})`;
40
+ }
41
+ return 'var(--catalog-entity-bg-color-custom)';
42
+ }};
37
43
  flex-shrink: 0;
38
44
  border: 1px solid
39
- ${({ defaultColor, entityType }) =>
40
- defaultColor
41
- ? 'var(--catalog-entity-border-color)'
42
- : `var(--catalog-entity-border-color-${entityType})`};
45
+ ${({ defaultColor, entityType }) => {
46
+ if (defaultColor) {
47
+ return 'var(--catalog-entity-border-color)';
48
+ }
49
+ if (PREDEFINED_ENTITY_TYPES.includes(entityType)) {
50
+ return `var(--catalog-entity-border-color-${entityType})`;
51
+ }
52
+ return 'var(--catalog-entity-border-color-custom)';
53
+ }};
43
54
  `;
@@ -4,6 +4,7 @@ import styled from 'styled-components';
4
4
  import { EntityType } from '@redocly/theme/core/types';
5
5
  import { Tag } from '@redocly/theme/components/Tag/Tag';
6
6
  import { CatalogHighlight } from '@redocly/theme/components/Catalog/CatalogHighlight';
7
+ import { PREDEFINED_ENTITY_TYPES } from '@redocly/theme/core';
7
8
 
8
9
  export type CatalogEntityTypeTagProps = {
9
10
  entityType: string;
@@ -43,7 +44,14 @@ export function CatalogEntityTypeTag({ entityType }: CatalogEntityTypeTagProps):
43
44
  const EntityTypeTagWrapper = styled(Tag)<{ entityType: EntityType }>`
44
45
  font-size: var(--font-size-base);
45
46
  background-color: transparent;
46
- text-transform: lowercase;
47
- border: 1px solid ${({ entityType }) => `var(--catalog-entity-border-color-${entityType})`};
48
- color: ${({ entityType }) => `var(--catalog-entity-icon-color-${entityType})`};
47
+ text-transform: none;
48
+ border: 1px solid
49
+ ${({ entityType }) =>
50
+ !PREDEFINED_ENTITY_TYPES.includes(entityType)
51
+ ? 'var(--catalog-entity-border-color-custom)'
52
+ : `var(--catalog-entity-border-color-${entityType})`};
53
+ color: ${({ entityType }) =>
54
+ !PREDEFINED_ENTITY_TYPES.includes(entityType)
55
+ ? 'var(--catalog-entity-icon-color-custom)'
56
+ : `var(--catalog-entity-icon-color-${entityType})`};
49
57
  `;
@@ -3,7 +3,7 @@ import styled from 'styled-components';
3
3
  import { useNavigate } from 'react-router-dom';
4
4
 
5
5
  import { Select } from '@redocly/theme/components/Select/Select';
6
- import { CatalogSwitcherItem, SortOption } from '@redocly/theme/core/types/catalog';
6
+ import { CatalogSwitcherItem, SortOption } from '@redocly/theme/core/types';
7
7
  import { getPathPrefix } from '@redocly/theme/core/utils';
8
8
  import { useThemeHooks } from '@redocly/theme/core/hooks';
9
9
  import { ChevronDownIcon } from '@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon';
@@ -13,7 +13,7 @@ export type CatalogEntityCellProps<T extends Entity> = {
13
13
  export function CatalogEntityCell<T extends Entity>({ entity }: CatalogEntityCellProps<T>) {
14
14
  return (
15
15
  <EntityTitleCellWrapper data-component-name="Catalog/CatalogTableView/CatalogEntityCell">
16
- <CatalogEntityTypeIcon entityType={entity.type} defaultColor={true} />
16
+ <CatalogEntityTypeIcon entityType={entity.type} />
17
17
  <EntityTitleContent>
18
18
  <EntityTitle data-component-name="Catalog/CatalogTableView/CatalogEntityTitle">
19
19
  <CatalogHighlight>{entity.title}</CatalogHighlight>
@@ -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);
@@ -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 = {
@@ -87,7 +84,7 @@ export function CodeBlockControls({
87
84
  {tabs && <CodeBlockTabs tabs={tabs} />}
88
85
  <ControlsWrapper>
89
86
  {dropdown && <CodeBlockDropdown {...dropdown} />}
90
- {report && !report?.props?.hide ? (
87
+ {report && !report.hidden && !report?.props?.hide ? (
91
88
  <TooltipWrapper
92
89
  tip={translate('codeSnippet.report.tooltipText', 'Report a problem')}
93
90
  placement="top"
@@ -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}
@@ -12,11 +12,11 @@ export type PanelType = 'request' | 'responses' | 'request-samples' | 'response-
12
12
 
13
13
  export type JsonProps = {
14
14
  title?: CodeBlockControlsProps['title'];
15
+ controls?: CodeBlockControlsProps['controls'];
15
16
  data: any;
16
17
  className?: string;
17
18
  expandLevel: number;
18
19
  startLineNumber?: number;
19
- hideHeader?: boolean;
20
20
  onCopyClick?: () => void;
21
21
  onPanelToggle?: (isExpanded: boolean, panelType?: PanelType) => void;
22
22
  };
@@ -28,7 +28,7 @@ function JsonComponent({
28
28
  onCopyClick,
29
29
  onPanelToggle,
30
30
  title,
31
- hideHeader,
31
+ controls = {},
32
32
  }: JsonProps): JSX.Element {
33
33
  const showFoldingButtons =
34
34
  data && Object.values(data).some((value) => typeof value === 'object' && value !== null);
@@ -53,6 +53,8 @@ function JsonComponent({
53
53
 
54
54
  const source = JSON.stringify(data, null, 2);
55
55
 
56
+ const hasHeader = title || controls;
57
+
56
58
  return (
57
59
  <JsonViewerWrap
58
60
  data-testid="json-viewer"
@@ -61,17 +63,22 @@ function JsonComponent({
61
63
  >
62
64
  <CodeBlock
63
65
  header={
64
- hideHeader
65
- ? undefined
66
- : {
66
+ hasHeader
67
+ ? {
67
68
  title,
68
69
  className: 'code-block-header',
69
- controls: {
70
- copy: { data, onClick: onCopyClick, handleOutside: true },
71
- expand: showFoldingButtons ? { onClick: expandAll } : undefined,
72
- collapse: showFoldingButtons ? { onClick: collapseAll } : undefined,
70
+ controls: controls && {
71
+ ...controls,
72
+ copy: { ...controls.copy, data, onClick: onCopyClick, handleOutside: true },
73
+ expand: showFoldingButtons
74
+ ? { ...controls.expand, onClick: expandAll }
75
+ : undefined,
76
+ collapse: showFoldingButtons
77
+ ? { ...controls.collapse, onClick: collapseAll }
78
+ : undefined,
73
79
  },
74
80
  }
81
+ : undefined
75
82
  }
76
83
  source={source}
77
84
  >
@@ -13,20 +13,22 @@ import { Dropdown } from '@redocly/theme/components/Dropdown/Dropdown';
13
13
  import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
14
14
  import { Spinner } from '@redocly/theme/icons/Spinner/Spinner';
15
15
  import { CheckmarkFilledIcon } from '@redocly/theme/icons/CheckmarkFilledIcon/CheckmarkFilledIcon';
16
- import { usePageActions } from '@redocly/theme/core/hooks';
16
+ import { PageActionType, usePageActions } from '@redocly/theme/core/hooks';
17
17
 
18
18
  type ActionState = 'idle' | 'processing' | 'done';
19
19
 
20
20
  type PageActionProps = {
21
- pageSlug: string;
21
+ pageSlug?: string;
22
+ mcpUrl?: string;
23
+ actions?: PageActionType[];
22
24
  };
23
25
 
24
26
  const ACTION_DONE_DISPLAY_DURATION = 1000;
25
27
 
26
28
  export function PageActions(props: PageActionProps): JSX.Element | null {
27
- const { pageSlug } = props;
29
+ const { pageSlug, mcpUrl } = props;
28
30
 
29
- const actions = usePageActions(pageSlug || '/');
31
+ const actions = usePageActions(pageSlug || '/', mcpUrl, props.actions);
30
32
 
31
33
  const [actionState, setActionState] = useState<ActionState>('idle');
32
34
 
@@ -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,6 +38,8 @@ 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
 
61
45
  export const relationTypeMap: Record<EntityRelationType, string> = {
@@ -84,6 +68,8 @@ export const relationTypeMap: Record<EntityRelationType, string> = {
84
68
  memberOf: 'Member of',
85
69
  triggers: 'Triggers',
86
70
  triggeredBy: 'Triggered by',
71
+ returns: 'Returns',
72
+ returnedBy: 'Returned by',
87
73
  };
88
74
 
89
75
  export enum GraphHandleType {