docusaurus-theme-openapi-docs 0.0.0-387 → 0.0.0-391

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.
@@ -3,7 +3,8 @@
3
3
  margin-bottom: var(--ifm-leading);
4
4
  border-radius: var(--ifm-global-radius);
5
5
  box-shadow: var(--ifm-global-shadow-lw);
6
- overflow: hidden;
6
+ overflow: auto;
7
+ max-height: 500px;
7
8
  }
8
9
 
9
10
  .playgroundHeader {
@@ -70,10 +70,6 @@
70
70
  padding-top: 5px;
71
71
  }
72
72
 
73
- :global(.theme-api-markdown details li:last-child) {
74
- border-left: none;
75
- }
76
-
77
73
  :global(.theme-api-markdown details p) {
78
74
  margin-bottom: 0;
79
75
  }
@@ -147,6 +143,11 @@
147
143
  border-bottom-color: var(--ifm-color-success);
148
144
  }
149
145
 
146
+ :global(.language-python) {
147
+ max-height: 500px;
148
+ overflow: auto;
149
+ }
150
+
150
151
  :global(.code__tab--go::after) {
151
152
  content: "";
152
153
  width: 32px;
@@ -165,6 +166,11 @@
165
166
  border-bottom-color: var(--ifm-color-info);
166
167
  }
167
168
 
169
+ :global(.language-go) {
170
+ max-height: 500px;
171
+ overflow: auto;
172
+ }
173
+
168
174
  :global(.code__tab--javascript::after) {
169
175
  content: "";
170
176
  width: 32px;
@@ -183,6 +189,11 @@
183
189
  border-bottom-color: var(--ifm-color-warning);
184
190
  }
185
191
 
