docusaurus-theme-openapi-docs 0.0.0-1177 → 0.0.0-1193

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.
@@ -231,27 +231,26 @@ function TabContent({ lazy, children, selectedValue }) {
231
231
  return react_1.default.createElement(
232
232
  "div",
233
233
  { className: "margin-top--md openapi-tabs__code-content" },
234
- childTabs.map((tabItem, i) =>
235
- (0, react_1.cloneElement)(tabItem, {
236
- key: i,
237
- hidden: tabItem.props.value !== selectedValue,
238
- })
239
- )
234
+ childTabs
240
235
  );
241
236
  }
242
237
  function TabsComponent(props) {
243
- const tabs = (0, internal_1.useTabs)(props);
238
+ const tabs = (0, internal_1.useTabsContextValue)(props);
244
239
  const { className } = props;
245
240
  return react_1.default.createElement(
246
- "div",
247
- {
248
- className: (0, clsx_1.default)(
249
- "tabs-container openapi-tabs__code-container",
250
- className
251
- ),
252
- },
253
- react_1.default.createElement(TabList, { ...props, ...tabs }),
254
- react_1.default.createElement(TabContent, { ...props, ...tabs })
241
+ internal_1.TabsProvider,
242
+ { value: tabs },
243
+ react_1.default.createElement(
244
+ "div",
245
+ {
246
+ className: (0, clsx_1.default)(
247
+ "tabs-container openapi-tabs__code-container",
248
+ className
249
+ ),
250
+ },
251
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
252
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
253
+ )
255
254
  );
256
255
  }
