docusaurus-theme-openapi-docs 0.0.0-348 → 0.0.0-351
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/index.js +48 -0
- package/lib/markdown/createDescription.js +20 -0
- package/lib/markdown/schema.js +121 -0
- package/lib/markdown/utils.js +45 -0
- package/lib/postman-code-generators.d.ts +9 -0
- package/lib/react-magic-dropzone.d.ts +9 -0
- package/lib/theme/ApiDemoPanel/Accept/index.js +41 -0
- package/lib/theme/ApiDemoPanel/Accept/slice.js +32 -0
- package/lib/theme/ApiDemoPanel/Authorization/auth-types.js +32 -0
- package/lib/theme/ApiDemoPanel/Authorization/slice.js +137 -0
- package/lib/theme/ApiDemoPanel/Body/index.js +185 -0
- package/lib/theme/ApiDemoPanel/Body/slice.js +105 -0
- package/lib/theme/ApiDemoPanel/ContentType/index.js +41 -0
- package/lib/theme/ApiDemoPanel/ContentType/slice.js +32 -0
- package/lib/theme/ApiDemoPanel/Curl/index.js +235 -0
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib/theme/ApiDemoPanel/FloatingButton/index.js +32 -0
- package/lib/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/lib/theme/ApiDemoPanel/FormFileUpload/index.js +96 -0
- package/lib/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/lib/theme/ApiDemoPanel/FormItem/index.js +35 -0
- package/lib/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/lib/theme/ApiDemoPanel/FormMultiSelect/index.js +52 -0
- package/lib/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/lib/theme/ApiDemoPanel/FormSelect/index.js +39 -0
- package/lib/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/lib/theme/ApiDemoPanel/FormTextInput/index.js +30 -0
- package/lib/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/lib/theme/ApiDemoPanel/MethodEndpoint/index.js +60 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/index.js +248 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/slice.js +35 -0
- package/lib/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/lib/theme/ApiDemoPanel/Response/index.js +75 -0
- package/lib/theme/ApiDemoPanel/Response/slice.js +37 -0
- package/lib/theme/ApiDemoPanel/SecuritySchemes/index.js +69 -0
- package/lib/theme/ApiDemoPanel/Server/index.js +109 -0
- package/lib/theme/ApiDemoPanel/Server/slice.js +41 -0
- package/lib/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/lib/theme/ApiDemoPanel/VSCode/index.js +252 -0
- package/lib/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/lib/theme/ApiDemoPanel/buildPostmanRequest.js +332 -0
- package/lib/theme/ApiDemoPanel/hooks.js +20 -0
- package/lib/theme/ApiDemoPanel/index.js +132 -0
- package/lib/theme/ApiDemoPanel/persistanceMiddleware.js +44 -0
- package/lib/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/lib/theme/ApiDemoPanel/storage-utils.js +47 -0
- package/lib/theme/ApiDemoPanel/store.js +48 -0
- package/lib/theme/ApiDemoPanel/styles.module.css +44 -0
- package/lib/theme/ApiItem/index.js +160 -0
- package/lib/theme/ApiItem/styles.module.css +113 -0
- package/lib/theme/ApiTabs/index.js +258 -0
- package/lib/theme/ApiTabs/styles.module.css +118 -0
- package/lib/theme/ParamsItem/index.js +68 -0
- package/lib/theme/ParamsItem/styles.module.css +24 -0
- package/lib/theme/SchemaItem/index.js +58 -0
- package/lib/theme/SchemaItem/styles.module.css +24 -0
- package/lib/theme-classic.d.ts +8 -0
- package/lib/theme-openapi.d.ts +48 -0
- package/lib/theme-translations.d.ts +9 -0
- package/lib/types.js +1 -0
- package/lib-next/index.js +38 -0
- package/lib-next/markdown/createDescription.js +13 -0
- package/lib-next/markdown/schema.js +115 -0
- package/lib-next/markdown/utils.js +31 -0
- package/lib-next/postman-code-generators.d.ts +9 -0
- package/lib-next/react-magic-dropzone.d.ts +9 -0
- package/lib-next/theme/ApiDemoPanel/Accept/index.js +33 -0
- package/lib-next/theme/ApiDemoPanel/Accept/slice.js +19 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/auth-types.js +22 -0
- package/lib-next/theme/ApiDemoPanel/Authorization/slice.js +101 -0
- package/lib-next/theme/ApiDemoPanel/Body/index.js +210 -0
- package/lib-next/theme/ApiDemoPanel/Body/slice.js +89 -0
- package/lib-next/theme/ApiDemoPanel/ContentType/index.js +33 -0
- package/lib-next/theme/ApiDemoPanel/ContentType/slice.js +19 -0
- package/lib-next/theme/ApiDemoPanel/Curl/index.js +262 -0
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib-next/theme/ApiDemoPanel/FloatingButton/index.js +19 -0
- package/lib-next/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/index.js +112 -0
- package/lib-next/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/lib-next/theme/ApiDemoPanel/FormItem/index.js +29 -0
- package/lib-next/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/index.js +49 -0
- package/lib-next/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/lib-next/theme/ApiDemoPanel/FormSelect/index.js +28 -0
- package/lib-next/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/lib-next/theme/ApiDemoPanel/FormTextInput/index.js +23 -0
- package/lib-next/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/lib-next/theme/ApiDemoPanel/MethodEndpoint/index.js +53 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/index.js +284 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/slice.js +22 -0
- package/lib-next/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/lib-next/theme/ApiDemoPanel/Response/index.js +65 -0
- package/lib-next/theme/ApiDemoPanel/Response/slice.js +22 -0
- package/lib-next/theme/ApiDemoPanel/SecuritySchemes/index.js +71 -0
- package/lib-next/theme/ApiDemoPanel/Server/index.js +114 -0
- package/lib-next/theme/ApiDemoPanel/Server/slice.js +25 -0
- package/lib-next/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/lib-next/theme/ApiDemoPanel/VSCode/index.js +265 -0
- package/lib-next/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/lib-next/theme/ApiDemoPanel/buildPostmanRequest.js +313 -0
- package/lib-next/theme/ApiDemoPanel/hooks.js +9 -0
- package/lib-next/theme/ApiDemoPanel/index.js +108 -0
- package/lib-next/theme/ApiDemoPanel/persistanceMiddleware.js +38 -0
- package/lib-next/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/lib-next/theme/ApiDemoPanel/storage-utils.js +35 -0
- package/lib-next/theme/ApiDemoPanel/store.js +30 -0
- package/lib-next/theme/ApiDemoPanel/styles.module.css +44 -0
- package/lib-next/theme/ApiItem/index.js +171 -0
- package/lib-next/theme/ApiItem/styles.module.css +113 -0
- package/lib-next/theme/ApiTabs/index.js +258 -0
- package/lib-next/theme/ApiTabs/styles.module.css +118 -0
- package/lib-next/theme/ParamsItem/index.js +68 -0
- package/lib-next/theme/ParamsItem/styles.module.css +24 -0
- package/lib-next/theme/SchemaItem/index.js +58 -0
- package/lib-next/theme/SchemaItem/styles.module.css +24 -0
- package/lib-next/theme-classic.d.ts +8 -0
- package/lib-next/theme-openapi.d.ts +48 -0
- package/lib-next/theme-translations.d.ts +9 -0
- package/lib-next/types.js +1 -0
- package/package.json +3 -3
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +26 -3
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +5 -1
- package/src/theme/ApiDemoPanel/Authorization/index.tsx +0 -211
- package/src/theme/ApiDemoPanel/Execute/index.tsx +0 -87
- package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +0 -182
|
@@ -0,0 +1,262 @@
|
|
|
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
|
+
import React, { useRef, useState, useEffect } from "react";
|
|
8
|
+
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
9
|
+
import codegen from "@paloaltonetworks/postman-code-generators";
|
|
10
|
+
import clsx from "clsx";
|
|
11
|
+
import Highlight, { defaultProps } from "prism-react-renderer";
|
|
12
|
+
import { useTypedSelector } from "../hooks";
|
|
13
|
+
import buildPostmanRequest from "./../buildPostmanRequest";
|
|
14
|
+
import FloatingButton from "./../FloatingButton";
|
|
15
|
+
import styles from "./styles.module.css";
|
|
16
|
+
const languageSet = [
|
|
17
|
+
{
|
|
18
|
+
tabName: "cURL",
|
|
19
|
+
highlight: "bash",
|
|
20
|
+
language: "curl",
|
|
21
|
+
variant: "curl",
|
|
22
|
+
options: {
|
|
23
|
+
longFormat: false,
|
|
24
|
+
followRedirect: true,
|
|
25
|
+
trimRequestBody: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tabName: "Node",
|
|
30
|
+
highlight: "javascript",
|
|
31
|
+
language: "nodejs",
|
|
32
|
+
variant: "axios",
|
|
33
|
+
options: {
|
|
34
|
+
ES6_enabled: true,
|
|
35
|
+
followRedirect: true,
|
|
36
|
+
trimRequestBody: true,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
tabName: "Go",
|
|
41
|
+
highlight: "go",
|
|
42
|
+
language: "go",
|
|
43
|
+
variant: "native",
|
|
44
|
+
options: {
|
|
45
|
+
followRedirect: true,
|
|
46
|
+
trimRequestBody: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
tabName: "Python",
|
|
51
|
+
highlight: "python",
|
|
52
|
+
language: "python",
|
|
53
|
+
variant: "requests",
|
|
54
|
+
options: {
|
|
55
|
+
followRedirect: true,
|
|
56
|
+
trimRequestBody: true,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
const languageTheme = {
|
|
61
|
+
plain: {
|
|
62
|
+
color: "var(--ifm-code-color)",
|
|
63
|
+
},
|
|
64
|
+
styles: [
|
|
65
|
+
{
|
|
66
|
+
types: ["inserted", "attr-name"],
|
|
67
|
+
style: {
|
|
68
|
+
color: "var(--openapi-code-green)",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
types: ["string", "url"],
|
|
73
|
+
style: {
|
|
74
|
+
color: "var(--openapi-code-green)",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
types: ["builtin", "char", "constant", "function"],
|
|
79
|
+
style: {
|
|
80
|
+
color: "var(--openapi-code-blue)",
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
types: ["punctuation", "operator"],
|
|
85
|
+
style: {
|
|
86
|
+
color: "var(--openapi-code-dim)",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
types: ["class-name"],
|
|
91
|
+
style: {
|
|
92
|
+
color: "var(--openapi-code-orange)",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
types: ["tag", "arrow", "keyword"],
|
|
97
|
+
style: {
|
|
98
|
+
color: "var(--openapi-code-purple)",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
types: ["boolean"],
|
|
103
|
+
style: {
|
|
104
|
+
color: "var(--openapi-code-red)",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
function Curl({ postman, codeSamples }) {
|
|
111
|
+
// TODO: match theme for vscode.
|
|
112
|
+
const { siteConfig } = useDocusaurusContext();
|
|
113
|
+
const [copyText, setCopyText] = useState("Copy");
|
|
114
|
+
const contentType = useTypedSelector((state) => state.contentType.value);
|
|
115
|
+
const accept = useTypedSelector((state) => state.accept.value);
|
|
116
|
+
const server = useTypedSelector((state) => state.server.value);
|
|
117
|
+
const body = useTypedSelector((state) => state.body);
|
|
118
|
+
const pathParams = useTypedSelector((state) => state.params.path);
|
|
119
|
+
const queryParams = useTypedSelector((state) => state.params.query);
|
|
120
|
+
const cookieParams = useTypedSelector((state) => state.params.cookie);
|
|
121
|
+
const headerParams = useTypedSelector((state) => state.params.header);
|
|
122
|
+
const auth = useTypedSelector((state) => state.auth); // TODO
|
|
123
|
+
|
|
124
|
+
const langs = [
|
|
125
|
+
...(siteConfig?.themeConfig?.languageTabs ?? languageSet),
|
|
126
|
+
...codeSamples,
|
|
127
|
+
];
|
|
128
|
+
const [language, setLanguage] = useState(langs[0]);
|
|
129
|
+
const [codeText, setCodeText] = useState("");
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
if (language && !!language.options) {
|
|
132
|
+
const postmanRequest = buildPostmanRequest(postman, {
|
|
133
|
+
queryParams,
|
|
134
|
+
pathParams,
|
|
135
|
+
cookieParams,
|
|
136
|
+
contentType,
|
|
137
|
+
accept,
|
|
138
|
+
headerParams,
|
|
139
|
+
body,
|
|
140
|
+
server,
|
|
141
|
+
auth,
|
|
142
|
+
});
|
|
143
|
+
codegen.convert(
|
|
144
|
+
language.language,
|
|
145
|
+
language.variant,
|
|
146
|
+
postmanRequest,
|
|
147
|
+
language.options,
|
|
148
|
+
(error, snippet) => {
|
|
149
|
+
if (error) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
setCodeText(snippet);
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
} else if (language && !!language.source) {
|
|
157
|
+
setCodeText(language.source);
|
|
158
|
+
} else {
|
|
159
|
+
setCodeText("");
|
|
160
|
+
}
|
|
161
|
+
}, [
|
|
162
|
+
accept,
|
|
163
|
+
body,
|
|
164
|
+
contentType,
|
|
165
|
+
cookieParams,
|
|
166
|
+
headerParams,
|
|
167
|
+
language,
|
|
168
|
+
pathParams,
|
|
169
|
+
postman,
|
|
170
|
+
queryParams,
|
|
171
|
+
server,
|
|
172
|
+
auth,
|
|
173
|
+
]);
|
|
174
|
+
const ref = useRef(null);
|
|
175
|
+
|
|
176
|
+
const handleCurlCopy = () => {
|
|
177
|
+
setCopyText("Copied");
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
setCopyText("Copy");
|
|
180
|
+
}, 2000);
|
|
181
|
+
|
|
182
|
+
if (ref.current?.innerText) {
|
|
183
|
+
navigator.clipboard.writeText(ref.current.innerText);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
if (language === undefined) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<>
|
|
193
|
+
<div className={clsx(styles.buttonGroup, "api-code-tab-group")}>
|
|
194
|
+
{langs.map((lang) => {
|
|
195
|
+
return (
|
|
196
|
+
<button
|
|
197
|
+
key={lang.tabName || lang.label}
|
|
198
|
+
className={clsx(
|
|
199
|
+
language === lang ? styles.selected : undefined,
|
|
200
|
+
language === lang ? "api-code-tab--active" : undefined,
|
|
201
|
+
"api-code-tab"
|
|
202
|
+
)}
|
|
203
|
+
onClick={() => setLanguage(lang)}
|
|
204
|
+
>
|
|
205
|
+
{lang.tabName || lang.label}
|
|
206
|
+
</button>
|
|
207
|
+
);
|
|
208
|
+
})}
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<Highlight
|
|
212
|
+
{...defaultProps}
|
|
213
|
+
theme={languageTheme}
|
|
214
|
+
code={codeText}
|
|
215
|
+
language={language.highlight || language.lang}
|
|
216
|
+
>
|
|
217
|
+
{({ className, tokens, getLineProps, getTokenProps }) => (
|
|
218
|
+
<FloatingButton onClick={handleCurlCopy} label={copyText}>
|
|
219
|
+
<pre
|
|
220
|
+
className={className}
|
|
221
|
+
style={{
|
|
222
|
+
background: "var(--openapi-card-background-color)",
|
|
223
|
+
paddingRight: "60px",
|
|
224
|
+
borderRadius:
|
|
225
|
+
"2px 2px var(--openapi-card-border-radius) var(--openapi-card-border-radius)",
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
<code ref={ref}>
|
|
229
|
+
{tokens.map((line, i) => (
|
|
230
|
+
<span
|
|
231
|
+
{...getLineProps({
|
|
232
|
+
line,
|
|
233
|
+
key: i,
|
|
234
|
+
})}
|
|
235
|
+
>
|
|
236
|
+
{line.map((token, key) => {
|
|
237
|
+
if (token.types.includes("arrow")) {
|
|
238
|
+
token.types = ["arrow"];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<span
|
|
243
|
+
{...getTokenProps({
|
|
244
|
+
token,
|
|
245
|
+
key,
|
|
246
|
+
})}
|
|
247
|
+
/>
|
|
248
|
+
);
|
|
249
|
+
})}
|
|
250
|
+
{"\n"}
|
|
251
|
+
</span>
|
|
252
|
+
))}
|
|
253
|
+
</code>
|
|
254
|
+
</pre>
|
|
255
|
+
</FloatingButton>
|
|
256
|
+
)}
|
|
257
|
+
</Highlight>
|
|
258
|
+
</>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export default Curl;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
.buttonGroup {
|
|
2
|
+
background: var(--openapi-card-background-color);
|
|
3
|
+
color: var(--ifm-pre-color);
|
|
4
|
+
font-family: var(--ifm-font-family-monospace);
|
|
5
|
+
/* font-size: var(--ifm-code-font-size); */
|
|
6
|
+
/* line-height: var(--ifm-pre-line-height); */
|
|
7
|
+
/* margin-bottom: calc(var(--ifm-spacing-vertical) / 4); */
|
|
8
|
+
margin-bottom: 1px;
|
|
9
|
+
margin-top: 0;
|
|
10
|
+
border-radius: var(--openapi-card-border-radius)
|
|
11
|
+
var(--openapi-card-border-radius) 2px 2px;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: flex-end;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.buttonGroup button {
|
|
17
|
+
-webkit-appearance: none;
|
|
18
|
+
-moz-appearance: none;
|
|
19
|
+
appearance: none;
|
|
20
|
+
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
/* font-size: calc(0.875rem * var(--ifm-button-size-multiplier)); */
|
|
23
|
+
/* line-height: 1.5; */
|
|
24
|
+
/* font-weight: var(--ifm-button-font-weight); */
|
|
25
|
+
|
|
26
|
+
/* font-size: var(--ifm-code-font-size); */
|
|
27
|
+
font-size: 13.3333px;
|
|
28
|
+
line-height: var(--ifm-pre-line-height);
|
|
29
|
+
font-weight: var(--ifm-font-weight-semibold);
|
|
30
|
+
|
|
31
|
+
padding: calc(
|
|
32
|
+
var(--ifm-button-padding-vertical) * var(--ifm-button-size-multiplier)
|
|
33
|
+
)
|
|
34
|
+
calc(
|
|
35
|
+
var(--ifm-button-padding-horizontal) * var(--ifm-button-size-multiplier)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
text-align: center;
|
|
39
|
+
|
|
40
|
+
transition: color var(--ifm-button-transition-duration)
|
|
41
|
+
cubic-bezier(0.08, 0.52, 0.52, 1),
|
|
42
|
+
background var(--ifm-button-transition-duration)
|
|
43
|
+
cubic-bezier(0.08, 0.52, 0.52, 1),
|
|
44
|
+
border-color var(--ifm-button-transition-duration)
|
|
45
|
+
cubic-bezier(0.08, 0.52, 0.52, 1);
|
|
46
|
+
-webkit-user-select: none;
|
|
47
|
+
user-select: none;
|
|
48
|
+
white-space: nowrap;
|
|
49
|
+
|
|
50
|
+
background: transparent;
|
|
51
|
+
|
|
52
|
+
color: var(--ifm-menu-color);
|
|
53
|
+
border: 0px solid transparent;
|
|
54
|
+
/* border-radius: var(--ifm-pre-border-radius); */
|
|
55
|
+
|
|
56
|
+
--margin: 0.25rem;
|
|
57
|
+
|
|
58
|
+
border-radius: calc(var(--margin));
|
|
59
|
+
/* border-radius: 0.25rem; */
|
|
60
|
+
|
|
61
|
+
display: block;
|
|
62
|
+
width: 100%;
|
|
63
|
+
|
|
64
|
+
/* margin: 2px; */
|
|
65
|
+
margin: var(--margin);
|
|
66
|
+
margin-right: 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.buttonGroup button:last-child {
|
|
70
|
+
margin-right: 0.25rem;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.buttonGroup button:hover {
|
|
74
|
+
background: var(--ifm-menu-color-background-active);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.buttonGroup button:focus {
|
|
78
|
+
outline: 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.buttonGroup button.selected {
|
|
82
|
+
background: var(--ifm-menu-color-background-active);
|
|
83
|
+
color: var(--ifm-menu-color-active);
|
|
84
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import React from "react";
|
|
8
|
+
import styles from "./styles.module.css";
|
|
9
|
+
|
|
10
|
+
function FloatingButton({ label, onClick, children }) {
|
|
11
|
+
return (
|
|
12
|
+
<div className={styles.floatingButton}>
|
|
13
|
+
{label && <button onClick={onClick}>{label}</button>}
|
|
14
|
+
{children}
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default FloatingButton;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
.floatingButton {
|
|
2
|
+
position: relative;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.floatingButton button {
|
|
6
|
+
position: relative;
|
|
7
|
+
background: rgba(25, 26, 27, 0.9);
|
|
8
|
+
border: none;
|
|
9
|
+
border-radius: var(--ifm-global-radius);
|
|
10
|
+
color: var(--ifm-color-white);
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
outline: none;
|
|
13
|
+
padding: 0.4rem 0.5rem;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
visibility: hidden;
|
|
16
|
+
transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out,
|
|
17
|
+
bottom 0.2s ease-in-out;
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: calc(var(--ifm-pre-padding) / 2);
|
|
20
|
+
right: calc(var(--ifm-pre-padding) / 2);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.floatingButton:hover button {
|
|
24
|
+
visibility: visible;
|
|
25
|
+
opacity: 1;
|
|
26
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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
|
+
import React, { useState } from "react";
|
|
8
|
+
import MagicDropzone from "react-magic-dropzone";
|
|
9
|
+
import FloatingButton from "../FloatingButton";
|
|
10
|
+
import styles from "./styles.module.css";
|
|
11
|
+
|
|
12
|
+
function RenderPreview({ file }) {
|
|
13
|
+
switch (file.type) {
|
|
14
|
+
case "image/png":
|
|
15
|
+
case "image/jpeg":
|
|
16
|
+
case "image/jpg":
|
|
17
|
+
case "image/svg+xml":
|
|
18
|
+
return (
|
|
19
|
+
<img
|
|
20
|
+
style={{
|
|
21
|
+
borderRadius: "4px",
|
|
22
|
+
}}
|
|
23
|
+
src={file.preview}
|
|
24
|
+
alt=""
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
default:
|
|
29
|
+
return (
|
|
30
|
+
<div
|
|
31
|
+
style={{
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center",
|
|
34
|
+
minWidth: 0,
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
<svg
|
|
38
|
+
viewBox="0 0 100 120"
|
|
39
|
+
style={{
|
|
40
|
+
width: "50px",
|
|
41
|
+
height: "60px",
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
<path
|
|
45
|
+
fillRule="evenodd"
|
|
46
|
+
fill="#b3beca"
|
|
47
|
+
d="M100.000,39.790 L100.000,105.000 C100.000,113.284 93.284,120.000 85.000,120.000 L15.000,120.000 C6.716,120.000 -0.000,113.284 -0.000,105.000 L-0.000,15.000 C-0.000,6.716 6.716,-0.000 15.000,-0.000 L60.210,-0.000 L100.000,39.790 Z"
|
|
48
|
+
/>
|
|
49
|
+
<path
|
|
50
|
+
fillRule="evenodd"
|
|
51
|
+
fill="#90a1b1"
|
|
52
|
+
transform="translate(60, 0)"
|
|
53
|
+
d="M0.210,-0.000 L40.000,39.790 L40.000,40.000 L15.000,40.000 C6.716,40.000 0.000,33.284 0.000,25.000 L0.000,-0.000 L0.210,-0.000 Z"
|
|
54
|
+
/>
|
|
55
|
+
</svg>
|
|
56
|
+
<div className={styles.filename}>{file.name}</div>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function FormFileUpload({ placeholder, onChange }) {
|
|
63
|
+
const [hover, setHover] = useState(false);
|
|
64
|
+
const [file, setFile] = useState();
|
|
65
|
+
|
|
66
|
+
function setAndNotifyFile(file) {
|
|
67
|
+
setFile(file);
|
|
68
|
+
onChange?.(file);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function handleDrop(accepted) {
|
|
72
|
+
const [file] = accepted;
|
|
73
|
+
setAndNotifyFile(file);
|
|
74
|
+
setHover(false);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<FloatingButton>
|
|
79
|
+
<MagicDropzone
|
|
80
|
+
className={hover ? styles.dropzoneHover : styles.dropzone}
|
|
81
|
+
onDrop={handleDrop}
|
|
82
|
+
onDragEnter={() => setHover(true)}
|
|
83
|
+
onDragLeave={() => setHover(false)}
|
|
84
|
+
multiple={false}
|
|
85
|
+
style={{
|
|
86
|
+
marginTop: "calc(var(--ifm-pre-padding) / 2)",
|
|
87
|
+
}}
|
|
88
|
+
>
|
|
89
|
+
{file ? (
|
|
90
|
+
<>
|
|
91
|
+
<button
|
|
92
|
+
style={{
|
|
93
|
+
marginTop: "calc(var(--ifm-pre-padding) / 2)",
|
|
94
|
+
}}
|
|
95
|
+
onClick={(e) => {
|
|
96
|
+
e.stopPropagation();
|
|
97
|
+
setAndNotifyFile(undefined);
|
|
98
|
+
}}
|
|
99
|
+
>
|
|
100
|
+
Clear
|
|
101
|
+
</button>
|
|
102
|
+
<RenderPreview file={file} />
|
|
103
|
+
</>
|
|
104
|
+
) : (
|
|
105
|
+
<div className={styles.dropzoneContent}>{placeholder}</div>
|
|
106
|
+
)}
|
|
107
|
+
</MagicDropzone>
|
|
108
|
+
</FloatingButton>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default FormFileUpload;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
.dropzone {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
border: 2px dashed var(--openapi-monaco-border-color);
|
|
7
|
+
/* border: 2px dashed var(--ifm-color-primary); */
|
|
8
|
+
background-color: var(--openapi-input-background);
|
|
9
|
+
|
|
10
|
+
width: 100%;
|
|
11
|
+
/* min-height: 120px; */
|
|
12
|
+
/* padding: 16px 11px; */
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
padding: var(--ifm-pre-padding);
|
|
15
|
+
font-size: var(--ifm-code-font-size);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.dropzoneHover {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
cursor: pointer;
|
|
23
|
+
border: 2px dashed var(--openapi-monaco-border-color);
|
|
24
|
+
background-color: var(--openapi-input-background);
|
|
25
|
+
width: 100%;
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
padding: var(--ifm-pre-padding);
|
|
28
|
+
font-size: var(--ifm-code-font-size);
|
|
29
|
+
border: 2px dashed var(--ifm-color-primary);
|
|
30
|
+
|
|
31
|
+
background: linear-gradient(
|
|
32
|
+
var(--openapi-dropzone-hover-shim),
|
|
33
|
+
var(--openapi-dropzone-hover-shim)
|
|
34
|
+
),
|
|
35
|
+
linear-gradient(var(--ifm-color-primary), var(--ifm-color-primary));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dropzone:hover {
|
|
39
|
+
border: 2px dashed var(--ifm-color-primary);
|
|
40
|
+
background: linear-gradient(
|
|
41
|
+
var(--openapi-dropzone-hover-shim),
|
|
42
|
+
var(--openapi-dropzone-hover-shim)
|
|
43
|
+
),
|
|
44
|
+
linear-gradient(var(--ifm-color-primary), var(--ifm-color-primary));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.dropzoneContent {
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: center;
|
|
51
|
+
flex-wrap: wrap;
|
|
52
|
+
margin: var(--ifm-pre-padding) 0;
|
|
53
|
+
color: var(--openapi-dropzone-color);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.dropzone:hover .dropzoneContent {
|
|
57
|
+
color: var(--ifm-pre-color);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.dropzoneHover .dropzoneContent {
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
flex-wrap: wrap;
|
|
65
|
+
margin: var(--ifm-pre-padding) 0;
|
|
66
|
+
color: var(--ifm-pre-color);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.filename {
|
|
70
|
+
margin: 0 calc(var(--ifm-pre-padding) * 1.5);
|
|
71
|
+
white-space: nowrap;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
text-overflow: ellipsis;
|
|
74
|
+
flex: 1;
|
|
75
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import React from "react";
|
|
8
|
+
import styles from "./styles.module.css";
|
|
9
|
+
|
|
10
|
+
function FormItem({ label, type, children }) {
|
|
11
|
+
return (
|
|
12
|
+
<div className={styles.formItem}>
|
|
13
|
+
<code>{label}</code>
|
|
14
|
+
{type && (
|
|
15
|
+
<span
|
|
16
|
+
style={{
|
|
17
|
+
opacity: 0.6,
|
|
18
|
+
}}
|
|
19
|
+
>
|
|
20
|
+
{" "}
|
|
21
|
+
— {type}
|
|
22
|
+
</span>
|
|
23
|
+
)}
|
|
24
|
+
<div>{children}</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default FormItem;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import React from "react";
|
|
8
|
+
import styles from "./styles.module.css";
|
|
9
|
+
|
|
10
|
+
function FormMultiSelect({ value, options, onChange }) {
|
|
11
|
+
if (options.length === 0) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let height;
|
|
16
|
+
|
|
17
|
+
if (options.length < 6) {
|
|
18
|
+
const selectPadding = 12 * 2;
|
|
19
|
+
const rawHeight = options.length * 29;
|
|
20
|
+
const innerMargins = 4 * options.length - 1;
|
|
21
|
+
const outerMargins = 4 * 2;
|
|
22
|
+
const mysteryScroll = 1;
|
|
23
|
+
height =
|
|
24
|
+
rawHeight + innerMargins + outerMargins + selectPadding + mysteryScroll;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<select
|
|
29
|
+
style={{
|
|
30
|
+
height: height,
|
|
31
|
+
}}
|
|
32
|
+
className={styles.selectInput}
|
|
33
|
+
value={value}
|
|
34
|
+
onChange={onChange}
|
|
35
|
+
size={Math.min(6, options.length + 1)}
|
|
36
|
+
multiple
|
|
37
|
+
>
|
|
38
|
+
{options.map((option) => {
|
|
39
|
+
return (
|
|
40
|
+
<option key={option} value={option}>
|
|
41
|
+
{option}
|
|
42
|
+
</option>
|
|
43
|
+
);
|
|
44
|
+
})}
|
|
45
|
+
</select>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export default FormMultiSelect;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.inputBase {
|
|
2
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
3
|
+
/* height: 40px; */
|
|
4
|
+
background-color: var(--openapi-input-background);
|
|
5
|
+
border: none;
|
|
6
|
+
outline: none;
|
|
7
|
+
width: 100%;
|
|
8
|
+
font-size: var(--ifm-code-font-size);
|
|
9
|
+
color: var(--ifm-pre-color);
|
|
10
|
+
padding: 12px var(--ifm-pre-padding);
|
|
11
|
+
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
border: 2px solid transparent;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.selectInput {
|
|
17
|
+
composes: inputBase;
|
|
18
|
+
-moz-appearance: none;
|
|
19
|
+
-webkit-appearance: none;
|
|
20
|
+
appearance: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.selectInput option {
|
|
24
|
+
border-radius: 0.25rem;
|
|
25
|
+
color: var(--ifm-menu-color);
|
|
26
|
+
margin: 0.25rem 0;
|
|
27
|
+
padding: var(--ifm-menu-link-padding-vertical)
|
|
28
|
+
var(--ifm-menu-link-padding-horizontal);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.selectInput:focus option:checked {
|
|
32
|
+
/* background: #0f62fe linear-gradient(0deg, #0f62fe 0%, #0f62fe 100%); */
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.selectInput:focus {
|
|
36
|
+
/* box-shadow: inset 0px 0px 0px 2px white; */
|
|
37
|
+
border: 2px solid var(--openapi-input-border);
|
|
38
|
+
}
|