@stoplight/elements-core 7.15.1 → 7.16.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.
@@ -1,13 +1,13 @@
1
- declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
1
+ declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, {
2
2
  data: any;
3
3
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
4
  export default meta;
5
- export declare const Basic: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
5
+ export declare const Basic: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, {
6
6
  data: any;
7
7
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
8
- export declare const KitchenSink: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
8
+ export declare const KitchenSink: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, {
9
9
  data: any;
10
10
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
11
- export declare const MultipleTryIts: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
11
+ export declare const MultipleTryIts: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, {
12
12
  data: any;
13
13
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,5 +1,6 @@
1
1
  import { IMarkdownViewerProps } from '@stoplight/markdown-viewer';
2
+ import * as React from 'react';
2
3
  import { DocsComponentProps } from '..';
3
4
  declare type ArticleProps = DocsComponentProps<IMarkdownViewerProps['markdown']>;
4
- export declare const Article: import("react").FunctionComponent<ArticleProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
5
+ export declare const Article: React.FunctionComponent<ArticleProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
5
6
  export {};
@@ -1,5 +1,5 @@
1
1
  import { Story } from '@storybook/react';
2
2
  import { DocsProps } from './Docs';
3
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, DocsProps>;
3
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, DocsProps>;
4
4
  export default _default;
5
5
  export declare const DocsStory: Story<DocsProps>;
@@ -1,7 +1,7 @@
1
1
  import { IHttpOperationRequestBody } from '@stoplight/types';
2
2
  export interface BodyProps {
3
3
  body: IHttpOperationRequestBody;
4
- onChange: (requestBodyIndex: number) => void;
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;
@@ -1,4 +1,15 @@
1
1
  import { IHttpOperation } from '@stoplight/types';
2
+ import * as React from 'react';
2
3
  import { DocsComponentProps } from '..';
3
4
  export declare type HttpOperationProps = DocsComponentProps<IHttpOperation>;
4
- export declare const HttpOperation: import("react").FunctionComponent<HttpOperationProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
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;
@@ -1,7 +1,7 @@
1
- declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
1
+ declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, {
2
2
  data: any;
3
3
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
4
  export default meta;
5
- export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
5
+ export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, {
6
6
  data: any;
7
7
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -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: (requestBodyIndex: number) => void;
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): void;
5
- onStatusCodeChange(statusCode: string): void;
4
+ onMediaTypeChange?: (mediaType: string) => void;
5
+ onStatusCodeChange?: (statusCode: string) => void;
6
6
  isCompact?: boolean;
7
7
  }
8
8
  export declare const Responses: {
@@ -1,4 +1,5 @@
1
1
  import { IHttpService } from '@stoplight/types';
2
+ import * as React from 'react';
2
3
  import { DocsComponentProps } from '..';
3
4
  export declare type HttpServiceProps = DocsComponentProps<Partial<IHttpService>>;
4
- export declare const HttpService: import("react").FunctionComponent<HttpServiceProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
5
+ export declare const HttpService: React.FunctionComponent<HttpServiceProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,7 +1,7 @@
1
- declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
1
+ declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, {
2
2
  data: any;
3
3
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
4
  export default meta;
5
- export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
5
+ export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, {
6
6
  data: any;
7
7
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,4 +1,5 @@
1
1
  import { JSONSchema7 } from 'json-schema';
2
+ import * as React from 'react';
2
3
  import { DocsComponentProps } from '..';
3
4
  export declare type ModelProps = DocsComponentProps<JSONSchema7>;
4
- export declare const Model: import("react").FunctionComponent<ModelProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
5
+ export declare const Model: React.FunctionComponent<ModelProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,7 +1,7 @@
1
- declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, {
1
+ declare const meta: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, {
2
2
  data: any;
3
3
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
4
  export default meta;
5
- export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, {
5
+ export declare const Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, {
6
6
  data: any;
7
7
  } & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
@@ -1,4 +1,4 @@
1
1
  import { RequestSamplesProps } from './RequestSamples';
2
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, RequestSamplesProps>;
2
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, RequestSamplesProps>;
3
3
  export default _default;
4
- export declare const HoistedStory: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, RequestSamplesProps>;
4
+ export declare const HoistedStory: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, RequestSamplesProps>;
@@ -1,4 +1,4 @@
1
1
  import { ResponseExamplesProps } from './ResponseExamples';
2
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, ResponseExamplesProps>;
2
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, ResponseExamplesProps>;
3
3
  export default _default;
4
- export declare const HoistedStory: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, ResponseExamplesProps>;
4
+ export declare const HoistedStory: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, ResponseExamplesProps>;
@@ -1,13 +1,13 @@
1
1
  import { TryItProps } from './TryIt';
2
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
2
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
3
3
  export default _default;
4
- export declare const SimpleGET: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
5
- export declare const WithParameters: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
6
- export declare const WithVariables: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
7
- export declare const UrlEncoded: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
8
- export declare const UrlEncodedOneOf: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
9
- export declare const Multipart: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
10
- export declare const RequestBodySchema: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
11
- export declare const RequestBodyExamples: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
12
- export declare const TryItAuth: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
13
- export declare const TryItAuthDuplicated: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItProps>;
4
+ export declare const SimpleGET: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
5
+ export declare const WithParameters: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
6
+ export declare const WithVariables: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
7
+ export declare const UrlEncoded: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
8
+ export declare const UrlEncodedOneOf: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
9
+ export declare const Multipart: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
10
+ export declare const RequestBodySchema: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
11
+ export declare const RequestBodyExamples: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
12
+ export declare const TryItAuth: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
13
+ export declare const TryItAuthDuplicated: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItProps>;
@@ -1,5 +1,5 @@
1
1
  import { TryItWithRequestSamplesProps } from './TryItWithRequestSamples';
2
- declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0a347bb9").R, TryItWithRequestSamplesProps>;
2
+ declare const _default: import("@storybook/types").ComponentAnnotations<import("@storybook/react/dist/types-0fc72a6d").R, TryItWithRequestSamplesProps>;
3
3
  export default _default;
4
- export declare const WithParameters: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItWithRequestSamplesProps>;
5
- export declare const WithVariables: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, TryItWithRequestSamplesProps>;
4
+ export declare const WithParameters: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItWithRequestSamplesProps>;
5
+ export declare const WithVariables: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, TryItWithRequestSamplesProps>;
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;
@@ -2519,7 +2519,12 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2519
2519
  const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
2520
2520
  const paramDescription = description || paramSchema.description;
2521
2521
  const paramDeprecated = !!(deprecated || paramSchema.deprecated);
2522
- const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
2522
+ const paramStyleUnspecified = style === HttpParamStyles.Unspecified;
2523
+ const paramStyle = paramStyleUnspecified
2524
+ ? undefined
2525
+ : style && defaultStyle[parameterType] !== style
2526
+ ? readableStyles[style] || style
2527
+ : undefined;
2523
2528
  if (isPlainObject$1(schema.properties)) {
2524
2529
  schema.properties[p.name] = Object.assign(Object.assign({}, paramSchema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (isPlainObject$1(paramSchema['x-stoplight']) ? paramSchema['x-stoplight'] : {})), { id: p.id }) });
2525
2530
  }
@@ -2603,7 +2608,7 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
2603
2608
  }
2604
2609
  }, [responses, setActiveResponseId, close]);
2605
2610
  React.useEffect(() => {
2606
- onStatusCodeChange(activeResponseId);
2611
+ onStatusCodeChange === null || onStatusCodeChange === void 0 ? void 0 : onStatusCodeChange(activeResponseId);
2607
2612
  }, [activeResponseId]);
2608
2613
  if (!responses.length)
2609
2614
  return null;
@@ -2634,7 +2639,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2634
2639
  const responseContent = contents[chosenContent];
2635
2640
  const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
2636
2641
  React.useEffect(() => {
2637
- responseContent && onMediaTypeChange(responseContent.mediaType);
2642
+ responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
2638
2643
  }, [responseContent]);
2639
2644
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
2640
2645
  return (React.createElement(VStack, { spacing: 8, pt: 8 },
@@ -2665,7 +2670,37 @@ const codeToIntentVal = (code) => {
2665
2670
  }
2666
2671
  };
2667
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
+
2668
2702
  const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
2703
+ var _a;
2669
2704
  const { nodeHasChanged } = useOptionsCtx();
2670
2705
  const data = useResolvedObject(unresolvedData);
2671
2706
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
@@ -2686,6 +2721,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
2686
2721
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2687
2722
  React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
2688
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 }),
2689
2725
  isCompact && tryItPanel));
2690
2726
  return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
2691
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;
@@ -2576,7 +2576,12 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2576
2576
  const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
2577
2577
  const paramDescription = description || paramSchema.description;
2578
2578
  const paramDeprecated = !!(deprecated || paramSchema.deprecated);
2579
- const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
2579
+ const paramStyleUnspecified = style === types.HttpParamStyles.Unspecified;
2580
+ const paramStyle = paramStyleUnspecified
2581
+ ? undefined
2582
+ : style && defaultStyle[parameterType] !== style
2583
+ ? readableStyles[style] || style
2584
+ : undefined;
2580
2585
  if (json.isPlainObject(schema.properties)) {
2581
2586
  schema.properties[p.name] = Object.assign(Object.assign({}, paramSchema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (json.isPlainObject(paramSchema['x-stoplight']) ? paramSchema['x-stoplight'] : {})), { id: p.id }) });
2582
2587
  }
@@ -2660,7 +2665,7 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
2660
2665
  }
