@redocly/theme 0.56.0-rc.2 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/lib/components/Breadcrumbs/Breadcrumbs.js +1 -1
  2. package/lib/components/Button/Button.d.ts +1 -1
  3. package/lib/components/Button/Button.js +3 -1
  4. package/lib/components/Button/ButtonGroup.d.ts +12 -0
  5. package/lib/components/Button/ButtonGroup.js +38 -0
  6. package/lib/components/Button/variables.js +32 -5
  7. package/lib/components/Catalog/Catalog.d.ts +1 -1
  8. package/lib/components/Catalog/CatalogCardView/CatalogCard.js +11 -6
  9. package/lib/components/Catalog/CatalogEntitiesEmptyState.d.ts +5 -1
  10. package/lib/components/Catalog/CatalogEntitiesEmptyState.js +25 -4
  11. package/lib/components/Catalog/CatalogEntity/CatalogEntity.d.ts +1 -3
  12. package/lib/components/Catalog/CatalogEntity/CatalogEntity.js +17 -13
  13. package/lib/components/Catalog/CatalogEntity/CatalogEntityInfoBar.d.ts +4 -2
  14. package/lib/components/Catalog/CatalogEntity/CatalogEntityInfoBar.js +15 -7
  15. package/lib/components/Catalog/CatalogEntity/CatalogEntityLinks.js +6 -6
  16. package/lib/components/Catalog/CatalogEntity/CatalogEntityMetadata.js +18 -1
  17. package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.d.ts +6 -0
  18. package/lib/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.js +47 -0
  19. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.js +8 -1
  20. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.js +7 -1
  21. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.d.ts +2 -1
  22. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.js +12 -5
  23. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.js +1 -1
  24. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.js +3 -3
  25. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/EntityTypeProperty.js +7 -2
  26. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.d.ts +6 -0
  27. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.js +19 -0
  28. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/GitProperty.js +1 -1
  29. package/lib/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.js +2 -1
  30. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.d.ts +2 -1
  31. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.js +4 -10
  32. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.d.ts +3 -1
  33. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.js +2 -6
  34. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.d.ts +3 -2
  35. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.js +5 -5
  36. package/lib/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.js +3 -3
  37. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.d.ts +6 -0
  38. package/lib/components/Catalog/CatalogEntity/CatalogEntitySchema.js +55 -0
  39. package/lib/components/Catalog/CatalogEntityIcon.d.ts +2 -1
  40. package/lib/components/Catalog/CatalogEntityIcon.js +22 -29
  41. package/lib/components/Catalog/CatalogEntityTypeIcon.d.ts +2 -1
  42. package/lib/components/Catalog/CatalogEntityTypeIcon.js +11 -23
  43. package/lib/components/Catalog/CatalogEntityTypeTag.d.ts +7 -0
  44. package/lib/components/Catalog/CatalogEntityTypeTag.js +40 -0
  45. package/lib/components/Catalog/CatalogPageDescription.js +3 -3
  46. package/lib/components/Catalog/CatalogSelector.d.ts +1 -1
  47. package/lib/components/Catalog/CatalogSelector.js +4 -3
  48. package/lib/components/Catalog/CatalogSortButton.js +6 -6
  49. package/lib/components/Catalog/CatalogTableView/CatalogDomainsCell.js +1 -0
  50. package/lib/components/Catalog/CatalogTableView/CatalogEntityCell.js +3 -15
  51. package/lib/components/Catalog/CatalogTableView/CatalogOwnersCell.js +1 -0
  52. package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.d.ts +1 -1
  53. package/lib/components/Catalog/CatalogTableView/CatalogTableHeaderCell.js +1 -5
  54. package/lib/components/Catalog/CatalogTableView/CatalogTableView.d.ts +3 -3
  55. package/lib/components/Catalog/CatalogTableView/CatalogTableView.js +5 -32
  56. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.d.ts +0 -2
  57. package/lib/components/Catalog/CatalogTableView/CatalogTableViewRow.js +12 -37
  58. package/lib/components/Catalog/CatalogTableView/CatalogTagsCell.js +1 -0
  59. package/lib/components/Catalog/CatalogTableView/CatalogUserEntityCell.js +8 -4
  60. package/lib/components/Catalog/CatalogTagsWithTooltip.d.ts +1 -1
  61. package/lib/components/Catalog/CatalogTagsWithTooltip.js +4 -4
  62. package/lib/components/Catalog/CatalogViewModeToggle.d.ts +1 -1
  63. package/lib/components/Catalog/variables.js +42 -8
  64. package/lib/components/CodeBlock/CodeBlock.d.ts +16 -6
  65. package/lib/components/CodeBlock/CodeBlock.js +3 -2
  66. package/lib/components/CodeBlock/CodeBlockControls.d.ts +4 -3
  67. package/lib/components/CodeBlock/CodeBlockControls.js +35 -8
  68. package/lib/components/CodeBlock/CodeBlockDropdown.d.ts +3 -0
  69. package/lib/components/CodeBlock/CodeBlockDropdown.js +35 -0
  70. package/lib/components/CodeBlock/CodeBlockTabs.d.ts +2 -2
  71. package/lib/components/CodeBlock/CodeBlockTabs.js +18 -9
  72. package/lib/components/CodeBlock/variables.js +1 -1
  73. package/lib/components/Dropdown/Dropdown.js +1 -0
  74. package/lib/components/Dropdown/DropdownMenu.js +4 -0
  75. package/lib/components/Dropdown/variables.js +1 -0
  76. package/lib/components/Feedback/Feedback.js +1 -1
  77. package/lib/components/Filter/FilterCheckboxes.js +5 -2
  78. package/lib/components/Footer/FooterItem.js +4 -7
  79. package/lib/components/Footer/variables.js +2 -2
  80. package/lib/components/Image/Image.js +2 -0
  81. package/lib/components/Markdown/Markdown.js +9 -9
  82. package/lib/components/Markdown/styles/headingAnchor.js +0 -1
  83. package/lib/components/Menu/MenuItem.js +5 -5
  84. package/lib/components/Menu/variables.js +3 -1
  85. package/lib/components/Navbar/NavbarItem.js +8 -39
  86. package/lib/components/Navbar/variables.js +2 -2
  87. package/lib/components/PageActions/PageActions.d.ts +6 -0
  88. package/lib/components/PageActions/PageActions.js +104 -0
  89. package/lib/components/PageActions/PageActionsMenuItem.d.ts +7 -0
  90. package/lib/components/PageActions/PageActionsMenuItem.js +58 -0
  91. package/lib/components/PageActions/variables.d.ts +1 -0
  92. package/lib/components/PageActions/variables.dark.d.ts +1 -0
  93. package/lib/components/PageActions/variables.dark.js +9 -0
  94. package/lib/components/PageActions/variables.js +37 -0
  95. package/lib/components/Search/SearchDialog.js +2 -2
  96. package/lib/components/Select/variables.js +2 -2
  97. package/lib/components/TableOfContent/TableOfContent.js +15 -12
  98. package/lib/components/Tag/Tag.d.ts +2 -1
  99. package/lib/components/Tag/Tag.js +3 -3
  100. package/lib/components/Tag/variables.js +14 -0
  101. package/lib/core/constants/catalog.d.ts +1 -1
  102. package/lib/core/constants/common.d.ts +4 -0
  103. package/lib/core/constants/common.js +5 -1
  104. package/lib/core/contexts/CodeSnippetContext.d.ts +7 -0
  105. package/lib/core/contexts/CodeSnippetContext.js +23 -0
  106. package/lib/core/contexts/index.d.ts +1 -0
  107. package/lib/core/contexts/index.js +1 -0
  108. package/lib/core/hooks/__mocks__/use-theme-hooks.d.ts +1 -0
  109. package/lib/core/hooks/__mocks__/use-theme-hooks.js +1 -0
  110. package/lib/core/hooks/code-walkthrough/use-renderable-files.d.ts +1 -2
  111. package/lib/core/hooks/code-walkthrough/use-renderable-files.js +2 -2
  112. package/lib/core/hooks/index.d.ts +1 -0
  113. package/lib/core/hooks/index.js +1 -0
  114. package/lib/core/hooks/use-active-heading.d.ts +7 -2
  115. package/lib/core/hooks/use-active-heading.js +160 -23
  116. package/lib/core/hooks/use-active-section-id.d.ts +1 -1
  117. package/lib/core/hooks/use-active-section-id.js +2 -2
  118. package/lib/core/hooks/use-codeblock-tabs-controls.d.ts +2 -2
  119. package/lib/core/hooks/use-codeblock-tabs-controls.js +6 -6
  120. package/lib/core/hooks/use-local-state.d.ts +1 -0
  121. package/lib/core/hooks/use-local-state.js +32 -0
  122. package/lib/core/hooks/use-page-actions.d.ts +2 -0
  123. package/lib/core/hooks/use-page-actions.js +101 -0
  124. package/lib/core/hooks/use-theme-hooks.js +2 -0
  125. package/lib/core/styles/dark.js +2 -0
  126. package/lib/core/styles/global.js +2 -0
  127. package/lib/core/types/catalog.d.ts +5 -1
  128. package/lib/core/types/hooks.d.ts +2 -1
  129. package/lib/core/types/index.d.ts +1 -0
  130. package/lib/core/types/index.js +1 -0
  131. package/lib/core/types/l10n.d.ts +1 -1
  132. package/lib/core/types/page-actions.d.ts +15 -0
  133. package/lib/core/types/page-actions.js +3 -0
  134. package/lib/core/types/sidebar.d.ts +1 -0
  135. package/lib/core/types/telemetry.d.ts +5 -20
  136. package/lib/core/utils/download-code-walkthrough.js +27 -7
  137. package/lib/core/utils/enhanced-smoothstep.d.ts +5 -0
  138. package/lib/core/utils/enhanced-smoothstep.js +15 -0
  139. package/lib/core/utils/get-file-icon.d.ts +3 -2
  140. package/lib/core/utils/get-file-icon.js +109 -29
  141. package/lib/core/utils/icon-resolver.d.ts +28 -0
  142. package/lib/core/utils/icon-resolver.js +52 -0
  143. package/lib/core/utils/index.d.ts +4 -1
  144. package/lib/core/utils/index.js +4 -1
  145. package/lib/core/utils/lang-to-name.d.ts +1 -0
  146. package/lib/core/utils/lang-to-name.js +37 -0
  147. package/lib/core/utils/{text-transform.js → string.js} +1 -1
  148. package/lib/ext/configure.d.ts +1 -1
  149. package/lib/icons/CDNIcon/CDNIcon.d.ts +14 -0
  150. package/lib/icons/CDNIcon/CDNIcon.js +48 -0
  151. package/lib/icons/ChatGptIcon/ChatGptIcon.d.ts +9 -0
  152. package/lib/icons/ChatGptIcon/ChatGptIcon.js +22 -0
  153. package/lib/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon.d.ts +9 -0
  154. package/lib/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon.js +23 -0
  155. package/lib/icons/ClaudeIcon/ClaudeIcon.d.ts +9 -0
  156. package/lib/icons/ClaudeIcon/ClaudeIcon.js +22 -0
  157. package/lib/icons/GenericIcon/GenericIcon.d.ts +11 -0
  158. package/lib/icons/GenericIcon/GenericIcon.js +61 -0
  159. package/lib/icons/GraphqlIcon/GraphqlIcon.d.ts +9 -0
  160. package/lib/icons/GraphqlIcon/GraphqlIcon.js +36 -0
  161. package/lib/icons/GraphqlIcon/index.d.ts +1 -0
  162. package/lib/icons/GraphqlIcon/index.js +6 -0
  163. package/lib/icons/HexagonIcon/HexagonIcon.d.ts +9 -0
  164. package/lib/icons/HexagonIcon/HexagonIcon.js +22 -0
  165. package/lib/icons/MarkdownFullIcon/MarkdownFullIcon.d.ts +9 -0
  166. package/lib/icons/MarkdownFullIcon/MarkdownFullIcon.js +23 -0
  167. package/lib/icons/MoleculesIcon/MoleculesIcon.d.ts +9 -0
  168. package/lib/icons/MoleculesIcon/MoleculesIcon.js +22 -0
  169. package/lib/icons/NetworkIcon/NetworkIcon.d.ts +9 -0
  170. package/lib/icons/NetworkIcon/NetworkIcon.js +23 -0
  171. package/lib/icons/NoneIcon/NoneIcon.d.ts +9 -0
  172. package/lib/icons/NoneIcon/NoneIcon.js +17 -0
  173. package/lib/icons/NotesIcon/NotesIcon.d.ts +9 -0
  174. package/lib/icons/NotesIcon/NotesIcon.js +26 -0
  175. package/lib/icons/types.d.ts +6 -0
  176. package/lib/index.d.ts +7 -1
  177. package/lib/index.js +7 -1
  178. package/lib/layouts/CodeWalkthroughLayout.js +2 -2
  179. package/lib/layouts/DocumentationLayout.js +14 -10
  180. package/lib/markdoc/components/Cards/CardIcon.js +7 -19
  181. package/lib/markdoc/components/CodeGroup/CodeGroup.d.ts +4 -0
  182. package/lib/markdoc/components/CodeGroup/CodeGroup.js +72 -0
  183. package/lib/markdoc/components/CodeWalkthrough/CodePanelHeader.js +7 -4
  184. package/lib/markdoc/components/Heading/Heading.d.ts +2 -1
  185. package/lib/markdoc/components/Heading/Heading.js +21 -3
  186. package/lib/markdoc/components/Icon/Icon.d.ts +3 -0
  187. package/lib/markdoc/components/Icon/Icon.js +29 -0
  188. package/lib/markdoc/components/Tabs/Tab.d.ts +2 -1
  189. package/lib/markdoc/components/Tabs/Tab.js +5 -2
  190. package/lib/markdoc/components/Tabs/Tabs.d.ts +1 -1
  191. package/lib/markdoc/components/Tabs/variables.js +2 -0
  192. package/lib/markdoc/components/default.d.ts +2 -0
  193. package/lib/markdoc/components/default.js +2 -0
  194. package/lib/markdoc/default.js +4 -0
  195. package/lib/markdoc/tags/card.js +1 -1
  196. package/lib/markdoc/tags/code-group.d.ts +2 -0
  197. package/lib/markdoc/tags/code-group.js +23 -0
  198. package/lib/markdoc/tags/code-snippet.js +1 -1
  199. package/lib/markdoc/tags/icon.d.ts +2 -0
  200. package/lib/markdoc/tags/icon.js +16 -0
  201. package/lib/markdoc/tags/tab.js +1 -0
  202. package/package.json +4 -4
  203. package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
  204. package/src/components/Button/Button.tsx +4 -2
  205. package/src/components/Button/ButtonGroup.tsx +53 -0
  206. package/src/components/Button/variables.ts +32 -5
  207. package/src/components/Catalog/Catalog.tsx +1 -1
  208. package/src/components/Catalog/CatalogCardView/CatalogCard.tsx +12 -6
  209. package/src/components/Catalog/CatalogEntitiesEmptyState.tsx +38 -4
  210. package/src/components/Catalog/CatalogEntity/CatalogEntity.tsx +25 -17
  211. package/src/components/Catalog/CatalogEntity/CatalogEntityInfoBar.tsx +25 -9
  212. package/src/components/Catalog/CatalogEntity/CatalogEntityLinks.tsx +12 -15
  213. package/src/components/Catalog/CatalogEntity/CatalogEntityMetadata.tsx +39 -2
  214. package/src/components/Catalog/CatalogEntity/CatalogEntityMethodAndPath.tsx +61 -0
  215. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ApiDescriptionProperty.tsx +12 -1
  216. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityProperties.tsx +7 -1
  217. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/CatalogEntityPropertyCard.tsx +15 -4
  218. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/ContactProperty.tsx +5 -1
  219. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/DomainsProperty.tsx +2 -3
  220. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/EntityTypeProperty.tsx +11 -3
  221. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/FormatProperty.tsx +37 -0
  222. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/GitProperty.tsx +1 -1
  223. package/src/components/Catalog/CatalogEntity/CatalogEntityProperties/TagsProperty.tsx +2 -0
  224. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityDefaultRelations.tsx +7 -23
  225. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelations.tsx +5 -6
  226. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityRelationsTable.tsx +21 -13
  227. package/src/components/Catalog/CatalogEntity/CatalogEntityRelations/CatalogEntityTeamRelations.tsx +9 -2
  228. package/src/components/Catalog/CatalogEntity/CatalogEntitySchema.tsx +52 -0
  229. package/src/components/Catalog/CatalogEntityIcon.tsx +33 -33
  230. package/src/components/Catalog/CatalogEntityTypeIcon.tsx +23 -28
  231. package/src/components/Catalog/CatalogEntityTypeTag.tsx +49 -0
  232. package/src/components/Catalog/CatalogPageDescription.tsx +5 -4
  233. package/src/components/Catalog/CatalogSelector.tsx +3 -1
  234. package/src/components/Catalog/CatalogSortButton.tsx +19 -20
  235. package/src/components/Catalog/CatalogTableView/CatalogDomainsCell.tsx +1 -0
  236. package/src/components/Catalog/CatalogTableView/CatalogEntityCell.tsx +3 -17
  237. package/src/components/Catalog/CatalogTableView/CatalogOwnersCell.tsx +1 -0
  238. package/src/components/Catalog/CatalogTableView/CatalogTableHeaderCell.tsx +5 -8
  239. package/src/components/Catalog/CatalogTableView/CatalogTableView.tsx +6 -36
  240. package/src/components/Catalog/CatalogTableView/CatalogTableViewRow.tsx +18 -46
  241. package/src/components/Catalog/CatalogTableView/CatalogTagsCell.tsx +1 -0
  242. package/src/components/Catalog/CatalogTableView/CatalogUserEntityCell.tsx +9 -4
  243. package/src/components/Catalog/CatalogTagsWithTooltip.tsx +9 -5
  244. package/src/components/Catalog/CatalogViewModeToggle.tsx +1 -1
  245. package/src/components/Catalog/variables.ts +42 -8
  246. package/src/components/CodeBlock/CodeBlock.tsx +15 -5
  247. package/src/components/CodeBlock/CodeBlockControls.tsx +67 -26
  248. package/src/components/CodeBlock/CodeBlockDropdown.tsx +53 -0
  249. package/src/components/CodeBlock/CodeBlockTabs.tsx +29 -20
  250. package/src/components/CodeBlock/variables.ts +1 -1
  251. package/src/components/Dropdown/Dropdown.tsx +1 -0
  252. package/src/components/Dropdown/DropdownMenu.tsx +4 -0
  253. package/src/components/Dropdown/variables.ts +1 -0
  254. package/src/components/Feedback/Feedback.tsx +1 -1
  255. package/src/components/Filter/FilterCheckboxes.tsx +9 -2
  256. package/src/components/Footer/FooterItem.tsx +5 -12
  257. package/src/components/Footer/variables.ts +2 -2
  258. package/src/components/Image/Image.tsx +2 -0
  259. package/src/components/Markdown/Markdown.tsx +3 -3
  260. package/src/components/Markdown/styles/headingAnchor.ts +0 -1
  261. package/src/components/Menu/MenuItem.tsx +5 -5
  262. package/src/components/Menu/variables.ts +3 -1
  263. package/src/components/Navbar/NavbarItem.tsx +8 -17
  264. package/src/components/Navbar/variables.ts +2 -2
  265. package/src/components/PageActions/PageActions.tsx +110 -0
  266. package/src/components/PageActions/PageActionsMenuItem.tsx +73 -0
  267. package/src/components/PageActions/variables.dark.ts +6 -0
  268. package/src/components/PageActions/variables.ts +34 -0
  269. package/src/components/Search/SearchDialog.tsx +2 -2
  270. package/src/components/Select/variables.ts +2 -2
  271. package/src/components/TableOfContent/TableOfContent.tsx +33 -36
  272. package/src/components/Tag/Tag.tsx +11 -2
  273. package/src/components/Tag/variables.ts +14 -0
  274. package/src/core/constants/catalog.ts +1 -1
  275. package/src/core/constants/common.ts +4 -0
  276. package/src/core/contexts/CodeSnippetContext.tsx +31 -0
  277. package/src/core/contexts/index.ts +1 -0
  278. package/src/core/hooks/__mocks__/use-theme-hooks.ts +1 -0
  279. package/src/core/hooks/code-walkthrough/use-renderable-files.ts +3 -4
  280. package/src/core/hooks/index.ts +1 -0
  281. package/src/core/hooks/use-active-heading.ts +199 -28
  282. package/src/core/hooks/use-active-section-id.ts +2 -1
  283. package/src/core/hooks/use-codeblock-tabs-controls.ts +8 -8
  284. package/src/core/hooks/use-local-state.ts +30 -0
  285. package/src/core/hooks/use-page-actions.ts +115 -0
  286. package/src/core/hooks/use-theme-hooks.ts +2 -0
  287. package/src/core/styles/dark.ts +2 -1
  288. package/src/core/styles/global.ts +2 -0
  289. package/src/core/types/catalog.ts +5 -1
  290. package/src/core/types/hooks.ts +2 -0
  291. package/src/core/types/index.ts +1 -0
  292. package/src/core/types/l10n.ts +21 -0
  293. package/src/core/types/page-actions.ts +18 -0
  294. package/src/core/types/sidebar.ts +1 -0
  295. package/src/core/types/telemetry.ts +5 -13
  296. package/src/core/utils/download-code-walkthrough.ts +5 -4
  297. package/src/core/utils/enhanced-smoothstep.ts +14 -0
  298. package/src/core/utils/get-file-icon.tsx +94 -0
  299. package/src/core/utils/icon-resolver.ts +57 -0
  300. package/src/core/utils/index.ts +4 -1
  301. package/src/core/utils/lang-to-name.ts +35 -0
  302. package/src/ext/configure.ts +1 -1
  303. package/src/icons/CDNIcon/CDNIcon.tsx +47 -0
  304. package/src/icons/ChatGptIcon/ChatGptIcon.tsx +23 -0
  305. package/src/icons/CheckmarkOutlineIcon/CheckmarkOutlineIcon.tsx +24 -0
  306. package/src/icons/ClaudeIcon/ClaudeIcon.tsx +23 -0
  307. package/src/icons/GenericIcon/GenericIcon.tsx +69 -0
  308. package/src/icons/GraphqlIcon/GraphqlIcon.tsx +81 -0
  309. package/src/icons/GraphqlIcon/index.ts +1 -0
  310. package/src/icons/HexagonIcon/HexagonIcon.tsx +23 -0
  311. package/src/icons/MarkdownFullIcon/MarkdownFullIcon.tsx +24 -0
  312. package/src/icons/MoleculesIcon/MoleculesIcon.tsx +23 -0
  313. package/src/icons/NetworkIcon/NetworkIcon.tsx +31 -0
  314. package/src/icons/NoneIcon/NoneIcon.tsx +17 -0
  315. package/src/icons/NotesIcon/NotesIcon.tsx +43 -0
  316. package/src/icons/types.ts +7 -0
  317. package/src/index.ts +7 -1
  318. package/src/layouts/CodeWalkthroughLayout.tsx +1 -1
  319. package/src/layouts/DocumentationLayout.tsx +23 -13
  320. package/src/markdoc/components/Cards/CardIcon.tsx +6 -21
  321. package/src/markdoc/components/CodeGroup/CodeGroup.tsx +78 -0
  322. package/src/markdoc/components/CodeWalkthrough/CodePanelHeader.tsx +7 -4
  323. package/src/markdoc/components/Heading/Heading.tsx +22 -3
  324. package/src/markdoc/components/Icon/Icon.tsx +16 -0
  325. package/src/markdoc/components/Tabs/Tab.tsx +6 -1
  326. package/src/markdoc/components/Tabs/Tabs.tsx +1 -1
  327. package/src/markdoc/components/Tabs/variables.ts +2 -0
  328. package/src/markdoc/components/default.ts +2 -0
  329. package/src/markdoc/default.ts +4 -0
  330. package/src/markdoc/tags/card.ts +1 -1
  331. package/src/markdoc/tags/code-group.ts +21 -0
  332. package/src/markdoc/tags/code-snippet.ts +1 -1
  333. package/src/markdoc/tags/icon.ts +14 -0
  334. package/src/markdoc/tags/tab.ts +1 -0
  335. package/lib/components/OpenApiDocs/hooks/AfterOpenApiDescription.d.ts +0 -1
  336. package/lib/components/OpenApiDocs/hooks/AfterOpenApiDescription.js +0 -5
  337. package/lib/ext/process-scorecard.d.ts +0 -5
  338. package/lib/ext/process-scorecard.js +0 -11
  339. package/src/components/OpenApiDocs/hooks/AfterOpenApiDescription.tsx +0 -1
  340. package/src/core/utils/get-file-icon.ts +0 -42
  341. package/src/ext/process-scorecard.ts +0 -13
  342. /package/lib/core/utils/{text-transform.d.ts → string.d.ts} +0 -0
  343. /package/src/core/utils/{text-transform.ts → string.ts} +0 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PageActionsMenuItem = PageActionsMenuItem;
