@redocly/theme 0.66.0 → 0.67.0-next.1

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 (201) hide show
  1. package/lib/components/Admonition/Admonition.js +9 -9
  2. package/lib/components/Badge/Badge.d.ts +1 -1
  3. package/lib/components/Badge/Badge.js +4 -4
  4. package/lib/components/Button/Button.d.ts +1 -1
  5. package/lib/components/Button/Button.js +16 -17
  6. package/lib/components/Buttons/AIAssistantButton.js +2 -0
  7. package/lib/components/Catalog/CatalogActionsRow.js +3 -1
  8. package/lib/components/Catalog/CatalogAvatar.d.ts +3 -1
  9. package/lib/components/Catalog/CatalogAvatar.js +3 -3
  10. package/lib/components/Catalog/CatalogCardView/CatalogCard.js +4 -4
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsNodeContent.js +7 -7
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntityInfoBar.js +6 -6
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.js +2 -2
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.js +4 -6
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +3 -5
  16. package/lib/components/Catalog/CatalogEntityTypeIcon.js +15 -11
  17. package/lib/components/Catalog/CatalogEntityTypeTag.js +5 -5
  18. package/lib/components/Catalog/CatalogTableView/CatalogTableView.js +5 -3
  19. package/lib/components/CatalogClassic/CatalogClassic.d.ts +4 -2
  20. package/lib/components/CatalogClassic/CatalogClassic.js +3 -1
  21. package/lib/components/CodeBlock/CodeBlockContainer.js +16 -4
  22. package/lib/components/CodeBlock/CodeBlockControls.d.ts +2 -1
  23. package/lib/components/CodeBlock/CodeBlockControls.js +9 -7
  24. package/lib/components/CodeBlock/CodeBlockTabs.js +2 -2
  25. package/lib/components/Dropdown/Dropdown.js +6 -6
  26. package/lib/components/Dropdown/DropdownMenuItem.d.ts +1 -1
  27. package/lib/components/Feedback/Comment.js +3 -3
  28. package/lib/components/Feedback/Mood.js +3 -3
  29. package/lib/components/Filter/FilterContent.js +2 -2
  30. package/lib/components/Footer/Footer.js +2 -2
  31. package/lib/components/Footer/FooterColumn.js +2 -2
  32. package/lib/components/Footer/FooterItem.js +5 -5
  33. package/lib/components/Image/Image.js +2 -2
  34. package/lib/components/LastUpdated/LastUpdated.js +2 -2
  35. package/lib/components/Link/Link.d.ts +2 -19
  36. package/lib/components/Link/Link.js +2 -9
  37. package/lib/components/Loaders/Loading.js +2 -2
  38. package/lib/components/Loaders/SpinnerLoader.js +4 -4
  39. package/lib/components/Markdown/Markdown.d.ts +7 -10
  40. package/lib/components/Markdown/Markdown.js +6 -3
  41. package/lib/components/Marker/Marker.js +3 -3
  42. package/lib/components/Menu/MenuContainer.d.ts +2 -2
  43. package/lib/components/Menu/MenuContainer.js +9 -11
  44. package/lib/components/Menu/MenuItem.js +14 -14
  45. package/lib/components/Menu/MenuMobile.js +8 -8
  46. package/lib/components/Navbar/NavbarItem.js +7 -7
  47. package/lib/components/PageNavigation/NavigationButton.js +3 -3
  48. package/lib/components/Panel/PanelBody.d.ts +5 -5
  49. package/lib/components/Panel/PanelBody.js +6 -3
  50. package/lib/components/Panel/PanelHeader.d.ts +2 -5
  51. package/lib/components/Panel/PanelHeader.js +6 -2
  52. package/lib/components/Search/SearchAiMessage.js +10 -8
  53. package/lib/components/Search/SearchDialog.js +6 -0
  54. package/lib/components/Search/SearchSuggestedPages.js +2 -2
  55. package/lib/components/Select/Select.js +3 -1
  56. package/lib/components/Select/SelectInput.d.ts +1 -0
  57. package/lib/components/Select/SelectInput.js +8 -8
  58. package/lib/components/Sidebar/Sidebar.d.ts +4 -2
  59. package/lib/components/Sidebar/Sidebar.js +10 -8
  60. package/lib/components/SidebarActions/styled.d.ts +6 -6
  61. package/lib/components/SidebarActions/styled.js +12 -4
  62. package/lib/components/StatusCode/StatusCode.d.ts +6 -4
  63. package/lib/components/StatusCode/StatusCode.js +8 -2
  64. package/lib/components/Switch/Switch.js +13 -13
  65. package/lib/components/TableOfContent/TableOfContent.js +2 -2
  66. package/lib/components/Tag/Tag.js +11 -11
  67. package/lib/components/Tooltip/AnchorTooltip.js +26 -25
  68. package/lib/components/Tooltip/JsTooltip.js +5 -5
  69. package/lib/components/Typography/CompactTypography.d.ts +27 -11
  70. package/lib/components/Typography/CompactTypography.js +2 -2
  71. package/lib/components/Typography/Typography.d.ts +6 -2
  72. package/lib/components/Typography/Typography.js +18 -3
  73. package/lib/components/UserMenu/UserAvatar.js +5 -5
  74. package/lib/core/contexts/ThemeDataContext.d.ts +1 -1
  75. package/lib/core/hooks/feedback/use-report-dialog.d.ts +8 -5
  76. package/lib/core/styles/global.js +1 -0
  77. package/lib/core/templates/Markdown.js +5 -6
  78. package/lib/core/types/index.d.ts +1 -0
  79. package/lib/core/types/link.d.ts +19 -0
  80. package/lib/core/types/link.js +3 -0
  81. package/lib/core/utils/details.d.ts +1 -1
  82. package/lib/core/utils/details.js +3 -0
  83. package/lib/core/utils/dom.d.ts +0 -1
  84. package/lib/core/utils/dom.js +0 -9
  85. package/lib/core/utils/index.d.ts +0 -1
  86. package/lib/core/utils/index.js +0 -1
  87. package/lib/icons/AiStarsGradientIcon/AiStarsGradientIcon.d.ts +1 -1
  88. package/lib/icons/AiStarsGradientIcon/AiStarsGradientIcon.js +6 -1
  89. package/lib/icons/AiStarsIcon/AiStarsIcon.d.ts +1 -1
  90. package/lib/icons/AiStarsIcon/AiStarsIcon.js +6 -1
  91. package/lib/icons/MagicWandIcon/MagicWandIcon.d.ts +23 -0
  92. package/lib/icons/MagicWandIcon/MagicWandIcon.js +25 -0
  93. package/lib/icons/ReturnKeyIcon/ReturnKeyIcon.d.ts +25 -5
  94. package/lib/index.d.ts +1 -0
  95. package/lib/index.js +1 -0
  96. package/lib/layouts/DocumentationLayout.js +2 -2
  97. package/lib/layouts/ThreePanelLayout.d.ts +27 -7
  98. package/lib/layouts/ThreePanelLayout.js +11 -8
  99. package/lib/markdoc/components/CodeWalkthrough/CodeContainer.js +2 -2
  100. package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +2 -2
  101. package/lib/markdoc/components/CodeWalkthrough/CodePanelPreview.js +2 -2
  102. package/lib/markdoc/components/CodeWalkthrough/CodeStep.d.ts +4 -2
  103. package/lib/markdoc/components/CodeWalkthrough/CodeStep.js +6 -2
  104. package/lib/markdoc/components/Image/Image.js +3 -3
  105. package/lib/markdoc/components/Tabs/TabItemFragment.d.ts +9 -0
  106. package/lib/markdoc/components/Tabs/TabItemFragment.js +11 -0
  107. package/lib/markdoc/components/Tabs/TabList.d.ts +7 -4
  108. package/lib/markdoc/components/Tabs/TabList.js +6 -4
  109. package/lib/markdoc/components/Tabs/Tabs.d.ts +3 -9
  110. package/lib/markdoc/components/Tabs/Tabs.js +12 -5
  111. package/lib/markdoc/components/default.d.ts +1 -0
  112. package/lib/markdoc/components/default.js +1 -0
  113. package/lib/markdoc/tags/tab.js +1 -1
  114. package/lib/markdoc/tags/tabs.js +1 -1
  115. package/package.json +2 -3
  116. package/src/components/Admonition/Admonition.tsx +11 -11
  117. package/src/components/Badge/Badge.tsx +11 -6
  118. package/src/components/Button/Button.tsx +51 -21
  119. package/src/components/Buttons/AIAssistantButton.tsx +2 -0
  120. package/src/components/Catalog/CatalogActionsRow.tsx +3 -1
  121. package/src/components/Catalog/CatalogAvatar.tsx +6 -10
  122. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +6 -6
  123. package/src/components/Catalog/CatalogEntity/CatalogEntityGraph/CatalogEntityRelationsNodeContent.tsx +14 -14
  124. package/src/components/Catalog/CatalogEntity/CatalogEntityInfoBar.tsx +11 -11
  125. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +4 -4
  126. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityApiDescriptionRelations.tsx +8 -11
  127. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +10 -9
  128. package/src/components/Catalog/CatalogEntityTypeIcon.tsx +22 -16
  129. package/src/components/Catalog/CatalogEntityTypeTag.tsx +8 -8
  130. package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +8 -6
  131. package/src/components/CatalogClassic/CatalogClassic.tsx +3 -1
  132. package/src/components/CodeBlock/CodeBlockContainer.tsx +23 -7
  133. package/src/components/CodeBlock/CodeBlockControls.tsx +16 -10
  134. package/src/components/CodeBlock/CodeBlockTabs.tsx +4 -4
  135. package/src/components/Dropdown/Dropdown.tsx +9 -9
  136. package/src/components/Dropdown/DropdownMenuItem.tsx +1 -1
  137. package/src/components/Feedback/Comment.tsx +5 -5
  138. package/src/components/Feedback/Mood.tsx +5 -5
  139. package/src/components/Filter/FilterContent.tsx +4 -4
  140. package/src/components/Filter/FilterPopover.tsx +1 -1
  141. package/src/components/Footer/Footer.tsx +4 -4
  142. package/src/components/Footer/FooterColumn.tsx +3 -3
  143. package/src/components/Footer/FooterItem.tsx +9 -9
  144. package/src/components/Image/Image.tsx +3 -3
  145. package/src/components/LastUpdated/LastUpdated.tsx +4 -4
  146. package/src/components/Link/Link.tsx +6 -51
  147. package/src/components/Loaders/Loading.tsx +3 -3
  148. package/src/components/Loaders/SpinnerLoader.tsx +5 -5
  149. package/src/components/Markdown/Markdown.tsx +7 -7
  150. package/src/components/Marker/Marker.tsx +4 -4
  151. package/src/components/Menu/MenuContainer.tsx +32 -16
  152. package/src/components/Menu/MenuItem.tsx +34 -29
  153. package/src/components/Menu/MenuMobile.tsx +12 -12
  154. package/src/components/Navbar/NavbarItem.tsx +13 -13
  155. package/src/components/PageNavigation/NavigationButton.tsx +4 -4
  156. package/src/components/Panel/PanelBody.tsx +7 -4
  157. package/src/components/Panel/PanelHeader.tsx +9 -4
  158. package/src/components/Search/SearchAiMessage.tsx +17 -15
  159. package/src/components/Search/SearchDialog.tsx +6 -0
  160. package/src/components/Search/SearchSuggestedPages.tsx +20 -5
  161. package/src/components/Select/Select.tsx +3 -1
  162. package/src/components/Select/SelectInput.tsx +10 -9
  163. package/src/components/Sidebar/Sidebar.tsx +15 -13
  164. package/src/components/SidebarActions/styled.ts +12 -4
  165. package/src/components/StatusCode/StatusCode.tsx +12 -4
  166. package/src/components/Switch/Switch.tsx +21 -21
  167. package/src/components/TableOfContent/TableOfContent.tsx +3 -3
  168. package/src/components/Tag/Tag.tsx +34 -27
  169. package/src/components/Tooltip/AnchorTooltip.tsx +50 -42
  170. package/src/components/Tooltip/JsTooltip.tsx +14 -13
  171. package/src/components/Typography/CompactTypography.tsx +4 -4
  172. package/src/components/Typography/Typography.tsx +21 -5
  173. package/src/components/UserMenu/UserAvatar.tsx +7 -7
  174. package/src/core/contexts/ThemeDataContext.tsx +1 -1
  175. package/src/core/hooks/feedback/use-report-dialog.ts +1 -5
  176. package/src/core/styles/dark.ts +1 -1
  177. package/src/core/styles/global.ts +1 -0
  178. package/src/core/templates/Markdown.tsx +6 -7
  179. package/src/core/types/index.ts +1 -0
  180. package/src/core/types/link.ts +20 -0
  181. package/src/core/utils/details.ts +4 -0
  182. package/src/core/utils/dom.ts +0 -8
  183. package/src/core/utils/index.ts +0 -1
  184. package/src/icons/AiStarsGradientIcon/AiStarsGradientIcon.tsx +9 -3
  185. package/src/icons/AiStarsIcon/AiStarsIcon.tsx +9 -3
  186. package/src/icons/MagicWandIcon/MagicWandIcon.tsx +26 -0
  187. package/src/icons/ReturnKeyIcon/ReturnKeyIcon.tsx +1 -1
  188. package/src/index.ts +1 -0
  189. package/src/layouts/DocumentationLayout.tsx +3 -3
  190. package/src/layouts/ThreePanelLayout.tsx +27 -14
  191. package/src/markdoc/components/CodeWalkthrough/CodeContainer.tsx +4 -4
  192. package/src/markdoc/components/CodeWalkthrough/CodePanelHeader.tsx +4 -4
  193. package/src/markdoc/components/CodeWalkthrough/CodePanelPreview.tsx +3 -3
  194. package/src/markdoc/components/CodeWalkthrough/CodeStep.tsx +6 -2
  195. package/src/markdoc/components/Image/Image.tsx +4 -4
  196. package/src/markdoc/components/Tabs/TabItemFragment.tsx +15 -0
  197. package/src/markdoc/components/Tabs/TabList.tsx +9 -6
  198. package/src/markdoc/components/Tabs/Tabs.tsx +21 -15
  199. package/src/markdoc/components/default.ts +1 -0
  200. package/src/markdoc/tags/tab.ts +1 -1
  201. package/src/markdoc/tags/tabs.ts +1 -1
