@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,19 +1,29 @@
1
- import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/theme/core/openapi";import{typography as n}from"../../../utils/index.js";import{deprecatedCss as l}from"../mixins.js";import{styled as a}from"../../../styled-components.js";const p=o=>typeof document<"u"?getComputedStyle(document.documentElement).getPropertyValue(o).trim():"",h=a.caption`
1
+ import { css } from 'styled-components';
2
+ import { breakpoints } from '@redocly/theme/core/openapi';
3
+ import { typography } from '../../../utils/index.js';
4
+ import { deprecatedCss } from '../mixins.js';
5
+ import { styled } from '../../../styled-components.js';
6
+ export const getCssVariable = (variable) => typeof document !== 'undefined'
7
+ ? getComputedStyle(document.documentElement).getPropertyValue(variable).trim()
8
+ : '';
9
+ export const PropertiesTableCaption = styled.caption `
2
10
  text-align: right;
3
11
  font-size: 0.9em;
4
12
  font-weight: normal;
5
13
  color: var(--text-color-secondary);
6
- `,t=i`
14
+ `;
15
+ const repeatingGradient = css `
7
16
  repeating-linear-gradient(0deg,
8
17
  var(--schemas-lines-color),
9
18
  var(--schemas-lines-color) 3px,
10
19
  transparent 3px,
11
20
  transparent 5px,
12
21
  var(--schemas-lines-color) 5px);
13
- `,d=a.td`
22
+ `;
23
+ export const PropertyCell = styled.td `
14
24
  box-sizing: border-box;
15
25
  position: relative;
16
- background-image: ${t};
26
+ background-image: ${repeatingGradient};
17
27
  background-repeat: no-repeat;
18
28
  background-size: 1px 100%;
19
29
  display: block;
@@ -21,7 +31,7 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
21
31
  padding: 0 20px;
22
32
  margin-bottom: 2px;
23
33
 
24
- @media screen and (min-width: ${r.small}) {
34
+ @media screen and (min-width: ${breakpoints.small}) {
25
35
  display: table-cell;
26
36
  overflow: initial;
27
37
  padding: 10px;
@@ -29,17 +39,17 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
29
39
  }
30
40
 
31
41
  tr:first-of-type > & {
32
- background-image: ${t};
42
+ background-image: ${repeatingGradient};
33
43
  background-position: 0 10px;
34
44
  padding-top: 0;
35
45
  }
36
46
 
37
47
  tr.last > & {
38
- background-image: ${t};
48
+ background-image: ${repeatingGradient};
39
49
  padding-bottom: 0;
40
50
  background-size: 0.9px 100%;
41
51
 
42
- @media screen and (min-width: ${r.small}) {
52
+ @media screen and (min-width: ${breakpoints.small}) {
43
53
  background-size: 0.9px 22px;
44
54
  }
45
55
  }
@@ -49,18 +59,20 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
49
59
  }
50
60
 
51
61
  tr.last:first-child > & {
52
- background-image: ${t};
62
+ background-image: ${repeatingGradient};
53
63
  background-size: 0.9px 100%;
54
64
  background-position: 0 20px;
55
65
 
56
- @media screen and (min-width: ${r.small}) {
66
+ @media screen and (min-width: ${breakpoints.small}) {
57
67
  background-size: 0.9px 22px;
58
68
  background-position: 0 0;
59
69
  }
60
70
  }
61
- `,x=a(d)`
71
+ `;
72
+ export const PropertyCellWithInner = styled(PropertyCell) `
62
73
  padding: 0;
63
- `,u=a(d)`
74
+ `;
75
+ export const PropertyNameCell = styled(PropertyCell) `
64
76
  vertical-align: top;
65
77
  line-height: 23px;
66
78
  white-space: nowrap;
@@ -68,10 +80,11 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
68
80
  font-family: var(--field-name-font-family);
69
81
 
70
82
  &.deprecated {
71
- ${l};
83
+ ${deprecatedCss};
72
84
  }
73
85
 
74
- ${({kind:o})=>o==="patternProperties"&&i`
86
+ ${({ kind }) => kind === 'patternProperties' &&
87
+ css `
75
88
  span.field-name {
76
89
  white-space: break-spaces;
77
90
  text-align: left;
@@ -80,24 +93,32 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
80
93
  }
81
94
  `}
