@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,4 +1,29 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useState, useRef } from 'react';
|
|
3
|
+
import { useOutsideClick, useFocusTrap } from '@redocly/theme/core/openapi';
|
|
4
|
+
import { Button } from '@redocly/theme/components/Button/Button';
|
|
5
|
+
import { SecurityIcon } from '@redocly/theme/icons/SecurityIcon/SecurityIcon';
|
|
6
|
+
import { Segmented } from '@redocly/theme/components/Segmented/Segmented';
|
|
7
|
+
import { CloseIcon } from '@redocly/theme/icons/CloseIcon/CloseIcon';
|
|
8
|
+
import { Typography } from '@redocly/theme/components/Typography/Typography';
|
|
9
|
+
import { SecurityFlow } from './SecurityFlow.js';
|
|
10
|
+
import { Divider } from './Divider.js';
|
|
11
|
+
import { useTranslate } from '../../hooks/index.js';
|
|
12
|
+
import { styled } from '../../styled-components.js';
|
|
13
|
+
export function SecurityModal({ securities, onClose }) {
|
|
14
|
+
const translate = useTranslate();
|
|
15
|
+
const [selectedSecurityScheme, setSelectedSecurityScheme] = useState(0);
|
|
16
|
+
const modalRef = useRef(null);
|
|
17
|
+
const { schemes } = securities[selectedSecurityScheme] || {};
|
|
18
|
+
useOutsideClick(modalRef, onClose);
|
|
19
|
+
useFocusTrap(modalRef);
|
|
20
|
+
const options = securities.map(({ schemes }, index) => ({
|
|
21
|
+
label: schemes.map(({ id }) => id).join(' and '),
|
|
22
|
+
value: index,
|
|
23
|
+
}));
|
|
24
|
+
return (_jsx(StyledBackground, { children: _jsxs(Wrapper, { ref: modalRef, tabIndex: 0, children: [_jsx(Close, { onClick: onClose, "data-testid": "close", variant: "ghost", icon: _jsx(CloseIcon, {}) }), _jsxs(Title, { children: [_jsx(SecurityIcon, { size: "24px" }), translate('openapi.security', 'Security')] }), _jsx(Segmented, { value: selectedSecurityScheme, onChange: ({ value }) => setSelectedSecurityScheme(value), options: options }), schemes.map((scheme, index) => (_jsxs(Fragment, { children: [_jsx(SecurityFlow, { ...scheme, securities: securities }), index !== schemes.length - 1 && _jsx(Divider, { label: "and" })] }, scheme.id)))] }) }));
|
|
25
|
+
}
|
|
26
|
+
const Wrapper = styled.div `
|
|
2
27
|
background: var(--bg-color);
|
|
3
28
|
box-shadow: var(--bg-raised-shadow);
|
|
4
29
|
border-radius: var(--border-radius-lg);
|
|
@@ -19,7 +44,8 @@ import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Fragment as h,useState
|
|
|
19
44
|
font-size: var(--font-size-base);
|
|
20
45
|
line-height: var(--line-height-base);
|
|
21
46
|
}
|
|
22
|
-
|
|
47
|
+
`;
|
|
48
|
+
const StyledBackground = styled.div `
|
|
23
49
|
background: var(--bg-color-modal-overlay);
|
|
24
50
|
position: fixed;
|
|
25
51
|
width: 100vw;
|
|
@@ -28,11 +54,13 @@ import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Fragment as h,useState
|
|
|
28
54
|
left: 0;
|
|
29
55
|
top: 0;
|
|
30
56
|
pointer-events: auto;
|
|
31
|
-
|
|
57
|
+
`;
|
|
58
|
+
const Close = styled(Button) `
|
|
32
59
|
position: absolute;
|
|
33
60
|
right: var(--spacing-md);
|
|
34
61
|
top: var(--spacing-md);
|
|
35
|
-
|
|
62
|
+
`;
|
|
63
|
+
const Title = styled(Typography) `
|
|
36
64
|
display: flex;
|
|
37
65
|
align-items: center;
|
|
38
66
|
font-size: var(--h4-font-size);
|
|
@@ -41,4 +69,5 @@ import{jsx as t,jsxs as n}from"react/jsx-runtime";import{Fragment as h,useState
|
|
|
41
69
|
svg {
|
|
42
70
|
margin-right: var(--spacing-xs);
|
|
43
71
|
}
|
|
44
|
-
`;
|
|
72
|
+
`;
|
|
73
|
+
//# sourceMappingURL=SecurityModal.js.map
|
|
@@ -1,20 +1,31 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { styled } from '../../styled-components.js';
|
|
3
|
+
export function SecuritySchemeItem({ label, value }) {
|
|
4
|
+
if (!label || !value) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return (_jsxs(Row, { children: [_jsx(Label, { children: label }), _jsx(Value, { children: value })] }));
|
|
8
|
+
}
|
|
9
|
+
const Row = styled.div `
|
|
2
10
|
display: flex;
|
|
3
11
|
flex-wrap: wrap;
|
|
4
12
|
justify-content: flex-start;
|
|
5
13
|
margin-bottom: var(--spacing-xs);
|
|
6
14
|
font-size: var(--font-size-sm);
|
|
7
15
|
color: var(--text-color-secondary);
|
|
8
|
-
|
|
16
|
+
`;
|
|
17
|
+
const Label = styled.div `
|
|
9
18
|
display: flex;
|
|
10
19
|
align-items: center;
|
|
11
20
|
justify-content: flex-start;
|
|
12
21
|
font-size: var(--font-size-base);
|
|
13
22
|
line-height: var(--line-height-base);
|
|
14
23
|
flex: 1;
|
|
15
|
-
|
|
24
|
+
`;
|
|
25
|
+
const Value = styled.div `
|
|
16
26
|
flex: 1;
|
|
17
27
|
font-size: var(--font-size-base);
|
|
18
28
|
line-height: var(--line-height-base);
|
|
19
29
|
word-break: break-word;
|
|
20
|
-
`;
|
|
30
|
+
`;
|
|
31
|
+
//# sourceMappingURL=SecuritySchemeItem.js.map
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
function
|
|
1
|
+
export function getRequiredScopes(id, securities) {
|
|
2
|
+
const allScopes = new Set();
|
|
3
|
+
securities.forEach(({ schemes }) => {
|
|
4
|
+
schemes.forEach(({ id: schemeId, scopes }) => {
|
|
5
|
+
if (schemeId === id) {
|
|
6
|
+
scopes.forEach((scope) => allScopes.add(scope));
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
return Array.from(allScopes);
|
|
11
|
+
}
|
|
12
|
+
export function getOptionalScopes(requiredScopes, allScopes) {
|
|
13
|
+
const requiredScopesSet = new Set(requiredScopes);
|
|
14
|
+
return allScopes.filter((scope) => !requiredScopesSet.has(scope));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
export { Security } from './Security.js';
|
|
2
|
+
export { SecurityButton } from './SecurityButton.js';
|
|
3
|
+
export { SecurityFlow } from './SecurityFlow.js';
|
|
4
|
+
export { SecuritySchemeItem } from './SecuritySchemeItem.js';
|
|
5
|
+
export { OAuthFlow } from './OAuthFlow.js';
|
|
6
|
+
export { OAuthScopes } from './OAuthScopes.js';
|
|
7
|
+
export { SecurityModal } from './SecurityModal.js';
|
|
8
|
+
export { Divider } from './Divider.js';
|
|
9
|
+
export * from './helper.js';
|
|
10
|
+
export * from './styled.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import{styled
|
|
1
|
+
import { styled } from '../../styled-components.js';
|
|
2
|
+
export const Tag = styled.div `
|
|
2
3
|
border-radius: var(--border-radius);
|
|
3
4
|
padding: 0 var(--spacing-xxs);
|
|
4
5
|
font-family: var(--font-family-monospaced);
|
|
@@ -6,8 +7,10 @@ import{styled as r}from"../../styled-components.js";const a=r.div`
|
|
|
6
7
|
line-height: var(--line-height-sm);
|
|
7
8
|
color: var(--text-color-primary);
|
|
8
9
|
background-color: var(--tag-bg-color);
|
|
9
|
-
|
|
10
|
+
`;
|
|
11
|
+
export const StyledLink = styled.a `
|
|
10
12
|
color: var(--link-color-primary);
|
|
11
13
|
text-decoration: none;
|
|
12
14
|
word-wrap: break-word;
|
|
13
|
-
`;
|
|
15
|
+
`;
|
|
16
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SimpleSelect } from '../common/Select/index.js';
|
|
3
|
+
import { styled } from '../../styled-components.js';
|
|
4
|
+
const MimeLabel = styled.span `
|
|
2
5
|
margin-left: 4px;
|
|
3
6
|
font-size: 14px;
|
|
4
7
|
text-transform: none;
|
|
5
8
|
font-weight: 400;
|
|
6
9
|
color: var(--text-color-primary);
|
|
7
|
-
`;
|
|
10
|
+
`;
|
|
11
|
+
export function SelectOrLabel({ Label = MimeLabel, Select = SimpleSelect, ...selectProps }) {
|
|
12
|
+
if (selectProps.options.length === 1) {
|
|
13
|
+
return _jsx(Label, { children: selectProps.options[0].value });
|
|
14
|
+
}
|
|
15
|
+
return _jsx(Select, { ...selectProps });
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=SelectOrLabel.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { SelectOrLabel } from './SelectOrLabel.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,21 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CopyButton } from '@redocly/theme/components/Buttons/CopyButton';
|
|
3
|
+
import { PanelItemDescription, Title } from '../PanelItem/index.js';
|
|
4
|
+
import { ViewNested } from '../ViewNested/index.js';
|
|
5
|
+
import { Tag } from '../common/index.js';
|
|
6
|
+
import { Markdown } from '../Markdown/index.js';
|
|
7
|
+
import { styled } from '../../styled-components.js';
|
|
8
|
+
export const ServerList = ({ servers, path, translate }) => (_jsx(ItemsList, { children: servers.map((server) => {
|
|
9
|
+
const url = server.url + path;
|
|
10
|
+
const propertyLength = Object.keys(server.variables || {}).length;
|
|
11
|
+
const keyword = propertyLength === 1 ? 'variable' : 'variables';
|
|
12
|
+
const pluralOrSingular = `${propertyLength || ''} ${translate(`openapi.${keyword}`, keyword)}`;
|
|
13
|
+
{
|
|
14
|
+
/* TODO: highlight server variables, e.g. https://{user}.test.com */
|
|
15
|
+
}
|
|
16
|
+
return (_jsxs("div", { children: [_jsx(PanelItemDescription, { children: server.description }), _jsxs(TitleWrap, { children: [_jsx(Title, { suppressHydrationWarning: true, children: url }), _jsx(CopyButton, { data: url }, url)] }), server.variables && (_jsx(ViewNested, { expandText: `${translate('openapi.actions.show', 'Show')} ${pluralOrSingular}`, hideText: `${translate('openapi.actions.hide', 'Hide')} ${pluralOrSingular}`, expandByDefault: false, expandable: true, hideDivider: true, children: _jsx(ServerVariablesContainer, { children: Object.entries(server.variables || {}).map(([varName, varValue]) => (_jsxs(ServerVariableContainer, { children: [_jsx(ServerVariableName, { children: varName }), _jsxs(Variable, { children: [translate('openapi.default', 'Default'), ' ', _jsx(StyledTag, { children: varValue.default })] }), _jsx(Description, { source: varValue.description }), varValue.enum && (_jsxs(Variable, { children: [translate('openapi.enum', 'Enum'), ' ', _jsx(TagWrapper, { children: varValue.enum.map((el) => (_jsx(StyledTag, { children: el }, el))) })] }))] }, varName))) }) }))] }, server.url));
|
|
17
|
+
}) }));
|
|
18
|
+
const ItemsList = styled.div `
|
|
2
19
|
& > div {
|
|
3
20
|
border-bottom: 1px solid var(--border-color-secondary);
|
|
4
21
|
margin-bottom: var(--spacing-xs);
|
|
@@ -10,7 +27,8 @@ import{jsx as i,jsxs as t}from"react/jsx-runtime";import{CopyButton as v}from"@r
|
|
|
10
27
|
margin-bottom: 0;
|
|
11
28
|
padding-bottom: 0;
|
|
12
29
|
}
|
|
13
|
-
|
|
30
|
+
`;
|
|
31
|
+
const ServerVariablesContainer = styled.div `
|
|
14
32
|
padding-left: var(--spacing-xxs);
|
|
15
33
|
& > div {
|
|
16
34
|
border-bottom: 1px solid var(--border-color-secondary);
|
|
@@ -28,32 +46,40 @@ import{jsx as i,jsxs as t}from"react/jsx-runtime";import{CopyButton as v}from"@r
|
|
|
28
46
|
margin-bottom: 0;
|
|
29
47
|
padding-bottom: 0;
|
|
30
48
|
}
|
|
31
|
-
|
|
49
|
+
`;
|
|
50
|
+
const ServerVariableContainer = styled.div `
|
|
32
51
|
display: flex;
|
|
33
52
|
flex-direction: column;
|
|
34
53
|
flex-wrap: wrap;
|
|
35
|
-
|
|
54
|
+
`;
|
|
55
|
+
const Description = styled(Markdown) `
|
|
36
56
|
font-size: var(--font-size-sm);
|
|
37
57
|
line-height: var(--line-height-sm);
|
|
38
58
|
color: var(--text-color-primary);
|
|
39
|
-
|
|
59
|
+
`;
|
|
60
|
+
const Variable = styled.span `
|
|
40
61
|
display: flex;
|
|
41
62
|
gap: var(--spacing-xxs);
|
|
42
63
|
font-size: var(--font-size-sm);
|
|
43
64
|
line-height: var(--line-height-sm);
|
|
44
65
|
color: var(--text-color-primary);
|
|
45
|
-
|
|
66
|
+
`;
|
|
67
|
+
const ServerVariableName = styled(Variable) `
|
|
46
68
|
padding-bottom: var(--spacing-xxs);
|
|
47
69
|
font-weight: var(--font-weight-semibold);
|
|
48
|
-
|
|
70
|
+
`;
|
|
71
|
+
const TagWrapper = styled.span `
|
|
49
72
|
display: flex;
|
|
50
73
|
gap: var(--spacing-xxs);
|
|
51
74
|
flex-wrap: wrap;
|
|
52
|
-
|
|
75
|
+
`;
|
|
76
|
+
const StyledTag = styled(Tag) `
|
|
53
77
|
font-size: var(--font-size-sm);
|
|
54
78
|
line-height: var(--line-height-sm);
|
|
55
|
-
|
|
79
|
+
`;
|
|
80
|
+
const TitleWrap = styled.div `
|
|
56
81
|
display: flex;
|
|
57
82
|
justify-content: space-between;
|
|
58
83
|
align-items: center;
|
|
59
|
-
`;
|
|
84
|
+
`;
|
|
85
|
+
//# sourceMappingURL=ServerList.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { ServerList } from './ServerList.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useCallback } from 'react';
|
|
3
|
+
import { useAtom, useAtomValue } from 'jotai';
|
|
4
|
+
import { DropdownMenu } from '@redocly/theme/components/Dropdown/DropdownMenu';
|
|
5
|
+
import { Dropdown } from '@redocly/theme/components/Dropdown/Dropdown';
|
|
6
|
+
import { HttpVerb } from '../common/index.js';
|
|
7
|
+
import { PathWrapper, Path, StyledCopyButton, StyledDropdownMenuItem } from './styled.js';
|
|
8
|
+
import { PanelItem } from '../PanelItem/index.js';
|
|
9
|
+
import { joinWithSeparator } from '../../services/index.js';
|
|
10
|
+
import { replaceVariables } from '../../utils/index.js';
|
|
11
|
+
import { environmentAtom } from '../../jotai/app.js';
|
|
12
|
+
import { useActiveWithFallback, useTelemetry } from '../../hooks/index.js';
|
|
13
|
+
import { getServerEnvName } from '../../utils/environments.js';
|
|
14
|
+
import { createTargetServerSwitchEvent } from '../../events/index.js';
|
|
15
|
+
import { globalStoreAtom } from '../../jotai/store.js';
|
|
16
|
+
export const ServerListDropdown = ({ operation, className, }) => {
|
|
17
|
+
const telemetry = useTelemetry();
|
|
18
|
+
const [[environment], setEnvironment] = useAtom(environmentAtom);
|
|
19
|
+
const { options: { events }, } = useAtomValue(globalStoreAtom);
|
|
20
|
+
const activeServerUrl = useActiveWithFallback(operation.servers.map((s) => ({
|
|
21
|
+
...s,
|
|
22
|
+
key: s.url,
|
|
23
|
+
})), environment.server);
|
|
24
|
+
const onCopyClick = useCallback((e) => {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
}, []);
|
|
27
|
+
const handleAction = useCallback((server) => () => {
|
|
28
|
+
if (operation.servers.length === 1) {
|
|
29
|
+
return; // do not override environment if there is only one server
|
|
30
|
+
}
|
|
31
|
+
setEnvironment({ environment: getServerEnvName(server) });
|
|
32
|
+
telemetry.send({
|
|
33
|
+
type: 'openapi_docs.switch_servers.clicked',
|
|
34
|
+
payload: { server: getServerEnvName(server) },
|
|
35
|
+
});
|
|
36
|
+
if (events?.targetServerSwitch && server) {
|
|
37
|
+
const eventPayload = createTargetServerSwitchEvent({
|
|
38
|
+
operation: operation,
|
|
39
|
+
serverUrl: server.url,
|
|
40
|
+
});
|
|
41
|
+
events.targetServerSwitch(eventPayload);
|
|
42
|
+
}
|
|
43
|
+
}, [operation, setEnvironment, telemetry, events]);
|
|
44
|
+
const items = useMemo(() => {
|
|
45
|
+
return operation.servers.map((server) => {
|
|
46
|
+
const url = joinWithSeparator(replaceVariables(server), operation.path);
|
|
47
|
+
return (_jsx(StyledDropdownMenuItem, { onAction: handleAction(server), children: _jsx(PanelItem, { header: server.description, title: url, actions: [
|
|
48
|
+
_jsx(StyledCopyButton, { data: url, toasterPlacement: "left", onCopyClick: onCopyClick }, url),
|
|
49
|
+
], active: server.url === activeServerUrl, withCheckmark: true }) }, url));
|
|
50
|
+
});
|
|
51
|
+
}, [operation.servers, operation.path, handleAction, onCopyClick, activeServerUrl]);
|
|
52
|
+
return (_jsx(Dropdown, { className: className, trigger: _jsxs(PathWrapper, { variant: "ghost", children: [_jsx(HttpVerb, { color: operation.httpVerb, children: operation.httpVerb }), _jsx(Path, { children: operation.path })] }), withArrow: true, children: _jsx(DropdownMenu, { children: items }) }));
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=ServerListDropdown.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { ServerListDropdown } from './ServerListDropdown.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { breakpoints } from '@redocly/theme/core/openapi';
|
|
2
|
+
import { Button } from '@redocly/theme/components/Button/Button';
|
|
3
|
+
import { CopyButton } from '@redocly/theme/components/Buttons/CopyButton';
|
|
4
|
+
import { DropdownMenuItem } from '@redocly/theme/components/Dropdown/DropdownMenuItem';
|
|
5
|
+
import { styled } from '../../styled-components.js';
|
|
6
|
+
export const PathWrapper = styled(Button) `
|
|
2
7
|
display: inline-flex;
|
|
3
8
|
overflow-x: hidden;
|
|
4
9
|
font-weight: var(--font-weight-regular);
|
|
5
|
-
|
|
10
|
+
`;
|
|
11
|
+
export const Path = styled.span `
|
|
6
12
|
overflow-x: hidden;
|
|
7
13
|
text-overflow: ellipsis;
|
|
8
14
|
white-space: nowrap;
|
|
9
15
|
display: inline-block;
|
|
10
16
|
line-height: var(--line-height-base);
|
|
11
17
|
font-size: var(--font-size-base);
|
|
12
|
-
|
|
18
|
+
`;
|
|
19
|
+
export const StyledDropdownMenuItem = styled(DropdownMenuItem) `
|
|
13
20
|
padding: calc(var(--spacing-unit) * 1.5) var(--spacing-xs) calc(var(--spacing-unit) * 1.5)
|
|
14
21
|
var(--spacing-lg);
|
|
15
|
-
@media screen and (max-width: ${
|
|
22
|
+
@media screen and (max-width: ${breakpoints.large}) {
|
|
16
23
|
max-width: 280px;
|
|
17
24
|
}
|
|
18
|
-
|
|
25
|
+
`;
|
|
26
|
+
export const StyledCopyButton = styled(CopyButton) `
|
|
19
27
|
:hover {
|
|
20
28
|
background-color: var(--dropdown-menu-item-bg-color-hover);
|
|
21
29
|
}
|
|
22
|
-
`;
|
|
30
|
+
`;
|
|
31
|
+
//# sourceMappingURL=styled.js.map
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { Menu } from '@redocly/theme/components/Menu/Menu';
|
|
4
|
+
import { useMenuItems } from './hooks/useMenuItems.js';
|
|
5
|
+
import { styled } from '../../styled-components.js';
|
|
6
|
+
const SideMenuComponent = ({ items, className }) => {
|
|
7
|
+
const menuItems = useMenuItems({ items });
|
|
8
|
+
return (_jsx(MenuWrapper, { className: className, children: _jsx(Menu, { items: menuItems }) }));
|
|
9
|
+
};
|
|
10
|
+
export const SideMenu = memo(SideMenuComponent);
|
|
11
|
+
export const MenuWrapper = styled.div `
|
|
2
12
|
overflow: auto;
|
|
3
|
-
`;
|
|
13
|
+
`;
|
|
14
|
+
//# sourceMappingURL=SideMenu.js.map
|
|
@@ -1 +1,110 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { useActiveSectionId } from '@redocly/theme/core/openapi';
|
|
4
|
+
import { pathMatchedLink } from '../../../utils/index.js';
|
|
5
|
+
import { DEFAULT_WEBHOOKS_TAG_NAME } from '../../../constants.js';
|
|
6
|
+
export function useMenuItems({ items }) {
|
|
7
|
+
const location = useLocation();
|
|
8
|
+
const activeItemId = useActiveSectionId(location, false, false);
|
|
9
|
+
return useMemo(() => mapAndSetActiveItems(items, activeItemId, location), [activeItemId, items, location]);
|
|
10
|
+
}
|
|
11
|
+
function mapAndSetActiveItems(items, activeItemId = '', location) {
|
|
12
|
+
const newItems = [];
|
|
13
|
+
convertOpenAPIDocs2Sidebar({
|
|
14
|
+
contentItems: items,
|
|
15
|
+
sidebarItems: newItems,
|
|
16
|
+
activeItemId,
|
|
17
|
+
location,
|
|
18
|
+
});
|
|
19
|
+
return newItems;
|
|
20
|
+
}
|
|
21
|
+
function isItemActive(item, activeItemId = '', location) {
|
|
22
|
+
if (!item.href)
|
|
23
|
+
return false;
|
|
24
|
+
if (activeItemId) {
|
|
25
|
+
return item.id === activeItemId;
|
|
26
|
+
}
|
|
27
|
+
return pathMatchedLink(location, item.href);
|
|
28
|
+
}
|
|
29
|
+
function isSubItemActive(item, activeItemId = '', location) {
|
|
30
|
+
const items = item.items || [];
|
|
31
|
+
return items.some((i) => {
|
|
32
|
+
return isItemActive(i, activeItemId, location) || isSubItemActive(i, activeItemId, location);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function convertOpenAPIDocs2Sidebar(data) {
|
|
36
|
+
const { contentItems, sidebarItems, activeItemId, location } = data;
|
|
37
|
+
let addWebhookSeparator = true;
|
|
38
|
+
for (const item of contentItems) {
|
|
39
|
+
const active = isItemActive(item, activeItemId, location);
|
|
40
|
+
const hasActiveSubItem = isSubItemActive(item, activeItemId, location);
|
|
41
|
+
switch (item.type) {
|
|
42
|
+
case 'group':
|
|
43
|
+
sidebarItems.push({ type: 'separator', label: item.name, active, hasActiveSubItem });
|
|
44
|
+
convertOpenAPIDocs2Sidebar({ ...data, contentItems: item.items, sidebarItems });
|
|
45
|
+
break;
|
|
46
|
+
case 'tag':
|
|
47
|
+
const tagGroup = {
|
|
48
|
+
type: 'group',
|
|
49
|
+
label: item.name,
|
|
50
|
+
items: [],
|
|
51
|
+
link: item.href,
|
|
52
|
+
active,
|
|
53
|
+
hasActiveSubItem,
|
|
54
|
+
modified: true,
|
|
55
|
+
};
|
|
56
|
+
sidebarItems.push(tagGroup);
|
|
57
|
+
convertOpenAPIDocs2Sidebar({
|
|
58
|
+
contentItems: item.items,
|
|
59
|
+
sidebarItems: tagGroup.items || [],
|
|
60
|
+
activeItemId,
|
|
61
|
+
location,
|
|
62
|
+
});
|
|
63
|
+
break;
|
|
64
|
+
case 'operation':
|
|
65
|
+
case 'schema':
|
|
66
|
+
if (item.isWebhook &&
|
|
67
|
+
addWebhookSeparator &&
|
|
68
|
+
item.parent.name !== DEFAULT_WEBHOOKS_TAG_NAME) {
|
|
69
|
+
sidebarItems.push({ type: 'separator', label: 'Webhooks', variant: 'secondary' });
|
|
70
|
+
addWebhookSeparator = false;
|
|
71
|
+
}
|
|
72
|
+
sidebarItems.push({
|
|
73
|
+
type: 'link',
|
|
74
|
+
label: item.name,
|
|
75
|
+
httpVerb: item.type === 'schema' ? 'schema' : item.httpVerb,
|
|
76
|
+
link: item.href,
|
|
77
|
+
badges: item.badges,
|
|
78
|
+
active,
|
|
79
|
+
hasActiveSubItem,
|
|
80
|
+
modified: true,
|
|
81
|
+
deprecated: item.deprecated,
|
|
82
|
+
});
|
|
83
|
+
break;
|
|
84
|
+
case 'section':
|
|
85
|
+
if (item.depth === -1) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const sectionItem = {
|
|
89
|
+
type: item.items.length ? 'group' : 'link',
|
|
90
|
+
label: item.name,
|
|
91
|
+
link: item.href,
|
|
92
|
+
items: [],
|
|
93
|
+
active,
|
|
94
|
+
hasActiveSubItem,
|
|
95
|
+
modified: true,
|
|
96
|
+
};
|
|
97
|
+
sidebarItems.push(sectionItem);
|
|
98
|
+
if (item.items.length) {
|
|
99
|
+
convertOpenAPIDocs2Sidebar({
|
|
100
|
+
contentItems: item.items,
|
|
101
|
+
sidebarItems: sectionItem.items,
|
|
102
|
+
activeItemId,
|
|
103
|
+
location,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=useMenuItems.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { SideMenu } from './SideMenu.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useAtom } from 'jotai';
|
|
3
|
+
import { LayoutVariant } from '@redocly/config';
|
|
4
|
+
import { SidebarActions as ThemeSidebarActions } from '@redocly/theme/components/SidebarActions/SidebarActions';
|
|
5
|
+
import { collapsedSidebarAtom, layoutAtom } from '../../jotai/app.js';
|
|
6
|
+
import { styled } from '../../styled-components.js';
|
|
7
|
+
export const SidebarActions = () => {
|
|
8
|
+
const [layout, setLayout] = useAtom(layoutAtom);
|
|
9
|
+
const [collapsedSidebar, setSidebarCollapsed] = useAtom(collapsedSidebarAtom);
|
|
10
|
+
return (_jsx(_Fragment, { children: _jsx(Wrapper, { children: _jsx(ThemeSidebarActions, { layout: layout, onChangeViewClick: () => setLayout(layout === LayoutVariant.STACKED ? LayoutVariant.THREE_PANEL : LayoutVariant.STACKED), collapsedSidebar: collapsedSidebar, onChangeCollapseSidebarClick: () => setSidebarCollapsed(!collapsedSidebar), isApiDocs: true }) }) }));
|
|
11
|
+
};
|
|
12
|
+
const Wrapper = styled.div `
|
|
2
13
|
position: sticky;
|
|
3
14
|
top: calc(100vh);
|
|
4
15
|
padding: var(--spacing-sm) var(--spacing-md);
|
|
5
|
-
`;
|
|
16
|
+
`;
|
|
17
|
+
//# sourceMappingURL=SidebarActions.js.map
|
|
@@ -1,24 +1,54 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useAtom } from 'jotai';
|
|
4
|
+
import { useLocation } from 'react-router-dom';
|
|
5
|
+
import { useMount, breakpoints } from '@redocly/theme/core/openapi';
|
|
6
|
+
import { isSidebarOpenedAtom } from '../../jotai/app.js';
|
|
7
|
+
import { SidebarActions } from './SidebarActions.js';
|
|
8
|
+
import { styled } from '../../styled-components.js';
|
|
9
|
+
const StyledStickySidebar = styled.div `
|
|
2
10
|
overflow: hidden;
|
|
3
11
|
flex-direction: column;
|
|
4
12
|
backface-visibility: hidden;
|
|
5
|
-
height: ${({offsetTop
|
|
13
|
+
height: ${({ offsetTop }) => `calc(100vh - ${offsetTop})`};
|
|
6
14
|
top: 0;
|
|
7
15
|
flex: 0 0 auto;
|
|
8
16
|
position: fixed;
|
|
9
|
-
display: ${({open
|
|
17
|
+
display: ${({ open }) => (open ? 'flex' : 'none')};
|
|
10
18
|
z-index: 2;
|
|
11
19
|
width: 100%;
|
|
12
20
|
background: var(--sidebar-bg-color);
|
|
13
|
-
border-right: ${({collapsedSidebar
|
|
21
|
+
border-right: ${({ collapsedSidebar }) => collapsedSidebar ? '1px solid var(--sidebar-border-color)' : 'auto'};
|
|
14
22
|
|
|
15
|
-
@media screen and (min-width: ${
|
|
23
|
+
@media screen and (min-width: ${breakpoints.small}) {
|
|
16
24
|
position: sticky;
|
|
17
25
|
z-index: auto;
|
|
18
|
-
width: ${({collapsedSidebar
|
|
26
|
+
width: ${({ collapsedSidebar }) => (collapsedSidebar ? 'var(--sidebar-width)' : 'auto')};
|
|
19
27
|
display: flex;
|
|
20
28
|
}
|
|
21
29
|
@media print {
|
|
22
30
|
display: none;
|
|
23
31
|
}
|
|
24
|
-
`;
|
|
32
|
+
`;
|
|
33
|
+
function StickyResponsiveSidebarComponent({ scrollYOffset, className, children, collapsedSidebar, }) {
|
|
34
|
+
const [offsetTop, setOffsetTop] = useState('0px');
|
|
35
|
+
const stickyElement = useRef(null);
|
|
36
|
+
const location = useLocation();
|
|
37
|
+
const [isSidebarOpened, setIsSidebarOpened] = useAtom(isSidebarOpenedAtom);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (location.hash) {
|
|
40
|
+
setIsSidebarOpened(false);
|
|
41
|
+
}
|
|
42
|
+
}, [location.pathname, location.hash, setIsSidebarOpened]);
|
|
43
|
+
useMount(() => {
|
|
44
|
+
const top = scrollYOffset();
|
|
45
|
+
// rerender when hydrating from SSR
|
|
46
|
+
// see https://github.com/facebook/react/issues/8017#issuecomment-256351955
|
|
47
|
+
setOffsetTop(`${top}px`);
|
|
48
|
+
});
|
|
49
|
+
return (_jsx(_Fragment, { children: _jsxs(StyledStickySidebar, { open: isSidebarOpened, className: className, offsetTop: offsetTop, style: {
|
|
50
|
+
top: offsetTop,
|
|
51
|
+
}, ref: stickyElement, collapsedSidebar: collapsedSidebar, children: [collapsedSidebar || isSidebarOpened ? children : null, _jsx(SidebarActions, {})] }) }));
|
|
52
|
+
}
|
|
53
|
+
export const StickyResponsiveSidebar = memo(StickyResponsiveSidebarComponent);
|
|
54
|
+
//# sourceMappingURL=StickyResponsiveSidebar.js.map
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export { StickyResponsiveSidebar } from './StickyResponsiveSidebar.js';
|
|
2
|
+
//# sourceMappingURL=index.js.map
|