docusaurus-theme-openapi-docs 3.0.0-beta.8 → 3.0.0

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 (50) hide show
  1. package/lib/theme/ApiExplorer/Body/slice.d.ts +8 -8
  2. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +1 -1
  3. package/lib/theme/ApiExplorer/CodeSnippets/index.js +16 -10
  4. package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +1 -0
  5. package/lib/theme/ApiExplorer/CodeSnippets/languages.js +29 -2
  6. package/lib/theme/ApiExplorer/Request/index.js +1 -3
  7. package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +1 -1
  8. package/lib/theme/ApiExplorer/Response/index.js +4 -1
  9. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
  10. package/lib/theme/ApiExplorer/buildPostmanRequest.js +1 -3
  11. package/lib/theme/ApiExplorer/index.js +1 -3
  12. package/lib/theme/ApiExplorer/persistanceMiddleware.js +6 -6
  13. package/lib/theme/ApiItem/Layout/index.js +19 -6
  14. package/lib/theme/ApiItem/index.js +6 -4
  15. package/lib/theme/ApiTabs/_ApiTabs.scss +1 -0
  16. package/lib/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +1 -0
  17. package/lib/theme/MimeTabs/_MimeTabs.scss +1 -0
  18. package/lib/theme/MimeTabs/index.js +2 -2
  19. package/lib/theme/OperationTabs/_OperationTabs.scss +1 -0
  20. package/lib/theme/SchemaTabs/_SchemaTabs.scss +1 -0
  21. package/lib/theme/SchemaTabs/index.js +10 -4
  22. package/lib/theme/styles.scss +15 -15
  23. package/package.json +5 -5
  24. package/src/postman-code-generators.d.ts +1 -1
  25. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +17 -11
  26. package/src/theme/ApiExplorer/CodeSnippets/languages.ts +22 -0
  27. package/src/theme/ApiExplorer/Request/index.tsx +1 -1
  28. package/src/theme/ApiExplorer/Request/makeRequest.ts +1 -1
  29. package/src/theme/ApiExplorer/Response/index.tsx +4 -1
  30. package/src/theme/ApiExplorer/buildPostmanRequest.ts +1 -1
  31. package/src/theme/ApiExplorer/index.tsx +1 -1
  32. package/src/theme/ApiExplorer/persistanceMiddleware.ts +6 -6
  33. package/src/theme/ApiExplorer/postman-collection.d.ts +1 -1
  34. package/src/theme/ApiItem/Layout/index.tsx +8 -4
  35. package/src/theme/ApiItem/index.tsx +6 -5
  36. package/src/theme/ApiTabs/_ApiTabs.scss +1 -0
  37. package/src/theme/ApiTabs/index.tsx +2 -2
  38. package/src/theme/DiscriminatorTabs/_DiscriminatorTabs.scss +1 -0
  39. package/src/theme/MimeTabs/_MimeTabs.scss +1 -0
  40. package/src/theme/MimeTabs/index.tsx +1 -1
  41. package/src/theme/OperationTabs/_OperationTabs.scss +1 -0
  42. package/src/theme/SchemaTabs/_SchemaTabs.scss +1 -0
  43. package/src/theme/SchemaTabs/index.tsx +12 -5
  44. package/src/theme/styles.scss +15 -15
  45. package/src/theme-openapi.d.ts +1 -0
  46. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.d.ts +0 -13
  47. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +0 -240
  48. package/lib/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +0 -46
  49. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.tsx +0 -178
  50. package/src/theme/ApiDemoPanel/ApiCodeBlock/Line/_Line.scss +0 -46