82
95
 
83
- ${()=>{const o=p("--schema-field-name-word-break");if(["break-all","break-word"].includes(o)){const s=`
96
+ ${() => {
97
+ const breakFieldNames = getCssVariable('--schema-field-name-word-break');
98
+ if (['break-all', 'break-word'].includes(breakFieldNames)) {
99
+ const wordBreakCSS = `
84
100
  && span:last-child {
85
101
  white-space: normal;
86
- word-break: ${o};
102
+ word-break: ${breakFieldNames};
87
103
  vertical-align: top;
88
104
  max-width: calc(100% - 21px);
89
105
  display: inline-flex;
90
106
  }
91
- `;return i`
92
- ${n("schemas-property-name")}
93
- ${s}
94
- `}return n("schemas-property-name")}};
107
+ `;
108
+ return css `
109
+ ${typography('schemas-property-name')}
110
+ ${wordBreakCSS}
111
+ `;
112
+ }
113
+ return typography('schemas-property-name');
114
+ }};
95
115
 
96
116
  .field-name {
97
117
  display: inline-flex;
98
118
  align-items: center;
99
119
  }
100
- `,$=a.td`
120
+ `;
121
+ export const PropertyDetailsCell = styled.td `
101
122
  box-sizing: border-box;
102
123
  vertical-align: top;
103
124
 
@@ -129,12 +150,13 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
129
150
  width: var(--schema-default-details-width);
130
151
  min-width: 200px;
131
152
 
