docusaurus-theme-openapi-docs 1.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.
- package/LICENSE +21 -0
- package/babel.config.js +35 -0
- 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/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/index.js +174 -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 +236 -0
- package/lib/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib/theme/ApiDemoPanel/Execute/index.js +85 -0
- package/lib/theme/ApiDemoPanel/Execute/makeRequest.js +202 -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 +97 -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 +51 -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 +329 -0
- package/lib/theme/ApiDemoPanel/hooks.js +20 -0
- package/lib/theme/ApiDemoPanel/index.js +134 -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 +109 -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/Tabs/index.js +258 -0
- package/lib/theme/Tabs/styles.module.css +118 -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/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/index.js +203 -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 +264 -0
- package/lib-next/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/lib-next/theme/ApiDemoPanel/Execute/index.js +74 -0
- package/lib-next/theme/ApiDemoPanel/Execute/makeRequest.js +183 -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 +113 -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 +48 -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 +310 -0
- package/lib-next/theme/ApiDemoPanel/hooks.js +9 -0
- package/lib-next/theme/ApiDemoPanel/index.js +110 -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 +109 -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/Tabs/index.js +258 -0
- package/lib-next/theme/Tabs/styles.module.css +118 -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 +68 -0
- package/src/index.ts +42 -0
- package/src/markdown/createDescription.ts +13 -0
- package/src/markdown/schema.ts +115 -0
- package/src/markdown/utils.ts +39 -0
- package/src/theme/ApiDemoPanel/Accept/index.tsx +35 -0
- package/src/theme/ApiDemoPanel/Accept/slice.ts +29 -0
- package/src/theme/ApiDemoPanel/Authorization/auth-types.ts +26 -0
- package/src/theme/ApiDemoPanel/Authorization/index.tsx +211 -0
- package/src/theme/ApiDemoPanel/Authorization/slice.ts +145 -0
- package/src/theme/ApiDemoPanel/Body/index.tsx +218 -0
- package/src/theme/ApiDemoPanel/Body/slice.ts +133 -0
- package/src/theme/ApiDemoPanel/ContentType/index.tsx +35 -0
- package/src/theme/ApiDemoPanel/ContentType/slice.ts +29 -0
- package/src/theme/ApiDemoPanel/Curl/index.tsx +280 -0
- package/src/theme/ApiDemoPanel/Curl/styles.module.css +84 -0
- package/src/theme/ApiDemoPanel/Execute/index.tsx +88 -0
- package/src/theme/ApiDemoPanel/Execute/makeRequest.ts +184 -0
- package/src/theme/ApiDemoPanel/FloatingButton/index.tsx +27 -0
- package/src/theme/ApiDemoPanel/FloatingButton/styles.module.css +26 -0
- package/src/theme/ApiDemoPanel/FormFileUpload/index.tsx +116 -0
- package/src/theme/ApiDemoPanel/FormFileUpload/styles.module.css +75 -0
- package/src/theme/ApiDemoPanel/FormItem/index.tsx +28 -0
- package/src/theme/ApiDemoPanel/FormItem/styles.module.css +7 -0
- package/src/theme/ApiDemoPanel/FormMultiSelect/index.tsx +54 -0
- package/src/theme/ApiDemoPanel/FormMultiSelect/styles.module.css +38 -0
- package/src/theme/ApiDemoPanel/FormSelect/index.tsx +36 -0
- package/src/theme/ApiDemoPanel/FormSelect/styles.module.css +51 -0
- package/src/theme/ApiDemoPanel/FormTextInput/index.tsx +32 -0
- package/src/theme/ApiDemoPanel/FormTextInput/styles.module.css +21 -0
- package/src/theme/ApiDemoPanel/MethodEndpoint/index.tsx +55 -0
- package/src/theme/ApiDemoPanel/ParamOptions/index.tsx +316 -0
- package/src/theme/ApiDemoPanel/ParamOptions/slice.ts +37 -0
- package/src/theme/ApiDemoPanel/ParamOptions/styles.module.css +180 -0
- package/src/theme/ApiDemoPanel/Response/index.tsx +66 -0
- package/src/theme/ApiDemoPanel/Response/slice.ts +31 -0
- package/src/theme/ApiDemoPanel/SecuritySchemes/index.tsx +49 -0
- package/src/theme/ApiDemoPanel/Server/index.tsx +103 -0
- package/src/theme/ApiDemoPanel/Server/slice.ts +40 -0
- package/src/theme/ApiDemoPanel/Server/styles.module.css +61 -0
- package/src/theme/ApiDemoPanel/VSCode/index.tsx +205 -0
- package/src/theme/ApiDemoPanel/VSCode/styles.module.css +19 -0
- package/src/theme/ApiDemoPanel/buildPostmanRequest.ts +307 -0
- package/src/theme/ApiDemoPanel/hooks.ts +13 -0
- package/src/theme/ApiDemoPanel/index.tsx +118 -0
- package/src/theme/ApiDemoPanel/persistanceMiddleware.ts +46 -0
- package/src/theme/ApiDemoPanel/postman-collection.d.ts +10 -0
- package/src/theme/ApiDemoPanel/storage-utils.ts +39 -0
- package/src/theme/ApiDemoPanel/store.ts +41 -0
- package/src/theme/ApiDemoPanel/styles.module.css +44 -0
- package/src/theme/ApiItem/index.tsx +171 -0
- package/src/theme/ApiItem/styles.module.css +109 -0
- package/src/theme/ParamsItem/index.js +68 -0
- package/src/theme/ParamsItem/styles.module.css +24 -0
- package/src/theme/SchemaItem/index.js +58 -0
- package/src/theme/SchemaItem/styles.module.css +24 -0
- package/src/theme/Tabs/index.js +258 -0
- package/src/theme/Tabs/styles.module.css +118 -0
- package/src/theme-classic.d.ts +8 -0
- package/src/theme-openapi.d.ts +48 -0
- package/src/theme-translations.d.ts +9 -0
- package/src/types.ts +70 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
// @ts-ignore
|
|
9
|
+
import sdk from "@paloaltonetworks/postman-collection";
|
|
10
|
+
|
|
11
|
+
import { Body } from "../Body/slice";
|
|
12
|
+
|
|
13
|
+
async function loadImage(content: Blob): Promise<string | ArrayBuffer | null> {
|
|
14
|
+
return new Promise((accept, reject) => {
|
|
15
|
+
const reader = new FileReader();
|
|
16
|
+
|
|
17
|
+
reader.onabort = () => {
|
|
18
|
+
console.log("file reading was aborted");
|
|
19
|
+
reject();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
reader.onerror = () => {
|
|
23
|
+
console.log("file reading has failed");
|
|
24
|
+
reject();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
reader.onload = () => {
|
|
28
|
+
// Do whatever you want with the file contents
|
|
29
|
+
const binaryStr = reader.result;
|
|
30
|
+
accept(binaryStr);
|
|
31
|
+
};
|
|
32
|
+
reader.readAsArrayBuffer(content);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function makeRequest(
|
|
37
|
+
request: sdk.Request,
|
|
38
|
+
proxy: string | undefined,
|
|
39
|
+
_body: Body
|
|
40
|
+
) {
|
|
41
|
+
const headers = request.toJSON().header;
|
|
42
|
+
|
|
43
|
+
let myHeaders = new Headers();
|
|
44
|
+
if (headers) {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
headers.forEach((header) => {
|
|
47
|
+
if (header.key && header.value) {
|
|
48
|
+
myHeaders.append(header.key, header.value);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// The following code handles multiple files in the same formdata param.
|
|
54
|
+
// It removes the form data params where the src property is an array of filepath strings
|
|
55
|
+
// Splits that array into different form data params with src set as a single filepath string
|
|
56
|
+
// TODO:
|
|
57
|
+
// if (request.body && request.body.mode === 'formdata') {
|
|
58
|
+
// let formdata = request.body.formdata,
|
|
59
|
+
// formdataArray = [];
|
|
60
|
+
// formdata.members.forEach((param) => {
|
|
61
|
+
// let key = param.key,
|
|
62
|
+
// type = param.type,
|
|
63
|
+
// disabled = param.disabled,
|
|
64
|
+
// contentType = param.contentType;
|
|
65
|
+
// // check if type is file or text
|
|
66
|
+
// if (type === 'file') {
|
|
67
|
+
// // if src is not of type string we check for array(multiple files)
|
|
68
|
+
// if (typeof param.src !== 'string') {
|
|
69
|
+
// // if src is an array(not empty), iterate over it and add files as separate form fields
|
|
70
|
+
// if (Array.isArray(param.src) && param.src.length) {
|
|
71
|
+
// param.src.forEach((filePath) => {
|
|
72
|
+
// addFormParam(
|
|
73
|
+
// formdataArray,
|
|
74
|
+
// key,
|
|
75
|
+
// param.type,
|
|
76
|
+
// filePath,
|
|
77
|
+
// disabled,
|
|
78
|
+
// contentType
|
|
79
|
+
// );
|
|
80
|
+
// });
|
|
81
|
+
// }
|
|
82
|
+
// // if src is not an array or string, or is an empty array, add a placeholder for file path(no files case)
|
|
83
|
+
// else {
|
|
84
|
+
// addFormParam(
|
|
85
|
+
// formdataArray,
|
|
86
|
+
// key,
|
|
87
|
+
// param.type,
|
|
88
|
+
// '/path/to/file',
|
|
89
|
+
// disabled,
|
|
90
|
+
// contentType
|
|
91
|
+
// );
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// // if src is string, directly add the param with src as filepath
|
|
95
|
+
// else {
|
|
96
|
+
// addFormParam(
|
|
97
|
+
// formdataArray,
|
|
98
|
+
// key,
|
|
99
|
+
// param.type,
|
|
100
|
+
// param.src,
|
|
101
|
+
// disabled,
|
|
102
|
+
// contentType
|
|
103
|
+
// );
|
|
104
|
+
// }
|
|
105
|
+
// }
|
|
106
|
+
// // if type is text, directly add it to formdata array
|
|
107
|
+
// else {
|
|
108
|
+
// addFormParam(
|
|
109
|
+
// formdataArray,
|
|
110
|
+
// key,
|
|
111
|
+
// param.type,
|
|
112
|
+
// param.value,
|
|
113
|
+
// disabled,
|
|
114
|
+
// contentType
|
|
115
|
+
// );
|
|
116
|
+
// }
|
|
117
|
+
// });
|
|
118
|
+
// request.body.update({
|
|
119
|
+
// mode: 'formdata',
|
|
120
|
+
// formdata: formdataArray,
|
|
121
|
+
// });
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
const body = request.body?.toJSON();
|
|
125
|
+
|
|
126
|
+
let myBody: RequestInit["body"] = undefined;
|
|
127
|
+
if (body !== undefined && Object.keys(body).length > 0) {
|
|
128
|
+
switch (body.mode) {
|
|
129
|
+
case "urlencoded": {
|
|
130
|
+
myBody = new URLSearchParams();
|
|
131
|
+
if (Array.isArray(body.urlencoded)) {
|
|
132
|
+
for (const data of body.urlencoded) {
|
|
133
|
+
if (data.key && data.value) {
|
|
134
|
+
myBody.append(data.key, data.value);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "raw": {
|
|
141
|
+
myBody = (body.raw ?? "").toString();
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case "formdata": {
|
|
145
|
+
myBody = new FormData();
|
|
146
|
+
if (Array.isArray(body.formdata)) {
|
|
147
|
+
for (const data of body.formdata) {
|
|
148
|
+
if (data.key && data.value) {
|
|
149
|
+
myBody.append(data.key, data.value);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case "file": {
|
|
156
|
+
if (_body.type === "raw" && _body.content?.type === "file") {
|
|
157
|
+
myBody = await loadImage(_body.content.value.content);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
default:
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const requestOptions: RequestInit = {
|
|
167
|
+
method: request.method,
|
|
168
|
+
headers: myHeaders,
|
|
169
|
+
body: myBody,
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
let finalUrl = request.url.toString();
|
|
173
|
+
if (proxy) {
|
|
174
|
+
// Ensure the proxy ends with a slash.
|
|
175
|
+
let normalizedProxy = proxy.replace(/\/$/, "") + "/";
|
|
176
|
+
finalUrl = normalizedProxy + request.url.toString();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return await fetch(finalUrl, requestOptions).then((response) => {
|
|
180
|
+
return response.text();
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export default makeRequest;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import styles from "./styles.module.css";
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
label?: string;
|
|
14
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function FloatingButton({ label, onClick, children }: Props) {
|
|
19
|
+
return (
|
|
20
|
+
<div className={styles.floatingButton}>
|
|
21
|
+
{label && <button onClick={onClick}>{label}</button>}
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
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,116 @@
|
|
|
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, { useState } from "react";
|
|
9
|
+
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
import MagicDropzone from "react-magic-dropzone";
|
|
12
|
+
|
|
13
|
+
import FloatingButton from "../FloatingButton";
|
|
14
|
+
import styles from "./styles.module.css";
|
|
15
|
+
|
|
16
|
+
type PreviewFile = { preview: string } & File;
|
|
17
|
+
|
|
18
|
+
interface RenderPreviewProps {
|
|
19
|
+
file: PreviewFile;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function RenderPreview({ file }: RenderPreviewProps) {
|
|
23
|
+
switch (file.type) {
|
|
24
|
+
case "image/png":
|
|
25
|
+
case "image/jpeg":
|
|
26
|
+
case "image/jpg":
|
|
27
|
+
case "image/svg+xml":
|
|
28
|
+
return (
|
|
29
|
+
<img
|
|
30
|
+
style={{
|
|
31
|
+
borderRadius: "4px",
|
|
32
|
+
}}
|
|
33
|
+
src={file.preview}
|
|
34
|
+
alt=""
|
|
35
|
+
/>
|
|
36
|
+
);
|
|
37
|
+
default:
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
style={{
|
|
41
|
+
display: "flex",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
minWidth: 0,
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<svg viewBox="0 0 100 120" style={{ width: "50px", height: "60px" }}>
|
|
47
|
+
<path
|
|
48
|
+
fillRule="evenodd"
|
|
49
|
+
fill="#b3beca"
|
|
50
|
+
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"
|
|
51
|
+
/>
|
|
52
|
+
<path
|
|
53
|
+
fillRule="evenodd"
|
|
54
|
+
fill="#90a1b1"
|
|
55
|
+
transform="translate(60, 0)"
|
|
56
|
+
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"
|
|
57
|
+
/>
|
|
58
|
+
</svg>
|
|
59
|
+
<div className={styles.filename}>{file.name}</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface Props {
|
|
66
|
+
placeholder: string;
|
|
67
|
+
onChange?(file?: File): any;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function FormFileUpload({ placeholder, onChange }: Props) {
|
|
71
|
+
const [hover, setHover] = useState(false);
|
|
72
|
+
const [file, setFile] = useState<PreviewFile>();
|
|
73
|
+
|
|
74
|
+
function setAndNotifyFile(file?: PreviewFile) {
|
|
75
|
+
setFile(file);
|
|
76
|
+
onChange?.(file);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function handleDrop(accepted: PreviewFile[]) {
|
|
80
|
+
const [file] = accepted;
|
|
81
|
+
setAndNotifyFile(file);
|
|
82
|
+
setHover(false);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<FloatingButton>
|
|
87
|
+
<MagicDropzone
|
|
88
|
+
className={hover ? styles.dropzoneHover : styles.dropzone}
|
|
89
|
+
onDrop={handleDrop}
|
|
90
|
+
onDragEnter={() => setHover(true)}
|
|
91
|
+
onDragLeave={() => setHover(false)}
|
|
92
|
+
multiple={false}
|
|
93
|
+
style={{ marginTop: "calc(var(--ifm-pre-padding) / 2)" }}
|
|
94
|
+
>
|
|
95
|
+
{file ? (
|
|
96
|
+
<>
|
|
97
|
+
<button
|
|
98
|
+
style={{ marginTop: "calc(var(--ifm-pre-padding) / 2)" }}
|
|
99
|
+
onClick={(e) => {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
setAndNotifyFile(undefined);
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
Clear
|
|
105
|
+
</button>
|
|
106
|
+
<RenderPreview file={file} />
|
|
107
|
+
</>
|
|
108
|
+
) : (
|
|
109
|
+
<div className={styles.dropzoneContent}>{placeholder}</div>
|
|
110
|
+
)}
|
|
111
|
+
</MagicDropzone>
|
|
112
|
+
</FloatingButton>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
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,28 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import styles from "./styles.module.css";
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
label: string;
|
|
14
|
+
type?: string;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function FormItem({ label, type, children }: Props) {
|
|
19
|
+
return (
|
|
20
|
+
<div className={styles.formItem}>
|
|
21
|
+
<code>{label}</code>
|
|
22
|
+
{type && <span style={{ opacity: 0.6 }}> — {type}</span>}
|
|
23
|
+
<div>{children}</div>
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default FormItem;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import styles from "./styles.module.css";
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
value?: string;
|
|
14
|
+
options: string[];
|
|
15
|
+
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function FormMultiSelect({ value, options, onChange }: Props) {
|
|
19
|
+
if (options.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let height;
|
|
24
|
+
if (options.length < 6) {
|
|
25
|
+
const selectPadding = 12 * 2;
|
|
26
|
+
const rawHeight = options.length * 29;
|
|
27
|
+
const innerMargins = 4 * options.length - 1;
|
|
28
|
+
const outerMargins = 4 * 2;
|
|
29
|
+
const mysteryScroll = 1;
|
|
30
|
+
height =
|
|
31
|
+
rawHeight + innerMargins + outerMargins + selectPadding + mysteryScroll;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<select
|
|
36
|
+
style={{ height: height }}
|
|
37
|
+
className={styles.selectInput}
|
|
38
|
+
value={value}
|
|
39
|
+
onChange={onChange}
|
|
40
|
+
size={Math.min(6, options.length + 1)}
|
|
41
|
+
multiple
|
|
42
|
+
>
|
|
43
|
+
{options.map((option) => {
|
|
44
|
+
return (
|
|
45
|
+
<option key={option} value={option}>
|
|
46
|
+
{option}
|
|
47
|
+
</option>
|
|
48
|
+
);
|
|
49
|
+
})}
|
|
50
|
+
</select>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
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
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import styles from "./styles.module.css";
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
value?: string;
|
|
14
|
+
options?: string[];
|
|
15
|
+
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function FormSelect({ value, options, onChange }: Props) {
|
|
19
|
+
if (!Array.isArray(options) || options.length === 0) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<select className={styles.selectInput} value={value} onChange={onChange}>
|
|
25
|
+
{options.map((option) => {
|
|
26
|
+
return (
|
|
27
|
+
<option key={option} value={option}>
|
|
28
|
+
{option}
|
|
29
|
+
</option>
|
|
30
|
+
);
|
|
31
|
+
})}
|
|
32
|
+
</select>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default FormSelect;
|
|
@@ -0,0 +1,51 @@
|
|
|
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 48px 12px var(--ifm-pre-padding);
|
|
11
|
+
|
|
12
|
+
border-radius: 4px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html[data-theme="dark"] .selectInput {
|
|
16
|
+
margin-top: calc(var(--ifm-pre-padding) / 2);
|
|
17
|
+
/* height: 40px; */
|
|
18
|
+
background-color: var(--openapi-input-background);
|
|
19
|
+
border: none;
|
|
20
|
+
outline: none;
|
|
21
|
+
width: 100%;
|
|
22
|
+
font-size: var(--ifm-code-font-size);
|
|
23
|
+
color: var(--ifm-pre-color);
|
|
24
|
+
/* padding: 12px var(--ifm-pre-padding); */
|
|
25
|
+
|
|
26
|
+
border-radius: 4px;
|
|
27
|
+
-moz-appearance: none;
|
|
28
|
+
-webkit-appearance: none;
|
|
29
|
+
appearance: none;
|
|
30
|
+
|
|
31
|
+
background-image: url('data:image/svg+xml;charset=US-ASCII,<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true" fill="white"><path d="M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z"></path></svg>');
|
|
32
|
+
background-repeat: no-repeat;
|
|
33
|
+
background-position: right var(--ifm-pre-padding) top 50%;
|
|
34
|
+
background-size: auto auto;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.selectInput {
|
|
38
|
+
composes: inputBase;
|
|
39
|
+
-moz-appearance: none;
|
|
40
|
+
-webkit-appearance: none;
|
|
41
|
+
appearance: none;
|
|
42
|
+
|
|
43
|
+
background-image: url('data:image/svg+xml;charset=US-ASCII,<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" aria-hidden="true"><path d="M8 11L3 6 3.7 5.3 8 9.6 12.3 5.3 13 6z"></path></svg>');
|
|
44
|
+
background-repeat: no-repeat;
|
|
45
|
+
background-position: right var(--ifm-pre-padding) top 50%;
|
|
46
|
+
background-size: auto auto;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.selectInput:focus {
|
|
50
|
+
box-shadow: inset 0px 0px 0px 2px var(--openapi-input-border);
|
|
51
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
* Copyright (c) Palo Alto Networks
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
* ========================================================================== */
|
|
7
|
+
|
|
8
|
+
import React from "react";
|
|
9
|
+
|
|
10
|
+
import styles from "./styles.module.css";
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
value?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
password?: boolean;
|
|
16
|
+
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function FormTextInput({ value, placeholder, password, onChange }: Props) {
|
|
20
|
+
return (
|
|
21
|
+
<input
|
|
22
|
+
className={styles.input}
|
|
23
|
+
type={password ? "password" : "text"}
|
|
24
|
+
placeholder={placeholder}
|
|
25
|
+
value={value}
|
|
26
|
+
onChange={onChange}
|
|
27
|
+
autoComplete="off"
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default FormTextInput;
|