7
+ const react_1 = __importDefault(require("react"));
8
+ const styled_components_1 = __importDefault(require("styled-components"));
9
+ const LaunchIcon_1 = require("../../icons/LaunchIcon/LaunchIcon");
10
+ function PageActionsMenuItem(props) {
11
+ const { pageAction } = props;
12
+ return (react_1.default.createElement(MenuItemWrapper, { "data-component-name": "PageActions/PageActionsMenuItem" },
13
+ react_1.default.createElement(IconWrapper, null,
14
+ react_1.default.createElement(pageAction.iconComponent, null)),
15
+ react_1.default.createElement(ContentWrapper, null,
16
+ react_1.default.createElement(Title, null,
17
+ pageAction.title,
18
+ 'link' in pageAction ? (react_1.default.createElement(LaunchIcon_1.LaunchIcon, { color: "var(--page-actions-menu-item-title-icon-color)", size: "14px" })) : null),
19
+ react_1.default.createElement(Description, null, pageAction.description))));
20
+ }
21
+ const MenuItemWrapper = styled_components_1.default.div `
22
+ padding: var(--page-actions-menu-item-padding);
23
+ display: flex;
24
+ flex-direction: row;
25
+ align-items: center;
26
+ gap: var(--page-actions-menu-item-gap);
27
+ `;
28
+ const IconWrapper = styled_components_1.default.div `
29
+ color: var(--page-actions-menu-item-icon-color);
30
+ border: 1px solid var(--page-actions-menu-item-icon-border-color);
31
+ border-radius: var(--page-actions-menu-item-icon-border-radius);
32
+ width: var(--page-actions-menu-item-icon-wrapper-size);
33
+ height: var(--page-actions-menu-item-icon-wrapper-size);
34
+ display: flex;
35
+ align-items: center;
36
+ justify-content: center;
37
+ `;
38
+ const ContentWrapper = styled_components_1.default.div `
39
+ display: flex;
40
+ flex-direction: column;
41
+ gap: var(--page-actions-menu-item-text-gap);
42
+ `;
43
+ const Title = styled_components_1.default.div `
44
+ font-weight: var(--page-actions-menu-item-title-font-weight);
45
+ font-size: var(--page-actions-menu-item-title-font-size);
46
+ line-height: var(--page-actions-menu-item-title-line-height);
47
+ color: var(--page-actions-menu-item-title-color);
48
+ display: flex;
49
+ align-items: center;
50
+ gap: var(--page-actions-menu-item-title-icon-gap);
51
+ `;
52
+ const Description = styled_components_1.default.div `
53
+ font-weight: var(--page-actions-menu-item-description-font-weight);
54
+ font-size: var(--page-actions-menu-item-description-font-size);
55
+ line-height: var(--page-actions-menu-item-description-line-height);
56
+ color: var(--page-actions-menu-item-description-color);
57
+ `;
58
+ //# sourceMappingURL=PageActionsMenuItem.js.map
@@ -0,0 +1 @@
1
+ export declare const pageActions: import("styled-components").FlattenSimpleInterpolation;
@@ -0,0 +1 @@
1
+ export declare const pageActionsDarkMode: import("styled-components").FlattenSimpleInterpolation;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pageActionsDarkMode = void 0;
4
+ const styled_components_1 = require("styled-components");
5
+ exports.pageActionsDarkMode = (0, styled_components_1.css) `
6
+ --page-actions-menu-item-icon-border-color: var(--color-warm-grey-5);
7
+ --page-actions-menu-item-description-color: var(--text-color-secondary);
8
+ `;
9
+ //# sourceMappingURL=variables.dark.js.map
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pageActions = void 0;
4
+ const styled_components_1 = require("styled-components");
5
+ exports.pageActions = (0, styled_components_1.css) `
6
+ /* Minimum spacing between page actions and heading text */
7
+ --page-actions-padding-left: var(--spacing-sm);
8
+
9
+ --page-actions-button-text-color: var(--text-color-secondary);
10
+ --page-actions-button-padding: 5px 14px 5px var(--spacing-sm);
11
+
12
+ --page-actions-menu-item-padding: 3px 0;
13
+ --page-actions-menu-item-gap: var(--spacing-xs);
14
+ --page-actions-menu-item-icon-color: var(--icon-color-secondary);
15
+ --page-actions-menu-item-icon-border-color: var(--color-warm-grey-3);
16
+ --page-actions-menu-item-icon-border-radius: var(--border-radius);
17
+ --page-actions-menu-item-icon-wrapper-size: 28px;
18
+
19
+ --page-actions-menu-item-text-gap: 2px;
20
+
21
+ --page-actions-menu-item-title-font-weight: var(--font-weight-regular);
22
+ --page-actions-menu-item-title-font-size: var(--font-size-base);
23
+ --page-actions-menu-item-title-line-height: var(--line-height-base);
24
+ --page-actions-menu-item-title-color: var(--text-color-secondary);
25
+
26
+ --page-actions-menu-item-title-icon-gap: var(--spacing-xxs);
27
+ --page-actions-menu-item-title-icon-color: var(--icon-color-secondary);
28
+
29
+ --page-actions-menu-item-description-font-weight: var(--font-weight-regular);
30
+ --page-actions-menu-item-description-font-size: var(--font-size-sm);
31
+ --page-actions-menu-item-description-line-height: var(--line-height-sm);
32
+ --page-actions-menu-item-description-color: var(--text-color-description);
33
+
34
+ --page-actions-processing-icon-color: var(--icon-color-interactive);
35
+ --page-actions-done-icon-color: var(--color-success-base);
36
+ `;
37
+ //# sourceMappingURL=variables.js.map
@@ -115,9 +115,9 @@ function SearchDialog({ onClose, className }) {
115
115
  payload: {
116
116
  query,
117
117
  url: item.document.url,
118
- total_results: results.length.toString(),
118
+ totalResults: results.length.toString(),
119
119
  index: index.toString(),
120
- search_engine: mode,
120
+ searchEngine: mode,
121
121
  },
122
122
  });