2661
2666
  }, [responses, setActiveResponseId, close]);
2662
2667
  React__namespace.useEffect(() => {
2663
- onStatusCodeChange(activeResponseId);
2668
+ onStatusCodeChange === null || onStatusCodeChange === void 0 ? void 0 : onStatusCodeChange(activeResponseId);
2664
2669
  }, [activeResponseId]);
2665
2670
  if (!responses.length)
2666
2671
  return null;
@@ -2691,7 +2696,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2691
2696
  const responseContent = contents[chosenContent];
2692
2697
  const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
2693
2698
  React__namespace.useEffect(() => {
2694
- responseContent && onMediaTypeChange(responseContent.mediaType);
2699
+ responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
2695
2700
  }, [responseContent]);
2696
2701
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
2697
2702
  return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
@@ -2722,7 +2727,37 @@ const codeToIntentVal = (code) => {
2722
2727
  }
2723
2728
  };
2724
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
+
2725
2759
  const HttpOperationComponent = React__namespace.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
2760
+ var _a;
2726
2761
  const { nodeHasChanged } = useOptionsCtx();
2727
2762
  const data = useResolvedObject(unresolvedData);
2728
2763
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
@@ -2743,6 +2778,7 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
2743
2778
  React__namespace.createElement(mosaic.NodeAnnotation, { change: descriptionChanged }))),