@@ -1,178 +0,0 @@
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, { useEffect } from "react";
9
-
10
- import { usePrismTheme } from "@docusaurus/theme-common";
11
- import { translate } from "@docusaurus/Translate";
12
- // @ts-ignore
13
- import Container from "@theme/ApiExplorer/ApiCodeBlock/Container";
14
- // @ts-ignore
15
- import CopyButton from "@theme/ApiExplorer/ApiCodeBlock/CopyButton";
16
- // @ts-ignore
17
- import ExitButton from "@theme/ApiExplorer/ApiCodeBlock/ExitButton";
18
- // @ts-ignore
19
- import Line from "@theme/ApiExplorer/ApiCodeBlock/Line";
20
- import clsx from "clsx";
21
- import { Highlight, type Language } from "prism-react-renderer";
22
- import Modal from "react-modal";
23
-
24
- interface Props {
25
- code: string;
26
- className: string;
27
- language: Language;
28
- showLineNumbers: boolean;
29
- blockClassName: string;
30
- title: string;
31
- lineClassNames: string[];
32
- }
33
-
34
- export default function ExpandButton({
35
- code,
36
- className,
37
- language,
38
- showLineNumbers,
39
- blockClassName,
40
- title,
41
- lineClassNames,
42
- }: Props): React.JSX.Element {
43
- const prismTheme = usePrismTheme();
44
-
45
- function openModal() {
46
- setIsOpen(true);
47
- }
48
-
49
- function closeModal() {
50
- setIsOpen(false);
51
- }
52
-
53
- const [modalIsOpen, setIsOpen] = React.useState(false);
54
-
55
- useEffect(() => {
56
- Modal.setAppElement("body");
57
- });
58
-
59
- return (
60
- <>
61
- <button
62
- type="button"
63
- aria-label={
64
- modalIsOpen
65
- ? translate({
66
- id: "theme.CodeBlock.expanded",
67
- message: "Expanded",
68
- description: "The expanded button label on code blocks",
69
- })
70
- : translate({
71
- id: "theme.CodeBlock.expandButtonAriaLabel",
72
- message: "Expand code to fullscreen",
73
- description: "The ARIA label for expand code blocks button",
74
- })
75
- }
76
- title={translate({
77
- id: "theme.CodeBlock.expand",
78
- message: "Expand",
79
- description: "The expand button label on code blocks",
80
- })}
81
- className={clsx(
82
- "clean-btn",
83
- className,
84
- "openapi-explorer__code-block-expand-btn",
85
- modalIsOpen && "openapi-explorer__code-block-expand-btn--copied"
86
- )}
87
- onClick={openModal}
88
- >
89
- <span
90
- className="openapi-explorer__code-block-expand-btn-icons"
91
- aria-hidden="true"
92
- >
93
- <svg
94
- className="openapi-explorer__code-block-expand-btn-icon"
95
- viewBox="0 0 448 512"
96
- >
97
- <path d="M32 32C14.3 32 0 46.3 0 64v96c0 17.7 14.3 32 32 32s32-14.3 32-32V96h64c17.7 0 32-14.3 32-32s-14.3-32-32-32H32zM64 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v96c0 17.7 14.3 32 32 32h96c17.7 0 32-14.3 32-32s-14.3-32-32-32H64V352zM320 32c-17.7 0-32 14.3-32 32s14.3 32 32 32h64v64c0 17.7 14.3 32 32 32s32-14.3 32-32V64c0-17.7-14.3-32-32-32H320zM448 352c0-17.7-14.3-32-32-32s-32 14.3-32 32v64H320c-17.7 0-32 14.3-32 32s14.3 32 32 32h96c17.7 0 32-14.3 32-32V352z" />
98
- </svg>
99
- <svg
100
- className="openapi-explorer__code-block-expand-btn-icon--success"
101
- viewBox="0 0 24 24"
102
- >
103
- <path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
104
- </svg>
105
- </span>
106
- </button>
107
- <Modal
108
- className="openapi-explorer__expand-modal-content"
109
- overlayClassName="openapi-explorer__expand-modal-overlay"
110
- isOpen={modalIsOpen}
111
- onRequestClose={closeModal}
112
- contentLabel="Code Snippet"
113
- >
114
- <Container
115
- as="div"
116
- className={clsx(
117
- "openapi-explorer__code-block-container",
118
- language &&
119
- !blockClassName.includes(`language-${language}`) &&
120
- `language-${language}`
121
- )}
122
- >
123
- {title && (
124
- <div className="openapi-explorer__code-block-title">{title}</div>
125
- )}
126
- <div className="openapi-explorer__code-block-content">
127
- <Highlight
128
- theme={prismTheme}
129
- code={code}
130
- language={language ?? "text"}
131
- >
132
- {({ className, tokens, getLineProps, getTokenProps }) => (
133
- <pre
134
- /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
135
- tabIndex={0}
136
- className={clsx(
137
- className,
138
- "openapi-explorer__code-block",
139
- "thin-scrollbar"
140
- )}
141
- >
142
- <code
143
- className={clsx(
144
- "openapi-explorer__code-block-lines",
145
- showLineNumbers &&
146
- "openapi-explorer__code-block-lines-numbers"
147
- )}
148
- >
149
- {tokens.map((line, i) => (
150
- <Line
151
- key={i}
152
- line={line}
153
- getLineProps={getLineProps}
154
- getTokenProps={getTokenProps}
155
- classNames={lineClassNames}
156
- showLineNumbers={showLineNumbers}
157
- />
158
- ))}
159
- </code>
160
- </pre>
161
- )}
162
- </Highlight>
163
- <div className="openapi-explorer__code-block-btn-group">
164
- <CopyButton
165
- className="openapi-explorer__code-block-code-btn"
166
- code={code}
167
- />
168
- <ExitButton
169
- className="openapi-dmeo__code-block-code-btn"
170
- handler={closeModal}
171
- />
172
- </div>
173
- </div>
174
- </Container>
175
- </Modal>
176
- </>
177
- );
178
- }
@@ -1,46 +0,0 @@
1
- /* Intentionally has zero specificity, so that to be able to override
2
- the background in custom CSS file due bug https://github.com/facebook/docusaurus/issues/3678 */
3
- :where(:root) {
4
- --docusaurus-highlighted-code-line-bg: rgb(72 77 91);
5
- }
6
-
7
- :where([data-theme="dark"]) {
8
- --docusaurus-highlighted-code-line-bg: rgb(100 100 100);
9
- }
10
-
11
- .theme-code-block-highlighted-line {
12
- background-color: var(--docusaurus-highlighted-code-line-bg);
13
- display: block;
14
- margin: 0 calc(-1 * var(--ifm-pre-padding));
15
- padding: 0 var(--ifm-pre-padding);
16
- }
17
-
18
- .openapi-explorer__code-block-code-line {
19
- display: table-row;
20
- counter-increment: line-count;
21
- }
22
-
23
- .openapi-explorer__code-block-code-line-number {
24
- display: table-cell;
25
- text-align: right;
26
- width: 1%;
27
- position: sticky;
28
- left: 0;
29
- padding: 0 var(--ifm-pre-padding);
30
- background: var(--ifm-pre-background);
31
- overflow-wrap: normal;
32
- }
33
-
34
- .openapi-explorer__code-block-code-line-number::before {
35
- content: counter(line-count);
36
- opacity: 0.4;
37
- }
38
-
39
- :global(.theme-code-block-highlighted-line)
40
- .openapi-explorer__code-block-code-line-number::before {
41
- opacity: 0.8;
42
- }
43
-
44
- .openapi-explorer__code-block-code-line-number {
45
- padding-right: var(--ifm-pre-padding);
46
- }