docusaurus-theme-openapi-docs 1.0.6 → 1.1.2
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/theme/ApiDemoPanel/CodeTabs/index.js +8 -3
- package/lib/theme/ApiDemoPanel/FloatingButton/index.js +4 -2
- package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +3 -2
- package/lib/theme/ApiDemoPanel/LiveEditor/index.js +17 -4
- package/lib/theme/ApiDemoPanel/LiveEditor/styles.module.css +2 -1
- package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -4
- package/lib/theme/ApiDemoPanel/Server/index.js +3 -3
- package/lib/theme/ApiDemoPanel/Server/styles.module.css +0 -4
- package/lib/theme/ApiItem/Content/index.js +65 -0
- package/lib/theme/ApiItem/Footer/index.js +78 -0
- package/lib/theme/ApiItem/Footer/styles.module.css +18 -0
- package/lib/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
- package/lib/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
- package/lib/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
- package/lib/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
- package/lib/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
- package/lib/theme/ApiItem/Layout/index.js +93 -0
- package/lib/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +42 -4
- package/lib/theme/ApiItem/Metadata/index.js +32 -0
- package/lib/theme/ApiItem/Paginator/index.js +33 -0
- package/lib/theme/ApiItem/TOC/Desktop/index.js +31 -0
- package/lib/theme/ApiItem/TOC/Mobile/index.js +35 -0
- package/lib/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
- package/lib/theme/ApiItem/index.js +37 -126
- package/lib/theme/ApiTabs/index.js +17 -6
- package/lib/theme/ApiTabs/styles.module.css +0 -1
- package/lib/theme/SchemaTabs/index.js +258 -0
- package/lib/theme/SchemaTabs/styles.module.css +110 -0
- package/lib-next/theme/ApiDemoPanel/CodeTabs/index.js +7 -6
- package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +6 -2
- package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +3 -2
- package/lib-next/theme/ApiDemoPanel/LiveEditor/index.js +14 -3
- package/lib-next/theme/ApiDemoPanel/LiveEditor/styles.module.css +2 -1
- package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -4
- package/lib-next/theme/ApiDemoPanel/Server/index.js +3 -2
- package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +0 -4
- package/lib-next/theme/ApiItem/Content/index.js +55 -0
- package/lib-next/theme/ApiItem/Footer/index.js +88 -0
- package/lib-next/theme/ApiItem/Footer/styles.module.css +18 -0
- package/lib-next/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
- package/lib-next/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
- package/lib-next/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
- package/lib-next/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
- package/lib-next/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
- package/lib-next/theme/ApiItem/Layout/index.js +69 -0
- package/lib-next/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +42 -4
- package/lib-next/theme/ApiItem/Metadata/index.js +21 -0
- package/lib-next/theme/ApiItem/Paginator/index.js +19 -0
- package/lib-next/theme/ApiItem/TOC/Desktop/index.js +22 -0
- package/lib-next/theme/ApiItem/TOC/Mobile/index.js +24 -0
- package/lib-next/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
- package/lib-next/theme/ApiItem/index.js +31 -133
- package/lib-next/theme/ApiTabs/index.js +17 -6
- package/lib-next/theme/ApiTabs/styles.module.css +0 -1
- package/lib-next/theme/SchemaTabs/index.js +258 -0
- package/lib-next/theme/SchemaTabs/styles.module.css +110 -0
- package/package.json +6 -6
- package/src/theme/ApiDemoPanel/CodeTabs/index.tsx +6 -5
- package/src/theme/ApiDemoPanel/FloatingButton/index.tsx +6 -2
- package/src/theme/ApiDemoPanel/FloatingButton/styles.module.css +3 -2
- package/src/theme/ApiDemoPanel/LiveEditor/index.tsx +15 -3
- package/src/theme/ApiDemoPanel/LiveEditor/styles.module.css +2 -1
- package/src/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -4
- package/src/theme/ApiDemoPanel/Server/index.tsx +3 -2
- package/src/theme/ApiDemoPanel/Server/styles.module.css +0 -4
- package/src/theme/ApiItem/Content/index.tsx +57 -0
- package/src/theme/ApiItem/Footer/index.tsx +101 -0
- package/src/theme/ApiItem/Footer/styles.module.css +18 -0
- package/src/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
- package/src/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
- package/src/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
- package/src/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
- package/src/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
- package/src/theme/ApiItem/Layout/index.tsx +78 -0
- package/src/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +42 -4
- package/src/theme/ApiItem/Metadata/index.tsx +24 -0
- package/src/theme/ApiItem/Paginator/index.tsx +21 -0
- package/src/theme/ApiItem/TOC/Desktop/index.tsx +25 -0
- package/src/theme/ApiItem/TOC/Mobile/index.tsx +28 -0
- package/src/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
- package/src/theme/ApiItem/index.tsx +31 -130
- package/src/theme/ApiTabs/index.js +17 -6
- package/src/theme/ApiTabs/styles.module.css +0 -1
- package/src/theme/SchemaTabs/index.js +258 -0
- package/src/theme/SchemaTabs/styles.module.css +110 -0
|
@@ -9,20 +9,22 @@ import React, {
|
|
|
9
9
|
Children,
|
|
10
10
|
cloneElement,
|
|
11
11
|
isValidElement,
|
|
12
|
+
useEffect,
|
|
12
13
|
useRef,
|
|
13
14
|
useState,
|
|
14
15
|
} from "react";
|
|
15
16
|
|
|
16
|
-
import {
|
|
17
|
-
duplicates,
|
|
18
|
-
useScrollPositionBlocker,
|
|
19
|
-
useTabGroupChoice,
|
|
20
|
-
} from "@docusaurus/theme-common";
|
|
17
|
+
import { duplicates } from "@docusaurus/theme-common";
|
|
21
18
|
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
22
19
|
import clsx from "clsx";
|
|
23
20
|
|
|
24
21
|
import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
|
|
25
22
|
|
|
23
|
+
const {
|
|
24
|
+
useScrollPositionBlocker,
|
|
25
|
+
useTabGroupChoice,
|
|
26
|
+
} = require("@docusaurus/theme-common/internal");
|
|
27
|
+
|
|
26
28
|
// allowing customization
|
|
27
29
|
|
|
28
30
|
function isTabItem(comp) {
|
|
@@ -142,7 +144,16 @@ function ApiTabsComponent(props) {
|
|
|
142
144
|
};
|
|
143
145
|
|
|
144
146
|
const tabItemListContainerRef = useRef(null);
|
|
145
|
-
const showTabArrows =
|
|
147
|
+
const [showTabArrows, setShowTabArrows] = useState(false);
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const tabOffsetWidth = tabItemListContainerRef.current.offsetWidth;
|
|
151
|
+
const tabScrollWidth = tabItemListContainerRef.current.scrollWidth;
|
|
152
|
+
|
|
153
|
+
if (tabOffsetWidth < tabScrollWidth) {
|
|
154
|
+
setShowTabArrows(true);
|
|
155
|
+
}
|
|
156
|
+
}, []);
|
|
146
157
|
|
|
147
158
|
const handleRightClick = () => {
|
|
148
159
|
tabItemListContainerRef.current.scrollLeft += 90;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
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
|
+
import React, {
|
|
9
|
+
Children,
|
|
10
|
+
cloneElement,
|
|
11
|
+
isValidElement,
|
|
12
|
+
useEffect,
|
|
13
|
+
useRef,
|
|
14
|
+
useState,
|
|
15
|
+
} from "react";
|
|
16
|
+
|
|
17
|
+
import { duplicates } from "@docusaurus/theme-common";
|
|
18
|
+
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
19
|
+
import clsx from "clsx";
|
|
20
|
+
|
|
21
|
+
import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
useScrollPositionBlocker,
|
|
25
|
+
useTabGroupChoice,
|
|
26
|
+
} = require("@docusaurus/theme-common/internal");
|
|
27
|
+
|
|
28
|
+
// allowing customization
|
|
29
|
+
|
|
30
|
+
function isTabItem(comp) {
|
|
31
|
+
return typeof comp.props.value !== "undefined";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function SchemaTabsComponent(props) {
|
|
35
|
+
const {
|
|
36
|
+
lazy,
|
|
37
|
+
block,
|
|
38
|
+
defaultValue: defaultValueProp,
|
|
39
|
+
values: valuesProp,
|
|
40
|
+
groupId,
|
|
41
|
+
className,
|
|
42
|
+
} = props;
|
|
43
|
+
const children = Children.map(props.children, (child) => {
|
|
44
|
+
if (isValidElement(child) && isTabItem(child)) {
|
|
45
|
+
return child;
|
|
46
|
+
} // child.type.name will give non-sensical values in prod because of
|
|
47
|
+
// minification, but we assume it won't throw in prod.
|
|
48
|
+
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Docusaurus error: Bad <Tabs> child <${
|
|
51
|
+
// @ts-expect-error: guarding against unexpected cases
|
|
52
|
+
typeof child.type === "string" ? child.type : child.type.name
|
|
53
|
+
}>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
const values =
|
|
57
|
+
valuesProp ?? // We only pick keys that we recognize. MDX would inject some keys by default
|
|
58
|
+
children.map(({ props: { value, label, attributes } }) => ({
|
|
59
|
+
value,
|
|
60
|
+
label,
|
|
61
|
+
attributes,
|
|
62
|
+
}));
|
|
63
|
+
const dup = duplicates(values, (a, b) => a.value === b.value);
|
|
64
|
+
|
|
65
|
+
if (dup.length > 0) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`Docusaurus error: Duplicate values "${dup
|
|
68
|
+
.map((a) => a.value)
|
|
69
|
+
.join(", ")}" found in <Tabs>. Every value needs to be unique.`
|
|
70
|
+
);
|
|
71
|
+
} // When defaultValueProp is null, don't show a default tab
|
|
72
|
+
|
|
73
|
+
const defaultValue =
|
|
74
|
+
defaultValueProp === null
|
|
75
|
+
? defaultValueProp
|
|
76
|
+
: defaultValueProp ??
|
|
77
|
+
children.find((child) => child.props.default)?.props.value ??
|
|
78
|
+
children[0]?.props.value;
|
|
79
|
+
|
|
80
|
+
if (defaultValue !== null && !values.some((a) => a.value === defaultValue)) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Docusaurus error: The <Tabs> has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values
|
|
83
|
+
.map((a) => a.value)
|
|
84
|
+
.join(
|
|
85
|
+
", "
|
|
86
|
+
)}. If you intend to show no default tab, use defaultValue={null} instead.`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const { tabGroupChoices, setTabGroupChoices } = useTabGroupChoice();
|
|
91
|
+
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
|
92
|
+
const tabRefs = [];
|
|
93
|
+
const { blockElementScrollPositionUntilNextRender } =
|
|
94
|
+
useScrollPositionBlocker();
|
|
95
|
+
|
|
96
|
+
if (groupId != null) {
|
|
97
|
+
const relevantTabGroupChoice = tabGroupChoices[groupId];
|
|
98
|
+
|
|
99
|
+
if (
|
|
100
|
+
relevantTabGroupChoice != null &&
|
|
101
|
+
relevantTabGroupChoice !== selectedValue &&
|
|
102
|
+
values.some((value) => value.value === relevantTabGroupChoice)
|
|
103
|
+
) {
|
|
104
|
+
setSelectedValue(relevantTabGroupChoice);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const handleTabChange = (event) => {
|
|
109
|
+
const newTab = event.currentTarget;
|
|
110
|
+
const newTabIndex = tabRefs.indexOf(newTab);
|
|
111
|
+
const newTabValue = values[newTabIndex].value;
|
|
112
|
+
|
|
113
|
+
if (newTabValue !== selectedValue) {
|
|
114
|
+
blockElementScrollPositionUntilNextRender(newTab);
|
|
115
|
+
setSelectedValue(newTabValue);
|
|
116
|
+
|
|
117
|
+
if (groupId != null) {
|
|
118
|
+
setTabGroupChoices(groupId, newTabValue);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const handleKeydown = (event) => {
|
|
124
|
+
let focusElement = null;
|
|
125
|
+
|
|
126
|
+
switch (event.key) {
|
|
127
|
+
case "ArrowRight": {
|
|
128
|
+
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
|
|
129
|
+
focusElement = tabRefs[nextTab] || tabRefs[0];
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
case "ArrowLeft": {
|
|
134
|
+
const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
|
|
135
|
+
focusElement = tabRefs[prevTab] || tabRefs[tabRefs.length - 1];
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
default:
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
focusElement?.focus();
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const tabItemListContainerRef = useRef(null);
|
|
147
|
+
const [showTabArrows, setShowTabArrows] = useState(false);
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
const tabOffsetWidth = tabItemListContainerRef.current.offsetWidth;
|
|
151
|
+
const tabScrollWidth = tabItemListContainerRef.current.scrollWidth;
|
|
152
|
+
|
|
153
|
+
if (tabOffsetWidth < tabScrollWidth) {
|
|
154
|
+
setShowTabArrows(true);
|
|
155
|
+
}
|
|
156
|
+
}, []);
|
|
157
|
+
|
|
158
|
+
const handleRightClick = () => {
|
|
159
|
+
tabItemListContainerRef.current.scrollLeft += 90;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const handleLeftClick = () => {
|
|
163
|
+
tabItemListContainerRef.current.scrollLeft -= 90;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<div className="tabs__container">
|
|
168
|
+
<div className={styles.schemaTabsTopSection}>
|
|
169
|
+
<div className={styles.schemaTabsContainer}>
|
|
170
|
+
{showTabArrows && (
|
|
171
|
+
<button
|
|
172
|
+
className={clsx(styles.tabArrow, styles.tabArrowLeft)}
|
|
173
|
+
onClick={handleLeftClick}
|
|
174
|
+
/>
|
|
175
|
+
)}
|
|
176
|
+
<ul
|
|
177
|
+
ref={tabItemListContainerRef}
|
|
178
|
+
role="tablist"
|
|
179
|
+
aria-orientation="horizontal"
|
|
180
|
+
className={clsx(
|
|
181
|
+
styles.schemaTabsListContainer,
|
|
182
|
+
"tabs",
|
|
183
|
+
{
|
|
184
|
+
"tabs--block": block,
|
|
185
|
+
},
|
|
186
|
+
className
|
|
187
|
+
)}
|
|
188
|
+
>
|
|
189
|
+
{values.map(({ value, label, attributes }) => {
|
|
190
|
+
return (
|
|
191
|
+
<li
|
|
192
|
+
role="tab"
|
|
193
|
+
tabIndex={selectedValue === value ? 0 : -1}
|
|
194
|
+
aria-selected={selectedValue === value}
|
|
195
|
+
key={value}
|
|
196
|
+
ref={(tabControl) => tabRefs.push(tabControl)}
|
|
197
|
+
onKeyDown={handleKeydown}
|
|
198
|
+
onFocus={handleTabChange}
|
|
199
|
+
onClick={handleTabChange}
|
|
200
|
+
{...attributes}
|
|
201
|
+
className={clsx(
|
|
202
|
+
"tabs__item",
|
|
203
|
+
styles.tabItem,
|
|
204
|
+
attributes?.className,
|
|
205
|
+
{
|
|
206
|
+
[styles.schemaTabActive]: selectedValue === value,
|
|
207
|
+
}
|
|
208
|
+
)}
|
|
209
|
+
>
|
|
210
|
+
<span className={styles.schemaTabLabel}>
|
|
211
|
+
{label ?? value}
|
|
212
|
+
</span>
|
|
213
|
+
</li>
|
|
214
|
+
);
|
|
215
|
+
})}
|
|
216
|
+
</ul>
|
|
217
|
+
{showTabArrows && (
|
|
218
|
+
<button
|
|
219
|
+
className={clsx(styles.tabArrow, styles.tabArrowRight)}
|
|
220
|
+
onClick={handleRightClick}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
</div>
|
|
224
|
+
</div>
|
|
225
|
+
<hr />
|
|
226
|
+
{lazy ? (
|
|
227
|
+
cloneElement(
|
|
228
|
+
children.filter(
|
|
229
|
+
(tabItem) => tabItem.props.value === selectedValue
|
|
230
|
+
)[0],
|
|
231
|
+
{
|
|
232
|
+
className: clsx("margin-vert--md", styles.schemaTabsContainer),
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
) : (
|
|
236
|
+
<div className={clsx("margin-vert--md", styles.schemaTabsContainer)}>
|
|
237
|
+
{children.map((tabItem, i) =>
|
|
238
|
+
cloneElement(tabItem, {
|
|
239
|
+
key: i,
|
|
240
|
+
hidden: tabItem.props.value !== selectedValue,
|
|
241
|
+
})
|
|
242
|
+
)}
|
|
243
|
+
</div>
|
|
244
|
+
)}
|
|
245
|
+
</div>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export default function SchemaTabs(props) {
|
|
250
|
+
const isBrowser = useIsBrowser();
|
|
251
|
+
return (
|
|
252
|
+
<SchemaTabsComponent // Remount tabs after hydration
|
|
253
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
254
|
+
key={String(isBrowser)}
|
|
255
|
+
{...props}
|
|
256
|
+
/>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
.tabItem {
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
height: 1.8rem;
|
|
13
|
+
margin-top: 0 !important;
|
|
14
|
+
margin-right: 0.5rem;
|
|
15
|
+
border: 1px solid var(--openapi-code-dim-dark);
|
|
16
|
+
border-radius: var(--ifm-global-radius);
|
|
17
|
+
color: var(--openapi-code-dim-dark);
|
|
18
|
+
font-size: 12px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tabItem:hover {
|
|
22
|
+
color: var(--ifm-color-emphasis-500) !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.tabItem:last-child {
|
|
26
|
+
margin-right: 0 !important;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Open API Schema Tabs */
|
|
30
|
+
.schemaTabsTopSection {
|
|
31
|
+
margin-top: 1rem;
|
|
32
|
+
display: flex;
|
|
33
|
+
justify-content: space-between;
|
|
34
|
+
align-items: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.schemaTabsTopSection + hr {
|
|
38
|
+
display: none;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.schemaTabsContainer {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
44
|
+
max-width: 390px;
|
|
45
|
+
padding-left: 3px;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.schemaTabsListContainer {
|
|
50
|
+
padding: 0 0.25rem;
|
|
51
|
+
overflow-y: hidden;
|
|
52
|
+
overflow-x: scroll;
|
|
53
|
+
scroll-behavior: smooth;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.schemaTabsListContainer::-webkit-scrollbar {
|
|
57
|
+
display: none;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.tabItem.schemaTabActive {
|
|
61
|
+
border: 1px solid var(--ifm-color-primary);
|
|
62
|
+
color: var(--ifm-color-primary);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.schemaTabLabel {
|
|
66
|
+
white-space: nowrap;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.schemaTabsContainer {
|
|
70
|
+
max-width: 600px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* Tab Arrows */
|
|
74
|
+
.tabArrow {
|
|
75
|
+
content: "";
|
|
76
|
+
height: 1.25rem;
|
|
77
|
+
width: 1.25rem;
|
|
78
|
+
padding: 0 0.75rem;
|
|
79
|
+
border: none;
|
|
80
|
+
min-width: 1.25rem;
|
|
81
|
+
background: var(--ifm-menu-link-sublist-icon) 50% / 2rem 2rem;
|
|
82
|
+
filter: var(--ifm-menu-link-sublist-icon-filter);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.tabArrow:hover {
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.tabArrowLeft {
|
|
90
|
+
transform: rotate(270deg);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.tabArrowRight {
|
|
94
|
+
transform: rotate(90deg);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@media screen and (max-width: 500px) {
|
|
98
|
+
.schemaTabsTopSection {
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
align-items: flex-start;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.schemaTabsContainer {
|
|
104
|
+
width: 100%;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.tabItem {
|
|
108
|
+
height: 100%;
|
|
109
|
+
}
|
|
110
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-theme-openapi-docs",
|
|
3
3
|
"description": "OpenAPI theme for Docusaurus.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@docusaurus/module-type-aliases": "2.0.0-
|
|
35
|
-
"@docusaurus/types": "2.0.0-
|
|
34
|
+
"@docusaurus/module-type-aliases": "2.0.0-rc.1",
|
|
35
|
+
"@docusaurus/types": "2.0.0-rc.1",
|
|
36
36
|
"@types/concurrently": "^6.3.0",
|
|
37
37
|
"@types/crypto-js": "^4.1.0",
|
|
38
38
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"concurrently": "^5.2.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@docusaurus/theme-common": "2.0.0-
|
|
45
|
+
"@docusaurus/theme-common": "2.0.0-rc.1",
|
|
46
46
|
"@mdx-js/react": "^1.6.21",
|
|
47
47
|
"@paloaltonetworks/postman-code-generators": "1.1.5-hotfix.5",
|
|
48
48
|
"@paloaltonetworks/postman-collection": "^4.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"buffer": "^6.0.3",
|
|
51
51
|
"clsx": "^1.1.1",
|
|
52
52
|
"crypto-js": "^4.1.1",
|
|
53
|
-
"docusaurus-plugin-openapi-docs": "^1.
|
|
53
|
+
"docusaurus-plugin-openapi-docs": "^1.1.2",
|
|
54
54
|
"immer": "^9.0.7",
|
|
55
55
|
"lodash": "^4.17.20",
|
|
56
56
|
"process": "^0.11.10",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "0c66efff6ff553647265abdc27d4ca847c6d8045"
|
|
72
72
|
}
|
|
@@ -12,11 +12,7 @@ import React, {
|
|
|
12
12
|
type ReactElement,
|
|
13
13
|
} from "react";
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
useScrollPositionBlocker,
|
|
17
|
-
duplicates,
|
|
18
|
-
useTabGroupChoice,
|
|
19
|
-
} from "@docusaurus/theme-common";
|
|
15
|
+
import { duplicates } from "@docusaurus/theme-common";
|
|
20
16
|
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
21
17
|
import type { Props as TabItemProps } from "@theme/TabItem";
|
|
22
18
|
import clsx from "clsx";
|
|
@@ -24,6 +20,11 @@ import clsx from "clsx";
|
|
|
24
20
|
import { languageSet } from "../Curl";
|
|
25
21
|
import styles from "./styles.module.css";
|
|
26
22
|
|
|
23
|
+
const {
|
|
24
|
+
useScrollPositionBlocker,
|
|
25
|
+
useTabGroupChoice,
|
|
26
|
+
} = require("@docusaurus/theme-common/internal");
|
|
27
|
+
|
|
27
28
|
// A very rough duck type, but good enough to guard against mistakes while
|
|
28
29
|
// allowing customization
|
|
29
30
|
function isTabItem(
|
|
@@ -17,8 +17,12 @@ interface Props {
|
|
|
17
17
|
|
|
18
18
|
function FloatingButton({ label, onClick, children }: Props) {
|
|
19
19
|
return (
|
|
20
|
-
<div className={styles.floatingButton}>
|
|
21
|
-
{label &&
|
|
20
|
+
<div tabIndex={0} className={styles.floatingButton}>
|
|
21
|
+
{label && (
|
|
22
|
+
<button tabIndex={0} onClick={onClick}>
|
|
23
|
+
{label}
|
|
24
|
+
</button>
|
|
25
|
+
)}
|
|
22
26
|
{children}
|
|
23
27
|
</div>
|
|
24
28
|
);
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
border-radius: var(--ifm-global-radius);
|
|
10
10
|
color: var(--ifm-color-white);
|
|
11
11
|
cursor: pointer;
|
|
12
|
-
outline: none;
|
|
13
12
|
padding: 0.4rem 0.5rem;
|
|
14
13
|
opacity: 0;
|
|
15
14
|
visibility: hidden;
|
|
@@ -20,7 +19,9 @@
|
|
|
20
19
|
right: calc(var(--ifm-pre-padding) / 2);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
.floatingButton:hover button
|
|
22
|
+
.floatingButton:hover button,
|
|
23
|
+
.floatingButton:focus-visible button,
|
|
24
|
+
.floatingButton button:focus-visible {
|
|
24
25
|
visibility: visible;
|
|
25
26
|
opacity: 1;
|
|
26
27
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
* ========================================================================== */
|
|
7
7
|
|
|
8
|
-
import React from "react";
|
|
8
|
+
import React, { useState } from "react";
|
|
9
9
|
|
|
10
10
|
import { usePrismTheme } from "@docusaurus/theme-common";
|
|
11
11
|
import useIsBrowser from "@docusaurus/useIsBrowser";
|
|
@@ -16,14 +16,26 @@ import styles from "./styles.module.css";
|
|
|
16
16
|
|
|
17
17
|
function Live({ onEdit }: any) {
|
|
18
18
|
const isBrowser = useIsBrowser();
|
|
19
|
+
const [editorDisabled, setEditorDisabled] = useState(false);
|
|
20
|
+
|
|
21
|
+
// TODO: Temporary solution for disabling tab key
|
|
22
|
+
const handleKeydown = (event: React.KeyboardEvent) => {
|
|
23
|
+
if (event.key === "Tab") {
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
setEditorDisabled(true);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
19
29
|
return (
|
|
20
|
-
|
|
30
|
+
<div onClick={() => setEditorDisabled(false)}>
|
|
21
31
|
<LiveEditor
|
|
22
32
|
key={String(isBrowser)}
|
|
23
33
|
className={styles.playgroundEditor}
|
|
24
34
|
onChange={onEdit}
|
|
35
|
+
disabled={editorDisabled}
|
|
36
|
+
onKeyDown={handleKeydown}
|
|
25
37
|
/>
|
|
26
|
-
|
|
38
|
+
</div>
|
|
27
39
|
);
|
|
28
40
|
}
|
|
29
41
|
|
|
@@ -26,7 +26,7 @@ function Server() {
|
|
|
26
26
|
return null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if (options.length
|
|
29
|
+
if (options.length < 1 && value?.variables === undefined) {
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -62,10 +62,11 @@ function Server() {
|
|
|
62
62
|
<button
|
|
63
63
|
className={styles.showMoreButton}
|
|
64
64
|
onClick={() => setIsEditing(false)}
|
|
65
|
+
tabIndex={0}
|
|
65
66
|
>
|
|
66
67
|
Hide
|
|
67
68
|
</button>
|
|
68
|
-
<FormItem label="
|
|
69
|
+
<FormItem label="Base URL">
|
|
69
70
|
<FormSelect
|
|
70
71
|
options={options.map((s) => s.url)}
|
|
71
72
|
onChange={(e) => dispatch(setServer(e.target.value))}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
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
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import { ThemeClassNames } from "@docusaurus/theme-common";
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
import { useDoc } from "@docusaurus/theme-common/internal";
|
|
13
|
+
import type { Props } from "@theme/DocItem/Content";
|
|
14
|
+
import Heading from "@theme/Heading";
|
|
15
|
+
import MDXContent from "@theme/MDXContent";
|
|
16
|
+
import clsx from "clsx";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
Title can be declared inside md content or declared through
|
|
20
|
+
front matter and added manually. To make both cases consistent,
|
|
21
|
+
the added title is added under the same div.markdown block
|
|
22
|
+
See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
|
|
23
|
+
|
|
24
|
+
We render a "synthetic title" if:
|
|
25
|
+
- user doesn't ask to hide it with front matter
|
|
26
|
+
- the markdown content does not already contain a top-level h1 heading
|
|
27
|
+
*/
|
|
28
|
+
function useSyntheticTitle(): string | null {
|
|
29
|
+
const { metadata, frontMatter, contentTitle } = useDoc();
|
|
30
|
+
const shouldRender =
|
|
31
|
+
!frontMatter.hide_title && typeof contentTitle === "undefined";
|
|
32
|
+
if (!shouldRender) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return metadata.title;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default function DocItemContent({ children }: Props): JSX.Element {
|
|
39
|
+
const syntheticTitle = useSyntheticTitle();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
className={clsx(
|
|
44
|
+
ThemeClassNames.docs.docMarkdown,
|
|
45
|
+
"theme-api-markdown",
|
|
46
|
+
"markdown"
|
|
47
|
+
)}
|
|
48
|
+
>
|
|
49
|
+
{syntheticTitle && (
|
|
50
|
+
<header>
|
|
51
|
+
<Heading as="h1">{syntheticTitle}</Heading>
|
|
52
|
+
</header>
|
|
53
|
+
)}
|
|
54
|
+
<MDXContent>{children}</MDXContent>
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
}
|