docusaurus-theme-openapi-docs 3.0.0-beta.1 → 3.0.0-beta.10
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/lib/markdown/utils.d.ts +3 -2
- package/lib/markdown/utils.js +1 -1
- package/lib/markdown/utils.test.d.ts +1 -0
- package/lib/markdown/utils.test.js +43 -0
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.d.ts +13 -0
- package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +199 -124
- package/lib/theme/ApiExplorer/Accept/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +25 -19
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +27 -16
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +4 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +115 -96
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +115 -54
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +41 -30
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +200 -120
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +36 -24
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +35 -28
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +72 -14
- package/lib/theme/ApiExplorer/Authorization/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Body/index.js +8 -1
- package/lib/theme/ApiExplorer/Body/slice.d.ts +3 -3
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.d.ts +21 -0
- package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.js +8 -0
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +4 -14
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +86 -8
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +3 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +48 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.json +0 -96
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +18 -2
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +131 -76
- package/lib/theme/ApiExplorer/ContentType/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Export/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/lib/theme/ApiExplorer/FloatingButton/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/FormFileUpload/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/FormSelect/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -4
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +4 -2
- package/lib/theme/ApiExplorer/Request/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Request/makeRequest.js +50 -1
- package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/lib/theme/ApiExplorer/Response/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Response/index.js +19 -19
- package/lib/theme/ApiExplorer/SecuritySchemes/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Server/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
- package/lib/theme/ApiExplorer/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/index.js +1 -1
- package/lib/theme/ApiExplorer/storage-utils.d.ts +1 -1
- package/lib/theme/ApiItem/index.js +28 -3
- package/lib/theme/ApiItem/store.d.ts +6 -6
- package/lib/theme/ApiLogo/index.d.ts +2 -2
- package/lib/theme/ApiTabs/_ApiTabs.scss +3 -1
- package/lib/theme/ApiTabs/index.d.ts +7 -0
- package/lib/theme/ApiTabs/index.js +167 -103
- package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
- package/lib/theme/DiscriminatorTabs/index.js +152 -98
- package/lib/theme/Markdown/index.js +37 -0
- package/lib/theme/MimeTabs/index.d.ts +6 -0
- package/lib/theme/MimeTabs/index.js +169 -118
- package/lib/theme/OperationTabs/_OperationTabs.scss +71 -0
- package/lib/theme/OperationTabs/index.d.ts +3 -0
- package/lib/theme/OperationTabs/index.js +234 -0
- package/lib/theme/ParamsItem/index.d.ts +23 -0
- package/lib/theme/ParamsItem/index.js +170 -111
- package/lib/theme/ResponseSamples/index.d.ts +8 -0
- package/lib/theme/ResponseSamples/index.js +18 -13
- package/lib/theme/SchemaItem/index.d.ts +12 -0
- package/lib/theme/SchemaItem/index.js +121 -89
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/lib/theme/SchemaTabs/index.d.ts +3 -0
- package/lib/theme/SchemaTabs/index.js +148 -95
- package/lib/theme/styles.scss +5 -0
- package/lib/types.d.ts +4 -4
- package/package.json +8 -7
- package/src/markdown/utils.test.ts +49 -0
- package/src/markdown/utils.ts +5 -3
- package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +21 -8
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/{index.js → index.tsx} +6 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/{Element.js → Element.tsx} +5 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/{String.js → String.tsx} +4 -4
- package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/{index.js → index.tsx} +8 -3
- package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/{index.js → index.tsx} +9 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +12 -2
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/{index.js → index.tsx} +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/{index.js → index.tsx} +11 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/{index.js → index.tsx} +10 -5
- package/src/theme/ApiExplorer/Body/index.tsx +3 -1
- package/src/theme/ApiExplorer/CodeSnippets/code-snippets-types.ts +55 -0
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +94 -21
- package/src/theme/ApiExplorer/CodeSnippets/languages.json +0 -96
- package/src/theme/ApiExplorer/CodeSnippets/languages.ts +53 -0
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +18 -2
- package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +64 -25
- package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +4 -4
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/src/theme/ApiExplorer/Request/_Request.scss +4 -2
- package/src/theme/ApiExplorer/Request/makeRequest.ts +59 -4
- package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/src/theme/ApiExplorer/Response/index.tsx +2 -2
- package/src/theme/ApiExplorer/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +22 -3
- package/src/theme/ApiLogo/index.tsx +1 -1
- package/src/theme/ApiTabs/_ApiTabs.scss +3 -1
- package/src/theme/ApiTabs/{index.js → index.tsx} +75 -31
- package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +63 -28
- package/src/theme/Markdown/index.js +37 -0
- package/src/theme/MimeTabs/{index.js → index.tsx} +64 -30
- package/src/theme/OperationTabs/_OperationTabs.scss +71 -0
- package/src/theme/OperationTabs/index.tsx +218 -0
- package/src/theme/ParamsItem/{index.js → index.tsx} +48 -17
- package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
- package/src/theme/SchemaItem/{index.js → index.tsx} +24 -18
- package/src/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/src/theme/SchemaTabs/{index.js → index.tsx} +62 -29
- package/src/theme/styles.scss +5 -0
- package/src/theme-classic.d.ts +69 -2
- package/src/theme-openapi.d.ts +6 -0
- package/tsconfig.json +4 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare function SecuritySchemes(props: any): JSX.Element | null;
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare function SecuritySchemes(props: any): React.JSX.Element | null;
|
|
3
3
|
export default SecuritySchemes;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare function Server(): JSX.Element | null;
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare function Server(): React.JSX.Element | null;
|
|
3
3
|
export default Server;
|
|
@@ -2,7 +2,7 @@ import sdk from "@paloaltonetworks/postman-collection";
|
|
|
2
2
|
import { AuthState } from "@theme/ApiExplorer/Authorization/slice";
|
|
3
3
|
import { Body } from "@theme/ApiExplorer/Body/slice";
|
|
4
4
|
import { ParameterObject, ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
5
|
-
|
|
5
|
+
type Param = {
|
|
6
6
|
value?: string | string[];
|
|
7
7
|
} & ParameterObject;
|
|
8
8
|
interface Options {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
2
|
import { ApiItem } from "docusaurus-plugin-openapi-docs/src/types";
|
|
3
3
|
declare function ApiExplorer({ item, infoPath, }: {
|
|
4
4
|
item: NonNullable<ApiItem>;
|
|
5
5
|
infoPath: string;
|
|
6
|
-
}): JSX.Element;
|
|
6
|
+
}): React.JSX.Element;
|
|
7
7
|
export default ApiExplorer;
|
|
@@ -28,7 +28,7 @@ function ApiExplorer({ item, infoPath }) {
|
|
|
28
28
|
item.method !== "event" &&
|
|
29
29
|
react_1.default.createElement(CodeSnippets_1.default, {
|
|
30
30
|
postman: postman,
|
|
31
|
-
codeSamples: item["x-
|
|
31
|
+
codeSamples: item["x-codeSamples"] ?? [],
|
|
32
32
|
}),
|
|
33
33
|
react_1.default.createElement(Request_1.default, { item: item }),
|
|
34
34
|
react_1.default.createElement(Response_1.default, { item: item })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function hashArray(arr: string[]): string;
|
|
2
|
-
|
|
2
|
+
type Persistance = false | "localStorage" | "sessionStorage" | undefined;
|
|
3
3
|
export declare function createStorage(persistance: Persistance): Storage;
|
|
4
4
|
export {};
|
|
@@ -18,6 +18,7 @@ const ExecutionEnvironment_1 = __importDefault(
|
|
|
18
18
|
require("@docusaurus/ExecutionEnvironment")
|
|
19
19
|
);
|
|
20
20
|
const theme_common_1 = require("@docusaurus/theme-common");
|
|
21
|
+
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
21
22
|
const useDocusaurusContext_1 = __importDefault(
|
|
22
23
|
require("@docusaurus/useDocusaurusContext")
|
|
23
24
|
);
|
|
@@ -29,17 +30,18 @@ const Metadata_1 = __importDefault(require("@theme/DocItem/Metadata"));
|
|
|
29
30
|
const clsx_1 = __importDefault(require("clsx"));
|
|
30
31
|
const react_redux_1 = require("react-redux");
|
|
31
32
|
const store_1 = require("./store");
|
|
32
|
-
const { DocProvider } = require("@docusaurus/theme-common/internal");
|
|
33
33
|
let ApiExplorer = (_) => react_1.default.createElement("div", null);
|
|
34
34
|
if (ExecutionEnvironment_1.default.canUseDOM) {
|
|
35
35
|
ApiExplorer = require("@theme/ApiExplorer").default;
|
|
36
36
|
}
|
|
37
|
+
// @ts-ignore
|
|
37
38
|
function ApiItem(props) {
|
|
38
39
|
const docHtmlClassName = `docs-doc-id-${props.content.metadata.id}`;
|
|
39
40
|
const MDXComponent = props.content;
|
|
40
41
|
const { frontMatter } = MDXComponent;
|
|
41
42
|
const { info_path: infoPath } = frontMatter;
|
|
42
43
|
let { api } = frontMatter;
|
|
44
|
+
const { schema } = frontMatter;
|
|
43
45
|
// decompress and parse
|
|
44
46
|
if (api) {
|
|
45
47
|
api = JSON.parse(
|
|
@@ -118,7 +120,7 @@ function ApiItem(props) {
|
|
|
118
120
|
}
|
|
119
121
|
if (api) {
|
|
120
122
|
return react_1.default.createElement(
|
|
121
|
-
DocProvider,
|
|
123
|
+
internal_1.DocProvider,
|
|
122
124
|
{ content: props.content },
|
|
123
125
|
react_1.default.createElement(
|
|
124
126
|
theme_common_1.HtmlClassNameProvider,
|
|
@@ -163,10 +165,33 @@ function ApiItem(props) {
|
|
|
163
165
|
)
|
|
164
166
|
)
|
|
165
167
|
);
|
|
168
|
+
} else if (schema) {
|
|
169
|
+
return react_1.default.createElement(
|
|
170
|
+
internal_1.DocProvider,
|
|
171
|
+
{ content: props.content },
|
|
172
|
+
react_1.default.createElement(
|
|
173
|
+
theme_common_1.HtmlClassNameProvider,
|
|
174
|
+
{ className: docHtmlClassName },
|
|
175
|
+
react_1.default.createElement(Metadata_1.default, null),
|
|
176
|
+
react_1.default.createElement(
|
|
177
|
+
Layout_1.default,
|
|
178
|
+
null,
|
|
179
|
+
react_1.default.createElement(
|
|
180
|
+
"div",
|
|
181
|
+
{ className: (0, clsx_1.default)("row", "theme-api-markdown") },
|
|
182
|
+
react_1.default.createElement(
|
|
183
|
+
"div",
|
|
184
|
+
{ className: "col col--12" },
|
|
185
|
+
react_1.default.createElement(MDXComponent, null)
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
)
|
|
189
|
+
)
|
|
190
|
+
);
|
|
166
191
|
}
|
|
167
192
|
// Non-API docs
|
|
168
193
|
return react_1.default.createElement(
|
|
169
|
-
DocProvider,
|
|
194
|
+
internal_1.DocProvider,
|
|
170
195
|
{ content: props.content },
|
|
171
196
|
react_1.default.createElement(
|
|
172
197
|
theme_common_1.HtmlClassNameProvider,
|
|
@@ -7,8 +7,8 @@ declare const rootReducer: import("redux").Reducer<import("redux").CombinedState
|
|
|
7
7
|
params: unknown;
|
|
8
8
|
auth: unknown;
|
|
9
9
|
}>, import("redux").Action<any>>;
|
|
10
|
-
export
|
|
11
|
-
export declare const createStoreWithState: (preloadedState: RootState, middlewares: any[]) => import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("redux").
|
|
10
|
+
export type RootState = ReturnType<typeof rootReducer>;
|
|
11
|
+
export declare const createStoreWithState: (preloadedState: RootState, middlewares: any[]) => import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("redux").EmptyObject & {
|
|
12
12
|
accept: unknown;
|
|
13
13
|
contentType: unknown;
|
|
14
14
|
response: unknown;
|
|
@@ -16,7 +16,7 @@ export declare const createStoreWithState: (preloadedState: RootState, middlewar
|
|
|
16
16
|
body: unknown;
|
|
17
17
|
params: unknown;
|
|
18
18
|
auth: unknown;
|
|
19
|
-
}
|
|
19
|
+
}, import("redux").Action<any>, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ThunkMiddleware<import("redux").CombinedState<{
|
|
20
20
|
accept: unknown;
|
|
21
21
|
contentType: unknown;
|
|
22
22
|
response: unknown;
|
|
@@ -25,7 +25,7 @@ export declare const createStoreWithState: (preloadedState: RootState, middlewar
|
|
|
25
25
|
params: unknown;
|
|
26
26
|
auth: unknown;
|
|
27
27
|
}>, import("redux").AnyAction, undefined>, ...any[]]>>;
|
|
28
|
-
export declare const createStoreWithoutState: (preloadedState: {}, middlewares: any[]) => import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("redux").
|
|
28
|
+
export declare const createStoreWithoutState: (preloadedState: {}, middlewares: any[]) => import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<import("redux").EmptyObject & {
|
|
29
29
|
accept: unknown;
|
|
30
30
|
contentType: unknown;
|
|
31
31
|
response: unknown;
|
|
@@ -33,7 +33,7 @@ export declare const createStoreWithoutState: (preloadedState: {}, middlewares:
|
|
|
33
33
|
body: unknown;
|
|
34
34
|
params: unknown;
|
|
35
35
|
auth: unknown;
|
|
36
|
-
}
|
|
36
|
+
}, import("redux").Action<any>, import("@reduxjs/toolkit").MiddlewareArray<[import("@reduxjs/toolkit").ThunkMiddleware<import("redux").CombinedState<{
|
|
37
37
|
accept: unknown;
|
|
38
38
|
contentType: unknown;
|
|
39
39
|
response: unknown;
|
|
@@ -42,5 +42,5 @@ export declare const createStoreWithoutState: (preloadedState: {}, middlewares:
|
|
|
42
42
|
params: unknown;
|
|
43
43
|
auth: unknown;
|
|
44
44
|
}>, import("redux").AnyAction, undefined>, ...any[]]>>;
|
|
45
|
-
export
|
|
45
|
+
export type AppDispatch = ReturnType<typeof createStoreWithState>["dispatch"];
|
|
46
46
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default function ApiLogo(props: any): JSX.Element | undefined;
|
|
1
|
+
import React from "react";
|
|
2
|
+
export default function ApiLogo(props: any): React.JSX.Element | undefined;
|
|
@@ -1,25 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/* ============================================================================
|
|
2
3
|
* Copyright (c) Palo Alto Networks
|
|
3
4
|
*
|
|
4
5
|
* This source code is licensed under the MIT license found in the
|
|
5
6
|
* LICENSE file in the root directory of this source tree.
|
|
6
7
|
* ========================================================================== */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
var __createBinding =
|
|
9
|
+
(this && this.__createBinding) ||
|
|
10
|
+
(Object.create
|
|
11
|
+
? function (o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (
|
|
15
|
+
!desc ||
|
|
16
|
+
("get" in desc ? !m.__esModule : desc.writable || desc.configurable)
|
|
17
|
+
) {
|
|
18
|
+
desc = {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return m[k];
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}
|
|
27
|
+
: function (o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
});
|
|
31
|
+
var __setModuleDefault =
|
|
32
|
+
(this && this.__setModuleDefault) ||
|
|
33
|
+
(Object.create
|
|
34
|
+
? function (o, v) {
|
|
35
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
36
|
+
}
|
|
37
|
+
: function (o, v) {
|
|
38
|
+
o["default"] = v;
|
|
39
|
+
});
|
|
40
|
+
var __importStar =
|
|
41
|
+
(this && this.__importStar) ||
|
|
42
|
+
function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null)
|
|
46
|
+
for (var k in mod)
|
|
47
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
|
48
|
+
__createBinding(result, mod, k);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
var __importDefault =
|
|
53
|
+
(this && this.__importDefault) ||
|
|
54
|
+
function (mod) {
|
|
55
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
58
|
+
const react_1 = __importStar(require("react"));
|
|
59
|
+
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
60
|
+
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
61
|
+
const Heading_1 = __importDefault(require("@theme/Heading"));
|
|
62
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
63
|
+
function TabList({
|
|
64
|
+
className,
|
|
65
|
+
block,
|
|
66
|
+
selectedValue,
|
|
67
|
+
selectValue,
|
|
68
|
+
tabValues,
|
|
69
|
+
label = "Responses",
|
|
70
|
+
id = "responses",
|
|
71
|
+
}) {
|
|
19
72
|
const tabRefs = [];
|
|
20
|
-
const { blockElementScrollPositionUntilNextRender } =
|
|
21
|
-
|
|
22
|
-
|
|
73
|
+
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
74
|
+
internal_1.useScrollPositionBlocker)();
|
|
23
75
|
const handleTabChange = (event) => {
|
|
24
76
|
const newTab = event.currentTarget;
|
|
25
77
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -29,7 +81,6 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
29
81
|
selectValue(newTabValue);
|
|
30
82
|
}
|
|
31
83
|
};
|
|
32
|
-
|
|
33
84
|
const handleKeydown = (event) => {
|
|
34
85
|
let focusElement = null;
|
|
35
86
|
switch (event.key) {
|
|
@@ -52,141 +103,154 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
52
103
|
}
|
|
53
104
|
focusElement?.focus();
|
|
54
105
|
};
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
106
|
+
const tabItemListContainerRef = (0, react_1.useRef)(null);
|
|
107
|
+
const [showTabArrows, setShowTabArrows] = (0, react_1.useState)(false);
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
60
109
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
61
110
|
for (let entry of entries) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
111
|
+
requestAnimationFrame(() => {
|
|
112
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
113
|
+
setShowTabArrows(true);
|
|
114
|
+
} else {
|
|
115
|
+
setShowTabArrows(false);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
67
118
|
}
|
|
68
119
|
});
|
|
69
|
-
|
|
70
120
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
71
|
-
|
|
72
121
|
return () => {
|
|
73
122
|
resizeObserver.disconnect();
|
|
74
123
|
};
|
|
75
124
|
}, []);
|
|
76
|
-
|
|
77
125
|
const handleRightClick = () => {
|
|
78
126
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
79
127
|
};
|
|
80
|
-
|
|
81
128
|
const handleLeftClick = () => {
|
|
82
129
|
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
83
130
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
className
|
|
131
|
+
return react_1.default.createElement(
|
|
132
|
+
"div",
|
|
133
|
+
{ className: "openapi-tabs__response-header-section" },
|
|
134
|
+
react_1.default.createElement(
|
|
135
|
+
Heading_1.default,
|
|
136
|
+
{
|
|
137
|
+
as: "h2",
|
|
138
|
+
id: id,
|
|
139
|
+
className: "openapi-tabs__heading openapi-tabs__response-header",
|
|
140
|
+
},
|
|
141
|
+
label
|
|
142
|
+
),
|
|
143
|
+
react_1.default.createElement(
|
|
144
|
+
"div",
|
|
145
|
+
{ className: "openapi-tabs__response-container" },
|
|
146
|
+
showTabArrows &&
|
|
147
|
+
react_1.default.createElement("button", {
|
|
148
|
+
className: "openapi-tabs__arrow left",
|
|
149
|
+
onClick: handleLeftClick,
|
|
150
|
+
}),
|
|
151
|
+
react_1.default.createElement(
|
|
152
|
+
"ul",
|
|
153
|
+
{
|
|
154
|
+
ref: tabItemListContainerRef,
|
|
155
|
+
role: "tablist",
|
|
156
|
+
"aria-orientation": "horizontal",
|
|
157
|
+
className: (0, clsx_1.default)(
|
|
102
158
|
"openapi-tabs__response-list-container",
|
|
103
159
|
"tabs",
|
|
104
160
|
{
|
|
105
161
|
"tabs--block": block,
|
|
106
162
|
},
|
|
107
163
|
className
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
tabValues.map(({ value, label, attributes }) =>
|
|
167
|
+
react_1.default.createElement(
|
|
168
|
+
"li",
|
|
169
|
+
{
|
|
112
170
|
// TODO extract TabListItem
|
|
113
|
-
role
|
|
114
|
-
tabIndex
|
|
115
|
-
aria-selected
|
|
116
|
-
key
|
|
117
|
-
ref
|
|
118
|
-
onKeyDown
|
|
119
|
-
onClick
|
|
120
|
-
|
|
121
|
-
className
|
|
171
|
+
role: "tab",
|
|
172
|
+
tabIndex: selectedValue === value ? 0 : -1,
|
|
173
|
+
"aria-selected": selectedValue === value,
|
|
174
|
+
key: value,
|
|
175
|
+
ref: (tabControl) => tabRefs.push(tabControl),
|
|
176
|
+
onKeyDown: handleKeydown,
|
|
177
|
+
onClick: handleTabChange,
|
|
178
|
+
...attributes,
|
|
179
|
+
className: (0, clsx_1.default)(
|
|
122
180
|
"tabs__item",
|
|
123
181
|
"openapi-tabs__response-code-item",
|
|
124
182
|
attributes?.className,
|
|
125
183
|
parseInt(value) >= 400
|
|
126
184
|
? "danger"
|
|
127
185
|
: parseInt(value) >= 200 && parseInt(value) < 300
|
|
128
|
-
|
|
129
|
-
|
|
186
|
+
? "success"
|
|
187
|
+
: "info",
|
|
130
188
|
{
|
|
131
189
|
active: selectedValue === value,
|
|
132
190
|
}
|
|
133
|
-
)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
</div>
|
|
146
|
-
</div>
|
|
191
|
+
),
|
|
192
|
+
},
|
|
193
|
+
label ?? value
|
|
194
|
+
)
|
|
195
|
+
)
|
|
196
|
+
),
|
|
197
|
+
showTabArrows &&
|
|
198
|
+
react_1.default.createElement("button", {
|
|
199
|
+
className: "openapi-tabs__arrow right",
|
|
200
|
+
onClick: handleRightClick,
|
|
201
|
+
})
|
|
202
|
+
)
|
|
147
203
|
);
|
|
148
204
|
}
|
|
149
205
|
function TabContent({ lazy, children, selectedValue }) {
|
|
150
|
-
|
|
151
|
-
|
|
206
|
+
const childTabs = (Array.isArray(children) ? children : [children]).filter(
|
|
207
|
+
Boolean
|
|
208
|
+
);
|
|
152
209
|
if (lazy) {
|
|
153
|
-
const selectedTabItem =
|
|
210
|
+
const selectedTabItem = childTabs.find(
|
|
154
211
|
(tabItem) => tabItem.props.value === selectedValue
|
|
155
212
|
);
|
|
156
213
|
if (!selectedTabItem) {
|
|
157
214
|
// fail-safe or fail-fast? not sure what's best here
|
|
158
215
|
return null;
|
|
159
216
|
}
|
|
160
|
-
return cloneElement(selectedTabItem, {
|
|
217
|
+
return (0, react_1.cloneElement)(selectedTabItem, {
|
|
218
|
+
className: "margin-top--md",
|
|
219
|
+
});
|
|
161
220
|
}
|
|
162
|
-
return (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)
|
|
170
|
-
|
|
221
|
+
return react_1.default.createElement(
|
|
222
|
+
"div",
|
|
223
|
+
{ className: "margin-top--md" },
|
|
224
|
+
childTabs.map((tabItem, i) =>
|
|
225
|
+
(0, react_1.cloneElement)(tabItem, {
|
|
226
|
+
key: i,
|
|
227
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
228
|
+
})
|
|
229
|
+
)
|
|
171
230
|
);
|
|
172
231
|
}
|
|
173
232
|
function TabsComponent(props) {
|
|
174
|
-
const tabs = useTabs(props);
|
|
175
|
-
return (
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
233
|
+
const tabs = (0, internal_1.useTabs)(props);
|
|
234
|
+
return react_1.default.createElement(
|
|
235
|
+
"div",
|
|
236
|
+
{ className: "openapi-tabs__container" },
|
|
237
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
238
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
180
239
|
);
|
|
181
240
|
}
|
|
182
|
-
|
|
183
|
-
const isBrowser =
|
|
184
|
-
return (
|
|
185
|
-
|
|
241
|
+
function ApiTabs(props) {
|
|
242
|
+
const isBrowser = (0, useIsBrowser_1.default)();
|
|
243
|
+
return react_1.default.createElement(
|
|
244
|
+
TabsComponent,
|
|
245
|
+
// Remount tabs after hydration
|
|
246
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
247
|
+
{
|
|
186
248
|
// Remount tabs after hydration
|
|
187
249
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
188
|
-
key
|
|
189
|
-
|
|
190
|
-
|
|
250
|
+
key: String(isBrowser),
|
|
251
|
+
...props,
|
|
252
|
+
},
|
|
253
|
+
(0, internal_1.sanitizeTabsChildren)(props.children)
|
|
191
254
|
);
|
|
192
255
|
}
|
|
256
|
+
exports.default = ApiTabs;
|