@@ -1,26 +1,24 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { isValidElement, useEffect, useRef, useState } from 'react';
2
2
  import { useInRouterContext } from 'react-router-dom';
3
3
  import styled from 'styled-components';
4
4
 
5
- import type { JSX } from 'react';
5
+ import type { JSX, ReactElement, ReactNode } from 'react';
6
6
 
7
7
  import { useActiveTab } from '@redocly/theme/core/hooks';
8
+ import {
9
+ TabItemFragment,
10
+ type TabItemProps,
11
+ } from '@redocly/theme/markdoc/components/Tabs/TabItemFragment';
8
12
  import { TabList } from '@redocly/theme/markdoc/components/Tabs/TabList';
9
13
  import { getTabId } from '@redocly/theme/core/utils';
10
14
 
15
+ export type { TabItemProps } from '@redocly/theme/markdoc/components/Tabs/TabItemFragment';
16
+
11
17
  export enum TabsSize {
12
18
  SMALL = 'small',
13
19
  MEDIUM = 'medium',
14
20
  }
15
21
 
16
- export type TabItemProps = {
17
- label: string;
18
- disable?: boolean;
19
- onClick?: () => void;
20
- children: React.ReactNode;
21
- icon?: React.ReactNode | string;
22
- };
23
-
24
22
  type TabsProps = {
25
23
  id?: string;
26
24
  children: React.ReactElement<TabItemProps>[];
@@ -55,14 +53,17 @@ export function Tabs({
55
53
  size,
56
54
  initialTab: propInitialTab,
57
55
  activeTab: controlledActiveTab,
58
- }: TabsProps): JSX.Element {
59
- const childrenArray = React.Children.toArray(children) as React.ReactElement<TabItemProps>[];
56
+ }: TabsProps): JSX.Element | null {
57
+ const inRouter = useInRouterContext();
58
+ const childrenArray = React.Children.toArray(children).filter(isTabItemFragment);
60
59
  const containerRef = useRef<HTMLUListElement | null>(null);
61
60
 
62
- const initialTab = propInitialTab ?? childrenArray[0]?.props.label ?? '';
63
- const labelsHash = childrenArray.map((c) => c.props.label).join('|');
61
+ if (childrenArray.length === 0) {
62
+ return null;
63
+ }
64
64
 
65
- const inRouter = useInRouterContext();
65
+ const initialTab = propInitialTab ?? childrenArray[0].props.label;
66
+ const labelsHash = childrenArray.map((c) => c.props.label).join('|');
66
67
 
67
68
  return (
68
69
  <TabsView
@@ -127,6 +128,11 @@ function TabsView({
127
128
  );
128
129
  }
129
130
 
131
+ function isTabItemFragment(node: ReactNode): node is ReactElement<TabItemProps> {
132
+ if (!isValidElement(node)) return false;
133
+ return node.type === TabItemFragment;
134
+ }
135
+
130
136
  /**
131
137
  * Validates that the active tab exists in children and resets to initial tab if not found.
132
138
  * Ensures tab state remains consistent when tab structure changes.
@@ -4,6 +4,7 @@ export * from '@redocly/theme/markdoc/components/MarkdocExample/MarkdocExample';
4
4
  export * from '@redocly/theme/markdoc/components/Heading/Heading';
5
5
  export * from '@redocly/theme/markdoc/components/Diagram/Diagram';
6
6
  export * from '@redocly/theme/markdoc/components/HtmlBlock/HtmlBlock';
7
+ export * from '@redocly/theme/markdoc/components/Tabs/TabItemFragment';
7
8
  export * from '@redocly/theme/markdoc/components/Tabs/Tab';
8
9
  export * from '@redocly/theme/markdoc/components/Tabs/TabList';
9
10
  export * from '@redocly/theme/markdoc/components/Tabs/Tabs';
@@ -7,7 +7,7 @@ export const tab: MarkdocSchemaWrapper = {
7
7
  disable: { type: Boolean, default: false },
8
8
  icon: { type: String, resolver: 'relativeOrCdnIcon' },
9
9
  },
10
- render: 'div',
10
+ render: 'TabItemFragment',
11
11
  },
12
12
  tagName: 'tab',
13
13
  };
@@ -14,7 +14,7 @@ export const tabs: MarkdocSchemaWrapper = {
14
14
  if (isTag(child) && child?.name === 'CodeBlock') {
15
15
  const key = child.attributes['data-language'] || 'default';
16
16
  const label = child.attributes['data-label'] || key;
17
- return new markdoc.Tag('div', { label, key }, [child]);
17
+ return new markdoc.Tag('TabItemFragment', { label, key }, [child]);
18
18
  }
19
19
  return child;
20
20
  });