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.
Files changed (85) hide show
  1. package/lib/theme/ApiDemoPanel/CodeTabs/index.js +8 -3
  2. package/lib/theme/ApiDemoPanel/FloatingButton/index.js +4 -2
  3. package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +3 -2
  4. package/lib/theme/ApiDemoPanel/LiveEditor/index.js +17 -4
  5. package/lib/theme/ApiDemoPanel/LiveEditor/styles.module.css +2 -1
  6. package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -4
  7. package/lib/theme/ApiDemoPanel/Server/index.js +3 -3
  8. package/lib/theme/ApiDemoPanel/Server/styles.module.css +0 -4
  9. package/lib/theme/ApiItem/Content/index.js +65 -0
  10. package/lib/theme/ApiItem/Footer/index.js +78 -0
  11. package/lib/theme/ApiItem/Footer/styles.module.css +18 -0
  12. package/lib/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  13. package/lib/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  14. package/lib/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  15. package/lib/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  16. package/lib/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  17. package/lib/theme/ApiItem/Layout/index.js +93 -0
  18. package/lib/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +42 -4
  19. package/lib/theme/ApiItem/Metadata/index.js +32 -0
  20. package/lib/theme/ApiItem/Paginator/index.js +33 -0
  21. package/lib/theme/ApiItem/TOC/Desktop/index.js +31 -0
  22. package/lib/theme/ApiItem/TOC/Mobile/index.js +35 -0
  23. package/lib/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  24. package/lib/theme/ApiItem/index.js +37 -126
  25. package/lib/theme/ApiTabs/index.js +17 -6
  26. package/lib/theme/ApiTabs/styles.module.css +0 -1
  27. package/lib/theme/SchemaTabs/index.js +258 -0
  28. package/lib/theme/SchemaTabs/styles.module.css +110 -0
  29. package/lib-next/theme/ApiDemoPanel/CodeTabs/index.js +7 -6
  30. package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +6 -2
  31. package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +3 -2
  32. package/lib-next/theme/ApiDemoPanel/LiveEditor/index.js +14 -3
  33. package/lib-next/theme/ApiDemoPanel/LiveEditor/styles.module.css +2 -1
  34. package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -4
  35. package/lib-next/theme/ApiDemoPanel/Server/index.js +3 -2
  36. package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +0 -4
  37. package/lib-next/theme/ApiItem/Content/index.js +55 -0
  38. package/lib-next/theme/ApiItem/Footer/index.js +88 -0
  39. package/lib-next/theme/ApiItem/Footer/styles.module.css +18 -0
  40. package/lib-next/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  41. package/lib-next/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  42. package/lib-next/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  43. package/lib-next/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  44. package/lib-next/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  45. package/lib-next/theme/ApiItem/Layout/index.js +69 -0
  46. package/lib-next/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +42 -4
  47. package/lib-next/theme/ApiItem/Metadata/index.js +21 -0
  48. package/lib-next/theme/ApiItem/Paginator/index.js +19 -0
  49. package/lib-next/theme/ApiItem/TOC/Desktop/index.js +22 -0
  50. package/lib-next/theme/ApiItem/TOC/Mobile/index.js +24 -0
  51. package/lib-next/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  52. package/lib-next/theme/ApiItem/index.js +31 -133
  53. package/lib-next/theme/ApiTabs/index.js +17 -6
  54. package/lib-next/theme/ApiTabs/styles.module.css +0 -1
  55. package/lib-next/theme/SchemaTabs/index.js +258 -0
  56. package/lib-next/theme/SchemaTabs/styles.module.css +110 -0
  57. package/package.json +6 -6
  58. package/src/theme/ApiDemoPanel/CodeTabs/index.tsx +6 -5
  59. package/src/theme/ApiDemoPanel/FloatingButton/index.tsx +6 -2
  60. package/src/theme/ApiDemoPanel/FloatingButton/styles.module.css +3 -2
  61. package/src/theme/ApiDemoPanel/LiveEditor/index.tsx +15 -3
  62. package/src/theme/ApiDemoPanel/LiveEditor/styles.module.css +2 -1
  63. package/src/theme/ApiDemoPanel/ParamOptions/styles.module.css +0 -4
  64. package/src/theme/ApiDemoPanel/Server/index.tsx +3 -2
  65. package/src/theme/ApiDemoPanel/Server/styles.module.css +0 -4
  66. package/src/theme/ApiItem/Content/index.tsx +57 -0
  67. package/src/theme/ApiItem/Footer/index.tsx +101 -0
  68. package/src/theme/ApiItem/Footer/styles.module.css +18 -0
  69. package/src/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  70. package/src/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  71. package/src/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  72. package/src/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  73. package/src/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  74. package/src/theme/ApiItem/Layout/index.tsx +78 -0
  75. package/src/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +42 -4
  76. package/src/theme/ApiItem/Metadata/index.tsx +24 -0
  77. package/src/theme/ApiItem/Paginator/index.tsx +21 -0
  78. package/src/theme/ApiItem/TOC/Desktop/index.tsx +25 -0
  79. package/src/theme/ApiItem/TOC/Mobile/index.tsx +28 -0
  80. package/src/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  81. package/src/theme/ApiItem/index.tsx +31 -130
  82. package/src/theme/ApiTabs/index.js +17 -6
  83. package/src/theme/ApiTabs/styles.module.css +0 -1
  84. package/src/theme/SchemaTabs/index.js +258 -0
  85. package/src/theme/SchemaTabs/styles.module.css +110 -0
