@redocly/openapi-docs 3.12.0 → 3.12.2

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 (384) hide show
  1. package/dist/redocly-openapi-docs.min.js +753 -750
  2. package/lib/components/ApiInfo/ApiInfo.js +29 -1
  3. package/lib/components/ApiInfo/Metadata.js +29 -1
  4. package/lib/components/ApiInfo/index.js +2 -1
  5. package/lib/components/ApiInfo/styled.js +16 -8
  6. package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
  7. package/lib/components/CallbackSamples/index.js +2 -1
  8. package/lib/components/Callbacks/CallbackDetails.js +17 -3
  9. package/lib/components/Callbacks/CallbackOperation.js +24 -3
  10. package/lib/components/Callbacks/CallbackSummary.js +19 -3
  11. package/lib/components/Callbacks/CallbacksList.js +16 -1
  12. package/lib/components/Callbacks/index.js +4 -1
  13. package/lib/components/Callbacks/styled.js +6 -3
  14. package/lib/components/Content/Content.js +10 -1
  15. package/lib/components/Content/index.js +2 -1
  16. package/lib/components/Content/useAutoScroll.js +50 -1
  17. package/lib/components/ContentItem/ContentItem.js +31 -1
  18. package/lib/components/ContentItem/index.js +2 -1
  19. package/lib/components/ContentItem/useIsExpanded.js +33 -1
  20. package/lib/components/ContentItems/ContentItems.js +19 -1
  21. package/lib/components/ContentItems/Items.js +13 -1
  22. package/lib/components/ContentItems/VirtualList.js +35 -1
  23. package/lib/components/ContentItems/helpers.js +49 -1
  24. package/lib/components/ContentItems/index.js +2 -1
  25. package/lib/components/ContentItems/useScrollOnRender.js +26 -1
  26. package/lib/components/Discriminator/Discriminator.js +27 -2
  27. package/lib/components/Discriminator/index.js +2 -1
  28. package/lib/components/Download/DownloadSpecification.js +46 -4
  29. package/lib/components/Download/index.js +2 -1
  30. package/lib/components/Download/types.js +2 -0
  31. package/lib/components/Download/useDownloadInfo.js +42 -1
  32. package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
  33. package/lib/components/ErrorBoundary/index.js +2 -1
  34. package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
  35. package/lib/components/ExpandAllButton/index.js +2 -1
  36. package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
  37. package/lib/components/ExternalDocumentation/index.js +2 -1
  38. package/lib/components/Language/LanguageDropdown.js +21 -1
  39. package/lib/components/Language/LanguageItem.js +33 -1
  40. package/lib/components/Language/LanguageList.js +93 -1
  41. package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
  42. package/lib/components/Language/constants.js +3 -1
  43. package/lib/components/Language/index.js +4 -1
  44. package/lib/components/Language/styled.js +29 -15
  45. package/lib/components/Markdown/Markdown.js +64 -1
  46. package/lib/components/Markdown/index.js +3 -1
  47. package/lib/components/Markdown/types.js +2 -0
  48. package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
  49. package/lib/components/MediaTypeSwitch/index.js +2 -1
  50. package/lib/components/OperationItem/Description.js +9 -1
  51. package/lib/components/OperationItem/OperationItem.js +70 -5
  52. package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
  53. package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
  54. package/lib/components/OperationItem/index.js +2 -1
  55. package/lib/components/OperationItem/types.js +2 -0
  56. package/lib/components/Overlay.js +48 -3
  57. package/lib/components/Overview/Overview.js +20 -1
  58. package/lib/components/Overview/index.js +2 -1
  59. package/lib/components/PageFooter/PageFooter.js +19 -1
  60. package/lib/components/PageFooter/index.js +2 -1
  61. package/lib/components/Panel/ResponsePanel.js +12 -6
  62. package/lib/components/Panel/Trigger.js +4 -2
  63. package/lib/components/Panel/index.js +3 -1
  64. package/lib/components/PanelItem/PanelItem.js +6 -1
  65. package/lib/components/PanelItem/index.js +3 -1
  66. package/lib/components/PanelItem/styled.js +20 -10
  67. package/lib/components/PayloadSamples/Example.js +6 -1
  68. package/lib/components/PayloadSamples/ExampleValue.js +30 -1
  69. package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
  70. package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
  71. package/lib/components/PayloadSamples/index.js +7 -1
  72. package/lib/components/PayloadSamples/styled.js +9 -4
  73. package/lib/components/PayloadSamples/types.js +2 -0
  74. package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
  75. package/lib/components/PropertyDetails/EnumValues.js +37 -1
  76. package/lib/components/PropertyDetails/Examples.js +26 -1
  77. package/lib/components/PropertyDetails/Extensions.js +17 -2
  78. package/lib/components/PropertyDetails/FieldDetail.js +15 -2
  79. package/lib/components/PropertyDetails/FieldDetails.js +51 -6
  80. package/lib/components/PropertyDetails/Pattern.js +21 -1
  81. package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
  82. package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
  83. package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
  84. package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
  85. package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
  86. package/lib/components/PropertyDetails/index.js +4 -1
  87. package/lib/components/PropertyDetails/styled.js +15 -7
  88. package/lib/components/PropertyDetails/types.js +2 -0
  89. package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
  90. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
  91. package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
  92. package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
  93. package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
  94. package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
  95. package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
  96. package/lib/components/RenderHook/RenderHook.js +17 -1
  97. package/lib/components/RenderHook/index.js +2 -1
  98. package/lib/components/Replay/EmbeddedReplay.js +41 -3
  99. package/lib/components/Replay/Replay.js +99 -1
  100. package/lib/components/Replay/index.js +3 -1
  101. package/lib/components/Replay/utils.js +208 -1
  102. package/lib/components/Request/RequestDetails.js +33 -2
  103. package/lib/components/Request/types.js +2 -0
  104. package/lib/components/RequestParameters/Body.js +8 -1
  105. package/lib/components/RequestParameters/ParametersGroup.js +19 -4
  106. package/lib/components/RequestParameters/RequestParameters.js +40 -1
  107. package/lib/components/RequestParameters/index.js +4 -1
  108. package/lib/components/RequestSamples/CodeSample.js +55 -2
  109. package/lib/components/RequestSamples/Example.js +37 -1
  110. package/lib/components/RequestSamples/RequestSamples.js +89 -5
  111. package/lib/components/RequestSamples/index.js +3 -1
  112. package/lib/components/RequestSamples/useCodeSamples.js +92 -1
  113. package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
  114. package/lib/components/ResponseSamples/Summary.js +9 -1
  115. package/lib/components/ResponseSamples/index.js +2 -1
  116. package/lib/components/Responses/OperationResponseList.js +42 -2
  117. package/lib/components/Responses/ResponseDetails.js +18 -1
  118. package/lib/components/Responses/ResponseHeaders.js +15 -1
  119. package/lib/components/Responses/index.js +6 -1
  120. package/lib/components/Responses/styled.js +14 -6
  121. package/lib/components/Responses/types.js +2 -0
  122. package/lib/components/RightPanel/RightPanel.js +21 -1
  123. package/lib/components/RightPanel/index.js +2 -1
  124. package/lib/components/Samples/ExampleSwitch.js +33 -1
  125. package/lib/components/Samples/index.js +3 -1
  126. package/lib/components/Samples/use-example-key.js +12 -1
  127. package/lib/components/Schema/ArraySchema.js +45 -1
  128. package/lib/components/Schema/ObjectSchema.js +29 -1
  129. package/lib/components/Schema/OneOfSchema.js +47 -3
  130. package/lib/components/Schema/RecursiveSchema.js +10 -1
  131. package/lib/components/Schema/Schema.js +63 -2
  132. package/lib/components/Schema/SubSchema.js +20 -1
  133. package/lib/components/Schema/helpers.js +16 -1
  134. package/lib/components/Schema/index.js +5 -1
  135. package/lib/components/Schema/types.js +2 -0
  136. package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
  137. package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
  138. package/lib/components/SchemaDefinition/index.js +2 -1
  139. package/lib/components/SectionContent/SectionContent.js +49 -6
  140. package/lib/components/SectionContent/index.js +2 -1
  141. package/lib/components/SectionItem/SectionItem.js +14 -1
  142. package/lib/components/SectionItem/index.js +2 -1
  143. package/lib/components/Security/Divider.js +9 -2
  144. package/lib/components/Security/OAuthFlow.js +11 -1
  145. package/lib/components/Security/OAuthScopes.js +59 -9
  146. package/lib/components/Security/Security.js +15 -1
  147. package/lib/components/Security/SecurityButton.js +31 -7
  148. package/lib/components/Security/SecurityFlow.js +28 -4
  149. package/lib/components/Security/SecurityModal.js +34 -5
  150. package/lib/components/Security/SecuritySchemeItem.js +15 -4
  151. package/lib/components/Security/helper.js +16 -1
  152. package/lib/components/Security/index.js +11 -1
  153. package/lib/components/Security/styled.js +6 -3
  154. package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
  155. package/lib/components/SelectOrLabel/index.js +2 -1
  156. package/lib/components/ServerList/ServerList.js +36 -10
  157. package/lib/components/ServerList/index.js +2 -1
  158. package/lib/components/ServerList/types.js +2 -0
  159. package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
  160. package/lib/components/ServerListDropdown/index.js +2 -1
  161. package/lib/components/ServerListDropdown/styled.js +15 -6
  162. package/lib/components/SideMenu/SideMenu.js +13 -2
  163. package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
  164. package/lib/components/SideMenu/index.js +2 -1
  165. package/lib/components/SideMenu/types.js +2 -0
  166. package/lib/components/StickySidebar/SidebarActions.js +14 -2
  167. package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
  168. package/lib/components/StickySidebar/index.js +2 -1
  169. package/lib/components/Tabs/Tabs.js +16 -5
  170. package/lib/components/Tabs/index.js +3 -1
  171. package/lib/components/Tabs/useTabsState.js +22 -1
  172. package/lib/components/TagItem/OperationNavigationItems.js +18 -4
  173. package/lib/components/TagItem/OperationsNavigation.js +46 -2
  174. package/lib/components/TagItem/TagItem.js +40 -7
  175. package/lib/components/TagItem/index.js +2 -1
  176. package/lib/components/TagItem/styled.js +5 -2
  177. package/lib/components/TagItem/types.js +2 -0
  178. package/lib/components/ViewNested/ViewNested.js +42 -9
  179. package/lib/components/ViewNested/index.js +2 -1
  180. package/lib/components/common/Badges.js +21 -5
  181. package/lib/components/common/BodyContent/BodyContent.js +31 -4
  182. package/lib/components/common/BodyContent/index.js +2 -1
  183. package/lib/components/common/ClearButton/ClearButton.js +5 -1
  184. package/lib/components/common/ClearButton/index.js +3 -1
  185. package/lib/components/common/ClearButton/styled.js +5 -2
  186. package/lib/components/common/ClearButton/types.js +2 -0
  187. package/lib/components/common/CodeBlockPanel.js +7 -3
  188. package/lib/components/common/ConstraintsView.js +14 -2
  189. package/lib/components/common/Dropdown/Dropdown.js +22 -4
  190. package/lib/components/common/Dropdown/index.js +2 -1
  191. package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
  192. package/lib/components/common/ExpandableExample/index.js +2 -1
  193. package/lib/components/common/Extensions.js +17 -2
  194. package/lib/components/common/Fields/fields-layout.js +76 -51
  195. package/lib/components/common/Fields/fields.js +39 -17
  196. package/lib/components/common/Fields/index.js +3 -1
  197. package/lib/components/common/LinkToField.js +33 -6
  198. package/lib/components/common/OperationItemTitle.js +12 -6
  199. package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
  200. package/lib/components/common/SchemaSelection/index.js +2 -1
  201. package/lib/components/common/Select/Select.js +21 -1
  202. package/lib/components/common/Select/index.js +3 -1
  203. package/lib/components/common/Select/styled.js +17 -9
  204. package/lib/components/common/Select/types.js +2 -0
  205. package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
  206. package/lib/components/common/Skeleton/Skeleton.js +15 -5
  207. package/lib/components/common/Skeleton/index.js +3 -1
  208. package/lib/components/common/headers.js +4 -2
  209. package/lib/components/common/index.js +14 -1
  210. package/lib/components/common/linkify.js +28 -4
  211. package/lib/components/common/mixins.js +4 -2
  212. package/lib/components/common/panels.js +52 -29
  213. package/lib/components/common/schema.js +16 -8
  214. package/lib/components/common/styled.js +15 -7
  215. package/lib/components/index.js +25 -1
  216. package/lib/components/pluggable/RedocExample.js +20 -1
  217. package/lib/components/pluggable/RedocSchema.js +22 -1
  218. package/lib/components/pluggable/index.js +3 -1
  219. package/lib/components/pluggable/styled.components.js +9 -4
  220. package/lib/constants.js +30 -1
  221. package/lib/empty.js +7 -1
  222. package/lib/events/codeSampleCopy.js +19 -1
  223. package/lib/events/creator.js +5 -1
  224. package/lib/events/index.js +8 -1
  225. package/lib/events/languageSwitch.js +18 -1
  226. package/lib/events/panelToggle.js +16 -1
  227. package/lib/events/serverSwitch.js +13 -1
  228. package/lib/events/tryItOpen.js +12 -1
  229. package/lib/events/tryItSent.js +12 -1
  230. package/lib/events/types.js +11 -1
  231. package/lib/hoc/types.js +2 -0
  232. package/lib/hoc/utils.js +4 -1
  233. package/lib/hoc/withRouter.js +17 -1
  234. package/lib/hoc/withStore.js +28 -1
  235. package/lib/hooks/index.js +9 -1
  236. package/lib/hooks/useActivateExample.js +35 -1
  237. package/lib/hooks/useActiveWithFallback.js +12 -1
  238. package/lib/hooks/useContentItems.js +10 -1
  239. package/lib/hooks/useLicense.js +17 -1
  240. package/lib/hooks/usePerformanceMetrics.js +26 -1
  241. package/lib/hooks/useRouter.js +17 -1
  242. package/lib/hooks/useTelemetry.js +5 -1
  243. package/lib/hooks/useTranslate.js +6 -1
  244. package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
  245. package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
  246. package/lib/icons/CSharpIcon/index.js +2 -1
  247. package/lib/icons/CurlIcon/CurlIcon.js +8 -2
  248. package/lib/icons/CurlIcon/index.js +2 -1
  249. package/lib/icons/GOIcon/GOIcon.js +7 -1
  250. package/lib/icons/GOIcon/index.js +2 -1
  251. package/lib/icons/JavaIcon/JavaIcon.js +7 -1
  252. package/lib/icons/JavaIcon/index.js +2 -1
  253. package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
  254. package/lib/icons/JavaScriptIcon/index.js +2 -1
  255. package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
  256. package/lib/icons/NodeJSIcon/index.js +2 -1
  257. package/lib/icons/PHPIcon/PHPIcon.js +7 -1
  258. package/lib/icons/PHPIcon/index.js +2 -1
  259. package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
  260. package/lib/icons/PayloadIcon/index.js +2 -1
  261. package/lib/icons/PythonIcon/PythonIcon.js +7 -1
  262. package/lib/icons/PythonIcon/index.js +2 -1
  263. package/lib/icons/RIcon/RIcon.js +7 -1
  264. package/lib/icons/RIcon/index.js +2 -1
  265. package/lib/icons/RubyIcon/RubyIcon.js +7 -1
  266. package/lib/icons/RubyIcon/index.js +2 -1
  267. package/lib/index.js +49 -1
  268. package/lib/jotai/app.js +113 -1
  269. package/lib/jotai/operation.js +28 -1
  270. package/lib/jotai/replay.js +5 -1
  271. package/lib/jotai/store.js +8 -1
  272. package/lib/jotai/use-write-atom.js +9 -1
  273. package/lib/models/callback.js +28 -1
  274. package/lib/models/code-sample-options.js +2 -0
  275. package/lib/models/example.js +17 -1
  276. package/lib/models/field.js +109 -1
  277. package/lib/models/group.js +38 -1
  278. package/lib/models/index.js +14 -1
  279. package/lib/models/mediaContent.js +26 -1
  280. package/lib/models/mediaType.js +153 -1
  281. package/lib/models/operation.js +166 -1
  282. package/lib/models/request.js +25 -1
  283. package/lib/models/response.js +46 -1
  284. package/lib/models/schema.js +474 -2
  285. package/lib/models/security.js +84 -1
  286. package/lib/models/tab.js +2 -0
  287. package/lib/models/types.js +2 -0
  288. package/lib/services/OpenAPIParser.js +321 -1
  289. package/lib/services/check.js +104 -1
  290. package/lib/services/code-samples/constants.js +16 -1
  291. package/lib/services/code-samples/generator.js +540 -1
  292. package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
  293. package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
  294. package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
  295. package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
  296. package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
  297. package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
  298. package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
  299. package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
  300. package/lib/services/code-samples/httpsnippet/index.js +166 -1
  301. package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
  302. package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
  303. package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
  304. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
  305. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
  306. package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
  307. package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
  308. package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
  309. package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
  310. package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
  311. package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
  312. package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
  313. package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
  314. package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
  315. package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
  316. package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
  317. package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
  318. package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
  319. package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
  320. package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
  321. package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
  322. package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
  323. package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
  324. package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
  325. package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
  326. package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
  327. package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
  328. package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
  329. package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
  330. package/lib/services/code-samples/index.js +3 -1
  331. package/lib/services/code-samples/types.js +2 -0
  332. package/lib/services/config-options/helpers.js +49 -1
  333. package/lib/services/config-options/index.js +3 -1
  334. package/lib/services/config-options/normalizeOptions.js +83 -1
  335. package/lib/services/config-options/types.js +2 -0
  336. package/lib/services/history/helpers.js +63 -1
  337. package/lib/services/history/index.js +2 -1
  338. package/lib/services/index.js +9 -1
  339. package/lib/services/menu/builder.js +47 -1
  340. package/lib/services/menu/index.js +2 -1
  341. package/lib/services/menu/markdown.js +93 -1
  342. package/lib/services/menu/operation.js +50 -1
  343. package/lib/services/menu/tags.js +166 -1
  344. package/lib/services/types.js +2 -0
  345. package/lib/services/utils.js +83 -1
  346. package/lib/standalone.js +68 -1
  347. package/lib/styled-components.js +6 -1
  348. package/lib/types/app.js +2 -0
  349. package/lib/types/index.js +4 -1
  350. package/lib/types/open-api.js +2 -0
  351. package/lib/types/security.js +2 -0
  352. package/lib/utils/JsonPointer.js +84 -1
  353. package/lib/utils/areArraysEqual.js +4 -1
  354. package/lib/utils/argValuesHelpers.js +35 -1
  355. package/lib/utils/compose.js +2 -1
  356. package/lib/utils/configure-helpers.js +223 -1
  357. package/lib/utils/convertSwagger2OpenAPI.js +14 -1
  358. package/lib/utils/cookies.js +73 -1
  359. package/lib/utils/debounce.js +22 -1
  360. package/lib/utils/debug.js +11 -1
  361. package/lib/utils/dom.js +65 -1
  362. package/lib/utils/environments.js +13 -1
  363. package/lib/utils/helpers.js +222 -12
  364. package/lib/utils/index.js +25 -1
  365. package/lib/utils/isMobile.js +13 -1
  366. package/lib/utils/loadAndBundleSpec.js +32 -1
  367. package/lib/utils/local-storage.js +12 -1
  368. package/lib/utils/object.js +31 -1
  369. package/lib/utils/openapi.js +592 -1
  370. package/lib/utils/parameters.js +13 -1
  371. package/lib/utils/path.js +22 -1
  372. package/lib/utils/queryString.js +60 -1
  373. package/lib/utils/replaceVariables.js +14 -1
  374. package/lib/utils/saveTextBeforeHeading.js +35 -1
  375. package/lib/utils/security-details.js +49 -1
  376. package/lib/utils/session-storage.js +12 -1
  377. package/lib/utils/simplifyAstStructure.js +22 -1
  378. package/lib/utils/sort.js +21 -1
  379. package/lib/utils/string.js +65 -1
  380. package/lib/utils/telemetry.js +7 -1
  381. package/lib/utils/test-utils.js +26 -1
  382. package/lib/utils/theme-helpers.js +24 -3
  383. package/lib/utils/url.js +38 -1
  384. package/package.json +4 -4
