docusaurus-theme-openapi-docs 0.0.0-739 → 0.0.0-750

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,4 +1,5 @@
1
- export type Children = string | undefined | (string | undefined)[];
1
+ import { ReactNode } from "react";
2
+ export type Children = ReactNode | string | undefined | (string | undefined)[];
2
3
  export type Props = Record<string, any> & {
3
4
  children?: Children;
4
5
  };
@@ -0,0 +1,4 @@
1
+ import React, { ComponentProps } from "react";
2
+ export default function CodeBlockContainer<T extends "div" | "pre">({ as: As, ...props }: {
3
+ as: T;
4
+ } & ComponentProps<T>): React.JSX.Element;
@@ -1,29 +1,35 @@
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 from "react";
9
-
10
- import { ThemeClassNames, usePrismTheme } from "@docusaurus/theme-common";
11
- import { getPrismCssVariables } from "@docusaurus/theme-common/internal";
12
- import clsx from "clsx";
13
-
14
- export default function CodeBlockContainer({ as: As, ...props }) {
15
- const prismTheme = usePrismTheme();
16
- const prismCssVariables = getPrismCssVariables(prismTheme);
17
- return (
18
- <As
19
- // Polymorphic components are hard to type, without `oneOf` generics
20
- {...props}
21
- style={prismCssVariables}
22
- className={clsx(
8
+ var __importDefault =
9
+ (this && this.__importDefault) ||
10
+ function (mod) {
11
+ return mod && mod.__esModule ? mod : { default: mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const react_1 = __importDefault(require("react"));
15
+ const theme_common_1 = require("@docusaurus/theme-common");
16
+ const internal_1 = require("@docusaurus/theme-common/internal");
17
+ const clsx_1 = __importDefault(require("clsx"));
18
+ function CodeBlockContainer({ as: As, ...props }) {
19
+ const prismTheme = (0, theme_common_1.usePrismTheme)();
20
+ const prismCssVariables = (0, internal_1.getPrismCssVariables)(prismTheme);
21
+ return react_1.default.createElement(
22
+ As,
23
+ // Polymorphic components are hard to type, without `oneOf` generics
24
+ {
25
+ ...props,
26
+ style: prismCssVariables,
27
+ className: (0, clsx_1.default)(
23
28
  "openapi-explorer__code-block-container",
24
29
  props.className,
25
- ThemeClassNames.common.codeBlock
26
- )}
27
- />
30
+ theme_common_1.ThemeClassNames.common.codeBlock
31
+ ),
32
+ }
28
33
  );
29
34
  }
35
+ exports.default = CodeBlockContainer;
@@ -0,0 +1,4 @@
1
+ /// <reference types="@docusaurus/theme-classic" />
2
+ import React from "react";
3
+ import type { Props } from "@theme/CodeBlock/Content/Element";
4
+ export default function CodeBlockJSX({ children, className, }: Props): React.JSX.Element;
@@ -1,30 +1,41 @@
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 from "react";
9
-
10
- import Container from "@theme/ApiExplorer/ApiCodeBlock/Container";
11
- import clsx from "clsx";
12
-
8
+ var __importDefault =
9
+ (this && this.__importDefault) ||
10
+ function (mod) {
11
+ return mod && mod.__esModule ? mod : { default: mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const react_1 = __importDefault(require("react"));
15
+ const Container_1 = __importDefault(
16
+ require("@theme/ApiExplorer/ApiCodeBlock/Container")
17
+ );
18
+ const clsx_1 = __importDefault(require("clsx"));
13
19
  // <pre> tags in markdown map to CodeBlocks. They may contain JSX children. When
14
20
  // the children is not a simple string, we just return a styled block without
15
21
  // actually highlighting.
16
- export default function CodeBlockJSX({ children, className }) {
17
- return (
18
- <Container
19
- as="pre"
20
- tabIndex={0}
21
- className={clsx(
22
+ function CodeBlockJSX({ children, className }) {
23
+ return react_1.default.createElement(
24
+ Container_1.default,
25
+ {
26
+ as: "pre",
27
+ tabIndex: 0,
28
+ className: (0, clsx_1.default)(
22
29
  "openapi-explorer__code-block-standalone",
23
30
  "thin-scrollbar",
24
31
  className
25
- )}
26
- >
27
- <code className="openapi-explorer__code-block-lines">{children}</code>
28
- </Container>
32
+ ),
33
+ },
34
+ react_1.default.createElement(
35
+ "code",
36
+ { className: "openapi-explorer__code-block-lines" },
37
+ children
38
+ )
29
39
  );
30
40
  }
41
+ exports.default = CodeBlockJSX;
@@ -0,0 +1,4 @@
1
+ /// <reference types="@docusaurus/theme-classic" />
2
+ import React from "react";
3
+ import type { Props } from "@theme/CodeBlock/Content/String";
4
+ export default function CodeBlockString({ children, className: blockClassName, metastring, title: titleProp, showLineNumbers: showLineNumbersProp, language: languageProp, }: Props): React.JSX.Element;
@@ -1,29 +1,35 @@
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 from "react";
9
-
10
- import { useThemeConfig, usePrismTheme } from "@docusaurus/theme-common";
11
- import {
12
- parseCodeBlockTitle,
13
- parseLanguage,
14
- parseLines,
15
- containsLineNumbers,
16
- useCodeWordWrap,
17
- } from "@docusaurus/theme-common/internal";
18
- import Container from "@theme/ApiExplorer/ApiCodeBlock/Container";
19
- import CopyButton from "@theme/ApiExplorer/ApiCodeBlock/CopyButton";
20
- import ExpandButton from "@theme/ApiExplorer/ApiCodeBlock/ExpandButton";
21
- import Line from "@theme/ApiExplorer/ApiCodeBlock/Line";
22
- import WordWrapButton from "@theme/ApiExplorer/ApiCodeBlock/WordWrapButton";
23
- import clsx from "clsx";
24
- import Highlight, { defaultProps } from "prism-react-renderer";
25
-
26
- export default function CodeBlockString({
8
+ var __importDefault =
9
+ (this && this.__importDefault) ||
10
+ function (mod) {
11
+ return mod && mod.__esModule ? mod : { default: mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ const react_1 = __importDefault(require("react"));
15
+ const theme_common_1 = require("@docusaurus/theme-common");
16
+ const internal_1 = require("@docusaurus/theme-common/internal");
17
+ const Container_1 = __importDefault(
18
+ require("@theme/ApiExplorer/ApiCodeBlock/Container")
19
+ );
20
+ const CopyButton_1 = __importDefault(
21
+ require("@theme/ApiExplorer/ApiCodeBlock/CopyButton")
22
+ );
23
+ const ExpandButton_1 = __importDefault(
24
+ require("@theme/ApiExplorer/ApiCodeBlock/ExpandButton")
25
+ );
26
+ const Line_1 = __importDefault(require("@theme/ApiExplorer/ApiCodeBlock/Line"));
27
+ const WordWrapButton_1 = __importDefault(
28
+ require("@theme/ApiExplorer/ApiCodeBlock/WordWrapButton")
29
+ );
30
+ const clsx_1 = __importDefault(require("clsx"));
31
+ const prism_react_renderer_1 = require("prism-react-renderer");
32
+ function CodeBlockString({
27
33
  children,
28
34
  className: blockClassName = "",
29
35
  metastring,
@@ -33,102 +39,115 @@ export default function CodeBlockString({
33
39
  }) {
34
40
  const {
35
41
  prism: { defaultLanguage, magicComments },
36
- } = useThemeConfig();
42
+ } = (0, theme_common_1.useThemeConfig)();
37
43
  const language =
38
- languageProp ?? parseLanguage(blockClassName) ?? defaultLanguage;
39
- const prismTheme = usePrismTheme();
40
- const wordWrap = useCodeWordWrap();
44
+ languageProp ??
45
+ (0, internal_1.parseLanguage)(blockClassName) ??
46
+ defaultLanguage;
47
+ const prismTheme = (0, theme_common_1.usePrismTheme)();
48
+ const wordWrap = (0, internal_1.useCodeWordWrap)();
41
49
  // We still parse the metastring in case we want to support more syntax in the
42
50
  // future. Note that MDX doesn't strip quotes when parsing metastring:
43
51
  // "title=\"xyz\"" => title: "\"xyz\""
44
- const title = parseCodeBlockTitle(metastring) || titleProp;
45
- const { lineClassNames, code } = parseLines(children, {
52
+ const title = (0, internal_1.parseCodeBlockTitle)(metastring) || titleProp;
53
+ const { lineClassNames, code } = (0, internal_1.parseLines)(children, {
46
54
  metastring,
47
55
  language,
48
56
  magicComments,
49
57
  });
50
58
  const showLineNumbers =
51
- showLineNumbersProp ?? containsLineNumbers(metastring);
52
-
53
- return (
54
- <Container
55
- as="div"
56
- className={clsx(
59
+ showLineNumbersProp ?? (0, internal_1.containsLineNumbers)(metastring);
60
+ return react_1.default.createElement(
61
+ Container_1.default,
62
+ {
63
+ as: "div",
64
+ className: (0, clsx_1.default)(
57
65
  blockClassName,
58
66
  language &&
59
67
  !blockClassName.includes(`language-${language}`) &&
60
68
  `language-${language}`
61
- )}
62
- >
63
- {title && (
64
- <div className="openapi-explorer__code-block-title">{title}</div>
65
- )}
66
- <div className="openapi-explorer__code-block-content">
67
- <Highlight
68
- {...defaultProps}
69
- theme={prismTheme}
70
- code={code}
71
- language={language ?? "text"}
72
- >
73
- {({ className, tokens, getLineProps, getTokenProps }) => (
74
- <pre
69
+ ),
70
+ },
71
+ title &&
72
+ react_1.default.createElement(
73
+ "div",
74
+ { className: "openapi-explorer__code-block-title" },
75
+ title
76
+ ),
77
+ react_1.default.createElement(
78
+ "div",
79
+ { className: "openapi-explorer__code-block-content" },
80
+ react_1.default.createElement(
81
+ prism_react_renderer_1.Highlight,
82
+ // {...defaultProps}
83
+ {
84
+ // {...defaultProps}
85
+ theme: prismTheme,
86
+ code: code,
87
+ language: language ?? "text",
88
+ },
89
+ ({ className, tokens, getLineProps, getTokenProps }) =>
90
+ react_1.default.createElement(
91
+ "pre",
92
+ {
75
93
  /* eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex */
76
- tabIndex={0}
77
- ref={wordWrap.codeBlockRef}
78
- className={clsx(
94
+ tabIndex: 0,
95
+ ref: wordWrap.codeBlockRef,
96
+ className: (0, clsx_1.default)(
79
97
  className,
80
98
  "openapi-explorer__code-block",
81
99
  "thin-scrollbar"
82
- )}
83
- >
84
- <code
85
- className={clsx(
100
+ ),
101
+ },
102
+ react_1.default.createElement(
103
+ "code",
104
+ {
105
+ className: (0, clsx_1.default)(
86
106
  "openapi-explorer__code-block-lines",
87
107
  showLineNumbers &&
88
108
  "openapi-explorer__code-block-lines-numbering"
89
- )}
90
- >
91
- {tokens.map((line, i) => (
92
- <Line
93
- key={i}
94
- line={line}
95
- getLineProps={getLineProps}
96
- getTokenProps={getTokenProps}
97
- classNames={lineClassNames[i]}
98
- showLineNumbers={showLineNumbers}
99
- />
100
- ))}
101
- </code>
102
- </pre>
103
- )}
104
- </Highlight>
105
- <div className="openapi-explorer__code-block-btn-group">
106
- {(wordWrap.isEnabled || wordWrap.isCodeScrollable) && (
107
- <WordWrapButton
108
- className="openapi-explorer__code-block-code-btn"
109
- onClick={() => wordWrap.toggle()}
110
- isEnabled={wordWrap.isEnabled}
111
- />
112
- )}
113
- <CopyButton
114
- className="openapi-explorer__code-block-code-btn"
115
- code={code}
116
- />
117
- <ExpandButton
118
- className={clsx(
119
- "openapi-explorer__code-block-code-btn",
120
- "openapi-explorer__expand-btn"
121
- )}
122
- code={code}
123
- language={language}
124
- showLineNumbers={showLineNumbers}
125
- blockClassName={blockClassName}
126
- title={title}
127
- lineClassNames={lineClassNames}
128
- wordWrap={wordWrap}
129
- />
130
- </div>
131
- </div>
132
- </Container>
109
+ ),
110
+ },
111
+ tokens.map((line, i) =>
112
+ react_1.default.createElement(Line_1.default, {
113
+ key: i,
114
+ line: line,
115
+ getLineProps: getLineProps,
116
+ getTokenProps: getTokenProps,
117
+ classNames: lineClassNames[i],
118
+ showLineNumbers: showLineNumbers,
119
+ })
120
+ )
121
+ )
122
+ )
123
+ ),
124
+ react_1.default.createElement(
125
+ "div",
126
+ { className: "openapi-explorer__code-block-btn-group" },
127
+ (wordWrap.isEnabled || wordWrap.isCodeScrollable) &&
128
+ react_1.default.createElement(WordWrapButton_1.default, {
129
+ className: "openapi-explorer__code-block-code-btn",
130
+ onClick: () => wordWrap.toggle(),
131
+ isEnabled: wordWrap.isEnabled,
132
+ }),
133
+ react_1.default.createElement(CopyButton_1.default, {
134
+ className: "openapi-explorer__code-block-code-btn",
135
+ code: code,
136
+ }),
137
+ react_1.default.createElement(ExpandButton_1.default, {
138
+ className: (0, clsx_1.default)(
139
+ "openapi-explorer__code-block-code-btn",
140
+ "openapi-explorer__expand-btn"
141
+ ),
142
+ code: code,
143
+ language: language ?? "text",
144
+ showLineNumbers: showLineNumbers,
145
+ blockClassName: blockClassName,
146
+ title: title,
147
+ lineClassNames: lineClassNames,
148
+ })
149
+ )
150
+ )
133
151
  );
134
152
  }
153
+ exports.default = CodeBlockString;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { CopyButtonProps } from "@docusaurus/theme-common/internal";
3
+ export default function CopyButton({ code, className, }: CopyButtonProps): React.JSX.Element;
@@ -1,74 +1,135 @@
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, { useCallback, useState, useRef, useEffect } from "react";
9
-
10
- import { translate } from "@docusaurus/Translate";
11
- import clsx from "clsx";
12
- // @ts-expect-error: TODO, we need to make theme-classic have type: module
13
- import copy from "copy-text-to-clipboard";
14
-
15
- export default function CopyButton({ code, className }) {
16
- const [isCopied, setIsCopied] = useState(false);
17
- const copyTimeout = useRef(undefined);
18
- const handleCopyCode = useCallback(() => {
19
- copy(code);
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 Translate_1 = require("@docusaurus/Translate");
60
+ const clsx_1 = __importDefault(require("clsx"));
61
+ const copy_text_to_clipboard_1 = __importDefault(
62
+ require("copy-text-to-clipboard")
63
+ );
64
+ function CopyButton({ code, className }) {
65
+ const [isCopied, setIsCopied] = (0, react_1.useState)(false);
66
+ const copyTimeout = (0, react_1.useRef)(undefined);
67
+ const handleCopyCode = (0, react_1.useCallback)(() => {
68
+ (0, copy_text_to_clipboard_1.default)(code);
20
69
  setIsCopied(true);
21
70
  copyTimeout.current = window.setTimeout(() => {
22
71
  setIsCopied(false);
23
72
  }, 1000);
24
73
  }, [code]);
25
- useEffect(() => () => window.clearTimeout(copyTimeout.current), []);
26
- return (
27
- <button
28
- type="button"
29
- aria-label={
30
- isCopied
31
- ? translate({
32
- id: "theme.CodeBlock.copied",
33
- message: "Copied",
34
- description: "The copied button label on code blocks",
35
- })
36
- : translate({
37
- id: "theme.CodeBlock.copyButtonAriaLabel",
38
- message: "Copy code to clipboard",
39
- description: "The ARIA label for copy code blocks button",
40
- })
41
- }
42
- title={translate({
74
+ (0, react_1.useEffect)(
75
+ () => () => window.clearTimeout(copyTimeout.current),
76
+ []
77
+ );
78
+ return react_1.default.createElement(
79
+ "button",
80
+ {
81
+ type: "button",
82
+ "aria-label": isCopied
83
+ ? (0, Translate_1.translate)({
84
+ id: "theme.CodeBlock.copied",
85
+ message: "Copied",
86
+ description: "The copied button label on code blocks",
87
+ })
88
+ : (0, Translate_1.translate)({
89
+ id: "theme.CodeBlock.copyButtonAriaLabel",
90
+ message: "Copy code to clipboard",
91
+ description: "The ARIA label for copy code blocks button",
92
+ }),
93
+ title: (0, Translate_1.translate)({
43
94
  id: "theme.CodeBlock.copy",
44
95
  message: "Copy",
45
96
  description: "The copy button label on code blocks",
46
- })}
47
- className={clsx(
97
+ }),
98
+ className: (0, clsx_1.default)(
48
99
  "clean-btn",
49
100
  className,
50
101
  "openapi-explorer__code-block-copy-btn",
51
102
  isCopied && "openapi-explorer__code-block-copy-btn--copied"
52
- )}
53
- onClick={handleCopyCode}
54
- >
55
- <span
56
- className="openapi-explorer__code-block-copy-btn-icons"
57
- aria-hidden="true"
58
- >
59
- <svg
60
- className="openapi-explorer__code-block-copy-btn-icon"
61
- viewBox="0 0 24 24"
62
- >
63
- <path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" />
64
- </svg>
65
- <svg
66
- className="openapi-explorer__code-block-copy-btn-icon--success"
67
- viewBox="0 0 24 24"
68
- >
69
- <path d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" />
70
- </svg>
71
- </span>
72
- </button>
103
+ ),
104
+ onClick: handleCopyCode,
105
+ },
106
+ react_1.default.createElement(
107
+ "span",
108
+ {
109
+ className: "openapi-explorer__code-block-copy-btn-icons",
110
+ "aria-hidden": "true",
111
+ },
112
+ react_1.default.createElement(
113
+ "svg",
114
+ {
115
+ className: "openapi-explorer__code-block-copy-btn-icon",
116
+ viewBox: "0 0 24 24",
117
+ },
118
+ react_1.default.createElement("path", {
119
+ d: "M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z",
120
+ })
121
+ ),
122
+ react_1.default.createElement(
123
+ "svg",
124
+ {
125
+ className: "openapi-explorer__code-block-copy-btn-icon--success",
126
+ viewBox: "0 0 24 24",
127
+ },
128
+ react_1.default.createElement("path", {
129
+ d: "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z",
130
+ })
131
+ )
132
+ )
73
133
  );
74
134
  }
135
+ exports.default = CopyButton;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ export interface Props {
3
+ readonly className: string;
4
+ readonly handler: () => void;
5
+ }
6
+ export default function ExitButton({ className, handler, }: Props): React.JSX.Element;