123
123
  onClose();
@@ -12,7 +12,7 @@ exports.select = (0, styled_components_1.css) `
12
12
  --select-text-color: var(--text-color-secondary); // @presenter Color
13
13
  --select-border-radius: var(--border-radius); // @presenter BorderRadius
14
14
  --select-border: var(--border-width) var(--border-style) var(--border-color-primary); // @presenter Border
15
-
15
+
16
16
  --select-input-padding-vertical: 6px; // @presenter Spacing
17
17
  --select-input-padding-horizontal: 6px; // @presenter Spacing
18
18
  --select-input-padding: var(--select-input-padding-vertical) var(--select-input-padding-horizontal);
@@ -40,7 +40,7 @@ exports.select = (0, styled_components_1.css) `
40
40
  --select-list-item-border-radius: var(--border-radius); // @presenter BorderRadius
41
41
  --select-list-item-bg-color-active: transparent; // @presenter Color
42
42
  --select-list-item-bg-color-hover: var(--menu-item-bg-color-hover); // @presenter Color
43
- --select-list-item-font-weight-active: var(--font-weight-medium); // @presenter Color
43
+ --select-list-item-font-weight-active: var(--font-weight-medium); // @presenter Color
44
44
 
45
45
  --select-placeholder-color: var(--color-warm-grey-6); // @presenter Color
