docusaurus-theme-openapi-docs 3.0.0-beta.1 → 3.0.0-beta.10

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 (142) hide show
  1. package/lib/markdown/utils.d.ts +3 -2
  2. package/lib/markdown/utils.js +1 -1
  3. package/lib/markdown/utils.test.d.ts +1 -0
  4. package/lib/markdown/utils.test.js +43 -0
  5. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.d.ts +13 -0
  6. package/lib/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/index.js +199 -124
  7. package/lib/theme/ApiExplorer/Accept/index.d.ts +2 -2
  8. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.d.ts +4 -0
  9. package/lib/theme/ApiExplorer/ApiCodeBlock/Container/index.js +25 -19
  10. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.d.ts +4 -0
  11. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/Element.js +27 -16
  12. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.d.ts +4 -0
  13. package/lib/theme/ApiExplorer/ApiCodeBlock/Content/String.js +115 -96
  14. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.d.ts +3 -0
  15. package/lib/theme/ApiExplorer/ApiCodeBlock/CopyButton/index.js +115 -54
  16. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.d.ts +6 -0
  17. package/lib/theme/ApiExplorer/ApiCodeBlock/ExitButton/index.js +41 -30
  18. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.d.ts +14 -0
  19. package/lib/theme/ApiExplorer/ApiCodeBlock/ExpandButton/index.js +200 -120
  20. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.d.ts +3 -0
  21. package/lib/theme/ApiExplorer/ApiCodeBlock/Line/index.js +36 -24
  22. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.d.ts +7 -0
  23. package/lib/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/index.js +35 -28
  24. package/lib/theme/ApiExplorer/ApiCodeBlock/index.d.ts +3 -0
  25. package/lib/theme/ApiExplorer/ApiCodeBlock/index.js +72 -14
  26. package/lib/theme/ApiExplorer/Authorization/index.d.ts +2 -2
  27. package/lib/theme/ApiExplorer/Authorization/slice.d.ts +1 -1
  28. package/lib/theme/ApiExplorer/Body/index.d.ts +2 -2
  29. package/lib/theme/ApiExplorer/Body/index.js +8 -1
  30. package/lib/theme/ApiExplorer/Body/slice.d.ts +3 -3
  31. package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.d.ts +21 -0
  32. package/lib/theme/ApiExplorer/CodeSnippets/code-snippets-types.js +8 -0
  33. package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +4 -14
  34. package/lib/theme/ApiExplorer/CodeSnippets/index.js +86 -8
  35. package/lib/theme/ApiExplorer/CodeSnippets/languages.d.ts +3 -0
  36. package/lib/theme/ApiExplorer/CodeSnippets/languages.js +48 -0
  37. package/lib/theme/ApiExplorer/CodeSnippets/languages.json +0 -96
  38. package/lib/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +18 -2
  39. package/lib/theme/ApiExplorer/CodeTabs/index.d.ts +15 -0
  40. package/lib/theme/ApiExplorer/CodeTabs/index.js +131 -76
  41. package/lib/theme/ApiExplorer/ContentType/index.d.ts +2 -2
  42. package/lib/theme/ApiExplorer/Export/index.d.ts +2 -2
  43. package/lib/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
  44. package/lib/theme/ApiExplorer/FloatingButton/index.d.ts +1 -1
  45. package/lib/theme/ApiExplorer/FormFileUpload/index.d.ts +2 -2
  46. package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -1
  47. package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +1 -1
  48. package/lib/theme/ApiExplorer/FormSelect/index.d.ts +1 -1
  49. package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +1 -1
  50. package/lib/theme/ApiExplorer/MethodEndpoint/index.d.ts +2 -2
  51. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +2 -2
  52. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +2 -2
  53. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +2 -2
  54. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -4
  55. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +2 -2
  56. package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +2 -2
  57. package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
  58. package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +2 -2
  59. package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
  60. package/lib/theme/ApiExplorer/Request/_Request.scss +4 -2
  61. package/lib/theme/ApiExplorer/Request/index.d.ts +2 -2
  62. package/lib/theme/ApiExplorer/Request/makeRequest.js +50 -1
  63. package/lib/theme/ApiExplorer/Response/_Response.scss +4 -2
  64. package/lib/theme/ApiExplorer/Response/index.d.ts +2 -2
  65. package/lib/theme/ApiExplorer/Response/index.js +19 -19
  66. package/lib/theme/ApiExplorer/SecuritySchemes/index.d.ts +2 -2
  67. package/lib/theme/ApiExplorer/Server/index.d.ts +2 -2
  68. package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +1 -1
  69. package/lib/theme/ApiExplorer/index.d.ts +2 -2
  70. package/lib/theme/ApiExplorer/index.js +1 -1
  71. package/lib/theme/ApiExplorer/storage-utils.d.ts +1 -1
  72. package/lib/theme/ApiItem/index.js +28 -3
  73. package/lib/theme/ApiItem/store.d.ts +6 -6
  74. package/lib/theme/ApiLogo/index.d.ts +2 -2
  75. package/lib/theme/ApiTabs/_ApiTabs.scss +3 -1
  76. package/lib/theme/ApiTabs/index.d.ts +7 -0
  77. package/lib/theme/ApiTabs/index.js +167 -103
  78. package/lib/theme/DiscriminatorTabs/index.d.ts +3 -0
  79. package/lib/theme/DiscriminatorTabs/index.js +152 -98
  80. package/lib/theme/Markdown/index.js +37 -0
  81. package/lib/theme/MimeTabs/index.d.ts +6 -0
  82. package/lib/theme/MimeTabs/index.js +169 -118
  83. package/lib/theme/OperationTabs/_OperationTabs.scss +71 -0
  84. package/lib/theme/OperationTabs/index.d.ts +3 -0
  85. package/lib/theme/OperationTabs/index.js +234 -0
  86. package/lib/theme/ParamsItem/index.d.ts +23 -0
  87. package/lib/theme/ParamsItem/index.js +170 -111
  88. package/lib/theme/ResponseSamples/index.d.ts +8 -0
  89. package/lib/theme/ResponseSamples/index.js +18 -13
  90. package/lib/theme/SchemaItem/index.d.ts +12 -0
  91. package/lib/theme/SchemaItem/index.js +121 -89
  92. package/lib/theme/SchemaTabs/_SchemaTabs.scss +0 -4
  93. package/lib/theme/SchemaTabs/index.d.ts +3 -0
  94. package/lib/theme/SchemaTabs/index.js +148 -95
  95. package/lib/theme/styles.scss +5 -0
  96. package/lib/types.d.ts +4 -4
  97. package/package.json +8 -7
  98. package/src/markdown/utils.test.ts +49 -0
  99. package/src/markdown/utils.ts +5 -3
  100. package/src/theme/ApiDemoPanel/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +21 -8
  101. package/src/theme/ApiExplorer/ApiCodeBlock/Container/{index.js → index.tsx} +6 -3
  102. package/src/theme/ApiExplorer/ApiCodeBlock/Content/{Element.js → Element.tsx} +5 -1
  103. package/src/theme/ApiExplorer/ApiCodeBlock/Content/{String.js → String.tsx} +4 -4
  104. package/src/theme/ApiExplorer/ApiCodeBlock/CopyButton/{index.js → index.tsx} +8 -3
  105. package/src/theme/ApiExplorer/ApiCodeBlock/ExitButton/{index.js → index.tsx} +9 -1
  106. package/src/theme/ApiExplorer/ApiCodeBlock/ExpandButton/{index.js → index.tsx} +12 -2
  107. package/src/theme/ApiExplorer/ApiCodeBlock/Line/{index.js → index.tsx} +2 -1
  108. package/src/theme/ApiExplorer/ApiCodeBlock/WordWrapButton/{index.js → index.tsx} +11 -1
  109. package/src/theme/ApiExplorer/ApiCodeBlock/{index.js → index.tsx} +10 -5
  110. package/src/theme/ApiExplorer/Body/index.tsx +3 -1
  111. package/src/theme/ApiExplorer/CodeSnippets/code-snippets-types.ts +55 -0
  112. package/src/theme/ApiExplorer/CodeSnippets/index.tsx +94 -21
  113. package/src/theme/ApiExplorer/CodeSnippets/languages.json +0 -96
  114. package/src/theme/ApiExplorer/CodeSnippets/languages.ts +53 -0
  115. package/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss +18 -2
  116. package/src/theme/ApiExplorer/CodeTabs/{index.js → index.tsx} +64 -25
  117. package/src/theme/ApiExplorer/FloatingButton/_FloatingButton.scss +3 -1
  118. package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +4 -4
  119. package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +2 -1
  120. package/src/theme/ApiExplorer/Request/_Request.scss +4 -2
  121. package/src/theme/ApiExplorer/Request/makeRequest.ts +59 -4
  122. package/src/theme/ApiExplorer/Response/_Response.scss +4 -2
  123. package/src/theme/ApiExplorer/Response/index.tsx +2 -2
  124. package/src/theme/ApiExplorer/index.tsx +1 -1
  125. package/src/theme/ApiItem/index.tsx +22 -3
  126. package/src/theme/ApiLogo/index.tsx +1 -1
  127. package/src/theme/ApiTabs/_ApiTabs.scss +3 -1
  128. package/src/theme/ApiTabs/{index.js → index.tsx} +75 -31
  129. package/src/theme/DiscriminatorTabs/{index.js → index.tsx} +63 -28
  130. package/src/theme/Markdown/index.js +37 -0
  131. package/src/theme/MimeTabs/{index.js → index.tsx} +64 -30
  132. package/src/theme/OperationTabs/_OperationTabs.scss +71 -0
  133. package/src/theme/OperationTabs/index.tsx +218 -0
  134. package/src/theme/ParamsItem/{index.js → index.tsx} +48 -17
  135. package/src/theme/ResponseSamples/{index.js → index.tsx} +10 -1
  136. package/src/theme/SchemaItem/{index.js → index.tsx} +24 -18
  137. package/src/theme/SchemaTabs/_SchemaTabs.scss +0 -4
  138. package/src/theme/SchemaTabs/{index.js → index.tsx} +62 -29
  139. package/src/theme/styles.scss +5 -0
  140. package/src/theme-classic.d.ts +69 -2
  141. package/src/theme-openapi.d.ts +6 -0
  142. package/tsconfig.json +4 -1
