docusaurus-theme-openapi-docs 0.0.0-1109 → 0.0.0-1130
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 +2 -0
- package/lib/theme/ApiExplorer/Accept/index.js +2 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +3 -1
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +61 -29
- package/lib/theme/ApiExplorer/Body/index.js +4 -6
- package/lib/theme/ApiExplorer/ContentType/index.js +2 -1
- package/lib/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/lib/theme/ApiExplorer/FormItem/index.d.ts +1 -4
- package/lib/theme/ApiExplorer/FormItem/index.js +2 -26
- package/lib/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
- package/lib/theme/ApiExplorer/FormLabel/index.d.ts +9 -0
- package/lib/theme/ApiExplorer/FormLabel/index.js +50 -0
- package/lib/theme/ApiExplorer/FormMultiSelect/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/FormMultiSelect/index.js +97 -19
- package/lib/theme/ApiExplorer/FormSelect/index.d.ts +6 -1
- package/lib/theme/ApiExplorer/FormSelect/index.js +96 -15
- package/lib/theme/ApiExplorer/FormTextInput/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/FormTextInput/index.js +71 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.js +11 -3
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +5 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.js +27 -3
- package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/lib/theme/ApiExplorer/Request/index.js +9 -3
- package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/lib/theme/ApiExplorer/Response/index.js +2 -1
- package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/Server/index.js +6 -3
- package/lib/theme/Schema/index.js +83 -7
- package/lib/theme/styles.scss +1 -0
- package/package.json +4 -3
- package/src/index.ts +2 -0
- package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +44 -26
- package/src/theme/ApiExplorer/Body/index.tsx +7 -8
- package/src/theme/ApiExplorer/ContentType/index.tsx +2 -1
- package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/src/theme/ApiExplorer/FormItem/index.tsx +2 -16
- package/src/theme/ApiExplorer/FormLabel/_FormLabel.scss +4 -0
- package/src/theme/ApiExplorer/FormLabel/index.tsx +43 -0
- package/src/theme/ApiExplorer/FormMultiSelect/index.tsx +40 -20
- package/src/theme/ApiExplorer/FormSelect/index.tsx +41 -15
- package/src/theme/ApiExplorer/FormTextInput/index.tsx +15 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamArrayFormItem.tsx +13 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamBooleanFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamMultiSelectFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +12 -1
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +65 -9
- package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/src/theme/ApiExplorer/Request/index.tsx +11 -6
- package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/src/theme/ApiExplorer/Response/index.tsx +3 -2
- package/src/theme/ApiExplorer/Server/index.tsx +10 -3
- package/src/theme/Schema/index.tsx +97 -7
- package/src/theme/styles.scss +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/lib/index.js
CHANGED
|
@@ -38,6 +38,7 @@ function docusaurusThemeOpenAPI() {
|
|
|
38
38
|
resolve: {
|
|
39
39
|
fallback: {
|
|
40
40
|
buffer: require.resolve("buffer/"),
|
|
41
|
+
path: require.resolve("path-browserify"),
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
44
|
plugins: [
|
|
@@ -67,6 +68,7 @@ function docusaurusThemeOpenAPI() {
|
|
|
67
68
|
resolve: {
|
|
68
69
|
fallback: {
|
|
69
70
|
buffer: require.resolve("buffer/"),
|
|
71
|
+
path: require.resolve("path-browserify"),
|
|
70
72
|
},
|
|
71
73
|
},
|
|
72
74
|
plugins: [
|
|
@@ -27,8 +27,9 @@ function Accept() {
|
|
|
27
27
|
}
|
|
28
28
|
return react_1.default.createElement(
|
|
29
29
|
FormItem_1.default,
|
|
30
|
-
|
|
30
|
+
null,
|
|
31
31
|
react_1.default.createElement(FormSelect_1.default, {
|
|
32
|
+
label: "Accept",
|
|
32
33
|
value: value,
|
|
33
34
|
options: options,
|
|
34
35
|
onChange: (e) => dispatch((0, slice_1.setAccept)(e.target.value)),
|
|
@@ -39,13 +39,12 @@ function Authorization() {
|
|
|
39
39
|
optionKeys.length > 1 &&
|
|
40
40
|
react_1.default.createElement(
|
|
41
41
|
FormItem_1.default,
|
|
42
|
-
|
|
42
|
+
null,
|
|
43
|
+
react_1.default.createElement(FormSelect_1.default, {
|
|
43
44
|
label: (0, Translate_1.translate)({
|
|
44
45
|
id: translationIds_1.OPENAPI_AUTH.SECURITY_SCHEME,
|
|
45
46
|
message: "Security Scheme",
|
|
46
47
|
}),
|
|
47
|
-
},
|
|
48
|
-
react_1.default.createElement(FormSelect_1.default, {
|
|
49
48
|
options: optionKeys,
|
|
50
49
|
value: selected,
|
|
51
50
|
onChange: (e) => {
|
|
@@ -57,14 +56,12 @@ function Authorization() {
|
|
|
57
56
|
if (a.type === "http" && a.scheme === "bearer") {
|
|
58
57
|
return react_1.default.createElement(
|
|
59
58
|
FormItem_1.default,
|
|
60
|
-
{
|
|
59
|
+
{ key: a.key + "-bearer" },
|
|
60
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
61
61
|
label: (0, Translate_1.translate)({
|
|
62
62
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
63
63
|
message: "Bearer Token",
|
|
64
64
|
}),
|
|
65
|
-
key: a.key + "-bearer",
|
|
66
|
-
},
|
|
67
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
68
65
|
placeholder: (0, Translate_1.translate)({
|
|
69
66
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
70
67
|
message: "Bearer Token",
|
|
@@ -87,14 +84,12 @@ function Authorization() {
|
|
|
87
84
|
if (a.type === "oauth2") {
|
|
88
85
|
return react_1.default.createElement(
|
|
89
86
|
FormItem_1.default,
|
|
90
|
-
{
|
|
87
|
+
{ key: a.key + "-oauth2" },
|
|
88
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
91
89
|
label: (0, Translate_1.translate)({
|
|
92
90
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
93
91
|
message: "Bearer Token",
|
|
94
92
|
}),
|
|
95
|
-
key: a.key + "-oauth2",
|
|
96
|
-
},
|
|
97
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
98
93
|
placeholder: (0, Translate_1.translate)({
|
|
99
94
|
id: translationIds_1.OPENAPI_AUTH.BEARER_TOKEN,
|
|
100
95
|
message: "Bearer Token",
|
|
@@ -120,13 +115,12 @@ function Authorization() {
|
|
|
120
115
|
{ key: a.key + "-basic" },
|
|
121
116
|
react_1.default.createElement(
|
|
122
117
|
FormItem_1.default,
|
|
123
|
-
|
|
118
|
+
null,
|
|
119
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
124
120
|
label: (0, Translate_1.translate)({
|
|
125
121
|
id: translationIds_1.OPENAPI_AUTH.USERNAME,
|
|
126
122
|
message: "Username",
|
|
127
123
|
}),
|
|
128
|
-
},
|
|
129
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
130
124
|
placeholder: (0, Translate_1.translate)({
|
|
131
125
|
id: translationIds_1.OPENAPI_AUTH.USERNAME,
|
|
132
126
|
message: "Username",
|
|
@@ -146,13 +140,12 @@ function Authorization() {
|
|
|
146
140
|
),
|
|
147
141
|
react_1.default.createElement(
|
|
148
142
|
FormItem_1.default,
|
|
149
|
-
|
|
143
|
+
null,
|
|
144
|
+
react_1.default.createElement(FormTextInput_1.default, {
|
|
150
145
|
label: (0, Translate_1.translate)({
|
|
151
146
|
id: translationIds_1.OPENAPI_AUTH.PASSWORD,
|
|
152
147
|
message: "Password",
|
|
153
148
|
}),
|
|
154
|
-
},
|
|
155
|
-
react_1.default.createElement(FormTextInput_1.default, {
|
|
156
149
|
placeholder: (0, Translate_1.translate)({
|
|
157
150
|
id: translationIds_1.OPENAPI_AUTH.PASSWORD,
|
|
158
151
|
message: "Password",
|
|
@@ -176,8 +169,9 @@ function Authorization() {
|
|
|
176
169
|
if (a.type === "apiKey") {
|
|
177
170
|
return react_1.default.createElement(
|
|
178
171
|
FormItem_1.default,
|
|
179
|
-
{
|
|
172
|
+
{ key: a.key + "-apikey" },
|
|
180
173
|
react_1.default.createElement(FormTextInput_1.default, {
|
|
174
|
+
label: `${a.key}`,
|
|
181
175
|
placeholder: `${a.key}`,
|
|
182
176
|
password: true,
|
|
183
177
|
value: data[a.key].apiKey ?? "",
|
|
@@ -4,6 +4,8 @@ interface FormBodyItemProps {
|
|
|
4
4
|
schemaObject: SchemaObject;
|
|
5
5
|
id: string;
|
|
6
6
|
schema: SchemaObject;
|
|
7
|
+
label?: string;
|
|
8
|
+
required?: boolean;
|
|
7
9
|
}
|
|
8
|
-
export default function FormBodyItem({ schemaObject, id, schema, }: FormBodyItemProps): React.JSX.Element;
|
|
10
|
+
export default function FormBodyItem({ schemaObject, id, schema, label, required, }: FormBodyItemProps): React.JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -16,6 +16,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
16
16
|
const FormFileUpload_1 = __importDefault(
|
|
17
17
|
require("@theme/ApiExplorer/FormFileUpload")
|
|
18
18
|
);
|
|
19
|
+
const FormLabel_1 = __importDefault(require("@theme/ApiExplorer/FormLabel"));
|
|
19
20
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
20
21
|
const FormTextInput_1 = __importDefault(
|
|
21
22
|
require("@theme/ApiExplorer/FormTextInput")
|
|
@@ -26,36 +27,54 @@ const FileArrayFormBodyItem_1 = __importDefault(
|
|
|
26
27
|
require("../FileArrayFormBodyItem")
|
|
27
28
|
);
|
|
28
29
|
const slice_1 = require("../slice");
|
|
29
|
-
function FormBodyItem({ schemaObject, id, schema }) {
|
|
30
|
+
function FormBodyItem({ schemaObject, id, schema, label, required }) {
|
|
30
31
|
const dispatch = (0, hooks_1.useTypedDispatch)();
|
|
31
32
|
if (
|
|
32
33
|
schemaObject.type === "array" &&
|
|
33
34
|
schemaObject.items?.format === "binary"
|
|
34
35
|
) {
|
|
35
|
-
return react_1.default.createElement(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
return react_1.default.createElement(
|
|
37
|
+
react_1.default.Fragment,
|
|
38
|
+
null,
|
|
39
|
+
label &&
|
|
40
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
41
|
+
label: label,
|
|
42
|
+
required: required,
|
|
43
|
+
}),
|
|
44
|
+
react_1.default.createElement(FileArrayFormBodyItem_1.default, {
|
|
45
|
+
id: id,
|
|
46
|
+
description: schemaObject.description,
|
|
47
|
+
})
|
|
48
|
+
);
|
|
39
49
|
}
|
|
40
50
|
if (schemaObject.format === "binary") {
|
|
41
|
-
return react_1.default.createElement(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
return react_1.default.createElement(
|
|
52
|
+
react_1.default.Fragment,
|
|
53
|
+
null,
|
|
54
|
+
label &&
|
|
55
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
56
|
+
label: label,
|
|
57
|
+
required: required,
|
|
58
|
+
}),
|
|
59
|
+
react_1.default.createElement(FormFileUpload_1.default, {
|
|
60
|
+
placeholder: schemaObject.description || id,
|
|
61
|
+
onChange: (file) => {
|
|
62
|
+
if (file === undefined) {
|
|
63
|
+
dispatch((0, slice_1.clearFormBodyKey)(id));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
dispatch(
|
|
67
|
+
(0, slice_1.setFileFormBody)({
|
|
68
|
+
key: id,
|
|
69
|
+
value: {
|
|
70
|
+
src: `/path/to/${file.name}`,
|
|
71
|
+
content: file,
|
|
72
|
+
},
|
|
73
|
+
})
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
);
|
|
59
78
|
}
|
|
60
79
|
if (
|
|
61
80
|
schemaObject.type === "object" &&
|
|
@@ -67,12 +86,21 @@ function FormBodyItem({ schemaObject, id, schema }) {
|
|
|
67
86
|
2
|
|
68
87
|
);
|
|
69
88
|
return react_1.default.createElement(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
react_1.default.Fragment,
|
|
90
|
+
null,
|
|
91
|
+
label &&
|
|
92
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
93
|
+
label: label,
|
|
94
|
+
required: required,
|
|
95
|
+
}),
|
|
96
|
+
react_1.default.createElement(
|
|
97
|
+
LiveEditor_1.default,
|
|
98
|
+
{
|
|
99
|
+
action: (code) =>
|
|
100
|
+
dispatch((0, slice_1.setStringFormBody)({ key: id, value: code })),
|
|
101
|
+
},
|
|
102
|
+
objectExample
|
|
103
|
+
)
|
|
76
104
|
);
|
|
77
105
|
}
|
|
78
106
|
if (
|
|
@@ -80,6 +108,8 @@ function FormBodyItem({ schemaObject, id, schema }) {
|
|
|
80
108
|
schemaObject.enum.every((value) => typeof value === "string")
|
|
81
109
|
) {
|
|
82
110
|
return react_1.default.createElement(FormSelect_1.default, {
|
|
111
|
+
label: label,
|
|
112
|
+
required: required,
|
|
83
113
|
options: ["---", ...schemaObject.enum],
|
|
84
114
|
onChange: (e) => {
|
|
85
115
|
const val = e.target.value;
|
|
@@ -98,6 +128,8 @@ function FormBodyItem({ schemaObject, id, schema }) {
|
|
|
98
128
|
}
|
|
99
129
|
// TODO: support all the other types.
|
|
100
130
|
return react_1.default.createElement(FormTextInput_1.default, {
|
|
131
|
+
label: label,
|
|
132
|
+
required: required,
|
|
101
133
|
paramName: id,
|
|
102
134
|
isRequired: Array.isArray(schema.required) && schema.required.includes(id),
|
|
103
135
|
placeholder: schemaObject.description || id,
|
|
@@ -368,16 +368,14 @@ function Body({
|
|
|
368
368
|
Object.entries(schema.properties ?? {}).map(([key, val]) => {
|
|
369
369
|
return react_1.default.createElement(
|
|
370
370
|
FormItem_1.default,
|
|
371
|
-
{
|
|
372
|
-
key: key,
|
|
373
|
-
label: key,
|
|
374
|
-
required:
|
|
375
|
-
Array.isArray(schema.required) && schema.required.includes(key),
|
|
376
|
-
},
|
|
371
|
+
{ key: key },
|
|
377
372
|
react_1.default.createElement(FormBodyItem_1.default, {
|
|
378
373
|
schemaObject: val,
|
|
379
374
|
id: key,
|
|
380
375
|
schema: schema,
|
|
376
|
+
label: key,
|
|
377
|
+
required:
|
|
378
|
+
Array.isArray(schema.required) && schema.required.includes(key),
|
|
381
379
|
})
|
|
382
380
|
);
|
|
383
381
|
})
|
|
@@ -29,8 +29,9 @@ function ContentType() {
|
|
|
29
29
|
}
|
|
30
30
|
return react_1.default.createElement(
|
|
31
31
|
FormItem_1.default,
|
|
32
|
-
|
|
32
|
+
null,
|
|
33
33
|
react_1.default.createElement(FormSelect_1.default, {
|
|
34
|
+
label: "Content-Type",
|
|
34
35
|
value: value,
|
|
35
36
|
options: options,
|
|
36
37
|
onChange: (e) => dispatch((0, slice_1.setContentType)(e.target.value)),
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export interface Props {
|
|
3
|
-
label?: string;
|
|
4
|
-
type?: string;
|
|
5
|
-
required?: boolean | undefined;
|
|
6
3
|
children?: React.ReactNode;
|
|
7
4
|
className?: string;
|
|
8
5
|
}
|
|
9
|
-
declare function FormItem({
|
|
6
|
+
declare function FormItem({ children, className }: Props): React.JSX.Element;
|
|
10
7
|
export default FormItem;
|
|
@@ -12,38 +12,14 @@ var __importDefault =
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
const react_1 = __importDefault(require("react"));
|
|
15
|
-
const Translate_1 = require("@docusaurus/Translate");
|
|
16
|
-
const translationIds_1 = require("@theme/translationIds");
|
|
17
15
|
const clsx_1 = __importDefault(require("clsx"));
|
|
18
|
-
function FormItem({
|
|
16
|
+
function FormItem({ children, className }) {
|
|
19
17
|
return react_1.default.createElement(
|
|
20
18
|
"div",
|
|
21
19
|
{
|
|
22
20
|
className: (0, clsx_1.default)("openapi-explorer__form-item", className),
|
|
23
21
|
},
|
|
24
|
-
|
|
25
|
-
react_1.default.createElement(
|
|
26
|
-
"label",
|
|
27
|
-
{ className: "openapi-explorer__form-item-label" },
|
|
28
|
-
label
|
|
29
|
-
),
|
|
30
|
-
type &&
|
|
31
|
-
react_1.default.createElement(
|
|
32
|
-
"span",
|
|
33
|
-
{ style: { opacity: 0.6 } },
|
|
34
|
-
" \u2014 ",
|
|
35
|
-
type
|
|
36
|
-
),
|
|
37
|
-
required &&
|
|
38
|
-
react_1.default.createElement(
|
|
39
|
-
"span",
|
|
40
|
-
{ className: "openapi-schema__required" },
|
|
41
|
-
(0, Translate_1.translate)({
|
|
42
|
-
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
43
|
-
message: "required",
|
|
44
|
-
})
|
|
45
|
-
),
|
|
46
|
-
react_1.default.createElement("div", null, children)
|
|
22
|
+
children
|
|
47
23
|
);
|
|
48
24
|
}
|
|
49
25
|
exports.default = FormItem;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* ============================================================================
|
|
3
|
+
* Copyright (c) Palo Alto Networks
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
* ========================================================================== */
|
|
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 translationIds_1 = require("@theme/translationIds");
|
|
17
|
+
function FormLabel({ htmlFor, label, type, required }) {
|
|
18
|
+
return react_1.default.createElement(
|
|
19
|
+
react_1.default.Fragment,
|
|
20
|
+
null,
|
|
21
|
+
htmlFor
|
|
22
|
+
? react_1.default.createElement(
|
|
23
|
+
"label",
|
|
24
|
+
{ className: "openapi-explorer__form-item-label", htmlFor: htmlFor },
|
|
25
|
+
label
|
|
26
|
+
)
|
|
27
|
+
: react_1.default.createElement(
|
|
28
|
+
"span",
|
|
29
|
+
{ className: "openapi-explorer__form-item-label" },
|
|
30
|
+
label
|
|
31
|
+
),
|
|
32
|
+
type &&
|
|
33
|
+
react_1.default.createElement(
|
|
34
|
+
"span",
|
|
35
|
+
{ style: { opacity: 0.6 } },
|
|
36
|
+
" \u2014 ",
|
|
37
|
+
type
|
|
38
|
+
),
|
|
39
|
+
required &&
|
|
40
|
+
react_1.default.createElement(
|
|
41
|
+
"span",
|
|
42
|
+
{ className: "openapi-schema__required" },
|
|
43
|
+
(0, Translate_1.translate)({
|
|
44
|
+
id: translationIds_1.OPENAPI_SCHEMA_ITEM.REQUIRED,
|
|
45
|
+
message: "required",
|
|
46
|
+
})
|
|
47
|
+
)
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
exports.default = FormLabel;
|
|
@@ -4,6 +4,9 @@ export interface Props {
|
|
|
4
4
|
options: string[];
|
|
5
5
|
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
6
6
|
showErrors?: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
required?: boolean;
|
|
7
10
|
}
|
|
8
|
-
declare function FormMultiSelect({ value, options, onChange, showErrors }: Props): React.JSX.Element | null;
|
|
11
|
+
declare function FormMultiSelect({ value, options, onChange, showErrors, label, type, required, }: Props): React.JSX.Element | null;
|
|
9
12
|
export default FormMultiSelect;
|
|
@@ -5,15 +5,81 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
* ========================================================================== */
|
|
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 () {
|
|
43
|
+
var ownKeys = function (o) {
|
|
44
|
+
ownKeys =
|
|
45
|
+
Object.getOwnPropertyNames ||
|
|
46
|
+
function (o) {
|
|
47
|
+
var ar = [];
|
|
48
|
+
for (var k in o)
|
|
49
|
+
if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null)
|
|
58
|
+
for (var k = ownKeys(mod), i = 0; i < k.length; i++)
|
|
59
|
+
if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
60
|
+
__setModuleDefault(result, mod);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
})();
|
|
8
64
|
var __importDefault =
|
|
9
65
|
(this && this.__importDefault) ||
|
|
10
66
|
function (mod) {
|
|
11
67
|
return mod && mod.__esModule ? mod : { default: mod };
|
|
12
68
|
};
|
|
13
69
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
const react_1 =
|
|
70
|
+
const react_1 = __importStar(require("react"));
|
|
71
|
+
const FormLabel_1 = __importDefault(require("@theme/ApiExplorer/FormLabel"));
|
|
15
72
|
const clsx_1 = __importDefault(require("clsx"));
|
|
16
|
-
function FormMultiSelect({
|
|
73
|
+
function FormMultiSelect({
|
|
74
|
+
value,
|
|
75
|
+
options,
|
|
76
|
+
onChange,
|
|
77
|
+
showErrors,
|
|
78
|
+
label,
|
|
79
|
+
type,
|
|
80
|
+
required,
|
|
81
|
+
}) {
|
|
82
|
+
const id = (0, react_1.useId)();
|
|
17
83
|
if (options.length === 0) {
|
|
18
84
|
return null;
|
|
19
85
|
}
|
|
@@ -28,24 +94,36 @@ function FormMultiSelect({ value, options, onChange, showErrors }) {
|
|
|
28
94
|
rawHeight + innerMargins + outerMargins + selectPadding + mysteryScroll;
|
|
29
95
|
}
|
|
30
96
|
return react_1.default.createElement(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
97
|
+
react_1.default.Fragment,
|
|
98
|
+
null,
|
|
99
|
+
label &&
|
|
100
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
101
|
+
htmlFor: id,
|
|
102
|
+
label: label,
|
|
103
|
+
type: type,
|
|
104
|
+
required: required,
|
|
36
105
|
}),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
106
|
+
react_1.default.createElement(
|
|
107
|
+
"select",
|
|
108
|
+
{
|
|
109
|
+
id: label ? id : undefined,
|
|
110
|
+
style: { height: height },
|
|
111
|
+
className: (0, clsx_1.default)("openapi-explorer__multi-select-input", {
|
|
112
|
+
error: showErrors,
|
|
113
|
+
}),
|
|
114
|
+
value: value,
|
|
115
|
+
onChange: onChange,
|
|
116
|
+
size: Math.min(6, options.length + 1),
|
|
117
|
+
multiple: true,
|
|
118
|
+
},
|
|
119
|
+
options.map((option) => {
|
|
120
|
+
return react_1.default.createElement(
|
|
121
|
+
"option",
|
|
122
|
+
{ key: option, value: option },
|
|
123
|
+
option
|
|
124
|
+
);
|
|
125
|
+
})
|
|
126
|
+
)
|
|
49
127
|
);
|
|
50
128
|
}
|
|
51
129
|
exports.default = FormMultiSelect;
|
|
@@ -3,6 +3,11 @@ export interface Props {
|
|
|
3
3
|
value?: string;
|
|
4
4
|
options?: string[];
|
|
5
5
|
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
6
|
+
label?: string;
|
|
7
|
+
type?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
ariaLabelledBy?: string;
|
|
10
|
+
ariaLabel?: string;
|
|
6
11
|
}
|
|
7
|
-
declare function FormSelect({ value, options, onChange }: Props): React.JSX.Element | null;
|
|
12
|
+
declare function FormSelect({ value, options, onChange, label, type, required, ariaLabelledBy, ariaLabel, }: Props): React.JSX.Element | null;
|
|
8
13
|
export default FormSelect;
|