46
46
  // @tokens End
@@ -41,21 +41,24 @@ function TableOfContent(props) {
41
41
  const { markdown: { toc = {} } = {} } = (0, hooks_1.useThemeConfig)();
42
42
  const displayedHeadings = (0, utils_1.getDisplayedHeadings)(headings, toc.depth || 3);
43
43
  const leastDepth = (0, utils_1.getLeastDepth)(displayedHeadings);
44
- const activeHeadingId = (0, hooks_1.useActiveHeading)(contentWrapper, (0, utils_1.getDisplayedHeadingsIds)(displayedHeadings));
44
+ const { heading: activeHeading, handleHeadingClick } = (0, hooks_1.useActiveHeading)(contentWrapper, displayedHeadings);
45
45
  if (toc === null || toc === void 0 ? void 0 : toc.hide) {
46
46
  return null;
47
47
  }
48
- return (React.createElement(React.Fragment, null,
49
- React.createElement(TableOfContentMenu, { "data-component-name": "TableOfContent/TableOfContent", className: className },
50
- React.createElement(TableOfContentItems, { ref: sidebar },
51
- displayedHeadings.length ? (React.createElement(TableOfContentHeader, { "data-translation-key": "toc.header" }, translate('toc.header', toc.header || 'On this page'))) : null,
52
- displayedHeadings.map((heading, idx) => {
53
- if (!heading) {
54
- return null;
55
- }
56
- const href = '#' + heading.id;
57
- return (React.createElement(TableOfContentMenuItem, { key: href + idx, href: href, depth: heading.depth - leastDepth + 1 || 0, className: activeHeadingId === heading.id ? 'active' : '', dangerouslySetInnerHTML: { __html: heading.value || '' }, "data-testid": `toc-${heading.value}`, onClick: () => telemetry.send({ type: 'toc_item.clicked' }) }));
58
- })))));
48
+ return (React.createElement(TableOfContentMenu, { "data-component-name": "TableOfContent/TableOfContent", className: className },
49
+ React.createElement(TableOfContentItems, { ref: sidebar },
50
+ displayedHeadings.length ? (React.createElement(TableOfContentHeader, { "data-translation-key": "toc.header" }, translate('toc.header', toc.header || 'On this page'))) : null,
51
+ displayedHeadings.map((heading, idx) => {
52
+ if (!heading) {
53
+ return null;
54
+ }
55
+ const href = '#' + heading.id;
56
+ return (React.createElement(TableOfContentMenuItem, { key: href + idx, href: href, depth: heading.depth - leastDepth + 1 || 0, className: activeHeading === heading.id ? 'active' : '', dangerouslySetInnerHTML: { __html: heading.value || '' }, "data-testid": `toc-${heading.value}`, onClick: (e) => {
57
+ e.preventDefault();
58
+ telemetry.send({ type: 'toc_item.clicked' });
59
+ handleHeadingClick(heading.id);
60
+ } }));
61
+ }))));
59
62
  }
