docusaurus-theme-openapi-docs 0.0.0-740 → 0.0.0-751
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
|
@@ -1,20 +1,65 @@
|
|
|
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 Heading_1 = __importDefault(require("@theme/Heading"));
|
|
62
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
18
63
|
function TabList({
|
|
19
64
|
className,
|
|
20
65
|
block,
|
|
@@ -25,9 +70,8 @@ function TabList({
|
|
|
25
70
|
id = "responses",
|
|
26
71
|
}) {
|
|
27
72
|
const tabRefs = [];
|
|
28
|
-
const { blockElementScrollPositionUntilNextRender } =
|
|
29
|
-
|
|
30
|
-
|
|
73
|
+
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
74
|
+
internal_1.useScrollPositionBlocker)();
|
|
31
75
|
const handleTabChange = (event) => {
|
|
32
76
|
const newTab = event.currentTarget;
|
|
33
77
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -37,7 +81,6 @@ function TabList({
|
|
|
37
81
|
selectValue(newTabValue);
|
|
38
82
|
}
|
|
39
83
|
};
|
|
40
|
-
|
|
41
84
|
const handleKeydown = (event) => {
|
|
42
85
|
let focusElement = null;
|
|
43
86
|
switch (event.key) {
|
|
@@ -60,15 +103,13 @@ function TabList({
|
|
|
60
103
|
}
|
|
61
104
|
focusElement?.focus();
|
|
62
105
|
};
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
106
|
+
const tabItemListContainerRef = (0, react_1.useRef)(null);
|
|
107
|
+
const [showTabArrows, setShowTabArrows] = (0, react_1.useState)(false);
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
68
109
|
const resizeObserver = new ResizeObserver((entries) => {
|
|
69
110
|
for (let entry of entries) {
|
|
70
111
|
requestAnimationFrame(() => {
|
|
71
|
-
if (entry.target.
|
|
112
|
+
if (entry.target.clientWidth < entry.target.scrollWidth) {
|
|
72
113
|
setShowTabArrows(true);
|
|
73
114
|
} else {
|
|
74
115
|
setShowTabArrows(false);
|
|
@@ -76,127 +117,140 @@ function TabList({
|
|
|
76
117
|
});
|
|
77
118
|
}
|
|
78
119
|
});
|
|
79
|
-
|
|
80
120
|
resizeObserver.observe(tabItemListContainerRef.current);
|
|
81
|
-
|
|
82
121
|
return () => {
|
|
83
122
|
resizeObserver.disconnect();
|
|
84
123
|
};
|
|
85
124
|
}, []);
|
|
86
|
-
|
|
87
125
|
const handleRightClick = () => {
|
|
88
126
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
89
127
|
};
|
|
90
|
-
|
|
91
128
|
const handleLeftClick = () => {
|
|
92
129
|
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
93
130
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
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)(
|
|
112
158
|
"openapi-tabs__response-list-container",
|
|
113
159
|
"tabs",
|
|
114
160
|
{
|
|
115
161
|
"tabs--block": block,
|
|
116
162
|
},
|
|
117
163
|
className
|
|
118
|
-
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
tabValues.map(({ value, label, attributes }) =>
|
|
167
|
+
react_1.default.createElement(
|
|
168
|
+
"li",
|
|
169
|
+
{
|
|
122
170
|
// TODO extract TabListItem
|
|
123
|
-
role
|
|
124
|
-
tabIndex
|
|
125
|
-
aria-selected
|
|
126
|
-
key
|
|
127
|
-
ref
|
|
128
|
-
onKeyDown
|
|
129
|
-
onClick
|
|
130
|
-
|
|
131
|
-
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)(
|
|
132
180
|
"tabs__item",
|
|
133
181
|
"openapi-tabs__response-code-item",
|
|
134
182
|
attributes?.className,
|
|
135
183
|
parseInt(value) >= 400
|
|
136
184
|
? "danger"
|
|
137
185
|
: parseInt(value) >= 200 && parseInt(value) < 300
|
|
138
|
-
|
|
139
|
-
|
|
186
|
+
? "success"
|
|
187
|
+
: "info",
|
|
140
188
|
{
|
|
141
189
|
active: selectedValue === value,
|
|
142
190
|
}
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</div>
|
|
156
|
-
</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
|
+
)
|
|
157
203
|
);
|
|
158
204
|
}
|
|
159
205
|
function TabContent({ lazy, children, selectedValue }) {
|
|
160
|
-
|
|
161
|
-
|
|
206
|
+
const childTabs = (Array.isArray(children) ? children : [children]).filter(
|
|
207
|
+
Boolean
|
|
208
|
+
);
|
|
162
209
|
if (lazy) {
|
|
163
|
-
const selectedTabItem =
|
|
210
|
+
const selectedTabItem = childTabs.find(
|
|
164
211
|
(tabItem) => tabItem.props.value === selectedValue
|
|
165
212
|
);
|
|
166
213
|
if (!selectedTabItem) {
|
|
167
214
|
// fail-safe or fail-fast? not sure what's best here
|
|
168
215
|
return null;
|
|
169
216
|
}
|
|
170
|
-
return cloneElement(selectedTabItem, {
|
|
217
|
+
return (0, react_1.cloneElement)(selectedTabItem, {
|
|
218
|
+
className: "margin-top--md",
|
|
219
|
+
});
|
|
171
220
|
}
|
|
172
|
-
return (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
)
|
|
180
|
-
|
|
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
|
+
)
|
|
181
230
|
);
|
|
182
231
|
}
|
|
183
232
|
function TabsComponent(props) {
|
|
184
|
-
const tabs = useTabs(props);
|
|
185
|
-
return (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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 })
|
|
190
239
|
);
|
|
191
240
|
}
|
|
192
|
-
|
|
193
|
-
const isBrowser =
|
|
194
|
-
return (
|
|
195
|
-
|
|
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
|
+
{
|
|
196
248
|
// Remount tabs after hydration
|
|
197
249
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
198
|
-
key
|
|
199
|
-
|
|
200
|
-
|
|
250
|
+
key: String(isBrowser),
|
|
251
|
+
...props,
|
|
252
|
+
},
|
|
253
|
+
(0, internal_1.sanitizeTabsChildren)(props.children)
|
|
201
254
|
);
|
|
202
255
|
}
|
|
256
|
+
exports.default = ApiTabs;
|
|
@@ -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,122 +109,131 @@ 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 = () => {
|
|
78
118
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
79
119
|
};
|
|
80
|
-
|
|
81
120
|
const handleLeftClick = () => {
|
|
82
121
|
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
83
122
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
123
|
+
return react_1.default.createElement(
|
|
124
|
+
"div",
|
|
125
|
+
{ className: "openapi-tabs__discriminator-top-section" },
|
|
126
|
+
react_1.default.createElement(
|
|
127
|
+
"div",
|
|
128
|
+
{ className: "openapi-tabs__discriminator-container" },
|
|
129
|
+
showTabArrows &&
|
|
130
|
+
react_1.default.createElement("button", {
|
|
131
|
+
className: "openapi-tabs__arrow left",
|
|
132
|
+
onClick: handleLeftClick,
|
|
133
|
+
}),
|
|
134
|
+
react_1.default.createElement(
|
|
135
|
+
"ul",
|
|
136
|
+
{
|
|
137
|
+
ref: tabItemListContainerRef,
|
|
138
|
+
role: "tablist",
|
|
139
|
+
"aria-orientation": "horizontal",
|
|
140
|
+
className: (0, clsx_1.default)(
|
|
99
141
|
"openapi-tabs__discriminator-list-container",
|
|
100
142
|
"tabs",
|
|
101
143
|
{
|
|
102
144
|
"tabs--block": block,
|
|
103
145
|
},
|
|
104
146
|
className
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
147
|
+
),
|
|
148
|
+
},
|
|
149
|
+
tabValues.map(({ value, label, attributes }) =>
|
|
150
|
+
react_1.default.createElement(
|
|
151
|
+
"li",
|
|
152
|
+
{
|
|
109
153
|
// TODO extract TabListItem
|
|
110
|
-
role
|
|
111
|
-
tabIndex
|
|
112
|
-
aria-selected
|
|
113
|
-
key
|
|
114
|
-
ref
|
|
115
|
-
onKeyDown
|
|
116
|
-
onClick
|
|
117
|
-
|
|
118
|
-
className
|
|
154
|
+
role: "tab",
|
|
155
|
+
tabIndex: selectedValue === value ? 0 : -1,
|
|
156
|
+
"aria-selected": selectedValue === value,
|
|
157
|
+
key: value,
|
|
158
|
+
ref: (tabControl) => tabRefs.push(tabControl),
|
|
159
|
+
onKeyDown: handleKeydown,
|
|
160
|
+
onClick: handleTabChange,
|
|
161
|
+
...attributes,
|
|
162
|
+
className: (0, clsx_1.default)(
|
|
119
163
|
"tabs__item",
|
|
120
164
|
"openapi-tabs__discriminator-item",
|
|
121
165
|
attributes?.className,
|
|
122
166
|
{
|
|
123
167
|
active: selectedValue === value,
|
|
124
168
|
}
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
169
|
+
),
|
|
170
|
+
},
|
|
171
|
+
react_1.default.createElement(
|
|
172
|
+
"span",
|
|
173
|
+
{ className: "openapi-tabs__discriminator-tab-label" },
|
|
174
|
+
label ?? value
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
)
|
|
178
|
+
),
|
|
179
|
+
showTabArrows &&
|
|
180
|
+
react_1.default.createElement("button", {
|
|
181
|
+
className: "openapi-tabs__arrow right",
|
|
182
|
+
onClick: handleRightClick,
|
|
183
|
+
})
|
|
184
|
+
)
|
|
141
185
|
);
|
|
142
186
|
}
|
|
143
187
|
function TabContent({ lazy, children, selectedValue }) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
188
|
+
const childTabs = (Array.isArray(children) ? children : [children]).filter(
|
|
189
|
+
Boolean
|
|
190
|
+
);
|
|
191
|
+
const flattenedChildTabs = (0, flatten_1.default)(childTabs);
|
|
147
192
|
if (lazy) {
|
|
148
|
-
const selectedTabItem =
|
|
193
|
+
const selectedTabItem = flattenedChildTabs.find(
|
|
149
194
|
(tabItem) => tabItem.props.value === selectedValue
|
|
150
195
|
);
|
|
151
196
|
if (!selectedTabItem) {
|
|
152
197
|
// fail-safe or fail-fast? not sure what's best here
|
|
153
198
|
return null;
|
|
154
199
|
}
|
|
155
|
-
return cloneElement(selectedTabItem, {
|
|
200
|
+
return (0, react_1.cloneElement)(selectedTabItem, {
|
|
201
|
+
className: "margin-top--md",
|
|
202
|
+
});
|
|
156
203
|
}
|
|
157
|
-
return (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
)
|
|
165
|
-
|
|
204
|
+
return react_1.default.createElement(
|
|
205
|
+
"div",
|
|
206
|
+
{ className: "margin-top--md" },
|
|
207
|
+
childTabs.map((tabItem, i) =>
|
|
208
|
+
(0, react_1.cloneElement)(tabItem, {
|
|
209
|
+
key: i,
|
|
210
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
211
|
+
})
|
|
212
|
+
)
|
|
166
213
|
);
|
|
167
214
|
}
|
|
168
215
|
function TabsComponent(props) {
|
|
169
|
-
const tabs = useTabs(props);
|
|
170
|
-
return (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
216
|
+
const tabs = (0, internal_1.useTabs)(props);
|
|
217
|
+
return react_1.default.createElement(
|
|
218
|
+
"div",
|
|
219
|
+
{ className: "openapi-tabs__container" },
|
|
220
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
221
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
175
222
|
);
|
|
176
223
|
}
|
|
177
|
-
|
|
178
|
-
const isBrowser =
|
|
179
|
-
return (
|
|
180
|
-
|
|
224
|
+
function DiscriminatorTabs(props) {
|
|
225
|
+
const isBrowser = (0, useIsBrowser_1.default)();
|
|
226
|
+
return react_1.default.createElement(
|
|
227
|
+
TabsComponent,
|
|
228
|
+
// Remount tabs after hydration
|
|
229
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
230
|
+
{
|
|
181
231
|
// Remount tabs after hydration
|
|
182
232
|
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
183
|
-
key
|
|
184
|
-
|
|
185
|
-
|
|
233
|
+
key: String(isBrowser),
|
|
234
|
+
...props,
|
|
235
|
+
},
|
|
236
|
+
(0, internal_1.sanitizeTabsChildren)(props.children)
|
|
186
237
|
);
|
|
187
238
|
}
|
|
239
|
+
exports.default = DiscriminatorTabs;
|