docusaurus-theme-openapi-docs 0.0.0-392 → 0.0.0-395

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 (58) hide show
  1. package/lib/theme/ApiDemoPanel/CodeTabs/index.js +8 -3
  2. package/lib/theme/ApiItem/Content/index.js +65 -0
  3. package/lib/theme/ApiItem/Footer/index.js +78 -0
  4. package/lib/theme/ApiItem/Footer/styles.module.css +18 -0
  5. package/lib/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  6. package/lib/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  7. package/lib/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  8. package/lib/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  9. package/lib/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  10. package/lib/theme/ApiItem/Layout/index.js +93 -0
  11. package/lib/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +22 -0
  12. package/lib/theme/ApiItem/Metadata/index.js +32 -0
  13. package/lib/theme/ApiItem/Paginator/index.js +33 -0
  14. package/lib/theme/ApiItem/TOC/Desktop/index.js +31 -0
  15. package/lib/theme/ApiItem/TOC/Mobile/index.js +35 -0
  16. package/lib/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  17. package/lib/theme/ApiItem/index.js +37 -126
  18. package/lib/theme/ApiTabs/index.js +6 -5
  19. package/lib/theme/SchemaTabs/index.js +6 -5
  20. package/lib-next/theme/ApiDemoPanel/CodeTabs/index.js +7 -6
  21. package/lib-next/theme/ApiItem/Content/index.js +55 -0
  22. package/lib-next/theme/ApiItem/Footer/index.js +88 -0
  23. package/lib-next/theme/ApiItem/Footer/styles.module.css +18 -0
  24. package/lib-next/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  25. package/lib-next/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  26. package/lib-next/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  27. package/lib-next/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  28. package/lib-next/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  29. package/lib-next/theme/ApiItem/Layout/index.js +69 -0
  30. package/lib-next/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +22 -0
  31. package/lib-next/theme/ApiItem/Metadata/index.js +21 -0
  32. package/lib-next/theme/ApiItem/Paginator/index.js +19 -0
  33. package/lib-next/theme/ApiItem/TOC/Desktop/index.js +22 -0
  34. package/lib-next/theme/ApiItem/TOC/Mobile/index.js +24 -0
  35. package/lib-next/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  36. package/lib-next/theme/ApiItem/index.js +31 -133
  37. package/lib-next/theme/ApiTabs/index.js +6 -5
  38. package/lib-next/theme/SchemaTabs/index.js +6 -5
  39. package/package.json +6 -6
  40. package/src/theme/ApiDemoPanel/CodeTabs/index.tsx +6 -5
  41. package/src/theme/ApiItem/Content/index.tsx +57 -0
  42. package/src/theme/ApiItem/Footer/index.tsx +101 -0
  43. package/src/theme/ApiItem/Footer/styles.module.css +18 -0
  44. package/src/theme/ApiItem/{icons → Layout/icons}/bash-original.svg +0 -0
  45. package/src/theme/ApiItem/{icons → Layout/icons}/go-original-wordmark.svg +0 -0
  46. package/src/theme/ApiItem/{icons → Layout/icons}/javascript-original.svg +0 -0
  47. package/src/theme/ApiItem/{icons → Layout/icons}/linux-original.svg +0 -0
  48. package/src/theme/ApiItem/{icons → Layout/icons}/python-original.svg +0 -0
  49. package/src/theme/ApiItem/Layout/index.tsx +78 -0
  50. package/src/theme/ApiItem/{styles.module.css → Layout/styles.module.css} +22 -0
  51. package/src/theme/ApiItem/Metadata/index.tsx +24 -0
  52. package/src/theme/ApiItem/Paginator/index.tsx +21 -0
  53. package/src/theme/ApiItem/TOC/Desktop/index.tsx +25 -0
  54. package/src/theme/ApiItem/TOC/Mobile/index.tsx +28 -0
  55. package/src/theme/ApiItem/TOC/Mobile/styles.module.css +19 -0
  56. package/src/theme/ApiItem/index.tsx +31 -130
  57. package/src/theme/ApiTabs/index.js +6 -5
  58. package/src/theme/SchemaTabs/index.js +6 -5
