@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.
- package/dist/redocly-openapi-docs.min.js +753 -750
- package/lib/components/ApiInfo/ApiInfo.js +29 -1
- package/lib/components/ApiInfo/Metadata.js +29 -1
- package/lib/components/ApiInfo/index.js +2 -1
- package/lib/components/ApiInfo/styled.js +16 -8
- package/lib/components/CallbackSamples/CallbackSamples.js +25 -4
- package/lib/components/CallbackSamples/index.js +2 -1
- package/lib/components/Callbacks/CallbackDetails.js +17 -3
- package/lib/components/Callbacks/CallbackOperation.js +24 -3
- package/lib/components/Callbacks/CallbackSummary.js +19 -3
- package/lib/components/Callbacks/CallbacksList.js +16 -1
- package/lib/components/Callbacks/index.js +4 -1
- package/lib/components/Callbacks/styled.js +6 -3
- package/lib/components/Content/Content.js +10 -1
- package/lib/components/Content/index.js +2 -1
- package/lib/components/Content/useAutoScroll.js +50 -1
- package/lib/components/ContentItem/ContentItem.js +31 -1
- package/lib/components/ContentItem/index.js +2 -1
- package/lib/components/ContentItem/useIsExpanded.js +33 -1
- package/lib/components/ContentItems/ContentItems.js +19 -1
- package/lib/components/ContentItems/Items.js +13 -1
- package/lib/components/ContentItems/VirtualList.js +35 -1
- package/lib/components/ContentItems/helpers.js +49 -1
- package/lib/components/ContentItems/index.js +2 -1
- package/lib/components/ContentItems/useScrollOnRender.js +26 -1
- package/lib/components/Discriminator/Discriminator.js +27 -2
- package/lib/components/Discriminator/index.js +2 -1
- package/lib/components/Download/DownloadSpecification.js +46 -4
- package/lib/components/Download/index.js +2 -1
- package/lib/components/Download/types.js +2 -0
- package/lib/components/Download/useDownloadInfo.js +42 -1
- package/lib/components/ErrorBoundary/ErrorBoundary.js +22 -2
- package/lib/components/ErrorBoundary/index.js +2 -1
- package/lib/components/ExpandAllButton/ExpandAllButton.js +31 -2
- package/lib/components/ExpandAllButton/index.js +2 -1
- package/lib/components/ExternalDocumentation/ExternalDocumentation.js +18 -4
- package/lib/components/ExternalDocumentation/index.js +2 -1
- package/lib/components/Language/LanguageDropdown.js +21 -1
- package/lib/components/Language/LanguageItem.js +33 -1
- package/lib/components/Language/LanguageList.js +93 -1
- package/lib/components/Language/_tests_/LanguageDropdown.test.js +23 -1
- package/lib/components/Language/constants.js +3 -1
- package/lib/components/Language/index.js +4 -1
- package/lib/components/Language/styled.js +29 -15
- package/lib/components/Markdown/Markdown.js +64 -1
- package/lib/components/Markdown/index.js +3 -1
- package/lib/components/Markdown/types.js +2 -0
- package/lib/components/MediaTypeSwitch/MediaTypesSwitch.js +51 -1
- package/lib/components/MediaTypeSwitch/index.js +2 -1
- package/lib/components/OperationItem/Description.js +9 -1
- package/lib/components/OperationItem/OperationItem.js +70 -5
- package/lib/components/OperationItem/_tests_/OperationItem.test.js +70 -1
- package/lib/components/OperationItem/_tests_/__mocks__/mock-intersection-observer.js +40 -1
- package/lib/components/OperationItem/index.js +2 -1
- package/lib/components/OperationItem/types.js +2 -0
- package/lib/components/Overlay.js +48 -3
- package/lib/components/Overview/Overview.js +20 -1
- package/lib/components/Overview/index.js +2 -1
- package/lib/components/PageFooter/PageFooter.js +19 -1
- package/lib/components/PageFooter/index.js +2 -1
- package/lib/components/Panel/ResponsePanel.js +12 -6
- package/lib/components/Panel/Trigger.js +4 -2
- package/lib/components/Panel/index.js +3 -1
- package/lib/components/PanelItem/PanelItem.js +6 -1
- package/lib/components/PanelItem/index.js +3 -1
- package/lib/components/PanelItem/styled.js +20 -10
- package/lib/components/PayloadSamples/Example.js +6 -1
- package/lib/components/PayloadSamples/ExampleValue.js +30 -1
- package/lib/components/PayloadSamples/MediaTypeSamples.js +36 -2
- package/lib/components/PayloadSamples/PayloadSamples.js +26 -1
- package/lib/components/PayloadSamples/index.js +7 -1
- package/lib/components/PayloadSamples/styled.js +9 -4
- package/lib/components/PayloadSamples/types.js +2 -0
- package/lib/components/PropertyDetails/DescriptionEnums.js +19 -3
- package/lib/components/PropertyDetails/EnumValues.js +37 -1
- package/lib/components/PropertyDetails/Examples.js +26 -1
- package/lib/components/PropertyDetails/Extensions.js +17 -2
- package/lib/components/PropertyDetails/FieldDetail.js +15 -2
- package/lib/components/PropertyDetails/FieldDetails.js +51 -6
- package/lib/components/PropertyDetails/Pattern.js +21 -1
- package/lib/components/PropertyDetails/PlusCircleIcon.js +10 -4
- package/lib/components/PropertyDetails/PropertyDetails.js +22 -5
- package/lib/components/PropertyDetails/SchemaTypeInfo.js +10 -2
- package/lib/components/PropertyDetails/SimpleEnums.js +13 -2
- package/lib/components/PropertyDetails/cycleColorsByLevel.js +18 -1
- package/lib/components/PropertyDetails/index.js +4 -1
- package/lib/components/PropertyDetails/styled.js +15 -7
- package/lib/components/PropertyDetails/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/Providers.js +114 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocs.js +57 -1
- package/lib/components/RedoclyOpenAPIDocs/RedoclyOpenAPIDocsStandalone.js +86 -1
- package/lib/components/RedoclyOpenAPIDocs/index.js +5 -1
- package/lib/components/RedoclyOpenAPIDocs/styled.js +4 -2
- package/lib/components/RedoclyOpenAPIDocs/types.js +2 -0
- package/lib/components/RedoclyOpenAPIDocs/utils.js +33 -1
- package/lib/components/RenderHook/RenderHook.js +17 -1
- package/lib/components/RenderHook/index.js +2 -1
- package/lib/components/Replay/EmbeddedReplay.js +41 -3
- package/lib/components/Replay/Replay.js +99 -1
- package/lib/components/Replay/index.js +3 -1
- package/lib/components/Replay/utils.js +208 -1
- package/lib/components/Request/RequestDetails.js +33 -2
- package/lib/components/Request/types.js +2 -0
- package/lib/components/RequestParameters/Body.js +8 -1
- package/lib/components/RequestParameters/ParametersGroup.js +19 -4
- package/lib/components/RequestParameters/RequestParameters.js +40 -1
- package/lib/components/RequestParameters/index.js +4 -1
- package/lib/components/RequestSamples/CodeSample.js +55 -2
- package/lib/components/RequestSamples/Example.js +37 -1
- package/lib/components/RequestSamples/RequestSamples.js +89 -5
- package/lib/components/RequestSamples/index.js +3 -1
- package/lib/components/RequestSamples/useCodeSamples.js +92 -1
- package/lib/components/ResponseSamples/ResponseSamples.js +47 -1
- package/lib/components/ResponseSamples/Summary.js +9 -1
- package/lib/components/ResponseSamples/index.js +2 -1
- package/lib/components/Responses/OperationResponseList.js +42 -2
- package/lib/components/Responses/ResponseDetails.js +18 -1
- package/lib/components/Responses/ResponseHeaders.js +15 -1
- package/lib/components/Responses/index.js +6 -1
- package/lib/components/Responses/styled.js +14 -6
- package/lib/components/Responses/types.js +2 -0
- package/lib/components/RightPanel/RightPanel.js +21 -1
- package/lib/components/RightPanel/index.js +2 -1
- package/lib/components/Samples/ExampleSwitch.js +33 -1
- package/lib/components/Samples/index.js +3 -1
- package/lib/components/Samples/use-example-key.js +12 -1
- package/lib/components/Schema/ArraySchema.js +45 -1
- package/lib/components/Schema/ObjectSchema.js +29 -1
- package/lib/components/Schema/OneOfSchema.js +47 -3
- package/lib/components/Schema/RecursiveSchema.js +10 -1
- package/lib/components/Schema/Schema.js +63 -2
- package/lib/components/Schema/SubSchema.js +20 -1
- package/lib/components/Schema/helpers.js +16 -1
- package/lib/components/Schema/index.js +5 -1
- package/lib/components/Schema/types.js +2 -0
- package/lib/components/Schema/useOneOfLocationIdx.js +11 -1
- package/lib/components/SchemaDefinition/SchemaDefinition.js +65 -2
- package/lib/components/SchemaDefinition/index.js +2 -1
- package/lib/components/SectionContent/SectionContent.js +49 -6
- package/lib/components/SectionContent/index.js +2 -1
- package/lib/components/SectionItem/SectionItem.js +14 -1
- package/lib/components/SectionItem/index.js +2 -1
- package/lib/components/Security/Divider.js +9 -2
- package/lib/components/Security/OAuthFlow.js +11 -1
- package/lib/components/Security/OAuthScopes.js +59 -9
- package/lib/components/Security/Security.js +15 -1
- package/lib/components/Security/SecurityButton.js +31 -7
- package/lib/components/Security/SecurityFlow.js +28 -4
- package/lib/components/Security/SecurityModal.js +34 -5
- package/lib/components/Security/SecuritySchemeItem.js +15 -4
- package/lib/components/Security/helper.js +16 -1
- package/lib/components/Security/index.js +11 -1
- package/lib/components/Security/styled.js +6 -3
- package/lib/components/SelectOrLabel/SelectOrLabel.js +12 -2
- package/lib/components/SelectOrLabel/index.js +2 -1
- package/lib/components/ServerList/ServerList.js +36 -10
- package/lib/components/ServerList/index.js +2 -1
- package/lib/components/ServerList/types.js +2 -0
- package/lib/components/ServerListDropdown/ServerListDropdown.js +54 -1
- package/lib/components/ServerListDropdown/index.js +2 -1
- package/lib/components/ServerListDropdown/styled.js +15 -6
- package/lib/components/SideMenu/SideMenu.js +13 -2
- package/lib/components/SideMenu/hooks/useMenuItems.js +110 -1
- package/lib/components/SideMenu/index.js +2 -1
- package/lib/components/SideMenu/types.js +2 -0
- package/lib/components/StickySidebar/SidebarActions.js +14 -2
- package/lib/components/StickySidebar/StickyResponsiveSidebar.js +37 -7
- package/lib/components/StickySidebar/index.js +2 -1
- package/lib/components/Tabs/Tabs.js +16 -5
- package/lib/components/Tabs/index.js +3 -1
- package/lib/components/Tabs/useTabsState.js +22 -1
- package/lib/components/TagItem/OperationNavigationItems.js +18 -4
- package/lib/components/TagItem/OperationsNavigation.js +46 -2
- package/lib/components/TagItem/TagItem.js +40 -7
- package/lib/components/TagItem/index.js +2 -1
- package/lib/components/TagItem/styled.js +5 -2
- package/lib/components/TagItem/types.js +2 -0
- package/lib/components/ViewNested/ViewNested.js +42 -9
- package/lib/components/ViewNested/index.js +2 -1
- package/lib/components/common/Badges.js +21 -5
- package/lib/components/common/BodyContent/BodyContent.js +31 -4
- package/lib/components/common/BodyContent/index.js +2 -1
- package/lib/components/common/ClearButton/ClearButton.js +5 -1
- package/lib/components/common/ClearButton/index.js +3 -1
- package/lib/components/common/ClearButton/styled.js +5 -2
- package/lib/components/common/ClearButton/types.js +2 -0
- package/lib/components/common/CodeBlockPanel.js +7 -3
- package/lib/components/common/ConstraintsView.js +14 -2
- package/lib/components/common/Dropdown/Dropdown.js +22 -4
- package/lib/components/common/Dropdown/index.js +2 -1
- package/lib/components/common/ExpandableExample/ExpandableExample.js +24 -3
- package/lib/components/common/ExpandableExample/index.js +2 -1
- package/lib/components/common/Extensions.js +17 -2
- package/lib/components/common/Fields/fields-layout.js +76 -51
- package/lib/components/common/Fields/fields.js +39 -17
- package/lib/components/common/Fields/index.js +3 -1
- package/lib/components/common/LinkToField.js +33 -6
- package/lib/components/common/OperationItemTitle.js +12 -6
- package/lib/components/common/SchemaSelection/SchemaSelection.js +51 -1
- package/lib/components/common/SchemaSelection/index.js +2 -1
- package/lib/components/common/Select/Select.js +21 -1
- package/lib/components/common/Select/index.js +3 -1
- package/lib/components/common/Select/styled.js +17 -9
- package/lib/components/common/Select/types.js +2 -0
- package/lib/components/common/Skeleton/LanguageListSkeleton.js +16 -6
- package/lib/components/common/Skeleton/Skeleton.js +15 -5
- package/lib/components/common/Skeleton/index.js +3 -1
- package/lib/components/common/headers.js +4 -2
- package/lib/components/common/index.js +14 -1
- package/lib/components/common/linkify.js +28 -4
- package/lib/components/common/mixins.js +4 -2
- package/lib/components/common/panels.js +52 -29
- package/lib/components/common/schema.js +16 -8
- package/lib/components/common/styled.js +15 -7
- package/lib/components/index.js +25 -1
- package/lib/components/pluggable/RedocExample.js +20 -1
- package/lib/components/pluggable/RedocSchema.js +22 -1
- package/lib/components/pluggable/index.js +3 -1
- package/lib/components/pluggable/styled.components.js +9 -4
- package/lib/constants.js +30 -1
- package/lib/empty.js +7 -1
- package/lib/events/codeSampleCopy.js +19 -1
- package/lib/events/creator.js +5 -1
- package/lib/events/index.js +8 -1
- package/lib/events/languageSwitch.js +18 -1
- package/lib/events/panelToggle.js +16 -1
- package/lib/events/serverSwitch.js +13 -1
- package/lib/events/tryItOpen.js +12 -1
- package/lib/events/tryItSent.js +12 -1
- package/lib/events/types.js +11 -1
- package/lib/hoc/types.js +2 -0
- package/lib/hoc/utils.js +4 -1
- package/lib/hoc/withRouter.js +17 -1
- package/lib/hoc/withStore.js +28 -1
- package/lib/hooks/index.js +9 -1
- package/lib/hooks/useActivateExample.js +35 -1
- package/lib/hooks/useActiveWithFallback.js +12 -1
- package/lib/hooks/useContentItems.js +10 -1
- package/lib/hooks/useLicense.js +17 -1
- package/lib/hooks/usePerformanceMetrics.js +26 -1
- package/lib/hooks/useRouter.js +17 -1
- package/lib/hooks/useTelemetry.js +5 -1
- package/lib/hooks/useTranslate.js +6 -1
- package/lib/hooks/useUppercase2LowercaseRedirect.js +12 -1
- package/lib/icons/CSharpIcon/CSharpIcon.js +7 -1
- package/lib/icons/CSharpIcon/index.js +2 -1
- package/lib/icons/CurlIcon/CurlIcon.js +8 -2
- package/lib/icons/CurlIcon/index.js +2 -1
- package/lib/icons/GOIcon/GOIcon.js +7 -1
- package/lib/icons/GOIcon/index.js +2 -1
- package/lib/icons/JavaIcon/JavaIcon.js +7 -1
- package/lib/icons/JavaIcon/index.js +2 -1
- package/lib/icons/JavaScriptIcon/JavaScriptIcon.js +7 -1
- package/lib/icons/JavaScriptIcon/index.js +2 -1
- package/lib/icons/NodeJSIcon/NodeJSIcon.js +7 -1
- package/lib/icons/NodeJSIcon/index.js +2 -1
- package/lib/icons/PHPIcon/PHPIcon.js +7 -1
- package/lib/icons/PHPIcon/index.js +2 -1
- package/lib/icons/PayloadIcon/PayloadIcon.js +7 -1
- package/lib/icons/PayloadIcon/index.js +2 -1
- package/lib/icons/PythonIcon/PythonIcon.js +7 -1
- package/lib/icons/PythonIcon/index.js +2 -1
- package/lib/icons/RIcon/RIcon.js +7 -1
- package/lib/icons/RIcon/index.js +2 -1
- package/lib/icons/RubyIcon/RubyIcon.js +7 -1
- package/lib/icons/RubyIcon/index.js +2 -1
- package/lib/index.js +49 -1
- package/lib/jotai/app.js +113 -1
- package/lib/jotai/operation.js +28 -1
- package/lib/jotai/replay.js +5 -1
- package/lib/jotai/store.js +8 -1
- package/lib/jotai/use-write-atom.js +9 -1
- package/lib/models/callback.js +28 -1
- package/lib/models/code-sample-options.js +2 -0
- package/lib/models/example.js +17 -1
- package/lib/models/field.js +109 -1
- package/lib/models/group.js +38 -1
- package/lib/models/index.js +14 -1
- package/lib/models/mediaContent.js +26 -1
- package/lib/models/mediaType.js +153 -1
- package/lib/models/operation.js +166 -1
- package/lib/models/request.js +25 -1
- package/lib/models/response.js +46 -1
- package/lib/models/schema.js +474 -2
- package/lib/models/security.js +84 -1
- package/lib/models/tab.js +2 -0
- package/lib/models/types.js +2 -0
- package/lib/services/OpenAPIParser.js +321 -1
- package/lib/services/check.js +104 -1
- package/lib/services/code-samples/constants.js +16 -1
- package/lib/services/code-samples/generator.js +540 -1
- package/lib/services/code-samples/httpsnippet/helpers/code-builder.js +252 -3
- package/lib/services/code-samples/httpsnippet/helpers/code-helpers.js +90 -2
- package/lib/services/code-samples/httpsnippet/helpers/constants.js +28 -1
- package/lib/services/code-samples/httpsnippet/helpers/lodash-int.js +173 -1
- package/lib/services/code-samples/httpsnippet/helpers/mocks/code-helpers-mock.js +76 -37
- package/lib/services/code-samples/httpsnippet/helpers/reducer.js +16 -1
- package/lib/services/code-samples/httpsnippet/helpers/shell.js +20 -1
- package/lib/services/code-samples/httpsnippet/helpers/string-utility.js +19 -1
- package/lib/services/code-samples/httpsnippet/index.js +166 -1
- package/lib/services/code-samples/httpsnippet/targets/__mocks__/mock.js +2340 -146
- package/lib/services/code-samples/httpsnippet/targets/csharp/httpclient.js +227 -2
- package/lib/services/code-samples/httpsnippet/targets/csharp/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/httpclient.js +185 -2
- package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/go/native.js +222 -3
- package/lib/services/code-samples/httpsnippet/targets/index.js +28 -1
- package/lib/services/code-samples/httpsnippet/targets/java/httpclient.js +184 -3
- package/lib/services/code-samples/httpsnippet/targets/java/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/java8/apachehttp.js +223 -2
- package/lib/services/code-samples/httpsnippet/targets/java8/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/fetch.js +147 -1
- package/lib/services/code-samples/httpsnippet/targets/javascript/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/node/fetch.js +199 -1
- package/lib/services/code-samples/httpsnippet/targets/node/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/curl.js +203 -5
- package/lib/services/code-samples/httpsnippet/targets/php/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/php/types.js +2 -0
- package/lib/services/code-samples/httpsnippet/targets/php/utils.js +106 -5
- package/lib/services/code-samples/httpsnippet/targets/python/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/python/requests.js +185 -6
- package/lib/services/code-samples/httpsnippet/targets/r/httr.js +111 -1
- package/lib/services/code-samples/httpsnippet/targets/r/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/r/utils.js +18 -6
- package/lib/services/code-samples/httpsnippet/targets/ruby/index.js +11 -1
- package/lib/services/code-samples/httpsnippet/targets/ruby/native.js +169 -1
- package/lib/services/code-samples/httpsnippet/targets/shell/curl.js +94 -6
- package/lib/services/code-samples/httpsnippet/targets/shell/index.js +11 -1
- package/lib/services/code-samples/index.js +3 -1
- package/lib/services/code-samples/types.js +2 -0
- package/lib/services/config-options/helpers.js +49 -1
- package/lib/services/config-options/index.js +3 -1
- package/lib/services/config-options/normalizeOptions.js +83 -1
- package/lib/services/config-options/types.js +2 -0
- package/lib/services/history/helpers.js +63 -1
- package/lib/services/history/index.js +2 -1
- package/lib/services/index.js +9 -1
- package/lib/services/menu/builder.js +47 -1
- package/lib/services/menu/index.js +2 -1
- package/lib/services/menu/markdown.js +93 -1
- package/lib/services/menu/operation.js +50 -1
- package/lib/services/menu/tags.js +166 -1
- package/lib/services/types.js +2 -0
- package/lib/services/utils.js +83 -1
- package/lib/standalone.js +68 -1
- package/lib/styled-components.js +6 -1
- package/lib/types/app.js +2 -0
- package/lib/types/index.js +4 -1
- package/lib/types/open-api.js +2 -0
- package/lib/types/security.js +2 -0
- package/lib/utils/JsonPointer.js +84 -1
- package/lib/utils/areArraysEqual.js +4 -1
- package/lib/utils/argValuesHelpers.js +35 -1
- package/lib/utils/compose.js +2 -1
- package/lib/utils/configure-helpers.js +223 -1
- package/lib/utils/convertSwagger2OpenAPI.js +14 -1
- package/lib/utils/cookies.js +73 -1
- package/lib/utils/debounce.js +22 -1
- package/lib/utils/debug.js +11 -1
- package/lib/utils/dom.js +65 -1
- package/lib/utils/environments.js +13 -1
- package/lib/utils/helpers.js +222 -12
- package/lib/utils/index.js +25 -1
- package/lib/utils/isMobile.js +13 -1
- package/lib/utils/loadAndBundleSpec.js +32 -1
- package/lib/utils/local-storage.js +12 -1
- package/lib/utils/object.js +31 -1
- package/lib/utils/openapi.js +592 -1
- package/lib/utils/parameters.js +13 -1
- package/lib/utils/path.js +22 -1
- package/lib/utils/queryString.js +60 -1
- package/lib/utils/replaceVariables.js +14 -1
- package/lib/utils/saveTextBeforeHeading.js +35 -1
- package/lib/utils/security-details.js +49 -1
- package/lib/utils/session-storage.js +12 -1
- package/lib/utils/simplifyAstStructure.js +22 -1
- package/lib/utils/sort.js +21 -1
- package/lib/utils/string.js +65 -1
- package/lib/utils/telemetry.js +7 -1
- package/lib/utils/test-utils.js +26 -1
- package/lib/utils/theme-helpers.js +24 -3
- package/lib/utils/url.js +38 -1
- package/package.json +4 -4
|
@@ -1 +1,29 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useAtomValue } from 'jotai';
|
|
3
|
+
import { LayoutVariant } from '@redocly/config';
|
|
4
|
+
import { AfterOpenApiTitle } from '@redocly/theme/components/OpenApiDocs/hooks/AfterOpenApiTitle';
|
|
5
|
+
import { PageActions } from '@redocly/theme/components/PageActions/PageActions';
|
|
6
|
+
import { SamplesMiddlePanel, Row } from '../common/index.js';
|
|
7
|
+
import { ExternalDocumentation } from '../ExternalDocumentation/index.js';
|
|
8
|
+
import { Markdown } from '../Markdown/index.js';
|
|
9
|
+
import { ApiHeader } from './styled.js';
|
|
10
|
+
import { globalStoreAtom } from '../../jotai/store.js';
|
|
11
|
+
import { saveTextBeforeHeading } from '../../utils/saveTextBeforeHeading.js';
|
|
12
|
+
import { getValueFromMdParsedExtension } from '../../utils/helpers.js';
|
|
13
|
+
import { RenderHook } from '../RenderHook/index.js';
|
|
14
|
+
import { Metadata } from './Metadata.js';
|
|
15
|
+
import { useTranslate } from '../../hooks/index.js';
|
|
16
|
+
export function ApiInfo({ item, layout, }) {
|
|
17
|
+
const translate = useTranslate();
|
|
18
|
+
const { options: { unstable_hooks, hideInfoMetadata, routingBasePath }, parser: { definition }, } = useAtomValue(globalStoreAtom);
|
|
19
|
+
const info = item.infoDefinition;
|
|
20
|
+
if (!info) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const description = saveTextBeforeHeading(getValueFromMdParsedExtension(info, 'description') || '');
|
|
24
|
+
const summary = getValueFromMdParsedExtension(info, 'summary') || undefined;
|
|
25
|
+
const externalDocs = definition?.externalDocs || info?.externalDocs;
|
|
26
|
+
const isStacked = layout === LayoutVariant.STACKED;
|
|
27
|
+
return (_jsx(Row, { layout: layout, children: _jsxs(SamplesMiddlePanel, { fullWidth: true, className: "api-info", isStacked: isStacked, children: [_jsxs(ApiHeader, { children: [(info.title || '') + (info.version ? ` (${info.version})` : ''), _jsx(PageActions, { pageSlug: routingBasePath })] }), _jsx(RenderHook, { Hook: AfterOpenApiTitle || unstable_hooks?.AfterApiTitle, props: { info } }), summary && _jsx(Markdown, { source: summary, "data-role": "redoc-summary" }), description && _jsx(Markdown, { source: description, "data-role": "redoc-description" }), externalDocs && _jsx(ExternalDocumentation, { externalDocs: externalDocs }), !hideInfoMetadata && _jsx(Metadata, { metadata: info['x-metadata'], translate: translate })] }) }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ApiInfo.js.map
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { Markdown as MarkdownWrapper } from '@redocly/theme/components/Markdown/Markdown';
|
|
4
|
+
import { H3 } from '@redocly/theme/components/Typography/H3';
|
|
5
|
+
import { isNotNull } from '@redocly/theme/core/openapi';
|
|
6
|
+
const FILTER_OUT_KEYS = ['title', 'description']; // We don't want to show these keys
|
|
7
|
+
function metadataMap([key, value]) {
|
|
8
|
+
if (FILTER_OUT_KEYS.includes(key)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
return { key, value: value.filter((val) => typeof val !== 'object').join(', ') };
|
|
13
|
+
}
|
|
14
|
+
// We don't want to show objects
|
|
15
|
+
if (typeof value === 'object') {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return { key, value };
|
|
19
|
+
}
|
|
20
|
+
export function Metadata({ metadata, translate }) {
|
|
21
|
+
const filteredMetadata = useMemo(() => Object.entries(metadata || {})
|
|
22
|
+
.map(metadataMap)
|
|
23
|
+
.filter(isNotNull), [metadata]);
|
|
24
|
+
if (!metadata) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return (_jsxs(MarkdownWrapper, { children: [_jsx(H3, { children: translate('openapi.info.metadata.title', 'Metadata') }), _jsxs("table", { className: "md", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: translate('openapi.key', 'Key') }), _jsx("th", { scope: "col", children: translate('openapi.value', 'Value') })] }) }), _jsx("tbody", { children: filteredMetadata.map(({ key, value }) => (_jsxs("tr", { children: [_jsx("td", { children: key }), _jsx("td", { children: `${value}` })] }, key))) })] })] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=Metadata.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { ApiInfo } from './ApiInfo.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,27 +1,35 @@
|
|
|
1
|
-
import{H1
|
|
1
|
+
import { H1 } from '@redocly/theme/components/Typography/H1';
|
|
2
|
+
import { Markdown } from '@redocly/theme/components/Markdown/Markdown';
|
|
3
|
+
import { styled } from '../../styled-components.js';
|
|
4
|
+
const delimiterWidth = 15;
|
|
5
|
+
export const ApiHeader = styled(H1) `
|
|
2
6
|
display: flex;
|
|
3
7
|
margin-top: 0;
|
|
4
8
|
margin-bottom: 0;
|
|
5
|
-
& + ${
|
|
9
|
+
& + ${Markdown} {
|
|
6
10
|
margin-top: var(--h1-margin-bottom);
|
|
7
11
|
}
|
|
8
|
-
|
|
12
|
+
`;
|
|
13
|
+
export const InfoSpan = styled.span `
|
|
9
14
|
&::before {
|
|
10
15
|
content: '|';
|
|
11
16
|
display: inline-block;
|
|
12
17
|
opacity: 0.5;
|
|
13
|
-
width: ${
|
|
18
|
+
width: ${delimiterWidth}px;
|
|
14
19
|
text-align: center;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
&:last-child::after {
|
|
18
23
|
display: none;
|
|
19
24
|
}
|
|
20
|
-
|
|
25
|
+
`;
|
|
26
|
+
export const InfoSpanBoxWrap = styled.div `
|
|
21
27
|
overflow: hidden;
|
|
22
|
-
|
|
28
|
+
`;
|
|
29
|
+
export const InfoSpanBox = styled.div `
|
|
23
30
|
display: flex;
|
|
24
31
|
flex-wrap: wrap;
|
|
25
32
|
// hide separator on new lines: idea from https://stackoverflow.com/a/31732902/1749888
|
|
26
|
-
margin-left: -${
|
|
27
|
-
`;
|
|
33
|
+
margin-left: -${delimiterWidth}px;
|
|
34
|
+
`;
|
|
35
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { PanelHeader } from '@redocly/theme/components/Panel/PanelHeader';
|
|
4
|
+
import { PayloadSamples } from '../PayloadSamples/index.js';
|
|
5
|
+
import { ServerListDropdown } from '../ServerListDropdown/index.js';
|
|
6
|
+
import { CodeBlockPanel } from '../common/index.js';
|
|
7
|
+
import { styled } from '../../styled-components.js';
|
|
8
|
+
function CallbackSamplesComponent({ callback, translate, }) {
|
|
9
|
+
const hasSamples = callback?.hasSamples;
|
|
10
|
+
if (!hasSamples) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const renderSummary = () => {
|
|
14
|
+
return (_jsxs(StyledPanelHeader, { isExpandable: false, children: [_jsx(StyledServerListDropdown, { operation: callback }), _jsx(PayloadTitle, { children: translate('openapi.payload', 'Payload') })] }));
|
|
15
|
+
};
|
|
16
|
+
return (_jsx(CodeBlockPanel, { className: "panel-callback-samples", header: renderSummary, isExpandable: false, children: callback?.payload?.requestBodyContent && (_jsx(PayloadSamples, { content: callback.payload.requestBodyContent })) }));
|
|
17
|
+
}
|
|
18
|
+
export const CallbackSamples = memo(CallbackSamplesComponent);
|
|
19
|
+
const PayloadTitle = styled.div `
|
|
2
20
|
font-size: var(--font-size-sm);
|
|
3
21
|
font-style: normal;
|
|
4
22
|
font-weight: var(--font-weight-regular);
|
|
@@ -7,9 +25,12 @@ import{jsx as r,jsxs as n}from"react/jsx-runtime";import{memo as t}from"react";i
|
|
|
7
25
|
border-radius: var(--border-radius);
|
|
8
26
|
background: var(--dropdown-bg-color);
|
|
9
27
|
color: var(--dropdown-text-color);
|
|
10
|
-
|
|
28
|
+
`;
|
|
29
|
+
const StyledPanelHeader = styled(PanelHeader) `
|
|
11
30
|
flex-wrap: nowrap;
|
|
12
|
-
|
|
31
|
+
`;
|
|
32
|
+
const StyledServerListDropdown = styled(ServerListDropdown) `
|
|
13
33
|
padding-right: var(--spacing-base);
|
|
14
34
|
min-width: 0;
|
|
15
|
-
`;
|
|
35
|
+
`;
|
|
36
|
+
//# sourceMappingURL=CallbackSamples.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { CallbackSamples } from './CallbackSamples.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,17 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback } from 'react';
|
|
3
|
+
import { LinkIcon } from '@redocly/theme/icons/LinkIcon/LinkIcon';
|
|
4
|
+
import { OperationResponseList } from '../Responses/index.js';
|
|
5
|
+
import { RequestDetails } from '../Request/RequestDetails.js';
|
|
6
|
+
import { LinkToField } from '../common/LinkToField.js';
|
|
7
|
+
import { makeDeepLink } from '../../services/index.js';
|
|
8
|
+
import { styled } from '../../styled-components.js';
|
|
9
|
+
function CallbackDetailsComponent({ operation, translate }) {
|
|
10
|
+
const renderResponseTitle = useCallback((tab) => (_jsxs(Title, { children: [_jsx(LinkToField, { to: makeDeepLink(operation.id, `${operation.callbackId}/callback-response&c=${tab.key}`) }), translate('openapi.callbackResponse', 'Callback Response')] })), [operation.callbackId, operation.id, translate]);
|
|
11
|
+
return (_jsxs(_Fragment, { children: [_jsx(RequestDetails, { operation: operation, title: _jsxs(_Fragment, { children: [_jsx(LinkToField, { to: makeDeepLink(operation.id, `${operation.callbackId}/callback-request`) }), translate('openapi.callbackRequest', 'Callback Request')] }) }), operation.responses?.length ? (_jsx(OperationResponseList, { responses: operation.responses, operationId: operation.id, operationPointer: operation.pointer, callbackId: operation.callbackId, renderTitle: renderResponseTitle })) : null] }));
|
|
12
|
+
}
|
|
13
|
+
export const CallbackDetails = memo(CallbackDetailsComponent);
|
|
14
|
+
const Title = styled.h4 `
|
|
2
15
|
position: relative;
|
|
3
16
|
font-size: var(--font-size-lg);
|
|
4
17
|
font-weight: var(--h4-font-weight);
|
|
@@ -11,9 +24,10 @@ import{jsx as l,jsxs as s,Fragment as t}from"react/jsx-runtime";import{memo as r
|
|
|
11
24
|
margin: 0 var(--spacing-sm) 0 0;
|
|
12
25
|
|
|
13
26
|
:hover {
|
|
14
|
-
${
|
|
27
|
+
${LinkIcon} {
|
|
15
28
|
opacity: 1;
|
|
16
29
|
visibility: visible;
|
|
17
30
|
}
|
|
18
31
|
}
|
|
19
|
-
`;
|
|
32
|
+
`;
|
|
33
|
+
//# sourceMappingURL=CallbackDetails.js.map
|
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { useTranslate } from '../../hooks/index.js';
|
|
4
|
+
import { CallbackPanel } from '../Panel/index.js';
|
|
5
|
+
import { CallbackDetails } from './CallbackDetails.js';
|
|
6
|
+
import { CallbackSummary } from './CallbackSummary.js';
|
|
7
|
+
import { pathIncludesLink } from '../../utils/index.js';
|
|
8
|
+
import { styled } from '../../styled-components.js';
|
|
9
|
+
export const CallbackOperation = ({ operation, operation: { callbackId }, onExpand, selectedCallback, }) => {
|
|
10
|
+
const translate = useTranslate();
|
|
11
|
+
const location = useLocation();
|
|
12
|
+
const renderSummary = ({ expanded, toggle }) => {
|
|
13
|
+
return (_jsx(CallbackSummary, { callback: operation, toggle: (params) => {
|
|
14
|
+
toggle?.(params);
|
|
15
|
+
onExpand?.(expanded ? null : operation);
|
|
16
|
+
}, expanded: expanded, translate: translate }));
|
|
17
|
+
};
|
|
18
|
+
return (_jsx(CallbackPanel, { header: renderSummary, expanded: selectedCallback?.callbackId === callbackId || pathIncludesLink(location, callbackId), className: "panel-response-callback", children: _jsxs(CallbackDetailsWrap, { children: [_jsx(CallbackDetails, { operation: operation, translate: translate }), _jsx(LeftBorder, {})] }) }));
|
|
19
|
+
};
|
|
20
|
+
const CallbackDetailsWrap = styled.div `
|
|
2
21
|
position: relative;
|
|
3
22
|
.property:last-child {
|
|
4
23
|
border-bottom: none;
|
|
5
24
|
padding-bottom: 0;
|
|
6
25
|
}
|
|
7
|
-
|
|
26
|
+
`;
|
|
27
|
+
const LeftBorder = styled.div `
|
|
8
28
|
position: absolute;
|
|
9
29
|
height: calc(100% + 14px);
|
|
10
30
|
border-left: 1px solid var(--border-color-primary);
|
|
11
31
|
top: -14px;
|
|
12
32
|
left: -12px;
|
|
13
33
|
z-index: 0;
|
|
14
|
-
`;
|
|
34
|
+
`;
|
|
35
|
+
//# sourceMappingURL=CallbackOperation.js.map
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { PanelHeader } from '@redocly/theme/components/Panel/PanelHeader';
|
|
3
|
+
import { Badge } from '@redocly/theme/components/Badge/Badge';
|
|
4
|
+
import { Trigger } from '../Panel/index.js';
|
|
5
|
+
import { HttpVerb } from '../common/index.js';
|
|
6
|
+
import { makeDeepLink } from '../../services/index.js';
|
|
7
|
+
import { shortenHTTPVerb } from '../../utils/index.js';
|
|
8
|
+
import { CallbackTitle } from './styled.js';
|
|
9
|
+
import { CircleIcon } from '../PropertyDetails/PlusCircleIcon.js';
|
|
10
|
+
import { LinkToField } from '../common/LinkToField.js';
|
|
11
|
+
import { styled } from '../../styled-components.js';
|
|
12
|
+
export function CallbackSummary({ expanded = false, toggle, callback: { name, httpVerb, deprecated, callbackId, id }, translate, }) {
|
|
13
|
+
return (_jsxs(CallbackHeader, { expanded: expanded, onClick: toggle, children: [_jsx(LinkToField, { to: makeDeepLink(id, `callbacks/${callbackId}`) }), _jsxs(Trigger, { children: [_jsx(CircleIconWrap, { children: _jsx(CircleIcon, { sign: expanded ? '-' : '+' }) }), _jsx(CallbackTitle, { deprecated: deprecated, children: name }), _jsx(HttpVerb, { color: httpVerb, children: shortenHTTPVerb(httpVerb) }), deprecated ? (_jsx(Badge, { deprecated: true, children: translate('openapi.badges.deprecated', 'Deprecated') })) : null] })] }));
|
|
14
|
+
}
|
|
15
|
+
const CallbackHeader = styled(PanelHeader) `
|
|
2
16
|
padding: var(--spacing-sm) 0 var(--spacing-sm) calc(var(--spacing-unit) / 2);
|
|
3
17
|
margin: 0;
|
|
4
18
|
line-height: var(--line-height-base);
|
|
5
19
|
position: relative;
|
|
6
|
-
|
|
20
|
+
`;
|
|
21
|
+
const CircleIconWrap = styled.button `
|
|
7
22
|
background: none;
|
|
8
23
|
border: none;
|
|
9
24
|
cursor: pointer;
|
|
@@ -15,4 +30,5 @@ import{jsx as r,jsxs as o}from"react/jsx-runtime";import{PanelHeader as p}from"@
|
|
|
15
30
|
font-size: var(--font-size-base);
|
|
16
31
|
font-family: var(--font-family-base);
|
|
17
32
|
line-height: var(--line-height-base);
|
|
18
|
-
`;
|
|
33
|
+
`;
|
|
34
|
+
//# sourceMappingURL=CallbackSummary.js.map
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { CallbackOperation } from './CallbackOperation.js';
|
|
4
|
+
function CallbacksListComponent({ callbacks, selectedCallback, onExpand, }) {
|
|
5
|
+
if (!callbacks || callbacks.length === 0) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const handleSelectCallback = (callbackId) => {
|
|
9
|
+
onExpand(callbackId);
|
|
10
|
+
};
|
|
11
|
+
return (_jsx("div", { children: callbacks.map((callback) => callback.operations.map((operation) => {
|
|
12
|
+
return (_jsx(CallbackOperation, { operation: operation, selectedCallback: selectedCallback, onExpand: handleSelectCallback }, operation.name));
|
|
13
|
+
})) }));
|
|
14
|
+
}
|
|
15
|
+
export const CallbacksList = memo(CallbacksListComponent);
|
|
16
|
+
//# sourceMappingURL=CallbacksList.js.map
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import{PanelHeaderTitle
|
|
2
|
-
|
|
1
|
+
import { PanelHeaderTitle } from '@redocly/theme/components/Panel/PanelHeaderTitle';
|
|
2
|
+
import { styled } from '../../styled-components.js';
|
|
3
|
+
export const CallbackTitle = styled(PanelHeaderTitle) `
|
|
4
|
+
text-decoration: ${({ deprecated }) => (deprecated ? 'line-through' : 'none')};
|
|
3
5
|
margin: 0 4px;
|
|
4
6
|
vertical-align: middle;
|
|
5
7
|
color: var(--panel-response-callback-heading-text-color);
|
|
6
8
|
font-weight: var(--font-weight-medium);
|
|
7
|
-
`;
|
|
9
|
+
`;
|
|
10
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { useAutoScroll } from './useAutoScroll.js';
|
|
4
|
+
import { ContentItems } from '../ContentItems/index.js';
|
|
5
|
+
function ContentComponent({ routingBasePath, items }) {
|
|
6
|
+
useAutoScroll(routingBasePath);
|
|
7
|
+
return _jsx(ContentItems, { root: true, items: items, routingBasePath: routingBasePath });
|
|
8
|
+
}
|
|
9
|
+
export const Content = memo(ContentComponent);
|
|
10
|
+
//# sourceMappingURL=Content.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { Content } from './Content.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
import{useLocation
|
|
1
|
+
import { useLocation } from 'react-router-dom';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { addLeadingSlash, removeLeadingSlash, useActiveSectionId, IS_BROWSER, } from '@redocly/theme/core/openapi';
|
|
4
|
+
import { compose, encodeBackSlashes, tryDecodeURIComponent } from '../../utils/index.js';
|
|
5
|
+
let initialPageLoad = true;
|
|
6
|
+
export function useAutoScroll(routingBasePath) {
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
const basePath = routingBasePath || '/';
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (location.pathname === basePath && location.hash === '') {
|
|
11
|
+
window.scrollTo(0, 0);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const pathname = removeLeadingSlash(location.pathname.replace(basePath, ''));
|
|
15
|
+
const legacyHash = getLegacyHash(location.hash);
|
|
16
|
+
const element = legacyHash
|
|
17
|
+
? getElementById(pathname + legacyHash) ||
|
|
18
|
+
document.querySelector(`[id$="${removeLeadingSlash(legacyHash)}"]`) // handle scroll to operation by legacy hash route
|
|
19
|
+
: getElementById(location.hash.replace('#', '')) || getElementById(pathname);
|
|
20
|
+
if (element) {
|
|
21
|
+
element.scrollIntoView();
|
|
22
|
+
}
|
|
23
|
+
}, [location, basePath]);
|
|
24
|
+
const activeSectionId = useActiveSectionId(location, false, false);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (activeSectionId && initialPageLoad) {
|
|
27
|
+
initialPageLoad = false;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (IS_BROWSER &&
|
|
31
|
+
!window.location.pathname.includes(activeSectionId) &&
|
|
32
|
+
!window.location.hash.includes(activeSectionId)) {
|
|
33
|
+
const url = compose(addLeadingSlash, encodeBackSlashes)(activeSectionId);
|
|
34
|
+
window.history.replaceState({}, '', url);
|
|
35
|
+
}
|
|
36
|
+
}, [activeSectionId]);
|
|
37
|
+
}
|
|
38
|
+
export function getElementById(id) {
|
|
39
|
+
return document.getElementById(tryDecodeURIComponent(id));
|
|
40
|
+
}
|
|
41
|
+
export function getLegacyHash(hash) {
|
|
42
|
+
const patterns = ['#tag', '#operation', '#paths'];
|
|
43
|
+
for (const pattern of patterns) {
|
|
44
|
+
if (hash.includes(pattern)) {
|
|
45
|
+
return hash.replace(pattern, '').toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=useAutoScroll.js.map
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { useAtomValue } from 'jotai';
|
|
4
|
+
import { joinWithSeparator } from '../../services/index.js';
|
|
5
|
+
import { TagItem } from '../TagItem/index.js';
|
|
6
|
+
import { OperationItem } from '../OperationItem/index.js';
|
|
7
|
+
import { Section } from '../common/index.js';
|
|
8
|
+
import { useIsExpanded } from './useIsExpanded.js';
|
|
9
|
+
import { SectionItem } from '../SectionItem/index.js';
|
|
10
|
+
import useScrollOnRender from '../ContentItems/useScrollOnRender.js';
|
|
11
|
+
import { isRootItem } from '../ContentItems/helpers.js';
|
|
12
|
+
import { ApiInfo } from '../ApiInfo/index.js';
|
|
13
|
+
import { layoutAtom } from '../../jotai/app.js';
|
|
14
|
+
const ContentComponentMap = {
|
|
15
|
+
group: null,
|
|
16
|
+
tag: TagItem,
|
|
17
|
+
section: SectionItem,
|
|
18
|
+
schema: TagItem,
|
|
19
|
+
operation: OperationItem,
|
|
20
|
+
root: ApiInfo,
|
|
21
|
+
};
|
|
22
|
+
function ContentItemComponent({ item, routingBasePath, children, layout: contentLayout, }) {
|
|
23
|
+
const ContentComponent = ContentComponentMap[isRootItem(item) ? 'root' : item.type];
|
|
24
|
+
const expandable = item.type === 'tag' && item.items.length > 0;
|
|
25
|
+
const isExpanded = useIsExpanded({ item, routingBasePath });
|
|
26
|
+
let ref = useScrollOnRender(item, routingBasePath);
|
|
27
|
+
const layout = useAtomValue(layoutAtom);
|
|
28
|
+
return (_jsxs(_Fragment, { children: [ContentComponent && (_jsx(Section, { id: item.id, ref: ref, sectionId: joinWithSeparator(routingBasePath, item.id), underlined: item.type === 'operation' || item.type === 'schema', expanded: expandable && !isExpanded, children: _jsx(ContentComponent, { item: item, routingBasePath: routingBasePath, isExpanded: isExpanded, layout: contentLayout || layout }) })), (isExpanded || item.type !== 'tag') && Boolean(item.items?.length) && _jsx(_Fragment, { children: children })] }));
|
|
29
|
+
}
|
|
30
|
+
export const ContentItem = memo(ContentItemComponent);
|
|
31
|
+
//# sourceMappingURL=ContentItem.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { ContentItem } from './ContentItem.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { removeLeadingSlash } from '@redocly/theme/core/openapi';
|
|
4
|
+
import { tryDecodeURIComponent, normalizePath } from '../../utils/index.js';
|
|
5
|
+
import { getLegacyHash } from '../Content/useAutoScroll.js';
|
|
6
|
+
export function useIsExpanded({ item, routingBasePath, }) {
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
const decodedPathname = useMemo(() => tryDecodeURIComponent(normalizePath(location.pathname.replace(routingBasePath, ''))), [location.pathname, routingBasePath]);
|
|
9
|
+
const flatItems = useMemo(() => {
|
|
10
|
+
const flat = [];
|
|
11
|
+
const traverse = (items) => {
|
|
12
|
+
items.forEach((item) => {
|
|
13
|
+
flat.push(item);
|
|
14
|
+
if (item.items?.length) {
|
|
15
|
+
traverse(item.items);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
traverse([item]);
|
|
20
|
+
return flat;
|
|
21
|
+
}, [item]);
|
|
22
|
+
if (item.type !== 'tag') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const itemHrefs = flatItems.map((item) => item.href);
|
|
26
|
+
return itemHrefs.some((href) => {
|
|
27
|
+
const legacyHash = getLegacyHash(location.hash);
|
|
28
|
+
return ([href, tryDecodeURIComponent(href)].includes(decodedPathname) ||
|
|
29
|
+
// handle expand tag by legacy hash route
|
|
30
|
+
(legacyHash && (href.endsWith(legacyHash) || href === removeLeadingSlash(legacyHash))));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=useIsExpanded.js.map
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useMemo } from 'react';
|
|
3
|
+
import { Navigate, Route, Routes } from 'react-router-dom';
|
|
4
|
+
import { getFirstPageLink, getItemsByType } from './helpers.js';
|
|
5
|
+
import { SectionContent } from '../SectionContent/index.js';
|
|
6
|
+
function ContentItemsComponent({ items, root = false }) {
|
|
7
|
+
const defaultRootLink = '/';
|
|
8
|
+
const { rootItem } = getItemsByType(items);
|
|
9
|
+
const firstPageLink = !root || rootItem ? defaultRootLink : getFirstPageLink(items, defaultRootLink);
|
|
10
|
+
const renderRoutes = useMemo(() => (_jsxs(Routes, { children: [rootItem && (_jsx(Route, { path: `${rootItem.href || defaultRootLink}*`, element: _jsx(SectionContent, { items: items }) })), _jsx(Route, { path: "*", element: _jsx(Navigate, { to: firstPageLink, replace: true }) })] })), [rootItem, defaultRootLink, items, firstPageLink]);
|
|
11
|
+
if (root && !items.length) {
|
|
12
|
+
return (_jsx(Routes, { children: _jsx(Route, { path: "*", element: _jsx(SectionContent, { items: items }) }) }));
|
|
13
|
+
}
|
|
14
|
+
if (!items.length)
|
|
15
|
+
return null;
|
|
16
|
+
return _jsx(_Fragment, { children: renderRoutes });
|
|
17
|
+
}
|
|
18
|
+
export const ContentItems = memo(ContentItemsComponent);
|
|
19
|
+
//# sourceMappingURL=ContentItems.js.map
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useCallback } from 'react';
|
|
3
|
+
import { ContentItem } from '../ContentItem/index.js';
|
|
4
|
+
import { VirtualList } from './VirtualList.js';
|
|
5
|
+
function ItemsComponent({ items, routingBasePath }) {
|
|
6
|
+
const renderItem = useCallback((item) => (_jsx(ContentItem, { item: item, routingBasePath: routingBasePath, children: item.items.length > 0 && (_jsx(VirtualList, { items: item.items, renderItem: renderItem, routingBasePath: routingBasePath })) }, item.id)), [routingBasePath]);
|
|
7
|
+
if (!items.length)
|
|
8
|
+
return null;
|
|
9
|
+
const shouldUseVirtualList = items.length > 15 && items.every((item) => item.type === 'operation' || item.type === 'schema');
|
|
10
|
+
return (_jsx(_Fragment, { children: shouldUseVirtualList ? (_jsx(VirtualList, { items: items, renderItem: renderItem, routingBasePath: routingBasePath })) : (_jsx(_Fragment, { children: items.map(renderItem) })) }));
|
|
11
|
+
}
|
|
12
|
+
export const Items = memo(ItemsComponent);
|
|
13
|
+
//# sourceMappingURL=Items.js.map
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
import{Fragment as
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, memo, useEffect, useState, useMemo } from 'react';
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
import { removeLeadingSlash } from '@redocly/theme/core/openapi';
|
|
5
|
+
const INITIAL_VISIBLE_ITEMS = 3;
|
|
6
|
+
const BUFFER_ITEMS = 1;
|
|
7
|
+
const FULL_LIST_DELAY = 1000;
|
|
8
|
+
const VirtualListComponent = ({ items = [], renderItem, routingBasePath, }) => {
|
|
9
|
+
const basePath = routingBasePath || '/';
|
|
10
|
+
const location = useLocation();
|
|
11
|
+
const pathname = removeLeadingSlash(location.pathname.replace(basePath, ''));
|
|
12
|
+
const findActiveItemIndex = useMemo(() => {
|
|
13
|
+
const itemMap = new Map(items.map((item, index) => [removeLeadingSlash(item.href), index]));
|
|
14
|
+
return (pathname) => (pathname ? itemMap.get(pathname) : undefined);
|
|
15
|
+
}, [items]);
|
|
16
|
+
const getVisibleRange = useCallback((pathname) => {
|
|
17
|
+
const currentIndex = findActiveItemIndex(pathname);
|
|
18
|
+
const start = Math.max(0, currentIndex ? currentIndex - BUFFER_ITEMS : 0);
|
|
19
|
+
const end = Math.min(items.length, currentIndex ? currentIndex + BUFFER_ITEMS + 1 : INITIAL_VISIBLE_ITEMS);
|
|
20
|
+
return { start, end };
|
|
21
|
+
}, [findActiveItemIndex, items.length]);
|
|
22
|
+
const [visibleItems, setVisibleItems] = useState(() => {
|
|
23
|
+
const { start, end } = getVisibleRange(pathname);
|
|
24
|
+
return items.slice(start, end);
|
|
25
|
+
});
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const timeoutId = setTimeout(() => {
|
|
28
|
+
setVisibleItems(items);
|
|
29
|
+
}, FULL_LIST_DELAY);
|
|
30
|
+
return () => clearTimeout(timeoutId);
|
|
31
|
+
}, [items]);
|
|
32
|
+
return _jsx(_Fragment, { children: visibleItems.map(renderItem) });
|
|
33
|
+
};
|
|
34
|
+
export const VirtualList = memo(VirtualListComponent);
|
|
35
|
+
//# sourceMappingURL=VirtualList.js.map
|
|
@@ -1 +1,49 @@
|
|
|
1
|
-
import{normalizePath
|
|
1
|
+
import { normalizePath } from '../../utils/index.js';
|
|
2
|
+
export function isRootItem(item) {
|
|
3
|
+
return item.type === 'section' && item.id === '';
|
|
4
|
+
}
|
|
5
|
+
export function getItemsByType(items) {
|
|
6
|
+
const groupItems = [];
|
|
7
|
+
const tagItems = [];
|
|
8
|
+
const operationItems = [];
|
|
9
|
+
let rootItem = undefined;
|
|
10
|
+
for (const item of items) {
|
|
11
|
+
switch (item.type) {
|
|
12
|
+
case 'group':
|
|
13
|
+
groupItems.push(item);
|
|
14
|
+
break;
|
|
15
|
+
case 'tag':
|
|
16
|
+
tagItems.push(item);
|
|
17
|
+
break;
|
|
18
|
+
case 'operation':
|
|
19
|
+
operationItems.push(item);
|
|
20
|
+
break;
|
|
21
|
+
case 'section':
|
|
22
|
+
if (isRootItem(item)) {
|
|
23
|
+
rootItem = item;
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { groupItems, tagItems, operationItems, rootItem };
|
|
29
|
+
}
|
|
30
|
+
export function getFirstPageLink(items, defaultRootLink) {
|
|
31
|
+
for (const item of items) {
|
|
32
|
+
if (item.type === 'group') {
|
|
33
|
+
return getFirstPageLink(item.items, defaultRootLink);
|
|
34
|
+
}
|
|
35
|
+
else if (item.type === 'tag') {
|
|
36
|
+
if (!item.description) {
|
|
37
|
+
return normalizePath(getFirstPageLink(item.items, defaultRootLink));
|
|
38
|
+
}
|
|
39
|
+
if (item.href) {
|
|
40
|
+
return normalizePath(item.href);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else if (item.type === 'operation' || item.type === 'schema') {
|
|
44
|
+
return normalizePath(item.href);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return defaultRootLink;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { ContentItems } from './ContentItems.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|