@@ -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 } 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
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
+ {
68
84
  // {...defaultProps}
69
- theme={prismTheme}
70
- code={code}
71
- language={language ?? "text"}
72
- >
73
- {({ className, tokens, getLineProps, getTokenProps }) => (
74
- <pre
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;
@@ -1,47 +1,58 @@
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 { translate } from "@docusaurus/Translate";
11
- import clsx from "clsx";
12
-
13
- export default function ExitButton({ className, handler }) {
14
- return (
15
- <button
16
- type="button"
17
- aria-label={translate({
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 Translate_1 = require("@docusaurus/Translate");
16
+ const clsx_1 = __importDefault(require("clsx"));
17
+ function ExitButton({ className, handler }) {
18
+ return react_1.default.createElement(
19
+ "button",
20
+ {
21
+ type: "button",
22
+ "aria-label": (0, Translate_1.translate)({
18
23
  id: "theme.CodeBlock.exitButtonAriaLabel",
19
24
  message: "Exit expanded view",
20
25
  description: "The ARIA label for exit expanded view button",
21
- })}
22
- title={translate({
26
+ }),
27
+ title: (0, Translate_1.translate)({
23
28
  id: "theme.CodeBlock.copy",
24
29
  message: "Copy",
25
30
  description: "The exit button label on code blocks",
26
- })}
27
- className={clsx(
31
+ }),
32
+ className: (0, clsx_1.default)(
28
33
  "clean-btn",
29
34
  "openapi-explorer__code-block-exit-btn",
30
35
  className
31
- )}
32
- onClick={handler}
33
- >
34
- <span
35
- className="openapi-explorer__code-block-exit-btn-icons"
36
- aria-hidden="true"
37
- >
38
- <svg
39
- className="openapi-explorer__code-block-exit-btn-icon"
40
- viewBox="0 0 384 512"
41
- >
42
- <path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z" />
43
- </svg>
44
- </span>
45
- </button>
36
+ ),
37
+ onClick: handler,
38
+ },
39
+ react_1.default.createElement(
40
+ "span",
41
+ {
42
+ className: "openapi-explorer__code-block-exit-btn-icons",
43
+ "aria-hidden": "true",
44
+ },
45
+ react_1.default.createElement(
46
+ "svg",
47
+ {
48
+ className: "openapi-explorer__code-block-exit-btn-icon",
49
+ viewBox: "0 0 384 512",
50
+ },
51
+ react_1.default.createElement("path", {
52
+ d: "M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z",
53
+ })
54
+ )
55
+ )
46
56
  );
47
57
  }
58
+ exports.default = ExitButton;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { Language } from "prism-react-renderer";
3
+ export interface Props {
4
+ readonly code: string;
5
+ readonly className: string;
6
+ readonly language: Language;
7
+ readonly showLineNumbers: boolean;
8
+ readonly blockClassName: string;
9
+ readonly title: string | undefined;
10
+ readonly lineClassNames: {
11
+ [lineIndex: number]: string[];
12
+ };
13
+ }
14
+ export default function ExpandButton({ code, className, language, showLineNumbers, blockClassName, title, lineClassNames, }: Props): React.JSX.Element;