@stoplight/elements-core 7.15.2 → 7.16.1
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/components/Docs/HttpOperation/Body.d.ts +1 -1
- package/components/Docs/HttpOperation/Callbacks.d.ts +14 -0
- package/components/Docs/HttpOperation/HttpOperation.d.ts +10 -0
- package/components/Docs/HttpOperation/Request.d.ts +1 -1
- package/components/Docs/HttpOperation/Responses.d.ts +2 -2
- package/index.esm.js +50 -19
- package/index.js +50 -19
- package/index.mjs +50 -19
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IHttpOperationRequestBody } from '@stoplight/types';
|
|
2
2
|
export interface BodyProps {
|
|
3
3
|
body: IHttpOperationRequestBody;
|
|
4
|
-
onChange
|
|
4
|
+
onChange?: (requestBodyIndex: number) => void;
|
|
5
5
|
}
|
|
6
6
|
export declare const isBodyEmpty: (body?: BodyProps['body']) => boolean;
|
|
7
7
|
export declare const Body: {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IHttpCallbackOperation } from '@stoplight/types';
|
|
2
|
+
export interface CallbacksProps {
|
|
3
|
+
callbacks: IHttpCallbackOperation[];
|
|
4
|
+
isCompact?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface CallbackProps {
|
|
7
|
+
data: IHttpCallbackOperation;
|
|
8
|
+
isCompact?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const Callbacks: {
|
|
11
|
+
({ callbacks, isCompact }: CallbacksProps): JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const Callback: ({ data, isCompact }: CallbackProps) => JSX.Element;
|
|
@@ -3,3 +3,13 @@ import * as React from 'react';
|
|
|
3
3
|
import { DocsComponentProps } from '..';
|
|
4
4
|
export declare type HttpOperationProps = DocsComponentProps<IHttpOperation>;
|
|
5
5
|
export declare const HttpOperation: React.FunctionComponent<HttpOperationProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
6
|
+
export declare function OperationHeader({ id, noHeading, hasBadges, name, isDeprecated, isInternal, method, path, }: {
|
|
7
|
+
id: string;
|
|
8
|
+
noHeading?: boolean;
|
|
9
|
+
hasBadges?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
isDeprecated?: boolean;
|
|
12
|
+
isInternal?: boolean;
|
|
13
|
+
method: string;
|
|
14
|
+
path: string;
|
|
15
|
+
}): JSX.Element | null;
|
|
@@ -2,7 +2,7 @@ import { IHttpOperation } from '@stoplight/types';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
interface IRequestProps {
|
|
4
4
|
operation: IHttpOperation;
|
|
5
|
-
onChange
|
|
5
|
+
onChange?: (requestBodyIndex: number) => void;
|
|
6
6
|
}
|
|
7
7
|
export declare const Request: React.FunctionComponent<IRequestProps>;
|
|
8
8
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IHttpOperationResponse } from '@stoplight/types';
|
|
2
2
|
interface ResponsesProps {
|
|
3
3
|
responses: IHttpOperationResponse[];
|
|
4
|
-
onMediaTypeChange(mediaType: string)
|
|
5
|
-
onStatusCodeChange(statusCode: string)
|
|
4
|
+
onMediaTypeChange?: (mediaType: string) => void;
|
|
5
|
+
onStatusCodeChange?: (statusCode: string) => void;
|
|
6
6
|
isCompact?: boolean;
|
|
7
7
|
}
|
|
8
8
|
export declare const Responses: {
|
package/index.esm.js
CHANGED
|
@@ -2312,22 +2312,6 @@ const enhanceVersionString = (version) => {
|
|
|
2312
2312
|
return `v${version}`;
|
|
2313
2313
|
};
|
|
2314
2314
|
|
|
2315
|
-
const operation = {
|
|
2316
|
-
id: '?http-operation-id?',
|
|
2317
|
-
iid: 'GET-simple',
|
|
2318
|
-
method: 'get',
|
|
2319
|
-
path: '/todos',
|
|
2320
|
-
summary: 'Get 200',
|
|
2321
|
-
responses: [
|
|
2322
|
-
{
|
|
2323
|
-
id: '?http-response-200?',
|
|
2324
|
-
code: '200',
|
|
2325
|
-
description: 'OK',
|
|
2326
|
-
},
|
|
2327
|
-
],
|
|
2328
|
-
servers: [{ id: '?http-server-0?', url: 'https://todos.stoplight.io' }],
|
|
2329
|
-
};
|
|
2330
|
-
|
|
2331
2315
|
const LinkHeading = React.memo(function LinkHeading(props) {
|
|
2332
2316
|
const isUsingRouter = !!useRouterType();
|
|
2333
2317
|
const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
|
|
@@ -2357,6 +2341,22 @@ const SubSectionPanel = ({ title, children, hasContent, rightComponent, defaultI
|
|
|
2357
2341
|
hasContent !== false && React.createElement(Panel.Content, null, children)));
|
|
2358
2342
|
};
|
|
2359
2343
|
|
|
2344
|
+
const operation = {
|
|
2345
|
+
id: '?http-operation-id?',
|
|
2346
|
+
iid: 'GET-simple',
|
|
2347
|
+
method: 'get',
|
|
2348
|
+
path: '/todos',
|
|
2349
|
+
summary: 'Get 200',
|
|
2350
|
+
responses: [
|
|
2351
|
+
{
|
|
2352
|
+
id: '?http-response-200?',
|
|
2353
|
+
code: '200',
|
|
2354
|
+
description: 'OK',
|
|
2355
|
+
},
|
|
2356
|
+
],
|
|
2357
|
+
servers: [{ id: '?http-server-0?', url: 'https://todos.stoplight.io' }],
|
|
2358
|
+
};
|
|
2359
|
+
|
|
2360
2360
|
const oauthFlowNames = {
|
|
2361
2361
|
implicit: 'Implicit',
|
|
2362
2362
|
authorizationCode: 'Authorization Code',
|
|
@@ -2453,7 +2453,7 @@ const Body = ({ body, onChange }) => {
|
|
|
2453
2453
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
2454
2454
|
const { nodeHasChanged } = useOptionsCtx();
|
|
2455
2455
|
React.useEffect(() => {
|
|
2456
|
-
onChange(chosenContent);
|
|
2456
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(chosenContent);
|
|
2457
2457
|
}, [chosenContent]);
|
|
2458
2458
|
if (isBodyEmpty(body))
|
|
2459
2459
|
return null;
|
|
@@ -2608,7 +2608,7 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2608
2608
|
}
|
|
2609
2609
|
}, [responses, setActiveResponseId, close]);
|
|
2610
2610
|
React.useEffect(() => {
|
|
2611
|
-
onStatusCodeChange(activeResponseId);
|
|
2611
|
+
onStatusCodeChange === null || onStatusCodeChange === void 0 ? void 0 : onStatusCodeChange(activeResponseId);
|
|
2612
2612
|
}, [activeResponseId]);
|
|
2613
2613
|
if (!responses.length)
|
|
2614
2614
|
return null;
|
|
@@ -2639,7 +2639,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2639
2639
|
const responseContent = contents[chosenContent];
|
|
2640
2640
|
const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
|
|
2641
2641
|
React.useEffect(() => {
|
|
2642
|
-
responseContent && onMediaTypeChange(responseContent.mediaType);
|
|
2642
|
+
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2643
2643
|
}, [responseContent]);
|
|
2644
2644
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
2645
2645
|
return (React.createElement(VStack, { spacing: 8, pt: 8 },
|
|
@@ -2670,7 +2670,37 @@ const codeToIntentVal = (code) => {
|
|
|
2670
2670
|
}
|
|
2671
2671
|
};
|
|
2672
2672
|
|
|
2673
|
+
const Callbacks = ({ callbacks, isCompact }) => {
|
|
2674
|
+
const [selectedCallbackIndex, setSelectedCallbackIndex] = React.useState(0);
|
|
2675
|
+
const callback = React.useMemo(() => callbacks[selectedCallbackIndex], [callbacks, selectedCallbackIndex]);
|
|
2676
|
+
return (React.createElement(VStack, { spacing: 8 },
|
|
2677
|
+
React.createElement(SectionTitle, { title: "Callbacks", isCompact: isCompact }, callbacks.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
|
|
2678
|
+
React.createElement(Select, { "aria-label": "Callback", value: String(selectedCallbackIndex), onChange: value => setSelectedCallbackIndex(parseInt(String(value), 10)), options: callbacks.map((c, index) => ({
|
|
2679
|
+
label: `${c.key} - ${c.path} - ${c.method}`,
|
|
2680
|
+
value: index,
|
|
2681
|
+
})), size: "sm" })))),
|
|
2682
|
+
callback && React.createElement(Callback, { data: callback, isCompact: isCompact })));
|
|
2683
|
+
};
|
|
2684
|
+
Callbacks.displayName = 'HttpOperation.Callbacks';
|
|
2685
|
+
const Callback = ({ data, isCompact }) => {
|
|
2686
|
+
const { nodeHasChanged } = useOptionsCtx();
|
|
2687
|
+
const isDeprecated = !!data.deprecated;
|
|
2688
|
+
const isInternal = !!data.internal;
|
|
2689
|
+
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: data.id, attr: 'description' });
|
|
2690
|
+
return (React.createElement(VStack, { spacing: 10 },
|
|
2691
|
+
React.createElement(Box, null,
|
|
2692
|
+
React.createElement(SectionSubtitle, { title: data.key, id: "callback-key" }),
|
|
2693
|
+
React.createElement(OperationHeader, { id: data.id, method: data.method, path: `/${data.path}`, isDeprecated: isDeprecated, isInternal: isInternal })),
|
|
2694
|
+
data.description && (React.createElement(Box, { pos: "relative" },
|
|
2695
|
+
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2696
|
+
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2697
|
+
React.createElement(Request, { operation: data }),
|
|
2698
|
+
data.responses && React.createElement(Responses, { responses: data.responses, isCompact: isCompact })));
|
|
2699
|
+
};
|
|
2700
|
+
Callbacks.displayName = 'HttpOperation.Callback';
|
|
2701
|
+
|
|
2673
2702
|
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
2703
|
+
var _a;
|
|
2674
2704
|
const { nodeHasChanged } = useOptionsCtx();
|
|
2675
2705
|
const data = useResolvedObject(unresolvedData);
|
|
2676
2706
|
const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
|
|
@@ -2691,6 +2721,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
2691
2721
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2692
2722
|
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
|
|
2693
2723
|
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
2724
|
+
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }),
|
|
2694
2725
|
isCompact && tryItPanel));
|
|
2695
2726
|
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
2696
2727
|
});
|
package/index.js
CHANGED
|
@@ -2369,22 +2369,6 @@ const enhanceVersionString = (version) => {
|
|
|
2369
2369
|
return `v${version}`;
|
|
2370
2370
|
};
|
|
2371
2371
|
|
|
2372
|
-
const operation = {
|
|
2373
|
-
id: '?http-operation-id?',
|
|
2374
|
-
iid: 'GET-simple',
|
|
2375
|
-
method: 'get',
|
|
2376
|
-
path: '/todos',
|
|
2377
|
-
summary: 'Get 200',
|
|
2378
|
-
responses: [
|
|
2379
|
-
{
|
|
2380
|
-
id: '?http-response-200?',
|
|
2381
|
-
code: '200',
|
|
2382
|
-
description: 'OK',
|
|
2383
|
-
},
|
|
2384
|
-
],
|
|
2385
|
-
servers: [{ id: '?http-server-0?', url: 'https://todos.stoplight.io' }],
|
|
2386
|
-
};
|
|
2387
|
-
|
|
2388
2372
|
const LinkHeading = React__namespace.memo(function LinkHeading(props) {
|
|
2389
2373
|
const isUsingRouter = !!useRouterType();
|
|
2390
2374
|
const Comp = isUsingRouter ? CustomLinkHeading : mosaic.LinkHeading;
|
|
@@ -2414,6 +2398,22 @@ const SubSectionPanel = ({ title, children, hasContent, rightComponent, defaultI
|
|
|
2414
2398
|
hasContent !== false && React__namespace.createElement(mosaic.Panel.Content, null, children)));
|
|
2415
2399
|
};
|
|
2416
2400
|
|
|
2401
|
+
const operation = {
|
|
2402
|
+
id: '?http-operation-id?',
|
|
2403
|
+
iid: 'GET-simple',
|
|
2404
|
+
method: 'get',
|
|
2405
|
+
path: '/todos',
|
|
2406
|
+
summary: 'Get 200',
|
|
2407
|
+
responses: [
|
|
2408
|
+
{
|
|
2409
|
+
id: '?http-response-200?',
|
|
2410
|
+
code: '200',
|
|
2411
|
+
description: 'OK',
|
|
2412
|
+
},
|
|
2413
|
+
],
|
|
2414
|
+
servers: [{ id: '?http-server-0?', url: 'https://todos.stoplight.io' }],
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2417
2417
|
const oauthFlowNames = {
|
|
2418
2418
|
implicit: 'Implicit',
|
|
2419
2419
|
authorizationCode: 'Authorization Code',
|
|
@@ -2510,7 +2510,7 @@ const Body = ({ body, onChange }) => {
|
|
|
2510
2510
|
const [chosenContent, setChosenContent] = React__namespace.useState(0);
|
|
2511
2511
|
const { nodeHasChanged } = useOptionsCtx();
|
|
2512
2512
|
React__namespace.useEffect(() => {
|
|
2513
|
-
onChange(chosenContent);
|
|
2513
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(chosenContent);
|
|
2514
2514
|
}, [chosenContent]);
|
|
2515
2515
|
if (isBodyEmpty(body))
|
|
2516
2516
|
return null;
|
|
@@ -2665,7 +2665,7 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2665
2665
|
}
|
|
2666
2666
|
}, [responses, setActiveResponseId, close]);
|
|
2667
2667
|
React__namespace.useEffect(() => {
|
|
2668
|
-
onStatusCodeChange(activeResponseId);
|
|
2668
|
+
onStatusCodeChange === null || onStatusCodeChange === void 0 ? void 0 : onStatusCodeChange(activeResponseId);
|
|
2669
2669
|
}, [activeResponseId]);
|
|
2670
2670
|
if (!responses.length)
|
|
2671
2671
|
return null;
|
|
@@ -2696,7 +2696,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2696
2696
|
const responseContent = contents[chosenContent];
|
|
2697
2697
|
const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
|
|
2698
2698
|
React__namespace.useEffect(() => {
|
|
2699
|
-
responseContent && onMediaTypeChange(responseContent.mediaType);
|
|
2699
|
+
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2700
2700
|
}, [responseContent]);
|
|
2701
2701
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
2702
2702
|
return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
|
|
@@ -2727,7 +2727,37 @@ const codeToIntentVal = (code) => {
|
|
|
2727
2727
|
}
|
|
2728
2728
|
};
|
|
2729
2729
|
|
|
2730
|
+
const Callbacks = ({ callbacks, isCompact }) => {
|
|
2731
|
+
const [selectedCallbackIndex, setSelectedCallbackIndex] = React__namespace.useState(0);
|
|
2732
|
+
const callback = React__namespace.useMemo(() => callbacks[selectedCallbackIndex], [callbacks, selectedCallbackIndex]);
|
|
2733
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 8 },
|
|
2734
|
+
React__namespace.createElement(SectionTitle, { title: "Callbacks", isCompact: isCompact }, callbacks.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
|
|
2735
|
+
React__namespace.createElement(mosaic.Select, { "aria-label": "Callback", value: String(selectedCallbackIndex), onChange: value => setSelectedCallbackIndex(parseInt(String(value), 10)), options: callbacks.map((c, index) => ({
|
|
2736
|
+
label: `${c.key} - ${c.path} - ${c.method}`,
|
|
2737
|
+
value: index,
|
|
2738
|
+
})), size: "sm" })))),
|
|
2739
|
+
callback && React__namespace.createElement(Callback, { data: callback, isCompact: isCompact })));
|
|
2740
|
+
};
|
|
2741
|
+
Callbacks.displayName = 'HttpOperation.Callbacks';
|
|
2742
|
+
const Callback = ({ data, isCompact }) => {
|
|
2743
|
+
const { nodeHasChanged } = useOptionsCtx();
|
|
2744
|
+
const isDeprecated = !!data.deprecated;
|
|
2745
|
+
const isInternal = !!data.internal;
|
|
2746
|
+
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: data.id, attr: 'description' });
|
|
2747
|
+
return (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
|
|
2748
|
+
React__namespace.createElement(mosaic.Box, null,
|
|
2749
|
+
React__namespace.createElement(SectionSubtitle, { title: data.key, id: "callback-key" }),
|
|
2750
|
+
React__namespace.createElement(OperationHeader, { id: data.id, method: data.method, path: `/${data.path}`, isDeprecated: isDeprecated, isInternal: isInternal })),
|
|
2751
|
+
data.description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2752
|
+
React__namespace.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2753
|
+
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
2754
|
+
React__namespace.createElement(Request, { operation: data }),
|
|
2755
|
+
data.responses && React__namespace.createElement(Responses, { responses: data.responses, isCompact: isCompact })));
|
|
2756
|
+
};
|
|
2757
|
+
Callbacks.displayName = 'HttpOperation.Callback';
|
|
2758
|
+
|
|
2730
2759
|
const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
2760
|
+
var _a;
|
|
2731
2761
|
const { nodeHasChanged } = useOptionsCtx();
|
|
2732
2762
|
const data = useResolvedObject(unresolvedData);
|
|
2733
2763
|
const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
|
|
@@ -2748,6 +2778,7 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
|
|
|
2748
2778
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
|
|
2749
2779
|
React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
|
|
2750
2780
|
data.responses && (React__namespace.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
2781
|
+
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) && React__namespace.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }),
|
|
2751
2782
|
isCompact && tryItPanel));
|
|
2752
2783
|
return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn__default["default"]('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
2753
2784
|
});
|
package/index.mjs
CHANGED
|
@@ -2312,22 +2312,6 @@ const enhanceVersionString = (version) => {
|
|
|
2312
2312
|
return `v${version}`;
|
|
2313
2313
|
};
|
|
2314
2314
|
|
|
2315
|
-
const operation = {
|
|
2316
|
-
id: '?http-operation-id?',
|
|
2317
|
-
iid: 'GET-simple',
|
|
2318
|
-
method: 'get',
|
|
2319
|
-
path: '/todos',
|
|
2320
|
-
summary: 'Get 200',
|
|
2321
|
-
responses: [
|
|
2322
|
-
{
|
|
2323
|
-
id: '?http-response-200?',
|
|
2324
|
-
code: '200',
|
|
2325
|
-
description: 'OK',
|
|
2326
|
-
},
|
|
2327
|
-
],
|
|
2328
|
-
servers: [{ id: '?http-server-0?', url: 'https://todos.stoplight.io' }],
|
|
2329
|
-
};
|
|
2330
|
-
|
|
2331
2315
|
const LinkHeading = React.memo(function LinkHeading(props) {
|
|
2332
2316
|
const isUsingRouter = !!useRouterType();
|
|
2333
2317
|
const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
|
|
@@ -2357,6 +2341,22 @@ const SubSectionPanel = ({ title, children, hasContent, rightComponent, defaultI
|
|
|
2357
2341
|
hasContent !== false && React.createElement(Panel.Content, null, children)));
|
|
2358
2342
|
};
|
|
2359
2343
|
|
|
2344
|
+
const operation = {
|
|
2345
|
+
id: '?http-operation-id?',
|
|
2346
|
+
iid: 'GET-simple',
|
|
2347
|
+
method: 'get',
|
|
2348
|
+
path: '/todos',
|
|
2349
|
+
summary: 'Get 200',
|
|
2350
|
+
responses: [
|
|
2351
|
+
{
|
|
2352
|
+
id: '?http-response-200?',
|
|
2353
|
+
code: '200',
|
|
2354
|
+
description: 'OK',
|
|
2355
|
+
},
|
|
2356
|
+
],
|
|
2357
|
+
servers: [{ id: '?http-server-0?', url: 'https://todos.stoplight.io' }],
|
|
2358
|
+
};
|
|
2359
|
+
|
|
2360
2360
|
const oauthFlowNames = {
|
|
2361
2361
|
implicit: 'Implicit',
|
|
2362
2362
|
authorizationCode: 'Authorization Code',
|
|
@@ -2453,7 +2453,7 @@ const Body = ({ body, onChange }) => {
|
|
|
2453
2453
|
const [chosenContent, setChosenContent] = React.useState(0);
|
|
2454
2454
|
const { nodeHasChanged } = useOptionsCtx();
|
|
2455
2455
|
React.useEffect(() => {
|
|
2456
|
-
onChange(chosenContent);
|
|
2456
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(chosenContent);
|
|
2457
2457
|
}, [chosenContent]);
|
|
2458
2458
|
if (isBodyEmpty(body))
|
|
2459
2459
|
return null;
|
|
@@ -2608,7 +2608,7 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
|
|
|
2608
2608
|
}
|
|
2609
2609
|
}, [responses, setActiveResponseId, close]);
|
|
2610
2610
|
React.useEffect(() => {
|
|
2611
|
-
onStatusCodeChange(activeResponseId);
|
|
2611
|
+
onStatusCodeChange === null || onStatusCodeChange === void 0 ? void 0 : onStatusCodeChange(activeResponseId);
|
|
2612
2612
|
}, [activeResponseId]);
|
|
2613
2613
|
if (!responses.length)
|
|
2614
2614
|
return null;
|
|
@@ -2639,7 +2639,7 @@ const Response = ({ response, onMediaTypeChange }) => {
|
|
|
2639
2639
|
const responseContent = contents[chosenContent];
|
|
2640
2640
|
const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
|
|
2641
2641
|
React.useEffect(() => {
|
|
2642
|
-
responseContent && onMediaTypeChange(responseContent.mediaType);
|
|
2642
|
+
responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
|
|
2643
2643
|
}, [responseContent]);
|
|
2644
2644
|
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
|
|
2645
2645
|
return (React.createElement(VStack, { spacing: 8, pt: 8 },
|
|
@@ -2670,7 +2670,37 @@ const codeToIntentVal = (code) => {
|
|
|
2670
2670
|
}
|
|
2671
2671
|
};
|
|
2672
2672
|
|
|
2673
|
+
const Callbacks = ({ callbacks, isCompact }) => {
|
|
2674
|
+
const [selectedCallbackIndex, setSelectedCallbackIndex] = React.useState(0);
|
|
2675
|
+
const callback = React.useMemo(() => callbacks[selectedCallbackIndex], [callbacks, selectedCallbackIndex]);
|
|
2676
|
+
return (React.createElement(VStack, { spacing: 8 },
|
|
2677
|
+
React.createElement(SectionTitle, { title: "Callbacks", isCompact: isCompact }, callbacks.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
|
|
2678
|
+
React.createElement(Select, { "aria-label": "Callback", value: String(selectedCallbackIndex), onChange: value => setSelectedCallbackIndex(parseInt(String(value), 10)), options: callbacks.map((c, index) => ({
|
|
2679
|
+
label: `${c.key} - ${c.path} - ${c.method}`,
|
|
2680
|
+
value: index,
|
|
2681
|
+
})), size: "sm" })))),
|
|
2682
|
+
callback && React.createElement(Callback, { data: callback, isCompact: isCompact })));
|
|
2683
|
+
};
|
|
2684
|
+
Callbacks.displayName = 'HttpOperation.Callbacks';
|
|
2685
|
+
const Callback = ({ data, isCompact }) => {
|
|
2686
|
+
const { nodeHasChanged } = useOptionsCtx();
|
|
2687
|
+
const isDeprecated = !!data.deprecated;
|
|
2688
|
+
const isInternal = !!data.internal;
|
|
2689
|
+
const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: data.id, attr: 'description' });
|
|
2690
|
+
return (React.createElement(VStack, { spacing: 10 },
|
|
2691
|
+
React.createElement(Box, null,
|
|
2692
|
+
React.createElement(SectionSubtitle, { title: data.key, id: "callback-key" }),
|
|
2693
|
+
React.createElement(OperationHeader, { id: data.id, method: data.method, path: `/${data.path}`, isDeprecated: isDeprecated, isInternal: isInternal })),
|
|
2694
|
+
data.description && (React.createElement(Box, { pos: "relative" },
|
|
2695
|
+
React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
|
|
2696
|
+
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2697
|
+
React.createElement(Request, { operation: data }),
|
|
2698
|
+
data.responses && React.createElement(Responses, { responses: data.responses, isCompact: isCompact })));
|
|
2699
|
+
};
|
|
2700
|
+
Callbacks.displayName = 'HttpOperation.Callback';
|
|
2701
|
+
|
|
2673
2702
|
const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
|
|
2703
|
+
var _a;
|
|
2674
2704
|
const { nodeHasChanged } = useOptionsCtx();
|
|
2675
2705
|
const data = useResolvedObject(unresolvedData);
|
|
2676
2706
|
const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
|
|
@@ -2691,6 +2721,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
|
|
|
2691
2721
|
React.createElement(NodeAnnotation, { change: descriptionChanged }))),
|
|
2692
2722
|
React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
|
|
2693
2723
|
data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
|
|
2724
|
+
((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) && React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }),
|
|
2694
2725
|
isCompact && tryItPanel));
|
|
2695
2726
|
return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
|
|
2696
2727
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements-core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.16.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"web-components.min.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@stoplight/json": "^3.18.1",
|
|
29
29
|
"@stoplight/json-schema-ref-parser": "^9.0.5",
|
|
30
30
|
"@stoplight/json-schema-sampler": "0.2.3",
|
|
31
|
-
"@stoplight/json-schema-tree": "^
|
|
32
|
-
"@stoplight/json-schema-viewer": "^4.14.
|
|
31
|
+
"@stoplight/json-schema-tree": "^3.0.0",
|
|
32
|
+
"@stoplight/json-schema-viewer": "^4.14.1",
|
|
33
33
|
"@stoplight/markdown-viewer": "^5.6.0",
|
|
34
34
|
"@stoplight/mosaic": "^1.46.1",
|
|
35
35
|
"@stoplight/mosaic-code-editor": "^1.46.1",
|