@stoplight/elements-core 9.0.12-beta-0.1 → 9.0.13
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/components → components}/Docs/Docs.d.ts +1 -14
- package/{dist/components → components}/Docs/HttpOperation/Body.d.ts +1 -9
- package/{dist/components → components}/Docs/HttpOperation/HttpOperation.d.ts +2 -6
- package/{dist/components → components}/Docs/HttpOperation/Request.d.ts +0 -6
- package/{dist/components → components}/Docs/HttpOperation/Responses.d.ts +1 -12
- package/{dist/components → components}/TableOfContents/types.d.ts +7 -0
- package/{dist/index.esm.js → index.esm.js} +86 -525
- package/{dist/index.js → index.js} +86 -525
- package/{dist/index.mjs → index.mjs} +86 -525
- package/package.json +14 -74
- package/.storybook/main.js +0 -6
- package/.storybook/manager.js +0 -1
- package/.storybook/preview.jsx +0 -50
- package/dist/LICENSE +0 -190
- package/dist/README.md +0 -1
- package/dist/components/Docs/HttpOperation/LazySchemaTreePreviewer.d.ts +0 -34
- package/dist/package.json +0 -64
- package/jest.config.js +0 -10
- package/src/__fixtures__/articles/basic.md +0 -10
- package/src/__fixtures__/articles/kitchen-sink.md +0 -318
- package/src/__fixtures__/articles/long-page-heading.md +0 -955
- package/src/__fixtures__/articles/multiple-try-its.md +0 -54
- package/src/__fixtures__/articles/schema-with-refs.ts +0 -82
- package/src/__fixtures__/http-request.json +0 -11
- package/src/__fixtures__/models/model-with-no-examples.json +0 -15
- package/src/__fixtures__/models/model-with-one-example.json +0 -23
- package/src/__fixtures__/models/model-with-three-examples.json +0 -35
- package/src/__fixtures__/operations/application-octet-stream-post.ts +0 -39
- package/src/__fixtures__/operations/base64-file-upload.ts +0 -43
- package/src/__fixtures__/operations/big-response.ts +0 -4690
- package/src/__fixtures__/operations/bundled-parameter.ts +0 -128
- package/src/__fixtures__/operations/empty-response.ts +0 -15
- package/src/__fixtures__/operations/examples-request-body.ts +0 -135
- package/src/__fixtures__/operations/head-todos.ts +0 -49
- package/src/__fixtures__/operations/invalid-response-example.ts +0 -45
- package/src/__fixtures__/operations/multipart-formdata-post.ts +0 -61
- package/src/__fixtures__/operations/operation-minimal.ts +0 -11
- package/src/__fixtures__/operations/operation-parameters.ts +0 -337
- package/src/__fixtures__/operations/operation-with-examples.ts +0 -113
- package/src/__fixtures__/operations/operation-without-servers.ts +0 -16
- package/src/__fixtures__/operations/patch-todos.ts +0 -49
- package/src/__fixtures__/operations/put-todos.ts +0 -862
- package/src/__fixtures__/operations/referenced-body.ts +0 -62
- package/src/__fixtures__/operations/request-body-empty-schema.ts +0 -35
- package/src/__fixtures__/operations/request-body.ts +0 -62
- package/src/__fixtures__/operations/securedOperation.ts +0 -118
- package/src/__fixtures__/operations/security-basic.ts +0 -24
- package/src/__fixtures__/operations/security-bearer.ts +0 -25
- package/src/__fixtures__/operations/simple-get.ts +0 -17
- package/src/__fixtures__/operations/simple.ts +0 -103
- package/src/__fixtures__/operations/string-numeric-enums.ts +0 -32
- package/src/__fixtures__/operations/urlencoded-post-oneof.ts +0 -81
- package/src/__fixtures__/operations/urlencoded-post.ts +0 -54
- package/src/__fixtures__/operations/vendor-extensions.ts +0 -337
- package/src/__fixtures__/operations/with-url-variables.ts +0 -47
- package/src/__fixtures__/operations/x-code-samples.ts +0 -348
- package/src/__fixtures__/schemas/circular.ts +0 -1906
- package/src/__fixtures__/schemas/contact.json +0 -293
- package/src/__fixtures__/schemas/media-entry.json +0 -69
- package/src/__fixtures__/schemas/simple.json +0 -27
- package/src/__fixtures__/schemas/todo-full.v1.json +0 -35
- package/src/__fixtures__/schemas/todo-partial.v1.json +0 -14
- package/src/__fixtures__/schemas/user.v1.json +0 -17
- package/src/__fixtures__/security-schemes/index.ts +0 -38
- package/src/__fixtures__/services/petstore.ts +0 -167
- package/src/__fixtures__/services/with-unnamed-servers.ts +0 -38
- package/src/__fixtures__/services/with-url-variables.ts +0 -83
- package/src/__fixtures__/services/without-origin.ts +0 -20
- package/src/__fixtures__/table-of-contents/nested.ts +0 -44
- package/src/__fixtures__/table-of-contents/studio-template.ts +0 -100
- package/src/__fixtures__/table-of-contents/studio.ts +0 -559
- package/src/components/Docs/Article/Article.spec.tsx +0 -38
- package/src/components/Docs/Article/Article.stories.tsx +0 -17
- package/src/components/Docs/Article/index.tsx +0 -38
- package/src/components/Docs/Docs.stories.tsx +0 -33
- package/src/components/Docs/Docs.tsx +0 -272
- package/src/components/Docs/HttpOperation/Badges.tsx +0 -49
- package/src/components/Docs/HttpOperation/Body.tsx +0 -115
- package/src/components/Docs/HttpOperation/Callbacks.tsx +0 -89
- package/src/components/Docs/HttpOperation/HttpOperation.spec.tsx +0 -787
- package/src/components/Docs/HttpOperation/HttpOperation.stories.ts +0 -14
- package/src/components/Docs/HttpOperation/HttpOperation.tsx +0 -260
- package/src/components/Docs/HttpOperation/LazySchemaTreePreviewer.tsx +0 -651
- package/src/components/Docs/HttpOperation/Parameters.spec.tsx +0 -101
- package/src/components/Docs/HttpOperation/Parameters.tsx +0 -118
- package/src/components/Docs/HttpOperation/Request.tsx +0 -152
- package/src/components/Docs/HttpOperation/Responses.tsx +0 -301
- package/src/components/Docs/HttpOperation/index.ts +0 -1
- package/src/components/Docs/HttpService/AdditionalInfo.stories.ts +0 -48
- package/src/components/Docs/HttpService/AdditionalInfo.tsx +0 -61
- package/src/components/Docs/HttpService/ExportButton.tsx +0 -35
- package/src/components/Docs/HttpService/HttpService.spec.tsx +0 -429
- package/src/components/Docs/HttpService/HttpService.stories.ts +0 -14
- package/src/components/Docs/HttpService/HttpService.tsx +0 -99
- package/src/components/Docs/HttpService/SecuritySchemes.tsx +0 -82
- package/src/components/Docs/HttpService/ServerInfo.tsx +0 -196
- package/src/components/Docs/HttpService/index.ts +0 -1
- package/src/components/Docs/Model/Model.spec.tsx +0 -241
- package/src/components/Docs/Model/Model.stories.tsx +0 -16
- package/src/components/Docs/Model/Model.tsx +0 -192
- package/src/components/Docs/Model/index.ts +0 -1
- package/src/components/Docs/NodeVendorExtensions.tsx +0 -55
- package/src/components/Docs/Sections.tsx +0 -54
- package/src/components/Docs/Security/PanelContent.tsx +0 -38
- package/src/components/Docs/Security/index.ts +0 -1
- package/src/components/Docs/Skeleton.tsx +0 -12
- package/src/components/Docs/TwoColumnLayout.tsx +0 -27
- package/src/components/Docs/index.ts +0 -1
- package/src/components/Docs/story-helper.ts +0 -46
- package/src/components/Docs/story-renderer-helper.tsx +0 -56
- package/src/components/Layout/MobileTopNav.tsx +0 -78
- package/src/components/Layout/ResponsiveSidebarLayout.tsx +0 -175
- package/src/components/Layout/SidebarLayout.tsx +0 -107
- package/src/components/LinkHeading.tsx +0 -21
- package/src/components/LoadMore.tsx +0 -20
- package/src/components/Loading/Loading.tsx +0 -9
- package/src/components/Logo.tsx +0 -25
- package/src/components/MarkdownViewer/CustomComponents/CodeComponent.spec.ts +0 -90
- package/src/components/MarkdownViewer/CustomComponents/CodeComponent.tsx +0 -164
- package/src/components/MarkdownViewer/CustomComponents/Provider.tsx +0 -20
- package/src/components/MarkdownViewer/CustomComponents/ReactRouterLink.tsx +0 -27
- package/src/components/MarkdownViewer/CustomComponents/ResolvedImage.tsx +0 -86
- package/src/components/MarkdownViewer/CustomComponents/ScrollToHashElement.tsx +0 -96
- package/src/components/MarkdownViewer/MarkdownViewer.spec.tsx +0 -170
- package/src/components/MarkdownViewer/index.tsx +0 -10
- package/src/components/NonIdealState.tsx +0 -20
- package/src/components/PoweredByLink.tsx +0 -30
- package/src/components/RequestSamples/RequestSamples.stories.tsx +0 -67
- package/src/components/RequestSamples/RequestSamples.tsx +0 -246
- package/src/components/RequestSamples/__tests__/RequestSamples.test.tsx +0 -131
- package/src/components/RequestSamples/__tests__/__snapshots__/convertRequestToSample.spec.ts.snap +0 -746
- package/src/components/RequestSamples/__tests__/convertRequestToSample.spec.ts +0 -118
- package/src/components/RequestSamples/convertRequestToSample.ts +0 -56
- package/src/components/RequestSamples/extractCodeSamples.ts +0 -50
- package/src/components/RequestSamples/index.ts +0 -2
- package/src/components/RequestSamples/requestSampleConfigs.ts +0 -182
- package/src/components/ResponseExamples/ResponseExamples.spec.tsx +0 -121
- package/src/components/ResponseExamples/ResponseExamples.stories.tsx +0 -21
- package/src/components/ResponseExamples/ResponseExamples.tsx +0 -79
- package/src/components/TableOfContents/TableOfContents.spec.tsx +0 -301
- package/src/components/TableOfContents/TableOfContents.stories.tsx +0 -121
- package/src/components/TableOfContents/TableOfContents.tsx +0 -406
- package/src/components/TableOfContents/constants.ts +0 -45
- package/src/components/TableOfContents/index.ts +0 -2
- package/src/components/TableOfContents/types.ts +0 -51
- package/src/components/TableOfContents/utils.ts +0 -84
- package/src/components/TryIt/Auth/APIKeyAuth.tsx +0 -19
- package/src/components/TryIt/Auth/Auth.tsx +0 -169
- package/src/components/TryIt/Auth/AuthTokenInput.tsx +0 -37
- package/src/components/TryIt/Auth/BasicAuth.tsx +0 -62
- package/src/components/TryIt/Auth/BearerAuth.tsx +0 -19
- package/src/components/TryIt/Auth/DigestAuth.tsx +0 -35
- package/src/components/TryIt/Auth/OAuth2Auth.tsx +0 -19
- package/src/components/TryIt/Auth/authentication-utils.ts +0 -113
- package/src/components/TryIt/Body/BinaryBody.tsx +0 -52
- package/src/components/TryIt/Body/FormDataBody.tsx +0 -145
- package/src/components/TryIt/Body/RequestBody.tsx +0 -71
- package/src/components/TryIt/Body/__tests__/BinaryBody.test.tsx +0 -29
- package/src/components/TryIt/Body/__tests__/FormDataBody.test.tsx +0 -94
- package/src/components/TryIt/Body/request-body-utils.ts +0 -127
- package/src/components/TryIt/Body/useTextRequestBodyState.ts +0 -27
- package/src/components/TryIt/Mocking/MockingButton.tsx +0 -98
- package/src/components/TryIt/Mocking/mocking-utils.ts +0 -56
- package/src/components/TryIt/Mocking/useMockingOptions.ts +0 -6
- package/src/components/TryIt/Parameters/FileUploadParameterEditors.tsx +0 -62
- package/src/components/TryIt/Parameters/OperationParameters.tsx +0 -39
- package/src/components/TryIt/Parameters/ParameterEditor.tsx +0 -118
- package/src/components/TryIt/Parameters/__tests__/parameter-utils.spec.ts +0 -60
- package/src/components/TryIt/Parameters/parameter-utils.spec.ts +0 -118
- package/src/components/TryIt/Parameters/parameter-utils.ts +0 -179
- package/src/components/TryIt/Parameters/useOperationParameters.ts +0 -60
- package/src/components/TryIt/Response/ReponseCodeViewer.tsx +0 -28
- package/src/components/TryIt/Response/Response.spec.tsx +0 -174
- package/src/components/TryIt/Response/Response.tsx +0 -172
- package/src/components/TryIt/Response/hooks/useLineCount.ts +0 -7
- package/src/components/TryIt/Servers/ServerVariables.tsx +0 -33
- package/src/components/TryIt/Servers/ServersDropdown.tsx +0 -53
- package/src/components/TryIt/Servers/VariableEditor.tsx +0 -51
- package/src/components/TryIt/Servers/useServerVariables.ts +0 -19
- package/src/components/TryIt/TryIt.spec.tsx +0 -1511
- package/src/components/TryIt/TryIt.stories.tsx +0 -77
- package/src/components/TryIt/TryIt.tsx +0 -384
- package/src/components/TryIt/TryItWithRequestSamples.spec.tsx +0 -143
- package/src/components/TryIt/TryItWithRequestSamples.stories.tsx +0 -32
- package/src/components/TryIt/TryItWithRequestSamples.tsx +0 -42
- package/src/components/TryIt/build-request.spec.ts +0 -213
- package/src/components/TryIt/build-request.ts +0 -357
- package/src/components/TryIt/chosenServer.ts +0 -5
- package/src/components/TryIt/index.ts +0 -3
- package/src/components/__tests__/LinkHeading.spec.tsx +0 -125
- package/src/constants.ts +0 -176
- package/src/containers/MockingProvider.tsx +0 -23
- package/src/context/InlineRefResolver.spec.tsx +0 -183
- package/src/context/InlineRefResolver.tsx +0 -94
- package/src/context/Options.tsx +0 -27
- package/src/context/Persistence.tsx +0 -24
- package/src/context/RouterType.tsx +0 -9
- package/src/core.css +0 -97
- package/src/hoc/utils.ts +0 -5
- package/src/hoc/withMosaicProvider.spec.tsx +0 -48
- package/src/hoc/withMosaicProvider.tsx +0 -28
- package/src/hoc/withQueryClientProvider.spec.tsx +0 -38
- package/src/hoc/withQueryClientProvider.tsx +0 -35
- package/src/hoc/withRouter.tsx +0 -71
- package/src/hooks/useBundleRefsIntoDocument.ts +0 -60
- package/src/hooks/useFirstRender.ts +0 -8
- package/src/hooks/useIsCompact.ts +0 -26
- package/src/hooks/useParsedData.ts +0 -99
- package/src/hooks/useParsedValue.ts +0 -19
- package/src/hooks/useResponsiveLayout.tsx +0 -51
- package/src/hooks/useRouter.tsx +0 -31
- package/src/hooks/useUniqueId.ts +0 -4
- package/src/index.ts +0 -48
- package/src/styled.tsx +0 -22
- package/src/styles.css +0 -4
- package/src/types.ts +0 -170
- package/src/utils/__tests__/securitySchemes.spec.ts +0 -137
- package/src/utils/exampleGeneration/exampleGeneration.spec.tsx +0 -18
- package/src/utils/exampleGeneration/exampleGeneration.ts +0 -110
- package/src/utils/fileToBase64.ts +0 -11
- package/src/utils/guards.ts +0 -48
- package/src/utils/headers.ts +0 -316
- package/src/utils/http-spec/IServer.ts +0 -100
- package/src/utils/http-spec/__tests__/IServer.spec.ts +0 -51
- package/src/utils/http-spec/examples.ts +0 -5
- package/src/utils/http.ts +0 -9
- package/src/utils/jotai/persistAtom.ts +0 -31
- package/src/utils/node.ts +0 -19
- package/src/utils/oas/__tests__/security.spec.ts +0 -18
- package/src/utils/oas/security.ts +0 -76
- package/src/utils/ref-resolving/ReferenceResolver.ts +0 -29
- package/src/utils/ref-resolving/resolvedObject.test.ts +0 -415
- package/src/utils/ref-resolving/resolvedObject.ts +0 -109
- package/src/utils/securitySchemes.ts +0 -117
- package/src/utils/string.ts +0 -15
- package/src/utils/tests/chooseOption.ts +0 -7
- package/src/web-components/createElementClass.ts +0 -154
- package/tsconfig.build.json +0 -14
- package/tsconfig.json +0 -7
- /package/{dist/__fixtures__ → __fixtures__}/articles/schema-with-refs.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/application-octet-stream-post.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/base64-file-upload.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/big-response.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/examples-request-body.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/head-todos.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/multipart-formdata-post.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-minimal.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-parameters.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-with-examples.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/operation-without-servers.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/patch-todos.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/put-todos.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/referenced-body.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/request-body-empty-schema.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/request-body.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/securedOperation.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/security-basic.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/security-bearer.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/simple-get.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/string-numeric-enums.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/urlencoded-post-oneof.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/urlencoded-post.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/operations/with-url-variables.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/security-schemes/index.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/petstore.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/with-unnamed-servers.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/with-url-variables.d.ts +0 -0
- /package/{dist/__fixtures__ → __fixtures__}/services/without-origin.d.ts +0 -0
- /package/{dist/components → components}/Docs/Article/Article.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/Article/Article.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/Article/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/Docs.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Badges.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Callbacks.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/HttpOperation.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/HttpOperation.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Parameters.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/Parameters.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpOperation/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/AdditionalInfo.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/AdditionalInfo.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/ExportButton.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/HttpService.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/HttpService.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/HttpService.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/SecuritySchemes.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/ServerInfo.d.ts +0 -0
- /package/{dist/components → components}/Docs/HttpService/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/Model.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/Model.spec.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/Model.stories.d.ts +0 -0
- /package/{dist/components → components}/Docs/Model/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/NodeVendorExtensions.d.ts +0 -0
- /package/{dist/components → components}/Docs/Sections.d.ts +0 -0
- /package/{dist/components → components}/Docs/Security/PanelContent.d.ts +0 -0
- /package/{dist/components → components}/Docs/Security/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/Skeleton.d.ts +0 -0
- /package/{dist/components → components}/Docs/TwoColumnLayout.d.ts +0 -0
- /package/{dist/components → components}/Docs/index.d.ts +0 -0
- /package/{dist/components → components}/Docs/story-helper.d.ts +0 -0
- /package/{dist/components → components}/Docs/story-renderer-helper.d.ts +0 -0
- /package/{dist/components → components}/Layout/MobileTopNav.d.ts +0 -0
- /package/{dist/components → components}/Layout/ResponsiveSidebarLayout.d.ts +0 -0
- /package/{dist/components → components}/Layout/SidebarLayout.d.ts +0 -0
- /package/{dist/components → components}/LinkHeading.d.ts +0 -0
- /package/{dist/components → components}/LoadMore.d.ts +0 -0
- /package/{dist/components → components}/Loading/Loading.d.ts +0 -0
- /package/{dist/components → components}/Logo.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/CodeComponent.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/CodeComponent.spec.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/Provider.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/ReactRouterLink.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/ResolvedImage.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/CustomComponents/ScrollToHashElement.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/MarkdownViewer.spec.d.ts +0 -0
- /package/{dist/components → components}/MarkdownViewer/index.d.ts +0 -0
- /package/{dist/components → components}/NonIdealState.d.ts +0 -0
- /package/{dist/components → components}/PoweredByLink.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/RequestSamples.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/RequestSamples.stories.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/convertRequestToSample.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/extractCodeSamples.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/index.d.ts +0 -0
- /package/{dist/components → components}/RequestSamples/requestSampleConfigs.d.ts +0 -0
- /package/{dist/components → components}/ResponseExamples/ResponseExamples.d.ts +0 -0
- /package/{dist/components → components}/ResponseExamples/ResponseExamples.spec.d.ts +0 -0
- /package/{dist/components → components}/ResponseExamples/ResponseExamples.stories.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.spec.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/TableOfContents.stories.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/constants.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/index.d.ts +0 -0
- /package/{dist/components → components}/TableOfContents/utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/APIKeyAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/Auth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/AuthTokenInput.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/BasicAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/BearerAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/DigestAuth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/OAuth2Auth.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Auth/authentication-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/BinaryBody.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/FormDataBody.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/RequestBody.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/request-body-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Body/useTextRequestBodyState.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Mocking/MockingButton.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Mocking/mocking-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Mocking/useMockingOptions.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/FileUploadParameterEditors.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/OperationParameters.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/ParameterEditor.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/parameter-utils.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/parameter-utils.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Parameters/useOperationParameters.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/ReponseCodeViewer.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/Response.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/Response.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Response/hooks/useLineCount.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/ServerVariables.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/ServersDropdown.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/VariableEditor.d.ts +0 -0
- /package/{dist/components → components}/TryIt/Servers/useServerVariables.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryIt.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryIt.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryIt.stories.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryItWithRequestSamples.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryItWithRequestSamples.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/TryItWithRequestSamples.stories.d.ts +0 -0
- /package/{dist/components → components}/TryIt/build-request.d.ts +0 -0
- /package/{dist/components → components}/TryIt/build-request.spec.d.ts +0 -0
- /package/{dist/components → components}/TryIt/chosenServer.d.ts +0 -0
- /package/{dist/components → components}/TryIt/index.d.ts +0 -0
- /package/{dist/constants.d.ts → constants.d.ts} +0 -0
- /package/{dist/containers → containers}/MockingProvider.d.ts +0 -0
- /package/{dist/context → context}/InlineRefResolver.d.ts +0 -0
- /package/{dist/context → context}/InlineRefResolver.spec.d.ts +0 -0
- /package/{dist/context → context}/Options.d.ts +0 -0
- /package/{dist/context → context}/Persistence.d.ts +0 -0
- /package/{dist/context → context}/RouterType.d.ts +0 -0
- /package/{dist/core.css → core.css} +0 -0
- /package/{dist/hoc → hoc}/utils.d.ts +0 -0
- /package/{dist/hoc → hoc}/withMosaicProvider.d.ts +0 -0
- /package/{dist/hoc → hoc}/withMosaicProvider.spec.d.ts +0 -0
- /package/{dist/hoc → hoc}/withQueryClientProvider.d.ts +0 -0
- /package/{dist/hoc → hoc}/withQueryClientProvider.spec.d.ts +0 -0
- /package/{dist/hoc → hoc}/withRouter.d.ts +0 -0
- /package/{dist/hooks → hooks}/useBundleRefsIntoDocument.d.ts +0 -0
- /package/{dist/hooks → hooks}/useFirstRender.d.ts +0 -0
- /package/{dist/hooks → hooks}/useIsCompact.d.ts +0 -0
- /package/{dist/hooks → hooks}/useParsedData.d.ts +0 -0
- /package/{dist/hooks → hooks}/useParsedValue.d.ts +0 -0
- /package/{dist/hooks → hooks}/useResponsiveLayout.d.ts +0 -0
- /package/{dist/hooks → hooks}/useRouter.d.ts +0 -0
- /package/{dist/hooks → hooks}/useUniqueId.d.ts +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/styled.d.ts → styled.d.ts} +0 -0
- /package/{dist/styles.min.css → styles.min.css} +0 -0
- /package/{dist/types.d.ts → types.d.ts} +0 -0
- /package/{dist/utils → utils}/exampleGeneration/exampleGeneration.d.ts +0 -0
- /package/{dist/utils → utils}/exampleGeneration/exampleGeneration.spec.d.ts +0 -0
- /package/{dist/utils → utils}/fileToBase64.d.ts +0 -0
- /package/{dist/utils → utils}/guards.d.ts +0 -0
- /package/{dist/utils → utils}/headers.d.ts +0 -0
- /package/{dist/utils → utils}/http-spec/IServer.d.ts +0 -0
- /package/{dist/utils → utils}/http-spec/examples.d.ts +0 -0
- /package/{dist/utils → utils}/http.d.ts +0 -0
- /package/{dist/utils → utils}/jotai/persistAtom.d.ts +0 -0
- /package/{dist/utils → utils}/node.d.ts +0 -0
- /package/{dist/utils → utils}/oas/security.d.ts +0 -0
- /package/{dist/utils → utils}/ref-resolving/ReferenceResolver.d.ts +0 -0
- /package/{dist/utils → utils}/ref-resolving/resolvedObject.d.ts +0 -0
- /package/{dist/utils → utils}/ref-resolving/resolvedObject.test.d.ts +0 -0
- /package/{dist/utils → utils}/securitySchemes.d.ts +0 -0
- /package/{dist/utils → utils}/string.d.ts +0 -0
- /package/{dist/utils → utils}/tests/chooseOption.d.ts +0 -0
- /package/{dist/web-components → web-components}/createElementClass.d.ts +0 -0
|
@@ -113,8 +113,6 @@ const isResolvedObjectProxy = (someObject) => {
|
|
|
113
113
|
return !!someObject[originalObjectSymbol];
|
|
114
114
|
};
|
|
115
115
|
const getOriginalObject = (resolvedObject) => {
|
|
116
|
-
if (!resolvedObject)
|
|
117
|
-
return resolvedObject;
|
|
118
116
|
const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
|
|
119
117
|
if (!originalObject) {
|
|
120
118
|
return resolvedObject;
|
|
@@ -2740,416 +2738,13 @@ const PanelContent = ({ schemes }) => {
|
|
|
2740
2738
|
})));
|
|
2741
2739
|
};
|
|
2742
2740
|
|
|
2743
|
-
const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
|
|
2744
|
-
function resolvePointer(obj, pointer) {
|
|
2745
|
-
const parts = pointer.replace(/^#\//, '').split('/');
|
|
2746
|
-
return parts.reduce((acc, key) => acc && acc[key], obj);
|
|
2747
|
-
}
|
|
2748
|
-
function detectCircularPath(path) {
|
|
2749
|
-
const ignored = ['properties', 'items'];
|
|
2750
|
-
const parts = path.split('/').filter(part => !ignored.includes(part));
|
|
2751
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
2752
|
-
const current = parts[i];
|
|
2753
|
-
const rest = parts.slice(i + 1);
|
|
2754
|
-
if (rest.includes(current)) {
|
|
2755
|
-
return true;
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
return false;
|
|
2759
|
-
}
|
|
2760
|
-
function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth = 10) {
|
|
2761
|
-
if (!node || typeof node !== 'object')
|
|
2762
|
-
return node;
|
|
2763
|
-
if (depth > maxDepth)
|
|
2764
|
-
return node;
|
|
2765
|
-
if (node.$ref || node['x-iata-$ref']) {
|
|
2766
|
-
let refPath = node.$ref || node['x-iata-$ref'];
|
|
2767
|
-
if (refPath.includes('#/%24defs')) {
|
|
2768
|
-
refPath = refPath.replace('#/%24defs', '$defs');
|
|
2769
|
-
}
|
|
2770
|
-
else {
|
|
2771
|
-
refPath = refPath.replace('__bundled__', 'definitions');
|
|
2772
|
-
}
|
|
2773
|
-
if (visited.has(node))
|
|
2774
|
-
return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
|
|
2775
|
-
visited.add(node);
|
|
2776
|
-
const target = resolvePointer(root, refPath);
|
|
2777
|
-
if (!target)
|
|
2778
|
-
return node;
|
|
2779
|
-
const result = Object.assign({}, target);
|
|
2780
|
-
if ('description' in node)
|
|
2781
|
-
result.description = node.description;
|
|
2782
|
-
if ('title' in node)
|
|
2783
|
-
result.title = node.title;
|
|
2784
|
-
return dereference(result, root, visited, depth + 1, maxDepth);
|
|
2785
|
-
}
|
|
2786
|
-
if (Array.isArray(node)) {
|
|
2787
|
-
return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
|
|
2788
|
-
}
|
|
2789
|
-
const result = {};
|
|
2790
|
-
for (const key in node) {
|
|
2791
|
-
result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
|
|
2792
|
-
}
|
|
2793
|
-
return result;
|
|
2794
|
-
}
|
|
2795
|
-
const trimSlashes = (str) => {
|
|
2796
|
-
return str.replace(/^\/|\/$/g, '');
|
|
2797
|
-
};
|
|
2798
|
-
function isPropertiesAllHidden(path, hideData) {
|
|
2799
|
-
const current = trimSlashes(path);
|
|
2800
|
-
const parts = current.split('/');
|
|
2801
|
-
for (let i = parts.length; i >= 2; i--) {
|
|
2802
|
-
if (parts[i - 1] === 'properties') {
|
|
2803
|
-
const ancestorPropPath = parts.slice(0, i).join('/');
|
|
2804
|
-
const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
|
|
2805
|
-
if (block && block.required === undefined) {
|
|
2806
|
-
return true;
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
}
|
|
2810
|
-
return false;
|
|
2811
|
-
}
|
|
2812
|
-
function isRequiredOverride(path, hideData) {
|
|
2813
|
-
const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
|
|
2814
|
-
return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
|
|
2815
|
-
}
|
|
2816
|
-
function isPathHidden(path, hideData, complexData) {
|
|
2817
|
-
const isComplex = checkIfIsComplex(path, complexData);
|
|
2818
|
-
if (isComplex === null) {
|
|
2819
|
-
return false;
|
|
2820
|
-
}
|
|
2821
|
-
else if (isComplex) {
|
|
2822
|
-
const normalizedPath = trimSlashes(path);
|
|
2823
|
-
const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
|
|
2824
|
-
if (direct && direct.required === undefined)
|
|
2825
|
-
return true;
|
|
2826
|
-
if (isPropertiesAllHidden(path, hideData))
|
|
2827
|
-
return true;
|
|
2828
|
-
for (const h of hideData) {
|
|
2829
|
-
const hPath = trimSlashes(h.path);
|
|
2830
|
-
if (h.required !== undefined)
|
|
2831
|
-
continue;
|
|
2832
|
-
if (normalizedPath.length > hPath.length &&
|
|
2833
|
-
normalizedPath.startsWith(hPath) &&
|
|
2834
|
-
(hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
|
|
2835
|
-
return true;
|
|
2836
|
-
}
|
|
2837
|
-
}
|
|
2838
|
-
return false;
|
|
2839
|
-
}
|
|
2840
|
-
else {
|
|
2841
|
-
return !hideData.some(h => h.path === path || h.path.startsWith(path + '/'));
|
|
2842
|
-
}
|
|
2843
|
-
}
|
|
2844
|
-
const checkIfIsComplex = (path, complexData) => {
|
|
2845
|
-
let isComplex = null;
|
|
2846
|
-
for (const complex of complexData) {
|
|
2847
|
-
if (path.startsWith(complex.location)) {
|
|
2848
|
-
isComplex = complex === null || complex === void 0 ? void 0 : complex.isComplex;
|
|
2849
|
-
break;
|
|
2850
|
-
}
|
|
2851
|
-
}
|
|
2852
|
-
return isComplex;
|
|
2853
|
-
};
|
|
2854
|
-
const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], complexData = [], parentRequired, propertyKey, _subType, }) => {
|
|
2855
|
-
var _a, _b, _c, _d;
|
|
2856
|
-
const [expanded, setExpanded] = useState(false);
|
|
2857
|
-
const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0);
|
|
2858
|
-
const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
|
|
2859
|
-
const [isHoveringSelector, setIsHoveringSelector] = useState(false);
|
|
2860
|
-
const isRoot = level === 1 && (title === undefined || path === '');
|
|
2861
|
-
useEffect(() => {
|
|
2862
|
-
setSelectedSchemaIndex(0);
|
|
2863
|
-
}, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
|
|
2864
|
-
const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
|
|
2865
|
-
const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
|
|
2866
|
-
(!isRoot && isPropertiesAllHidden(path, hideData));
|
|
2867
|
-
const hasExpandableChildren = useMemo(() => {
|
|
2868
|
-
var _a;
|
|
2869
|
-
if (shouldHideAllChildren)
|
|
2870
|
-
return false;
|
|
2871
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
|
|
2872
|
-
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2873
|
-
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2874
|
-
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2875
|
-
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2876
|
-
});
|
|
2877
|
-
}
|
|
2878
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2879
|
-
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2880
|
-
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2881
|
-
}
|
|
2882
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2883
|
-
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2884
|
-
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2885
|
-
}
|
|
2886
|
-
if (props && Object.keys(props).length > 0) {
|
|
2887
|
-
for (const [key] of Object.entries(props)) {
|
|
2888
|
-
const childPath = `${path}/properties/${key}`;
|
|
2889
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2890
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2891
|
-
if (!shouldHideChild)
|
|
2892
|
-
return true;
|
|
2893
|
-
}
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
|
|
2897
|
-
(schema === null || schema === void 0 ? void 0 : schema.items) &&
|
|
2898
|
-
Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
|
|
2899
|
-
!((_a = schema === null || schema === void 0 ? void 0 : schema.items) === null || _a === void 0 ? void 0 : _a.circular)) {
|
|
2900
|
-
const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
|
|
2901
|
-
const itemsPath = `${path}/items`;
|
|
2902
|
-
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2903
|
-
for (const [key] of Object.entries(resolvedItems.properties)) {
|
|
2904
|
-
const childPath = `${itemsPath}/properties/${key}`;
|
|
2905
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2906
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2907
|
-
if (!shouldHideChild)
|
|
2908
|
-
return true;
|
|
2909
|
-
}
|
|
2910
|
-
}
|
|
2911
|
-
else if (resolvedItems &&
|
|
2912
|
-
resolvedItems.type === 'array' &&
|
|
2913
|
-
resolvedItems.items &&
|
|
2914
|
-
resolvedItems.items.length > 0) {
|
|
2915
|
-
const childPath = `${path}/items`;
|
|
2916
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2917
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2918
|
-
if (!shouldHideChild)
|
|
2919
|
-
return true;
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
return false;
|
|
2923
|
-
}, [schema, path, hideData, complexData, shouldHideAllChildren, root, selectedSchemaIndex]);
|
|
2924
|
-
const shouldHideNode = useMemo(() => {
|
|
2925
|
-
if (isRoot)
|
|
2926
|
-
return false;
|
|
2927
|
-
if (isPathHidden(path, hideData, complexData) && thisNodeRequiredOverride === undefined)
|
|
2928
|
-
return true;
|
|
2929
|
-
return false;
|
|
2930
|
-
}, [path, hideData, isRoot, thisNodeRequiredOverride, complexData]);
|
|
2931
|
-
if (!schema || shouldHideNode) {
|
|
2932
|
-
return null;
|
|
2933
|
-
}
|
|
2934
|
-
const displayTitle = level === 1 && (title === undefined || path === '') ? '' : (_a = title !== null && title !== void 0 ? title : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _a !== void 0 ? _a : 'Node';
|
|
2935
|
-
const handleToggle = () => {
|
|
2936
|
-
const circular = detectCircularPath(path);
|
|
2937
|
-
if (!circular) {
|
|
2938
|
-
setExpanded(prev => !prev);
|
|
2939
|
-
}
|
|
2940
|
-
};
|
|
2941
|
-
const renderChildren = () => {
|
|
2942
|
-
var _a, _b, _c, _d;
|
|
2943
|
-
if (shouldHideAllChildren)
|
|
2944
|
-
return null;
|
|
2945
|
-
if (!expanded && !isRoot)
|
|
2946
|
-
return null;
|
|
2947
|
-
const children = [];
|
|
2948
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
|
|
2949
|
-
let props = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2950
|
-
if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
|
|
2951
|
-
schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
|
|
2952
|
-
props = Object.assign(Object.assign({}, props), item.properties);
|
|
2953
|
-
});
|
|
2954
|
-
}
|
|
2955
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
2956
|
-
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
|
|
2957
|
-
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2958
|
-
}
|
|
2959
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
2960
|
-
const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
|
|
2961
|
-
props = Object.assign(Object.assign({}, props), selectedSchema.properties);
|
|
2962
|
-
}
|
|
2963
|
-
for (const [key, child] of Object.entries(props || {})) {
|
|
2964
|
-
const childPath = `${path}/properties/${key}`;
|
|
2965
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2966
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2967
|
-
const resolved = dereference(child, root);
|
|
2968
|
-
if (!shouldHideChild) {
|
|
2969
|
-
children.push(React__default.createElement("li", { key: key },
|
|
2970
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, complexData: complexData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key, _subType: (_a = resolved === null || resolved === void 0 ? void 0 : resolved.items) === null || _a === void 0 ? void 0 : _a.type })));
|
|
2971
|
-
}
|
|
2972
|
-
}
|
|
2973
|
-
}
|
|
2974
|
-
else if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
|
|
2975
|
-
(schema === null || schema === void 0 ? void 0 : schema.items) &&
|
|
2976
|
-
Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
|
|
2977
|
-
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular)) {
|
|
2978
|
-
const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
|
|
2979
|
-
const itemsPath = `${path}/items`;
|
|
2980
|
-
if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
|
|
2981
|
-
for (const [key, child] of Object.entries(resolvedItems.properties)) {
|
|
2982
|
-
const childPath = `${itemsPath}/properties/${key}`;
|
|
2983
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2984
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2985
|
-
const resolved = dereference(child, root);
|
|
2986
|
-
if (!shouldHideChild) {
|
|
2987
|
-
children.push(React__default.createElement("li", { key: key },
|
|
2988
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 2, path: childPath, hideData: hideData, complexData: complexData, parentRequired: resolvedItems.required, propertyKey: key, _subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
|
|
2989
|
-
}
|
|
2990
|
-
}
|
|
2991
|
-
}
|
|
2992
|
-
else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
|
|
2993
|
-
const childPath = `${path}/items`;
|
|
2994
|
-
const childRequiredOverride = isRequiredOverride(childPath, hideData);
|
|
2995
|
-
const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
|
|
2996
|
-
if (!shouldHideChild) {
|
|
2997
|
-
children.push(React__default.createElement("li", { key: "items" },
|
|
2998
|
-
React__default.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, complexData: complexData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items", _subType: (_d = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _d === void 0 ? void 0 : _d.type })));
|
|
2999
|
-
}
|
|
3000
|
-
}
|
|
3001
|
-
}
|
|
3002
|
-
return children.length > 0 ? React__default.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
|
|
3003
|
-
};
|
|
3004
|
-
const combinedSchemaSelector = () => {
|
|
3005
|
-
var _a;
|
|
3006
|
-
return (React__default.createElement(React__default.Fragment, null,
|
|
3007
|
-
React__default.createElement(Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
|
|
3008
|
-
React__default.createElement(Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
|
|
3009
|
-
zIndex: 1000,
|
|
3010
|
-
top: '100%',
|
|
3011
|
-
left: 0,
|
|
3012
|
-
minWidth: '150px',
|
|
3013
|
-
maxWidth: '200px',
|
|
3014
|
-
marginTop: '2px',
|
|
3015
|
-
border: '1px solid rgba(0, 0, 0, 0.1)',
|
|
3016
|
-
}, fontSize: "sm", onClick: (e) => e.stopPropagation() }, (_a = ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) === null || _a === void 0 ? void 0 : _a.map((schemaOption, index) => (React__default.createElement(Box, { key: index, px: 3, py: 2, cursor: "pointer", bg: selectedSchemaIndex === index ? 'primary-tint' : 'canvas', fontSize: "xs", display: "flex", alignItems: "center", style: {
|
|
3017
|
-
borderBottom: index < ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)).length - 1 ? '1px solid rgba(0, 0, 0, 0.1)' : 'none',
|
|
3018
|
-
gap: '8px',
|
|
3019
|
-
}, onMouseEnter: (e) => {
|
|
3020
|
-
if (selectedSchemaIndex !== index) {
|
|
3021
|
-
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
|
|
3022
|
-
}
|
|
3023
|
-
}, onMouseLeave: (e) => {
|
|
3024
|
-
if (selectedSchemaIndex !== index) {
|
|
3025
|
-
e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
|
|
3026
|
-
}
|
|
3027
|
-
}, onClick: () => {
|
|
3028
|
-
setSelectedSchemaIndex(index);
|
|
3029
|
-
setShowSchemaDropdown(false);
|
|
3030
|
-
} },
|
|
3031
|
-
React__default.createElement(Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
|
|
3032
|
-
selectedSchemaIndex === index && (React__default.createElement(Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
|
|
3033
|
-
};
|
|
3034
|
-
const renderMinEnums = (schema) => {
|
|
3035
|
-
if (!schema || typeof schema !== 'object')
|
|
3036
|
-
return null;
|
|
3037
|
-
const boxStyle = {
|
|
3038
|
-
background: 'rgba(245, 247, 250, 0.5)',
|
|
3039
|
-
border: '1px solid #a0aec0',
|
|
3040
|
-
borderRadius: '4px',
|
|
3041
|
-
padding: '0px 2px',
|
|
3042
|
-
display: 'inline-block',
|
|
3043
|
-
overflowWrap: 'break-word',
|
|
3044
|
-
textAlign: 'left',
|
|
3045
|
-
maxWidth: 'fit-content',
|
|
3046
|
-
maxHeight: 'fit-content',
|
|
3047
|
-
};
|
|
3048
|
-
if ('minItems' in schema) {
|
|
3049
|
-
const schemaWithMinItems = schema;
|
|
3050
|
-
if (typeof schemaWithMinItems.minItems === 'number') {
|
|
3051
|
-
return (React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, `>=${schemaWithMinItems.minItems} items`));
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
if ('enum' in schema && Array.isArray(schema.enum)) {
|
|
3055
|
-
return (React__default.createElement("div", null,
|
|
3056
|
-
"Allowed values:",
|
|
3057
|
-
' ',
|
|
3058
|
-
schema.enum.map((val, idx) => (React__default.createElement(Box, { key: idx, className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, val)))));
|
|
3059
|
-
}
|
|
3060
|
-
return null;
|
|
3061
|
-
};
|
|
3062
|
-
const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
|
|
3063
|
-
let showRequiredLabel = false;
|
|
3064
|
-
const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
|
|
3065
|
-
if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
|
|
3066
|
-
showRequiredLabel = true;
|
|
3067
|
-
}
|
|
3068
|
-
if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
|
|
3069
|
-
schema = dereference(schema, root);
|
|
3070
|
-
}
|
|
3071
|
-
return (React__default.createElement("div", { className: "mb-1" },
|
|
3072
|
-
React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
|
|
3073
|
-
React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
|
|
3074
|
-
React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
|
|
3075
|
-
!isRoot ? (React__default.createElement(Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
|
|
3076
|
-
hasExpandableChildren &&
|
|
3077
|
-
!TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
|
|
3078
|
-
!detectCircularPath(path) &&
|
|
3079
|
-
!((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
|
|
3080
|
-
!(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
|
|
3081
|
-
' ' + displayTitle)) : null,
|
|
3082
|
-
!isRoot ? (React__default.createElement(Box, { mr: 2, pos: "relative" },
|
|
3083
|
-
React__default.createElement(Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
|
|
3084
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3085
|
-
setIsHoveringSelector(true);
|
|
3086
|
-
}
|
|
3087
|
-
}, onMouseLeave: () => {
|
|
3088
|
-
if (!showSchemaDropdown) {
|
|
3089
|
-
setIsHoveringSelector(false);
|
|
3090
|
-
}
|
|
3091
|
-
}, onClick: (e) => {
|
|
3092
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
|
|
3093
|
-
e.stopPropagation();
|
|
3094
|
-
setShowSchemaDropdown(prev => !prev);
|
|
3095
|
-
}
|
|
3096
|
-
}, style: {
|
|
3097
|
-
cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
|
|
3098
|
-
} },
|
|
3099
|
-
React__default.createElement("span", { className: "sl-truncate sl-text-muted" },
|
|
3100
|
-
(() => {
|
|
3101
|
-
let typeDisplay = (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : (schema === null || schema === void 0 ? void 0 : schema.type) || (root === null || root === void 0 ? void 0 : root.title);
|
|
3102
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
|
|
3103
|
-
return `any of ${typeDisplay}`;
|
|
3104
|
-
}
|
|
3105
|
-
else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
|
|
3106
|
-
return `one of ${typeDisplay}`;
|
|
3107
|
-
}
|
|
3108
|
-
return typeDisplay;
|
|
3109
|
-
})(),
|
|
3110
|
-
(schema === null || schema === void 0 ? void 0 : schema.items) && ((_c = schema === null || schema === void 0 ? void 0 : schema.items) === null || _c === void 0 ? void 0 : _c.title) !== undefined ? ` [${(_d = schema === null || schema === void 0 ? void 0 : schema.items) === null || _d === void 0 ? void 0 : _d.title}] ` : null),
|
|
3111
|
-
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && (React__default.createElement(Box, { display: "inline-flex", alignItems: "center", ml: 1, style: {
|
|
3112
|
-
opacity: isHoveringSelector ? 1 : 0.6,
|
|
3113
|
-
transition: 'opacity 0.2s',
|
|
3114
|
-
} },
|
|
3115
|
-
React__default.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
|
|
3116
|
-
fontSize: '10px',
|
|
3117
|
-
opacity: 0.6,
|
|
3118
|
-
} })))),
|
|
3119
|
-
React__default.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null),
|
|
3120
|
-
((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
|
|
3121
|
-
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
|
|
3122
|
-
(schema === null || schema === void 0 ? void 0 : schema.description) && (React__default.createElement(Box, { fontFamily: "ui", fontWeight: "light" },
|
|
3123
|
-
React__default.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
|
|
3124
|
-
!isRoot && (schema === null || schema === void 0 ? void 0 : schema.examples) !== undefined && (React__default.createElement(Flex, { align: "center", mb: 1, style: { flexWrap: 'wrap' } },
|
|
3125
|
-
React__default.createElement("span", { className: "text-gray-500", style: { marginRight: 8, flexShrink: 0 } }, "Example"),
|
|
3126
|
-
React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: {
|
|
3127
|
-
background: 'rgba(245, 247, 250, 0.5)',
|
|
3128
|
-
border: '1px solid #a0aec0',
|
|
3129
|
-
borderRadius: '4px',
|
|
3130
|
-
padding: '4px 8px',
|
|
3131
|
-
display: 'inline-block',
|
|
3132
|
-
overflowWrap: 'break-word',
|
|
3133
|
-
textAlign: 'left',
|
|
3134
|
-
maxWidth: '530px',
|
|
3135
|
-
} }, JSON.stringify(schema === null || schema === void 0 ? void 0 : schema.examples))))),
|
|
3136
|
-
React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } }, schema &&
|
|
3137
|
-
typeof schema === 'object' &&
|
|
3138
|
-
('minItems' in schema || 'enum' in schema) &&
|
|
3139
|
-
renderMinEnums(schema))),
|
|
3140
|
-
!isRoot && (React__default.createElement("label", { className: "inline-flex items-top ml-2" },
|
|
3141
|
-
React__default.createElement(Box, { mr: 2, fontFamily: "ui", fontWeight: "normal" }, showRequiredLabel && (React__default.createElement("div", { className: "sl-ml-2 sl-text-warning" },
|
|
3142
|
-
React__default.createElement("span", { style: { marginLeft: '10px' } }, "required"))))))),
|
|
3143
|
-
renderChildren()));
|
|
3144
|
-
};
|
|
3145
|
-
|
|
3146
2741
|
const isBodyEmpty = (body) => {
|
|
3147
2742
|
if (!body)
|
|
3148
2743
|
return true;
|
|
3149
2744
|
const { contents = [], description } = body;
|
|
3150
2745
|
return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
|
|
3151
2746
|
};
|
|
3152
|
-
const Body = ({ body, onChange, isHttpWebhookOperation = false
|
|
2747
|
+
const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
|
|
3153
2748
|
var _a;
|
|
3154
2749
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3155
2750
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
@@ -3162,36 +2757,13 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
|
|
|
3162
2757
|
const { contents = [], description } = body;
|
|
3163
2758
|
const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
|
|
3164
2759
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: body.id, attr: 'description' });
|
|
3165
|
-
const getMaskProperties = () => {
|
|
3166
|
-
const disablePropsConfig = disableProps || [];
|
|
3167
|
-
const absolutePathsToHide = [];
|
|
3168
|
-
disablePropsConfig.forEach(configEntry => {
|
|
3169
|
-
const { location, paths, isComplex } = configEntry;
|
|
3170
|
-
if (paths.length === 0 && !isComplex) {
|
|
3171
|
-
absolutePathsToHide.push({ path: location });
|
|
3172
|
-
}
|
|
3173
|
-
else {
|
|
3174
|
-
paths.forEach((item) => {
|
|
3175
|
-
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3176
|
-
let object = { path: fullPath };
|
|
3177
|
-
if (item.hasOwnProperty('required')) {
|
|
3178
|
-
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3179
|
-
}
|
|
3180
|
-
absolutePathsToHide.push(object);
|
|
3181
|
-
});
|
|
3182
|
-
}
|
|
3183
|
-
});
|
|
3184
|
-
return absolutePathsToHide;
|
|
3185
|
-
};
|
|
3186
|
-
const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
|
|
3187
|
-
console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
|
|
3188
2760
|
return (React.createElement(VStack, { spacing: 6 },
|
|
3189
2761
|
React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
|
|
3190
2762
|
React.createElement(Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
|
|
3191
2763
|
description && (React.createElement(Box, { pos: "relative" },
|
|
3192
2764
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
3193
2765
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3194
|
-
|
|
2766
|
+
isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
|
|
3195
2767
|
};
|
|
3196
2768
|
Body.displayName = 'HttpOperation.Body';
|
|
3197
2769
|
|
|
@@ -3258,7 +2830,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
3258
2830
|
return schema;
|
|
3259
2831
|
};
|
|
3260
2832
|
|
|
3261
|
-
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false,
|
|
2833
|
+
const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
|
|
3262
2834
|
if (!request || typeof request !== 'object')
|
|
3263
2835
|
return null;
|
|
3264
2836
|
const bodyIsEmpty = isBodyEmpty(body);
|
|
@@ -3286,7 +2858,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
|
|
|
3286
2858
|
cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
|
|
3287
2859
|
React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
|
|
3288
2860
|
React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
|
|
3289
|
-
body &&
|
|
2861
|
+
body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
|
|
3290
2862
|
};
|
|
3291
2863
|
Request.displayName = 'HttpOperation.Request';
|
|
3292
2864
|
const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
|
|
@@ -3317,7 +2889,7 @@ const OptionalMessage$1 = () => {
|
|
|
3317
2889
|
return React.createElement(Callout, { appearance: "outline" }, OptionalSecurityMessage);
|
|
3318
2890
|
};
|
|
3319
2891
|
|
|
3320
|
-
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact,
|
|
2892
|
+
const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
|
|
3321
2893
|
var _a, _b;
|
|
3322
2894
|
const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
|
|
3323
2895
|
const [activeResponseId, setActiveResponseId] = React.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
|
|
@@ -3350,12 +2922,11 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
3350
2922
|
const tabResponses = (React.createElement(TabList, { density: "compact" }, responses.map(({ code }) => (React.createElement(Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code)))));
|
|
3351
2923
|
return (React.createElement(VStack, { spacing: 8, as: Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
|
|
3352
2924
|
React.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
|
|
3353
|
-
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange
|
|
3354
|
-
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange
|
|
2925
|
+
isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
|
|
2926
|
+
React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
|
|
3355
2927
|
};
|
|
3356
2928
|
Responses.displayName = 'HttpOperation.Responses';
|
|
3357
|
-
const Response = ({ response, onMediaTypeChange
|
|
3358
|
-
var _a, _b;
|
|
2929
|
+
const Response = ({ response, onMediaTypeChange }) => {
|
|
3359
2930
|
const { contents = [], headers = [], description } = response;
|
|
3360
2931
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
3361
2932
|
const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
|
|
@@ -3366,29 +2937,6 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
|
|
|
3366
2937
|
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
3367
2938
|
}, [responseContent]);
|
|
3368
2939
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
3369
|
-
const getMaskProperties = () => {
|
|
3370
|
-
if (!disableProps || !statusCode)
|
|
3371
|
-
return [];
|
|
3372
|
-
const configEntries = disableProps[statusCode] || [];
|
|
3373
|
-
const absolutePathsToHide = [];
|
|
3374
|
-
configEntries.forEach(({ location, paths, isComplex }) => {
|
|
3375
|
-
if (paths.length === 0 && !isComplex) {
|
|
3376
|
-
absolutePathsToHide.push({ path: location });
|
|
3377
|
-
}
|
|
3378
|
-
else {
|
|
3379
|
-
paths.forEach((item) => {
|
|
3380
|
-
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3381
|
-
let object = { path: fullPath };
|
|
3382
|
-
if (item.hasOwnProperty('required')) {
|
|
3383
|
-
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3384
|
-
}
|
|
3385
|
-
absolutePathsToHide.push(object);
|
|
3386
|
-
});
|
|
3387
|
-
}
|
|
3388
|
-
});
|
|
3389
|
-
return absolutePathsToHide;
|
|
3390
|
-
};
|
|
3391
|
-
const shouldUseLazySchema = (_b = (statusCode && ((_a = disableProps === null || disableProps === void 0 ? void 0 : disableProps[statusCode]) === null || _a === void 0 ? void 0 : _a.some(entry => entry.isComplex)))) !== null && _b !== void 0 ? _b : false;
|
|
3392
2940
|
return (React.createElement(VStack, { spacing: 8, pt: 8 },
|
|
3393
2941
|
description && (React.createElement(Box, { pos: "relative" },
|
|
3394
2942
|
React.createElement(MarkdownViewer, { markdown: description }),
|
|
@@ -3400,7 +2948,7 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
|
|
|
3400
2948
|
React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
|
|
3401
2949
|
React.createElement(Flex, { flex: 1, justify: "end" },
|
|
3402
2950
|
React.createElement(Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
|
|
3403
|
-
schema &&
|
|
2951
|
+
schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
|
|
3404
2952
|
};
|
|
3405
2953
|
Response.displayName = 'HttpOperation.Response';
|
|
3406
2954
|
const codeToIntentVal = (code) => {
|
|
@@ -3449,7 +2997,7 @@ const Callback = ({ data, isCompact }) => {
|
|
|
3449
2997
|
};
|
|
3450
2998
|
Callbacks.displayName = 'HttpOperation.Callback';
|
|
3451
2999
|
|
|
3452
|
-
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy
|
|
3000
|
+
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
3453
3001
|
var _a;
|
|
3454
3002
|
const { nodeHasChanged } = useOptionsCtx();
|
|
3455
3003
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3480,11 +3028,11 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
3480
3028
|
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
3481
3029
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3482
3030
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3483
|
-
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data)
|
|
3484
|
-
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact
|
|
3031
|
+
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
|
|
3032
|
+
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
3485
3033
|
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
|
|
3486
3034
|
isCompact && tryItPanel));
|
|
3487
|
-
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !
|
|
3035
|
+
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
3488
3036
|
});
|
|
3489
3037
|
HttpOperationComponent.displayName = 'HttpOperation.Component';
|
|
3490
3038
|
const HttpOperation = withErrorBoundary(HttpOperationComponent, {
|
|
@@ -3735,7 +3283,7 @@ const HttpServiceComponent = React.memo(({ data: unresolvedData, location = {},
|
|
|
3735
3283
|
HttpServiceComponent.displayName = 'HttpService.Component';
|
|
3736
3284
|
const HttpService = withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
|
|
3737
3285
|
|
|
3738
|
-
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps,
|
|
3286
|
+
const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
|
|
3739
3287
|
var _a, _b;
|
|
3740
3288
|
const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
|
|
3741
3289
|
const data = useResolvedObject(unresolvedData);
|
|
@@ -3758,40 +3306,14 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
3758
3306
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
3759
3307
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
|
3760
3308
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
|
|
3761
|
-
const getMaskProperties = () => {
|
|
3762
|
-
const disablePropsConfig = disableProps === null || disableProps === void 0 ? void 0 : disableProps.models;
|
|
3763
|
-
const absolutePathsToHide = [];
|
|
3764
|
-
if (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models) {
|
|
3765
|
-
disablePropsConfig.forEach((configEntry) => {
|
|
3766
|
-
const { location, paths, isComplex } = configEntry;
|
|
3767
|
-
if (paths.length === 0 && !isComplex) {
|
|
3768
|
-
absolutePathsToHide.push({ path: location });
|
|
3769
|
-
}
|
|
3770
|
-
else {
|
|
3771
|
-
paths.forEach((item) => {
|
|
3772
|
-
const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
|
|
3773
|
-
let object = { path: fullPath };
|
|
3774
|
-
if (item.hasOwnProperty('required')) {
|
|
3775
|
-
object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
|
|
3776
|
-
}
|
|
3777
|
-
absolutePathsToHide.push(object);
|
|
3778
|
-
});
|
|
3779
|
-
}
|
|
3780
|
-
});
|
|
3781
|
-
}
|
|
3782
|
-
return absolutePathsToHide;
|
|
3783
|
-
};
|
|
3784
|
-
const shouldUseLazySchema = disableProps && (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models)
|
|
3785
|
-
? disableProps.models.some((entry) => entry.isComplex === true)
|
|
3786
|
-
: false;
|
|
3787
3309
|
const description = (React.createElement(VStack, { spacing: 10 },
|
|
3788
3310
|
data.description && data.type === 'object' && (React.createElement(Box, { pos: "relative" },
|
|
3789
3311
|
React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
|
|
3790
3312
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
3791
3313
|
React.createElement(NodeVendorExtensions, { data: data }),
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !
|
|
3314
|
+
isCompact && modelExamples,
|
|
3315
|
+
React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
|
|
3316
|
+
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
|
|
3795
3317
|
};
|
|
3796
3318
|
const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
|
|
3797
3319
|
var _a;
|
|
@@ -3813,41 +3335,30 @@ const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
|
|
|
3813
3335
|
|
|
3814
3336
|
const Docs = React.memo((_a) => {
|
|
3815
3337
|
var _b;
|
|
3816
|
-
var { nodeType, nodeData,
|
|
3338
|
+
var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
|
|
3817
3339
|
const parsedNode = useParsedData(nodeType, nodeData);
|
|
3818
3340
|
if (!parsedNode) {
|
|
3819
3341
|
(_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
|
|
3820
3342
|
return null;
|
|
3821
3343
|
}
|
|
3822
|
-
let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode
|
|
3344
|
+
let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
|
|
3823
3345
|
if (useNodeForRefResolving) {
|
|
3824
3346
|
elem = (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
|
|
3825
3347
|
}
|
|
3826
3348
|
return (React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
|
|
3827
3349
|
});
|
|
3828
|
-
const getTryItVisibility = (disableProps) => {
|
|
3829
|
-
var _a, _b, _c, _d;
|
|
3830
|
-
if (!disableProps)
|
|
3831
|
-
return { hideOperationTryIt: false, hideModelTryIt: false };
|
|
3832
|
-
const requestHasComplex = (_b = (_a = disableProps.request) === null || _a === void 0 ? void 0 : _a.some(item => item.isComplex)) !== null && _b !== void 0 ? _b : false;
|
|
3833
|
-
const responseHasComplex = Object.values(disableProps.response || {}).some(arr => arr.some(item => item.isComplex));
|
|
3834
|
-
const hideOperationTryIt = requestHasComplex || responseHasComplex;
|
|
3835
|
-
const hideModelTryIt = (_d = (_c = disableProps.models) === null || _c === void 0 ? void 0 : _c.some(item => item.isComplex)) !== null && _d !== void 0 ? _d : false;
|
|
3836
|
-
return { hideOperationTryIt, hideModelTryIt };
|
|
3837
|
-
};
|
|
3838
3350
|
const ParsedDocs = (_a) => {
|
|
3839
|
-
var { node, nodeUnsupported
|
|
3840
|
-
const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
|
|
3351
|
+
var { node, nodeUnsupported } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported"]);
|
|
3841
3352
|
switch (node.type) {
|
|
3842
3353
|
case 'article':
|
|
3843
3354
|
return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
|
|
3844
3355
|
case 'http_operation':
|
|
3845
3356
|
case 'http_webhook':
|
|
3846
|
-
return React.createElement(HttpOperation, Object.assign({ data: node.data
|
|
3357
|
+
return React.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
|
|
3847
3358
|
case 'http_service':
|
|
3848
3359
|
return React.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
|
|
3849
3360
|
case 'model':
|
|
3850
|
-
return React.createElement(Model, Object.assign({ data: node.data
|
|
3361
|
+
return React.createElement(Model, Object.assign({ data: node.data }, commonProps));
|
|
3851
3362
|
default:
|
|
3852
3363
|
nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
|
|
3853
3364
|
return null;
|
|
@@ -3985,7 +3496,7 @@ function findFirstNode(items) {
|
|
|
3985
3496
|
return;
|
|
3986
3497
|
}
|
|
3987
3498
|
function isDivider(item) {
|
|
3988
|
-
return Object.keys(item).length ===
|
|
3499
|
+
return Object.keys(item).length === 2 && 'title' in item && 'index' in item;
|
|
3989
3500
|
}
|
|
3990
3501
|
function isGroup(item) {
|
|
3991
3502
|
return Object.keys(item).length >= 2 && 'title' in item && 'items' in item;
|
|
@@ -3997,13 +3508,33 @@ function isNode(item) {
|
|
|
3997
3508
|
return 'title' in item && 'slug' in item && 'id' in item && 'meta' in item && 'type' in item;
|
|
3998
3509
|
}
|
|
3999
3510
|
function isExternalLink(item) {
|
|
4000
|
-
return Object.keys(item).length ===
|
|
3511
|
+
return Object.keys(item).length === 3 && 'title' in item && 'url' in item && 'index' in item;
|
|
4001
3512
|
}
|
|
4002
3513
|
|
|
4003
|
-
const
|
|
3514
|
+
const ActiveItemContext = React.createContext({
|
|
3515
|
+
activeId: undefined,
|
|
3516
|
+
lastActiveIndex: '',
|
|
3517
|
+
setLastActiveIndex: () => { },
|
|
3518
|
+
});
|
|
4004
3519
|
const LinkContext = React.createContext(undefined);
|
|
4005
3520
|
LinkContext.displayName = 'LinkContext';
|
|
4006
3521
|
const TableOfContents = React.memo(({ tree, activeId, Link, maxDepthOpenByDefault, externalScrollbar = false, isInResponsiveMode = false, onLinkClick, }) => {
|
|
3522
|
+
const [lastActiveIndex, setLastActiveIndex] = useState('');
|
|
3523
|
+
const value = React.useMemo(() => ({
|
|
3524
|
+
lastActiveIndex,
|
|
3525
|
+
setLastActiveIndex,
|
|
3526
|
+
activeId,
|
|
3527
|
+
}), [lastActiveIndex, activeId]);
|
|
3528
|
+
const updateTocTree = React.useCallback((arr, parentId) => {
|
|
3529
|
+
return arr.map((item, key) => {
|
|
3530
|
+
let newItem = Object.assign(Object.assign({}, item), { index: parentId + key + '-' });
|
|
3531
|
+
if (isGroup(item) || isNodeGroup(item)) {
|
|
3532
|
+
newItem.items = updateTocTree(item.items, parentId + key + '-');
|
|
3533
|
+
}
|
|
3534
|
+
return newItem;
|
|
3535
|
+
});
|
|
3536
|
+
}, []);
|
|
3537
|
+
const updatedTree = updateTocTree(tree, '');
|
|
4007
3538
|
const container = React.useRef(null);
|
|
4008
3539
|
const child = React.useRef(null);
|
|
4009
3540
|
const firstRender = useFirstRender();
|
|
@@ -4023,18 +3554,30 @@ const TableOfContents = React.memo(({ tree, activeId, Link, maxDepthOpenByDefaul
|
|
|
4023
3554
|
return (React.createElement(Box, { ref: container, w: "full", bg: isInResponsiveMode ? 'canvas' : 'canvas-100', overflowY: "auto" },
|
|
4024
3555
|
React.createElement(Box, { ref: child, my: 3 },
|
|
4025
3556
|
React.createElement(LinkContext.Provider, { value: Link },
|
|
4026
|
-
React.createElement(
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
3557
|
+
React.createElement(ActiveItemContext.Provider, { value: value },
|
|
3558
|
+
React.createElement(TOCContainer, { updatedTree: updatedTree }, updatedTree.map((item, key) => {
|
|
3559
|
+
if (isDivider(item)) {
|
|
3560
|
+
return React.createElement(Divider, { key: key, item: item, isInResponsiveMode: isInResponsiveMode });
|
|
3561
|
+
}
|
|
3562
|
+
return (React.createElement(GroupItem, { key: key, item: item, depth: 0, maxDepthOpenByDefault: maxDepthOpenByDefault, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode }));
|
|
3563
|
+
})))))));
|
|
4032
3564
|
});
|
|
4033
3565
|
TableOfContents.displayName = 'TableOfContents';
|
|
4034
3566
|
const Divider = React.memo(({ item, isInResponsiveMode = false }) => {
|
|
4035
3567
|
return (React.createElement(Box, { pl: 4, mb: 2, mt: 6, textTransform: "uppercase", fontSize: isInResponsiveMode ? 'lg' : 'sm', lineHeight: "relaxed", letterSpacing: "wide", fontWeight: "bold" }, item.title));
|
|
4036
3568
|
});
|
|
4037
3569
|
Divider.displayName = 'Divider';
|
|
3570
|
+
const TOCContainer = React.memo(({ children, updatedTree }) => {
|
|
3571
|
+
const { setLastActiveIndex } = React.useContext(ActiveItemContext);
|
|
3572
|
+
React.useEffect(() => {
|
|
3573
|
+
const firstNode = findFirstNode(updatedTree);
|
|
3574
|
+
if (firstNode) {
|
|
3575
|
+
setLastActiveIndex(firstNode.index);
|
|
3576
|
+
}
|
|
3577
|
+
}, []);
|
|
3578
|
+
return React.createElement(Box, null, children);
|
|
3579
|
+
});
|
|
3580
|
+
TOCContainer.displayName = 'TOCContainer';
|
|
4038
3581
|
const GroupItem = React.memo(({ item, depth, maxDepthOpenByDefault, isInResponsiveMode, onLinkClick }) => {
|
|
4039
3582
|
if (isExternalLink(item)) {
|
|
4040
3583
|
return (React.createElement(Box, { as: "a", href: item.url, target: "_blank", rel: "noopener noreferrer", display: "block" },
|
|
@@ -4052,9 +3595,24 @@ const GroupItem = React.memo(({ item, depth, maxDepthOpenByDefault, isInResponsi
|
|
|
4052
3595
|
});
|
|
4053
3596
|
GroupItem.displayName = 'GroupItem';
|
|
4054
3597
|
const Group = React.memo(({ depth, item, maxDepthOpenByDefault, isInResponsiveMode, onLinkClick = () => { } }) => {
|
|
4055
|
-
const activeId = React.useContext(
|
|
3598
|
+
const { activeId, lastActiveIndex } = React.useContext(ActiveItemContext);
|
|
4056
3599
|
const [isOpen, setIsOpen] = React.useState(() => isGroupOpenByDefault(depth, item, activeId, maxDepthOpenByDefault));
|
|
4057
|
-
const
|
|
3600
|
+
const isActiveGroup = React.useCallback((items, activeId, contextIndex) => {
|
|
3601
|
+
return items.some(element => {
|
|
3602
|
+
const hasSlugOrId = 'slug' in element || 'id' in element;
|
|
3603
|
+
const hasItems = 'items' in element && Array.isArray(element.items);
|
|
3604
|
+
if (!hasSlugOrId && !hasItems)
|
|
3605
|
+
return false;
|
|
3606
|
+
if (activeId &&
|
|
3607
|
+
'index' in element &&
|
|
3608
|
+
(element.slug === activeId || element.id === activeId) &&
|
|
3609
|
+
element.index === contextIndex) {
|
|
3610
|
+
return true;
|
|
3611
|
+
}
|
|
3612
|
+
return hasItems ? isActiveGroup(element.items, activeId, contextIndex) : false;
|
|
3613
|
+
});
|
|
3614
|
+
}, []);
|
|
3615
|
+
const hasActive = isActiveGroup(item.items, activeId, lastActiveIndex);
|
|
4058
3616
|
React.useEffect(() => {
|
|
4059
3617
|
const openByDefault = isGroupOpenByDefault(depth, item, activeId, maxDepthOpenByDefault);
|
|
4060
3618
|
if (isOpen !== openByDefault) {
|
|
@@ -4104,8 +3662,10 @@ const Item = React.memo(({ depth, isActive, id, title, meta, icon, isInResponsiv
|
|
|
4104
3662
|
});
|
|
4105
3663
|
Item.displayName = 'Item';
|
|
4106
3664
|
const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode, onClick, onLinkClick = () => { } }) => {
|
|
4107
|
-
const activeId = React.useContext(
|
|
4108
|
-
const
|
|
3665
|
+
const { activeId, lastActiveIndex, setLastActiveIndex } = React.useContext(ActiveItemContext);
|
|
3666
|
+
const { index } = item;
|
|
3667
|
+
const isSlugMatched = activeId === item.slug || activeId === item.id;
|
|
3668
|
+
const isActive = lastActiveIndex === index && isSlugMatched;
|
|
4109
3669
|
const LinkComponent = React.useContext(LinkContext);
|
|
4110
3670
|
const handleClick = (e) => {
|
|
4111
3671
|
if (isActive) {
|
|
@@ -4113,6 +3673,7 @@ const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode,
|
|
|
4113
3673
|
e.preventDefault();
|
|
4114
3674
|
}
|
|
4115
3675
|
else {
|
|
3676
|
+
setLastActiveIndex(index);
|
|
4116
3677
|
onLinkClick();
|
|
4117
3678
|
}
|
|
4118
3679
|
if (onClick) {
|
|
@@ -4120,7 +3681,7 @@ const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode,
|
|
|
4120
3681
|
}
|
|
4121
3682
|
};
|
|
4122
3683
|
return (React.createElement(Box, { as: LinkComponent, to: resolveRelativeLink(item.slug), display: "block", textDecoration: "no-underline", className: "ElementsTableOfContentsItem" },
|
|
4123
|
-
React.createElement(Item, { id: getHtmlIdFromItemId(item.slug || item.id), isActive: isActive || showAsActive, depth: depth, title: item.title, icon: NODE_TYPE_TITLE_ICON[item.type] && (React.createElement(Box, { as: Icon, color: NODE_TYPE_ICON_COLOR[item.type], icon: NODE_TYPE_TITLE_ICON[item.type] })), meta: meta, isInResponsiveMode: isInResponsiveMode, onClick: handleClick })));
|
|
3684
|
+
React.createElement(Item, { id: getHtmlIdFromItemId(item.slug || item.id), isActive: isActive || showAsActive, depth: depth, title: item.title, icon: NODE_TYPE_TITLE_ICON[item.type] && (React.createElement(Box, { as: Icon, color: NODE_TYPE_ICON_COLOR[item.type], icon: NODE_TYPE_TITLE_ICON[item.type] })), meta: meta, isInResponsiveMode: isInResponsiveMode, onClick: e => handleClick(e) })));
|
|
4124
3685
|
});
|
|
4125
3686
|
Node.displayName = 'Node';
|
|
4126
3687
|
const Version = ({ value }) => {
|