@redocly/theme 0.58.0-next.1 → 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 (120) 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 +1 -2
  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/CodeBlockDropdown.d.ts +2 -2
  25. package/lib/components/CodeBlock/CodeBlockDropdown.js +4 -13
  26. package/lib/components/CodeBlock/CodeBlockTabs.d.ts +2 -2
  27. package/lib/components/CodeBlock/CodeBlockTabs.js +4 -3
  28. package/lib/components/Search/SearchDialog.js +12 -6
  29. package/lib/components/Search/SearchFilter.js +2 -1
  30. package/lib/components/Tooltip/Tooltip.js +7 -9
  31. package/lib/components/Tooltip/TooltipWrapper.js +1 -1
  32. package/lib/core/constants/catalog.d.ts +1 -1
  33. package/lib/core/constants/catalog.js +13 -27
  34. package/lib/core/contexts/CodeSnippetContext.d.ts +14 -6
  35. package/lib/core/contexts/CodeSnippetContext.js +57 -14
  36. package/lib/core/hooks/catalog/useCatalogTableViewRow.js +1 -1
  37. package/lib/core/hooks/use-active-section-id.js +4 -0
  38. package/lib/core/hooks/use-codeblock-tabs-controls.d.ts +2 -2
  39. package/lib/core/hooks/use-control.js +17 -2
  40. package/lib/core/hooks/use-local-state.js +22 -18
  41. package/lib/core/hooks/use-telemetry-fallback.d.ts +5 -0
  42. package/lib/core/hooks/use-telemetry-fallback.js +5 -0
  43. package/lib/core/openapi/index.d.ts +8 -4
  44. package/lib/core/openapi/index.js +9 -9
  45. package/lib/core/styles/global.js +19 -0
  46. package/lib/core/types/catalog.d.ts +1 -1
  47. package/lib/core/types/hooks.d.ts +2 -2
  48. package/lib/core/types/index.d.ts +1 -0
  49. package/lib/core/types/index.js +1 -0
  50. package/lib/core/types/l10n.d.ts +1 -1
  51. package/lib/core/types/open-api-info.d.ts +34 -0
  52. package/lib/core/types/open-api-info.js +3 -0
  53. package/lib/core/types/open-api-server.d.ts +1 -0
  54. package/lib/core/types/search.d.ts +2 -3
  55. package/lib/core/utils/urls.js +1 -1
  56. package/lib/ext/useConfigureReplay.d.ts +2 -1
  57. package/lib/icons/HierarchyIcon/HierarchyIcon.d.ts +9 -0
  58. package/lib/icons/HierarchyIcon/HierarchyIcon.js +23 -0
  59. package/lib/icons/NoteIcon/NoteIcon.d.ts +9 -0
  60. package/lib/icons/NoteIcon/NoteIcon.js +24 -0
  61. package/lib/icons/ShareIcon/ShareIcon.d.ts +9 -0
  62. package/lib/icons/ShareIcon/ShareIcon.js +22 -0
  63. package/lib/index.d.ts +2 -0
  64. package/lib/index.js +2 -0
  65. package/lib/layouts/DocumentationLayout.js +1 -3
  66. package/lib/markdoc/components/CodeGroup/CodeGroup.js +49 -27
  67. package/lib/markdoc/components/Tabs/Tabs.d.ts +2 -1
  68. package/lib/markdoc/components/Tabs/Tabs.js +3 -2
  69. package/package.json +4 -4
  70. package/src/components/Catalog/Catalog.tsx +18 -6
  71. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +20 -19
  72. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +15 -2
  73. package/src/components/Catalog/CatalogEntity/CatalogEntityLinks.tsx +0 -1
  74. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +1 -2
  75. package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +0 -1
  76. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +1 -1
  77. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +1 -1
  78. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +31 -18
  79. package/src/components/Catalog/CatalogEntityIcon.tsx +53 -18
  80. package/src/components/Catalog/CatalogEntityTypeIcon.tsx +19 -8
  81. package/src/components/Catalog/CatalogEntityTypeTag.tsx +11 -3
  82. package/src/components/Catalog/CatalogSelector.tsx +1 -1
  83. package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +1 -1
  84. package/src/components/Catalog/CatalogViewModeToggle.tsx +1 -1
  85. package/src/components/Catalog/variables.ts +9 -6
  86. package/src/components/CatalogClassic/CatalogClassic.tsx +26 -10
  87. package/src/components/CodeBlock/CodeBlock.tsx +5 -11
  88. package/src/components/CodeBlock/CodeBlockControls.tsx +3 -6
  89. package/src/components/CodeBlock/CodeBlockDropdown.tsx +11 -20
  90. package/src/components/CodeBlock/CodeBlockTabs.tsx +8 -8
  91. package/src/components/Search/SearchDialog.tsx +14 -5
  92. package/src/components/Search/SearchFilter.tsx +2 -1
  93. package/src/components/Tooltip/Tooltip.tsx +6 -8
  94. package/src/components/Tooltip/TooltipWrapper.tsx +1 -1
  95. package/src/core/constants/catalog.ts +13 -27
  96. package/src/core/contexts/CodeSnippetContext.tsx +54 -18
  97. package/src/core/hooks/catalog/useCatalogTableViewRow.ts +1 -1
  98. package/src/core/hooks/use-active-section-id.ts +6 -0
  99. package/src/core/hooks/use-codeblock-tabs-controls.ts +2 -2
  100. package/src/core/hooks/use-control.ts +21 -3
  101. package/src/core/hooks/use-local-state.ts +28 -19
  102. package/src/core/hooks/use-telemetry-fallback.ts +5 -0
  103. package/src/core/openapi/index.ts +8 -4
  104. package/src/core/styles/global.ts +19 -0
  105. package/src/core/types/catalog.ts +1 -2
  106. package/src/core/types/hooks.ts +6 -1
  107. package/src/core/types/index.ts +1 -0
  108. package/src/core/types/l10n.ts +3 -0
  109. package/src/core/types/open-api-info.ts +34 -0
  110. package/src/core/types/open-api-server.ts +1 -0
  111. package/src/core/types/search.ts +3 -3
  112. package/src/core/utils/urls.ts +2 -1
  113. package/src/ext/useConfigureReplay.ts +2 -1
  114. package/src/icons/HierarchyIcon/HierarchyIcon.tsx +32 -0
  115. package/src/icons/NoteIcon/NoteIcon.tsx +35 -0
  116. package/src/icons/ShareIcon/ShareIcon.tsx +23 -0
  117. package/src/index.ts +2 -0
  118. package/src/layouts/DocumentationLayout.tsx +3 -10
  119. package/src/markdoc/components/CodeGroup/CodeGroup.tsx +81 -52
  120. package/src/markdoc/components/Tabs/Tabs.tsx +10 -2