132
- @media screen and (min-width: ${r.small}) {
153
+ @media screen and (min-width: ${breakpoints.small}) {
133
154
  border-bottom: 1px solid var(--border-color-primary);
134
155
  border-left: none;
135
156
  padding: 10px 0;
136
157
  }
137
- `,k=a.span`
158
+ `;
159
+ export const PropertyBullet = styled.span `
138
160
  margin-right: 10px;
139
161
  color: var(--schemas-lines-color);
140
162
  font-family: var(--code-font-family);
@@ -142,7 +164,7 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
142
164
  border-left: 1px dashed var(--schemas-lines-color);
143
165
  padding: 5px 10px;
144
166
 
145
- @media screen and (min-width: ${r.small}) {
167
+ @media screen and (min-width: ${breakpoints.small}) {
146
168
  border-left: none;
147
169
  padding: 10px;
148
170
  }
@@ -155,16 +177,18 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
155
177
  height: 1px;
156
178
  background: var(--schemas-lines-color);
157
179
  }
158
- `,e=a.div`
180
+ `;
181
+ export const InnerPropertiesWrap = styled.div `
159
182
  padding: var(--schema-nested-offset);
160
- `,v=a.table`
183
+ `;
184
+ export const PropertiesTable = styled.table `
161
185
  border-collapse: separate;
162
186
  border-radius: var(--border-radius);
163
187
  width: 100%;
164
188
  font-size: var(--font-size-base);
165
189
  display: block;
166
190
 
167
- @media screen and (min-width: ${r.small}) {
191
+ @media screen and (min-width: ${breakpoints.small}) {
168
192
  display: table;
169
193
  }
170
194
 
@@ -174,7 +198,7 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
174
198
  margin-bottom: 10px;
175
199
  border-spacing: 0;
176
200
 
177
- @media screen and (min-width: ${r.small}) {
201
+ @media screen and (min-width: ${breakpoints.small}) {
178
202
  display: table-row;
179
203
  margin-bottom: 0;
180
204
  border-spacing: 0 2px;
@@ -185,7 +209,7 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
185
209
  vertical-align: middle;
186
210
  }
187
211
 
188
- @media screen and (max-width: ${r.small}) and (-ms-high-contrast: none) {
212
+ @media screen and (max-width: ${breakpoints.small}) and (-ms-high-contrast: none) {
189
213
  td {
190
214
  float: left;
191
215
  width: 100%;
@@ -193,17 +217,17 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
193
217
  }
194
218
 
195
219
  &
196
- ${e},
220
+ ${InnerPropertiesWrap},
197
221
  &
198
- ${e}
199
- ${e}
200
- ${e},
222
+ ${InnerPropertiesWrap}
223
+ ${InnerPropertiesWrap}
224
+ ${InnerPropertiesWrap},
201
225
  &
202
- ${e}
203
- ${e}
204
- ${e}
205
- ${e}
206
- ${e} {
226
+ ${InnerPropertiesWrap}
227
+ ${InnerPropertiesWrap}
228
+ ${InnerPropertiesWrap}
229
+ ${InnerPropertiesWrap}
230
+ ${InnerPropertiesWrap} {
207
231
  margin-left: var(--schema-nested-offset);
208
232
  margin-bottom: var(--schema-nested-offset);
209
233
  background: var(--schema-nested-background-color);
@@ -211,20 +235,21 @@ import{css as i}from"styled-components";import{breakpoints as r}from"@redocly/th
211
235
  }
212
236
 
213
237
  &
214
- ${e}
215
- ${e},
238
+ ${InnerPropertiesWrap}
239
+ ${InnerPropertiesWrap},
216
240
  &
217
- ${e}
218
- ${e}
219
- ${e}
220
- ${e},
241
+ ${InnerPropertiesWrap}
242
+ ${InnerPropertiesWrap}
243
+ ${InnerPropertiesWrap}
244
+ ${InnerPropertiesWrap},
221
245
  &
222
- ${e}
223
- ${e}
224
- ${e}
225
- ${e}
226
- ${e}
227
- ${e} {
246
+ ${InnerPropertiesWrap}
247
+ ${InnerPropertiesWrap}
248
+ ${InnerPropertiesWrap}
249
+ ${InnerPropertiesWrap}
250
+ ${InnerPropertiesWrap}
251
+ ${InnerPropertiesWrap} {
228
252
  background: var(--panel-bg-color, #fff);
229
253
  }
230
- `;export{e as InnerPropertiesWrap,v as PropertiesTable,h as PropertiesTableCaption,k as PropertyBullet,d as PropertyCell,x as PropertyCellWithInner,$ as PropertyDetailsCell,u as PropertyNameCell,p as getCssVariable};
254
+ `;
255
+ //# sourceMappingURL=fields-layout.js.map
@@ -1,28 +1,37 @@
1
- import{Button as t}from"@redocly/theme/components/Button/Button";import{styled as r}from"../../../styled-components.js";const o=r.span`
1
+ import { Button } from '@redocly/theme/components/Button/Button';
2
+ import { styled } from '../../../styled-components.js';
3
+ export const FieldLabel = styled.span `
2
4
  vertical-align: middle;
3
5
  line-height: var(--schema-labels-line-height);
4
6
  font-size: var(--schema-property-labels-font-size);
5
7
  color: var(--schema-labels--text-color);
6
- `,i=r(o)`
8
+ `;
9
+ export const TypePrefix = styled(FieldLabel) `
7
10
  color: var(--schema-type-text-color);
8
- `,d=r(o)`
11
+ `;
12
+ export const TypeName = styled(FieldLabel) `
9
13
  color: var(--schema-type-text-color);
10
- `,m=r(o)`
14
+ `;
15
+ export const TypeTitle = styled(FieldLabel) `
11
16
  color: var(--schema-type-title-text-color);
12
17
  word-break: break-word;
13
- `,c=r(o).attrs({as:"div"})`
18
+ `;
19
+ export const PropertyLabel = styled(FieldLabel).attrs({ as: 'div' }) `
14
20
  color: var(--text-color-secondary);
15
21
  font-size: var(--schema-labels-font-size);
16
22
  line-height: var(--schema-labels-line-height);
17
23
  font-weight: normal;
18
24
  display: block;
19
- `,p=r(o)`
25
+ `;
26
+ export const RequiredLabel = styled(FieldLabel) `
20
27
  color: var(--schema-property-required-label-text-color);
21
28
  font-size: var(--font-size-base);
22
29
  line-height: var(--line-height-base);
23
- `,b=r(c)`
30
+ `;
31
+ export const AdditionalPropertiesLabel = styled(PropertyLabel) `
24
32
  color: var(--schema-property-additional-label-text-color);
25
- `,e=r.span.attrs(()=>({className:"tag-grey"}))`
33
+ `;
34
+ export const Tag = styled.span.attrs(() => ({ className: 'tag-grey' })) `
26
35
  background: var(--tag-bg-color);
27
36
  padding: 0 var(--spacing-xxs);
28
37
  font-family: var(--font-family-monospaced);
@@ -32,30 +41,36 @@ import{Button as t}from"@redocly/theme/components/Button/Button";import{styled a
32
41
  color: var(--text-color-secondary);
33
42
  display: inline-flex;
34
43
  word-break: var(--code-word-break);
35
- `,v=r(e)`
44
+ `;
45
+ export const AccessLabel = styled(Tag) `
36
46
  color: var(--schema-property-access-label-text-color);
37
47
  background-color: var(--bg-color);
38
48
  border: 1px solid var(--border-color-secondary);
39
- `,a=r(e)`
49
+ `;
50
+ export const FieldValueLabel = styled(Tag) `
40
51
  background-color: var(--schema-inline-bg-color);
41
52
  border-radius: var(--border-radius);
42
53
  border: var(--schema-inline-border);
43
54
  padding: 0 var(--spacing-unit);
44
55
  width: fit-content;
45
- `,h=r(e)`
56
+ `;
57
+ export const RecursiveLabel = styled(Tag) `
46
58
  background-color: var(--schema-recursive-bg-color);
47
59
  border-color: var(--schema-recursive-border-color);
48
60
  color: var(--schema-recursive-text-color);
49
61
  padding: 0 var(--spacing-xs);
50
- `,g=r(a)`
62
+ `;
63
+ export const EnumValue = styled(FieldValueLabel) `
51
64
  background-color: var(--schema-enum-bg-color);
52
65
  border-color: var(--schema-enum-border-color);
53
66
  color: var(--schema-enum-text-color);
54
- `,x=r(e)`
67
+ `;
68
+ export const DefaultValue = styled(Tag) `
55
69
  background-color: var(--schema-default-bg-color);
56
70
  border-color: var(--schema-default-border-color);
57
71
  color: var(--schema-default-text-color);
58
- `,l=r(e)`
72
+ `;
73
+ export const ExampleValue = styled(Tag) `
59
74
  background-color: var(--schema-example-bg-color);
60
75
  border-color: var(--schema-example-border-color);
61
76
  color: var(--schema-example-text-color);
@@ -75,7 +90,9 @@ import{Button as t}from"@redocly/theme/components/Button/Button";import{styled a
75
90
  font-family: var(--schema-inline-code-font-family);
76
91
  margin: 0;
77
92
  }
78
- `,f=r(l)``,u=r(a)`
93
+ `;
94
+ export const ExtensionValue = styled(ExampleValue) ``;
95
+ export const ConstraintItem = styled(FieldValueLabel) `
79
96
  background-color: var(--schema-constraint-bg-color);
80
97
  border-color: var(--schema-constraint-border-color);
81
98
  color: var(--schema-constraint-text-color);
@@ -85,8 +102,13 @@ import{Button as t}from"@redocly/theme/components/Button/Button";import{styled a
85
102
  & + & {
86
103
  margin-left: 0;
87
104
  }
88
- `,y=r(t).attrs(()=>({variant:"link",size:"small"}))`
105
+ `;
106
+ export const ToggleButton = styled(Button).attrs(() => ({
107
+ variant: 'link',
108
+ size: 'small',
109
+ })) `
89
110
  padding: 0;
90
111
  font-size: var(--font-size-sm);
91
112
  line-height: var(--line-height-sm);
92
- `;export{v as AccessLabel,b as AdditionalPropertiesLabel,u as ConstraintItem,x as DefaultValue,g as EnumValue,l as ExampleValue,f as ExtensionValue,o as FieldLabel,a as FieldValueLabel,c as PropertyLabel,h as RecursiveLabel,p as RequiredLabel,e as Tag,y as ToggleButton,d as TypeName,i as TypePrefix,m as TypeTitle};
113
+ `;
114
+ //# sourceMappingURL=fields.js.map
@@ -1 +1,3 @@
1
- export*from"./fields.js";export*from"./fields-layout.js";
1
+ export * from './fields.js';
2
+ export * from './fields-layout.js';
3
+ //# sourceMappingURL=index.js.map
@@ -1,19 +1,46 @@
1
- import{jsx as c}from"react/jsx-runtime";import{css as p}from"styled-components";import{useLocation as l}from"react-router-dom";import{LinkIcon as r}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{encodeBackSlashes as m}from"../../utils/string.js";import{constructFieldDeepFragment as d,joinWithSeparator as n}from"../../services/history/helpers.js";import{ShareLink as f}from"./linkify.js";import{styled as h}from"../../styled-components.js";function F(i,s){const o=i.deps.operation,e=d(i,s);if(!o?.id&&!o.isCallback)return"#"+e.toLowerCase();const t=n(o.href,n(o.id,e),"#");return m(t.toLowerCase())}const S=({to:i,className:s})=>{const o=i,e=l(),t=o?.split("#")[1],a=e?e.hash===`#${t}`:!1;return c(k,{ariaLabel:`link to ${o}`,className:s,isActive:a,to:o,id:t})},k=h(f)`
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { css } from 'styled-components';
3
+ import { useLocation } from 'react-router-dom';
4
+ import { LinkIcon } from '@redocly/theme/icons/LinkIcon/LinkIcon';
5
+ import { encodeBackSlashes } from '../../utils/string.js';
6
+ import { constructFieldDeepFragment, joinWithSeparator } from '../../services/history/helpers.js';
7
+ import { ShareLink } from './linkify.js';
8
+ import { styled } from '../../styled-components.js';
9
+ export function generateDeepLink(field, activeMimeName) {
10
+ const operation = field.deps.operation;
11
+ const fieldFragment = constructFieldDeepFragment(field, activeMimeName);
12
+ //Models doesnt have operation.id
13
+ if (!operation?.id && !operation.isCallback) {
14
+ return '#' + fieldFragment.toLowerCase();
15
+ }
16
+ const deepLink = joinWithSeparator(operation.href, joinWithSeparator(operation.id, fieldFragment), '#');
17
+ return encodeBackSlashes(deepLink.toLowerCase());
18
+ }
19
+ export const LinkToField = ({ to, className, }) => {
20
+ const deepLink = to;
21
+ const location = useLocation();
22
+ const hash = deepLink?.split('#')[1];
23
+ const isActive = location ? location.hash === `#${hash}` : false;
24
+ return (_jsx(ShareLinkToField, { ariaLabel: `link to ${deepLink}`, className: className, isActive: isActive, to: deepLink, id: hash }));
25
+ };
26
+ export const ShareLinkToField = styled(ShareLink) `
2
27
  display: flex;
3
- ${r} {
28
+ ${LinkIcon} {
4
29
  visibility: hidden;
5
30
  cursor: pointer;
6
31
  background-color: var(--bg-color);
7
32
  }
8
33
 
9
- ${({isActive:i})=>i&&p`
10
- ${r} {
34
+ ${({ isActive }) => isActive &&
35
+ css `
36
+ ${LinkIcon} {
11
37
  visibility: visible;
12
38
  opacity: 1;
13
39
  }
14
40
  `}
15
- :hover ${r}, :focus ${r} {
41
+ :hover ${LinkIcon}, :focus ${LinkIcon} {
16
42
  visibility: visible;
17
43
  opacity: 1;
18
44
  }
19
- `;export{S as LinkToField,k as ShareLinkToField,F as generateDeepLink};
45
+ `;
46
+ //# sourceMappingURL=LinkToField.js.map
@@ -1,4 +1,7 @@
1
- import{LinkIcon as t}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{H2 as e}from"@redocly/theme/components/Typography/H2";import{styled as i}from"../../styled-components.js";const n=i.h4`
1
+ import { LinkIcon } from '@redocly/theme/icons/LinkIcon/LinkIcon';
2
+ import { H2 } from '@redocly/theme/components/Typography/H2';
3
+ import { styled } from '../../styled-components.js';
4
+ export const Title = styled.h4 `
2
5
  font-size: var(--h4-font-size);
3
6
  font-weight: var(--h4-font-weight);
4
7
  line-height: var(--h4-line-height);
@@ -11,12 +14,13 @@ import{LinkIcon as t}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{H2 as e
11
14
  position: relative;
12
15
 
13
16
  :hover {
14
- ${t} {
17
+ ${LinkIcon} {
15
18
  opacity: 1;
16
19
  visibility: visible;
17
20
  }
18
21
  }
19
- `,l=i(e)`
22
+ `;
23
+ export const Heading = styled(H2) `
20
24
  position: relative;
21
25
  display: flex;
22
26
  align-items: center;
@@ -25,13 +29,15 @@ import{LinkIcon as t}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{H2 as e
25
29
  margin: 0;
26
30
 
27
31
  :hover {
28
- ${t} {
32
+ ${LinkIcon} {
29
33
  opacity: 1;
30
34
  visibility: visible;
31
35
  }
32
36
  }
33
- `,s=i.div`
37
+ `;
38
+ export const HeadingWrapper = styled.div `
34
39
  display: flex;
35
40
  align-items: flex-start;
36
41
  margin: var(--h2-margin-top) 0 var(--h2-margin-bottom);
37
- `;export{l as Heading,s as HeadingWrapper,n as Title};
42
+ `;
43
+ //# sourceMappingURL=OperationItemTitle.js.map
@@ -1 +1,51 @@
1
- import{jsx as m}from"react/jsx-runtime";import{useCallback as E,useEffect as I,useRef as T,useState as g}from"react";import{useAtom as h}from"jotai";import{Segmented as w}from"@redocly/theme/components/Segmented/Segmented";import{isUndefined as x}from"@redocly/theme/core/openapi";import{Dropdown as y}from"../Dropdown/index.js";import{operationStore as A}from"../../../jotai/operation.js";const b=5;function z({options:t,onChange:r,pointer:u,schema:n,defaultOneOfIdx:d}){const[p,c]=h(A(u)),S=p.activeOneOf[n.pointer]??d,o=t[S]?.value,[i,O]=g(!1),s=T(null);I(()=>{if(!s.current)return;const e=()=>{const v=s.current?.querySelectorAll('button[role="tab"]'),a=Array.from(v||[]).some(l=>l.offsetWidth<l.scrollWidth);a!==i&&O(a)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[i,t]);const f=E(({value:e})=>{e!==void 0&&(r?r(e):c({activeExampleName:n.oneOf?.[e]?.title,activeOneOf:{[n.pointer]:e},requestValues:{body:null}}))},[r,n.oneOf,n.pointer,c]);return x(o)?null:t.length>b||i?m(y,{options:t,value:o,onChange:f}):m(w,{ref:s,value:o,onChange:f,options:t,size:"small","data-testid":"segmented-schema"})}const D=z;export{D as SchemaSelection};
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useRef, useState } from 'react';
3
+ import { useAtom } from 'jotai';
4
+ import { Segmented } from '@redocly/theme/components/Segmented/Segmented';
5
+ import { isUndefined } from '@redocly/theme/core/openapi';
6
+ import { Dropdown } from '../Dropdown/index.js';
7
+ import { operationStore } from '../../../jotai/operation.js';
8
+ const LIMIT_FOR_SEGMENTED = 5;
9
+ function SchemaSelectionComponent({ options, onChange, pointer, schema, defaultOneOfIdx, }) {
10
+ const [store, setOperationStore] = useAtom(operationStore(pointer));
11
+ const activeOneOfIdx = store.activeOneOf[schema.pointer] ?? defaultOneOfIdx;
12
+ const activeValue = options[activeOneOfIdx]?.value;
13
+ const [isAnyItemTruncated, setIsAnyItemTruncated] = useState(false);
14
+ const segmentedRef = useRef(null);
15
+ useEffect(() => {
16
+ if (!segmentedRef.current)
17
+ return;
18
+ const checkTruncation = () => {
19
+ const items = segmentedRef.current?.querySelectorAll('button[role="tab"]');
20
+ const isTruncated = Array.from(items || []).some((item) => {
21
+ return item.offsetWidth < item.scrollWidth;
22
+ });
23
+ if (isTruncated !== isAnyItemTruncated) {
24
+ setIsAnyItemTruncated(isTruncated);
25
+ }
26
+ };
27
+ checkTruncation();
28
+ window.addEventListener('resize', checkTruncation);
29
+ return () => window.removeEventListener('resize', checkTruncation);
30
+ }, [isAnyItemTruncated, options]);
31
+ const handleSelectedChange = useCallback(({ value }) => {
32
+ if (value !== undefined) {
33
+ if (onChange) {
34
+ onChange(value);
35
+ }
36
+ else {
37
+ setOperationStore({
38
+ activeExampleName: schema.oneOf?.[value]?.title,
39
+ activeOneOf: { [schema.pointer]: value },
40
+ requestValues: { body: null },
41
+ });
42
+ }
43
+ }
44
+ }, [onChange, schema.oneOf, schema.pointer, setOperationStore]);
45
+ if (isUndefined(activeValue)) {
46
+ return null;
47
+ }
48
+ return options.length > LIMIT_FOR_SEGMENTED || isAnyItemTruncated ? (_jsx(Dropdown, { options: options, value: activeValue, onChange: handleSelectedChange })) : (_jsx(Segmented, { ref: segmentedRef, value: activeValue, onChange: handleSelectedChange, options: options, size: "small", "data-testid": "segmented-schema" }));
49
+ }
50
+ export const SchemaSelection = SchemaSelectionComponent;
51
+ //# sourceMappingURL=SchemaSelection.js.map
@@ -1 +1,2 @@
1
- import{SchemaSelection as c}from"./SchemaSelection.js";export{c as SchemaSelection};
1
+ export { SchemaSelection } from './SchemaSelection.js';
2
+ //# sourceMappingURL=index.js.map
@@ -1 +1,21 @@
1
- import{jsx as e,jsxs as i}from"react/jsx-runtime";import{memo as b,useMemo as g}from"react";import{ClearButton as j}from"../ClearButton/index.js";import{normalizeText as m}from"../../../utils/index.js";import{Arrow as v}from"./styled.js";function z({options:o,onChange:c,handleClear:p,clearable:u,placeholder:n,value:a="",className:x}){const f=t=>{const{selectedIndex:s}=t.target,l=n||!a?s-1:s;c(o[l])},h=g(()=>o.map(({idx:t,value:s,title:l},C)=>{const d=m(s);return e("option",{value:d,className:"dropdown-option",children:l||d},t||d+C)}),[o]),r=m(a),w=o.find(t=>t.value===a)?.title||r;return i("div",{className:x+" dropdown-wrapper",children:[e(v,{}),u&&r?.length>0&&e(j,{handleClear:p}),i("select",{onChange:f,value:r,className:"dropdown-select","aria-label":"dropdown select",children:[n&&e("option",{disabled:!0,hidden:!0,value:n,children:n}),!r&&!n&&e("option",{disabled:!0}),h]}),e("label",{children:w})]})}const B=b(z);export{B as Select};
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { memo, useMemo } from 'react';
3
+ import { ClearButton } from '../ClearButton/index.js';
4
+ import { normalizeText } from '../../../utils/index.js';
5
+ import { Arrow } from './styled.js';
6
+ function SelectComponent({ options, onChange, handleClear, clearable, placeholder, value = '', className, }) {
7
+ const handleChange = (event) => {
8
+ const { selectedIndex } = event.target;
9
+ const index = placeholder || !value ? selectedIndex - 1 : selectedIndex;
10
+ onChange(options[index]);
11
+ };
12
+ const renderOptions = useMemo(() => options.map(({ idx, value, title }, index) => {
13
+ const normalizedValue = normalizeText(value);
14
+ return (_jsx("option", { value: normalizedValue, className: "dropdown-option", children: title || normalizedValue }, idx || normalizedValue + index));
15
+ }), [options]);
16
+ const normalizedValue = normalizeText(value);
17
+ const title = options.find((option) => option.value === value)?.title || normalizedValue;
18
+ return (_jsxs("div", { className: className + ' dropdown-wrapper', children: [_jsx(Arrow, {}), clearable && normalizedValue?.length > 0 && _jsx(ClearButton, { handleClear: handleClear }), _jsxs("select", { onChange: handleChange, value: normalizedValue, className: "dropdown-select", "aria-label": "dropdown select", children: [placeholder && (_jsx("option", { disabled: true, hidden: true, value: placeholder, children: placeholder })), !normalizedValue && !placeholder && _jsx("option", { disabled: true }), renderOptions] }), _jsx("label", { children: title })] }));
19
+ }
20
+ export const Select = memo(SelectComponent);
21
+ //# sourceMappingURL=Select.js.map
@@ -1 +1,3 @@
1
- export*from"./styled.js";export*from"./types.js";
1
+ export * from './styled.js';
2
+ export * from './types.js';
3
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,8 @@
1
- import{css as n}from"styled-components";import{ChevronDownIcon as t}from"@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon";import{Select as i}from"./Select.js";import{styled as e}from"../../../styled-components.js";const r=n`
1
+ import { css } from 'styled-components';
2
+ import { ChevronDownIcon } from '@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon';
3
+ import { Select as SelectComponent } from './Select.js';
4
+ import { styled } from '../../../styled-components.js';
5
+ const darkSelectStyle = css `
2
6
  background-color: var(--panel-samples-dropdown-bg-color);
3
7
  border: var(--panel-samples-dropdown-border);
4
8
  color: var(--panel-samples-dropdown-color);
@@ -8,13 +12,14 @@ import{css as n}from"styled-components";import{ChevronDownIcon as t}from"@redocl
8
12
  &:focus-within {
9
13
  box-shadow: none;
10
14
  }
11
- `,a=e(i)`
15
+ `;
16
+ export const Select = styled(SelectComponent) `
12
17
  box-sizing: border-box;
13
18
  outline: none;
14
19
  display: inline-block;
15
20
  vertical-align: bottom;
16
21
  position: relative;
17
- width: ${({fullWidth:o})=>o?"100%":"auto"};
22
+ width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
18
23
  cursor: pointer;
19
24
  text-transform: none;
20
25
 
@@ -28,7 +33,7 @@ import{css as n}from"styled-components";import{ChevronDownIcon as t}from"@redocl
28
33
  border-radius: var(--border-radius-md);
29
34
  padding: var(--docs-dropdown-padding);
30
35
  vertical-align: bottom;
31
- width: ${({fullWidth:o})=>o?"100%":"auto"};
36
+ width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
32
37
  text-transform: none;
33
38
  line-height: inherit;
34
39
  font-size: var(--docs-dropdown-font-size);
@@ -43,7 +48,7 @@ import{css as n}from"styled-components";import{ChevronDownIcon as t}from"@redocl
43
48
  box-shadow: none;
44
49
  }
45
50
 
46
- ${({variant:o})=>o==="dark"?r:""};
51
+ ${({ variant }) => (variant === 'dark' ? darkSelectStyle : '')};
47
52
  }
48
53
 
49
54
  .dropdown-select {
@@ -62,9 +67,10 @@ import{css as n}from"styled-components";import{ChevronDownIcon as t}from"@redocl
62
67
  font-size: var(--font-size-base);
63
68
  font-family: inherit;
64
69
  padding: var(--docs-dropdown-padding);
65
- ${({variant:o})=>o==="dark"?r:""};
70
+ ${({ variant }) => (variant === 'dark' ? darkSelectStyle : '')};
66
71
  }
67
- `,c=e(a)`
72
+ `;
73
+ export const SimpleSelect = styled(Select) `
68
74
  svg {
69
75
  top: 60%;
70
76
  transform: translateY(-60%);
@@ -82,8 +88,10 @@ import{css as n}from"styled-components";import{ChevronDownIcon as t}from"@redocl
82
88
  box-shadow: none;
83
89
  }
84
90
  }
85
- `,h=e(t)`
91
+ `;
92
+ export const Arrow = styled(ChevronDownIcon) `
86
93
  position: absolute;
87
94
  right: 10px;
88
95
  top: 10px;
89
- `;export{h as Arrow,a as Select,c as SimpleSelect};
96
+ `;
97
+ //# sourceMappingURL=styled.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map