60
63
  const TableOfContentMenu = styled_components_1.default.aside `
61
64
  background-color: var(--toc-bg-color);
@@ -26,7 +26,8 @@ export type TagProps = {
26
26
  onKeyDown?: (event: React.KeyboardEvent) => void;
27
27
  onClose?: (event: React.MouseEvent) => void;
28
28
  maxLength?: number;
29
+ textTransform?: 'uppercase' | 'lowercase' | 'capitalize' | 'none';
29
30
  };
30
- export declare function Tag({ children, color, icon, active, closable, tabIndex, onClick, onKeyDown, onClose, size, borderless, withStatusDot, statusDotColor, maxLength, ...otherProps }: TagProps): JSX.Element;
31
+ export declare function Tag({ children, color, icon, active, closable, tabIndex, onClick, onKeyDown, onClose, size, borderless, withStatusDot, statusDotColor, maxLength, textTransform, ...otherProps }: TagProps): JSX.Element;
31
32
  export declare const ContentWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
32
33
  export {};
@@ -21,7 +21,7 @@ const styled_components_1 = __importDefault(require("styled-components"));
21
21
  const CloseIcon_1 = require("../../icons/CloseIcon/CloseIcon");
22
22
  const CheckmarkFilledIcon_1 = require("../../icons/CheckmarkFilledIcon/CheckmarkFilledIcon");
23
23
  function Tag(_a) {
24
- var { children, color, icon, active, closable, tabIndex, onClick, onKeyDown, onClose, size, borderless, withStatusDot, statusDotColor = 'var(--tag-status-dot-color-default)', maxLength } = _a, otherProps = __rest(_a, ["children", "color", "icon", "active", "closable", "tabIndex", "onClick", "onKeyDown", "onClose", "size", "borderless", "withStatusDot", "statusDotColor", "maxLength"]);
24
+ var { children, color, icon, active, closable, tabIndex, onClick, onKeyDown, onClose, size, borderless, withStatusDot, statusDotColor = 'var(--tag-status-dot-color-default)', maxLength, textTransform } = _a, otherProps = __rest(_a, ["children", "color", "icon", "active", "closable", "tabIndex", "onClick", "onKeyDown", "onClose", "size", "borderless", "withStatusDot", "statusDotColor", "maxLength", "textTransform"]);
25
25
  const truncateText = (text, maxLen) => {
26
26
  if (text.length <= maxLen)
27
27
  return text;
@@ -74,7 +74,7 @@ function Tag(_a) {
74
74
  }
75
75
  return children;
76
76
  };
77
- return (react_1.default.createElement(TagWrapper, Object.assign({ tabIndex: tabIndex, "data-component-name": "Tag/Tag", borderless: borderless, color: color, size: size, onClick: onClick, onKeyDown: onKeyDown, hasCloseButton: closable }, otherProps),
77
+ return (react_1.default.createElement(TagWrapper, Object.assign({ tabIndex: tabIndex, "data-component-name": "Tag/Tag", borderless: borderless, color: color, size: size, onClick: onClick, onKeyDown: onKeyDown, hasCloseButton: closable, textTransform: textTransform }, otherProps),
78
78
  withStatusDot ? react_1.default.createElement(StatusDot, { color: statusDotColor }) : icon ? icon : null,
79
79
  react_1.default.createElement(exports.ContentWrapper, null, renderChildren()),
80
80
  closable && (react_1.default.createElement(CloseButton, { onClick: (event) => {
@@ -128,7 +128,7 @@ const TagWrapper = styled_components_1.default.div.attrs(({ className, color, si
128
128
  font-weight: var(--tag-font-weight);
129
129
  line-height: var(--tag-line-height);
130
130
  box-shadow: var(--tag-box-shadow);
131
- text-transform: var(--tag-text-transform);
131
+ ${({ textTransform }) => `text-transform: ${textTransform ? `${textTransform}` : 'var(--tag-text-transform)'};`}
132
132
 
133
133
  color: var(--tag-color);
134
134
  background-color: var(--tag-bg-color);
@@ -183,6 +183,20 @@ exports.tag = (0, styled_components_1.css) `
183
183
  --tag-close-button-bg-color-hover: var(--color-sky-2); // @presenter Color