@@ -1,6 +1,6 @@
1
1
  import type { JSX } from 'react';
2
- import type { CodeBlockTabItems } from '../../components/CodeBlock/CodeBlock';
2
+ import type { CodeBlockItems } from '../../components/CodeBlock/CodeBlock';
3
3
  export type CodeBlockTabsProps = {
4
- tabs: CodeBlockTabItems;
4
+ tabs: CodeBlockItems;
5
5
  };
6
6
  export declare function CodeBlockTabs({ tabs }: CodeBlockTabsProps): JSX.Element;
@@ -40,15 +40,16 @@ function CodeBlockTabs({ tabs }) {
40
40
  tabRefs,
41
41
  });
42
42
  (0, react_1.useEffect)(() => {
43
- const activeTab = tabRefs.current.find((tab) => (tab === null || tab === void 0 ? void 0 : tab.dataset.name) === tabs.value);
43
+ const activeTab = tabRefs.current.find((tab) => (tab === null || tab === void 0 ? void 0 : tab.dataset.id) === tabs.value);
44
44
  if (activeTab) {
45
45
  activeTab.scrollIntoView({ block: 'nearest', inline: 'center' });
46
46
  }
47
47
  }, [tabs.value]);
48
48
  return (react_1.default.createElement(CodeBlockTabsWrapper, { ref: containerRef, "data-component-name": "CodeBlock/CodeBlockTabs" },
49
49
  react_1.default.createElement(ShadowWrapper, null,
50
- react_1.default.createElement(Tabs, null, tabs.items.map(({ name, lang }, i) => {
50
+ react_1.default.createElement(Tabs, null, tabs.items.map((item, i) => {
51
51
  var _a;
52
+ const { name, lang, id } = item;
52
53
  const ext = (_a = name.match(/\.([^.]+)$/)) === null || _a === void 0 ? void 0 : _a[1];
53
54
  const fileIcon = lang
54
55
  ? (0, get_file_icon_1.getFileIconByLanguage)(lang)
@@ -57,7 +58,7 @@ function CodeBlockTabs({ tabs }) {
57
58
  : null;
58
59
  return (react_1.default.createElement(Tab, { ref: (el) => {
59
60
  tabRefs.current[i] = el;
60
- }, "data-name": name, active: name === tabs.value, key: name + i, onClick: () => tabs.onChange(name) },
61
+ }, "data-name": name, active: id === tabs.value, key: id, onClick: () => tabs.onChange(id) },
61
62
  fileIcon,
62
63
  name));
63
64
  }))),
@@ -190,8 +190,9 @@ function SearchDialog({ onClose, className }) {
190
190
  }
191
191
  }
192
192
  }, ref: aiQueryRef, tabIndex: 0, role: "option", "aria-selected": "true" },
193
- react_1.default.createElement(AiStarsIcon_1.AiStarsIcon, { color: "var(--search-ai-icon-color)", size: "36px", background: "var(--search-ai-icon-bg-color)", margin: "0 var(--spacing-md) 0 0", borderRadius: "var(--border-radius-lg)" }),
194
- react_1.default.createElement(Typography_1.Typography, { fontWeight: "var(--font-weight-semibold)" }, query),
193
+ react_1.default.createElement(AiStarsIcon_1.AiStarsIcon, { style: { flexShrink: 0 }, color: "var(--search-ai-icon-color)", size: "36px", background: "var(--search-ai-icon-bg-color)", margin: "0 var(--spacing-md) 0 0", borderRadius: "var(--border-radius-lg)" }),
194
+ react_1.default.createElement(QueryWrapper, null,
195
+ react_1.default.createElement(Typography_1.Typography, { fontWeight: "var(--font-weight-semibold)" }, query)),
195
196
  react_1.default.createElement(Typography_1.Typography, null,
196
197
  "- ",
197
198
  translate('search.ai.label', 'Ask AI assistant')),
@@ -268,10 +269,10 @@ const SearchDialogWrapper = styled_components_1.default.div `
268
269
  border-radius: 0;
269
270
 
270
271
  @media screen and (max-width: ${utils_1.breakpoints.small}) {
271
- min-height: -webkit-fill-available !important;
272
- min-height: 100dvh !important;
273
- height: auto !important;
274
- width: 100vw !important;
272
+ min-height: -webkit-fill-available;
273
+ min-height: 100dvh;
274
+ height: 100dvh;
275
+ width: 100vw;
275
276
  }
276
277
 
277
278
  @media screen and (min-width: ${utils_1.breakpoints.small}) {
@@ -318,6 +319,8 @@ const SearchDialogBodyMainView = styled_components_1.default.div `
318
319
  `;
319
320
  const SearchDialogBodyFilterView = styled_components_1.default.div `
320
321
  overflow: scroll;
322
+ max-width: var(--search-filter-width);
323
+ width: 100%;
321
324
  `;
322
325
  const SearchDialogFooter = styled_components_1.default.footer `
323
326
  display: flex;
@@ -439,4 +442,7 @@ const SearchWithAI = styled_components_1.default.div `
439
442
  margin-right: var(--spacing-xs);
440
443
  }
441
444
  `;
445
+ const QueryWrapper = styled_components_1.default.div `
446
+ word-break: break-word;
447
+ `;
442
448
  //# sourceMappingURL=SearchDialog.js.map
@@ -43,7 +43,8 @@ function SearchFilter({ className, facets, filter, query, quickFilterFields, onF
43
43
  React.createElement(SearchFilterFields, null, facets.map((facet, index) => (React.createElement(SearchFilterField_1.SearchFilterField, { key: `${facet.field}-${index}`, facet: facet, filter: filter, query: query, quickFilterFields: quickFilterFields, onFilterChange: onFilterChange, onFacetReset: onFacetReset }))))));
44
44
  }