2744
2779
  React__namespace.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
2745
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 }),
2746
2782
  isCompact && tryItPanel));
2747
2783
  return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn__default["default"]('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
2748
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;
@@ -2519,7 +2519,12 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2519
2519
  const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
2520
2520
  const paramDescription = description || paramSchema.description;
2521
2521
  const paramDeprecated = !!(deprecated || paramSchema.deprecated);
2522
- const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
2522
+ const paramStyleUnspecified = style === HttpParamStyles.Unspecified;
2523
+ const paramStyle = paramStyleUnspecified
2524
+ ? undefined
2525
+ : style && defaultStyle[parameterType] !== style
2526
+ ? readableStyles[style] || style
2527
+ : undefined;
2523
2528
  if (isPlainObject$1(schema.properties)) {
2524
2529
  schema.properties[p.name] = Object.assign(Object.assign({}, paramSchema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (isPlainObject$1(paramSchema['x-stoplight']) ? paramSchema['x-stoplight'] : {})), { id: p.id }) });
2525
2530
  }
@@ -2603,7 +2608,7 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
2603
2608
  }
2604
2609
  }, [responses, setActiveResponseId, close]);
2605
2610
  React.useEffect(() => {
2606
- onStatusCodeChange(activeResponseId);
2611
+ onStatusCodeChange === null || onStatusCodeChange === void 0 ? void 0 : onStatusCodeChange(activeResponseId);
2607
2612
  }, [activeResponseId]);
2608
2613
  if (!responses.length)
2609
2614
  return null;
@@ -2634,7 +2639,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2634
2639
  const responseContent = contents[chosenContent];
2635
2640
  const schema = responseContent === null || responseContent === void 0 ? void 0 : responseContent.schema;
2636
2641
  React.useEffect(() => {
2637
- responseContent && onMediaTypeChange(responseContent.mediaType);
2642
+ responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
2638
2643
  }, [responseContent]);
2639
2644
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
2640
2645
  return (React.createElement(VStack, { spacing: 8, pt: 8 },
@@ -2665,7 +2670,37 @@ const codeToIntentVal = (code) => {
2665
2670
  }
2666
2671
  };
2667
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
+
2668
2702
  const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
2703
+ var _a;
2669
2704
  const { nodeHasChanged } = useOptionsCtx();
2670
2705
  const data = useResolvedObject(unresolvedData);
2671
2706
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
@@ -2686,6 +2721,7 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
2686
2721
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
2687
2722
  React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data }),
2688
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 }),
2689
2725
  isCompact && tryItPanel));
2690
2726
  return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
2691
2727
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.15.1",
3
+ "version": "7.16.0",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -35,7 +35,7 @@
35
35
  "@stoplight/mosaic-code-editor": "^1.46.1",
36
36
  "@stoplight/mosaic-code-viewer": "^1.46.1",
37
37
  "@stoplight/path": "^1.3.2",
38
- "@stoplight/react-error-boundary": "^2.0.0",
38
+ "@stoplight/react-error-boundary": "^3.0.0",
39
39
  "@stoplight/types": "^14.0.0",
40
40
  "@stoplight/yaml": "^4.2.3",
41
41
  "classnames": "^2.2.6",