docusaurus-theme-openapi-docs 4.7.0 → 5.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/lib/index.js +2 -0
- package/lib/markdown/schema.js +63 -9
- package/lib/theme/ApiExplorer/Accept/index.js +2 -1
- package/lib/theme/ApiExplorer/Authorization/index.js +12 -18
- package/lib/theme/ApiExplorer/Authorization/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.js +0 -4
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.d.ts +6 -2
- package/lib/theme/ApiExplorer/Body/FormBodyItem/index.js +191 -38
- package/lib/theme/ApiExplorer/Body/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/index.js +86 -15
- package/lib/theme/ApiExplorer/Body/resolveSchemaWithSelections.d.ts +1 -1
- package/lib/theme/ApiExplorer/Body/slice.d.ts +136 -544
- package/lib/theme/ApiExplorer/CodeSnippets/index.d.ts +2 -1
- package/lib/theme/ApiExplorer/CodeSnippets/index.js +4 -0
- package/lib/theme/ApiExplorer/CodeTabs/index.js +15 -16
- package/lib/theme/ApiExplorer/ContentType/index.js +7 -2
- package/lib/theme/ApiExplorer/EncodingSelection/slice.d.ts +17 -0
- package/lib/theme/ApiExplorer/EncodingSelection/slice.js +29 -0
- package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.d.ts +12 -0
- package/lib/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.js +39 -0
- 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/MethodEndpoint/index.js +28 -0
- 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 +6 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.js +6 -2
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.d.ts +4 -1
- package/lib/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.js +8 -3
- package/lib/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/lib/theme/ApiExplorer/ParamOptions/index.d.ts +10 -0
- package/lib/theme/ApiExplorer/ParamOptions/index.js +55 -5
- package/lib/theme/ApiExplorer/ParamOptions/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/lib/theme/ApiExplorer/Request/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Request/index.js +19 -5
- package/lib/theme/ApiExplorer/Request/makeRequest.d.ts +3 -1
- package/lib/theme/ApiExplorer/Request/makeRequest.js +19 -3
- package/lib/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/lib/theme/ApiExplorer/Response/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/Response/index.js +98 -12
- package/lib/theme/ApiExplorer/SecuritySchemes/index.js +2 -2
- package/lib/theme/ApiExplorer/Server/index.d.ts +4 -1
- package/lib/theme/ApiExplorer/Server/index.js +6 -3
- package/lib/theme/ApiExplorer/Server/slice.d.ts +1 -1
- package/lib/theme/ApiExplorer/buildPostmanRequest.d.ts +5 -2
- package/lib/theme/ApiExplorer/buildPostmanRequest.js +46 -5
- package/lib/theme/ApiExplorer/index.d.ts +1 -1
- package/lib/theme/ApiExplorer/index.js +1 -0
- package/lib/theme/ApiExplorer/persistenceMiddleware.d.ts +2 -0
- package/lib/theme/ApiItem/hooks.d.ts +1 -0
- package/lib/theme/ApiItem/index.js +2 -1
- package/lib/theme/ApiItem/store.d.ts +6 -0
- package/lib/theme/ApiItem/store.js +11 -7
- package/lib/theme/ApiTabs/index.js +10 -11
- package/lib/theme/DiscriminatorTabs/index.js +10 -11
- package/lib/theme/MimeTabs/index.js +10 -11
- package/lib/theme/OperationTabs/index.js +10 -11
- package/lib/theme/ParamsDetails/index.js +2 -2
- package/lib/theme/ParamsItem/index.js +27 -0
- package/lib/theme/RequestSchema/index.d.ts +1 -1
- package/lib/theme/RequestSchema/index.js +174 -111
- package/lib/theme/ResponseHeaders/index.js +0 -1
- package/lib/theme/ResponseSchema/index.d.ts +1 -1
- package/lib/theme/Schema/index.d.ts +1 -1
- package/lib/theme/Schema/index.js +91 -23
- package/lib/theme/SchemaItem/index.js +6 -1
- package/lib/theme/SchemaTabs/index.d.ts +1 -1
- package/lib/theme/SchemaTabs/index.js +31 -12
- package/lib/theme/StatusCodes/index.d.ts +1 -1
- package/lib/theme/styles.scss +1 -0
- package/lib/theme/translationIds.d.ts +3 -0
- package/lib/theme/translationIds.js +3 -0
- package/package.json +9 -8
- package/src/index.ts +2 -0
- package/src/markdown/schema.ts +69 -13
- package/src/theme/ApiExplorer/Accept/index.tsx +2 -1
- package/src/theme/ApiExplorer/Authorization/index.tsx +27 -33
- package/src/theme/ApiExplorer/Authorization/slice.ts +1 -1
- package/src/theme/ApiExplorer/Body/FileArrayFormBodyItem/index.tsx +2 -5
- package/src/theme/ApiExplorer/Body/FormBodyItem/index.tsx +119 -39
- package/src/theme/ApiExplorer/Body/index.tsx +88 -21
- package/src/theme/ApiExplorer/Body/resolveSchemaWithSelections.ts +1 -1
- package/src/theme/ApiExplorer/CodeSnippets/index.tsx +9 -1
- package/src/theme/ApiExplorer/CodeTabs/index.tsx +19 -19
- package/src/theme/ApiExplorer/ContentType/index.tsx +7 -4
- package/src/theme/ApiExplorer/EncodingSelection/slice.ts +31 -0
- package/src/theme/ApiExplorer/EncodingSelection/useResolvedEncoding.ts +43 -0
- package/src/theme/ApiExplorer/FormItem/_FormItem.scss +0 -5
- package/src/theme/ApiExplorer/FormItem/index.tsx +2 -17
- 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/MethodEndpoint/index.tsx +21 -0
- 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 +14 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem.tsx +14 -2
- package/src/theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem.tsx +16 -3
- package/src/theme/ApiExplorer/ParamOptions/_ParamOptions.scss +0 -9
- package/src/theme/ApiExplorer/ParamOptions/index.tsx +97 -11
- package/src/theme/ApiExplorer/ParamOptions/slice.ts +1 -1
- package/src/theme/ApiExplorer/Request/_Request.scss +11 -0
- package/src/theme/ApiExplorer/Request/index.tsx +22 -10
- package/src/theme/ApiExplorer/Request/makeRequest.ts +19 -3
- package/src/theme/ApiExplorer/Response/_Response.scss +11 -0
- package/src/theme/ApiExplorer/Response/index.tsx +37 -17
- package/src/theme/ApiExplorer/SecuritySchemes/index.tsx +2 -3
- package/src/theme/ApiExplorer/Server/index.tsx +10 -3
- package/src/theme/ApiExplorer/Server/slice.ts +1 -1
- package/src/theme/ApiExplorer/buildPostmanRequest.ts +53 -6
- package/src/theme/ApiExplorer/index.tsx +2 -1
- package/src/theme/ApiItem/index.tsx +3 -2
- package/src/theme/ApiItem/store.ts +2 -0
- package/src/theme/ApiTabs/index.tsx +14 -19
- package/src/theme/DiscriminatorTabs/index.tsx +14 -19
- package/src/theme/MimeTabs/index.tsx +15 -19
- package/src/theme/OperationTabs/index.tsx +14 -19
- package/src/theme/ParamsDetails/index.tsx +2 -3
- package/src/theme/ParamsItem/index.tsx +25 -0
- package/src/theme/RequestSchema/index.tsx +144 -87
- package/src/theme/ResponseHeaders/index.tsx +1 -2
- package/src/theme/ResponseSchema/index.tsx +1 -1
- package/src/theme/Schema/index.tsx +112 -27
- package/src/theme/SchemaItem/index.tsx +6 -1
- package/src/theme/SchemaTabs/index.tsx +42 -21
- package/src/theme/StatusCodes/index.tsx +1 -1
- package/src/theme/styles.scss +1 -0
- package/src/theme/translationIds.ts +3 -0
- package/src/theme-classic.d.ts +25 -1
- package/src/types.d.ts +15 -52
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,6 +6,7 @@ export interface Props {
|
|
|
6
6
|
postman: sdk.Request;
|
|
7
7
|
codeSamples: CodeSample[];
|
|
8
8
|
maskCredentials?: boolean;
|
|
9
|
+
requestBody?: import("docusaurus-plugin-openapi-docs/src/openapi/types").RequestBodyObject;
|
|
9
10
|
}
|
|
10
|
-
declare function CodeSnippets({ postman, codeSamples, maskCredentials: propMaskCredentials, }: Props): React.JSX.Element | null;
|
|
11
|
+
declare function CodeSnippets({ postman, codeSamples, maskCredentials: propMaskCredentials, requestBody, }: Props): React.JSX.Element | null;
|
|
11
12
|
export default CodeSnippets;
|
|
@@ -79,6 +79,7 @@ const buildPostmanRequest_1 = __importDefault(
|
|
|
79
79
|
require("@theme/ApiExplorer/buildPostmanRequest")
|
|
80
80
|
);
|
|
81
81
|
const CodeTabs_1 = __importDefault(require("@theme/ApiExplorer/CodeTabs"));
|
|
82
|
+
const useResolvedEncoding_1 = require("@theme/ApiExplorer/EncodingSelection/useResolvedEncoding");
|
|
82
83
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
83
84
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
84
85
|
const postman_code_generators_1 = __importDefault(
|
|
@@ -97,6 +98,7 @@ function CodeSnippets({
|
|
|
97
98
|
postman,
|
|
98
99
|
codeSamples,
|
|
99
100
|
maskCredentials: propMaskCredentials,
|
|
101
|
+
requestBody,
|
|
100
102
|
}) {
|
|
101
103
|
const { siteConfig } = (0, useDocusaurusContext_1.default)();
|
|
102
104
|
const contentType = (0, hooks_1.useTypedSelector)(
|
|
@@ -147,6 +149,7 @@ function CodeSnippets({
|
|
|
147
149
|
};
|
|
148
150
|
})()
|
|
149
151
|
: auth;
|
|
152
|
+
const encoding = (0, useResolvedEncoding_1.useResolvedEncoding)(requestBody);
|
|
150
153
|
// Create a Postman request object using cleanedAuth or original auth
|
|
151
154
|
const cleanedPostmanRequest = (0, buildPostmanRequest_1.default)(postman, {
|
|
152
155
|
queryParams,
|
|
@@ -158,6 +161,7 @@ function CodeSnippets({
|
|
|
158
161
|
body,
|
|
159
162
|
server,
|
|
160
163
|
auth: cleanedAuth,
|
|
164
|
+
encoding,
|
|
161
165
|
});
|
|
162
166
|
// User-defined languages array
|
|
163
167
|
// Can override languageSet, change order of langs, override options and variants
|
|
@@ -231,27 +231,26 @@ function TabContent({ lazy, children, selectedValue }) {
|
|
|
231
231
|
return react_1.default.createElement(
|
|
232
232
|
"div",
|
|
233
233
|
{ className: "margin-top--md openapi-tabs__code-content" },
|
|
234
|
-
childTabs
|
|
235
|
-
(0, react_1.cloneElement)(tabItem, {
|
|
236
|
-
key: i,
|
|
237
|
-
hidden: tabItem.props.value !== selectedValue,
|
|
238
|
-
})
|
|
239
|
-
)
|
|
234
|
+
childTabs
|
|
240
235
|
);
|
|
241
236
|
}
|
|
242
237
|
function TabsComponent(props) {
|
|
243
|
-
const tabs = (0, internal_1.
|
|
238
|
+
const tabs = (0, internal_1.useTabsContextValue)(props);
|
|
244
239
|
const { className } = props;
|
|
245
240
|
return react_1.default.createElement(
|
|
246
|
-
|
|
247
|
-
{
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
241
|
+
internal_1.TabsProvider,
|
|
242
|
+
{ value: tabs },
|
|
243
|
+
react_1.default.createElement(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
className: (0, clsx_1.default)(
|
|
247
|
+
"tabs-container openapi-tabs__code-container",
|
|
248
|
+
className
|
|
249
|
+
),
|
|
250
|
+
},
|
|
251
|
+
react_1.default.createElement(TabList, { ...props, ...tabs }),
|
|
252
|
+
react_1.default.createElement(TabContent, { ...props, ...tabs })
|
|
253
|
+
)
|
|
255
254
|
);
|
|
256
255
|
}
|
|
257
256
|
function CodeTabs(props) {
|
|
@@ -16,6 +16,7 @@ const FormItem_1 = __importDefault(require("@theme/ApiExplorer/FormItem"));
|
|
|
16
16
|
const FormSelect_1 = __importDefault(require("@theme/ApiExplorer/FormSelect"));
|
|
17
17
|
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
18
18
|
const slice_1 = require("./slice");
|
|
19
|
+
const slice_2 = require("@theme/ApiExplorer/EncodingSelection/slice");
|
|
19
20
|
function ContentType() {
|
|
20
21
|
const value = (0, hooks_1.useTypedSelector)(
|
|
21
22
|
(state) => state.contentType.value
|
|
@@ -29,11 +30,15 @@ function ContentType() {
|
|
|
29
30
|
}
|
|
30
31
|
return react_1.default.createElement(
|
|
31
32
|
FormItem_1.default,
|
|
32
|
-
|
|
33
|
+
null,
|
|
33
34
|
react_1.default.createElement(FormSelect_1.default, {
|
|
35
|
+
label: "Content-Type",
|
|
34
36
|
value: value,
|
|
35
37
|
options: options,
|
|
36
|
-
onChange: (e) =>
|
|
38
|
+
onChange: (e) => {
|
|
39
|
+
dispatch((0, slice_1.setContentType)(e.target.value));
|
|
40
|
+
dispatch((0, slice_2.clearEncodingSelection)());
|
|
41
|
+
},
|
|
37
42
|
})
|
|
38
43
|
);
|
|
39
44
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PayloadAction } from "@reduxjs/toolkit";
|
|
2
|
+
export type State = Record<string, string>;
|
|
3
|
+
export declare const slice: import("@reduxjs/toolkit").Slice<State, {
|
|
4
|
+
setFieldEncoding: (state: {
|
|
5
|
+
[x: string]: string;
|
|
6
|
+
}, action: PayloadAction<{
|
|
7
|
+
field: string;
|
|
8
|
+
contentType: string;
|
|
9
|
+
}>) => void;
|
|
10
|
+
clearEncodingSelection: () => State;
|
|
11
|
+
}, "encodingSelection", "encodingSelection", import("@reduxjs/toolkit").SliceSelectors<State>>;
|
|
12
|
+
export declare const setFieldEncoding: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
|
|
13
|
+
field: string;
|
|
14
|
+
contentType: string;
|
|
15
|
+
}, "encodingSelection/setFieldEncoding">, clearEncodingSelection: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"encodingSelection/clearEncodingSelection">;
|
|
16
|
+
declare const _default: import("redux").Reducer<State>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 _a;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.clearEncodingSelection =
|
|
11
|
+
exports.setFieldEncoding =
|
|
12
|
+
exports.slice =
|
|
13
|
+
void 0;
|
|
14
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
15
|
+
const initialState = {};
|
|
16
|
+
exports.slice = (0, toolkit_1.createSlice)({
|
|
17
|
+
name: "encodingSelection",
|
|
18
|
+
initialState,
|
|
19
|
+
reducers: {
|
|
20
|
+
setFieldEncoding: (state, action) => {
|
|
21
|
+
state[action.payload.field] = action.payload.contentType;
|
|
22
|
+
},
|
|
23
|
+
clearEncodingSelection: () => initialState,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
((_a = exports.slice.actions),
|
|
27
|
+
(exports.setFieldEncoding = _a.setFieldEncoding),
|
|
28
|
+
(exports.clearEncodingSelection = _a.clearEncodingSelection));
|
|
29
|
+
exports.default = exports.slice.reducer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RequestBodyObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
|
|
2
|
+
/**
|
|
3
|
+
* Merges the spec-declared `encoding` for the active content type with any
|
|
4
|
+
* per-field content-type selections the user has made in the UI. User picks
|
|
5
|
+
* take precedence over the spec default.
|
|
6
|
+
*
|
|
7
|
+
* Returns `undefined` when no encoding is declared for the current content
|
|
8
|
+
* type so callers can skip the encoding path entirely.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useResolvedEncoding(requestBody: RequestBodyObject | undefined): Record<string, {
|
|
11
|
+
contentType?: string;
|
|
12
|
+
}> | undefined;
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.useResolvedEncoding = useResolvedEncoding;
|
|
10
|
+
const hooks_1 = require("@theme/ApiItem/hooks");
|
|
11
|
+
/**
|
|
12
|
+
* Merges the spec-declared `encoding` for the active content type with any
|
|
13
|
+
* per-field content-type selections the user has made in the UI. User picks
|
|
14
|
+
* take precedence over the spec default.
|
|
15
|
+
*
|
|
16
|
+
* Returns `undefined` when no encoding is declared for the current content
|
|
17
|
+
* type so callers can skip the encoding path entirely.
|
|
18
|
+
*/
|
|
19
|
+
function useResolvedEncoding(requestBody) {
|
|
20
|
+
const contentType = (0, hooks_1.useTypedSelector)(
|
|
21
|
+
(state) => state.contentType.value
|
|
22
|
+
);
|
|
23
|
+
const encodingSelection = (0, hooks_1.useTypedSelector)(
|
|
24
|
+
(state) => state.encodingSelection
|
|
25
|
+
);
|
|
26
|
+
const specEncoding = requestBody?.content?.[contentType]?.encoding ?? {};
|
|
27
|
+
if (!Object.keys(specEncoding).length) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return Object.fromEntries(
|
|
31
|
+
Object.entries(specEncoding).map(([field, enc]) => [
|
|
32
|
+
field,
|
|
33
|
+
{
|
|
34
|
+
...enc,
|
|
35
|
+
contentType: encodingSelection[field] ?? enc.contentType,
|
|
36
|
+
},
|
|
37
|
+
])
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -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;
|
|
@@ -5,31 +5,112 @@
|
|
|
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 =
|
|
15
|
-
|
|
70
|
+
const react_1 = __importStar(require("react"));
|
|
71
|
+
const FormLabel_1 = __importDefault(require("@theme/ApiExplorer/FormLabel"));
|
|
72
|
+
function FormSelect({
|
|
73
|
+
value,
|
|
74
|
+
options,
|
|
75
|
+
onChange,
|
|
76
|
+
label,
|
|
77
|
+
type,
|
|
78
|
+
required,
|
|
79
|
+
ariaLabelledBy,
|
|
80
|
+
ariaLabel,
|
|
81
|
+
}) {
|
|
82
|
+
const id = (0, react_1.useId)();
|
|
16
83
|
if (!Array.isArray(options) || options.length === 0) {
|
|
17
84
|
return null;
|
|
18
85
|
}
|
|
19
86
|
return react_1.default.createElement(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
87
|
+
react_1.default.Fragment,
|
|
88
|
+
null,
|
|
89
|
+
label &&
|
|
90
|
+
react_1.default.createElement(FormLabel_1.default, {
|
|
91
|
+
htmlFor: id,
|
|
92
|
+
label: label,
|
|
93
|
+
type: type,
|
|
94
|
+
required: required,
|
|
95
|
+
}),
|
|
96
|
+
react_1.default.createElement(
|
|
97
|
+
"select",
|
|
98
|
+
{
|
|
99
|
+
id: label ? id : undefined,
|
|
100
|
+
className: "openapi-explorer__select-input",
|
|
101
|
+
value: value,
|
|
102
|
+
onChange: onChange,
|
|
103
|
+
"aria-labelledby": !label ? ariaLabelledBy : undefined,
|
|
104
|
+
"aria-label": !label && !ariaLabelledBy ? ariaLabel : undefined,
|
|
105
|
+
},
|
|
106
|
+
options.map((option) => {
|
|
107
|
+
return react_1.default.createElement(
|
|
108
|
+
"option",
|
|
109
|
+
{ key: option, value: option },
|
|
110
|
+
option
|
|
111
|
+
);
|
|
112
|
+
})
|
|
113
|
+
)
|
|
33
114
|
);
|
|
34
115
|
}
|
|
35
116
|
exports.default = FormSelect;
|
|
@@ -6,6 +6,9 @@ export interface Props {
|
|
|
6
6
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
7
7
|
paramName?: string;
|
|
8
8
|
isRequired?: boolean;
|
|
9
|
+
label?: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
required?: boolean;
|
|
9
12
|
}
|
|
10
|
-
declare function FormTextInput({ isRequired, value, placeholder, password, onChange, paramName, }: Props): React.JSX.Element;
|
|
13
|
+
declare function FormTextInput({ isRequired, value, placeholder, password, onChange, paramName, label, type, required, }: Props): React.JSX.Element;
|
|
11
14
|
export default FormTextInput;
|