184
184
  }
185
185
 
186
+ .tag-raspberry {
187
+ --tag-color: var(--color-raspberry-7); // @presenter Color
188
+ --tag-bg-color: transparent; // @presenter Color
189
+ --tag-border-color: var(--color-raspberry-3); // @presenter Color
190
+ --tag-close-button-bg-color-hover: var(--color-raspberry-1); // @presenter Color
191
+ }
192
+
193
+ .tag-carrot {
194
+ --tag-color: var(--color-carrot-8); // @presenter Color
195
+ --tag-bg-color: transparent; // @presenter Color
196
+ --tag-border-color: var(--color-carrot-6); // @presenter Color
197
+ --tag-close-button-bg-color-hover: var(--color-carrot-3); // @presenter Color
198
+ }
199
+
186
200
  /**
187
201
  * @tokens Tag http
188
202
  */
@@ -1,4 +1,4 @@
1
- import type { EntityRelationType } from '../../core/types';
1
+ import type { EntityRelationType } from '../types/catalog';
2
2
  export declare const CATALOG_TAG_MAX_LENGTH = 15;
3
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"];
4
4
  export declare const reverseRelationMap: Record<EntityRelationType, EntityRelationType>;
@@ -1,6 +1,10 @@
1
1
  export { REDOCLY_TEAMS_RBAC } from '@redocly/config';
2
2
  export declare const DEFAULT_LOCALE_PLACEHOLDER = "default_locale";
3
3
  export declare const CONTENT_ID = "content";
4
+ export declare const ICONS_CDN_URL: {
5
+ 'font-awesome': string;
6
+ code: string;
7
+ };
4
8
  export declare enum FEEDBACK_TYPES {
5
9
  RATING = "rating",
6
10
  SENTIMENT = "sentiment",
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MobileMenuType = exports.MenuItemType = exports.DEFAULT_FEEDBACK_TYPE = exports.FEEDBACK_TYPES = exports.CONTENT_ID = exports.DEFAULT_LOCALE_PLACEHOLDER = exports.REDOCLY_TEAMS_RBAC = void 0;
3
+ exports.MobileMenuType = exports.MenuItemType = exports.DEFAULT_FEEDBACK_TYPE = exports.FEEDBACK_TYPES = exports.ICONS_CDN_URL = exports.CONTENT_ID = exports.DEFAULT_LOCALE_PLACEHOLDER = exports.REDOCLY_TEAMS_RBAC = void 0;
4
4
  var config_1 = require("@redocly/config");
5
5
  Object.defineProperty(exports, "REDOCLY_TEAMS_RBAC", { enumerable: true, get: function () { return config_1.REDOCLY_TEAMS_RBAC; } });
6
6
  exports.DEFAULT_LOCALE_PLACEHOLDER = 'default_locale';
7
7
  exports.CONTENT_ID = 'content';
8
+ exports.ICONS_CDN_URL = {
9
+ 'font-awesome': 'https://cdn.redocly.com/icons/fa/7.0.0',
10
+ code: 'https://cdn.redocly.com/icons/code/5.24.0',
11
+ };
8
12
  var FEEDBACK_TYPES;
9
13
  (function (FEEDBACK_TYPES) {
10
14
  FEEDBACK_TYPES["RATING"] = "rating";
@@ -0,0 +1,7 @@
1
+ export type CodeSnippetContextType = {
2
+ activeSnippetName: string;
3
+ setActiveSnippetName: (name: string) => void;
4
+ };
5
+ 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];
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ 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");
6
+ exports.CODE_GROUP_SNIPPET_NAME_KEY = 'redocly:codeGroupSnippetName';
7
+ exports.CodeSnippetContext = (0, react_1.createContext)(null);
8
+ function useActiveCodeSnippetName(mode) {
9
+ const context = (0, react_1.useContext)(exports.CodeSnippetContext);
10
+ if (!context) {
11
+ throw new Error('useCodeSnippetContext must be used within a CodeSnippetContext');
12
+ }
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
+ }
23
+ //# sourceMappingURL=CodeSnippetContext.js.map
@@ -1,3 +1,4 @@
1
1
  export * from './ThemeDataContext';
2
2
  export * from './CodeWalkthrough/CodeWalkthroughControlsContext';
3
3
  export * from './CodeWalkthrough/CodeWalkthroughStepsContext';
4
+ export * from './CodeSnippetContext';
@@ -17,4 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ThemeDataContext"), exports);
18
18
  __exportStar(require("./CodeWalkthrough/CodeWalkthroughControlsContext"), exports);
19
19
  __exportStar(require("./CodeWalkthrough/CodeWalkthroughStepsContext"), exports);
20
+ __exportStar(require("./CodeSnippetContext"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -64,4 +64,5 @@ export declare const useThemeHooks: jest.Mock<{
64
64
  }, [], any>;
65
65
  useLoadAndNavigate: jest.Mock<any, any, any>;
66
66
  usePageProps: jest.Mock<any, any, any>;
67
+ usePageData: jest.Mock<any, any, any>;
67
68
  }, [], any>;
@@ -87,5 +87,6 @@ exports.useThemeHooks = jest.fn(() => ({
87
87
  })),
88
88
  useLoadAndNavigate: jest.fn(),
89
89
  usePageProps: jest.fn().mockReturnValue({}),
90
+ usePageData: jest.fn().mockReturnValue(null),
90
91
  }));
