docusaurus-theme-openapi-docs 0.0.0-740 → 0.0.0-750
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 +2 -1
- 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 +116 -97
- 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 +201 -121
- 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/Body/slice.d.ts +8 -8
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +2 -2
- package/lib/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +122 -76
- package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -4
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +4 -6
- package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/lib/theme/ApiExplorer/Response/index.js +23 -20
- package/lib/theme/ApiExplorer/index.js +0 -4
- package/lib/theme/ApiExplorer/persistanceMiddleware.js +6 -6
- package/lib/theme/ApiItem/Layout/index.js +3 -0
- package/lib/theme/ApiItem/index.js +6 -5
- 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 +152 -98
- package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
- package/lib/theme/DiscriminatorTabs/index.js +146 -94
- package/lib/theme/MimeTabs/index.d.ts +6 -0
- package/lib/theme/MimeTabs/index.js +163 -114
- package/lib/theme/OperationTabs/_OperationTabs.scss +4 -1
- package/lib/theme/OperationTabs/index.d.ts +3 -0
- package/lib/theme/OperationTabs/index.js +148 -103
- package/lib/theme/ParamsItem/index.d.ts +23 -0
- package/lib/theme/ParamsItem/index.js +168 -123
- 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 +123 -88
- package/lib/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/lib/theme/SchemaTabs/index.d.ts +3 -0
- package/lib/theme/SchemaTabs/index.js +148 -93
- package/lib/theme/styles.scss +4 -0
- package/package.json +8 -7
- package/src/markdown/utils.ts +4 -2
- 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} +5 -5
- 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} +13 -3
- 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/CodeSnippets/index.tsx +3 -5
- package/src/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
- package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +56 -26
- 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 -6
- package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
- package/src/theme/ApiExplorer/Response/index.tsx +6 -3
- package/src/theme/ApiExplorer/index.tsx +0 -3
- package/src/theme/ApiExplorer/persistanceMiddleware.ts +6 -6
- package/src/theme/ApiItem/Layout/index.tsx +3 -0
- package/src/theme/ApiItem/index.tsx +3 -4
- package/src/theme/ApiLogo/index.tsx +1 -1
- package/src/theme/ApiTabs/_ApiTabs.scss +3 -1
- package/src/theme/ApiTabs/{index.js → index.tsx} +60 -26
- package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +57 -24
- package/src/theme/MimeTabs/{index.js → index.tsx} +57 -25
- package/src/theme/OperationTabs/_OperationTabs.scss +4 -1
- package/src/theme/OperationTabs/{index.js → index.tsx} +54 -25
- package/src/theme/ParamsItem/{index.js → index.tsx} +31 -14
- package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
- package/src/theme/SchemaItem/{index.js → index.tsx} +18 -9
- package/src/theme/SchemaTabs/_SchemaTabs.scss +0 -4
- package/src/theme/SchemaTabs/{index.js → index.tsx} +64 -28
- package/src/theme/styles.scss +4 -0
- package/src/theme-classic.d.ts +69 -2
- package/src/theme-openapi.d.ts +3 -0
- package/tsconfig.json +4 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Language } from "prism-react-renderer";
|
|
3
|
+
export interface Props {
|
|
4
|
+
readonly responseExample: string;
|
|
5
|
+
readonly language: Language;
|
|
6
|
+
}
|
|
7
|
+
declare function ResponseSamples({ responseExample, language, }: Props): React.JSX.Element;
|
|
8
|
+
export default ResponseSamples;
|
|
@@ -1,22 +1,27 @@
|
|
|
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
|
-
|
|
8
|
+
var __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
|
|
12
16
|
function ResponseSamples({ responseExample, language }) {
|
|
13
|
-
return (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
return react_1.default.createElement(
|
|
18
|
+
"div",
|
|
19
|
+
{ className: "openapi-code__response-samples-container" },
|
|
20
|
+
react_1.default.createElement(
|
|
21
|
+
CodeBlock_1.default,
|
|
22
|
+
{ language: language ? language : "json" },
|
|
23
|
+
responseExample
|
|
24
|
+
)
|
|
19
25
|
);
|
|
20
26
|
}
|
|
21
|
-
|
|
22
|
-
export default ResponseSamples;
|
|
27
|
+
exports.default = ResponseSamples;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export interface Props {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
collapsible: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
qualifierMessage: string | undefined;
|
|
7
|
+
required: boolean;
|
|
8
|
+
schemaName: string;
|
|
9
|
+
schema: any;
|
|
10
|
+
discriminator: boolean;
|
|
11
|
+
}
|
|
12
|
+
export default function SchemaItem({ children: collapsibleSchemaContent, collapsible, name, qualifierMessage, required, schemaName, schema, }: Props): React.JSX.Element;
|
|
@@ -1,21 +1,23 @@
|
|
|
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 __importDefault =
|
|
9
|
+
(this && this.__importDefault) ||
|
|
10
|
+
function (mod) {
|
|
11
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
const react_1 = __importDefault(require("react"));
|
|
15
|
+
const CodeBlock_1 = __importDefault(require("@theme/CodeBlock"));
|
|
16
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
17
|
+
const react_markdown_1 = __importDefault(require("react-markdown"));
|
|
18
|
+
const rehype_raw_1 = __importDefault(require("rehype-raw"));
|
|
19
|
+
const createDescription_1 = require("../../markdown/createDescription");
|
|
20
|
+
const utils_1 = require("../../markdown/utils");
|
|
19
21
|
function SchemaItem({
|
|
20
22
|
children: collapsibleSchemaContent,
|
|
21
23
|
collapsible,
|
|
@@ -35,86 +37,119 @@ function SchemaItem({
|
|
|
35
37
|
defaultValue = schema.default;
|
|
36
38
|
nullable = schema.nullable;
|
|
37
39
|
}
|
|
38
|
-
|
|
39
|
-
const renderRequired = guard(
|
|
40
|
+
const renderRequired = (0, utils_1.guard)(
|
|
40
41
|
Array.isArray(required) ? required.includes(name) : required,
|
|
41
|
-
() =>
|
|
42
|
+
() =>
|
|
43
|
+
react_1.default.createElement(
|
|
44
|
+
"span",
|
|
45
|
+
{ className: "openapi-schema__required" },
|
|
46
|
+
"required"
|
|
47
|
+
)
|
|
42
48
|
);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
))
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
49
|
+
const renderDeprecated = (0, utils_1.guard)(deprecated, () =>
|
|
50
|
+
react_1.default.createElement(
|
|
51
|
+
"span",
|
|
52
|
+
{ className: "openapi-schema__deprecated" },
|
|
53
|
+
"deprecated"
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
const renderNullable = (0, utils_1.guard)(nullable, () =>
|
|
57
|
+
react_1.default.createElement(
|
|
58
|
+
"span",
|
|
59
|
+
{ className: "openapi-schema__nullable" },
|
|
60
|
+
"nullable"
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
const renderSchemaDescription = (0, utils_1.guard)(
|
|
64
|
+
schemaDescription,
|
|
65
|
+
(description) =>
|
|
66
|
+
react_1.default.createElement(
|
|
67
|
+
"div",
|
|
68
|
+
null,
|
|
69
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
70
|
+
children: (0, createDescription_1.createDescription)(description),
|
|
71
|
+
components: {
|
|
72
|
+
pre: "div",
|
|
73
|
+
code({ node, inline, className, children, ...props }) {
|
|
74
|
+
const match = /language-(\w+)/.exec(className || "");
|
|
75
|
+
if (inline)
|
|
76
|
+
return react_1.default.createElement("code", null, children);
|
|
77
|
+
return !inline && match
|
|
78
|
+
? react_1.default.createElement(
|
|
79
|
+
CodeBlock_1.default,
|
|
80
|
+
{ className: className },
|
|
81
|
+
children
|
|
82
|
+
)
|
|
83
|
+
: react_1.default.createElement(
|
|
84
|
+
CodeBlock_1.default,
|
|
85
|
+
null,
|
|
86
|
+
children
|
|
87
|
+
);
|
|
88
|
+
},
|
|
66
89
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
rehypePlugins: [rehype_raw_1.default],
|
|
91
|
+
})
|
|
92
|
+
)
|
|
93
|
+
);
|
|
94
|
+
const renderQualifierMessage = (0, utils_1.guard)(
|
|
95
|
+
qualifierMessage,
|
|
96
|
+
(message) =>
|
|
97
|
+
react_1.default.createElement(
|
|
98
|
+
"div",
|
|
99
|
+
null,
|
|
100
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
101
|
+
children: (0, createDescription_1.createDescription)(message),
|
|
102
|
+
rehypePlugins: [rehype_raw_1.default],
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
const renderDefaultValue = (0, utils_1.guard)(defaultValue, (value) =>
|
|
107
|
+
react_1.default.createElement(
|
|
108
|
+
"div",
|
|
109
|
+
{ className: "" },
|
|
110
|
+
react_1.default.createElement(react_markdown_1.default, {
|
|
111
|
+
children: `**Default value:** \`${value}\``,
|
|
112
|
+
})
|
|
113
|
+
)
|
|
114
|
+
);
|
|
115
|
+
const schemaContent = react_1.default.createElement(
|
|
116
|
+
"div",
|
|
117
|
+
null,
|
|
118
|
+
react_1.default.createElement(
|
|
119
|
+
"span",
|
|
120
|
+
{ className: "openapi-schema__container" },
|
|
121
|
+
react_1.default.createElement(
|
|
122
|
+
"strong",
|
|
123
|
+
{
|
|
124
|
+
className: (0, clsx_1.default)("openapi-schema__property", {
|
|
93
125
|
"openapi-schema__strikethrough": deprecated,
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
}),
|
|
127
|
+
},
|
|
128
|
+
name
|
|
129
|
+
),
|
|
130
|
+
react_1.default.createElement(
|
|
131
|
+
"span",
|
|
132
|
+
{ className: "openapi-schema__name" },
|
|
133
|
+
" ",
|
|
134
|
+
schemaName
|
|
135
|
+
),
|
|
136
|
+
(nullable || required || deprecated) &&
|
|
137
|
+
react_1.default.createElement("span", {
|
|
138
|
+
className: "openapi-schema__divider",
|
|
139
|
+
}),
|
|
140
|
+
renderNullable,
|
|
141
|
+
renderRequired,
|
|
142
|
+
renderDeprecated
|
|
143
|
+
),
|
|
144
|
+
renderQualifierMessage,
|
|
145
|
+
renderDefaultValue,
|
|
146
|
+
renderSchemaDescription,
|
|
147
|
+
collapsibleSchemaContent ?? collapsibleSchemaContent
|
|
111
148
|
);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
</div>
|
|
149
|
+
return react_1.default.createElement(
|
|
150
|
+
"div",
|
|
151
|
+
{ className: "openapi-schema__list-item" },
|
|
152
|
+
collapsible ? collapsibleSchemaContent : schemaContent
|
|
117
153
|
);
|
|
118
154
|
}
|
|
119
|
-
|
|
120
|
-
export default SchemaItem;
|
|
155
|
+
exports.default = SchemaItem;
|
|
@@ -1,24 +1,69 @@
|
|
|
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
|
-
|
|
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 clsx_1 = __importDefault(require("clsx"));
|
|
62
|
+
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
18
63
|
function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
19
64
|
const tabRefs = [];
|
|
20
|
-
const { blockElementScrollPositionUntilNextRender } =
|
|
21
|
-
|
|
65
|
+
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
66
|
+
internal_1.useScrollPositionBlocker)();
|
|
22
67
|
const handleTabChange = (event) => {
|
|
23
68
|
const newTab = event.currentTarget;
|
|
24
69
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -50,15 +95,13 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
50
95
|
}
|
|
51
96
|
focusElement?.focus();
|
|
52
97
|
};
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
useEffect(() => {
|
|
98
|
+
const tabItemListContainerRef = (0, react_1.useRef)(null);
|
|
99
|
+
const [showTabArrows, setShowTabArrows] = (0, react_1.useState)(false);
|
|
100
|
+
(0, react_1.useEffect)(() => {
|
|
58
101
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
59
102
|
for (let entry of entries) {
|
|
60
103
|
requestAnimationFrame(() => {
|
|
61
|
-
if (entry.target.
|
|
104
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
62
105
|
setShowTabArrows(true);
|
|
63
106
|
} else {
|
|
64
107
|
setShowTabArrows(false);
|
|
@@ -66,121 +109,133 @@ function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
|
66
109
|
});
|
|
67
110
|
}
|
|
68
111
|
});
|
|
69
|
-
|
|
70
112
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
71
|
-
|
|
72
113
|
return () => {
|
|
73
114
|
resizeObserver.disconnect();
|
|
74
115
|
};
|
|
75
116
|
}, []);
|
|
76
|
-
|
|
77
117
|
const handleRightClick = (e) => {
|
|
78
118
|
e.preventDefault();
|
|
79
|
-
tabItemListContainerRef.current
|
|
119
|
+
if (tabItemListContainerRef.current) {
|
|
120
|
+
tabItemListContainerRef.current.scrollLeft += 90;
|
|
121
|
+
}
|
|
80
122
|
};
|
|
81
|
-
|
|
82
123
|
const handleLeftClick = (e) => {
|
|
83
124
|
e.preventDefault();
|
|
84
|
-
tabItemListContainerRef.current
|
|
125
|
+
if (tabItemListContainerRef.current) {
|
|
126
|
+
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
127
|
+
}
|
|
85
128
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
129
|
+
return react_1.default.createElement(
|
|
130
|
+
"div",
|
|
131
|
+
{ className: "openapi-tabs__schema-tabs-container" },
|
|
132
|
+
showTabArrows &&
|
|
133
|
+
react_1.default.createElement("button", {
|
|
134
|
+
className: "openapi-tabs__arrow left",
|
|
135
|
+
onClick: handleLeftClick,
|
|
136
|
+
}),
|
|
137
|
+
react_1.default.createElement(
|
|
138
|
+
"ul",
|
|
139
|
+
{
|
|
140
|
+
ref: tabItemListContainerRef,
|
|
141
|
+
role: "tablist",
|
|
142
|
+
"aria-orientation": "horizontal",
|
|
143
|
+
className: (0, clsx_1.default)(
|
|
100
144
|
"openapi-tabs__schema-list-container",
|
|
101
145
|
"tabs",
|
|
102
146
|
{
|
|
103
147
|
"tabs--block": block,
|
|
104
148
|
},
|
|
105
149
|
className
|
|
106
|
-
)
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
150
|
+
),
|
|
151
|
+
},
|
|
152
|
+
tabValues.map(({ value, label, attributes }) =>
|
|
153
|
+
react_1.default.createElement(
|
|
154
|
+
"li",
|
|
155
|
+
{
|
|
110
156
|
// TODO extract TabListItem
|
|
111
|
-
role
|
|
112
|
-
tabIndex
|
|
113
|
-
aria-selected
|
|
114
|
-
key
|
|
115
|
-
ref
|
|
116
|
-
onKeyDown
|
|
117
|
-
onClick
|
|
118
|
-
|
|
119
|
-
className
|
|
157
|
+
role: "tab",
|
|
158
|
+
tabIndex: selectedValue === value ? 0 : -1,
|
|
159
|
+
"aria-selected": selectedValue === value,
|
|
160
|
+
key: value,
|
|
161
|
+
ref: (tabControl) => tabRefs.push(tabControl),
|
|
162
|
+
onKeyDown: handleKeydown,
|
|
163
|
+
onClick: handleTabChange,
|
|
164
|
+
...attributes,
|
|
165
|
+
className: (0, clsx_1.default)(
|
|
120
166
|
"tabs__item",
|
|
121
167
|
"openapi-tabs__schema-item",
|
|
122
168
|
attributes?.className,
|
|
123
169
|
{
|
|
124
170
|
active: selectedValue === value,
|
|
125
171
|
}
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
172
|
+
),
|
|
173
|
+
},
|
|
174
|
+
react_1.default.createElement(
|
|
175
|
+
"span",
|
|
176
|
+
{ className: "openapi-tabs__schema-label" },
|
|
177
|
+
label ?? value
|
|
178
|
+
)
|
|
179
|
+
)
|
|
180
|
+
)
|
|
181
|
+
),
|
|
182
|
+
showTabArrows &&
|
|
183
|
+
react_1.default.createElement("button", {
|
|
184
|
+
className: "openapi-tabs__arrow right",
|
|
185
|
+
onClick: handleRightClick,
|
|
186
|
+
})
|
|
139
187
|
);
|
|
140
188
|
}
|
|
141
189
|
function TabContent({ lazy, children, selectedValue }) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
190
|
+
const childTabs = (Array.isArray(children) ? children : [children]).filter(
|
|
191
|
+
Boolean
|
|
192
|
+
);
|
|
193
|
+
const flattenedChildTabs = (0, flatten_1.default)(childTabs);
|
|
146
194
|
if (lazy) {
|
|
147
|
-
const selectedTabItem =
|
|
195
|
+
const selectedTabItem = flattenedChildTabs.find(
|
|
148
196
|
(tabItem) => tabItem.props.value === selectedValue
|
|
149
197
|
);
|
|
150
198
|
if (!selectedTabItem) {
|
|
151
199
|
// fail-safe or fail-fast? not sure what's best here
|
|
152
200
|
return null;
|
|
153
201
|
}
|
|
154
|
-
return cloneElement(selectedTabItem, {
|
|
202
|
+
return (0, react_1.cloneElement)(selectedTabItem, {
|
|
203
|
+
className: "margin-top--md",
|
|
204
|
+
});
|
|
155
205
|
}
|
|
156
|
-
return (
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
)
|
|
164
|
-
|
|
206
|
+
return react_1.default.createElement(
|
|
207
|
+
"div",
|
|
208
|
+
{ className: "margin-top--md" },
|
|
209
|
+
childTabs.map((tabItem, i) =>
|
|
210
|
+
(0, react_1.cloneElement)(tabItem, {
|
|
211
|
+
key: i,
|
|
212
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
213
|
+
})
|
|
214
|
+
)
|
|
165
215
|
);
|
|
166
216
|
}
|
|
167
217
|
function TabsComponent(props) {
|
|
168
|
-
const tabs = useTabs(props);
|
|
169
|
-
return (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
218
|
+
const tabs = (0, internal_1.useTabs)(props);
|
|
219
|
+
return react_1.default.createElement(
|
|
220
|
+
"div",
|
|
221
|
+
{ className: "openapi-tabs__schema-container" },
|
|
222
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
223
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
174
224
|
);
|
|
175
225
|
}
|
|
176
|
-
|
|
177
|
-
const isBrowser =
|
|
178
|
-
return (
|
|
179
|
-
|
|
226
|
+
function SchemaTabs(props) {
|
|
227
|
+
const isBrowser = (0, useIsBrowser_1.default)();
|
|
228
|
+
return react_1.default.createElement(
|
|
229
|
+
TabsComponent,
|
|
230
|
+
// Remount tabs after hydration
|
|
231
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
232
|
+
{
|
|
180
233
|
// Remount tabs after hydration
|
|
181
234
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
182
|
-
key
|
|
183
|
-
|
|
184
|
-
|
|
235
|
+
key: String(isBrowser),
|
|
236
|
+
...props,
|
|
237
|
+
},
|
|
238
|
+
(0, internal_1.sanitizeTabsChildren)(props.children)
|
|
185
239
|
);
|
|
186
240
|
}
|
|
241
|
+
exports.default = SchemaTabs;
|