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.
Files changed (97) hide show
  1. package/lib/markdown/utils.d.ts +2 -1
  2. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
  3. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +25 -19
  4. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +4 -0
  5. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +27 -16
  6. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +4 -0
  7. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +116 -97
  8. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
  9. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +115 -54
  10. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
  11. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +41 -30
  12. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
  13. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +201 -121
  14. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
  15. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +36 -24
  16. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
  17. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +35 -28
  18. package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
  19. package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +72 -14
  20. package/lib/theme/ApiExplorer/Body/slice.d.ts +8 -8
  21. package/lib/theme/ApiExplorer/CodeSnippets/index.js +2 -2
  22. package/lib/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
  23. package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
  24. package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
  25. package/lib/theme/ApiExplorer/CodeTabs/index.js +122 -76
  26. package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
  27. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -4
  28. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
  29. package/lib/theme/ApiExplorer/Request/_Request.scss +4 -6
  30. package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
  31. package/lib/theme/ApiExplorer/Response/index.js +23 -20
  32. package/lib/theme/ApiExplorer/index.js +0 -4
  33. package/lib/theme/ApiExplorer/persistanceMiddleware.js +6 -6
  34. package/lib/theme/ApiItem/Layout/index.js +3 -0
  35. package/lib/theme/ApiItem/index.js +6 -5
  36. package/lib/theme/ApiLogo/index.d.ts +2 -2
  37. package/lib/theme/ApiTabs/_ApiTabs.scss +3 -1
  38. package/lib/theme/ApiTabs/index.d.ts +7 -0
  39. package/lib/theme/ApiTabs/index.js +152 -98
  40. package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
  41. package/lib/theme/DiscriminatorTabs/index.js +146 -94
  42. package/lib/theme/MimeTabs/index.d.ts +6 -0
  43. package/lib/theme/MimeTabs/index.js +163 -114
  44. package/lib/theme/OperationTabs/_OperationTabs.scss +4 -1
  45. package/lib/theme/OperationTabs/index.d.ts +3 -0
  46. package/lib/theme/OperationTabs/index.js +148 -103
  47. package/lib/theme/ParamsItem/index.d.ts +23 -0
  48. package/lib/theme/ParamsItem/index.js +168 -123
  49. package/lib/theme/ResponseSamples/index.d.ts +8 -0
  50. package/lib/theme/ResponseSamples/index.js +18 -13
  51. package/lib/theme/SchemaItem/index.d.ts +12 -0
  52. package/lib/theme/SchemaItem/index.js +123 -88
  53. package/lib/theme/SchemaTabs/_SchemaTabs.scss +0 -4
  54. package/lib/theme/SchemaTabs/index.d.ts +3 -0
  55. package/lib/theme/SchemaTabs/index.js +148 -93
  56. package/lib/theme/styles.scss +4 -0
  57. package/package.json +8 -7
  58. package/src/markdown/utils.ts +4 -2
  59. package/src/theme/ApiExplorer/ApiCodeBlock/Container/{index.js → index.tsx} +6 -3
  60. package/src/theme/ApiExplorer/ApiCodeBlock/Content/{Element.js → Element.tsx} +5 -1
  61. package/src/theme/ApiExplorer/ApiCodeBlock/Content/{String.js → String.tsx} +5 -5
  62. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/{index.js → index.tsx} +8 -3
  63. package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/{index.js → index.tsx} +9 -1
  64. package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +13 -3
  65. package/src/theme/ApiExplorer/ApiCodeBlock/Line/{index.js → index.tsx} +2 -1
  66. package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/{index.js → index.tsx} +11 -1
  67. package/src/theme/ApiExplorer/ApiCodeBlock/{index.js → index.tsx} +10 -5
  68. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +3 -5
  69. package/src/theme/ApiExplorer/CodeSnippets/languages.json +1290 -0
  70. package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +4 -2
  71. package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +56 -26
  72. package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
  73. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +4 -4
  74. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
  75. package/src/theme/ApiExplorer/Request/_Request.scss +4 -6
  76. package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
  77. package/src/theme/ApiExplorer/Response/index.tsx +6 -3
  78. package/src/theme/ApiExplorer/index.tsx +0 -3
  79. package/src/theme/ApiExplorer/persistanceMiddleware.ts +6 -6
  80. package/src/theme/ApiItem/Layout/index.tsx +3 -0
  81. package/src/theme/ApiItem/index.tsx +3 -4
  82. package/src/theme/ApiLogo/index.tsx +1 -1
  83. package/src/theme/ApiTabs/_ApiTabs.scss +3 -1
  84. package/src/theme/ApiTabs/{index.js → index.tsx} +60 -26
  85. package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +57 -24
  86. package/src/theme/MimeTabs/{index.js → index.tsx} +57 -25
  87. package/src/theme/OperationTabs/_OperationTabs.scss +4 -1
  88. package/src/theme/OperationTabs/{index.js → index.tsx} +54 -25
  89. package/src/theme/ParamsItem/{index.js → index.tsx} +31 -14
  90. package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
  91. package/src/theme/SchemaItem/{index.js → index.tsx} +18 -9
  92. package/src/theme/SchemaTabs/_SchemaTabs.scss +0 -4
  93. package/src/theme/SchemaTabs/{index.js → index.tsx} +64 -28
  94. package/src/theme/styles.scss +4 -0
  95. package/src/theme-classic.d.ts +69 -2
  96. package/src/theme-openapi.d.ts +3 -0
  97. 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