@@ -1,4 +1,29 @@
1
- import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Fragment as h,useState as f,useRef as u}from"react";import{useOutsideClick as v,useFocusTrap as x}from"@redocly/theme/core/openapi";import{Button as b}from"@redocly/theme/components/Button/Button";import{SecurityIcon as y}from"@redocly/theme/icons/SecurityIcon/SecurityIcon";import{Segmented as S}from"@redocly/theme/components/Segmented/Segmented";import{CloseIcon as w}from"@redocly/theme/icons/CloseIcon/CloseIcon";import{Typography as z}from"@redocly/theme/components/Typography/Typography";import{SecurityFlow as j}from"./SecurityFlow.js";import{Divider as k}from"./Divider.js";import{useTranslate as C}from"../../hooks/index.js";import{styled as e}from"../../styled-components.js";function J({securities:r,onClose:s}){const c=C(),[l,d]=f(0),i=u(null),{schemes:p}=r[l]||{};v(i,s),x(i);const m=r.map(({schemes:o},a)=>({label:o.map(({id:g})=>g).join(" and "),value:a}));return t(F,{children:n(T,{ref:i,tabIndex:0,children:[t(I,{onClick:s,"data-testid":"close",variant:"ghost",icon:t(w,{})}),n(B,{children:[t(y,{size:"24px"}),c("openapi.security","Security")]}),t(S,{value:l,onChange:({value:o})=>d(o),options:m}),p.map((o,a)=>n(h,{children:[t(j,{...o,securities:r}),a!==p.length-1&&t(k,{label:"and"})]},o.id))]})})}const T=e.div`
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, useState, useRef } from 'react';
3
+ import { useOutsideClick, useFocusTrap } from '@redocly/theme/core/openapi';
4
+ import { Button } from '@redocly/theme/components/Button/Button';
5
+ import { SecurityIcon } from '@redocly/theme/icons/SecurityIcon/SecurityIcon';
6
+ import { Segmented } from '@redocly/theme/components/Segmented/Segmented';
7
+ import { CloseIcon } from '@redocly/theme/icons/CloseIcon/CloseIcon';
8
+ import { Typography } from '@redocly/theme/components/Typography/Typography';
9
+ import { SecurityFlow } from './SecurityFlow.js';
10
+ import { Divider } from './Divider.js';
11
+ import { useTranslate } from '../../hooks/index.js';
12
+ import { styled } from '../../styled-components.js';
13
+ export function SecurityModal({ securities, onClose }) {
14
+ const translate = useTranslate();
15
+ const [selectedSecurityScheme, setSelectedSecurityScheme] = useState(0);
16
+ const modalRef = useRef(null);
17
+ const { schemes } = securities[selectedSecurityScheme] || {};
18
+ useOutsideClick(modalRef, onClose);
19
+ useFocusTrap(modalRef);
20
+ const options = securities.map(({ schemes }, index) => ({
21
+ label: schemes.map(({ id }) => id).join(' and '),
22
+ value: index,
23
+ }));
24
+ return (_jsx(StyledBackground, { children: _jsxs(Wrapper, { ref: modalRef, tabIndex: 0, children: [_jsx(Close, { onClick: onClose, "data-testid": "close", variant: "ghost", icon: _jsx(CloseIcon, {}) }), _jsxs(Title, { children: [_jsx(SecurityIcon, { size: "24px" }), translate('openapi.security', 'Security')] }), _jsx(Segmented, { value: selectedSecurityScheme, onChange: ({ value }) => setSelectedSecurityScheme(value), options: options }), schemes.map((scheme, index) => (_jsxs(Fragment, { children: [_jsx(SecurityFlow, { ...scheme, securities: securities }), index !== schemes.length - 1 && _jsx(Divider, { label: "and" })] }, scheme.id)))] }) }));
25
+ }
26
+ const Wrapper = styled.div `
2
27
  background: var(--bg-color);