@@ -14,16 +14,17 @@ import React, {
14
14
  useState,
15
15
  } from "react";
16
16
 
17
- import {
18
- duplicates,
19
- useScrollPositionBlocker,
20
- useTabGroupChoice,
21
- } from "@docusaurus/theme-common";
17
+ import { duplicates } from "@docusaurus/theme-common";
22
18
  import useIsBrowser from "@docusaurus/useIsBrowser";
23
19
  import clsx from "clsx";
24
20
 
25
21
  import styles from "./styles.module.css"; // A very rough duck type, but good enough to guard against mistakes while
26
22
 
23
+ const {
24
+ useScrollPositionBlocker,
25
+ useTabGroupChoice,
26
+ } = require("@docusaurus/theme-common/internal");
27
+
27
28
  // allowing customization
28
29
 
29
30
  function isTabItem(comp) {
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-392",
4
+ "version": "0.0.0-395",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "openapi",
@@ -31,8 +31,8 @@
31
31
  "format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
32
32
  },
33
33
  "devDependencies": {
34
- "@docusaurus/module-type-aliases": "2.0.0-beta.21",
35
- "@docusaurus/types": "2.0.0-beta.21",
34
+ "@docusaurus/module-type-aliases": "2.0.0-beta.22",
35
+ "@docusaurus/types": "2.0.0-beta.22",
36
36
  "@types/concurrently": "^6.3.0",
37
37
  "@types/crypto-js": "^4.1.0",
38
38
  "@types/fs-extra": "^9.0.13",
@@ -42,7 +42,7 @@
42
42
  "concurrently": "^5.2.0"
43
43
  },
44
44
  "dependencies": {
45
- "@docusaurus/theme-common": "2.0.0-beta.21",
45
+ "@docusaurus/theme-common": "2.0.0-beta.22",
46
46
  "@mdx-js/react": "^1.6.21",
47
47
  "@paloaltonetworks/postman-code-generators": "1.1.5-hotfix.5",
48
48
  "@paloaltonetworks/postman-collection": "^4.1.0",
@@ -50,7 +50,7 @@
50
50
  "buffer": "^6.0.3",
51
51
  "clsx": "^1.1.1",
52
52
  "crypto-js": "^4.1.1",
53
- "docusaurus-plugin-openapi-docs": "0.0.0-392",
53
+ "docusaurus-plugin-openapi-docs": "0.0.0-395",
54
54
  "immer": "^9.0.7",
55
55
  "lodash": "^4.17.20",
56
56
  "process": "^0.11.10",
@@ -68,5 +68,5 @@
68
68
  "engines": {
69
69
  "node": ">=14"
70
70
  },
71
- "gitHead": "04ea33fa332252a40c87d8018afe6cdb91cbdf8a"
71
+ "gitHead": "6b0d77e35b366bb8418b6f9523b29e5c137a7464"
72
72
  }
@@ -12,11 +12,7 @@ import React, {
12
12
  type ReactElement,
13
13
  } from "react";
14
14
 
15
- import {
16
- useScrollPositionBlocker,
17
- duplicates,
18
- useTabGroupChoice,
19
- } from "@docusaurus/theme-common";
15
+ import { duplicates } from "@docusaurus/theme-common";
20
16
  import useIsBrowser from "@docusaurus/useIsBrowser";
21
17
  import type { Props as TabItemProps } from "@theme/TabItem";
22
18
  import clsx from "clsx";
@@ -24,6 +20,11 @@ import clsx from "clsx";
24
20
  import { languageSet } from "../Curl";
25
21
  import styles from "./styles.module.css";
26
22
 
23
+ const {
24
+ useScrollPositionBlocker,
25
+ useTabGroupChoice,
26
+ } = require("@docusaurus/theme-common/internal");
27
+
27
28
  // A very rough duck type, but good enough to guard against mistakes while
28
29
  // allowing customization