- import React, { cloneElement, useRef, useState, useEffect } from "react";
9
-
10
- import {
11
- useScrollPositionBlocker,
12
- useTabs,
13
- } from "@docusaurus/theme-common/internal";
14
- import useIsBrowser from "@docusaurus/useIsBrowser";
15
- import Heading from "@theme/Heading";
16
- import clsx from "clsx";
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
- useScrollPositionBlocker();
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 tabItemListContainerRef = useRef(null);
65
- const [showTabArrows, setShowTabArrows] = useState(false);
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.offsetWidth < entry.target.scrollWidth) {
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
- return (
96
- <div className="openapi-tabs__response-header-section">
97
- <Heading as="h2" id={id} className="openapi-tabs__response-header">
98
- {label}
99
- </Heading>
100
- <div className="openapi-tabs__response-container">
101
- {showTabArrows && (
102
- <button
103
- className="openapi-tabs__arrow left"
104
- onClick={handleLeftClick}
105
- />
106
- )}
107
- <ul
108
- ref={tabItemListContainerRef}
109
- role="tablist"
110
- aria-orientation="horizontal"
111
- className={clsx(
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
- {tabValues.map(({ value, label, attributes }) => (
121
- <li
164
+ ),
165
+ },
166
+ tabValues.map(({ value, label, attributes }) =>
167
+ react_1.default.createElement(
168
+ "li",
169
+ {
122
170
  // TODO extract TabListItem
123
- role="tab"
124
- tabIndex={selectedValue === value ? 0 : -1}
125
- aria-selected={selectedValue === value}
126
- key={value}
127
- ref={(tabControl) => tabRefs.push(tabControl)}
128
- onKeyDown={handleKeydown}
129
- onClick={handleTabChange}
130
- {...attributes}
131
- className={clsx(
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
- ? "success"
139
- : "info",
186
+ ? "success"
187
+ : "info",
140
188
  {
141
189
  active: selectedValue === value,
142
190
  }
143
- )}
144
- >
145
- {label ?? value}
146
- </li>
147
- ))}
148
- </ul>
149
- {showTabArrows && (
150
- <button
151
- className="openapi-tabs__arrow right"
152
- onClick={handleRightClick}
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
- // eslint-disable-next-line no-param-reassign
161
- children = Array.isArray(children) ? children : [children];
206
+ const childTabs = (Array.isArray(children) ? children : [children]).filter(
207
+ Boolean
208
+ );
162
209
  if (lazy) {
163
- const selectedTabItem = children.find(
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, { className: "margin-top--md" });
217
+ return (0, react_1.cloneElement)(selectedTabItem, {
218
+ className: "margin-top--md",
219
+ });
171
220
  }
172
- return (
173
- <div className="margin-top--md">
174
- {children.map((tabItem, i) =>
175
- cloneElement(tabItem, {
176
- key: i,
177
- hidden: tabItem.props.value !== selectedValue,
178
- })
179
- )}
180
- </div>
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
- <div className="openapi-tabs__container">
187
- <TabList {...props} {...tabs} />
188
- <TabContent {...props} {...tabs} />
189
- </div>
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
- export default function ApiTabs(props) {
193
- const isBrowser = useIsBrowser();
194
- return (
195
- <TabsComponent
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={String(isBrowser)}
199
- {...props}
200
- />
250
+ key: String(isBrowser),
251
+ ...props,
252
+ },
253
+ (0, internal_1.sanitizeTabsChildren)(props.children)
201
254
  );
202
255
  }
256
+ exports.default = ApiTabs;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { TabProps } from "@docusaurus/theme-common/internal";
3
+ export default function DiscriminatorTabs(props: TabProps): React.JSX.Element;
@@ -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
- import React, { cloneElement, useRef, useEffect, useState } from "react";
9
-
10
- import {
11
- useScrollPositionBlocker,
12
- useTabs,
13
- } from "@docusaurus/theme-common/internal";
14
- import useIsBrowser from "@docusaurus/useIsBrowser";
15
- import clsx from "clsx";
16
- import flatten from "lodash/flatten";
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
- useScrollPositionBlocker();
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 tabItemListContainerRef = useRef(null);
55
- const [showTabArrows, setShowTabArrows] = useState(false);
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.offsetWidth < entry.target.scrollWidth) {
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
- return (
86
- <div className="openapi-tabs__discriminator-top-section">
87
- <div className="openapi-tabs__discriminator-container">
88
- {showTabArrows && (
89
- <button
90
- className="openapi-tabs__arrow left"
91
- onClick={handleLeftClick}
92
- />
93
- )}
94
- <ul
95
- ref={tabItemListContainerRef}
96
- role="tablist"
97
- aria-orientation="horizontal"
98
- className={clsx(
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
- {tabValues.map(({ value, label, attributes }) => (
108
- <li
147
+ ),
148
+ },
149
+ tabValues.map(({ value, label, attributes }) =>
150
+ react_1.default.createElement(
151
+ "li",
152
+ {
109
153
  // TODO extract TabListItem
110
- role="tab"
111
- tabIndex={selectedValue === value ? 0 : -1}
112
- aria-selected={selectedValue === value}
113
- key={value}
114
- ref={(tabControl) => tabRefs.push(tabControl)}
115
- onKeyDown={handleKeydown}
116
- onClick={handleTabChange}
117
- {...attributes}
118
- className={clsx(
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
- <span className="openapi-tabs__discriminator-tab-label">
128
- {label ?? value}
129
- </span>
130
- </li>
131
- ))}
132
- </ul>
133
- {showTabArrows && (
134
- <button
135
- className="openapi-tabs__arrow right"
136
- onClick={handleRightClick}
137
- />
138
- )}
139
- </div>
140
- </div>
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
- // eslint-disable-next-line no-param-reassign
145
- children = Array.isArray(children) ? children : [children];
146
- const flattenedChildren = flatten(children);
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 = flattenedChildren.find(
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, { className: "margin-top--md" });
200
+ return (0, react_1.cloneElement)(selectedTabItem, {
201
+ className: "margin-top--md",
202
+ });
156
203
  }
157
- return (
158
- <div className="margin-top--md">
159
- {children.map((tabItem, i) =>
160
- cloneElement(tabItem, {
161
- key: i,
162
- hidden: tabItem.props.value !== selectedValue,
163
- })
164
- )}
165
- </div>
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
- <div className="openapi-tabs__container">
172
- <TabList {...props} {...tabs} />
173
- <TabContent {...props} {...tabs} />
174
- </div>
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
- export default function DiscriminatorTabs(props) {
178
- const isBrowser = useIsBrowser();
179
- return (
180
- <TabsComponent
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={String(isBrowser)}
184
- {...props}
185
- />
233
+ key: String(isBrowser),
234
+ ...props,
235
+ },
236
+ (0, internal_1.sanitizeTabsChildren)(props.children)
186
237
  );
187
238
  }
239
+ exports.default = DiscriminatorTabs;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ import { TabProps } from "@docusaurus/theme-common/internal";
3
+ export interface Props {
4
+ schemaType: any;
5
+ }
6
+ export default function MimeTabs(props: Props & TabProps): React.JSX.Element;