45
45
  const SearchFilterWrapper = styled_components_1.default.div `
46
- width: var(--search-filter-width);
46
+ width: 100%;
47
+ max-width: var(--search-filter-width);
47
48
  display: flex;
48
49
  flex-direction: column;
49
50
  padding: var(--search-filter-padding);
@@ -91,15 +91,13 @@ function TooltipComponent({ children, isOpen, tip, withArrow = true, placement =
91
91
  }
92
92
  }, [isOpened, placement, updateTooltipPosition]);
93
93
  (0, react_1.useEffect)(() => {
94
- if (isControlled && !disabled) {
95
- if (isOpen) {
96
- handleOpen();
97
- }
98
- else {
99
- handleClose();
100
- }
94
+ if (isOpen && !disabled) {
95
+ handleOpen();
96
+ }
97
+ else {
98
+ handleClose();
101
99
  }
102
- }, [isOpen, isControlled, handleOpen, handleClose, disabled]);
100
+ }, [isOpen, handleOpen, handleClose, disabled]);
103
101
  const controllers = !isControlled &&
104
102
  !disabled && {
105
103
  onMouseEnter: handleOpen,
@@ -228,7 +226,7 @@ const TooltipBody = styled_components_1.default.span `
228
226
  display: inline-block;
229
227
 
230
228
  padding: var(--tooltip-padding);
231
- max-width: var(--tooltip-max-width);
229
+ max-width: ${({ width }) => width || 'var(--tooltip-max-width)'};
232
230
  white-space: normal;
233
231
  word-break: normal;
234
232
  overflow-wrap: break-word;
@@ -9,7 +9,7 @@ const react_1 = __importDefault(require("react"));
9
9
  const hooks_1 = require("../../core/hooks");
10
10
  const Tooltip_1 = require("../../components/Tooltip/Tooltip");