3
28
  box-shadow: var(--bg-raised-shadow);
4
29
  border-radius: var(--border-radius-lg);
@@ -19,7 +44,8 @@ import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Fragment as h,useState
19
44
  font-size: var(--font-size-base);
20
45
  line-height: var(--line-height-base);
21
46
  }
22
- `,F=e.div`
47
+ `;
48
+ const StyledBackground = styled.div `
23
49
  background: var(--bg-color-modal-overlay);
24
50
  position: fixed;
25
51
  width: 100vw;
@@ -28,11 +54,13 @@ import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Fragment as h,useState
28
54
  left: 0;
29
55
  top: 0;
30
56
  pointer-events: auto;
31
- `,I=e(b)`
57
+ `;
58
+ const Close = styled(Button) `
32
59
  position: absolute;
33
60
  right: var(--spacing-md);
34
61
  top: var(--spacing-md);
35
- `,B=e(z)`
62
+ `;
63
+ const Title = styled(Typography) `
36
64
  display: flex;
37
65
  align-items: center;
38
66
  font-size: var(--h4-font-size);
@@ -41,4 +69,5 @@ import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Fragment as h,useState
41
69
  svg {
42
70
  margin-right: var(--spacing-xs);
43
71
  }
44
- `;export{J as SecurityModal};
72
+ `;
73
+ //# sourceMappingURL=SecurityModal.js.map
@@ -1,20 +1,31 @@
1
- import{jsx as r,jsxs as s}from"react/jsx-runtime";import{styled as e}from"../../styled-components.js";function c({label:t,value:i}){return!t||!i?null:s(n,{children:[r(o,{children:t}),r(a,{children:i})]})}const n=e.div`
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { styled } from '../../styled-components.js';
3
+ export function SecuritySchemeItem({ label, value }) {
4
+ if (!label || !value) {
5
+ return null;
6
+ }
7
+ return (_jsxs(Row, { children: [_jsx(Label, { children: label }), _jsx(Value, { children: value })] }));
8
+ }
9
+ const Row = styled.div `
2
10
  display: flex;