29
30
  function isTabItem(
@@ -0,0 +1,57 @@
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 from "react";
9
+
10
+ import { ThemeClassNames } from "@docusaurus/theme-common";
11
+ // @ts-ignore
12
+ import { useDoc } from "@docusaurus/theme-common/internal";
13
+ import type { Props } from "@theme/DocItem/Content";
14
+ import Heading from "@theme/Heading";
15
+ import MDXContent from "@theme/MDXContent";
16
+ import clsx from "clsx";
17
+
18
+ /**
19
+ Title can be declared inside md content or declared through
20
+ front matter and added manually. To make both cases consistent,
21
+ the added title is added under the same div.markdown block
22
+ See https://github.com/facebook/docusaurus/pull/4882#issuecomment-853021120
23
+
24
+ We render a "synthetic title" if:
25
+ - user doesn't ask to hide it with front matter
26
+ - the markdown content does not already contain a top-level h1 heading
27
+ */
28
+ function useSyntheticTitle(): string | null {
29
+ const { metadata, frontMatter, contentTitle } = useDoc();
30
+ const shouldRender =
31
+ !frontMatter.hide_title && typeof contentTitle === "undefined";
32
+ if (!shouldRender) {
33
+ return null;
34
+ }
35
+ return metadata.title;
36
+ }
37
+
38
+ export default function DocItemContent({ children }: Props): JSX.Element {
39
+ const syntheticTitle = useSyntheticTitle();
40
+
41
+ return (
42
+ <div
43
+ className={clsx(
44
+ ThemeClassNames.docs.docMarkdown,
45
+ "theme-api-markdown",
46
+ "markdown"
47
+ )}
48
+ >
49
+ {syntheticTitle && (
50
+ <header>
51
+ <Heading as="h1">{syntheticTitle}</Heading>
52
+ </header>
53
+ )}
54
+ <MDXContent>{children}</MDXContent>
55
+ </div>
56
+ );
57
+ }
@@ -0,0 +1,101 @@
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 from "react";
9
+
10
+ import { ThemeClassNames } from "@docusaurus/theme-common";
11
+ import {
12
+ useDoc,
13
+ type DocContextValue,
14
+ // @ts-ignore
15
+ } from "@docusaurus/theme-common/internal";
16
+ import EditThisPage from "@theme/EditThisPage";
17
+ import LastUpdated from "@theme/LastUpdated";
18
+ import TagsListInline, {
19
+ type Props as TagsListInlineProps,
20
+ } from "@theme/TagsListInline";
21
+ import clsx from "clsx";
22
+
23
+ import styles from "./styles.module.css";
24
+
25
+ function TagsRow(props: TagsListInlineProps) {
26
+ return (
27
+ <div
28
+ className={clsx(
29
+ ThemeClassNames.docs.docFooterTagsRow,
30
+ "row margin-bottom--sm"
31
+ )}
32
+ >
33
+ <div className="col">
34
+ <TagsListInline {...props} />
35
+ </div>
36
+ </div>
37
+ );
38
+ }
39
+
40
+ type EditMetaRowProps = Pick<
41
+ DocContextValue["metadata"],
42
+ "editUrl" | "lastUpdatedAt" | "lastUpdatedBy" | "formattedLastUpdatedAt"
43
+ >;
44
+ function EditMetaRow({
45
+ editUrl,
46
+ lastUpdatedAt,
47
+ lastUpdatedBy,
48
+ formattedLastUpdatedAt,
49
+ }: EditMetaRowProps) {
50
+ return (
51
+ <div className={clsx(ThemeClassNames.docs.docFooterEditMetaRow, "row")}>
52
+ <div className="col">{editUrl && <EditThisPage editUrl={editUrl} />}</div>
53
+
54
+ <div className={clsx("col", styles.lastUpdated)}>
55
+ {(lastUpdatedAt || lastUpdatedBy) && (
56
+ <LastUpdated
57
+ lastUpdatedAt={lastUpdatedAt}
58
+ formattedLastUpdatedAt={formattedLastUpdatedAt}
59
+ lastUpdatedBy={lastUpdatedBy}
60
+ />
61
+ )}
62
+ </div>
63
+ </div>
64
+ );
65
+ }
66
+
67
+ export default function DocItemFooter(): JSX.Element | null {
68
+ const { metadata } = useDoc();
69
+ const {
70
+ editUrl,
71
+ lastUpdatedAt,
72
+ formattedLastUpdatedAt,
73
+ lastUpdatedBy,
74
+ tags,
75
+ } = metadata;
76
+
77
+ const canDisplayTagsRow = tags.length > 0;
78
+ const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);
79
+
80
+ const canDisplayFooter = canDisplayTagsRow || canDisplayEditMetaRow;
81
+
82
+ if (!canDisplayFooter) {
83
+ return null;
84
+ }
85
+
86
+ return (
87
+ <footer
88
+ className={clsx(ThemeClassNames.docs.docFooter, "docusaurus-mt-lg")}
89
+ >
90
+ {canDisplayTagsRow && <TagsRow tags={tags} />}
91
+ {canDisplayEditMetaRow && (
92
+ <EditMetaRow
93
+ editUrl={editUrl}
94
+ lastUpdatedAt={lastUpdatedAt}
95
+ lastUpdatedBy={lastUpdatedBy}
96
+ formattedLastUpdatedAt={formattedLastUpdatedAt}
97
+ />
98
+ )}
99
+ </footer>
100
+ );
101
+ }
@@ -0,0 +1,18 @@
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
+ .lastUpdated {
9
+ margin-top: 0.2rem;
10
+ font-style: italic;
11
+ font-size: smaller;
12
+ }
13
+
14
+ @media (min-width: 997px) {
15
+ .lastUpdated {
16
+ text-align: right;
17
+ }
18
+ }
@@ -0,0 +1,78 @@
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 from "react";
9
+
10
+ import { useWindowSize } from "@docusaurus/theme-common";
11
+ // @ts-ignore
12
+ import { useDoc } from "@docusaurus/theme-common/internal";
13
+ import DocBreadcrumbs from "@theme/DocBreadcrumbs";
14
+ import type { Props } from "@theme/DocItem/Layout";
15
+ import DocVersionBadge from "@theme/DocVersionBadge";
16
+ import DocVersionBanner from "@theme/DocVersionBanner";
17
+ import clsx from "clsx";
18
+
19
+ import DocItemContent from "../Content";
20
+ import DocItemFooter from "../Footer";
21
+ import DocItemPaginator from "../Paginator";
22
+ import DocItemTOCDesktop from "../TOC/Desktop";
23
+ import DocItemTOCMobile from "../TOC/Mobile";
24
+ import styles from "./styles.module.css";
25
+
26
+ /**
27
+ * Decide if the toc should be rendered, on mobile or desktop viewports
28
+ */
29
+ function useDocTOC() {
30
+ const { frontMatter, toc } = useDoc();
31
+ const windowSize = useWindowSize();
32
+
33
+ const hidden = frontMatter.hide_table_of_contents;
34
+ const canRender = !hidden && toc.length > 0;
35
+
36
+ const mobile = canRender ? <DocItemTOCMobile /> : undefined;
37
+
38
+ const desktop =
39
+ canRender && (windowSize === "desktop" || windowSize === "ssr") ? (
40
+ <DocItemTOCDesktop />
41
+ ) : undefined;
42
+
43
+ return {
44
+ hidden,
45
+ mobile,
46
+ desktop,
47
+ };
48
+ }
49
+
50
+ export default function DocItemLayout({ children }: Props): JSX.Element {
51
+ const docTOC = useDocTOC();
52
+ const {
53
+ frontMatter: { api },
54
+ } = useDoc();
55
+
56
+ return (
57
+ <div className="row">
58
+ <div className={clsx("col", !docTOC.hidden && styles.docItemCol)}>
59
+ <DocVersionBanner />
60
+ <div className={styles.docItemContainer}>
61
+ <article>
62
+ <DocBreadcrumbs />
63
+ <DocVersionBadge />
64
+ {docTOC.mobile}
65
+ <DocItemContent>{children}</DocItemContent>
66
+ <div className={clsx("col", api ? "col--7" : "col--12")}>
67
+ <DocItemFooter />
68
+ </div>
69
+ </article>
70
+ <div className={clsx("col", api ? "col--7" : "col--12")}>
71
+ <DocItemPaginator />
72
+ </div>
73
+ </div>
74
+ </div>
75
+ {docTOC.desktop && <div className="col col--3">{docTOC.desktop}</div>}
76
+ </div>
77
+ );
78
+ }
@@ -1,3 +1,10 @@
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
+
1
8
  :root {
2
9
  --openapi-required: var(--ifm-color-danger);
3
10
  --openapi-code-blue: var(--ifm-color-info);
@@ -6,6 +13,21 @@
6
13
  --openapi-code-green: var(--ifm-color-success);
7
14
  }