11
11
  function TooltipWrapper({ children, tip, placement = 'top', width = 'max-content', className = '', showOnHover = true, disabled = false, }) {
12
- const tooltip = (0, hooks_1.useControl)();
12
+ const tooltip = (0, hooks_1.useControl)(false);
13
13
  const handleMouseEnter = () => {
14
14
  if (showOnHover && !disabled) {
15
15
  tooltip.handleOpen();
@@ -1,6 +1,6 @@
1
1
  import type { EntityRelationType } from '../types/catalog';
2
2
  export declare const CATALOG_TAG_MAX_LENGTH = 15;
3
- export declare const ENTITY_RELATION_TYPES: readonly ["partOf", "hasParts", "creates", "createdBy", "owns", "ownedBy", "implements", "implementedBy", "dependsOn", "dependencyOf", "uses", "usedBy", "produces", "consumes", "linksTo", "supersedes", "supersededBy", "compatibleWith", "extends", "extendedBy", "relatesTo", "hasMember", "memberOf", "triggers", "triggeredBy"];
3
+ export declare const PREDEFINED_ENTITY_TYPES: string[];
4
4
  export declare const reverseRelationMap: Record<EntityRelationType, EntityRelationType>;
5
5
  export declare const relationTypeMap: Record<EntityRelationType, string>;
6
6
  export declare enum GraphHandleType {
@@ -1,33 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GraphCustomEdgeType = exports.GraphCustomNodeType = exports.GraphHandleType = exports.relationTypeMap = exports.reverseRelationMap = exports.ENTITY_RELATION_TYPES = exports.CATALOG_TAG_MAX_LENGTH = void 0;
3
+ exports.GraphCustomEdgeType = exports.GraphCustomNodeType = exports.GraphHandleType = exports.relationTypeMap = exports.reverseRelationMap = exports.PREDEFINED_ENTITY_TYPES = exports.CATALOG_TAG_MAX_LENGTH = void 0;
4
4
  exports.CATALOG_TAG_MAX_LENGTH = 15;
5
- exports.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',
5
+ exports.PREDEFINED_ENTITY_TYPES = [
6
+ 'service',
7
+ 'domain',
8
+ 'team',
9
+ 'user',
10
+ 'api-description',
11
+ 'data-schema',
12
+ 'api-operation',
31
13
  ];
32
14
  exports.reverseRelationMap = {
33
15
  partOf: 'hasParts',
@@ -55,6 +37,8 @@ exports.reverseRelationMap = {
55
37
  memberOf: 'hasMember',
56
38
  triggers: 'triggeredBy',
57
39
  triggeredBy: 'triggers',
40
+ returns: 'returnedBy',
41
+ returnedBy: 'returns',
58
42
  };
59
43
  exports.relationTypeMap = {
60
44
  partOf: 'Part of',
@@ -82,6 +66,8 @@ exports.relationTypeMap = {
82
66
  memberOf: 'Member of',
83
67
  triggers: 'Triggers',
84
68
  triggeredBy: 'Triggered by',
69
+ returns: 'Returns',
70
+ returnedBy: 'Returned by',
85
71
  };
86
72
  var GraphHandleType;
87
73
  (function (GraphHandleType) {
@@ -1,7 +1,15 @@
1
- export type CodeSnippetContextType = {
2
- activeSnippetName: string;
3
- setActiveSnippetName: (name: string) => void;
4
- };
1
+ import React from 'react';
5
2
  export declare const CODE_GROUP_SNIPPET_NAME_KEY = "redocly:codeGroupSnippetName";
6
- export declare const CodeSnippetContext: import("react").Context<CodeSnippetContextType | null>;
7
- export declare function useActiveCodeSnippetName(mode: 'tabs' | 'dropdown'): [string, (name: string) => void];
3
+ type CodeSnippetContextType = {
4
+ activeSnippets: Record<string, string>;
5
+ setActiveSnippet: (groupId: string, snippetId: string) => void;
6
+ };
7
+ export declare const CodeSnippetContext: React.Context<CodeSnippetContextType | null>;
8
+ export declare function CodeSnippetProvider({ children }: {
9
+ children: React.ReactNode;
10
+ }): React.JSX.Element;
11
+ export declare const useCodeSnippetContext: () => CodeSnippetContextType;
12
+ export declare const useActiveCodeSnippetId: (groupId?: string, availableSnippets?: {
13
+ id: string;
14
+ }[]) => [string, (id: string) => void];
15
+ export {};
@@ -1,23 +1,66 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CodeSnippetContext = exports.CODE_GROUP_SNIPPET_NAME_KEY = void 0;
4
- exports.useActiveCodeSnippetName = useActiveCodeSnippetName;
5
- const react_1 = require("react");
26
+ exports.useActiveCodeSnippetId = exports.useCodeSnippetContext = exports.CodeSnippetContext = exports.CODE_GROUP_SNIPPET_NAME_KEY = void 0;
27
+ exports.CodeSnippetProvider = CodeSnippetProvider;
28
+ const react_1 = __importStar(require("react"));
29
+ const use_local_state_1 = require("../hooks/use-local-state");
6
30
  exports.CODE_GROUP_SNIPPET_NAME_KEY = 'redocly:codeGroupSnippetName';
7
31
  exports.CodeSnippetContext = (0, react_1.createContext)(null);
8
- function useActiveCodeSnippetName(mode) {
32
+ function CodeSnippetProvider({ children }) {
33
+ const [activeSnippets, setActiveSnippets] = (0, use_local_state_1.useLocalState)(exports.CODE_GROUP_SNIPPET_NAME_KEY, {});
34
+ const setActiveSnippet = (0, react_1.useCallback)((groupId, snippetId) => {
35
+ setActiveSnippets(Object.assign(Object.assign({}, activeSnippets), { [groupId]: snippetId }));
36
+ }, [activeSnippets, setActiveSnippets]);
37
+ const contextValue = { activeSnippets, setActiveSnippet };
38
+ return react_1.default.createElement(exports.CodeSnippetContext.Provider, { value: contextValue }, children);
39
+ }
40
+ const useCodeSnippetContext = () => {
9
41
  const context = (0, react_1.useContext)(exports.CodeSnippetContext);
10
42
  if (!context) {
11
43
  throw new Error('useCodeSnippetContext must be used within a CodeSnippetContext');
12
44
  }
13
- const [activeSnippetName, setActiveSnippetName] = (0, react_1.useState)(mode === 'tabs' ? '' : context.activeSnippetName);
14
- if (mode === 'tabs') {
15
- // use non-synced state for tabs mode
16
- return [activeSnippetName, setActiveSnippetName];
17
- }
18
- else {
19
- // use global synced state for dropdown mode
20
- return [context.activeSnippetName, context.setActiveSnippetName];
21
- }
22
- }
45
+ return context;
46
+ };
47
+ exports.useCodeSnippetContext = useCodeSnippetContext;
48
+ const useActiveCodeSnippetId = (groupId, availableSnippets) => {
49
+ const { activeSnippets, setActiveSnippet } = (0, exports.useCodeSnippetContext)();
50
+ const storedSnippetId = groupId ? activeSnippets[groupId] || '' : '';
51
+ const activeId = (0, react_1.useMemo)(() => {
52
+ var _a;
53
+ if (!(availableSnippets === null || availableSnippets === void 0 ? void 0 : availableSnippets.length))
54
+ return storedSnippetId;
55
+ const found = storedSnippetId && availableSnippets.find((s) => s.id === storedSnippetId);
56
+ return found ? storedSnippetId : ((_a = availableSnippets[0]) === null || _a === void 0 ? void 0 : _a.id) || '';
57
+ }, [storedSnippetId, availableSnippets]);
58
+ const setActiveSnippetId = (0, react_1.useCallback)((id) => {
59
+ if (groupId) {
60
+ setActiveSnippet(groupId, id);
61
+ }
62
+ }, [groupId, setActiveSnippet]);
63
+ return [activeId, setActiveSnippetId];
64
+ };
65
+ exports.useActiveCodeSnippetId = useActiveCodeSnippetId;
23
66
  //# sourceMappingURL=CodeSnippetContext.js.map
@@ -10,7 +10,7 @@ function useCatalogTableViewRow({ entityKey, entityType, catalogConfig, entities
10
10
  }
11
11
  return Object.values((_a = entitiesCatalogConfig.catalogs) !== null && _a !== void 0 ? _a : {}).find((catalog) => {
12
12
  var _a;
13
- return (_a = catalog.includes) === null || _a === void 0 ? void 0 : _a.some((include) => include.type === entityType);
13
+ return (_a = catalog === null || catalog === void 0 ? void 0 : catalog.includes) === null || _a === void 0 ? void 0 : _a.some((include) => include.type === entityType);
14
14
  });
15
15
  };
16
16
  const getEntityDetailsLink = () => {
@@ -17,6 +17,10 @@ function useActiveSectionId(location, hasOverviewPage = false, withNavbar = true
17
17
  setItemId('');
18
18
  return;
19
19
  }
20
+ if (window.scrollY <= 0) {
21
+ setItemId(sections[0].getAttribute('data-section-id') || '');
22
+ return;
23
+ }
20
24
  for (let i = 0; i < sections.length; i++) {
21
25
  const section = sections[i];
22
26
  const rect = section.getBoundingClientRect();
@@ -1,6 +1,6 @@
1
- import type { CodeBlockTabItems } from '../../components/CodeBlock/CodeBlock';
1
+ import type { CodeBlockItems } from '../../components/CodeBlock/CodeBlock';
2
2
  type CodeBlockTabsProps = {
3
- tabs: CodeBlockTabItems;
3
+ tabs: CodeBlockItems;
4
4
  containerRef: React.RefObject<HTMLDivElement | null>;
5
5
  tabRefs: React.RefObject<HTMLButtonElement[]>;
6
6
  };
@@ -2,10 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useControl = void 0;
4
4
  const react_1 = require("react");
5
+ const DEFAULT_CONTROL_OPEN_DELAY = 300;
5
6
  const useControl = (initialVal = false) => {
6
7
  const [isOpened, setIsOpened] = (0, react_1.useState)(initialVal);
7
- const handleOpen = (0, react_1.useCallback)(() => setIsOpened(true), []);
8
- const handleClose = (0, react_1.useCallback)(() => setIsOpened(false), []);
8
+ const timeoutRef = (0, react_1.useRef)(null);
9
+ const clearOpenTimer = (0, react_1.useCallback)(() => {
10
+ if (timeoutRef.current) {
11
+ clearTimeout(timeoutRef.current);
12
+ }
13
+ }, []);
14
+ const handleOpen = (0, react_1.useCallback)(() => {
15
+ clearOpenTimer();
16
+ timeoutRef.current = setTimeout(() => {
17
+ setIsOpened(true);
18
+ }, DEFAULT_CONTROL_OPEN_DELAY);
19
+ }, [clearOpenTimer]);
20
+ const handleClose = (0, react_1.useCallback)(() => {
21
+ clearOpenTimer();
22
+ setIsOpened(false);
23
+ }, [clearOpenTimer]);
9
24
  return {
10
25
  isOpened,
11
26
  handleOpen,
@@ -2,31 +2,35 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useLocalState = useLocalState;
4
4
  const react_1 = require("react");
5
- function getInitialValue(key, initialValue) {
6
- if (typeof window === 'undefined') {
7
- return initialValue;
8
- }
5
+ const js_utils_1 = require("../utils/js-utils");
6
+ function getStoredValue(key, fallback) {
7
+ if (!(0, js_utils_1.isBrowser)())
8
+ return fallback;
9
9
  try {
10
10
  const savedValue = localStorage.getItem(key);
11
- if (savedValue) {
12
- return JSON.parse(savedValue);
13
- }
11
+ return savedValue ? JSON.parse(savedValue) : fallback;
14
12
  }
15
- catch (error) {
16
- console.error(`Error reading from localStorage for key "${key}":`, error);
13
+ catch (_a) {
14
+ return fallback;
17
15
  }
18
- return initialValue;
19
16
  }
20
17
  function useLocalState(key, initialValue) {
21
- const [value, setValue] = (0, react_1.useState)(() => getInitialValue(key, initialValue));
18
+ const [value, setValue] = (0, react_1.useState)(initialValue);
19
+ // Load stored value from localStorage after component mounts
20
+ // This ensures SSR compatibility: server and client both start with initialValue,
21
+ // then client loads the actual stored value without hydration mismatch
22
22
  (0, react_1.useEffect)(() => {
23
- try {
24
- localStorage.setItem(key, JSON.stringify(value));
25
- }
26
- catch (error) {
27
- console.error(`Error writing to localStorage for key "${key}":`, error);
23
+ if (!(0, js_utils_1.isBrowser)())
24
+ return;
25
+ setValue(getStoredValue(key, initialValue));
26
+ // eslint-disable-next-line react-hooks/exhaustive-deps
27
+ }, [key]);
28
+ const handleSetValue = (0, react_1.useCallback)((newValue) => {
29
+ setValue(newValue);
30
+ if ((0, js_utils_1.isBrowser)()) {
31
+ localStorage.setItem(key, JSON.stringify(newValue));
28
32
  }
29
- }, [key, value]);
30
- return [value, setValue];
33
+ }, [key]);
34
+ return [value, handleSetValue];
31
35
  }
32
36
  //# sourceMappingURL=use-local-state.js.map
@@ -57,4 +57,9 @@ export declare const useTelemetryFallback: () => {
57
57
  sendAsyncapiDocsMessageClickedMessage: () => void;
58
58
  sendAsyncapiDocsServerModalOpenedMessage: () => void;
59
59
  sendAsyncapiDocsDownloadDefinitionClickedMessage: () => void;
60
+ sendGraphqlDocsViewedMessage: () => void;
61
+ sendGraphqlDocsPerformanceMetricsMessage: () => void;
62
+ sendGraphqlDocsReferencedInLinkClickedMessage: () => void;
63
+ sendGraphqlDocsRequiredScopesModalOpenedMessage: () => void;
64
+ sendGraphqlDocsDownloadDefinitionClickedMessage: () => void;
60
65
  };
@@ -61,6 +61,11 @@ const useTelemetryFallback = () => ({
61
61
  sendAsyncapiDocsMessageClickedMessage: () => { },
62
62
  sendAsyncapiDocsServerModalOpenedMessage: () => { },
63
63
  sendAsyncapiDocsDownloadDefinitionClickedMessage: () => { },
64
+ sendGraphqlDocsViewedMessage: () => { },
65
+ sendGraphqlDocsPerformanceMetricsMessage: () => { },
66
+ sendGraphqlDocsReferencedInLinkClickedMessage: () => { },
67
+ sendGraphqlDocsRequiredScopesModalOpenedMessage: () => { },
68
+ sendGraphqlDocsDownloadDefinitionClickedMessage: () => { },
64
69
  });
65
70
  exports.useTelemetryFallback = useTelemetryFallback;
66
71
  //# sourceMappingURL=use-telemetry-fallback.js.map
@@ -1,3 +1,7 @@
1
+ export type { UserClaims } from '../types/user-claims';
2
+ export type { OperationParameter, ParameterHighlight } from '../types/search';
3
+ export type { TFunction, TOptions } from '../types/l10n';
4
+ export type { SelectOption, SelectProps } from '../types/select';
1
5
  export { IS_BROWSER } from '../utils/dom';
2
6
  export { addLeadingSlash, removeLeadingSlash, getPathPrefix, combineUrls, addTrailingSlash, withPathPrefix, } from '../utils/urls';
3
7
  export { typedMemo } from '../hoc/typedMemo';
@@ -5,15 +9,15 @@ export { useMount } from '../hooks/use-mount';
5
9
  export { GlobalStyle } from '../styles/global';
6
10
  export { breakpoints } from '../utils/media-css';
7
11
  export { isPrimitive } from '../utils/args-typecheck';
8
- export type { UserClaims } from '../types/user-claims';
12
+ export { ClipboardService } from '../utils/clipboard-service';
13
+ export { getUserAgent } from '../utils/get-user-agent';
9
14
  export { useFocusTrap } from '../hooks/use-focus-trap';
10
- export type { TFunction, TOptions } from '../types/l10n';
11
15
  export { useThemeHooks } from '../hooks/use-theme-hooks';
12
16
  export { useOutsideClick } from '../hooks/use-outside-click';
13
- export type { SelectOption, SelectProps } from '../types/select';
14
17
  export { useActiveSectionId } from '../hooks/use-active-section-id';
15
18
  export { useModalScrollLock } from '../hooks/use-modal-scroll-lock';
19
+ export { useSearchDialog } from '../hooks/search/use-search-dialog';
20
+ export { useDialogHotKeys } from '../hooks/use-dialog-hotkeys';
16
21
  export { SecurityVariablesEnvSuffix } from '../constants/environments';
17
22
  export { isUndefined, isString, isNotNull, isObject } from '../utils/type-guards';
18
23
  export { ThemeDataContext, type ThemeDataTransferObject } from '../contexts/ThemeDataContext';
19
- export { ENTITY_RELATION_TYPES } from '../constants/catalog';
@@ -1,12 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENTITY_RELATION_TYPES = exports.ThemeDataContext = exports.isObject = exports.isNotNull = exports.isString = exports.isUndefined = exports.SecurityVariablesEnvSuffix = exports.useModalScrollLock = exports.useActiveSectionId = exports.useOutsideClick = exports.useThemeHooks = exports.useFocusTrap = exports.isPrimitive = exports.breakpoints = exports.GlobalStyle = exports.useMount = exports.typedMemo = exports.withPathPrefix = exports.addTrailingSlash = exports.combineUrls = exports.getPathPrefix = exports.removeLeadingSlash = exports.addLeadingSlash = exports.IS_BROWSER = void 0;
4
- // This file is intended to provide selective imports from @redocly/theme/core
5
- // to reduce bundle size by exporting only functionality used in the @redocly/openapi-docs package.
6
- //
7
- // This selective import approach will help with tree shaking and reduce
8
- // the overall bundle size by avoiding importing the entire theme package
9
- // when only specific functionality is needed.
3
+ exports.ThemeDataContext = exports.isObject = exports.isNotNull = exports.isString = exports.isUndefined = exports.SecurityVariablesEnvSuffix = exports.useDialogHotKeys = exports.useSearchDialog = exports.useModalScrollLock = exports.useActiveSectionId = exports.useOutsideClick = exports.useThemeHooks = exports.useFocusTrap = exports.getUserAgent = exports.ClipboardService = exports.isPrimitive = exports.breakpoints = exports.GlobalStyle = exports.useMount = exports.typedMemo = exports.withPathPrefix = exports.addTrailingSlash = exports.combineUrls = exports.getPathPrefix = exports.removeLeadingSlash = exports.addLeadingSlash = exports.IS_BROWSER = void 0;
10
4
  var dom_1 = require("../utils/dom");
11
5
  Object.defineProperty(exports, "IS_BROWSER", { enumerable: true, get: function () { return dom_1.IS_BROWSER; } });
12
6
  var urls_1 = require("../utils/urls");
@@ -26,6 +20,10 @@ var media_css_1 = require("../utils/media-css");
26
20
  Object.defineProperty(exports, "breakpoints", { enumerable: true, get: function () { return media_css_1.breakpoints; } });
27
21
  var args_typecheck_1 = require("../utils/args-typecheck");
28
22
  Object.defineProperty(exports, "isPrimitive", { enumerable: true, get: function () { return args_typecheck_1.isPrimitive; } });
23
+ var clipboard_service_1 = require("../utils/clipboard-service");
24
+ Object.defineProperty(exports, "ClipboardService", { enumerable: true, get: function () { return clipboard_service_1.ClipboardService; } });
25
+ var get_user_agent_1 = require("../utils/get-user-agent");
26
+ Object.defineProperty(exports, "getUserAgent", { enumerable: true, get: function () { return get_user_agent_1.getUserAgent; } });
29
27
  var use_focus_trap_1 = require("../hooks/use-focus-trap");
30
28
  Object.defineProperty(exports, "useFocusTrap", { enumerable: true, get: function () { return use_focus_trap_1.useFocusTrap; } });
31
29
  var use_theme_hooks_1 = require("../hooks/use-theme-hooks");
@@ -36,6 +34,10 @@ var use_active_section_id_1 = require("../hooks/use-active-section-id");
36
34
  Object.defineProperty(exports, "useActiveSectionId", { enumerable: true, get: function () { return use_active_section_id_1.useActiveSectionId; } });
37
35
  var use_modal_scroll_lock_1 = require("../hooks/use-modal-scroll-lock");
38
36
  Object.defineProperty(exports, "useModalScrollLock", { enumerable: true, get: function () { return use_modal_scroll_lock_1.useModalScrollLock; } });
37
+ var use_search_dialog_1 = require("../hooks/search/use-search-dialog");
38
+ Object.defineProperty(exports, "useSearchDialog", { enumerable: true, get: function () { return use_search_dialog_1.useSearchDialog; } });
39
+ var use_dialog_hotkeys_1 = require("../hooks/use-dialog-hotkeys");
40
+ Object.defineProperty(exports, "useDialogHotKeys", { enumerable: true, get: function () { return use_dialog_hotkeys_1.useDialogHotKeys; } });
39
41
  var environments_1 = require("../constants/environments");
40
42
  Object.defineProperty(exports, "SecurityVariablesEnvSuffix", { enumerable: true, get: function () { return environments_1.SecurityVariablesEnvSuffix; } });
41
43
  var type_guards_1 = require("../utils/type-guards");
@@ -45,6 +47,4 @@ Object.defineProperty(exports, "isNotNull", { enumerable: true, get: function ()
45
47
  Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return type_guards_1.isObject; } });
46
48
  var ThemeDataContext_1 = require("../contexts/ThemeDataContext");
47
49
  Object.defineProperty(exports, "ThemeDataContext", { enumerable: true, get: function () { return ThemeDataContext_1.ThemeDataContext; } });
48
- var catalog_1 = require("../constants/catalog");
49
- Object.defineProperty(exports, "ENTITY_RELATION_TYPES", { enumerable: true, get: function () { return catalog_1.ENTITY_RELATION_TYPES; } });
50
50
  //# sourceMappingURL=index.js.map
@@ -773,6 +773,25 @@ const apiReferenceDocs = (0, styled_components_1.css) `
773
773
  --fab-icon-color: var(--navbar-text-color); // @presenter Color
774
774
 
775
775
  // @tokens End
776
+
777
+ /**
778
+ * @tokens OpenAPI Schema Catalog Link
779
+ */
780
+
781
+ --schema-catalog-link-margin-bottom: var(--spacing-lg);
782
+ --schema-catalog-link-padding: 2px;
783
+ --schema-catalog-link-border-radius: var(--border-radius-md);
784
+ --schema-catalog-link-background-color: var(--layer-color);
785
+ --schema-catalog-link-color: var(--color-purple-7);
786
+
787
+ --schema-catalog-link-share-icon-color: var(--color-purple-7);
788
+ --schema-catalog-link-share-icon-background-color: var(--color-purple-1);
789
+ --schema-catalog-link-share-icon-border-radius: var(--border-radius-md);
790
+ --schema-catalog-link-share-icon-wrapper-size: var(--spacing-xl);
791
+
792
+ --schema-catalog-link-text-color: var(--text-color-primary);
793
+
794
+ // @tokens End
776
795
  `;
777
796
  const badges = (0, styled_components_1.css) `
778
797
  /**
@@ -1,7 +1,7 @@
1
1
  import { InfiniteData, UseInfiniteQueryResult } from '@tanstack/react-query';
2
2
  import { CatalogEntityConfig, LayoutVariant } from '@redocly/config';
3
+ import { ENTITY_RELATION_TYPES } from '@redocly/config';
3
4
  import type { CatalogFilterConfig } from '../../config';
4
- import { ENTITY_RELATION_TYPES } from '../constants/catalog';
5
5
  export type SortOption = 'title' | '-title' | 'type' | '-type';
6
6
  export type UseCatalogResponse = {
7
7
  filters: ResolvedFilter[];
@@ -4,7 +4,7 @@ import type { ShikiTransformer } from '@shikijs/types';
4
4
  import type { Callback, TFunction as TFunc } from 'i18next';
5
5
  import type { To, Location, NavigateFunction } from 'react-router-dom';
6
6
  import type { CatalogConfig, ProductUiConfig } from '../../config';
7
- import type { UseCatalogResponse, CatalogApiResults, CatalogApiParams, FilteredCatalog, UseCatalogSortResponse, UseCatalogSearchResponse } from './catalog';
7
+ import type { UseCatalogResponse, CatalogApiResults, CatalogApiParams, FilteredCatalog, UseCatalogSortResponse, UseCatalogSearchResponse, CatalogViewMode } from './catalog';
8
8
  import type { UserMenuData } from './user-menu';
9
9
  import type { ItemState } from './sidebar';
10
10
  import type { SearchItemData, SearchFacet, SearchFilterItem, SearchFacetQuery, AiSearchConversationItem } from './search';
@@ -112,7 +112,7 @@ export type ThemeHooks = {
112
112
  prevPage?: ResolvedNavItemWithLink;
113
113
  nextPage?: ResolvedNavItemWithLink;
114
114
  } | undefined;
115
- useCatalog: (config?: CatalogEntityConfig, entitiesCounterInitial?: number) => UseCatalogResponse;
115
+ useCatalog: (config?: CatalogEntityConfig, entitiesCounterInitial?: number, initialViewMode?: CatalogViewMode) => UseCatalogResponse;
116
116
  useCatalogSort: () => UseCatalogSortResponse;
117
117
  useCatalogSearch: () => UseCatalogSearchResponse;
118
118
  useFetchCatalogEntities: (params: CatalogApiParams, initialData?: BffCatalogEntityList) => CatalogApiResults<BffCatalogEntity, BffCatalogEntityList>;
@@ -16,3 +16,4 @@ export * from './open-api-server';
16
16
  export * from './marker';
17
17
  export * from './code-walkthrough';
18
18
  export * from './page-actions';
19
+ export * from './open-api-info';
@@ -32,4 +32,5 @@ __exportStar(require("./open-api-server"), exports);
32
32
  __exportStar(require("./marker"), exports);
33
33
  __exportStar(require("./code-walkthrough"), exports);
34
34
  __exportStar(require("./page-actions"), exports);
35
+ __exportStar(require("./open-api-info"), exports);
35
36
  //# sourceMappingURL=index.js.map