192
+ :global(.language-javascript) {
193
+ max-height: 500px;
194
+ overflow: auto;
195
+ }
196
+
186
197
  :global(.code__tab--bash::after) {
187
198
  content: "";
188
199
  width: 32px;
@@ -200,3 +211,8 @@
200
211
  :global(.code__tab--bash.tabs__item--active) {
201
212
  border-bottom-color: var(--ifm-color-danger);
202
213
  }
214
+
215
+ :global(.language-bash) {
216
+ max-height: 500px;
217
+ overflow: auto;
218
+ }
@@ -9,6 +9,7 @@ import React, {
9
9
  Children,
10
10
  cloneElement,
11
11
  isValidElement,
12
+ useEffect,
12
13
  useRef,
13
14
  useState,
14
15
  } from "react";
@@ -142,7 +143,16 @@ function ApiTabsComponent(props) {
142
143
  };
143
144
 
144
145
  const tabItemListContainerRef = useRef(null);
145
- const showTabArrows = values.length >= 5;
146
+ const [showTabArrows, setShowTabArrows] = useState(false);
147
+
148
+ useEffect(() => {
149
+ const tabOffsetWidth = tabItemListContainerRef.current.offsetWidth;
150
+ const tabScrollWidth = tabItemListContainerRef.current.scrollWidth;
151
+
152
+ if (tabOffsetWidth < tabScrollWidth) {
153
+ setShowTabArrows(true);
154
+ }
155
+ }, []);
146
156
 
147
157
  const handleRightClick = () => {
148
158
  tabItemListContainerRef.current.scrollLeft += 90;
@@ -87,7 +87,6 @@
87
87
  content: "";
88
88
  height: 1.25rem;
89
89
  width: 1.25rem;
90
- padding: 0 0.75rem;
91
90
  border: none;
92
91
  min-width: 1.25rem;
93
92
  background: var(--ifm-menu-link-sublist-icon) 50% / 2rem 2rem;
@@ -0,0 +1,257 @@
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 {
18
+ duplicates,
19
+ useScrollPositionBlocker,
20
+ useTabGroupChoice,
21
+ } from "@docusaurus/theme-common";
22
+ import useIsBrowser from "@docusaurus/useIsBrowser";
23
+ import clsx from "clsx";
24
+
25
+ import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
26
+
27
+ // allowing customization
28
+
29
+ function isTabItem(comp) {
30
+ return typeof comp.props.value !== "undefined";
31
+ }
32
+
33
+ function SchemaTabsComponent(props) {
34
+ const {
35
+ lazy,
36
+ block,
37
+ defaultValue: defaultValueProp,
38
+ values: valuesProp,
39
+ groupId,
40
+ className,
41
+ } = props;
42
+ const children = Children.map(props.children, (child) => {
43
+ if (isValidElement(child) && isTabItem(child)) {
44
+ return child;
45
+ } // child.type.name will give non-sensical values in prod because of
46
+ // minification, but we assume it won't throw in prod.
47
+
48
+ throw new Error(
49
+ `Docusaurus error: Bad <Tabs> child <${
50
+ // @ts-expect-error: guarding against unexpected cases
51
+ typeof child.type === "string" ? child.type : child.type.name
52
+ }>: all children of the <Tabs> component should be <TabItem>, and every <TabItem> should have a unique "value" prop.`
53
+ );
54
+ });
55
+ const values =
56
+ valuesProp ?? // We only pick keys that we recognize. MDX would inject some keys by default
57
+ children.map(({ props: { value, label, attributes } }) => ({
58
+ value,
59
+ label,
60
+ attributes,
61
+ }));
62
+ const dup = duplicates(values, (a, b) => a.value === b.value);
63
+
64
+ if (dup.length > 0) {
65
+ throw new Error(
66
+ `Docusaurus error: Duplicate values "${dup
67
+ .map((a) => a.value)
68
+ .join(", ")}" found in <Tabs>. Every value needs to be unique.`
69
+ );
70
+ } // When defaultValueProp is null, don't show a default tab
71
+
72
+ const defaultValue =
73
+ defaultValueProp === null
74
+ ? defaultValueProp
75
+ : defaultValueProp ??
76
+ children.find((child) => child.props.default)?.props.value ??
77
+ children[0]?.props.value;
78
+
79
+ if (defaultValue !== null && !values.some((a) => a.value === defaultValue)) {
80
+ throw new Error(
81
+ `Docusaurus error: The <Tabs> has a defaultValue "${defaultValue}" but none of its children has the corresponding value. Available values are: ${values
82
+ .map((a) => a.value)
83
+ .join(
84
+ ", "
85
+ )}. If you intend to show no default tab, use defaultValue={null} instead.`
86
+ );
87
+ }
88
+
89
+ const { tabGroupChoices, setTabGroupChoices } = useTabGroupChoice();
90
+ const [selectedValue, setSelectedValue] = useState(defaultValue);
91
+ const tabRefs = [];
92
+ const { blockElementScrollPositionUntilNextRender } =
93
+ useScrollPositionBlocker();
94
+
95
+ if (groupId != null) {
96
+ const relevantTabGroupChoice = tabGroupChoices[groupId];
97
+
98
+ if (
99
+ relevantTabGroupChoice != null &&
100
+ relevantTabGroupChoice !== selectedValue &&
101
+ values.some((value) => value.value === relevantTabGroupChoice)
102
+ ) {
103
+ setSelectedValue(relevantTabGroupChoice);
104
+ }
105
+ }
106
+
107
+ const handleTabChange = (event) => {
108
+ const newTab = event.currentTarget;
109
+ const newTabIndex = tabRefs.indexOf(newTab);
110
+ const newTabValue = values[newTabIndex].value;
111
+
112
+ if (newTabValue !== selectedValue) {
113
+ blockElementScrollPositionUntilNextRender(newTab);
114
+ setSelectedValue(newTabValue);
115
+
116
+ if (groupId != null) {
117
+ setTabGroupChoices(groupId, newTabValue);
118
+ }
119
+ }
120
+ };
121
+
122
+ const handleKeydown = (event) => {
123
+ let focusElement = null;
124
+
125
+ switch (event.key) {
126
+ case "ArrowRight": {
127
+ const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
128
+ focusElement = tabRefs[nextTab] || tabRefs[0];
129
+ break;
130
+ }
131
+
132
+ case "ArrowLeft": {
133
+ const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
134
+ focusElement = tabRefs[prevTab] || tabRefs[tabRefs.length - 1];
135
+ break;
136
+ }
137
+
138
+ default:
139
+ break;
140
+ }
141
+
142
+ focusElement?.focus();
143
+ };
144
+
145
+ const tabItemListContainerRef = useRef(null);
146
+ const [showTabArrows, setShowTabArrows] = useState(false);
147
+
148
+ useEffect(() => {
149
+ const tabOffsetWidth = tabItemListContainerRef.current.offsetWidth;
150
+ const tabScrollWidth = tabItemListContainerRef.current.scrollWidth;
151
+
152
+ if (tabOffsetWidth < tabScrollWidth) {
153
+ setShowTabArrows(true);
154
+ }
155
+ }, []);
156
+
157
+ const handleRightClick = () => {
158
+ tabItemListContainerRef.current.scrollLeft += 90;
159
+ };
160
+
161
+ const handleLeftClick = () => {
162
+ tabItemListContainerRef.current.scrollLeft -= 90;
163
+ };
164
+
165
+ return (
166
+ <div className="tabs__container">
167
+ <div className={styles.schemaTabsTopSection}>
168
+ <div className={styles.schemaTabsContainer}>
169
+ {showTabArrows && (
170
+ <button
171
+ className={clsx(styles.tabArrow, styles.tabArrowLeft)}
172
+ onClick={handleLeftClick}
173
+ />
174
+ )}
175
+ <ul
176
+ ref={tabItemListContainerRef}
177
+ role="tablist"
178
+ aria-orientation="horizontal"
179
+ className={clsx(
180
+ styles.schemaTabsListContainer,
181
+ "tabs",
182
+ {
183
+ "tabs--block": block,
184
+ },
185
+ className
186
+ )}
187
+ >
188
+ {values.map(({ value, label, attributes }) => {
189
+ return (
190
+ <li
191
+ role="tab"
192
+ tabIndex={selectedValue === value ? 0 : -1}
193
+ aria-selected={selectedValue === value}
194
+ key={value}
195
+ ref={(tabControl) => tabRefs.push(tabControl)}
196
+ onKeyDown={handleKeydown}
197
+ onFocus={handleTabChange}
198
+ onClick={handleTabChange}
199
+ {...attributes}
200
+ className={clsx(
201
+ "tabs__item",
202
+ styles.tabItem,
203
+ attributes?.className,
204
+ {
205
+ [styles.schemaTabActive]: selectedValue === value,
206
+ }
207
+ )}
208
+ >
209
+ <span className={styles.schemaTabLabel}>
210
+ {label ?? value}
211
+ </span>
212
+ </li>
213
+ );
214
+ })}
215
+ </ul>
216
+ {showTabArrows && (
217
+ <button
218
+ className={clsx(styles.tabArrow, styles.tabArrowRight)}
219
+ onClick={handleRightClick}
220
+ />
221
+ )}
222
+ </div>
223
+ </div>
224
+ <hr />
225
+ {lazy ? (
226
+ cloneElement(
227
+ children.filter(
228
+ (tabItem) => tabItem.props.value === selectedValue
229
+ )[0],
230
+ {
231
+ className: clsx("margin-vert--md", styles.schemaTabsContainer),
232
+ }
233
+ )
234
+ ) : (
235
+ <div className={clsx("margin-vert--md", styles.schemaTabsContainer)}>
236
+ {children.map((tabItem, i) =>
237
+ cloneElement(tabItem, {
238
+ key: i,
239
+ hidden: tabItem.props.value !== selectedValue,
240
+ })
241
+ )}
242
+ </div>
243
+ )}
244
+ </div>
245
+ );
246
+ }
247
+
248
+ export default function SchemaTabs(props) {
249
+ const isBrowser = useIsBrowser();
250
+ return (
251
+ <SchemaTabsComponent // Remount tabs after hydration
252
+ // Temporary fix for https://github.com/facebook/docusaurus/issues/5653
253
+ key={String(isBrowser)}
254
+ {...props}
255
+ />
256
+ );
257
+ }
@@ -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
+ }
@@ -3,7 +3,8 @@
3
3
  margin-bottom: var(--ifm-leading);
4
4
  border-radius: var(--ifm-global-radius);
5
5
  box-shadow: var(--ifm-global-shadow-lw);
6
- overflow: hidden;
6
+ overflow: auto;
7
+ max-height: 500px;
7
8
  }
