@stoplight/elements 7.6.5 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/API/APIWithSidebarLayout.d.ts +1 -2
- package/index.esm.js +4 -8
- package/index.js +4 -8
- package/index.mjs +4 -8
- package/package.json +4 -4
- package/styles.min.css +1 -1
- package/web-components.min.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExportButtonProps
|
|
1
|
+
import { ExportButtonProps } from '@stoplight/elements-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { ServiceNode } from '../../utils/oas/types';
|
|
4
4
|
declare type SidebarLayoutProps = {
|
|
@@ -11,7 +11,6 @@ declare type SidebarLayoutProps = {
|
|
|
11
11
|
exportProps?: ExportButtonProps;
|
|
12
12
|
tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
|
|
13
13
|
tryItCorsProxy?: string;
|
|
14
|
-
router?: RoutingProps['router'];
|
|
15
14
|
};
|
|
16
15
|
export declare const APIWithSidebarLayout: React.FC<SidebarLayoutProps>;
|
|
17
16
|
export {};
|
package/index.esm.js
CHANGED
|
@@ -157,21 +157,17 @@ const isInternal = (node) => {
|
|
|
157
157
|
return !!data['x-internal'];
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy,
|
|
160
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
161
161
|
const container = React.useRef(null);
|
|
162
162
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
163
163
|
const location = useLocation();
|
|
164
164
|
const { pathname } = location;
|
|
165
165
|
const isRootPath = !pathname || pathname === '/';
|
|
166
|
-
|
|
167
|
-
const isHashRouter = router === 'hash';
|
|
166
|
+
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
168
167
|
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
|
169
168
|
if (!node) {
|
|
170
169
|
const firstSlug = findFirstNodeSlug(tree);
|
|
171
|
-
if (
|
|
172
|
-
node = serviceNode;
|
|
173
|
-
}
|
|
174
|
-
else if (firstSlug) {
|
|
170
|
+
if (firstSlug) {
|
|
175
171
|
return React.createElement(Redirect, { to: firstSlug });
|
|
176
172
|
}
|
|
177
173
|
}
|
|
@@ -513,7 +509,7 @@ const APIImpl = props => {
|
|
|
513
509
|
return (React.createElement(Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
514
510
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
515
511
|
}
|
|
516
|
-
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy
|
|
512
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
517
513
|
};
|
|
518
514
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
519
515
|
|
package/index.js
CHANGED
|
@@ -190,21 +190,17 @@ const isInternal = (node) => {
|
|
|
190
190
|
return !!data['x-internal'];
|
|
191
191
|
};
|
|
192
192
|
|
|
193
|
-
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy,
|
|
193
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
194
194
|
const container = React__namespace.useRef(null);
|
|
195
195
|
const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
196
196
|
const location = reactRouterDom.useLocation();
|
|
197
197
|
const { pathname } = location;
|
|
198
198
|
const isRootPath = !pathname || pathname === '/';
|
|
199
|
-
|
|
200
|
-
const isHashRouter = router === 'hash';
|
|
199
|
+
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
201
200
|
const layoutOptions = React__namespace.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
|
202
201
|
if (!node) {
|
|
203
202
|
const firstSlug = findFirstNodeSlug(tree);
|
|
204
|
-
if (
|
|
205
|
-
node = serviceNode;
|
|
206
|
-
}
|
|
207
|
-
else if (firstSlug) {
|
|
203
|
+
if (firstSlug) {
|
|
208
204
|
return React__namespace.createElement(reactRouterDom.Redirect, { to: firstSlug });
|
|
209
205
|
}
|
|
210
206
|
}
|
|
@@ -546,7 +542,7 @@ const APIImpl = props => {
|
|
|
546
542
|
return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
547
543
|
React__namespace.createElement(elementsCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
548
544
|
}
|
|
549
|
-
return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy
|
|
545
|
+
return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
550
546
|
};
|
|
551
547
|
const API = flow__default["default"](elementsCore.withRouter, elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(APIImpl);
|
|
552
548
|
|
package/index.mjs
CHANGED
|
@@ -157,21 +157,17 @@ const isInternal = (node) => {
|
|
|
157
157
|
return !!data['x-internal'];
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
-
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy,
|
|
160
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, }) => {
|
|
161
161
|
const container = React.useRef(null);
|
|
162
162
|
const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
|
|
163
163
|
const location = useLocation();
|
|
164
164
|
const { pathname } = location;
|
|
165
165
|
const isRootPath = !pathname || pathname === '/';
|
|
166
|
-
|
|
167
|
-
const isHashRouter = router === 'hash';
|
|
166
|
+
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
168
167
|
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
|
169
168
|
if (!node) {
|
|
170
169
|
const firstSlug = findFirstNodeSlug(tree);
|
|
171
|
-
if (
|
|
172
|
-
node = serviceNode;
|
|
173
|
-
}
|
|
174
|
-
else if (firstSlug) {
|
|
170
|
+
if (firstSlug) {
|
|
175
171
|
return React.createElement(Redirect, { to: firstSlug });
|
|
176
172
|
}
|
|
177
173
|
}
|
|
@@ -513,7 +509,7 @@ const APIImpl = props => {
|
|
|
513
509
|
return (React.createElement(Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
|
514
510
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
|
515
511
|
}
|
|
516
|
-
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy
|
|
512
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
517
513
|
};
|
|
518
514
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
519
515
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.7.0",
|
|
4
4
|
"description": "UI components for composing beautiful developer documentation.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "./index.js",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"react-dom": ">=16.8"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@stoplight/elements-core": "~7.
|
|
29
|
+
"@stoplight/elements-core": "~7.7.0",
|
|
30
30
|
"@stoplight/http-spec": "^5.1.4",
|
|
31
31
|
"@stoplight/json": "^3.18.1",
|
|
32
|
-
"@stoplight/mosaic": "^1.
|
|
33
|
-
"@stoplight/types": "^13.
|
|
32
|
+
"@stoplight/mosaic": "^1.33.0",
|
|
33
|
+
"@stoplight/types": "^13.7.0",
|
|
34
34
|
"@stoplight/yaml": "^4.2.3",
|
|
35
35
|
"classnames": "^2.2.6",
|
|
36
36
|
"file-saver": "^2.0.5",
|