91
92
  //# sourceMappingURL=use-theme-hooks.js.map
@@ -1,7 +1,6 @@
1
1
  import type { CodeWalkthroughFile } from '@redocly/config';
2
- import type { IconProps } from '../../../icons/types';
3
2
  export type RenderableFile = CodeWalkthroughFile & {
4
- FileIcon: React.FunctionComponent<IconProps>;
3
+ fileIcon: React.JSX.Element;
5
4
  parentFolder: string;
6
5
  isNameDuplicate: boolean;
7
6
  inRootDir: boolean;
@@ -10,11 +10,11 @@ function useRenderableFiles(files) {
10
10
  const filePaths = files.map(({ path }) => path);
11
11
  const rootDir = (0, find_closest_common_directory_1.findClosestCommonDirectory)(filePaths);
12
12
  const renderableFiles = files.map((file) => {
13
- const FileIcon = getFileTypeIcon(file.basename);
13
+ const fileIcon = getFileTypeIcon(file.basename);
14
14
  const parentFolder = file.path.split('/').slice(-2, -1)[0];
15
15
  const isNameDuplicate = files.some((_file) => file.basename === _file.basename && file.path !== _file.path);
16
16
  const inRootDir = file.path === `${(0, urls_1.removeLeadingSlash)(rootDir)}/${file.basename}`;
17
- return Object.assign(Object.assign({}, file), { FileIcon,
17
+ return Object.assign(Object.assign({}, file), { fileIcon,
18
18
  inRootDir,
19
19
  parentFolder,
20
20
  isNameDuplicate });
@@ -40,3 +40,4 @@ export * from './catalog/useCatalogEntities';
40
40
  export * from './use-active-page-version';
41
41
  export * from './use-page-versions';
42
42
  export * from './use-user-teams';
43
+ export * from './use-page-actions';
@@ -56,4 +56,5 @@ __exportStar(require("./catalog/useCatalogEntities"), exports);
56
56
  __exportStar(require("./use-active-page-version"), exports);
57
57
  __exportStar(require("./use-page-versions"), exports);
58
58
  __exportStar(require("./use-user-teams"), exports);
59
+ __exportStar(require("./use-page-actions"), exports);
59
60
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,7 @@
1
- export type UseActiveHeadingReturnType = string | undefined;
2
- export declare function useActiveHeading(contentElement: HTMLDivElement | null, displayedHeaders: Array<string | undefined>): UseActiveHeadingReturnType;
1
+ export declare function useActiveHeading(contentElement: HTMLDivElement | null, displayedHeadings?: Array<{
2
+ id: string;
3
+ depth: number;
4
+ } | null>): {
5
+ heading: string | undefined;
6
+ handleHeadingClick: (headingId: string) => void;
7
+ };
@@ -3,11 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useActiveHeading = useActiveHeading;
4
4
  const react_1 = require("react");
5
5
  const react_router_dom_1 = require("react-router-dom");
6
- function useActiveHeading(contentElement, displayedHeaders) {
7
- const [heading, setHeading] = (0, react_1.useState)(displayedHeaders.length > 1 ? displayedHeaders[0] : undefined);
6
+ const utils_1 = require("../utils");
7
+ function useActiveHeading(contentElement, displayedHeadings) {
8
+ const [heading, setHeading] = (0, react_1.useState)(undefined);
8
9
  const [headingElements, setHeadingElements] = (0, react_1.useState)([]);
9
10
  const headingElementsRef = (0, react_1.useRef)({});
11
+ const displayedHeadingsRef = (0, react_1.useRef)(displayedHeadings);
12
+ const lockObserver = (0, react_1.useRef)(false);
10
13
  const location = (0, react_router_dom_1.useLocation)();
14
+ (0, react_1.useEffect)(() => {
15
+ setHeading(undefined);
16
+ headingElementsRef.current = {};
17
+ }, [location.pathname]);
18
+ (0, react_1.useEffect)(() => {
19
+ displayedHeadingsRef.current = displayedHeadings;
20
+ }, [displayedHeadings]);
11
21
  const getVisibleHeadings = () => {
12
22
  const visibleHeadings = [];
13
23
  for (const key in headingElementsRef.current) {
@@ -18,28 +28,98 @@ function useActiveHeading(contentElement, displayedHeaders) {
18
28
  }
19
29
  return visibleHeadings;
20
30
  };
31
+ const isTopOfPage = () => window.scrollY <= 50;
32
+ // Returns viewport ratio for intersection observer based on screen height
33
+ const getViewportRatio = () => {
34
+ const vh = window.innerHeight;
35
+ if (vh >= 1400)
36
+ return 0.4;
37
+ if (vh >= 1000)
38
+ return 0.3;
39
+ return 0.25;
40
+ };
21
41
  const getIndexFromId = (0, react_1.useCallback)((id) => {
22
42
  return headingElements.findIndex((item) => item.id === id);
23
43
  }, [headingElements]);
24
44
  const findHeaders = (allContent) => {
25
45
  const allHeaders = allContent.querySelectorAll('.heading-anchor');
26
- return Array.from(allHeaders);
46
+ const headers = Array.from(allHeaders);
47
+ if (displayedHeadingsRef.current && displayedHeadingsRef.current.length > 0) {
48
+ const displayedIds = displayedHeadingsRef.current.map((h) => h === null || h === void 0 ? void 0 : h.id).filter(Boolean);
49
+ return headers.filter((header) => displayedIds.includes(header.id));
50
+ }
51
+ return headers;
27
52
  };
28
- const intersectionCallback = (0, react_1.useCallback)((headings) => {
53
+ const calculateVirtualPositions = (0, react_1.useCallback)((headers) => {
54
+ var _a;
55
+ if (!headers.length)
56
+ return {};
57
+ const navbarHeight = ((_a = document.querySelector('nav')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
58
+ const viewportHeight = window.innerHeight;
59
+ const triggerOffset = navbarHeight + viewportHeight * 0.25;
60
+ const lastHeader = headers[headers.length - 1];
61
+ const lastHeaderTop = lastHeader.offsetTop;
62
+ const maxScrollableHeight = document.body.scrollHeight - viewportHeight;
63
+ const requiredUplift = Math.max(0, lastHeaderTop - maxScrollableHeight + triggerOffset);
64
+ const virtualPositions = {};
65
+ for (let i = 0; i < headers.length; i++) {
66
+ const header = headers[i];
67
+ const headerTop = header.offsetTop;
68
+ const normalizedPosition = headers.length === 1 ? 0 : i / (headers.length - 1);
69
+ const adjustmentFactor = (0, utils_1.enhancedSmoothstep)(normalizedPosition, 0.4);
70
+ const uplift = requiredUplift * adjustmentFactor;
71
+ const virtualTop = headerTop - uplift;
72
+ virtualPositions[header.id] = virtualTop;
73
+ }
74
+ return virtualPositions;
75
+ }, []);
76
+ const getTriggerOffset = (0, react_1.useCallback)(() => {
29
77
  var _a;
30
- headingElementsRef.current = headings.reduce((map, headingElement) => {
31
- map[headingElement.target.id] = headingElement;
78
+ const navbarHeight = ((_a = document.querySelector('nav')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().height) || 0;
79
+ return navbarHeight + window.innerHeight * getViewportRatio();
80
+ }, []);
81
+ const findActiveHeaderByVirtualPosition = (0, react_1.useCallback)((headers, scrollY, triggerOffset) => {
82
+ const virtualPositions = calculateVirtualPositions(headers);
83
+ let activeHeader = headers[0];
84
+ for (const header of headers) {
85
+ const virtualTop = virtualPositions[header.id] || header.offsetTop;
86
+ if (virtualTop <= scrollY + triggerOffset) {
87
+ activeHeader = header;
88
+ }
89
+ else {
90
+ break;
91
+ }
92
+ }
93
+ return activeHeader;
94
+ }, [calculateVirtualPositions]);
95
+ const intersectionCallback = (0, react_1.useCallback)((entries) => {
96
+ var _a, _b, _c;
97
+ if (lockObserver.current) {
98
+ return;
99
+ }
100
+ headingElementsRef.current = entries.reduce((map, entry) => {
101
+ map[entry.target.id] = entry;
32
102
  return map;
33
103
  }, headingElementsRef.current);
34
- const totalHeight = window.scrollY + window.innerHeight;
35
- // handle bottom of the page
36
- if (totalHeight >= document.body.scrollHeight) {
37
- const newHeading = ((_a = headingElements[(headingElements === null || headingElements === void 0 ? void 0 : headingElements.length) - 1]) === null || _a === void 0 ? void 0 : _a.id) || undefined;
104
+ if (isTopOfPage()) {
105
+ const newHeading = ((_a = headingElements[0]) === null || _a === void 0 ? void 0 : _a.id) || undefined;
38
106
  setHeading(newHeading);
39
107
  return;
40
108
  }
41
109
  const visibleHeadings = getVisibleHeadings();
42
110
  if (!visibleHeadings.length) {
111
+ const triggerOffset = getTriggerOffset();
112
+ if (isTopOfPage()) {
113
+ setHeading(((_b = headingElements[0]) === null || _b === void 0 ? void 0 : _b.id) || undefined);
114
+ return;
115
+ }
116
+ const totalHeight = window.scrollY + window.innerHeight;
117
+ if (totalHeight >= document.body.scrollHeight - 10) {
118
+ setHeading(((_c = headingElements[headingElements.length - 1]) === null || _c === void 0 ? void 0 : _c.id) || undefined);
119
+ return;
120
+ }
121
+ const activeHeader = findActiveHeaderByVirtualPosition(headingElements, window.scrollY, triggerOffset);
122
+ setHeading(activeHeader.id);
43
123
  return;
44
124
  }
45
125
  if (visibleHeadings.length === 1) {
@@ -49,31 +129,88 @@ function useActiveHeading(contentElement, displayedHeaders) {
49
129
  visibleHeadings.sort((a, b) => {
50
130
  return getIndexFromId(a.target.id) - getIndexFromId(b.target.id);
51
131
  });
132
+ const firstVisibleHeading = visibleHeadings[0];
133
+ if (getIndexFromId(firstVisibleHeading.target.id) === 0 && isTopOfPage()) {
134
+ setHeading(firstVisibleHeading.target.id);
135
+ return;
136
+ }
137
+ const totalHeight = scrollY + window.innerHeight;
138
+ if (totalHeight >= document.body.scrollHeight - 10) {
139
+ setHeading(visibleHeadings[visibleHeadings.length - 1].target.id);
140
+ return;
141
+ }
52
142
  setHeading(visibleHeadings[0].target.id);
53
- }, [getIndexFromId, headingElements]);
143
+ }, [getIndexFromId, headingElements, getTriggerOffset, findActiveHeaderByVirtualPosition]);
144
+ const handleHeadingClick = (0, react_1.useCallback)((headingId) => {
145
+ lockObserver.current = true;
146
+ setHeading(headingId);
147
+ const headingElement = headingElements.find((el) => el.id === headingId);
148
+ if (headingElement && headingElement.scrollIntoView) {
149
+ headingElement.scrollIntoView({ behavior: 'smooth', block: 'start' });
150
+ }
151
+ setTimeout(() => {
152
+ headingElementsRef.current = {};
153
+ lockObserver.current = false;
154
+ }, 300);
155
+ }, [headingElements]);
54
156
  (0, react_1.useEffect)(() => {
157
+ var _a;
55
158
  if (!contentElement) {
56
159
  return;
57
160
  }
58
- setHeadingElements(findHeaders(contentElement));
59
- }, [contentElement, location]);
161
+ const headers = findHeaders(contentElement);
162
+ setHeadingElements(headers);
163
+ if (headers.length > 0 && !heading) {
164
+ if (isTopOfPage()) {
165
+ setHeading(headers[0].id);
166
+ }
167
+ else {
168
+ const totalHeight = scrollY + window.innerHeight;
169
+ if (totalHeight >= document.body.scrollHeight - 10) {
170
+ setHeading(((_a = headers[headers.length - 1]) === null || _a === void 0 ? void 0 : _a.id) || undefined);
171
+ }
172
+ else {
173
+ const triggerOffset = getTriggerOffset();
174
+ const activeHeader = findActiveHeaderByVirtualPosition(headers, scrollY, triggerOffset);
175
+ setHeading(activeHeader.id);
176
+ }
177
+ }
178
+ }
179
+ }, [
180
+ contentElement,
181
+ location,
182
+ heading,
183
+ calculateVirtualPositions,
184
+ getTriggerOffset,
185
+ findActiveHeaderByVirtualPosition,
186
+ ]);
60
187
  (0, react_1.useEffect)(() => {
61
188
  if (!(headingElements === null || headingElements === void 0 ? void 0 : headingElements.length)) {
62
189
  return;
63
190
  }
64
191
  headingElementsRef.current = {};
65
- // Bottom rootMargin -30% changes part of the view where IntersectionObserver starts to detect headers
192
+ const triggerOffset = getTriggerOffset();
66
193
  const observer = new IntersectionObserver(intersectionCallback, {
67
- rootMargin: '0px 0px -30% 0px',
68
- threshold: 1,
194
+ rootMargin: `-${triggerOffset}px 0px -${window.innerHeight * getViewportRatio()}px 0px`,
195
+ threshold: [0, 0.1, 0.3, 0.5, 0.7, 1],
69
196
  });
70
- headingElements === null || headingElements === void 0 ? void 0 : headingElements.forEach((element) => {
71
- if (displayedHeaders.includes(element.id)) {
72
- observer.observe(element);
73
- }
197
+ headingElements.forEach((element) => {
198
+ observer.observe(element);
74
199
  });
75
- return () => observer.disconnect();
76
- }, [headingElements, displayedHeaders, intersectionCallback]);
77
- return heading;
200
+ const handleScroll = () => {
201
+ var _a;
202
+ if (lockObserver.current)
203
+ return;
204
+ if (isTopOfPage()) {
205
+ setHeading(((_a = headingElements[0]) === null || _a === void 0 ? void 0 : _a.id) || undefined);
206
+ }
207
+ };
208
+ window.addEventListener('scroll', handleScroll, { passive: true });
209
+ return () => {
210
+ observer.disconnect();
211
+ window.removeEventListener('scroll', handleScroll);
212
+ };
213
+ }, [headingElements, intersectionCallback, getTriggerOffset]);
214
+ return { heading, handleHeadingClick };
78
215
  }
79
216
  //# sourceMappingURL=use-active-heading.js.map
@@ -1,3 +1,3 @@
1
1
  import type { Location } from 'react-router-dom';
2
2
  export type UseActiveSectionIdReturnType = string;
3
- export declare function useActiveSectionId(location: Location, hasOverviewPage?: boolean, withNavbar?: boolean): UseActiveSectionIdReturnType;
3
+ export declare function useActiveSectionId(location: Location, hasOverviewPage?: boolean, withNavbar?: boolean, sectionOffset?: number): UseActiveSectionIdReturnType;