8
9
 
9
10
  .playgroundHeader {
@@ -70,10 +70,6 @@
70
70
  padding-top: 5px;
71
71
  }
72
72
 
73
- :global(.theme-api-markdown details li:last-child) {
74
- border-left: none;
75
- }
76
-
77
73
  :global(.theme-api-markdown details p) {
78
74
  margin-bottom: 0;
79
75
  }
@@ -147,6 +143,11 @@
147
143
  border-bottom-color: var(--ifm-color-success);
148
144
  }
149
145
 
146
+ :global(.language-python) {
147
+ max-height: 500px;
148
+ overflow: auto;
149
+ }
150
+
150
151
  :global(.code__tab--go::after) {
151
152
  content: "";
152
153
  width: 32px;
@@ -165,6 +166,11 @@
165
166
  border-bottom-color: var(--ifm-color-info);
166
167
  }
167
168
 
169
+ :global(.language-go) {
170
+ max-height: 500px;
171
+ overflow: auto;
172
+ }
173
+
168
174
  :global(.code__tab--javascript::after) {
169
175
  content: "";
170
176
  width: 32px;
@@ -183,6 +189,11 @@
183
189
  border-bottom-color: var(--ifm-color-warning);
184
190
  }
185
191
 
192
+ :global(.language-javascript) {
193
+ max-height: 500px;
194
+ overflow: auto;
195
+ }
196
+
186
197
  :global(.code__tab--bash::after) {
187
198
  content: "";
188
199
  width: 32px;
@@ -200,3 +211,8 @@
200
211
  :global(.code__tab--bash.tabs__item--active) {
201
212
  border-bottom-color: var(--ifm-color-danger);
202
213
  }
214
+
215
+ :global(.language-bash) {
216
+ max-height: 500px;
217
+ overflow: auto;
218
+ }
@@ -9,6 +9,7 @@ import React, {
9
9
  Children,
10
10
  cloneElement,
11
11
  isValidElement,
12
+ useEffect,
12
13
  useRef,
13
14
  useState,
14
15
  } from "react";
@@ -142,7 +143,16 @@ function ApiTabsComponent(props) {
142
143
  };
143
144
 
144
145
  const tabItemListContainerRef = useRef(null);
145
- const showTabArrows = values.length >= 5;
146
+ const [showTabArrows, setShowTabArrows] = useState(false);
147
+
148
+ useEffect(() => {
149
+ const tabOffsetWidth = tabItemListContainerRef.current.offsetWidth;
150
+ const tabScrollWidth = tabItemListContainerRef.current.scrollWidth;
151
+
152
+ if (tabOffsetWidth < tabScrollWidth) {
153
+ setShowTabArrows(true);
154
+ }
155
+ }, []);
146
156
 
147
157
  const handleRightClick = () => {
148
158
  tabItemListContainerRef.current.scrollLeft += 90;
@@ -87,7 +87,6 @@
87
87
  content: "";
88
88
  height: 1.25rem;
89
89
  width: 1.25rem;
90
- padding: 0 0.75rem;
91
90
  border: none;
92
91
  min-width: 1.25rem;
93
92
  background: var(--ifm-menu-link-sublist-icon) 50% / 2rem 2rem;