@jpmorganchase/elemental 4.0.1 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/components/API/APIWithSidebarLayout.d.ts +2 -0
- package/components/API/APIWithStackedLayout.d.ts +1 -0
- package/containers/API.d.ts +2 -1
- package/index.esm.js +15 -9
- package/index.js +15 -9
- package/index.mjs +15 -9
- package/package.json +2 -2
- package/web-components.min.js +1 -1
@@ -8,11 +8,13 @@ declare type SidebarLayoutProps = {
|
|
8
8
|
hideSchemas?: boolean;
|
9
9
|
hideInternal?: boolean;
|
10
10
|
hideExport?: boolean;
|
11
|
+
hideInlineExamples?: boolean;
|
11
12
|
exportProps?: ExportButtonProps;
|
12
13
|
tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
|
13
14
|
tryItCorsProxy?: string;
|
14
15
|
tryItOutDefaultServer?: string;
|
15
16
|
useCustomNav?: boolean;
|
17
|
+
layout?: 'sidebar' | 'drawer';
|
16
18
|
};
|
17
19
|
export declare const APIWithSidebarLayout: React.FC<SidebarLayoutProps>;
|
18
20
|
export {};
|
package/containers/API.d.ts
CHANGED
@@ -9,12 +9,13 @@ 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' | 'drawer';
|
13
13
|
logo?: string;
|
14
14
|
hideTryIt?: boolean;
|
15
15
|
hideSchemas?: boolean;
|
16
16
|
hideInternal?: boolean;
|
17
17
|
hideExport?: boolean;
|
18
|
+
hideInlineExamples?: boolean;
|
18
19
|
tryItCredentialsPolicy?: 'omit' | 'include' | 'same-origin';
|
19
20
|
tryItCorsProxy?: string;
|
20
21
|
tryItOutDefaultServer?: string;
|
package/index.esm.js
CHANGED
@@ -157,7 +157,7 @@ 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, tryItOutDefaultServer, useCustomNav, }) => {
|
160
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples = false, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, layout, }) => {
|
161
161
|
const container = React.useRef(null);
|
162
162
|
const tree = React.useMemo(() => {
|
163
163
|
if (!useCustomNav)
|
@@ -171,7 +171,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
171
171
|
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
172
172
|
React.useEffect(() => {
|
173
173
|
}, [pathname]);
|
174
|
-
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
174
|
+
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideInlineExamples, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node, hideInlineExamples]);
|
175
175
|
if (!node) {
|
176
176
|
const firstSlug = findFirstNodeSlug(tree);
|
177
177
|
if (firstSlug) {
|
@@ -193,7 +193,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
193
193
|
React.createElement(Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
|
194
194
|
React.createElement(TableOfContents, { tree: tree, activeId: pathname, Link: Link, onLinkClick: handleTocClick })),
|
195
195
|
React.createElement(PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
|
196
|
-
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer }))));
|
196
|
+
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav, layout: layout }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer }))));
|
197
197
|
};
|
198
198
|
|
199
199
|
const itemUriMatchesPathname = (itemUri, pathname) => itemUri === pathname;
|
@@ -202,10 +202,16 @@ const TryItContext = React.createContext({
|
|
202
202
|
tryItCredentialsPolicy: 'omit',
|
203
203
|
});
|
204
204
|
TryItContext.displayName = 'TryItContext';
|
205
|
-
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, }) => {
|
205
|
+
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, hideInlineExamples, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, }) => {
|
206
206
|
const location = useLocation();
|
207
207
|
const { groups } = computeTagGroups(serviceNode);
|
208
|
-
return (React.createElement(TryItContext.Provider, { value: {
|
208
|
+
return (React.createElement(TryItContext.Provider, { value: {
|
209
|
+
hideTryIt,
|
210
|
+
hideInlineExamples,
|
211
|
+
tryItCredentialsPolicy,
|
212
|
+
corsProxy: tryItCorsProxy,
|
213
|
+
tryItOutDefaultServer,
|
214
|
+
} },
|
209
215
|
React.createElement(Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
|
210
216
|
React.createElement(Box, { w: "full", borderB: true },
|
211
217
|
React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink: true, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer })),
|
@@ -238,7 +244,7 @@ const Item = React.memo(({ item }) => {
|
|
238
244
|
const scrollRef = React.useRef(null);
|
239
245
|
const color = HttpMethodColors[item.data.method] || 'gray';
|
240
246
|
const isDeprecated = !!item.data.deprecated;
|
241
|
-
const { hideTryIt, tryItCredentialsPolicy, corsProxy, tryItOutDefaultServer } = React.useContext(TryItContext);
|
247
|
+
const { hideTryIt, hideInlineExamples, tryItCredentialsPolicy, corsProxy, tryItOutDefaultServer } = React.useContext(TryItContext);
|
242
248
|
const onClick = React.useCallback(() => {
|
243
249
|
setIsExpanded(!isExpanded);
|
244
250
|
if (window && window.location) {
|
@@ -268,7 +274,7 @@ const Item = React.memo(({ item }) => {
|
|
268
274
|
React.createElement(TabPanel, null,
|
269
275
|
React.createElement(ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: true } })),
|
270
276
|
React.createElement(TabPanel, null,
|
271
|
-
React.createElement(TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy }))))))));
|
277
|
+
React.createElement(TryItWithRequestSamples, { httpOperation: item.data, hideInlineExamples: hideInlineExamples, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy }))))))));
|
272
278
|
});
|
273
279
|
const Collapse = ({ isOpen, children }) => {
|
274
280
|
if (!isOpen)
|
@@ -488,7 +494,7 @@ const propsAreWithDocument = (props) => {
|
|
488
494
|
return props.hasOwnProperty('apiDescriptionDocument');
|
489
495
|
};
|
490
496
|
const APIImpl = props => {
|
491
|
-
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, } = props;
|
497
|
+
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, } = props;
|
492
498
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
493
499
|
const { data: fetchedDocument, error } = useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
|
494
500
|
if (res.ok) {
|
@@ -515,7 +521,7 @@ const APIImpl = props => {
|
|
515
521
|
return (React.createElement(Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
516
522
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
517
523
|
}
|
518
|
-
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav }))));
|
524
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav, layout: layout }))));
|
519
525
|
};
|
520
526
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
521
527
|
|
package/index.js
CHANGED
@@ -190,7 +190,7 @@ 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, tryItOutDefaultServer, useCustomNav, }) => {
|
193
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples = false, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, layout, }) => {
|
194
194
|
const container = React__namespace.useRef(null);
|
195
195
|
const tree = React__namespace.useMemo(() => {
|
196
196
|
if (!useCustomNav)
|
@@ -204,7 +204,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
204
204
|
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
205
205
|
React__namespace.useEffect(() => {
|
206
206
|
}, [pathname]);
|
207
|
-
const layoutOptions = React__namespace.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
207
|
+
const layoutOptions = React__namespace.useMemo(() => ({ hideTryIt: hideTryIt, hideInlineExamples, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService }), [hideTryIt, hideExport, node, hideInlineExamples]);
|
208
208
|
if (!node) {
|
209
209
|
const firstSlug = findFirstNodeSlug(tree);
|
210
210
|
if (firstSlug) {
|
@@ -226,7 +226,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
226
226
|
React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
|
227
227
|
React__namespace.createElement(elementalCore.TableOfContents, { tree: tree, activeId: pathname, Link: reactRouterDom.Link, onLinkClick: handleTocClick })),
|
228
228
|
React__namespace.createElement(elementalCore.PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
|
229
|
-
return (React__namespace.createElement(elementalCore.SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav }, node && (React__namespace.createElement(elementalCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer }))));
|
229
|
+
return (React__namespace.createElement(elementalCore.SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav, layout: layout }, node && (React__namespace.createElement(elementalCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer }))));
|
230
230
|
};
|
231
231
|
|
232
232
|
const itemUriMatchesPathname = (itemUri, pathname) => itemUri === pathname;
|
@@ -235,10 +235,16 @@ const TryItContext = React__namespace.createContext({
|
|
235
235
|
tryItCredentialsPolicy: 'omit',
|
236
236
|
});
|
237
237
|
TryItContext.displayName = 'TryItContext';
|
238
|
-
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, }) => {
|
238
|
+
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, hideInlineExamples, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, }) => {
|
239
239
|
const location = reactRouterDom.useLocation();
|
240
240
|
const { groups } = computeTagGroups(serviceNode);
|
241
|
-
return (React__namespace.createElement(TryItContext.Provider, { value: {
|
241
|
+
return (React__namespace.createElement(TryItContext.Provider, { value: {
|
242
|
+
hideTryIt,
|
243
|
+
hideInlineExamples,
|
244
|
+
tryItCredentialsPolicy,
|
245
|
+
corsProxy: tryItCorsProxy,
|
246
|
+
tryItOutDefaultServer,
|
247
|
+
} },
|
242
248
|
React__namespace.createElement(mosaic.Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
|
243
249
|
React__namespace.createElement(mosaic.Box, { w: "full", borderB: true },
|
244
250
|
React__namespace.createElement(elementalCore.Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: types.NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink: true, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer })),
|
@@ -271,7 +277,7 @@ const Item = React__namespace.memo(({ item }) => {
|
|
271
277
|
const scrollRef = React__namespace.useRef(null);
|
272
278
|
const color = elementalCore.HttpMethodColors[item.data.method] || 'gray';
|
273
279
|
const isDeprecated = !!item.data.deprecated;
|
274
|
-
const { hideTryIt, tryItCredentialsPolicy, corsProxy, tryItOutDefaultServer } = React__namespace.useContext(TryItContext);
|
280
|
+
const { hideTryIt, hideInlineExamples, tryItCredentialsPolicy, corsProxy, tryItOutDefaultServer } = React__namespace.useContext(TryItContext);
|
275
281
|
const onClick = React__namespace.useCallback(() => {
|
276
282
|
setIsExpanded(!isExpanded);
|
277
283
|
if (window && window.location) {
|
@@ -301,7 +307,7 @@ const Item = React__namespace.memo(({ item }) => {
|
|
301
307
|
React__namespace.createElement(mosaic.TabPanel, null,
|
302
308
|
React__namespace.createElement(elementalCore.ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: true } })),
|
303
309
|
React__namespace.createElement(mosaic.TabPanel, null,
|
304
|
-
React__namespace.createElement(elementalCore.TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy }))))))));
|
310
|
+
React__namespace.createElement(elementalCore.TryItWithRequestSamples, { httpOperation: item.data, hideInlineExamples: hideInlineExamples, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy }))))))));
|
305
311
|
});
|
306
312
|
const Collapse = ({ isOpen, children }) => {
|
307
313
|
if (!isOpen)
|
@@ -521,7 +527,7 @@ const propsAreWithDocument = (props) => {
|
|
521
527
|
return props.hasOwnProperty('apiDescriptionDocument');
|
522
528
|
};
|
523
529
|
const APIImpl = props => {
|
524
|
-
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, } = props;
|
530
|
+
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, } = props;
|
525
531
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
526
532
|
const { data: fetchedDocument, error } = reactQuery.useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
|
527
533
|
if (res.ok) {
|
@@ -548,7 +554,7 @@ const APIImpl = props => {
|
|
548
554
|
return (React__namespace.createElement(mosaic.Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
549
555
|
React__namespace.createElement(elementalCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
550
556
|
}
|
551
|
-
return (React__namespace.createElement(elementalCore.InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer })) : (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav }))));
|
557
|
+
return (React__namespace.createElement(elementalCore.InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer })) : (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav, layout: layout }))));
|
552
558
|
};
|
553
559
|
const API = flow__default["default"](elementalCore.withRouter, elementalCore.withStyles, elementalCore.withPersistenceBoundary, elementalCore.withMosaicProvider, elementalCore.withQueryClientProvider)(APIImpl);
|
554
560
|
|
package/index.mjs
CHANGED
@@ -157,7 +157,7 @@ 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, tryItOutDefaultServer, useCustomNav, }) => {
|
160
|
+
const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples = false, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, layout, }) => {
|
161
161
|
const container = React.useRef(null);
|
162
162
|
const tree = React.useMemo(() => {
|
163
163
|
if (!useCustomNav)
|
@@ -171,7 +171,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
171
171
|
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
172
172
|
React.useEffect(() => {
|
173
173
|
}, [pathname]);
|
174
|
-
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
174
|
+
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideInlineExamples, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node, hideInlineExamples]);
|
175
175
|
if (!node) {
|
176
176
|
const firstSlug = findFirstNodeSlug(tree);
|
177
177
|
if (firstSlug) {
|
@@ -193,7 +193,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
193
193
|
React.createElement(Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
|
194
194
|
React.createElement(TableOfContents, { tree: tree, activeId: pathname, Link: Link, onLinkClick: handleTocClick })),
|
195
195
|
React.createElement(PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
|
196
|
-
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer }))));
|
196
|
+
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar, renderSideBar: !useCustomNav, layout: layout }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer }))));
|
197
197
|
};
|
198
198
|
|
199
199
|
const itemUriMatchesPathname = (itemUri, pathname) => itemUri === pathname;
|
@@ -202,10 +202,16 @@ const TryItContext = React.createContext({
|
|
202
202
|
tryItCredentialsPolicy: 'omit',
|
203
203
|
});
|
204
204
|
TryItContext.displayName = 'TryItContext';
|
205
|
-
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, }) => {
|
205
|
+
const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, hideInlineExamples, exportProps, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, }) => {
|
206
206
|
const location = useLocation();
|
207
207
|
const { groups } = computeTagGroups(serviceNode);
|
208
|
-
return (React.createElement(TryItContext.Provider, { value: {
|
208
|
+
return (React.createElement(TryItContext.Provider, { value: {
|
209
|
+
hideTryIt,
|
210
|
+
hideInlineExamples,
|
211
|
+
tryItCredentialsPolicy,
|
212
|
+
corsProxy: tryItCorsProxy,
|
213
|
+
tryItOutDefaultServer,
|
214
|
+
} },
|
209
215
|
React.createElement(Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
|
210
216
|
React.createElement(Box, { w: "full", borderB: true },
|
211
217
|
React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink: true, hideExport }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer })),
|
@@ -238,7 +244,7 @@ const Item = React.memo(({ item }) => {
|
|
238
244
|
const scrollRef = React.useRef(null);
|
239
245
|
const color = HttpMethodColors[item.data.method] || 'gray';
|
240
246
|
const isDeprecated = !!item.data.deprecated;
|
241
|
-
const { hideTryIt, tryItCredentialsPolicy, corsProxy, tryItOutDefaultServer } = React.useContext(TryItContext);
|
247
|
+
const { hideTryIt, hideInlineExamples, tryItCredentialsPolicy, corsProxy, tryItOutDefaultServer } = React.useContext(TryItContext);
|
242
248
|
const onClick = React.useCallback(() => {
|
243
249
|
setIsExpanded(!isExpanded);
|
244
250
|
if (window && window.location) {
|
@@ -268,7 +274,7 @@ const Item = React.memo(({ item }) => {
|
|
268
274
|
React.createElement(TabPanel, null,
|
269
275
|
React.createElement(ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: true } })),
|
270
276
|
React.createElement(TabPanel, null,
|
271
|
-
React.createElement(TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy }))))))));
|
277
|
+
React.createElement(TryItWithRequestSamples, { httpOperation: item.data, hideInlineExamples: hideInlineExamples, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItOutDefaultServer: tryItOutDefaultServer, corsProxy: corsProxy }))))))));
|
272
278
|
});
|
273
279
|
const Collapse = ({ isOpen, children }) => {
|
274
280
|
if (!isOpen)
|
@@ -488,7 +494,7 @@ const propsAreWithDocument = (props) => {
|
|
488
494
|
return props.hasOwnProperty('apiDescriptionDocument');
|
489
495
|
};
|
490
496
|
const APIImpl = props => {
|
491
|
-
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, } = props;
|
497
|
+
const { layout, apiDescriptionUrl = '', logo, hideTryIt, hideSchemas, hideInternal, hideExport, hideInlineExamples, tryItCredentialsPolicy, tryItCorsProxy, tryItOutDefaultServer, useCustomNav, } = props;
|
492
498
|
const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
|
493
499
|
const { data: fetchedDocument, error } = useQuery([apiDescriptionUrl], () => fetch(apiDescriptionUrl).then(res => {
|
494
500
|
if (res.ok) {
|
@@ -515,7 +521,7 @@ const APIImpl = props => {
|
|
515
521
|
return (React.createElement(Flex, { justify: "center", alignItems: "center", w: "full", minH: "screen" },
|
516
522
|
React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
|
517
523
|
}
|
518
|
-
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav }))));
|
524
|
+
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, hideInlineExamples: hideInlineExamples, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, tryItOutDefaultServer: tryItOutDefaultServer, useCustomNav: useCustomNav, layout: layout }))));
|
519
525
|
};
|
520
526
|
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
521
527
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jpmorganchase/elemental",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.2.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
|
-
"@jpmorganchase/elemental-core": "^1.
|
29
|
+
"@jpmorganchase/elemental-core": "^1.6.1",
|
30
30
|
"@stoplight/http-spec": "^6.0.0",
|
31
31
|
"@stoplight/json": "^3.18.1",
|
32
32
|
"@stoplight/mosaic": "^1.44.4",
|