257
256
  function CodeTabs(props) {
@@ -241,21 +241,20 @@ function TabContent({ lazy, children, selectedValue }) {
241
241
  return react_1.default.createElement(
242
242
  "div",
243
243
  { className: "margin-top--md" },
244
- childTabs.map((tabItem, i) =>
245
- (0, react_1.cloneElement)(tabItem, {
246
- key: i,
247
- hidden: tabItem.props.value !== selectedValue,
248
- })
249
- )
244
+ childTabs
250
245
  );
251
246
  }
252
247
  function TabsComponent(props) {
253
- const tabs = (0, internal_1.useTabs)(props);
248
+ const tabs = (0, internal_1.useTabsContextValue)(props);
254
249
  return react_1.default.createElement(
255
- "div",
256
- { className: "openapi-tabs__container" },
257
- react_1.default.createElement(TabList, { ...props, ...tabs }),
258
- react_1.default.createElement(TabContent, { ...props, ...tabs })
250
+ internal_1.TabsProvider,
251
+ { value: tabs },
252
+ react_1.default.createElement(
253
+ "div",
254
+ { className: "openapi-tabs__container" },
255
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
256
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
257
+ )
259
258
  );
260
259
  }
261
260
  function ApiTabs(props) {
@@ -219,21 +219,20 @@ function TabContent({ lazy, children, selectedValue }) {
219
219
  return react_1.default.createElement(
220
220
  "div",
221
221
  { className: "margin-top--md" },
222
- childTabs.map((tabItem, i) =>
223
- (0, react_1.cloneElement)(tabItem, {
224
- key: i,
225
- hidden: tabItem.props.value !== selectedValue,
226
- })
227
- )
222
+ childTabs
228
223
  );
229
224
  }
230
225
  function TabsComponent(props) {
231
- const tabs = (0, internal_1.useTabs)(props);
226
+ const tabs = (0, internal_1.useTabsContextValue)(props);
232
227
  return react_1.default.createElement(
233
- "div",
234
- { className: "openapi-tabs__container" },
235
- react_1.default.createElement(TabList, { ...props, ...tabs }),
236
- react_1.default.createElement(TabContent, { ...props, ...tabs })
228
+ internal_1.TabsProvider,
229
+ { value: tabs },
230
+ react_1.default.createElement(
231
+ "div",
232
+ { className: "openapi-tabs__container" },
233
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
234
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
235
+ )
237
236
  );
238
237
  }
239
238
  function DiscriminatorTabs(props) {
@@ -252,21 +252,20 @@ function TabContent({ lazy, children, selectedValue }) {
252
252
  return react_1.default.createElement(
253
253
  "div",
254
254
  { className: "margin-top--md" },
255
- childTabs.map((tabItem, i) =>
256
- (0, react_1.cloneElement)(tabItem, {
257
- key: i,
258
- hidden: tabItem.props.value !== selectedValue,
259
- })
260
- )
255
+ childTabs
261
256
  );
262
257
  }
263
258
  function TabsComponent(props) {
264
- const tabs = (0, internal_1.useTabs)(props);
259
+ const tabs = (0, internal_1.useTabsContextValue)(props);
265
260
  return react_1.default.createElement(
266
- "div",
267
- { className: "tabs-container" },
268
- react_1.default.createElement(TabList, { ...props, ...tabs }),
269
- react_1.default.createElement(TabContent, { ...props, ...tabs })
261
+ internal_1.TabsProvider,
262
+ { value: tabs },
263
+ react_1.default.createElement(
264
+ "div",
265
+ { className: "tabs-container" },
266
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
267
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
268
+ )
270
269
  );
271
270
  }
272
271
  function MimeTabs(props) {
@@ -214,21 +214,20 @@ function TabContent({ lazy, children, selectedValue }) {
214
214
  return react_1.default.createElement(
215
215
  "div",
216
216
  { className: "margin-top--md" },
217
- childTabs.map((tabItem, i) =>
218
- (0, react_1.cloneElement)(tabItem, {
219
- key: i,
220
- hidden: tabItem.props.value !== selectedValue,
221
- })
222
- )
217
+ childTabs
223
218
  );
224
219
  }
225
220
  function TabsComponent(props) {
226
- const tabs = (0, internal_1.useTabs)(props);
221
+ const tabs = (0, internal_1.useTabsContextValue)(props);
227
222
  return react_1.default.createElement(
228
- "div",
229
- { className: "tabs-container" },
230
- react_1.default.createElement(TabList, { ...props, ...tabs }),
231
- react_1.default.createElement(TabContent, { ...props, ...tabs })
223
+ internal_1.TabsProvider,
224
+ { value: tabs },
225
+ react_1.default.createElement(
226
+ "div",
227
+ { className: "tabs-container" },
228
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
229
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
230
+ )
232
231
  );
233
232
  }
234
233
  function OperationTabs(props) {
@@ -233,21 +233,20 @@ function TabContent({ lazy, children, selectedValue }) {
233
233
  return react_1.default.createElement(
234
234
  "div",
235
235
  { className: "margin-top--md" },
236
- childTabs.map((tabItem, i) =>
237
- (0, react_1.cloneElement)(tabItem, {
238
- key: i,
239
- hidden: tabItem.props.value !== selectedValue,
240
- })
241
- )
236
+ childTabs
242
237
  );
243
238
  }
244
239
  function TabsComponent(props) {
245
- const tabs = (0, internal_1.useTabs)(props);
240
+ const tabs = (0, internal_1.useTabsContextValue)(props);
246
241
  return react_1.default.createElement(
247
- "div",
248
- { className: "openapi-tabs__schema-container" },
249
- react_1.default.createElement(TabList, { ...props, ...tabs }),
250
- react_1.default.createElement(TabContent, { ...props, ...tabs })
242
+ internal_1.TabsProvider,
243
+ { value: tabs },
244
+ react_1.default.createElement(
245
+ "div",
246
+ { className: "openapi-tabs__schema-container" },
247
+ react_1.default.createElement(TabList, { ...props, ...tabs }),
248
+ react_1.default.createElement(TabContent, { ...props, ...tabs })
249
+ )
251
250
  );
252
251
  }
253
252
  function SchemaTabs(props) {
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": "0.0.0-1177",
4
+ "version": "0.0.0-1193",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -28,9 +28,9 @@
28
28
  "watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\""
29
29
  },
30
30
  "devDependencies": {
31
- "@docusaurus/theme-classic": "^3.5.0",
32
- "@docusaurus/theme-common": "^3.5.0",
33
- "@docusaurus/types": "^3.5.0",
31
+ "@docusaurus/theme-classic": "^3.10.0",
32
+ "@docusaurus/theme-common": "^3.10.0",
33
+ "@docusaurus/types": "^3.10.0",
34
34
  "@types/crypto-js": "^4.2.2",
35
35
  "@types/file-saver": "^2.0.7",
36
36
  "@types/lodash": "^4.17.20",
@@ -38,7 +38,7 @@
38
38
  "@types/postman-collection": "^3.5.11",
39
39
  "@types/react-modal": "^3.16.3",
40
40
  "concurrently": "^9.2.0",
41
- "docusaurus-plugin-openapi-docs": "0.0.0-1177",
41
+ "docusaurus-plugin-openapi-docs": "0.0.0-1193",
42
42
  "docusaurus-plugin-sass": "^0.2.6",
43
43
  "eslint-plugin-prettier": "^5.5.1"
44
44
  },
@@ -73,7 +73,7 @@
73
73
  "xml-formatter": "^3.6.6"
74
74
  },
75
75
  "peerDependencies": {
76
- "@docusaurus/theme-common": "^3.5.0",
76
+ "@docusaurus/theme-common": "^3.10.0",
77
77
  "docusaurus-plugin-openapi-docs": "^4.0.0",
78
78
  "docusaurus-plugin-sass": "^0.2.3",
79
79
  "react": "^16.8.4 || ^17.0.0 || ^18.0.0 || ^19.0.0",
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14"
84
84
  },
85
- "gitHead": "83b6ecb227cd8e9681667a02fecaee40bf12733f"
85
+ "gitHead": "07dacb357fc1fb93959465c3f69501c311362116"
86
86
  }
@@ -9,11 +9,12 @@ import React, { cloneElement, ReactElement, useEffect, useRef } from "react";
9
9
 
10
10
  import {
11
11
  sanitizeTabsChildren,
12
+ type TabItemProps,
12
13
  type TabProps,
14
+ TabsProvider,
13
15
  useScrollPositionBlocker,
14
- useTabs,
16
+ useTabsContextValue,
15
17
  } from "@docusaurus/theme-common/internal";
16
- import { TabItemProps } from "@docusaurus/theme-common/lib/utils/tabsUtils";
17
18
  import useIsBrowser from "@docusaurus/useIsBrowser";
18
19
  import clsx from "clsx";
19
20
 
@@ -43,7 +44,7 @@ function TabList({
43
44
  selectedValue,
44
45
  selectValue,
45
46
  tabValues,
46
- }: CodeTabsProps & ReturnType<typeof useTabs>) {
47
+ }: CodeTabsProps & ReturnType<typeof useTabsContextValue>) {
47
48
  const tabRefs = useRef<(HTMLLIElement | null)[]>([]);
48
49
  const tabsScrollContainerRef = useRef<any>(null);
49
50
  const { blockElementScrollPositionUntilNextRender } =
@@ -192,7 +193,8 @@ function TabContent({
192
193
  lazy,
193
194
  children,
194
195
  selectedValue,
195
- }: CodeTabsProps & ReturnType<typeof useTabs>): React.JSX.Element | null {
196
+ }: CodeTabsProps &
197
+ ReturnType<typeof useTabsContextValue>): React.JSX.Element | null {
196
198
  const childTabs = (Array.isArray(children) ? children : [children]).filter(
197
199
  Boolean
198
200
  ) as ReactElement<TabItemProps>[];
@@ -207,28 +209,26 @@ function TabContent({
207
209
  return cloneElement(selectedTabItem, { className: "margin-top--md" });
208
210
  }
209
211
  return (
210
- <div className="margin-top--md openapi-tabs__code-content">
211
- {childTabs.map((tabItem, i) =>
212
- cloneElement(tabItem, {
213
- key: i,
214
- hidden: tabItem.props.value !== selectedValue,
215
- })
216
- )}
217
- </div>
212
+ <div className="margin-top--md openapi-tabs__code-content">{childTabs}</div>
218
213
  );
219
214
  }
220
215
 
221
216
  function TabsComponent(props: CodeTabsProps & Props): React.JSX.Element {
222
- const tabs = useTabs(props);
217
+ const tabs = useTabsContextValue(props);
223
218
  const { className } = props;
224
219
 
225
220
  return (
226
- <div
227
- className={clsx("tabs-container openapi-tabs__code-container", className)}
228
- >
229
- <TabList {...props} {...tabs} />
230
- <TabContent {...props} {...tabs} />
231
- </div>
221
+ <TabsProvider value={tabs}>
222
+ <div
223
+ className={clsx(
224
+ "tabs-container openapi-tabs__code-container",
225
+ className
226
+ )}
227
+ >
228
+ <TabList {...props} {...tabs} />
229
+ <TabContent {...props} {...tabs} />
230
+ </div>
231
+ </TabsProvider>
232
232
  );
233
233
  }
234
234
 
@@ -15,11 +15,12 @@ import React, {
15
15
 
16
16
  import {
17
17
  sanitizeTabsChildren,
18
+ type TabItemProps,
18
19
  TabProps,
20
+ TabsProvider,
19
21
  useScrollPositionBlocker,
20
- useTabs,
22
+ useTabsContextValue,
21
23
  } from "@docusaurus/theme-common/internal";
22
- import { TabItemProps } from "@docusaurus/theme-common/lib/utils/tabsUtils";
23
24
  import { translate } from "@docusaurus/Translate";
24
25
  import useIsBrowser from "@docusaurus/useIsBrowser";
25
26
  import Heading from "@theme/Heading";
@@ -42,7 +43,7 @@ function TabList({
42
43
  message: "Responses",
43
44
  }),
44
45
  id = "responses",
45
- }: TabListProps & ReturnType<typeof useTabs>) {
46
+ }: TabListProps & ReturnType<typeof useTabsContextValue>) {
46
47
  const tabRefs: (HTMLLIElement | null)[] = [];
47
48
  const { blockElementScrollPositionUntilNextRender } =
48
49
  useScrollPositionBlocker();
@@ -194,7 +195,8 @@ function TabContent({
194
195
  lazy,
195
196
  children,
196
197
  selectedValue,
197
- }: TabProps & ReturnType<typeof useTabs>): React.JSX.Element | null {
198
+ }: TabProps &
199
+ ReturnType<typeof useTabsContextValue>): React.JSX.Element | null {
198
200
  const childTabs = (Array.isArray(children) ? children : [children]).filter(
199
201
  Boolean
200
202
  ) as ReactElement<TabItemProps>[];
@@ -208,24 +210,17 @@ function TabContent({
208
210
  }
209
211
  return cloneElement(selectedTabItem, { className: "margin-top--md" });
210
212
  }
211
- return (
212
- <div className="margin-top--md">
213
- {childTabs.map((tabItem, i) =>
214
- cloneElement(tabItem, {
215
- key: i,
216
- hidden: tabItem.props.value !== selectedValue,
217
- })
218
- )}
219
- </div>
220
- );
213
+ return <div className="margin-top--md">{childTabs}</div>;
221
214
  }
222
215
  function TabsComponent(props: TabListProps): React.JSX.Element {
223
- const tabs = useTabs(props);
216
+ const tabs = useTabsContextValue(props);
224
217
  return (
225
- <div className="openapi-tabs__container">
226
- <TabList {...props} {...tabs} />
227
- <TabContent {...props} {...tabs} />
228
- </div>
218
+ <TabsProvider value={tabs}>
219
+ <div className="openapi-tabs__container">
220
+ <TabList {...props} {...tabs} />
221
+ <TabContent {...props} {...tabs} />
222
+ </div>
223
+ </TabsProvider>
229
224
  );
230
225
  }
231
226
  export default function ApiTabs(props: TabListProps): React.JSX.Element {
@@ -15,11 +15,12 @@ import React, {
15
15
 
16
16
  import {
17
17
  sanitizeTabsChildren,
18
+ type TabItemProps,
18
19
  TabProps,
20
+ TabsProvider,
19
21
  useScrollPositionBlocker,
20
- useTabs,
22
+ useTabsContextValue,
21
23
  } from "@docusaurus/theme-common/internal";
22
- import { TabItemProps } from "@docusaurus/theme-common/lib/utils/tabsUtils";
23
24
  import useIsBrowser from "@docusaurus/useIsBrowser";
24
25
  import clsx from "clsx";
25
26
  import flatten from "lodash/flatten";
@@ -30,7 +31,7 @@ function TabList({
30
31
  selectedValue,
31
32
  selectValue,
32
33
  tabValues,
33
- }: TabProps & ReturnType<typeof useTabs>) {
34
+ }: TabProps & ReturnType<typeof useTabsContextValue>) {
34
35
  const tabRefs: (HTMLLIElement | null)[] = [];
35
36
  const { blockElementScrollPositionUntilNextRender } =
36
37
  useScrollPositionBlocker();
@@ -172,7 +173,8 @@ function TabContent({
172
173
  lazy,
173
174
  children,
174
175
  selectedValue,
175
- }: TabProps & ReturnType<typeof useTabs>): React.JSX.Element | null {
176
+ }: TabProps &
177
+ ReturnType<typeof useTabsContextValue>): React.JSX.Element | null {
176
178
  const childTabs = (Array.isArray(children) ? children : [children]).filter(
177
179
  Boolean
178
180
  ) as ReactElement<TabItemProps>[];
@@ -187,24 +189,17 @@ function TabContent({
187
189
  }
188
190
  return cloneElement(selectedTabItem, { className: "margin-top--md" });
189
191
  }
190
- return (
191
- <div className="margin-top--md">
192
- {childTabs.map((tabItem, i) =>
193
- cloneElement(tabItem, {
194
- key: i,
195
- hidden: tabItem.props.value !== selectedValue,
196
- })
197
- )}
198
- </div>
199
- );
192
+ return <div className="margin-top--md">{childTabs}</div>;
200
193
  }
201
194
  function TabsComponent(props: TabProps): React.JSX.Element {
202
- const tabs = useTabs(props);
195
+ const tabs = useTabsContextValue(props);
203
196
  return (
204
- <div className="openapi-tabs__container">
205
- <TabList {...props} {...tabs} />
206
- <TabContent {...props} {...tabs} />
207
- </div>
197
+ <TabsProvider value={tabs}>
198
+ <div className="openapi-tabs__container">
199
+ <TabList {...props} {...tabs} />
200
+ <TabContent {...props} {...tabs} />
201
+ </div>
202
+ </TabsProvider>
208
203
  );
209
204
  }
210
205
  export default function DiscriminatorTabs(props: TabProps): React.JSX.Element {
@@ -15,11 +15,12 @@ import React, {
15
15
 
16
16
  import {
17
17
  sanitizeTabsChildren,
18
+ type TabItemProps,
18
19
  TabProps,
20
+ TabsProvider,
19
21
  useScrollPositionBlocker,
20
- useTabs,
22
+ useTabsContextValue,
21
23
  } from "@docusaurus/theme-common/internal";
22
- import { TabItemProps } from "@docusaurus/theme-common/lib/utils/tabsUtils";
23
24
  import useIsBrowser from "@docusaurus/useIsBrowser";
24
25
  import { setAccept } from "@theme/ApiExplorer/Accept/slice";
25
26
  import { setContentType } from "@theme/ApiExplorer/ContentType/slice";
@@ -38,7 +39,9 @@ function TabList({
38
39
  selectValue,
39
40
  tabValues,
40
41
  schemaType,
41
- }: Props & TabProps & ReturnType<typeof useTabs>): React.JSX.Element {
42
+ }: Props &
43
+ TabProps &
44
+ ReturnType<typeof useTabsContextValue>): React.JSX.Element {
42
45
  const tabRefs: (HTMLLIElement | null)[] = [];
43
46
  const { blockElementScrollPositionUntilNextRender } =
44
47
  useScrollPositionBlocker();
@@ -208,7 +211,7 @@ function TabContent({
208
211
  lazy,
209
212
  children,
210
213
  selectedValue,
211
- }: Props & TabProps & ReturnType<typeof useTabs>) {
214
+ }: Props & TabProps & ReturnType<typeof useTabsContextValue>) {
212
215
  const childTabs = (Array.isArray(children) ? children : [children]).filter(
213
216
  Boolean
214
217
  ) as ReactElement<TabItemProps>[];
@@ -222,24 +225,17 @@ function TabContent({
222
225
  }
223
226
  return cloneElement(selectedTabItem, { className: "margin-top--md" });
224
227
  }
225
- return (
226
- <div className="margin-top--md">
227
- {childTabs.map((tabItem, i) =>
228
- cloneElement(tabItem, {
229
- key: i,
230
- hidden: tabItem.props.value !== selectedValue,
231
- })
232
- )}
233
- </div>
234
- );
228
+ return <div className="margin-top--md">{childTabs}</div>;
235
229
  }
236
230
  function TabsComponent(props: Props & TabProps): React.JSX.Element {
237
- const tabs = useTabs(props);
231
+ const tabs = useTabsContextValue(props);
238
232
  return (
239
- <div className="tabs-container">
240
- <TabList {...props} {...tabs} />
241
- <TabContent {...props} {...tabs} />
242
- </div>
233
+ <TabsProvider value={tabs}>
234
+ <div className="tabs-container">
235
+ <TabList {...props} {...tabs} />
236
+ <TabContent {...props} {...tabs} />
237
+ </div>
238
+ </TabsProvider>
243
239
  );
244
240
  }
245
241
  export default function MimeTabs(props: Props & TabProps) {
@@ -15,11 +15,12 @@ import React, {
15
15
 
16
16
  import {
17
17
  sanitizeTabsChildren,
18
+ type TabItemProps,
18
19
  TabProps,
20
+ TabsProvider,
19
21
  useScrollPositionBlocker,
20
- useTabs,
22
+ useTabsContextValue,
21
23
  } from "@docusaurus/theme-common/internal";
22
- import { TabItemProps } from "@docusaurus/theme-common/lib/utils/tabsUtils";
23
24
  import useIsBrowser from "@docusaurus/useIsBrowser";
24
25
  import clsx from "clsx";
25
26
 
@@ -29,7 +30,7 @@ function TabList({
29
30
  selectedValue,
30
31
  selectValue,
31
32
  tabValues,
32
- }: TabProps & ReturnType<typeof useTabs>) {
33
+ }: TabProps & ReturnType<typeof useTabsContextValue>) {
33
34
  const tabRefs: (HTMLLIElement | null)[] = [];
34
35
  const { blockElementScrollPositionUntilNextRender } =
35
36
  useScrollPositionBlocker();
@@ -171,7 +172,8 @@ function TabContent({
171
172
  lazy,
172
173
  children,
173
174
  selectedValue,
174
- }: TabProps & ReturnType<typeof useTabs>): React.JSX.Element | null {
175
+ }: TabProps &
176
+ ReturnType<typeof useTabsContextValue>): React.JSX.Element | null {
175
177
  const childTabs = (Array.isArray(children) ? children : [children]).filter(
176
178
  Boolean
177
179
  ) as ReactElement<TabItemProps>[];
@@ -185,24 +187,17 @@ function TabContent({
185
187
  }
186
188
  return cloneElement(selectedTabItem, { className: "margin-top--md" });
187
189
  }
188
- return (
189
- <div className="margin-top--md">
190
- {childTabs.map((tabItem, i) =>
191
- cloneElement(tabItem, {
192
- key: i,
193
- hidden: tabItem.props.value !== selectedValue,
194
- })
195
- )}
196
- </div>
197
- );
190
+ return <div className="margin-top--md">{childTabs}</div>;
198
191
  }
199
192
  function TabsComponent(props: TabProps): React.JSX.Element {
200
- const tabs = useTabs(props);
193
+ const tabs = useTabsContextValue(props);
201
194
  return (
202
- <div className="tabs-container">
203
- <TabList {...props} {...tabs} />
204
- <TabContent {...props} {...tabs} />
205
- </div>
195
+ <TabsProvider value={tabs}>
196
+ <div className="tabs-container">
197
+ <TabList {...props} {...tabs} />
198
+ <TabContent {...props} {...tabs} />
199
+ </div>
200
+ </TabsProvider>
206
201
  );
207
202
  }
208
203
  export default function OperationTabs(props: TabProps): React.JSX.Element {
@@ -16,11 +16,12 @@ import React, {
16
16
 
17
17
  import {
18
18
  sanitizeTabsChildren,
19
+ type TabItemProps,
19
20
  TabProps,
21
+ TabsProvider,
20
22
  useScrollPositionBlocker,
21
- useTabs,
23
+ useTabsContextValue,
22
24
  } from "@docusaurus/theme-common/internal";
23
- import { TabItemProps } from "@docusaurus/theme-common/lib/utils/tabsUtils";
24
25
  import useIsBrowser from "@docusaurus/useIsBrowser";
25
26
  import clsx from "clsx";
26
27
  import flatten from "lodash/flatten";
@@ -40,7 +41,7 @@ function TabList({
40
41
  selectValue,
41
42
  tabValues,
42
43
  onChange,
43
- }: SchemaTabsProps & ReturnType<typeof useTabs>) {
44
+ }: SchemaTabsProps & ReturnType<typeof useTabsContextValue>) {
44
45
  const tabRefs: (HTMLLIElement | null)[] = [];
45
46
  const { blockElementScrollPositionUntilNextRender } =
46
47
  useScrollPositionBlocker();
@@ -188,7 +189,7 @@ function TabContent({
188
189
  lazy,
189
190
  children,
190
191
  selectedValue,
191
- }: SchemaTabsProps & ReturnType<typeof useTabs>) {
192
+ }: SchemaTabsProps & ReturnType<typeof useTabsContextValue>) {
192
193
  const childTabs = (Array.isArray(children) ? children : [children]).filter(
193
194
  Boolean
194
195
  ) as ReactElement<TabItemProps>[];
@@ -203,24 +204,17 @@ function TabContent({
203
204
  }
204
205
  return cloneElement(selectedTabItem, { className: "margin-top--md" });
205
206
  }
206
- return (
207
- <div className="margin-top--md">
208
- {childTabs.map((tabItem, i) =>
209
- cloneElement(tabItem, {
210
- key: i,
211
- hidden: tabItem.props.value !== selectedValue,
212
- })
213
- )}
214
- </div>
215
- );
207
+ return <div className="margin-top--md">{childTabs}</div>;
216
208
  }
217
209
  function TabsComponent(props: SchemaTabsProps): React.JSX.Element {
218
- const tabs = useTabs(props);
210
+ const tabs = useTabsContextValue(props);
219
211
  return (
220
- <div className="openapi-tabs__schema-container">
221
- <TabList {...props} {...tabs} />
222
- <TabContent {...props} {...tabs} />
223
- </div>
212
+ <TabsProvider value={tabs}>
213
+ <div className="openapi-tabs__schema-container">
214
+ <TabList {...props} {...tabs} />
215
+ <TabContent {...props} {...tabs} />
216
+ </div>
217
+ </TabsProvider>
224
218
  );
225
219
  }
226
220
  export default function SchemaTabs(
@@ -21,6 +21,15 @@ declare module "@docusaurus/theme-common/internal" {
21
21
  import { Props as ILineProps } from "@theme/CodeBlock/Line";
22
22
  import { PrismTheme } from "prism-react-renderer";
23
23
 
24
+ export interface TabItemProps {
25
+ readonly children: ReactNode;
26
+ readonly value: string;
27
+ readonly default?: boolean;
28
+ readonly label?: string;
29
+ readonly className?: string;
30
+ readonly attributes?: { [key: string]: unknown };
31
+ }
32
+
24
33
  export interface TabProps extends ITabsProps {
25
34
  length?: number;
26
35
  }
@@ -53,12 +62,27 @@ declare module "@docusaurus/theme-common/internal" {
53
62
  content: PropDocContent;
54
63
  });
55
64
 
56
- export function useTabs(props: TabProps): {
65
+ export function useTabsContextValue(props: TabProps): {
57
66
  selectedValue: string;
58
67
  selectValue: (value: string) => void;
59
68
  tabValues: readonly TabValue[];
69
+ lazy: boolean;
70
+ block: boolean;
60
71
  };
61
72
 
73
+ export function useTabs(): {
74
+ selectedValue: string;
75
+ selectValue: (value: string) => void;
76
+ tabValues: readonly TabValue[];
77
+ lazy: boolean;
78
+ block: boolean;
79
+ };
80
+
81
+ export function TabsProvider(props: {
82
+ children: ReactNode;
83
+ value: ReturnType<typeof useTabsContextValue>;
84
+ }): ReactNode;
85
+
62
86
  export function parseLines(
63
87
  content: string,
64
88
  options: {