docusaurus-theme-openapi-docs 0.0.0-1295 → 0.0.0-1310
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +4 -2
- package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +9 -6
- package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/CodeTabs/index.js +6 -5
- package/lib/theme/ApiTabs/index.d.ts +1 -1
- package/lib/theme/ApiTabs/index.js +6 -5
- package/lib/theme/DiscriminatorTabs/index.d.ts +1 -1
- package/lib/theme/DiscriminatorTabs/index.js +6 -5
- package/lib/theme/MimeTabs/index.d.ts +1 -1
- package/lib/theme/MimeTabs/index.js +6 -5
- package/lib/theme/OperationTabs/index.d.ts +1 -1
- package/lib/theme/OperationTabs/index.js +6 -5
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +6 -5
- package/lib/theme/TabItem/index.d.ts +5 -0
- package/lib/theme/TabItem/index.js +51 -0
- package/lib/theme/TabItem/styles.module.css +3 -0
- package/lib/theme/Tabs/index.d.ts +5 -0
- package/lib/theme/Tabs/index.js +148 -0
- package/lib/theme/Tabs/styles.module.css +7 -0
- package/lib/theme/utils/codeBlockUtils.d.ts +28 -0
- package/lib/theme/utils/codeBlockUtils.js +223 -0
- package/lib/theme/utils/reactUtils.d.ts +1 -0
- package/lib/theme/utils/reactUtils.js +23 -0
- package/lib/theme/utils/scrollUtils.d.ts +7 -0
- package/lib/theme/utils/scrollUtils.js +175 -0
- package/lib/theme/utils/tabsUtils.d.ts +47 -0
- package/lib/theme/utils/tabsUtils.js +299 -0
- package/lib/theme/utils/useCodeWordWrap.d.ts +8 -0
- package/lib/theme/utils/useCodeWordWrap.js +84 -0
- package/lib/theme/utils/useMutationObserver.d.ts +3 -0
- package/lib/theme/utils/useMutationObserver.js +34 -0
- package/package.json +4 -4
- package/src/theme/ApiExplorer/ApiCodeBlock/Container/index.tsx +2 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/Content/String.tsx +8 -7
- package/src/theme/ApiExplorer/ApiCodeBlock/Line/index.tsx +1 -1
- package/src/theme/ApiExplorer/ApiCodeBlock/index.tsx +1 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +5 -5
- package/src/theme/ApiTabs/index.tsx +7 -6
- package/src/theme/DiscriminatorTabs/index.tsx +6 -5
- package/src/theme/MimeTabs/index.tsx +9 -8
- package/src/theme/OperationTabs/index.tsx +5 -4
- package/src/theme/SchemaTabs/index.tsx +6 -5
- package/src/theme/TabItem/index.tsx +61 -0
- package/src/theme/TabItem/styles.module.css +3 -0
- package/src/theme/Tabs/index.tsx +164 -0
- package/src/theme/Tabs/styles.module.css +7 -0
- package/src/theme/utils/codeBlockUtils.ts +296 -0
- package/src/theme/utils/reactUtils.ts +22 -0
- package/src/theme/utils/scrollUtils.tsx +153 -0
- package/src/theme/utils/tabsUtils.tsx +329 -0
- package/src/theme/utils/useCodeWordWrap.ts +110 -0
- package/src/theme/utils/useMutationObserver.ts +43 -0
- package/src/theme-classic.d.ts +0 -96
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -14,11 +14,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.default = CodeBlockContainer;
|
|
15
15
|
const react_1 = __importDefault(require("react"));
|
|
16
16
|
const theme_common_1 = require("@docusaurus/theme-common");
|
|
17
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
18
17
|
const clsx_1 = __importDefault(require("clsx"));
|
|
18
|
+
const codeBlockUtils_1 = require("@theme/utils/codeBlockUtils");
|
|
19
19
|
function CodeBlockContainer({ as: As, ...props }) {
|
|
20
20
|
const prismTheme = (0, theme_common_1.usePrismTheme)();
|
|
21
|
-
const prismCssVariables = (0,
|
|
21
|
+
const prismCssVariables = (0, codeBlockUtils_1.getPrismCssVariables)(
|
|
22
|
+
prismTheme
|
|
23
|
+
);
|
|
22
24
|
return react_1.default.createElement(
|
|
23
25
|
As,
|
|
24
26
|
// Polymorphic components are hard to type, without `oneOf` generics
|
|
@@ -14,7 +14,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.default = CodeBlockString;
|
|
15
15
|
const react_1 = __importDefault(require("react"));
|
|
16
16
|
const theme_common_1 = require("@docusaurus/theme-common");
|
|
17
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
18
17
|
const Container_1 = __importDefault(
|
|
19
18
|
require("@theme/ApiExplorer/ApiCodeBlock/Container")
|
|
20
19
|
);
|
|
@@ -30,6 +29,8 @@ const WordWrapButton_1 = __importDefault(
|
|
|
30
29
|
);
|
|
31
30
|
const clsx_1 = __importDefault(require("clsx"));
|
|
32
31
|
const prism_react_renderer_1 = require("prism-react-renderer");
|
|
32
|
+
const codeBlockUtils_1 = require("@theme/utils/codeBlockUtils");
|
|
33
|
+
const useCodeWordWrap_1 = require("@theme/utils/useCodeWordWrap");
|
|
33
34
|
function CodeBlockString({
|
|
34
35
|
children,
|
|
35
36
|
className: blockClassName = "",
|
|
@@ -43,21 +44,23 @@ function CodeBlockString({
|
|
|
43
44
|
} = (0, theme_common_1.useThemeConfig)();
|
|
44
45
|
const language =
|
|
45
46
|
languageProp ??
|
|
46
|
-
(0,
|
|
47
|
+
(0, codeBlockUtils_1.parseLanguage)(blockClassName) ??
|
|
47
48
|
defaultLanguage;
|
|
48
49
|
const prismTheme = (0, theme_common_1.usePrismTheme)();
|
|
49
|
-
const wordWrap = (0,
|
|
50
|
+
const wordWrap = (0, useCodeWordWrap_1.useCodeWordWrap)();
|
|
50
51
|
// We still parse the metastring in case we want to support more syntax in the
|
|
51
52
|
// future. Note that MDX doesn't strip quotes when parsing metastring:
|
|
52
53
|
// "title=\"xyz\"" => title: "\"xyz\""
|
|
53
|
-
const title =
|
|
54
|
-
|
|
54
|
+
const title =
|
|
55
|
+
(0, codeBlockUtils_1.parseCodeBlockTitle)(metastring) || titleProp;
|
|
56
|
+
const { lineClassNames, code } = (0, codeBlockUtils_1.parseLines)(children, {
|
|
55
57
|
metastring,
|
|
56
58
|
language,
|
|
57
59
|
magicComments,
|
|
58
60
|
});
|
|
59
61
|
const showLineNumbers =
|
|
60
|
-
showLineNumbersProp ??
|
|
62
|
+
showLineNumbersProp ??
|
|
63
|
+
(0, codeBlockUtils_1.containsLineNumbers)(metastring);
|
|
61
64
|
return react_1.default.createElement(
|
|
62
65
|
Container_1.default,
|
|
63
66
|
{
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { LineProps } from "@
|
|
2
|
+
import type { Props as LineProps } from "@theme/CodeBlock/Line";
|
|
3
3
|
export default function CodeBlockLine({ line, classNames, showLineNumbers, getLineProps, getTokenProps, }: LineProps): React.JSX.Element;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { CodeBlockProps } from "@
|
|
2
|
+
import type { Props as CodeBlockProps } from "@theme/CodeBlock";
|
|
3
3
|
export default function ApiCodeBlock({ children: rawChildren, ...props }: CodeBlockProps): React.JSX.Element;
|
|
@@ -69,9 +69,10 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = CodeTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
73
|
const clsx_1 = __importDefault(require("clsx"));
|
|
74
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
75
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
75
76
|
function TabList({
|
|
76
77
|
action,
|
|
77
78
|
currentLanguage,
|
|
@@ -87,7 +88,7 @@ function TabList({
|
|
|
87
88
|
const tabRefs = (0, react_1.useRef)([]);
|
|
88
89
|
const tabsScrollContainerRef = (0, react_1.useRef)(null);
|
|
89
90
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
90
|
-
|
|
91
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
91
92
|
(0, react_1.useEffect)(() => {
|
|
92
93
|
const activeTab = tabRefs.current.find(
|
|
93
94
|
(tab) => tab?.getAttribute("aria-selected") === "true"
|
|
@@ -235,10 +236,10 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
235
236
|
);
|
|
236
237
|
}
|
|
237
238
|
function TabsComponent(props) {
|
|
238
|
-
const tabs = (0,
|
|
239
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
239
240
|
const { className } = props;
|
|
240
241
|
return react_1.default.createElement(
|
|
241
|
-
|
|
242
|
+
tabsUtils_1.TabsProvider,
|
|
242
243
|
{ value: tabs },
|
|
243
244
|
react_1.default.createElement(
|
|
244
245
|
"div",
|
|
@@ -265,6 +266,6 @@ function CodeTabs(props) {
|
|
|
265
266
|
key: String(isBrowser),
|
|
266
267
|
...props,
|
|
267
268
|
},
|
|
268
|
-
(0,
|
|
269
|
+
(0, tabsUtils_1.sanitizeTabsChildren)(props.children)
|
|
269
270
|
);
|
|
270
271
|
}
|
|
@@ -69,11 +69,12 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = ApiTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const Translate_1 = require("@docusaurus/Translate");
|
|
74
73
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
75
74
|
const Heading_1 = __importDefault(require("@theme/Heading"));
|
|
76
75
|
const clsx_1 = __importDefault(require("clsx"));
|
|
76
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
77
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
77
78
|
function TabList({
|
|
78
79
|
className,
|
|
79
80
|
block,
|
|
@@ -88,7 +89,7 @@ function TabList({
|
|
|
88
89
|
}) {
|
|
89
90
|
const tabRefs = [];
|
|
90
91
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
91
|
-
|
|
92
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
92
93
|
const handleTabChange = (event) => {
|
|
93
94
|
const newTab = event.currentTarget;
|
|
94
95
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -244,9 +245,9 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
244
245
|
);
|
|
245
246
|
}
|
|
246
247
|
function TabsComponent(props) {
|
|
247
|
-
const tabs = (0,
|
|
248
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
248
249
|
return react_1.default.createElement(
|
|
249
|
-
|
|
250
|
+
tabsUtils_1.TabsProvider,
|
|
250
251
|
{ value: tabs },
|
|
251
252
|
react_1.default.createElement(
|
|
252
253
|
"div",
|
|
@@ -268,6 +269,6 @@ function ApiTabs(props) {
|
|
|
268
269
|
key: String(isBrowser),
|
|
269
270
|
...props,
|
|
270
271
|
},
|
|
271
|
-
(0,
|
|
272
|
+
(0, tabsUtils_1.sanitizeTabsChildren)(props.children)
|
|
272
273
|
);
|
|
273
274
|
}
|
|
@@ -69,14 +69,15 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = DiscriminatorTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
73
|
const clsx_1 = __importDefault(require("clsx"));
|
|
75
74
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
75
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
76
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
76
77
|
function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
77
78
|
const tabRefs = [];
|
|
78
79
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
79
|
-
|
|
80
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
80
81
|
const handleTabChange = (event) => {
|
|
81
82
|
const newTab = event.currentTarget;
|
|
82
83
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -223,9 +224,9 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
223
224
|
);
|
|
224
225
|
}
|
|
225
226
|
function TabsComponent(props) {
|
|
226
|
-
const tabs = (0,
|
|
227
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
227
228
|
return react_1.default.createElement(
|
|
228
|
-
|
|
229
|
+
tabsUtils_1.TabsProvider,
|
|
229
230
|
{ value: tabs },
|
|
230
231
|
react_1.default.createElement(
|
|
231
232
|
"div",
|
|
@@ -252,6 +253,6 @@ function DiscriminatorTabs(props) {
|
|
|
252
253
|
key: String(isBrowser),
|
|
253
254
|
...props,
|
|
254
255
|
},
|
|
255
|
-
(0,
|
|
256
|
+
(0, tabsUtils_1.sanitizeTabsChildren)(props.children)
|
|
256
257
|
);
|
|
257
258
|
}
|
|
@@ -69,12 +69,13 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = MimeTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
73
|
const slice_1 = require("@theme/ApiExplorer/Accept/slice");
|
|
75
74
|
const slice_2 = require("@theme/ApiExplorer/ContentType/slice");
|
|
76
75
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
77
76
|
const clsx_1 = __importDefault(require("clsx"));
|
|
77
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
78
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
78
79
|
function TabList({
|
|
79
80
|
className,
|
|
80
81
|
block,
|
|
@@ -85,7 +86,7 @@ function TabList({
|
|
|
85
86
|
}) {
|
|
86
87
|
const tabRefs = [];
|
|
87
88
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
88
|
-
|
|
89
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
89
90
|
// custom
|
|
90
91
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
91
92
|
const isRequestSchema = schemaType?.toLowerCase() === "request";
|
|
@@ -256,9 +257,9 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
256
257
|
);
|
|
257
258
|
}
|
|
258
259
|
function TabsComponent(props) {
|
|
259
|
-
const tabs = (0,
|
|
260
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
260
261
|
return react_1.default.createElement(
|
|
261
|
-
|
|
262
|
+
tabsUtils_1.TabsProvider,
|
|
262
263
|
{ value: tabs },
|
|
263
264
|
react_1.default.createElement(
|
|
264
265
|
"div",
|
|
@@ -280,6 +281,6 @@ function MimeTabs(props) {
|
|
|
280
281
|
key: String(isBrowser),
|
|
281
282
|
...props,
|
|
282
283
|
},
|
|
283
|
-
(0,
|
|
284
|
+
(0, tabsUtils_1.sanitizeTabsChildren)(props.children)
|
|
284
285
|
);
|
|
285
286
|
}
|
|
@@ -69,13 +69,14 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = OperationTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
73
|
const clsx_1 = __importDefault(require("clsx"));
|
|
74
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
75
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
75
76
|
function TabList({ className, block, selectedValue, selectValue, tabValues }) {
|
|
76
77
|
const tabRefs = [];
|
|
77
78
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
78
|
-
|
|
79
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
79
80
|
const handleTabChange = (event) => {
|
|
80
81
|
const newTab = event.currentTarget;
|
|
81
82
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -218,9 +219,9 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
218
219
|
);
|
|
219
220
|
}
|
|
220
221
|
function TabsComponent(props) {
|
|
221
|
-
const tabs = (0,
|
|
222
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
222
223
|
return react_1.default.createElement(
|
|
223
|
-
|
|
224
|
+
tabsUtils_1.TabsProvider,
|
|
224
225
|
{ value: tabs },
|
|
225
226
|
react_1.default.createElement(
|
|
226
227
|
"div",
|
|
@@ -242,6 +243,6 @@ function OperationTabs(props) {
|
|
|
242
243
|
key: String(isBrowser),
|
|
243
244
|
...props,
|
|
244
245
|
},
|
|
245
|
-
(0,
|
|
246
|
+
(0, tabsUtils_1.sanitizeTabsChildren)(props.children)
|
|
246
247
|
);
|
|
247
248
|
}
|
|
@@ -69,10 +69,11 @@ var __importDefault =
|
|
|
69
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
70
|
exports.default = SchemaTabs;
|
|
71
71
|
const react_1 = __importStar(require("react"));
|
|
72
|
-
const internal_1 = require("@docusaurus/theme-common/internal");
|
|
73
72
|
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
74
73
|
const clsx_1 = __importDefault(require("clsx"));
|
|
75
74
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
75
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
76
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
76
77
|
function TabList({
|
|
77
78
|
className,
|
|
78
79
|
block,
|
|
@@ -83,7 +84,7 @@ function TabList({
|
|
|
83
84
|
}) {
|
|
84
85
|
const tabRefs = [];
|
|
85
86
|
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
86
|
-
|
|
87
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
87
88
|
const handleTabChange = (event) => {
|
|
88
89
|
const newTab = event.currentTarget;
|
|
89
90
|
const newTabIndex = tabRefs.indexOf(newTab);
|
|
@@ -237,9 +238,9 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
237
238
|
);
|
|
238
239
|
}
|
|
239
240
|
function TabsComponent(props) {
|
|
240
|
-
const tabs = (0,
|
|
241
|
+
const tabs = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
241
242
|
return react_1.default.createElement(
|
|
242
|
-
|
|
243
|
+
tabsUtils_1.TabsProvider,
|
|
243
244
|
{ value: tabs },
|
|
244
245
|
react_1.default.createElement(
|
|
245
246
|
"div",
|
|
@@ -261,7 +262,7 @@ function SchemaTabs(props) {
|
|
|
261
262
|
}
|
|
262
263
|
let sanitizedChildren;
|
|
263
264
|
try {
|
|
264
|
-
sanitizedChildren = (0,
|
|
265
|
+
sanitizedChildren = (0, tabsUtils_1.sanitizeTabsChildren)(children);
|
|
265
266
|
} catch {
|
|
266
267
|
return null;
|
|
267
268
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
* Portions Copyright (c) Palo Alto Networks
|
|
5
|
+
*
|
|
6
|
+
* Swizzled from @docusaurus/theme-classic/src/theme/TabItem/index.tsx (MIT).
|
|
7
|
+
* Re-points useTabs to our vendored tabsUtils so that <TabItem> reads the same
|
|
8
|
+
* context our swizzled <Tabs> and OpenAPI tab variants (ApiTabs, MimeTabs,
|
|
9
|
+
* SchemaTabs, etc.) provide. See:
|
|
10
|
+
* https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/1140
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
* ========================================================================== */
|
|
15
|
+
var __importDefault =
|
|
16
|
+
(this && this.__importDefault) ||
|
|
17
|
+
function (mod) {
|
|
18
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.default = TabItem;
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
24
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
25
|
+
const styles_module_css_1 = __importDefault(require("./styles.module.css"));
|
|
26
|
+
function TabItemPanel({ children, className, hidden }) {
|
|
27
|
+
return react_1.default.createElement(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
role: "tabpanel",
|
|
31
|
+
className: (0, clsx_1.default)(
|
|
32
|
+
styles_module_css_1.default.tabItem,
|
|
33
|
+
className
|
|
34
|
+
),
|
|
35
|
+
hidden,
|
|
36
|
+
},
|
|
37
|
+
children
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function TabItem({ children, className, value }) {
|
|
41
|
+
const { selectedValue, lazy } = (0, tabsUtils_1.useTabs)();
|
|
42
|
+
const isSelected = value === selectedValue;
|
|
43
|
+
if (!isSelected && lazy) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return react_1.default.createElement(
|
|
47
|
+
TabItemPanel,
|
|
48
|
+
{ className: className, hidden: !isSelected },
|
|
49
|
+
children
|
|
50
|
+
);
|
|
51
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
4
|
+
* Portions Copyright (c) Palo Alto Networks
|
|
5
|
+
*
|
|
6
|
+
* Swizzled from @docusaurus/theme-classic/src/theme/Tabs/index.tsx (MIT).
|
|
7
|
+
* Re-points the internal hooks (useTabs, useTabsContextValue, etc.) to our
|
|
8
|
+
* vendored tabsUtils so that the entire <Tabs>/<TabItem> pair runs through a
|
|
9
|
+
* single React context owned by this package. See:
|
|
10
|
+
* https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/issues/1140
|
|
11
|
+
*
|
|
12
|
+
* This source code is licensed under the MIT license found in the
|
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
|
14
|
+
* ========================================================================== */
|
|
15
|
+
var __importDefault =
|
|
16
|
+
(this && this.__importDefault) ||
|
|
17
|
+
function (mod) {
|
|
18
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.default = Tabs;
|
|
22
|
+
const react_1 = __importDefault(require("react"));
|
|
23
|
+
const theme_common_1 = require("@docusaurus/theme-common");
|
|
24
|
+
const useIsBrowser_1 = __importDefault(require("@docusaurus/useIsBrowser"));
|
|
25
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
26
|
+
const scrollUtils_1 = require("@theme/utils/scrollUtils");
|
|
27
|
+
const tabsUtils_1 = require("@theme/utils/tabsUtils");
|
|
28
|
+
const styles_module_css_1 = __importDefault(require("./styles.module.css"));
|
|
29
|
+
function TabList({ className }) {
|
|
30
|
+
const { selectedValue, selectValue, tabValues, block } = (0,
|
|
31
|
+
tabsUtils_1.useTabs)();
|
|
32
|
+
const tabRefs = [];
|
|
33
|
+
const { blockElementScrollPositionUntilNextRender } = (0,
|
|
34
|
+
scrollUtils_1.useScrollPositionBlocker)();
|
|
35
|
+
const handleTabChange = (event) => {
|
|
36
|
+
const newTab = event.currentTarget;
|
|
37
|
+
const newTabIndex = tabRefs.indexOf(newTab);
|
|
38
|
+
const newTabValue = tabValues[newTabIndex].value;
|
|
39
|
+
if (newTabValue !== selectedValue) {
|
|
40
|
+
blockElementScrollPositionUntilNextRender(newTab);
|
|
41
|
+
selectValue(newTabValue);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const handleKeydown = (event) => {
|
|
45
|
+
let focusElement = null;
|
|
46
|
+
switch (event.key) {
|
|
47
|
+
case "Enter": {
|
|
48
|
+
handleTabChange(event);
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case "ArrowRight": {
|
|
52
|
+
const nextTab = tabRefs.indexOf(event.currentTarget) + 1;
|
|
53
|
+
focusElement = tabRefs[nextTab] ?? tabRefs[0];
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case "ArrowLeft": {
|
|
57
|
+
const prevTab = tabRefs.indexOf(event.currentTarget) - 1;
|
|
58
|
+
focusElement = tabRefs[prevTab] ?? tabRefs[tabRefs.length - 1];
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
default:
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
focusElement?.focus();
|
|
65
|
+
};
|
|
66
|
+
return react_1.default.createElement(
|
|
67
|
+
"ul",
|
|
68
|
+
{
|
|
69
|
+
role: "tablist",
|
|
70
|
+
"aria-orientation": "horizontal",
|
|
71
|
+
className: (0, clsx_1.default)(
|
|
72
|
+
"tabs",
|
|
73
|
+
{
|
|
74
|
+
"tabs--block": block,
|
|
75
|
+
},
|
|
76
|
+
className
|
|
77
|
+
),
|
|
78
|
+
},
|
|
79
|
+
tabValues.map(({ value, label, attributes }) =>
|
|
80
|
+
react_1.default.createElement(
|
|
81
|
+
"li",
|
|
82
|
+
{
|
|
83
|
+
// TODO extract TabListItem
|
|
84
|
+
role: "tab",
|
|
85
|
+
tabIndex: selectedValue === value ? 0 : -1,
|
|
86
|
+
"aria-selected": selectedValue === value,
|
|
87
|
+
key: value,
|
|
88
|
+
ref: (ref) => {
|
|
89
|
+
tabRefs.push(ref);
|
|
90
|
+
},
|
|
91
|
+
onKeyDown: handleKeydown,
|
|
92
|
+
onClick: handleTabChange,
|
|
93
|
+
...attributes,
|
|
94
|
+
className: (0, clsx_1.default)(
|
|
95
|
+
"tabs__item",
|
|
96
|
+
styles_module_css_1.default.tabItem,
|
|
97
|
+
attributes?.className,
|
|
98
|
+
{
|
|
99
|
+
"tabs__item--active": selectedValue === value,
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
},
|
|
103
|
+
label ?? value
|
|
104
|
+
)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
function TabContent({ children }) {
|
|
109
|
+
return react_1.default.createElement(
|
|
110
|
+
"div",
|
|
111
|
+
{ className: "margin-top--md" },
|
|
112
|
+
children
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function TabsContainer({ className, children }) {
|
|
116
|
+
return react_1.default.createElement(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
className: (0, clsx_1.default)(
|
|
120
|
+
theme_common_1.ThemeClassNames.tabs.container,
|
|
121
|
+
// former name kept for backward compatibility
|
|
122
|
+
// see https://github.com/facebook/docusaurus/pull/4086
|
|
123
|
+
"tabs-container",
|
|
124
|
+
styles_module_css_1.default.tabList
|
|
125
|
+
),
|
|
126
|
+
},
|
|
127
|
+
react_1.default.createElement(TabList, { className: className }),
|
|
128
|
+
react_1.default.createElement(TabContent, null, children)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
function Tabs(props) {
|
|
132
|
+
const isBrowser = (0, useIsBrowser_1.default)();
|
|
133
|
+
const value = (0, tabsUtils_1.useTabsContextValue)(props);
|
|
134
|
+
return react_1.default.createElement(
|
|
135
|
+
tabsUtils_1.TabsProvider,
|
|
136
|
+
{
|
|
137
|
+
value: value,
|
|
138
|
+
// Remount tabs after hydration
|
|
139
|
+
// Temporary fix for https://github.com/facebook/docusaurus/issues/5653
|
|
140
|
+
key: String(isBrowser),
|
|
141
|
+
},
|
|
142
|
+
react_1.default.createElement(
|
|
143
|
+
TabsContainer,
|
|
144
|
+
{ className: props.className },
|
|
145
|
+
(0, tabsUtils_1.sanitizeTabsChildren)(props.children)
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { PrismTheme } from "prism-react-renderer";
|
|
3
|
+
export type MagicCommentConfig = {
|
|
4
|
+
className: string;
|
|
5
|
+
line?: string;
|
|
6
|
+
block?: {
|
|
7
|
+
start: string;
|
|
8
|
+
end: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function parseCodeBlockTitle(metastring?: string): string;
|
|
12
|
+
export declare function containsLineNumbers(metastring?: string): boolean;
|
|
13
|
+
type ParseCodeLinesParam = {
|
|
14
|
+
metastring: string | undefined;
|
|
15
|
+
language: string | undefined;
|
|
16
|
+
magicComments: MagicCommentConfig[];
|
|
17
|
+
};
|
|
18
|
+
type CodeLineClassNames = {
|
|
19
|
+
[lineIndex: number]: string[];
|
|
20
|
+
};
|
|
21
|
+
type ParsedCodeLines = {
|
|
22
|
+
code: string;
|
|
23
|
+
lineClassNames: CodeLineClassNames;
|
|
24
|
+
};
|
|
25
|
+
export declare function parseLines(code: string, params: ParseCodeLinesParam): ParsedCodeLines;
|
|
26
|
+
declare function parseClassNameLanguage(className: string | undefined): string | undefined;
|
|
27
|
+
export { parseClassNameLanguage as parseLanguage };
|
|
28
|
+
export declare function getPrismCssVariables(prismTheme: PrismTheme): CSSProperties;
|