@@ -11,27 +11,11 @@ var _ExecutionEnvironment = _interopRequireDefault(require("@docusaurus/Executio
11
11
 
12
12
  var _themeCommon = require("@docusaurus/theme-common");
13
13
 
14
- var _DocBreadcrumbs = _interopRequireDefault(require("@theme/DocBreadcrumbs"));
15
-
16
- var _DocItemFooter = _interopRequireDefault(require("@theme/DocItemFooter"));
17
-
18
- var _DocPaginator = _interopRequireDefault(require("@theme/DocPaginator"));
19
-
20
- var _DocVersionBadge = _interopRequireDefault(require("@theme/DocVersionBadge"));
21
-
22
- var _DocVersionBanner = _interopRequireDefault(require("@theme/DocVersionBanner"));
23
-
24
- var _Heading = _interopRequireDefault(require("@theme/Heading"));
25
-
26
- var _MDXContent = _interopRequireDefault(require("@theme/MDXContent"));
27
-
28
- var _TOC = _interopRequireDefault(require("@theme/TOC"));
29
-
30
- var _TOCCollapsible = _interopRequireDefault(require("@theme/TOCCollapsible"));
31
-
32
14
  var _clsx = _interopRequireDefault(require("clsx"));
33
15
 
34
- var _stylesModule = _interopRequireDefault(require("./styles.module.css"));
16
+ var _Layout = _interopRequireDefault(require("./Layout"));
17
+
18
+ var _Metadata = _interopRequireDefault(require("./Metadata"));
35
19
 
36
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
21
 
@@ -41,6 +25,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
41
25
  * This source code is licensed under the MIT license found in the
42
26
  * LICENSE file in the root directory of this source tree.
43
27
  * ========================================================================== */
28
+ const {
29
+ DocProvider
30
+ } = require("@docusaurus/theme-common/internal");
31
+
44
32
  let ApiDemoPanel = _ => <div style={{
45
33
  marginTop: "3.5em"
46
34
  }} />;
@@ -49,113 +37,36 @@ if (_ExecutionEnvironment.default.canUseDOM) {
49
37
  ApiDemoPanel = require("@theme/ApiDemoPanel").default;
50
38
  }
51
39
 
52
- function DocItemMetadata(props) {
53
- var _assets$image;
54
-
55
- const {
56
- content: DocContent
57
- } = props;
58
- const {
59
- metadata,
60
- frontMatter,
61
- assets
62
- } = DocContent;
63
- const {
64
- keywords
65
- } = frontMatter;
66
- const {
67
- description,
68
- title
69
- } = metadata;
70
- const image = (_assets$image = assets.image) !== null && _assets$image !== void 0 ? _assets$image : frontMatter.image;
71
- return <_themeCommon.PageMetadata {...{
72
- title,
73
- description,
74
- keywords,
75
- image
76
- }} />;
77
- }
78
-
79
- function DocItemContent(props) {
80
- const {
81
- content: DocContent
82
- } = props;
83
- const {
84
- metadata,
85
- frontMatter
86
- } = DocContent;
87
- const {
88
- info_path: infoPath,
89
- hide_title: hideTitle,
90
- hide_table_of_contents: hideTableOfContents,
91
- toc_min_heading_level: tocMinHeadingLevel,
92
- toc_max_heading_level: tocMaxHeadingLevel
93
- } = frontMatter;
94
- const {
95
- title
96
- } = metadata;
97
- const {
98
- api
99
- } = frontMatter; // We only add a title if:
100
- // - user doesn't ask to hide it with front matter
101
- // - the markdown content does not already contain a top-level h1 heading
102
-
103
- const shouldAddTitle = !hideTitle && typeof DocContent.contentTitle === "undefined";
104
- const windowSize = (0, _themeCommon.useWindowSize)();
105
- const canRenderTOC = !hideTableOfContents && DocContent.toc && DocContent.toc.length > 0;
106
- const renderTocDesktop = canRenderTOC && (windowSize === "desktop" || windowSize === "ssr");
107
- return <div className="row">
108
- <div className={(0, _clsx.default)("col", !hideTableOfContents && _stylesModule.default.docItemCol)}>
109
- <_DocVersionBanner.default />
110
- <div className={_stylesModule.default.docItemContainer}>
111
- <article>
112
- <_DocBreadcrumbs.default />
113
- <_DocVersionBadge.default />
114
-
115
- {canRenderTOC && <_TOCCollapsible.default toc={DocContent.toc} minHeadingLevel={tocMinHeadingLevel} maxHeadingLevel={tocMaxHeadingLevel} className={(0, _clsx.default)(_themeCommon.ThemeClassNames.docs.docTocMobile, _stylesModule.default.tocMobile)} />}
116
-
117
- <div className={(0, _clsx.default)(_themeCommon.ThemeClassNames.docs.docMarkdown, "theme-api-markdown", "markdown")}>
118
- {
119
- /*
120
- Title can be declared inside md content or declared through
121
- front matter and added manually. To make both cases consistent,
122
- the added title is added under the same div.markdown block
123
- See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
124
- */
125
- }
126
- {shouldAddTitle && <header>
127
- <_Heading.default as="h1">{title}</_Heading.default>
128
- </header>}
129
- <_MDXContent.default>
130
- <div className="row">
131
- <div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
132
- <DocContent />
133
- </div>
134
- {api && <div className="col col--5">
135
- <ApiDemoPanel item={api} infoPath={infoPath} />
136
- </div>}
137
- </div>
138
- </_MDXContent.default>
139
- </div>
140
- <div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
141
- <_DocItemFooter.default {...props} />
142
- </div>
143
- </article>
144
- <div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
145
- <_DocPaginator.default previous={metadata.previous} next={metadata.next} />
146
- </div>
147
- </div>
148
- </div>
149
- {renderTocDesktop && <div className="col col--3">
150
- <_TOC.default toc={DocContent.toc} minHeadingLevel={tocMinHeadingLevel} maxHeadingLevel={tocMaxHeadingLevel} className={_themeCommon.ThemeClassNames.docs.docTocDesktop} />
151
- </div>}
152
- </div>;
153
- }
154
-
155
40
  function DocItem(props) {
156
41
  const docHtmlClassName = `docs-doc-id-${props.content.metadata.unversionedId}`;
157
- return <_themeCommon.HtmlClassNameProvider className={docHtmlClassName}>
158
- <DocItemMetadata {...props} />
159
- <DocItemContent {...props} />
160
- </_themeCommon.HtmlClassNameProvider>;
42
+
43
+ const DocContent = () => {
44
+ const MDXComponent = props.content;
45
+ const {
46
+ frontMatter
47
+ } = MDXComponent;
48
+ const {
49
+ info_path: infoPath
50
+ } = frontMatter;
51
+ const {
52
+ api
53
+ } = frontMatter;
54
+ return <div className="row">
55
+ <div className={(0, _clsx.default)("col", api ? "col--7" : "col--12")}>
56
+ <MDXComponent />
57
+ </div>
58
+ {api && <div className="col col--5">
59
+ <ApiDemoPanel item={api} infoPath={infoPath} />
60
+ </div>}
61
+ </div>;
62
+ };
63
+
64
+ return <DocProvider content={props.content}>
65
+ <_themeCommon.HtmlClassNameProvider className={docHtmlClassName}>
66
+ <_Metadata.default />
67
+ <_Layout.default>
68
+ <DocContent />
69
+ </_Layout.default>
70
+ </_themeCommon.HtmlClassNameProvider>
71
+ </DocProvider>;
161
72
  }
@@ -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 = values.length >= 5;
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;
@@ -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,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
+ }
@@ -5,15 +5,16 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
7
  import React, { useState, cloneElement, isValidElement } from "react";
8
- import {
9
- useScrollPositionBlocker,
10
- duplicates,
11
- useTabGroupChoice,
12
- } from "@docusaurus/theme-common";
8
+ import { duplicates } from "@docusaurus/theme-common";
13
9
  import useIsBrowser from "@docusaurus/useIsBrowser";
14
10
  import clsx from "clsx";
15
11
  import { languageSet } from "../Curl";
16
- import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
12
+ import styles from "./styles.module.css";
13
+
14
+ const {
15
+ useScrollPositionBlocker,
16
+ useTabGroupChoice,
17
+ } = require("@docusaurus/theme-common/internal"); // A very rough duck type, but good enough to guard against mistakes while
17
18
  // allowing customization
18
19
 
19
20
  function isTabItem(comp) {
@@ -9,8 +9,12 @@ import styles from "./styles.module.css";
9
9
 
10
10
  function FloatingButton({ label, onClick, children }) {
11
11
  return (
12
- <div className={styles.floatingButton}>
13
- {label && <button onClick={onClick}>{label}</button>}
12
+ <div tabIndex={0} className={styles.floatingButton}>
13
+ {label && (
14
+ <button tabIndex={0} onClick={onClick}>
15
+ {label}
16
+ </button>
17
+ )}
14
18
  {children}
15
19
  </div>
16
20
  );
@@ -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
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  * ========================================================================== */
7
- import React from "react";
7
+ import React, { useState } from "react";
8
8
  import { usePrismTheme } from "@docusaurus/theme-common";
9
9
  import useIsBrowser from "@docusaurus/useIsBrowser";
10
10
  import { LiveProvider, LiveEditor, withLive } from "react-live";
@@ -13,14 +13,25 @@ import styles from "./styles.module.css";
13
13
 
14
14
  function Live({ onEdit }) {
15
15
  const isBrowser = useIsBrowser();
16
+ const [editorDisabled, setEditorDisabled] = useState(false); // TODO: Temporary solution for disabling tab key
17
+
18
+ const handleKeydown = (event) => {
19
+ if (event.key === "Tab") {
20
+ event.preventDefault();
21
+ setEditorDisabled(true);
22
+ }
23
+ };
24
+
16
25
  return (
17
- <>
26
+ <div onClick={() => setEditorDisabled(false)}>
18
27
  <LiveEditor
19
28
  key={String(isBrowser)}
20
29
  className={styles.playgroundEditor}
21
30
  onChange={onEdit}
31
+ disabled={editorDisabled}
32
+ onKeyDown={handleKeydown}
22
33
  />
23
- </>
34
+ </div>
24
35
  );
25
36
  }
26
37