docusaurus-theme-openapi-docs 3.0.0-beta.3 → 3.0.0-beta.5
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/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/Body/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Body/index.js +8 -1
- 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 +87 -8
- package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +2 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.js +32 -0
- package/lib/theme/ApiExplorer/CodeSnippets/languages.json +0 -96
- package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +14 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +14 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +130 -78
- 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/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/ParamSelectFormItem.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +2 -2
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Request/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Response/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/SecuritySchemes/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/Server/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/index.d.ts +2 -2
- package/lib/theme/ApiExplorer/index.js +1 -1
- package/lib/theme/ApiItem/index.d.ts +2 -2
- package/lib/theme/ApiItem/index.js +4 -3
- package/lib/theme/ApiItem/store.d.ts +4 -4
- package/lib/theme/ApiLogo/index.d.ts +2 -2
- package/lib/theme/ApiTabs/index.d.ts +7 -0
- package/lib/theme/ApiTabs/index.js +155 -97
- package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
- package/lib/theme/DiscriminatorTabs/index.js +146 -94
- package/lib/theme/Markdown/index.js +37 -0
- package/lib/theme/MimeTabs/index.d.ts +6 -0
- package/lib/theme/MimeTabs/index.js +163 -114
- package/lib/theme/OperationTabs/_OperationTabs.scss +68 -0
- package/lib/theme/OperationTabs/index.d.ts +3 -0
- package/lib/theme/OperationTabs/index.js +232 -0
- package/lib/theme/ParamsItem/index.d.ts +22 -0
- package/lib/theme/ParamsItem/index.js +154 -109
- 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 -89
- package/lib/theme/SchemaTabs/index.d.ts +3 -0
- package/lib/theme/SchemaTabs/index.js +142 -91
- package/lib/theme/styles.scss +1 -0
- package/package.json +4 -4
- package/src/markdown/utils.ts +4 -2
- 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 +37 -0
- package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +14 -0
- package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +57 -25
- package/src/theme/ApiExplorer/index.tsx +1 -1
- package/src/theme/ApiItem/index.tsx +3 -4
- package/src/theme/ApiLogo/index.tsx +1 -1
- package/src/theme/ApiTabs/{index.js → index.tsx} +63 -25
- package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +57 -24
- package/src/theme/Markdown/index.js +37 -0
- package/src/theme/MimeTabs/{index.js → index.tsx} +58 -26
- package/src/theme/OperationTabs/_OperationTabs.scss +68 -0
- package/src/theme/OperationTabs/index.tsx +216 -0
- package/src/theme/ParamsItem/{index.js → index.tsx} +28 -13
- package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
- package/src/theme/SchemaItem/{index.js → index.tsx} +18 -9
- package/src/theme/SchemaTabs/{index.js → index.tsx} +56 -25
- package/src/theme/styles.scss +1 -0
- package/src/theme-classic.d.ts +69 -2
- package/src/theme-openapi.d.ts +4 -0
- package/tsconfig.json +4 -1
|
@@ -1,22 +1,67 @@
|
|
|
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
|
-
|
|
19
|
-
|
|
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 slice_1 = __importDefault(require("@theme/ApiExplorer/Accept/slice"));
|
|
62
|
+
const slice_2 = require("@theme/ApiExplorer/ContentType/slice");
|
|
63
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
64
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
20
65
|
function TabList({
|
|
21
66
|
className,
|
|
22
67
|
block,
|
|
@@ -26,18 +71,21 @@ function TabList({
|
|
|
26
71
|
schemaType,
|
|
27
72
|
}) {
|
|
28
73
|
const tabRefs = [];
|
|
29
|
-
const { blockElementScrollPositionUntilNextRender } =
|
|
30
|
-
|
|
31
|
-
|
|
74
|
+
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
75
|
+
internal_1.useScrollPositionBlocker)();
|
|
32
76
|
// custom
|
|
33
|
-
const dispatch = useTypedDispatch();
|
|
77
|
+
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
34
78
|
const isRequestSchema = schemaType?.toLowerCase() === "request";
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
79
|
+
const [selectedValue, setSelectedValue] = (0, react_1.useState)(
|
|
80
|
+
selectedValueProp
|
|
81
|
+
);
|
|
82
|
+
const contentTypeVal = (0, hooks_1.useTypedSelector)(
|
|
83
|
+
(state) => state.contentType.value
|
|
84
|
+
);
|
|
85
|
+
const acceptTypeVal = (0, hooks_1.useTypedSelector)(
|
|
86
|
+
(state) => state.accept.value
|
|
87
|
+
);
|
|
88
|
+
(0, react_1.useEffect)(() => {
|
|
41
89
|
if (tabRefs.length > 1) {
|
|
42
90
|
if (isRequestSchema) {
|
|
43
91
|
setSelectedValue(contentTypeVal);
|
|
@@ -47,7 +95,6 @@ function TabList({
|
|
|
47
95
|
}
|
|
48
96
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
97
|
}, [contentTypeVal, acceptTypeVal]);
|
|
50
|
-
|
|
51
98
|
const handleTabChange = (event) => {
|
|
52
99
|
event.preventDefault();
|
|
53
100
|
const newTab = event.currentTarget;
|
|
@@ -56,15 +103,14 @@ function TabList({
|
|
|
56
103
|
// custom
|
|
57
104
|
if (newTabValue !== selectedValue) {
|
|
58
105
|
if (isRequestSchema) {
|
|
59
|
-
dispatch(setContentType(newTabValue));
|
|
106
|
+
dispatch((0, slice_2.setContentType)(newTabValue));
|
|
60
107
|
} else {
|
|
61
|
-
dispatch(
|
|
108
|
+
dispatch((0, slice_1.default)(newTabValue));
|
|
62
109
|
}
|
|
63
110
|
blockElementScrollPositionUntilNextRender(newTab);
|
|
64
111
|
selectValue(newTabValue);
|
|
65
112
|
}
|
|
66
113
|
};
|
|
67
|
-
|
|
68
114
|
const handleKeydown = (event) => {
|
|
69
115
|
let focusElement = null;
|
|
70
116
|
switch (event.key) {
|
|
@@ -87,135 +133,138 @@ function TabList({
|
|
|
87
133
|
}
|
|
88
134
|
focusElement?.focus();
|
|
89
135
|
};
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
useEffect(() => {
|
|
136
|
+
const tabItemListContainerRef = (0, react_1.useRef)(null);
|
|
137
|
+
const [showTabArrows, setShowTabArrows] = (0, react_1.useState)(false);
|
|
138
|
+
(0, react_1.useEffect)(() => {
|
|
95
139
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
96
140
|
for (let entry of entries) {
|
|
97
|
-
if (entry.target.
|
|
141
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
98
142
|
setShowTabArrows(true);
|
|
99
143
|
} else {
|
|
100
144
|
setShowTabArrows(false);
|
|
101
145
|
}
|
|
102
146
|
}
|
|
103
147
|
});
|
|
104
|
-
|
|
105
148
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
106
|
-
|
|
107
149
|
return () => {
|
|
108
150
|
resizeObserver.disconnect();
|
|
109
151
|
};
|
|
110
152
|
}, []);
|
|
111
|
-
|
|
112
153
|
const handleRightClick = () => {
|
|
113
154
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
114
155
|
};
|
|
115
|
-
|
|
116
156
|
const handleLeftClick = () => {
|
|
117
157
|
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
118
158
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
159
|
+
return react_1.default.createElement(
|
|
160
|
+
"div",
|
|
161
|
+
{ className: "tabs__container" },
|
|
162
|
+
react_1.default.createElement(
|
|
163
|
+
"div",
|
|
164
|
+
{ className: "openapi-tabs__mime-container" },
|
|
165
|
+
showTabArrows &&
|
|
166
|
+
react_1.default.createElement("button", {
|
|
167
|
+
className: (0, clsx_1.default)("openapi-tabs__arrow", "left"),
|
|
168
|
+
onClick: handleLeftClick,
|
|
169
|
+
}),
|
|
170
|
+
react_1.default.createElement(
|
|
171
|
+
"ul",
|
|
172
|
+
{
|
|
173
|
+
ref: tabItemListContainerRef,
|
|
174
|
+
role: "tablist",
|
|
175
|
+
"aria-orientation": "horizontal",
|
|
176
|
+
className: (0, clsx_1.default)(
|
|
134
177
|
"openapi-tabs__mime-list-container",
|
|
135
178
|
"tabs",
|
|
136
179
|
{
|
|
137
180
|
"tabs--block": block,
|
|
138
181
|
},
|
|
139
182
|
className
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
</div>
|
|
175
|
-
</div>
|
|
183
|
+
),
|
|
184
|
+
},
|
|
185
|
+
tabValues.map(({ value, label, attributes }) => {
|
|
186
|
+
return react_1.default.createElement(
|
|
187
|
+
"li",
|
|
188
|
+
{
|
|
189
|
+
role: "tab",
|
|
190
|
+
tabIndex: selectedValue === value ? 0 : -1,
|
|
191
|
+
"aria-selected": selectedValue === value,
|
|
192
|
+
key: value,
|
|
193
|
+
ref: (tabControl) => tabRefs.push(tabControl),
|
|
194
|
+
onKeyDown: handleKeydown,
|
|
195
|
+
onFocus: handleTabChange,
|
|
196
|
+
onClick: (e) => handleTabChange(e),
|
|
197
|
+
...attributes,
|
|
198
|
+
className: (0, clsx_1.default)(
|
|
199
|
+
"tabs__item",
|
|
200
|
+
"openapi-tabs__mime-item",
|
|
201
|
+
attributes?.className,
|
|
202
|
+
{
|
|
203
|
+
active: selectedValue === value,
|
|
204
|
+
}
|
|
205
|
+
),
|
|
206
|
+
},
|
|
207
|
+
label ?? value
|
|
208
|
+
);
|
|
209
|
+
})
|
|
210
|
+
),
|
|
211
|
+
showTabArrows &&
|
|
212
|
+
react_1.default.createElement("button", {
|
|
213
|
+
className: (0, clsx_1.default)("openapi-tabs__arrow", "right"),
|
|
214
|
+
onClick: handleRightClick,
|
|
215
|
+
})
|
|
216
|
+
)
|
|
176
217
|
);
|
|
177
218
|
}
|
|
178
219
|
function TabContent({ lazy, children, selectedValue }) {
|
|
179
|
-
|
|
180
|
-
|
|
220
|
+
const childTabs = (Array.isArray(children) ? children : [children]).filter(
|
|
221
|
+
Boolean
|
|
222
|
+
);
|
|
181
223
|
if (lazy) {
|
|
182
|
-
const selectedTabItem =
|
|
224
|
+
const selectedTabItem = childTabs.find(
|
|
183
225
|
(tabItem) => tabItem.props.value === selectedValue
|
|
184
226
|
);
|
|
185
227
|
if (!selectedTabItem) {
|
|
186
228
|
// fail-safe or fail-fast? not sure what's best here
|
|
187
229
|
return null;
|
|
188
230
|
}
|
|
189
|
-
return cloneElement(selectedTabItem, {
|
|
231
|
+
return (0, react_1.cloneElement)(selectedTabItem, {
|
|
232
|
+
className: "margin-top--md",
|
|
233
|
+
});
|
|
190
234
|
}
|
|
191
|
-
return (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
)
|
|
199
|
-
|
|
235
|
+
return react_1.default.createElement(
|
|
236
|
+
"div",
|
|
237
|
+
{ className: "margin-top--md" },
|
|
238
|
+
childTabs.map((tabItem, i) =>
|
|
239
|
+
(0, react_1.cloneElement)(tabItem, {
|
|
240
|
+
key: i,
|
|
241
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
242
|
+
})
|
|
243
|
+
)
|
|
200
244
|
);
|
|
201
245
|
}
|
|
202
246
|
function TabsComponent(props) {
|
|
203
|
-
const tabs = useTabs(props);
|
|
204
|
-
return (
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
247
|
+
const tabs = (0, internal_1.useTabs)(props);
|
|
248
|
+
return react_1.default.createElement(
|
|
249
|
+
"div",
|
|
250
|
+
{ className: "tabs-container" },
|
|
251
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
252
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
209
253
|
);
|
|
210
254
|
}
|
|
211
|
-
|
|
212
|
-
const isBrowser =
|
|
213
|
-
return (
|
|
214
|
-
|
|
255
|
+
function MimeTabs(props) {
|
|
256
|
+
const isBrowser = (0, useIsBrowser_1.default)();
|
|
257
|
+
return react_1.default.createElement(
|
|
258
|
+
TabsComponent,
|
|
259
|
+
// Remount tabs after hydration
|
|
260
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
261
|
+
{
|
|
215
262
|
// Remount tabs after hydration
|
|
216
263
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
217
|
-
key
|
|
218
|
-
|
|
219
|
-
|
|
264
|
+
key: String(isBrowser),
|
|
265
|
+
...props,
|
|
266
|
+
},
|
|
267
|
+
(0, internal_1.sanitizeTabsChildren)(props.children)
|
|
220
268
|
);
|
|
221
269
|
}
|
|
270
|
+
exports.default = MimeTabs;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.openapi-tabs__operation-container {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
margin-top: 1rem;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.openapi-tabs__operation-item {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
padding: 0.35rem 0.7rem;
|
|
20
|
+
border: 1px solid transparent;
|
|
21
|
+
margin-top: 0 !important;
|
|
22
|
+
margin-right: 0.5rem;
|
|
23
|
+
font-weight: var(--ifm-font-weight-bold);
|
|
24
|
+
font-size: 12px;
|
|
25
|
+
white-space: nowrap;
|
|
26
|
+
transition: 300ms;
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
background-color: transparent;
|
|
30
|
+
border: 1px solid var(--ifm-toc-border-color);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.active {
|
|
34
|
+
border: 1px solid var(--ifm-tabs-color-active-border);
|
|
35
|
+
color: var(--ifm-tabs-color-active);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:last-child {
|
|
39
|
+
margin-right: 0 !important;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.openapi-tabs__operation-list-container {
|
|
44
|
+
overflow-y: hidden;
|
|
45
|
+
overflow-x: scroll;
|
|
46
|
+
scroll-behavior: smooth;
|
|
47
|
+
|
|
48
|
+
&::-webkit-scrollbar {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.openapi-tabs__operation-schema-container {
|
|
54
|
+
max-width: 600px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media screen and (max-width: 500px) {
|
|
58
|
+
.operationTabsTopSection {
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
align-items: flex-start;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.operationTabsContainer {
|
|
64
|
+
width: 100%;
|
|
65
|
+
margin-top: var(--ifm-spacing-vertical);
|
|
66
|
+
padding: 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
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
|
+
function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
63
|
+
const tabRefs = [];
|
|
64
|
+
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
65
|
+
internal_1.useScrollPositionBlocker)();
|
|
66
|
+
const handleTabChange = (event) => {
|
|
67
|
+
const newTab = event.currentTarget;
|
|
68
|
+
const newTabIndex = tabRefs.indexOf(newTab);
|
|
69
|
+
const newTabValue = tabValues[newTabIndex].value;
|
|
70
|
+
if (newTabValue !== selectedValue) {
|
|
71
|
+
blockElementScrollPositionUntilNextRender(newTab);
|
|
72
|
+
selectValue(newTabValue);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const handleKeydown = (event) => {
|
|
76
|
+
let focusElement = null;
|
|
77
|
+
switch (event.key) {
|
|
78
|
+
case "Enter": {
|
|
79
|
+
handleTabChange(event);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
case "ArrowRight": {
|
|
83
|
+
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
|
|
84
|
+
focusElement = tabRefs[nextTab] ?? tabRefs[0];
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case "ArrowLeft": {
|
|
88
|
+
const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
|
|
89
|
+
focusElement = tabRefs[prevTab] ?? tabRefs[tabRefs.length - 1];
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
default:
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
focusElement?.focus();
|
|
96
|
+
};
|
|
97
|
+
const tabItemListContainerRef = (0, react_1.useRef)(null);
|
|
98
|
+
const [showTabArrows, setShowTabArrows] = (0, react_1.useState)(false);
|
|
99
|
+
(0, react_1.useEffect)(() => {
|
|
100
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
101
|
+
for (let entry of entries) {
|
|
102
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
103
|
+
setShowTabArrows(true);
|
|
104
|
+
} else {
|
|
105
|
+
setShowTabArrows(false);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
resizeObserver.observe(tabItemListContainerRef.current);
|
|
110
|
+
return () => {
|
|
111
|
+
resizeObserver.disconnect();
|
|
112
|
+
};
|
|
113
|
+
}, []);
|
|
114
|
+
const handleRightClick = () => {
|
|
115
|
+
tabItemListContainerRef.current.scrollLeft += 90;
|
|
116
|
+
};
|
|
117
|
+
const handleLeftClick = () => {
|
|
118
|
+
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
119
|
+
};
|
|
120
|
+
return react_1.default.createElement(
|
|
121
|
+
"div",
|
|
122
|
+
{ className: "tabs__container" },
|
|
123
|
+
react_1.default.createElement(
|
|
124
|
+
"div",
|
|
125
|
+
{ className: "openapi-tabs__operation-container" },
|
|
126
|
+
showTabArrows &&
|
|
127
|
+
react_1.default.createElement("button", {
|
|
128
|
+
className: (0, clsx_1.default)("openapi-tabs__arrow", "left"),
|
|
129
|
+
onClick: handleLeftClick,
|
|
130
|
+
}),
|
|
131
|
+
react_1.default.createElement(
|
|
132
|
+
"ul",
|
|
133
|
+
{
|
|
134
|
+
ref: tabItemListContainerRef,
|
|
135
|
+
role: "tablist",
|
|
136
|
+
"aria-orientation": "horizontal",
|
|
137
|
+
className: (0, clsx_1.default)(
|
|
138
|
+
"openapi-tabs__operation-list-container",
|
|
139
|
+
"tabs",
|
|
140
|
+
{
|
|
141
|
+
"tabs--block": block,
|
|
142
|
+
},
|
|
143
|
+
className
|
|
144
|
+
),
|
|
145
|
+
},
|
|
146
|
+
tabValues.map(({ value, label, attributes }) => {
|
|
147
|
+
return react_1.default.createElement(
|
|
148
|
+
"li",
|
|
149
|
+
{
|
|
150
|
+
// TODO extract TabListItem
|
|
151
|
+
role: "tab",
|
|
152
|
+
tabIndex: selectedValue === value ? 0 : -1,
|
|
153
|
+
"aria-selected": selectedValue === value,
|
|
154
|
+
key: value,
|
|
155
|
+
ref: (tabControl) => tabRefs.push(tabControl),
|
|
156
|
+
onKeyDown: handleKeydown,
|
|
157
|
+
onFocus: handleTabChange,
|
|
158
|
+
onClick: (e) => handleTabChange(e),
|
|
159
|
+
...attributes,
|
|
160
|
+
className: (0, clsx_1.default)(
|
|
161
|
+
"tabs__item",
|
|
162
|
+
"openapi-tabs__operation-item",
|
|
163
|
+
attributes?.className,
|
|
164
|
+
{
|
|
165
|
+
active: selectedValue === value,
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
},
|
|
169
|
+
label ?? value
|
|
170
|
+
);
|
|
171
|
+
})
|
|
172
|
+
),
|
|
173
|
+
showTabArrows &&
|
|
174
|
+
react_1.default.createElement("button", {
|
|
175
|
+
className: (0, clsx_1.default)("openapi-tabs__arrow", "right"),
|
|
176
|
+
onClick: handleRightClick,
|
|
177
|
+
})
|
|
178
|
+
)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function TabContent({ lazy, children, selectedValue }) {
|
|
182
|
+
const childTabs = (Array.isArray(children) ? children : [children]).filter(
|
|
183
|
+
Boolean
|
|
184
|
+
);
|
|
185
|
+
if (lazy) {
|
|
186
|
+
const selectedTabItem = childTabs.find(
|
|
187
|
+
(tabItem) => tabItem.props.value === selectedValue
|
|
188
|
+
);
|
|
189
|
+
if (!selectedTabItem) {
|
|
190
|
+
// fail-safe or fail-fast? not sure what's best here
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return (0, react_1.cloneElement)(selectedTabItem, {
|
|
194
|
+
className: "margin-top--md",
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return react_1.default.createElement(
|
|
198
|
+
"div",
|
|
199
|
+
{ className: "margin-top--md" },
|
|
200
|
+
childTabs.map((tabItem, i) =>
|
|
201
|
+
(0, react_1.cloneElement)(tabItem, {
|
|
202
|
+
key: i,
|
|
203
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
204
|
+
})
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
function TabsComponent(props) {
|
|
209
|
+
const tabs = (0, internal_1.useTabs)(props);
|
|
210
|
+
return react_1.default.createElement(
|
|
211
|
+
"div",
|
|
212
|
+
{ className: "tabs-container" },
|
|
213
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
214
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
function OperationTabs(props) {
|
|
218
|
+
const isBrowser = (0, useIsBrowser_1.default)();
|
|
219
|
+
return react_1.default.createElement(
|
|
220
|
+
TabsComponent,
|
|
221
|
+
// Remount tabs after hydration
|
|
222
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
223
|
+
{
|
|
224
|
+
// Remount tabs after hydration
|
|
225
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
226
|
+
key: String(isBrowser),
|
|
227
|
+
...props,
|
|
228
|
+
},
|
|
229
|
+
(0, internal_1.sanitizeTabsChildren)(props.children)
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
exports.default = OperationTabs;
|