@stoplight/elements 8.0.0 → 8.0.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 +17 -0
- package/containers/API.d.ts +1 -1
- package/containers/API.stories.d.ts +12 -11
- package/index.d.ts +1 -0
- package/index.esm.js +32 -3
- package/index.js +31 -2
- package/index.mjs +32 -3
- package/package.json +2 -2
- package/styles.min.css +1 -1
- package/web-components.min.js +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ExportButtonProps } from '@stoplight/elements-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ServiceNode } from '../../utils/oas/types';
|
|
4
|
+
declare type SidebarLayoutProps = {
|
|
5
|
+
serviceNode: ServiceNode;
|
|
6
|
+
logo?: string;
|
|
7
|
+
hideTryIt?: boolean;
|
|
8
|
+
hideSchemas?: boolean;
|
|
9
|
+
hideInternal?: boolean;
|
|
10
|
+
hideExport?: boolean;
|
|
11
|
+
exportProps?: ExportButtonProps;
|
|
12
|
+
tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
|
|
13
|
+
tryItCorsProxy?: string;
|
|
14
|
+
compact?: number | boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const APIWithResponsiveSidebarLayout: React.FC<SidebarLayoutProps>;
|
|
17
|
+
export {};
|
package/containers/API.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare type APIPropsWithDocument = {
|
|
|
9
9
|
apiDescriptionUrl?: string;
|
|
10
10
|
} & CommonAPIProps;
|
|
11
11
|
export interface CommonAPIProps extends RoutingProps {
|
|
12
|
-
layout?: 'sidebar' | 'stacked';
|
|
12
|
+
layout?: 'sidebar' | 'stacked' | 'responsive';
|
|
13
13
|
logo?: string;
|
|
14
14
|
hideTryIt?: boolean;
|
|
15
15
|
hideSchemas?: boolean;
|
|
@@ -43,14 +43,15 @@ declare const _default: {
|
|
|
43
43
|
};
|
|
44
44
|
};
|
|
45
45
|
export default _default;
|
|
46
|
-
export declare const APIWithYamlProvidedDirectly: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-
|
|
47
|
-
export declare const APIWithJSONProvidedDirectly: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-
|
|
48
|
-
export declare const APIWithoutDescription: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-
|
|
49
|
-
export declare const APIWithInternalOperations: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-
|
|
50
|
-
export declare const OpenApi3Schema: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-
|
|
51
|
-
export declare const BadgesForSchema: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-
|
|
52
|
-
export declare const StackedLayout: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-
|
|
53
|
-
export declare const
|
|
54
|
-
export declare const
|
|
55
|
-
export declare const
|
|
56
|
-
export declare const
|
|
46
|
+
export declare const APIWithYamlProvidedDirectly: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
47
|
+
export declare const APIWithJSONProvidedDirectly: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
48
|
+
export declare const APIWithoutDescription: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
49
|
+
export declare const APIWithInternalOperations: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
50
|
+
export declare const OpenApi3Schema: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
51
|
+
export declare const BadgesForSchema: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
52
|
+
export declare const StackedLayout: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
53
|
+
export declare const ResponsiveLayout: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
54
|
+
export declare const Box: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
55
|
+
export declare const DigitalOcean: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
56
|
+
export declare const Github: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
|
57
|
+
export declare const Instagram: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, APIProps>;
|
package/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export type { APIProps } from './containers/API';
|
|
|
3
3
|
export { API } from './containers/API';
|
|
4
4
|
export { useExportDocumentProps } from './hooks/useExportDocumentProps';
|
|
5
5
|
export { transformOasToServiceNode } from './utils/oas';
|
|
6
|
+
export type { ServiceNode } from './utils/oas/types';
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHttpOperation, isHttpWebhookOperation, isHttpService, HttpMethodColors, DeprecatedBadge, ParsedDocs, TryItWithRequestSamples, Docs, SidebarLayout, Logo, TableOfContents, PoweredByLink, slugify, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
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';
|
|
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';
|
|
@@ -305,6 +305,31 @@ const Collapse = ({ isOpen, children }) => {
|
|
|
305
305
|
};
|
|
306
306
|
Collapse.displayName = 'Collapse';
|
|
307
307
|
|
|
308
|
+
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
309
|
+
const container = React.useRef(null);
|
|
310
|
+
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
311
|
+
const location = useLocation();
|
|
312
|
+
const { pathname } = location;
|
|
313
|
+
const isRootPath = !pathname || pathname === '/';
|
|
314
|
+
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
315
|
+
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, compact: compact, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node, compact]);
|
|
316
|
+
if (!node) {
|
|
317
|
+
const firstSlug = findFirstNodeSlug(tree);
|
|
318
|
+
if (firstSlug) {
|
|
319
|
+
return React.createElement(Redirect, { to: firstSlug });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (hideInternal && node && isInternal(node)) {
|
|
323
|
+
return React.createElement(Redirect, { to: "/" });
|
|
324
|
+
}
|
|
325
|
+
const handleTocClick = () => {
|
|
326
|
+
if (container.current) {
|
|
327
|
+
container.current.scrollIntoView();
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
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(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
331
|
+
};
|
|
332
|
+
|
|
308
333
|
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
309
334
|
const container = React.useRef(null);
|
|
310
335
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
@@ -601,9 +626,10 @@ const propsAreWithDocument = (props) => {
|
|
|
601
626
|
return props.hasOwnProperty('apiDescriptionDocument');
|
|
602
627
|
};
|
|
603
628
|
const APIImpl = props => {
|
|
604
|
-
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
629
|
+
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
605
630
|
const location = useLocation();
|
|
606
631
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
|
632
|
+
const { isResponsiveLayoutEnabled } = useResponsiveLayout();
|
|
607
633
|
const { data: fetchedDocument, error } = useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
|
|
608
634
|
if (res.ok) {
|
|
609
635
|
return res.text();
|
|
@@ -629,7 +655,10 @@ const APIImpl = props => {
|
|
|
629
655
|
return (React.createElement(Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
630
656
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
631
657
|
}
|
|
632
|
-
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
658
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
659
|
+
layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, location: location })),
|
|
660
|
+
layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })),
|
|
661
|
+
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 }))));
|
|
633
662
|
};
|
|
634
663
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
635
664
|
|
package/index.js
CHANGED
|
@@ -338,6 +338,31 @@ const Collapse = ({ isOpen, children }) => {
|
|
|
338
338
|
};
|
|
339
339
|
Collapse.displayName = 'Collapse';
|
|
340
340
|
|
|
341
|
+
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
342
|
+
const container = React__namespace.useRef(null);
|
|
343
|
+
const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
344
|
+
const location = reactRouterDom.useLocation();
|
|
345
|
+
const { pathname } = location;
|
|
346
|
+
const isRootPath = !pathname || pathname === '/';
|
|
347
|
+
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
348
|
+
const layoutOptions = React__namespace.useMemo(() => ({ hideTryIt: hideTryIt, compact: compact, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService }), [hideTryIt, hideExport, node, compact]);
|
|
349
|
+
if (!node) {
|
|
350
|
+
const firstSlug = findFirstNodeSlug(tree);
|
|
351
|
+
if (firstSlug) {
|
|
352
|
+
return React__namespace.createElement(reactRouterDom.Redirect, { to: firstSlug });
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (hideInternal && node && isInternal(node)) {
|
|
356
|
+
return React__namespace.createElement(reactRouterDom.Redirect, { to: "/" });
|
|
357
|
+
}
|
|
358
|
+
const handleTocClick = () => {
|
|
359
|
+
if (container.current) {
|
|
360
|
+
container.current.scrollIntoView();
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
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.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
364
|
+
};
|
|
365
|
+
|
|
341
366
|
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
342
367
|
const container = React__namespace.useRef(null);
|
|
343
368
|
const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
@@ -634,9 +659,10 @@ const propsAreWithDocument = (props) => {
|
|
|
634
659
|
return props.hasOwnProperty('apiDescriptionDocument');
|
|
635
660
|
};
|
|
636
661
|
const APIImpl = props => {
|
|
637
|
-
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
662
|
+
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
638
663
|
const location = reactRouterDom.useLocation();
|
|
639
664
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
|
665
|
+
const { isResponsiveLayoutEnabled } = elementsCore.useResponsiveLayout();
|
|
640
666
|
const { data: fetchedDocument, error } = reactQuery.useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
|
|
641
667
|
if (res.ok) {
|
|
642
668
|
return res.text();
|
|
@@ -662,7 +688,10 @@ const APIImpl = props => {
|
|
|
662
688
|
return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
663
689
|
React__namespace.createElement(elementsCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
664
690
|
}
|
|
665
|
-
return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
691
|
+
return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
692
|
+
layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, location: location })),
|
|
693
|
+
layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })),
|
|
694
|
+
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 }))));
|
|
666
695
|
};
|
|
667
696
|
const API = flow__default["default"](elementsCore.withRouter, elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(APIImpl);
|
|
668
697
|
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isHttpOperation, isHttpWebhookOperation, isHttpService, HttpMethodColors, DeprecatedBadge, ParsedDocs, TryItWithRequestSamples, Docs, SidebarLayout, Logo, TableOfContents, PoweredByLink, slugify, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
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';
|
|
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';
|
|
@@ -305,6 +305,31 @@ const Collapse = ({ isOpen, children }) => {
|
|
|
305
305
|
};
|
|
306
306
|
Collapse.displayName = 'Collapse';
|
|
307
307
|
|
|
308
|
+
const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
309
|
+
const container = React.useRef(null);
|
|
310
|
+
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
311
|
+
const location = useLocation();
|
|
312
|
+
const { pathname } = location;
|
|
313
|
+
const isRootPath = !pathname || pathname === '/';
|
|
314
|
+
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
315
|
+
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, compact: compact, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node, compact]);
|
|
316
|
+
if (!node) {
|
|
317
|
+
const firstSlug = findFirstNodeSlug(tree);
|
|
318
|
+
if (firstSlug) {
|
|
319
|
+
return React.createElement(Redirect, { to: firstSlug });
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (hideInternal && node && isInternal(node)) {
|
|
323
|
+
return React.createElement(Redirect, { to: "/" });
|
|
324
|
+
}
|
|
325
|
+
const handleTocClick = () => {
|
|
326
|
+
if (container.current) {
|
|
327
|
+
container.current.scrollIntoView();
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
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(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
331
|
+
};
|
|
332
|
+
|
|
308
333
|
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
309
334
|
const container = React.useRef(null);
|
|
310
335
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
@@ -601,9 +626,10 @@ const propsAreWithDocument = (props) => {
|
|
|
601
626
|
return props.hasOwnProperty('apiDescriptionDocument');
|
|
602
627
|
};
|
|
603
628
|
const APIImpl = props => {
|
|
604
|
-
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
629
|
+
const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, } = props;
|
|
605
630
|
const location = useLocation();
|
|
606
631
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
|
632
|
+
const { isResponsiveLayoutEnabled } = useResponsiveLayout();
|
|
607
633
|
const { data: fetchedDocument, error } = useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
|
|
608
634
|
if (res.ok) {
|
|
609
635
|
return res.text();
|
|
@@ -629,7 +655,10 @@ const APIImpl = props => {
|
|
|
629
655
|
return (React.createElement(Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
630
656
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
631
657
|
}
|
|
632
|
-
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
658
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
|
|
659
|
+
layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, location: location })),
|
|
660
|
+
layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })),
|
|
661
|
+
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 }))));
|
|
633
662
|
};
|
|
634
663
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
635
664
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.1",
|
|
4
4
|
"description": "UI components for composing beautiful developer documentation.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "./index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-dom": ">=16.8"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@stoplight/elements-core": "~8.0.
|
|
29
|
+
"@stoplight/elements-core": "~8.0.1",
|
|
30
30
|
"@stoplight/http-spec": "^7.0.1",
|
|
31
31
|
"@stoplight/json": "^3.18.1",
|
|
32
32
|
"@stoplight/mosaic": "^1.46.1",
|