3
11
  flex-wrap: wrap;
4
12
  justify-content: flex-start;
5
13
  margin-bottom: var(--spacing-xs);
6
14
  font-size: var(--font-size-sm);
7
15
  color: var(--text-color-secondary);
8
- `,o=e.div`
16
+ `;
17
+ const Label = styled.div `
9
18
  display: flex;
10
19
  align-items: center;
11
20
  justify-content: flex-start;
12
21
  font-size: var(--font-size-base);
13
22
  line-height: var(--line-height-base);
14
23
  flex: 1;
15
- `,a=e.div`
24
+ `;
25
+ const Value = styled.div `
16
26
  flex: 1;
17
27
  font-size: var(--font-size-base);
18
28
  line-height: var(--line-height-base);
19
29
  word-break: break-word;
20
- `;export{c as SecuritySchemeItem};
30
+ `;
31
+ //# sourceMappingURL=SecuritySchemeItem.js.map
@@ -1 +1,16 @@
1
- function f(r,o){const e=new Set;return o.forEach(({schemes:t})=>{t.forEach(({id:c,scopes:n})=>{c===r&&n.forEach(a=>e.add(a))})}),Array.from(e)}function i(r,o){const e=new Set(r);return o.filter(t=>!e.has(t))}export{i as getOptionalScopes,f as getRequiredScopes};
1
+ export function getRequiredScopes(id, securities) {
2
+ const allScopes = new Set();
3
+ securities.forEach(({ schemes }) => {
4
+ schemes.forEach(({ id: schemeId, scopes }) => {
5
+ if (schemeId === id) {
6
+ scopes.forEach((scope) => allScopes.add(scope));
7
+ }
8
+ });
9
+ });
10
+ return Array.from(allScopes);
11
+ }
12
+ export function getOptionalScopes(requiredScopes, allScopes) {
13
+ const requiredScopesSet = new Set(requiredScopes);
14
+ return allScopes.filter((scope) => !requiredScopesSet.has(scope));
15
+ }
16
+ //# sourceMappingURL=helper.js.map
@@ -1 +1,11 @@
1
- import{Security as e}from"./Security.js";import{SecurityButton as m}from"./SecurityButton.js";import{SecurityFlow as f}from"./SecurityFlow.js";import{SecuritySchemeItem as u}from"./SecuritySchemeItem.js";import{OAuthFlow as i}from"./OAuthFlow.js";import{OAuthScopes as y}from"./OAuthScopes.js";import{SecurityModal as l}from"./SecurityModal.js";import{Divider as w}from"./Divider.js";export*from"./helper.js";export*from"./styled.js";export{w as Divider,i as OAuthFlow,y as OAuthScopes,e as Security,m as SecurityButton,f as SecurityFlow,l as SecurityModal,u as SecuritySchemeItem};
1
+ export { Security } from './Security.js';
2
+ export { SecurityButton } from './SecurityButton.js';
3
+ export { SecurityFlow } from './SecurityFlow.js';
4
+ export { SecuritySchemeItem } from './SecuritySchemeItem.js';
5
+ export { OAuthFlow } from './OAuthFlow.js';
6
+ export { OAuthScopes } from './OAuthScopes.js';
7
+ export { SecurityModal } from './SecurityModal.js';
8
+ export { Divider } from './Divider.js';
9
+ export * from './helper.js';
10
+ export * from './styled.js';
11
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,5 @@
1
- import{styled as r}from"../../styled-components.js";const a=r.div`
1
+ import { styled } from '../../styled-components.js';
2
+ export const Tag = styled.div `
2
3
  border-radius: var(--border-radius);
3
4
  padding: 0 var(--spacing-xxs);
4
5
  font-family: var(--font-family-monospaced);
