@stoplight/elements 8.1.3 → 8.3.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/API/APIWithResponsiveSidebarLayout.d.ts +2 -0
- package/components/API/APIWithSidebarLayout.d.ts +2 -0
- package/components/API/APIWithStackedLayout.d.ts +2 -0
- package/containers/API.d.ts +2 -0
- package/containers/API.stories.d.ts +1 -0
- package/containers/story-helper.d.ts +2 -0
- package/index.esm.js +13 -11
- package/index.js +12 -10
- package/index.mjs +13 -11
- package/package.json +3 -3
- package/web-components.min.js +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExportButtonProps } from '@stoplight/elements-core';
|
|
2
|
+
import { ExtensionAddonRenderer } from '@stoplight/elements-core/components/Docs';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { ServiceNode } from '../../utils/oas/types';
|
|
4
5
|
declare type SidebarLayoutProps = {
|
|
@@ -12,6 +13,7 @@ declare type SidebarLayoutProps = {
|
|
|
12
13
|
tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
|
|
13
14
|
tryItCorsProxy?: string;
|
|
14
15
|
compact?: number | boolean;
|
|
16
|
+
renderExtensionAddon?: ExtensionAddonRenderer;
|
|
15
17
|
};
|
|
16
18
|
export declare const APIWithResponsiveSidebarLayout: React.FC<SidebarLayoutProps>;
|
|
17
19
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExportButtonProps, TableOfContentsItem } from '@stoplight/elements-core';
|
|
2
|
+
import { ExtensionAddonRenderer } from '@stoplight/elements-core/components/Docs';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { ServiceNode } from '../../utils/oas/types';
|
|
4
5
|
declare type SidebarLayoutProps = {
|
|
@@ -11,6 +12,7 @@ declare type SidebarLayoutProps = {
|
|
|
11
12
|
exportProps?: ExportButtonProps;
|
|
12
13
|
tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
|
|
13
14
|
tryItCorsProxy?: string;
|
|
15
|
+
renderExtensionAddon?: ExtensionAddonRenderer;
|
|
14
16
|
};
|
|
15
17
|
export declare const APIWithSidebarLayout: React.FC<SidebarLayoutProps>;
|
|
16
18
|
declare type SidebarProps = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ExportButtonProps } from '@stoplight/elements-core';
|
|
2
|
+
import { ExtensionAddonRenderer } from '@stoplight/elements-core/components/Docs';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { ServiceNode } from '../../utils/oas/types';
|
|
4
5
|
declare type TryItCredentialsPolicy = 'omit' | 'include' | 'same-origin';
|
|
@@ -18,6 +19,7 @@ declare type StackedLayoutProps = {
|
|
|
18
19
|
tryItCorsProxy?: string;
|
|
19
20
|
showPoweredByLink?: boolean;
|
|
20
21
|
location: Location;
|
|
22
|
+
renderExtensionAddon?: ExtensionAddonRenderer;
|
|
21
23
|
};
|
|
22
24
|
export declare const APIWithStackedLayout: React.FC<StackedLayoutProps>;
|
|
23
25
|
export {};
|
package/containers/API.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RoutingProps } from '@stoplight/elements-core';
|
|
2
|
+
import { ExtensionAddonRenderer } from '@stoplight/elements-core/components/Docs';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
export declare type APIProps = APIPropsWithDocument | APIPropsWithUrl;
|
|
4
5
|
export declare type APIPropsWithUrl = {
|
|
@@ -18,6 +19,7 @@ export interface CommonAPIProps extends RoutingProps {
|
|
|
18
19
|
tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
|
|
19
20
|
tryItCorsProxy?: string;
|
|
20
21
|
maxRefDepth?: number;
|
|
22
|
+
renderExtensionAddon?: ExtensionAddonRenderer;
|
|
21
23
|
}
|
|
22
24
|
export declare const APIImpl: React.FC<APIProps>;
|
|
23
25
|
export declare const API: React.FC<APIProps>;
|
|
@@ -55,3 +55,4 @@ export declare const Box: import("@storybook/types").AnnotatedStoryFn<import("@s
|
|
|
55
55
|
export declare const DigitalOcean: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
56
56
|
export declare const Github: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
57
57
|
export declare const Instagram: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
58
|
+
export declare const WithExtensionRenderer: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHttpOperation, isHttpWebhookOperation, isHttpService, HttpMethodColors, DeprecatedBadge, ParsedDocs, TryItWithRequestSamples, Docs, ResponsiveSidebarLayout, SidebarLayout, Logo, TableOfContents, PoweredByLink, slugify, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useResponsiveLayout, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
1
|
+
import { isHttpOperation, isHttpWebhookOperation, isHttpService, HttpMethodColors, DeprecatedBadge, ParsedDocs, TryItWithRequestSamples, Docs, ResponsiveSidebarLayout, ElementsOptionsProvider, SidebarLayout, Logo, TableOfContents, PoweredByLink, slugify, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useResponsiveLayout, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
2
2
|
import { Box, Flex, Icon, Tabs, TabList, Tab, TabPanels, TabPanel, Heading } from '@stoplight/mosaic';
|
|
3
3
|
import { NodeType } from '@stoplight/types';
|
|
4
4
|
import cn from 'classnames';
|
|
@@ -185,14 +185,14 @@ const LocationContext = React.createContext({
|
|
|
185
185
|
},
|
|
186
186
|
});
|
|
187
187
|
LocationContext.displayName = 'LocationContext';
|
|
188
|
-
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, showPoweredByLink = true, location, }) => {
|
|
188
|
+
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
|
|
189
189
|
const { groups: operationGroups } = computeTagGroups(serviceNode, NodeType.HttpOperation);
|
|
190
190
|
const { groups: webhookGroups } = computeTagGroups(serviceNode, NodeType.HttpWebhook);
|
|
191
191
|
return (React.createElement(LocationContext.Provider, { value: { location } },
|
|
192
192
|
React.createElement(TryItContext.Provider, { value: { hideTryIt, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
|
|
193
193
|
React.createElement(Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
|
|
194
194
|
React.createElement(Box, { w: "full", borderB: true },
|
|
195
|
-
React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy })),
|
|
195
|
+
React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon })),
|
|
196
196
|
operationGroups.length > 0 && webhookGroups.length > 0 ? React.createElement(Heading, { size: 2 }, "Endpoints") : null,
|
|
197
197
|
operationGroups.map(group => (React.createElement(Group, { key: group.title, group: group }))),
|
|
198
198
|
webhookGroups.length > 0 ? React.createElement(Heading, { size: 2 }, "Webhooks") : null,
|
|
@@ -269,7 +269,7 @@ const Collapse = ({ isOpen, children }) => {
|
|
|
269
269
|
};
|
|
270
270
|
Collapse.displayName = 'Collapse';
|
|
271
271
|
|
|
272
|
-
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
272
|
+
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
|
|
273
273
|
const container = React.useRef(null);
|
|
274
274
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
275
275
|
const location = useLocation();
|
|
@@ -291,10 +291,11 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
|
|
|
291
291
|
container.current.scrollIntoView();
|
|
292
292
|
}
|
|
293
293
|
};
|
|
294
|
-
return (React.createElement(ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React.createElement(
|
|
294
|
+
return (React.createElement(ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React.createElement(ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
295
|
+
React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
295
296
|
};
|
|
296
297
|
|
|
297
|
-
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
298
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
|
|
298
299
|
const container = React.useRef(null);
|
|
299
300
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
300
301
|
const location = useLocation();
|
|
@@ -312,7 +313,8 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
312
313
|
return React.createElement(Redirect, { to: "/" });
|
|
313
314
|
}
|
|
314
315
|
const sidebar = (React.createElement(Sidebar, { serviceNode: serviceNode, logo: logo, container: container, pathname: pathname, tree: tree }));
|
|
315
|
-
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(
|
|
316
|
+
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
317
|
+
React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
316
318
|
};
|
|
317
319
|
const Sidebar = ({ serviceNode, logo, container, pathname, tree }) => {
|
|
318
320
|
const handleTocClick = () => {
|
|
@@ -590,7 +592,7 @@ const propsAreWithDocument = (props) => {
|
|
|
590
592
|
return props.hasOwnProperty('apiDescriptionDocument');
|
|
591
593
|
};
|
|
592
594
|
const APIImpl = props => {
|
|
593
|
-
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
595
|
+
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
|
|
594
596
|
const location = useLocation();
|
|
595
597
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
|
596
598
|
const { isResponsiveLayoutEnabled } = useResponsiveLayout();
|
|
@@ -620,9 +622,9 @@ const APIImpl = props => {
|
|
|
620
622
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
621
623
|
}
|
|
622
624
|
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
623
|
-
layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, location: location })),
|
|
624
|
-
layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })),
|
|
625
|
-
layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, compact: isResponsiveLayoutEnabled }))));
|
|
625
|
+
layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
|
|
626
|
+
layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
|
|
627
|
+
layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
|
|
626
628
|
};
|
|
627
629
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
628
630
|
|
package/index.js
CHANGED
|
@@ -218,14 +218,14 @@ const LocationContext = React__namespace.createContext({
|
|
|
218
218
|
},
|
|
219
219
|
});
|
|
220
220
|
LocationContext.displayName = 'LocationContext';
|
|
221
|
-
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, showPoweredByLink = true, location, }) => {
|
|
221
|
+
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
|
|
222
222
|
const { groups: operationGroups } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
|
|
223
223
|
const { groups: webhookGroups } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
|
|
224
224
|
return (React__namespace.createElement(LocationContext.Provider, { value: { location } },
|
|
225
225
|
React__namespace.createElement(TryItContext.Provider, { value: { hideTryIt, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
|
|
226
226
|
React__namespace.createElement(mosaic.Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
|
|
227
227
|
React__namespace.createElement(mosaic.Box, { w: "full", borderB: true },
|
|
228
|
-
React__namespace.createElement(elementsCore.Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: types.NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy })),
|
|
228
|
+
React__namespace.createElement(elementsCore.Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: types.NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon })),
|
|
229
229
|
operationGroups.length > 0 && webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Endpoints") : null,
|
|
230
230
|
operationGroups.map(group => (React__namespace.createElement(Group, { key: group.title, group: group }))),
|
|
231
231
|
webhookGroups.length > 0 ? React__namespace.createElement(mosaic.Heading, { size: 2 }, "Webhooks") : null,
|
|
@@ -302,7 +302,7 @@ const Collapse = ({ isOpen, children }) => {
|
|
|
302
302
|
};
|
|
303
303
|
Collapse.displayName = 'Collapse';
|
|
304
304
|
|
|
305
|
-
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
305
|
+
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
|
|
306
306
|
const container = React__namespace.useRef(null);
|
|
307
307
|
const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
308
308
|
const location = reactRouterDom.useLocation();
|
|
@@ -324,10 +324,11 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
|
|
|
324
324
|
container.current.scrollIntoView();
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
|
-
return (React__namespace.createElement(elementsCore.ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React__namespace.createElement(elementsCore.
|
|
327
|
+
return (React__namespace.createElement(elementsCore.ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React__namespace.createElement(elementsCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
328
|
+
React__namespace.createElement(elementsCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
328
329
|
};
|
|
329
330
|
|
|
330
|
-
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
331
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
|
|
331
332
|
const container = React__namespace.useRef(null);
|
|
332
333
|
const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
333
334
|
const location = reactRouterDom.useLocation();
|
|
@@ -345,7 +346,8 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
345
346
|
return React__namespace.createElement(reactRouterDom.Redirect, { to: "/" });
|
|
346
347
|
}
|
|
347
348
|
const sidebar = (React__namespace.createElement(Sidebar, { serviceNode: serviceNode, logo: logo, container: container, pathname: pathname, tree: tree }));
|
|
348
|
-
return (React__namespace.createElement(elementsCore.SidebarLayout, { ref: container, sidebar: sidebar }, node && (React__namespace.createElement(elementsCore.
|
|
349
|
+
return (React__namespace.createElement(elementsCore.SidebarLayout, { ref: container, sidebar: sidebar }, node && (React__namespace.createElement(elementsCore.ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
350
|
+
React__namespace.createElement(elementsCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
349
351
|
};
|
|
350
352
|
const Sidebar = ({ serviceNode, logo, container, pathname, tree }) => {
|
|
351
353
|
const handleTocClick = () => {
|
|
@@ -623,7 +625,7 @@ const propsAreWithDocument = (props) => {
|
|
|
623
625
|
return props.hasOwnProperty('apiDescriptionDocument');
|
|
624
626
|
};
|
|
625
627
|
const APIImpl = props => {
|
|
626
|
-
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
628
|
+
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
|
|
627
629
|
const location = reactRouterDom.useLocation();
|
|
628
630
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
|
629
631
|
const { isResponsiveLayoutEnabled } = elementsCore.useResponsiveLayout();
|
|
@@ -653,9 +655,9 @@ const APIImpl = props => {
|
|
|
653
655
|
React__namespace.createElement(elementsCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
654
656
|
}
|
|
655
657
|
return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
656
|
-
layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, location: location })),
|
|
657
|
-
layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })),
|
|
658
|
-
layout === 'responsive' && (React__namespace.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, compact: isResponsiveLayoutEnabled }))));
|
|
658
|
+
layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
|
|
659
|
+
layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
|
|
660
|
+
layout === 'responsive' && (React__namespace.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
|
|
659
661
|
};
|
|
660
662
|
const API = flow__default["default"](elementsCore.withRouter, elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(APIImpl);
|
|
661
663
|
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHttpOperation, isHttpWebhookOperation, isHttpService, HttpMethodColors, DeprecatedBadge, ParsedDocs, TryItWithRequestSamples, Docs, ResponsiveSidebarLayout, SidebarLayout, Logo, TableOfContents, PoweredByLink, slugify, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useResponsiveLayout, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
1
|
+
import { isHttpOperation, isHttpWebhookOperation, isHttpService, HttpMethodColors, DeprecatedBadge, ParsedDocs, TryItWithRequestSamples, Docs, ResponsiveSidebarLayout, ElementsOptionsProvider, SidebarLayout, Logo, TableOfContents, PoweredByLink, slugify, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useResponsiveLayout, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
2
2
|
import { Box, Flex, Icon, Tabs, TabList, Tab, TabPanels, TabPanel, Heading } from '@stoplight/mosaic';
|
|
3
3
|
import { NodeType } from '@stoplight/types';
|
|
4
4
|
import cn from 'classnames';
|
|
@@ -185,14 +185,14 @@ const LocationContext = React.createContext({
|
|
|
185
185
|
},
|
|
186
186
|
});
|
|
187
187
|
LocationContext.displayName = 'LocationContext';
|
|
188
|
-
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, showPoweredByLink = true, location, }) => {
|
|
188
|
+
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
|
|
189
189
|
const { groups: operationGroups } = computeTagGroups(serviceNode, NodeType.HttpOperation);
|
|
190
190
|
const { groups: webhookGroups } = computeTagGroups(serviceNode, NodeType.HttpWebhook);
|
|
191
191
|
return (React.createElement(LocationContext.Provider, { value: { location } },
|
|
192
192
|
React.createElement(TryItContext.Provider, { value: { hideTryIt, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
|
|
193
193
|
React.createElement(Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
|
|
194
194
|
React.createElement(Box, { w: "full", borderB: true },
|
|
195
|
-
React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy })),
|
|
195
|
+
React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon })),
|
|
196
196
|
operationGroups.length > 0 && webhookGroups.length > 0 ? React.createElement(Heading, { size: 2 }, "Endpoints") : null,
|
|
197
197
|
operationGroups.map(group => (React.createElement(Group, { key: group.title, group: group }))),
|
|
198
198
|
webhookGroups.length > 0 ? React.createElement(Heading, { size: 2 }, "Webhooks") : null,
|
|
@@ -269,7 +269,7 @@ const Collapse = ({ isOpen, children }) => {
|
|
|
269
269
|
};
|
|
270
270
|
Collapse.displayName = 'Collapse';
|
|
271
271
|
|
|
272
|
-
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
272
|
+
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
|
|
273
273
|
const container = React.useRef(null);
|
|
274
274
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
275
275
|
const location = useLocation();
|
|
@@ -291,10 +291,11 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
|
|
|
291
291
|
container.current.scrollIntoView();
|
|
292
292
|
}
|
|
293
293
|
};
|
|
294
|
-
return (React.createElement(ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React.createElement(
|
|
294
|
+
return (React.createElement(ResponsiveSidebarLayout, { onTocClick: handleTocClick, tree: tree, logo: logo !== null && logo !== void 0 ? logo : serviceNode.data.logo, ref: container, name: serviceNode.name }, node && (React.createElement(ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
295
|
+
React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
295
296
|
};
|
|
296
297
|
|
|
297
|
-
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
298
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
|
|
298
299
|
const container = React.useRef(null);
|
|
299
300
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
300
301
|
const location = useLocation();
|
|
@@ -312,7 +313,8 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
312
313
|
return React.createElement(Redirect, { to: "/" });
|
|
313
314
|
}
|
|
314
315
|
const sidebar = (React.createElement(Sidebar, { serviceNode: serviceNode, logo: logo, container: container, pathname: pathname, tree: tree }));
|
|
315
|
-
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(
|
|
316
|
+
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(ElementsOptionsProvider, { renderExtensionAddon: renderExtensionAddon },
|
|
317
|
+
React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
|
|
316
318
|
};
|
|
317
319
|
const Sidebar = ({ serviceNode, logo, container, pathname, tree }) => {
|
|
318
320
|
const handleTocClick = () => {
|
|
@@ -590,7 +592,7 @@ const propsAreWithDocument = (props) => {
|
|
|
590
592
|
return props.hasOwnProperty('apiDescriptionDocument');
|
|
591
593
|
};
|
|
592
594
|
const APIImpl = props => {
|
|
593
|
-
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
595
|
+
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
|
|
594
596
|
const location = useLocation();
|
|
595
597
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
|
596
598
|
const { isResponsiveLayoutEnabled } = useResponsiveLayout();
|
|
@@ -620,9 +622,9 @@ const APIImpl = props => {
|
|
|
620
622
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
621
623
|
}
|
|
622
624
|
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
623
|
-
layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, location: location })),
|
|
624
|
-
layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })),
|
|
625
|
-
layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, compact: isResponsiveLayoutEnabled }))));
|
|
625
|
+
layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
|
|
626
|
+
layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
|
|
627
|
+
layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
|
|
626
628
|
};
|
|
627
629
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
628
630
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements",
|
|
3
|
-
"version": "8.1
|
|
3
|
+
"version": "8.3.1",
|
|
4
4
|
"description": "UI components for composing beautiful developer documentation.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "./index.js",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"react-dom": ">=16.8"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@stoplight/elements-core": "~8.1
|
|
29
|
+
"@stoplight/elements-core": "~8.3.1",
|
|
30
30
|
"@stoplight/http-spec": "^7.0.3",
|
|
31
31
|
"@stoplight/json": "^3.18.1",
|
|
32
32
|
"@stoplight/mosaic": "^1.53.1",
|
|
33
33
|
"@stoplight/types": "^14.1.1",
|
|
34
|
-
"@stoplight/yaml": "^4.
|
|
34
|
+
"@stoplight/yaml": "^4.3.0",
|
|
35
35
|
"classnames": "^2.2.6",
|
|
36
36
|
"file-saver": "^2.0.5",
|
|
37
37
|
"lodash": "^4.17.21",
|