8
15
 
16
+ :global(.docs-wrapper) {
17
+ height: 100%;
18
+ }
19
+
20
+ .docItemContainer header + *,
21
+ .docItemContainer article > *:first-child {
22
+ margin-top: 0;
23
+ }
24
+
25
+ @media (min-width: 997px) {
26
+ .docItemCol {
27
+ max-width: 75% !important;
28
+ }
29
+ }
30
+
9
31
  .apiItemContainer article > *:first-child,
10
32
  .apiItemContainer header + * {
11
33
  margin-top: 0;
@@ -0,0 +1,24 @@
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 from "react";
9
+
10
+ import { PageMetadata } from "@docusaurus/theme-common";
11
+ // @ts-ignore
12
+ import { useDoc } from "@docusaurus/theme-common/internal";
13
+
14
+ export default function DocItemMetadata(): JSX.Element {
15
+ const { metadata, frontMatter, assets } = useDoc();
16
+ return (
17
+ <PageMetadata
18
+ title={metadata.title}
19
+ description={metadata.description}
20
+ keywords={frontMatter.keywords}
21
+ image={assets.image ?? frontMatter.image}
22
+ />
23
+ );
24
+ }
@@ -0,0 +1,21 @@
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 from "react";
9
+
10
+ // @ts-ignore
11
+ import { useDoc } from "@docusaurus/theme-common/internal";
12
+ import DocPaginator from "@theme/DocPaginator";
13
+
14
+ /**
15
+ * This extra component is needed, because <DocPaginator> should remain generic.
16
+ * DocPaginator is used in non-docs contexts too: generated-index pages...
17
+ */
18
+ export default function DocItemPaginator(): JSX.Element {
19
+ const { metadata } = useDoc();
20
+ return <DocPaginator previous={metadata.previous} next={metadata.next} />;
21
+ }
@@ -0,0 +1,25 @@
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 from "react";
9
+
10
+ import { ThemeClassNames } from "@docusaurus/theme-common";
11
+ // @ts-ignore
12
+ import { useDoc } from "@docusaurus/theme-common/internal";
13
+ import TOC from "@theme/TOC";
14
+
15
+ export default function DocItemTOCDesktop(): JSX.Element {
16
+ const { toc, frontMatter } = useDoc();
17
+ return (
18
+ <TOC
19
+ toc={toc}
20
+ minHeadingLevel={frontMatter.toc_min_heading_level}
21
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
22
+ className={ThemeClassNames.docs.docTocDesktop}
23
+ />
24
+ );
25
+ }
@@ -0,0 +1,28 @@
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 from "react";
9
+
10
+ import { ThemeClassNames } from "@docusaurus/theme-common";
11
+ // @ts-ignore
12
+ import { useDoc } from "@docusaurus/theme-common/internal";
13
+ import TOCCollapsible from "@theme/TOCCollapsible";
14
+ import clsx from "clsx";
15
+
16
+ import styles from "./styles.module.css";
17
+
18
+ export default function DocItemTOCMobile(): JSX.Element {
19
+ const { toc, frontMatter } = useDoc();
20
+ return (
21
+ <TOCCollapsible
22
+ toc={toc}
23
+ minHeadingLevel={frontMatter.toc_min_heading_level}
24
+ maxHeadingLevel={frontMatter.toc_max_heading_level}
25
+ className={clsx(ThemeClassNames.docs.docTocMobile, styles.tocMobile)}
26
+ />
27
+ );
28
+ }
@@ -0,0 +1,19 @@
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
+ @media (min-width: 997px) {
9
+ /* Prevent hydration FOUC, as the mobile TOC needs to be server-rendered */
10
+ .tocMobile {
11
+ display: none;
12
+ }
13
+ }
14
+
15
+ @media print {
16
+ .tocMobile {
17
+ display: none;
18
+ }
19
+ }