@@ -6,8 +7,10 @@ import{styled as r}from"../../styled-components.js";const a=r.div`
6
7
  line-height: var(--line-height-sm);
7
8
  color: var(--text-color-primary);
8
9
  background-color: var(--tag-bg-color);
9
- `,i=r.a`
10
+ `;
11
+ export const StyledLink = styled.a `
10
12
  color: var(--link-color-primary);
11
13
  text-decoration: none;
12
14
  word-wrap: break-word;
13
- `;export{i as StyledLink,a as Tag};
15
+ `;
16
+ //# sourceMappingURL=styled.js.map
@@ -1,7 +1,17 @@
1
- import{jsx as o}from"react/jsx-runtime";import{SimpleSelect as n}from"../common/Select/index.js";import{styled as i}from"../../styled-components.js";const m=i.span`
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { SimpleSelect } from '../common/Select/index.js';
3
+ import { styled } from '../../styled-components.js';
4
+ const MimeLabel = styled.span `
2
5
  margin-left: 4px;
3
6
  font-size: 14px;
4
7
  text-transform: none;
5
8
  font-weight: 400;
6
9
  color: var(--text-color-primary);
7
- `;function p({Label:r=m,Select:e=n,...t}){return t.options.length===1?o(r,{children:t.options[0].value}):o(e,{...t})}export{p as SelectOrLabel};
10
+ `;
11
+ export function SelectOrLabel({ Label = MimeLabel, Select = SimpleSelect, ...selectProps }) {
12
+ if (selectProps.options.length === 1) {
13
+ return _jsx(Label, { children: selectProps.options[0].value });
14
+ }
15
+ return _jsx(Select, { ...selectProps });
16
+ }
17
+ //# sourceMappingURL=SelectOrLabel.js.map
@@ -1 +1,2 @@
1
- import{SelectOrLabel as l}from"./SelectOrLabel.js";export{l as SelectOrLabel};
1
+ export { SelectOrLabel } from './SelectOrLabel.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,21 @@
1
- import{jsx as i,jsxs as t}from"react/jsx-runtime";import{CopyButton as v}from"@redocly/theme/components/Buttons/CopyButton";import{PanelItemDescription as x,Title as f}from"../PanelItem/index.js";import{ViewNested as u}from"../ViewNested/index.js";import{Tag as y}from"../common/index.js";import{Markdown as w}from"../Markdown/index.js";import{styled as e}from"../../styled-components.js";const V=({servers:h,path:b,translate:r})=>i(j,{children:h.map(o=>{const a=o.url+b,d=Object.keys(o.variables||{}).length,p=d===1?"variable":"variables",l=`${d||""} ${r(`openapi.${p}`,p)}`;return t("div",{children:[i(x,{children:o.description}),t(k,{children:[i(f,{suppressHydrationWarning:!0,children:a}),i(v,{data:a},a)]}),o.variables&&i(u,{expandText:`${r("openapi.actions.show","Show")} ${l}`,hideText:`${r("openapi.actions.hide","Hide")} ${l}`,expandByDefault:!1,expandable:!0,hideDivider:!0,children:i(S,{children:Object.entries(o.variables||{}).map(([c,n])=>t(T,{children:[i(z,{children:c}),t(s,{children:[r("openapi.default","Default")," ",i(g,{children:n.default})]}),i($,{source:n.description}),n.enum&&t(s,{children:[r("openapi.enum","Enum")," ",i(D,{children:n.enum.map(m=>i(g,{children:m},m))})]})]},c))})})]},o.url)})}),j=e.div`
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CopyButton } from '@redocly/theme/components/Buttons/CopyButton';
3
+ import { PanelItemDescription, Title } from '../PanelItem/index.js';
4
+ import { ViewNested } from '../ViewNested/index.js';
5
+ import { Tag } from '../common/index.js';
6
+ import { Markdown } from '../Markdown/index.js';
7
+ import { styled } from '../../styled-components.js';
8
+ export const ServerList = ({ servers, path, translate }) => (_jsx(ItemsList, { children: servers.map((server) => {
9
+ const url = server.url + path;
10
+ const propertyLength = Object.keys(server.variables || {}).length;
11
+ const keyword = propertyLength === 1 ? 'variable' : 'variables';
12
+ const pluralOrSingular = `${propertyLength || ''} ${translate(`openapi.${keyword}`, keyword)}`;
13
+ {
14
+ /* TODO: highlight server variables, e.g. https://{user}.test.com */
15
+ }
16
+ return (_jsxs("div", { children: [_jsx(PanelItemDescription, { children: server.description }), _jsxs(TitleWrap, { children: [_jsx(Title, { suppressHydrationWarning: true, children: url }), _jsx(CopyButton, { data: url }, url)] }), server.variables && (_jsx(ViewNested, { expandText: `${translate('openapi.actions.show', 'Show')} ${pluralOrSingular}`, hideText: `${translate('openapi.actions.hide', 'Hide')} ${pluralOrSingular}`, expandByDefault: false, expandable: true, hideDivider: true, children: _jsx(ServerVariablesContainer, { children: Object.entries(server.variables || {}).map(([varName, varValue]) => (_jsxs(ServerVariableContainer, { children: [_jsx(ServerVariableName, { children: varName }), _jsxs(Variable, { children: [translate('openapi.default', 'Default'), ' ', _jsx(StyledTag, { children: varValue.default })] }), _jsx(Description, { source: varValue.description }), varValue.enum && (_jsxs(Variable, { children: [translate('openapi.enum', 'Enum'), ' ', _jsx(TagWrapper, { children: varValue.enum.map((el) => (_jsx(StyledTag, { children: el }, el))) })] }))] }, varName))) }) }))] }, server.url));
17
+ }) }));
18
+ const ItemsList = styled.div `
2
19
  & > div {
3
20
  border-bottom: 1px solid var(--border-color-secondary);
4
21
  margin-bottom: var(--spacing-xs);
@@ -10,7 +27,8 @@ import{jsx as i,jsxs as t}from"react/jsx-runtime";import{CopyButton as v}from"@r
10
27
  margin-bottom: 0;
11
28
  padding-bottom: 0;
12
29
  }
13
- `,S=e.div`
30
+ `;
31
+ const ServerVariablesContainer = styled.div `
14
32
  padding-left: var(--spacing-xxs);
15
33
  & > div {
16
34
  border-bottom: 1px solid var(--border-color-secondary);
@@ -28,32 +46,40 @@ import{jsx as i,jsxs as t}from"react/jsx-runtime";import{CopyButton as v}from"@r
28
46
  margin-bottom: 0;
29
47
  padding-bottom: 0;
30
48
  }
31
- `,T=e.div`
49
+ `;
50
+ const ServerVariableContainer = styled.div `
32
51
  display: flex;
33
52
  flex-direction: column;
34
53
  flex-wrap: wrap;
35
- `,$=e(w)`
54
+ `;
55
+ const Description = styled(Markdown) `
36
56
  font-size: var(--font-size-sm);
37
57
  line-height: var(--line-height-sm);
38
58
  color: var(--text-color-primary);
39
- `,s=e.span`
59
+ `;
60
+ const Variable = styled.span `
40
61
  display: flex;
41
62
  gap: var(--spacing-xxs);
42
63
  font-size: var(--font-size-sm);
43
64
  line-height: var(--line-height-sm);
44
65
  color: var(--text-color-primary);
45
- `,z=e(s)`
66
+ `;
67
+ const ServerVariableName = styled(Variable) `
46
68
  padding-bottom: var(--spacing-xxs);
47
69
  font-weight: var(--font-weight-semibold);
48
- `,D=e.span`
70
+ `;
71
+ const TagWrapper = styled.span `
49
72
  display: flex;
50
73
  gap: var(--spacing-xxs);
51
74
  flex-wrap: wrap;
52
- `,g=e(y)`
75
+ `;
76
+ const StyledTag = styled(Tag) `
53
77
  font-size: var(--font-size-sm);
54
78
  line-height: var(--line-height-sm);
55
- `,k=e.div`
79
+ `;
80
+ const TitleWrap = styled.div `
56
81
  display: flex;
57
82
  justify-content: space-between;
58
83
  align-items: center;
59
- `;export{V as ServerList};
84
+ `;
85
+ //# sourceMappingURL=ServerList.js.map
@@ -1 +1,2 @@
1
- import{ServerList as o}from"./ServerList.js";export{o as ServerList};
1
+ export { ServerList } from './ServerList.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1,54 @@
1
- import{jsx as e,jsxs as v}from"react/jsx-runtime";import{useMemo as f,useCallback as l}from"react";import{useAtom as S,useAtomValue as w}from"jotai";import{DropdownMenu as y}from"@redocly/theme/components/Dropdown/DropdownMenu";import{Dropdown as g}from"@redocly/theme/components/Dropdown/Dropdown";import{HttpVerb as k}from"../common/index.js";import{PathWrapper as A,Path as b,StyledCopyButton as C,StyledDropdownMenuItem as P}from"./styled.js";import{PanelItem as j}from"../PanelItem/index.js";import{joinWithSeparator as x}from"../../services/index.js";import{replaceVariables as V}from"../../utils/index.js";import{environmentAtom as D}from"../../jotai/app.js";import{useActiveWithFallback as _,useTelemetry as E}from"../../hooks/index.js";import{getServerEnvName as p}from"../../utils/environments.js";import{createTargetServerSwitchEvent as M}from"../../events/index.js";import{globalStoreAtom as W}from"../../jotai/store.js";const R=({operation:r,className:h})=>{const m=E(),[[d],i]=S(D),{options:{events:n}}=w(W),s=_(r.servers.map(t=>({...t,key:t.url})),d.server),c=l(t=>{t.stopPropagation()},[]),a=l(t=>()=>{if(r.servers.length!==1&&(i({environment:p(t)}),m.send({type:"openapi_docs.switch_servers.clicked",payload:{server:p(t)}}),n?.targetServerSwitch&&t)){const o=M({operation:r,serverUrl:t.url});n.targetServerSwitch(o)}},[r,i,m,n]),u=f(()=>r.servers.map(t=>{const o=x(V(t),r.path);return e(P,{onAction:a(t),children:e(j,{header:t.description,title:o,actions:[e(C,{data:o,toasterPlacement:"left",onCopyClick:c},o)],active:t.url===s,withCheckmark:!0})},o)}),[r.servers,r.path,a,c,s]);return e(g,{className:h,trigger:v(A,{variant:"ghost",children:[e(k,{color:r.httpVerb,children:r.httpVerb}),e(b,{children:r.path})]}),withArrow:!0,children:e(y,{children:u})})};export{R as ServerListDropdown};
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useCallback } from 'react';
3
+ import { useAtom, useAtomValue } from 'jotai';
4
+ import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
5
+ import { Dropdown } from '@redocly/theme/components/Dropdown/Dropdown';
6
+ import { HttpVerb } from '../common/index.js';
7
+ import { PathWrapper, Path, StyledCopyButton, StyledDropdownMenuItem } from './styled.js';
8
+ import { PanelItem } from '../PanelItem/index.js';
9
+ import { joinWithSeparator } from '../../services/index.js';
10
+ import { replaceVariables } from '../../utils/index.js';
11
+ import { environmentAtom } from '../../jotai/app.js';
12
+ import { useActiveWithFallback, useTelemetry } from '../../hooks/index.js';
13
+ import { getServerEnvName } from '../../utils/environments.js';
14
+ import { createTargetServerSwitchEvent } from '../../events/index.js';
15
+ import { globalStoreAtom } from '../../jotai/store.js';
16
+ export const ServerListDropdown = ({ operation, className, }) => {
17
+ const telemetry = useTelemetry();
18
+ const [[environment], setEnvironment] = useAtom(environmentAtom);
19
+ const { options: { events }, } = useAtomValue(globalStoreAtom);
20
+ const activeServerUrl = useActiveWithFallback(operation.servers.map((s) => ({
21
+ ...s,
22
+ key: s.url,
23
+ })), environment.server);
24
+ const onCopyClick = useCallback((e) => {
25
+ e.stopPropagation();
26
+ }, []);
27
+ const handleAction = useCallback((server) => () => {
28
+ if (operation.servers.length === 1) {
29
+ return; // do not override environment if there is only one server
30
+ }
31
+ setEnvironment({ environment: getServerEnvName(server) });
32
+ telemetry.send({
33
+ type: 'openapi_docs.switch_servers.clicked',
34
+ payload: { server: getServerEnvName(server) },
35
+ });
36
+ if (events?.targetServerSwitch && server) {
37
+ const eventPayload = createTargetServerSwitchEvent({
38
+ operation: operation,
39
+ serverUrl: server.url,
40
+ });
41
+ events.targetServerSwitch(eventPayload);
42
+ }
43
+ }, [operation, setEnvironment, telemetry, events]);
44
+ const items = useMemo(() => {
45
+ return operation.servers.map((server) => {
46
+ const url = joinWithSeparator(replaceVariables(server), operation.path);
47
+ return (_jsx(StyledDropdownMenuItem, { onAction: handleAction(server), children: _jsx(PanelItem, { header: server.description, title: url, actions: [
48
+ _jsx(StyledCopyButton, { data: url, toasterPlacement: "left", onCopyClick: onCopyClick }, url),
49
+ ], active: server.url === activeServerUrl, withCheckmark: true }) }, url));
50
+ });
51
+ }, [operation.servers, operation.path, handleAction, onCopyClick, activeServerUrl]);
52
+ return (_jsx(Dropdown, { className: className, trigger: _jsxs(PathWrapper, { variant: "ghost", children: [_jsx(HttpVerb, { color: operation.httpVerb, children: operation.httpVerb }), _jsx(Path, { children: operation.path })] }), withArrow: true, children: _jsx(DropdownMenu, { children: items }) }));
53
+ };
54
+ //# sourceMappingURL=ServerListDropdown.js.map
@@ -1 +1,2 @@
1
- import{ServerListDropdown as e}from"./ServerListDropdown.js";export{e as ServerListDropdown};
1
+ export { ServerListDropdown } from './ServerListDropdown.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1,22 +1,31 @@
1
- import{breakpoints as e}from"@redocly/theme/core/openapi";import{Button as t}from"@redocly/theme/components/Button/Button";import{CopyButton as r}from"@redocly/theme/components/Buttons/CopyButton";import{DropdownMenuItem as n}from"@redocly/theme/components/Dropdown/DropdownMenuItem";import{styled as o}from"../../styled-components.js";const d=o(t)`
1
+ import { breakpoints } from '@redocly/theme/core/openapi';
2
+ import { Button } from '@redocly/theme/components/Button/Button';
3
+ import { CopyButton } from '@redocly/theme/components/Buttons/CopyButton';
4
+ import { DropdownMenuItem } from '@redocly/theme/components/Dropdown/DropdownMenuItem';
5
+ import { styled } from '../../styled-components.js';
6
+ export const PathWrapper = styled(Button) `
2
7
  display: inline-flex;
3
8
  overflow-x: hidden;
4
9
  font-weight: var(--font-weight-regular);
5
- `,c=o.span`
10
+ `;
11
+ export const Path = styled.span `
6
12
  overflow-x: hidden;
7
13
  text-overflow: ellipsis;
8
14
  white-space: nowrap;
9
15
  display: inline-block;
10
16
  line-height: var(--line-height-base);
11
17
  font-size: var(--font-size-base);
12
- `,m=o(n)`
18
+ `;
19
+ export const StyledDropdownMenuItem = styled(DropdownMenuItem) `
13
20
  padding: calc(var(--spacing-unit) * 1.5) var(--spacing-xs) calc(var(--spacing-unit) * 1.5)
14
21
  var(--spacing-lg);
15
- @media screen and (max-width: ${e.large}) {
22
+ @media screen and (max-width: ${breakpoints.large}) {
16
23
  max-width: 280px;
17
24
  }
18
- `,h=o(r)`
25
+ `;
26
+ export const StyledCopyButton = styled(CopyButton) `
19
27
  :hover {
20
28
  background-color: var(--dropdown-menu-item-bg-color-hover);
21
29
  }
22
- `;export{c as Path,d as PathWrapper,h as StyledCopyButton,m as StyledDropdownMenuItem};
30
+ `;
31
+ //# sourceMappingURL=styled.js.map
@@ -1,3 +1,14 @@
1
- import{jsx as e}from"react/jsx-runtime";import{memo as t}from"react";import{Menu as n}from"@redocly/theme/components/Menu/Menu";import{useMenuItems as s}from"./hooks/useMenuItems.js";import{styled as i}from"../../styled-components.js";const p=({items:o,className:m})=>{const r=s({items:o});return e(u,{className:m,children:e(n,{items:r})})},l=t(p),u=i.div`
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo } from 'react';
3
+ import { Menu } from '@redocly/theme/components/Menu/Menu';
4
+ import { useMenuItems } from './hooks/useMenuItems.js';
5
+ import { styled } from '../../styled-components.js';
6
+ const SideMenuComponent = ({ items, className }) => {
7
+ const menuItems = useMenuItems({ items });
8
+ return (_jsx(MenuWrapper, { className: className, children: _jsx(Menu, { items: menuItems }) }));
9
+ };
10
+ export const SideMenu = memo(SideMenuComponent);
11
+ export const MenuWrapper = styled.div `
2
12
  overflow: auto;
3
- `;export{u as MenuWrapper,l as SideMenu};
13
+ `;
14
+ //# sourceMappingURL=SideMenu.js.map
@@ -1 +1,110 @@
1
- import{useMemo as d}from"react";import{useLocation as b}from"react-router-dom";import{useActiveSectionId as l}from"@redocly/theme/core/openapi";import{pathMatchedLink as I}from"../../../utils/index.js";import{DEFAULT_WEBHOOKS_TAG_NAME as k}from"../../../constants.js";function W({items:s}){const n=b(),t=l(n,!1,!1);return d(()=>A(s,t,n),[t,s,n])}function A(s,n="",t){const o=[];return m({contentItems:s,sidebarItems:o,activeItemId:n,location:t}),o}function f(s,n="",t){return s.href?n?s.id===n:I(t,s.href):!1}function h(s,n="",t){return(s.items||[]).some(r=>f(r,n,t)||h(r,n,t))}function m(s){const{contentItems:n,sidebarItems:t,activeItemId:o,location:r}=s;let c=!0;for(const e of n){const i=f(e,o,r),a=h(e,o,r);switch(e.type){case"group":t.push({type:"separator",label:e.name,active:i,hasActiveSubItem:a}),m({...s,contentItems:e.items,sidebarItems:t});break;case"tag":const p={type:"group",label:e.name,items:[],link:e.href,active:i,hasActiveSubItem:a,modified:!0};t.push(p),m({contentItems:e.items,sidebarItems:p.items||[],activeItemId:o,location:r});break;case"operation":case"schema":e.isWebhook&&c&&e.parent.name!==k&&(t.push({type:"separator",label:"Webhooks",variant:"secondary"}),c=!1),t.push({type:"link",label:e.name,httpVerb:e.type==="schema"?"schema":e.httpVerb,link:e.href,badges:e.badges,active:i,hasActiveSubItem:a,modified:!0,deprecated:e.deprecated});break;case"section":if(e.depth===-1)continue;const u={type:e.items.length?"group":"link",label:e.name,link:e.href,items:[],active:i,hasActiveSubItem:a,modified:!0};t.push(u),e.items.length&&m({contentItems:e.items,sidebarItems:u.items,activeItemId:o,location:r});break}}}export{W as useMenuItems};
1
+ import { useMemo } from 'react';
2
+ import { useLocation } from 'react-router-dom';
3
+ import { useActiveSectionId } from '@redocly/theme/core/openapi';
4
+ import { pathMatchedLink } from '../../../utils/index.js';
5
+ import { DEFAULT_WEBHOOKS_TAG_NAME } from '../../../constants.js';
6
+ export function useMenuItems({ items }) {
7
+ const location = useLocation();
8
+ const activeItemId = useActiveSectionId(location, false, false);
9
+ return useMemo(() => mapAndSetActiveItems(items, activeItemId, location), [activeItemId, items, location]);
10
+ }
11
+ function mapAndSetActiveItems(items, activeItemId = '', location) {
12
+ const newItems = [];
13
+ convertOpenAPIDocs2Sidebar({
14
+ contentItems: items,
15
+ sidebarItems: newItems,
16
+ activeItemId,
17
+ location,
18
+ });
19
+ return newItems;
20
+ }
21
+ function isItemActive(item, activeItemId = '', location) {
22
+ if (!item.href)
23
+ return false;
24
+ if (activeItemId) {
25
+ return item.id === activeItemId;
26
+ }
27
+ return pathMatchedLink(location, item.href);
28
+ }
29
+ function isSubItemActive(item, activeItemId = '', location) {
30
+ const items = item.items || [];
31
+ return items.some((i) => {
32
+ return isItemActive(i, activeItemId, location) || isSubItemActive(i, activeItemId, location);
33
+ });
34
+ }
35
+ function convertOpenAPIDocs2Sidebar(data) {
36
+ const { contentItems, sidebarItems, activeItemId, location } = data;
37
+ let addWebhookSeparator = true;
38
+ for (const item of contentItems) {
39
+ const active = isItemActive(item, activeItemId, location);
40
+ const hasActiveSubItem = isSubItemActive(item, activeItemId, location);
41
+ switch (item.type) {
42
+ case 'group':
43
+ sidebarItems.push({ type: 'separator', label: item.name, active, hasActiveSubItem });
44
+ convertOpenAPIDocs2Sidebar({ ...data, contentItems: item.items, sidebarItems });
45
+ break;
46
+ case 'tag':
47
+ const tagGroup = {
48
+ type: 'group',
49
+ label: item.name,
50
+ items: [],
51
+ link: item.href,
52
+ active,
53
+ hasActiveSubItem,
54
+ modified: true,
55
+ };
56
+ sidebarItems.push(tagGroup);
57
+ convertOpenAPIDocs2Sidebar({
58
+ contentItems: item.items,
59
+ sidebarItems: tagGroup.items || [],
60
+ activeItemId,
61
+ location,
62
+ });
63
+ break;
64
+ case 'operation':
65
+ case 'schema':
66
+ if (item.isWebhook &&
67
+ addWebhookSeparator &&
68
+ item.parent.name !== DEFAULT_WEBHOOKS_TAG_NAME) {
69
+ sidebarItems.push({ type: 'separator', label: 'Webhooks', variant: 'secondary' });
70
+ addWebhookSeparator = false;
71
+ }
72
+ sidebarItems.push({
73
+ type: 'link',
74
+ label: item.name,
75
+ httpVerb: item.type === 'schema' ? 'schema' : item.httpVerb,
76
+ link: item.href,
77
+ badges: item.badges,
78
+ active,
79
+ hasActiveSubItem,
80
+ modified: true,
81
+ deprecated: item.deprecated,
82
+ });
83
+ break;
84
+ case 'section':
85
+ if (item.depth === -1) {
86
+ continue;
87
+ }
88
+ const sectionItem = {
89
+ type: item.items.length ? 'group' : 'link',
90
+ label: item.name,
91
+ link: item.href,
92
+ items: [],
93
+ active,
94
+ hasActiveSubItem,
95
+ modified: true,
96
+ };
97
+ sidebarItems.push(sectionItem);
98
+ if (item.items.length) {
99
+ convertOpenAPIDocs2Sidebar({
100
+ contentItems: item.items,
101
+ sidebarItems: sectionItem.items,
102
+ activeItemId,
103
+ location,
104
+ });
105
+ }
106
+ break;
107
+ }
108
+ }
109
+ }
110
+ //# sourceMappingURL=useMenuItems.js.map
@@ -1 +1,2 @@
1
- import{SideMenu as r}from"./SideMenu.js";export{r as SideMenu};
1
+ export { SideMenu } from './SideMenu.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1,5 +1,17 @@
1
- import{jsx as o,Fragment as n}from"react/jsx-runtime";import{useAtom as i}from"jotai";import{LayoutVariant as a}from"@redocly/config";import{SidebarActions as c}from"@redocly/theme/components/SidebarActions/SidebarActions";import{collapsedSidebarAtom as m,layoutAtom as p}from"../../jotai/app.js";import{styled as d}from"../../styled-components.js";const y=()=>{const[r,e]=i(p),[t,s]=i(m);return o(n,{children:o(l,{children:o(c,{layout:r,onChangeViewClick:()=>e(r===a.STACKED?a.THREE_PANEL:a.STACKED),collapsedSidebar:t,onChangeCollapseSidebarClick:()=>s(!t),isApiDocs:!0})})})},l=d.div`
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useAtom } from 'jotai';
3
+ import { LayoutVariant } from '@redocly/config';
4
+ import { SidebarActions as ThemeSidebarActions } from '@redocly/theme/components/SidebarActions/SidebarActions';
5
+ import { collapsedSidebarAtom, layoutAtom } from '../../jotai/app.js';
6
+ import { styled } from '../../styled-components.js';
7
+ export const SidebarActions = () => {
8
+ const [layout, setLayout] = useAtom(layoutAtom);
9
+ const [collapsedSidebar, setSidebarCollapsed] = useAtom(collapsedSidebarAtom);
10
+ return (_jsx(_Fragment, { children: _jsx(Wrapper, { children: _jsx(ThemeSidebarActions, { layout: layout, onChangeViewClick: () => setLayout(layout === LayoutVariant.STACKED ? LayoutVariant.THREE_PANEL : LayoutVariant.STACKED), collapsedSidebar: collapsedSidebar, onChangeCollapseSidebarClick: () => setSidebarCollapsed(!collapsedSidebar), isApiDocs: true }) }) }));
11
+ };
12
+ const Wrapper = styled.div `
2
13
  position: sticky;
3
14
  top: calc(100vh);
4
15
  padding: var(--spacing-sm) var(--spacing-md);
5
- `;export{y as SidebarActions};
16
+ `;
17
+ //# sourceMappingURL=SidebarActions.js.map
@@ -1,24 +1,54 @@
1
- import{jsx as n,jsxs as l,Fragment as f}from"react/jsx-runtime";import{memo as b,useEffect as h,useRef as u,useState as x}from"react";import{useAtom as y}from"jotai";import{useLocation as S}from"react-router-dom";import{useMount as v,breakpoints as k}from"@redocly/theme/core/openapi";import{isSidebarOpenedAtom as $}from"../../jotai/app.js";import{SidebarActions as g}from"./SidebarActions.js";import{styled as w}from"../../styled-components.js";const j=w.div`
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { memo, useEffect, useRef, useState } from 'react';
3
+ import { useAtom } from 'jotai';
4
+ import { useLocation } from 'react-router-dom';
5
+ import { useMount, breakpoints } from '@redocly/theme/core/openapi';
6
+ import { isSidebarOpenedAtom } from '../../jotai/app.js';
7
+ import { SidebarActions } from './SidebarActions.js';
8
+ import { styled } from '../../styled-components.js';
9
+ const StyledStickySidebar = styled.div `
2
10
  overflow: hidden;
3
11
  flex-direction: column;
4
12
  backface-visibility: hidden;
5
- height: ${({offsetTop:e})=>`calc(100vh - ${e})`};
13
+ height: ${({ offsetTop }) => `calc(100vh - ${offsetTop})`};
6
14
  top: 0;
7
15
  flex: 0 0 auto;
8
16
  position: fixed;
9
- display: ${({open:e})=>e?"flex":"none"};
17
+ display: ${({ open }) => (open ? 'flex' : 'none')};
10
18
  z-index: 2;
11
19
  width: 100%;
12
20
  background: var(--sidebar-bg-color);
13
- border-right: ${({collapsedSidebar:e})=>e?"1px solid var(--sidebar-border-color)":"auto"};
21
+ border-right: ${({ collapsedSidebar }) => collapsedSidebar ? '1px solid var(--sidebar-border-color)' : 'auto'};
14
22
 
15
- @media screen and (min-width: ${k.small}) {
23
+ @media screen and (min-width: ${breakpoints.small}) {
16
24
  position: sticky;
17
25
  z-index: auto;
18
- width: ${({collapsedSidebar:e})=>e?"var(--sidebar-width)":"auto"};
26
+ width: ${({ collapsedSidebar }) => (collapsedSidebar ? 'var(--sidebar-width)' : 'auto')};
19
27
  display: flex;
20
28
  }
21
29
  @media print {
22
30
  display: none;
23
31
  }
24
- `;function O({scrollYOffset:e,className:a,children:d,collapsedSidebar:i}){const[t,p]=x("0px"),m=u(null),o=S(),[s,r]=y($);return h(()=>{o.hash&&r(!1)},[o.pathname,o.hash,r]),v(()=>{const c=e();p(`${c}px`)}),n(f,{children:l(j,{open:s,className:a,offsetTop:t,style:{top:t},ref:m,collapsedSidebar:i,children:[i||s?d:null,n(g,{})]})})}const I=b(O);export{I as StickyResponsiveSidebar};
32
+ `;
33
+ function StickyResponsiveSidebarComponent({ scrollYOffset, className, children, collapsedSidebar, }) {
34
+ const [offsetTop, setOffsetTop] = useState('0px');
35
+ const stickyElement = useRef(null);
36
+ const location = useLocation();
37
+ const [isSidebarOpened, setIsSidebarOpened] = useAtom(isSidebarOpenedAtom);
38
+ useEffect(() => {
39
+ if (location.hash) {
40
+ setIsSidebarOpened(false);
41
+ }
42
+ }, [location.pathname, location.hash, setIsSidebarOpened]);
43
+ useMount(() => {
44
+ const top = scrollYOffset();
45
+ // rerender when hydrating from SSR
46
+ // see https://github.com/facebook/react/issues/8017#issuecomment-256351955
47
+ setOffsetTop(`${top}px`);
48
+ });
49
+ return (_jsx(_Fragment, { children: _jsxs(StyledStickySidebar, { open: isSidebarOpened, className: className, offsetTop: offsetTop, style: {
50
+ top: offsetTop,
51
+ }, ref: stickyElement, collapsedSidebar: collapsedSidebar, children: [collapsedSidebar || isSidebarOpened ? children : null, _jsx(SidebarActions, {})] }) }));
52
+ }
53
+ export const StickyResponsiveSidebar = memo(StickyResponsiveSidebarComponent);
54
+ //# sourceMappingURL=StickyResponsiveSidebar.js.map
@@ -1 +1,2 @@
1
- import{StickyResponsiveSidebar as o}from"./StickyResponsiveSidebar.js";export{o as StickyResponsiveSidebar};
1
+ export { StickyResponsiveSidebar } from './StickyResponsiveSidebar.js';
2
+ //# sourceMappingURL=index.js.map