@stoplight/elements 8.3.4 → 8.4.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.
@@ -5,7 +5,9 @@ import { ServiceNode } from '../../utils/oas/types';
5
5
  declare type SidebarLayoutProps = {
6
6
  serviceNode: ServiceNode;
7
7
  logo?: string;
8
+ hideTryItPanel?: boolean;
8
9
  hideTryIt?: boolean;
10
+ hideSamples?: boolean;
9
11
  hideSchemas?: boolean;
10
12
  hideInternal?: boolean;
11
13
  hideExport?: boolean;
@@ -5,7 +5,9 @@ import { ServiceNode } from '../../utils/oas/types';
5
5
  declare type SidebarLayoutProps = {
6
6
  serviceNode: ServiceNode;
7
7
  logo?: string;
8
+ hideTryItPanel?: boolean;
8
9
  hideTryIt?: boolean;
10
+ hideSamples?: boolean;
9
11
  hideSchemas?: boolean;
10
12
  hideInternal?: boolean;
11
13
  hideServerInfo?: boolean;
@@ -12,7 +12,9 @@ interface Location {
12
12
  }
13
13
  declare type StackedLayoutProps = {
14
14
  serviceNode: ServiceNode;
15
+ hideTryItPanel?: boolean;
15
16
  hideTryIt?: boolean;
17
+ hideSamples?: boolean;
16
18
  hideExport?: boolean;
17
19
  hideServerInfo?: boolean;
18
20
  hideSecurityInfo?: boolean;
@@ -13,6 +13,8 @@ export interface CommonAPIProps extends RoutingProps {
13
13
  layout?: 'sidebar' | 'stacked' | 'responsive';
14
14
  logo?: string;
15
15
  hideTryIt?: boolean;
16
+ hideSamples?: boolean;
17
+ hideTryItPanel?: boolean;
16
18
  hideSecurityInfo?: boolean;
17
19
  hideServerInfo?: boolean;
18
20
  hideSchemas?: boolean;
package/index.esm.js CHANGED
@@ -172,6 +172,8 @@ const itemMatchesHash = (hash, item) => {
172
172
  };
173
173
  const TryItContext = React.createContext({
174
174
  hideTryIt: false,
175
+ hideTryItPanel: false,
176
+ hideSamples: false,
175
177
  tryItCredentialsPolicy: 'omit',
176
178
  });
177
179
  TryItContext.displayName = 'TryItContext';
@@ -185,11 +187,11 @@ const LocationContext = React.createContext({
185
187
  },
186
188
  });
187
189
  LocationContext.displayName = 'LocationContext';
188
- const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
190
+ const APIWithStackedLayout = ({ serviceNode, hideTryItPanel, hideTryIt, hideSamples, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
189
191
  const { groups: operationGroups } = computeTagGroups(serviceNode, NodeType.HttpOperation);
190
192
  const { groups: webhookGroups } = computeTagGroups(serviceNode, NodeType.HttpWebhook);
191
193
  return (React.createElement(LocationContext.Provider, { value: { location } },
192
- React.createElement(TryItContext.Provider, { value: { hideTryIt, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
194
+ React.createElement(TryItContext.Provider, { value: { hideTryItPanel, hideTryIt, hideSamples, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
193
195
  React.createElement(Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
194
196
  React.createElement(Box, { w: "full", borderB: true },
195
197
  React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport, hideSecurityInfo, hideServerInfo }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon })),
@@ -233,7 +235,7 @@ const Item = React.memo(({ item }) => {
233
235
  const scrollRef = React.useRef(null);
234
236
  const color = HttpMethodColors[item.data.method] || 'gray';
235
237
  const isDeprecated = !!item.data.deprecated;
236
- const { hideTryIt, tryItCredentialsPolicy, corsProxy } = React.useContext(TryItContext);
238
+ const { hideTryIt, hideSamples, hideTryItPanel, tryItCredentialsPolicy, corsProxy } = React.useContext(TryItContext);
237
239
  const onClick = React.useCallback(() => setIsExpanded(!isExpanded), [isExpanded]);
238
240
  React.useEffect(() => {
239
241
  var _a;
@@ -251,15 +253,15 @@ const Item = React.memo(({ item }) => {
251
253
  isDeprecated && React.createElement(DeprecatedBadge, null)),
252
254
  React.createElement(Collapse, { isOpen: isExpanded },
253
255
  React.createElement(Box, { flex: 1, p: 2, fontWeight: "medium", mx: "auto", fontSize: "xl" }, item.name),
254
- hideTryIt ? (React.createElement(Box, { as: ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true }, node: item, p: 4 })) : (React.createElement(Tabs, { appearance: "line" },
256
+ hideTryItPanel ? (React.createElement(Box, { as: ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true, hideSamples, hideTryIt }, node: item, p: 4 })) : (React.createElement(Tabs, { appearance: "line" },
255
257
  React.createElement(TabList, null,
256
258
  React.createElement(Tab, null, "Docs"),
257
259
  React.createElement(Tab, null, "TryIt")),
258
260
  React.createElement(TabPanels, null,
259
261
  React.createElement(TabPanel, null,
260
- React.createElement(ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: true } })),
262
+ React.createElement(ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: false, hideSamples, hideTryIt } })),
261
263
  React.createElement(TabPanel, null,
262
- React.createElement(TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, corsProxy: corsProxy }))))))));
264
+ React.createElement(TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, corsProxy: corsProxy, hideSamples: hideSamples, hideTryIt: hideTryIt }))))))));
263
265
  });
264
266
  Item.displayName = 'Item';
265
267
  const Collapse = ({ isOpen, children }) => {
@@ -269,7 +271,7 @@ const Collapse = ({ isOpen, children }) => {
269
271
  };
270
272
  Collapse.displayName = 'Collapse';
271
273
 
272
- const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
274
+ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
273
275
  const container = React.useRef(null);
274
276
  const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
275
277
  const location = useLocation();
@@ -278,11 +280,13 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
278
280
  const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
279
281
  const layoutOptions = React.useMemo(() => ({
280
282
  hideTryIt: hideTryIt,
283
+ hideTryItPanel,
284
+ hideSamples,
281
285
  hideSecurityInfo: hideSecurityInfo,
282
286
  hideServerInfo: hideServerInfo,
283
287
  compact: compact,
284
288
  hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService,
285
- }), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, node === null || node === void 0 ? void 0 : node.type]);
289
+ }), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
286
290
  if (!node) {
287
291
  const firstSlug = findFirstNodeSlug(tree);
288
292
  if (firstSlug) {
@@ -301,7 +305,7 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
301
305
  React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
302
306
  };
303
307
 
304
- const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
308
+ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
305
309
  const container = React.useRef(null);
306
310
  const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
307
311
  const location = useLocation();
@@ -310,10 +314,12 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideS
310
314
  const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
311
315
  const layoutOptions = React.useMemo(() => ({
312
316
  hideTryIt: hideTryIt,
317
+ hideTryItPanel,
318
+ hideSamples,
313
319
  hideServerInfo: hideServerInfo,
314
320
  hideSecurityInfo: hideSecurityInfo,
315
321
  hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService,
316
- }), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, node === null || node === void 0 ? void 0 : node.type]);
322
+ }), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
317
323
  if (!node) {
318
324
  const firstSlug = findFirstNodeSlug(tree);
319
325
  if (firstSlug) {
@@ -603,7 +609,7 @@ const propsAreWithDocument = (props) => {
603
609
  return props.hasOwnProperty('apiDescriptionDocument');
604
610
  };
605
611
  const APIImpl = props => {
606
- const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
612
+ const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryItPanel, hideTryIt, hideSamples, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
607
613
  const location = useLocation();
608
614
  const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
609
615
  const { isResponsiveLayoutEnabled } = useResponsiveLayout();
@@ -633,9 +639,9 @@ const APIImpl = props => {
633
639
  React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
634
640
  }
635
641
  return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
636
- layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
637
- layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
638
- layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
642
+ layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSamples: hideSamples, hideTryItPanel: hideTryItPanel, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
643
+ layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
644
+ layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
639
645
  };
640
646
  const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
641
647
 
package/index.js CHANGED
@@ -193,6 +193,8 @@ const itemMatchesHash = (hash, item) => {
193
193
  };
194
194
  const TryItContext = React__namespace.createContext({
195
195
  hideTryIt: false,
196
+ hideTryItPanel: false,
197
+ hideSamples: false,
196
198
  tryItCredentialsPolicy: 'omit',
197
199
  });
198
200
  TryItContext.displayName = 'TryItContext';
@@ -206,11 +208,11 @@ const LocationContext = React__namespace.createContext({
206
208
  },
207
209
  });
208
210
  LocationContext.displayName = 'LocationContext';
209
- const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
211
+ const APIWithStackedLayout = ({ serviceNode, hideTryItPanel, hideTryIt, hideSamples, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
210
212
  const { groups: operationGroups } = computeTagGroups(serviceNode, types.NodeType.HttpOperation);
211
213
  const { groups: webhookGroups } = computeTagGroups(serviceNode, types.NodeType.HttpWebhook);
212
214
  return (React__namespace.createElement(LocationContext.Provider, { value: { location } },
213
- React__namespace.createElement(TryItContext.Provider, { value: { hideTryIt, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
215
+ React__namespace.createElement(TryItContext.Provider, { value: { hideTryItPanel, hideTryIt, hideSamples, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
214
216
  React__namespace.createElement(mosaic.Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
215
217
  React__namespace.createElement(mosaic.Box, { w: "full", borderB: true },
216
218
  React__namespace.createElement(elementsCore.Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: types.NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport, hideSecurityInfo, hideServerInfo }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon })),
@@ -254,7 +256,7 @@ const Item = React__namespace.memo(({ item }) => {
254
256
  const scrollRef = React__namespace.useRef(null);
255
257
  const color = elementsCore.HttpMethodColors[item.data.method] || 'gray';
256
258
  const isDeprecated = !!item.data.deprecated;
257
- const { hideTryIt, tryItCredentialsPolicy, corsProxy } = React__namespace.useContext(TryItContext);
259
+ const { hideTryIt, hideSamples, hideTryItPanel, tryItCredentialsPolicy, corsProxy } = React__namespace.useContext(TryItContext);
258
260
  const onClick = React__namespace.useCallback(() => setIsExpanded(!isExpanded), [isExpanded]);
259
261
  React__namespace.useEffect(() => {
260
262
  var _a;
@@ -272,15 +274,15 @@ const Item = React__namespace.memo(({ item }) => {
272
274
  isDeprecated && React__namespace.createElement(elementsCore.DeprecatedBadge, null)),
273
275
  React__namespace.createElement(Collapse, { isOpen: isExpanded },
274
276
  React__namespace.createElement(mosaic.Box, { flex: 1, p: 2, fontWeight: "medium", mx: "auto", fontSize: "xl" }, item.name),
275
- hideTryIt ? (React__namespace.createElement(mosaic.Box, { as: elementsCore.ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true }, node: item, p: 4 })) : (React__namespace.createElement(mosaic.Tabs, { appearance: "line" },
277
+ hideTryItPanel ? (React__namespace.createElement(mosaic.Box, { as: elementsCore.ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true, hideSamples, hideTryIt }, node: item, p: 4 })) : (React__namespace.createElement(mosaic.Tabs, { appearance: "line" },
276
278
  React__namespace.createElement(mosaic.TabList, null,
277
279
  React__namespace.createElement(mosaic.Tab, null, "Docs"),
278
280
  React__namespace.createElement(mosaic.Tab, null, "TryIt")),
279
281
  React__namespace.createElement(mosaic.TabPanels, null,
280
282
  React__namespace.createElement(mosaic.TabPanel, null,
281
- React__namespace.createElement(elementsCore.ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: true } })),
283
+ React__namespace.createElement(elementsCore.ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: false, hideSamples, hideTryIt } })),
282
284
  React__namespace.createElement(mosaic.TabPanel, null,
283
- React__namespace.createElement(elementsCore.TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, corsProxy: corsProxy }))))))));
285
+ React__namespace.createElement(elementsCore.TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, corsProxy: corsProxy, hideSamples: hideSamples, hideTryIt: hideTryIt }))))))));
284
286
  });
285
287
  Item.displayName = 'Item';
286
288
  const Collapse = ({ isOpen, children }) => {
@@ -290,7 +292,7 @@ const Collapse = ({ isOpen, children }) => {
290
292
  };
291
293
  Collapse.displayName = 'Collapse';
292
294
 
293
- const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
295
+ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
294
296
  const container = React__namespace.useRef(null);
295
297
  const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
296
298
  const location = reactRouterDom.useLocation();
@@ -299,11 +301,13 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
299
301
  const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
300
302
  const layoutOptions = React__namespace.useMemo(() => ({
301
303
  hideTryIt: hideTryIt,
304
+ hideTryItPanel,
305
+ hideSamples,
302
306
  hideSecurityInfo: hideSecurityInfo,
303
307
  hideServerInfo: hideServerInfo,
304
308
  compact: compact,
305
309
  hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService,
306
- }), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, node === null || node === void 0 ? void 0 : node.type]);
310
+ }), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
307
311
  if (!node) {
308
312
  const firstSlug = findFirstNodeSlug(tree);
309
313
  if (firstSlug) {
@@ -322,7 +326,7 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
322
326
  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 })))));
323
327
  };
324
328
 
325
- const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
329
+ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
326
330
  const container = React__namespace.useRef(null);
327
331
  const tree = React__namespace.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
328
332
  const location = reactRouterDom.useLocation();
@@ -331,10 +335,12 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideS
331
335
  const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
332
336
  const layoutOptions = React__namespace.useMemo(() => ({
333
337
  hideTryIt: hideTryIt,
338
+ hideTryItPanel,
339
+ hideSamples,
334
340
  hideServerInfo: hideServerInfo,
335
341
  hideSecurityInfo: hideSecurityInfo,
336
342
  hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService,
337
- }), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, node === null || node === void 0 ? void 0 : node.type]);
343
+ }), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
338
344
  if (!node) {
339
345
  const firstSlug = findFirstNodeSlug(tree);
340
346
  if (firstSlug) {
@@ -624,7 +630,7 @@ const propsAreWithDocument = (props) => {
624
630
  return props.hasOwnProperty('apiDescriptionDocument');
625
631
  };
626
632
  const APIImpl = props => {
627
- const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
633
+ const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryItPanel, hideTryIt, hideSamples, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
628
634
  const location = reactRouterDom.useLocation();
629
635
  const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
630
636
  const { isResponsiveLayoutEnabled } = elementsCore.useResponsiveLayout();
@@ -654,9 +660,9 @@ const APIImpl = props => {
654
660
  React__namespace.createElement(elementsCore.NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
655
661
  }
656
662
  return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
657
- layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
658
- layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
659
- layout === 'responsive' && (React__namespace.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
663
+ layout === 'stacked' && (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSamples: hideSamples, hideTryItPanel: hideTryItPanel, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
664
+ layout === 'sidebar' && (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
665
+ layout === 'responsive' && (React__namespace.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
660
666
  };
661
667
  const API = flow(elementsCore.withRouter, elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(APIImpl);
662
668
 
package/index.mjs CHANGED
@@ -172,6 +172,8 @@ const itemMatchesHash = (hash, item) => {
172
172
  };
173
173
  const TryItContext = React.createContext({
174
174
  hideTryIt: false,
175
+ hideTryItPanel: false,
176
+ hideSamples: false,
175
177
  tryItCredentialsPolicy: 'omit',
176
178
  });
177
179
  TryItContext.displayName = 'TryItContext';
@@ -185,11 +187,11 @@ const LocationContext = React.createContext({
185
187
  },
186
188
  });
187
189
  LocationContext.displayName = 'LocationContext';
188
- const APIWithStackedLayout = ({ serviceNode, hideTryIt, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
190
+ const APIWithStackedLayout = ({ serviceNode, hideTryItPanel, hideTryIt, hideSamples, hideExport, hideSecurityInfo, hideServerInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, showPoweredByLink = true, location, }) => {
189
191
  const { groups: operationGroups } = computeTagGroups(serviceNode, NodeType.HttpOperation);
190
192
  const { groups: webhookGroups } = computeTagGroups(serviceNode, NodeType.HttpWebhook);
191
193
  return (React.createElement(LocationContext.Provider, { value: { location } },
192
- React.createElement(TryItContext.Provider, { value: { hideTryIt, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
194
+ React.createElement(TryItContext.Provider, { value: { hideTryItPanel, hideTryIt, hideSamples, tryItCredentialsPolicy, corsProxy: tryItCorsProxy } },
193
195
  React.createElement(Flex, { w: "full", flexDirection: "col", m: "auto", className: "sl-max-w-4xl" },
194
196
  React.createElement(Box, { w: "full", borderB: true },
195
197
  React.createElement(Docs, { className: "sl-mx-auto", nodeData: serviceNode.data, nodeTitle: serviceNode.name, nodeType: NodeType.HttpService, location: location, layoutOptions: { showPoweredByLink, hideExport, hideSecurityInfo, hideServerInfo }, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, renderExtensionAddon: renderExtensionAddon })),
@@ -233,7 +235,7 @@ const Item = React.memo(({ item }) => {
233
235
  const scrollRef = React.useRef(null);
234
236
  const color = HttpMethodColors[item.data.method] || 'gray';
235
237
  const isDeprecated = !!item.data.deprecated;
236
- const { hideTryIt, tryItCredentialsPolicy, corsProxy } = React.useContext(TryItContext);
238
+ const { hideTryIt, hideSamples, hideTryItPanel, tryItCredentialsPolicy, corsProxy } = React.useContext(TryItContext);
237
239
  const onClick = React.useCallback(() => setIsExpanded(!isExpanded), [isExpanded]);
238
240
  React.useEffect(() => {
239
241
  var _a;
@@ -251,15 +253,15 @@ const Item = React.memo(({ item }) => {
251
253
  isDeprecated && React.createElement(DeprecatedBadge, null)),
252
254
  React.createElement(Collapse, { isOpen: isExpanded },
253
255
  React.createElement(Box, { flex: 1, p: 2, fontWeight: "medium", mx: "auto", fontSize: "xl" }, item.name),
254
- hideTryIt ? (React.createElement(Box, { as: ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true }, node: item, p: 4 })) : (React.createElement(Tabs, { appearance: "line" },
256
+ hideTryItPanel ? (React.createElement(Box, { as: ParsedDocs, layoutOptions: { noHeading: true, hideTryItPanel: true, hideSamples, hideTryIt }, node: item, p: 4 })) : (React.createElement(Tabs, { appearance: "line" },
255
257
  React.createElement(TabList, null,
256
258
  React.createElement(Tab, null, "Docs"),
257
259
  React.createElement(Tab, null, "TryIt")),
258
260
  React.createElement(TabPanels, null,
259
261
  React.createElement(TabPanel, null,
260
- React.createElement(ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: true } })),
262
+ React.createElement(ParsedDocs, { className: "sl-px-4", node: item, location: location, layoutOptions: { noHeading: true, hideTryItPanel: false, hideSamples, hideTryIt } })),
261
263
  React.createElement(TabPanel, null,
262
- React.createElement(TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, corsProxy: corsProxy }))))))));
264
+ React.createElement(TryItWithRequestSamples, { httpOperation: item.data, tryItCredentialsPolicy: tryItCredentialsPolicy, corsProxy: corsProxy, hideSamples: hideSamples, hideTryIt: hideTryIt }))))))));
263
265
  });
264
266
  Item.displayName = 'Item';
265
267
  const Collapse = ({ isOpen, children }) => {
@@ -269,7 +271,7 @@ const Collapse = ({ isOpen, children }) => {
269
271
  };
270
272
  Collapse.displayName = 'Collapse';
271
273
 
272
- const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
274
+ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, compact, hideSchemas, hideInternal, hideExport, hideServerInfo, hideSecurityInfo, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
273
275
  const container = React.useRef(null);
274
276
  const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
275
277
  const location = useLocation();
@@ -278,11 +280,13 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
278
280
  const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
279
281
  const layoutOptions = React.useMemo(() => ({
280
282
  hideTryIt: hideTryIt,
283
+ hideTryItPanel,
284
+ hideSamples,
281
285
  hideSecurityInfo: hideSecurityInfo,
282
286
  hideServerInfo: hideServerInfo,
283
287
  compact: compact,
284
288
  hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService,
285
- }), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, node === null || node === void 0 ? void 0 : node.type]);
289
+ }), [hideTryIt, hideSecurityInfo, hideServerInfo, compact, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
286
290
  if (!node) {
287
291
  const firstSlug = findFirstNodeSlug(tree);
288
292
  if (firstSlug) {
@@ -301,7 +305,7 @@ const APIWithResponsiveSidebarLayout = ({ serviceNode, logo, hideTryIt, compact,
301
305
  React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })))));
302
306
  };
303
307
 
304
- const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
308
+ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryItPanel, hideTryIt, hideSamples, hideSchemas, hideSecurityInfo, hideServerInfo, hideInternal, hideExport, exportProps, tryItCredentialsPolicy, tryItCorsProxy, renderExtensionAddon, }) => {
305
309
  const container = React.useRef(null);
306
310
  const tree = React.useMemo(() => computeAPITree(serviceNode, { hideSchemas, hideInternal }), [serviceNode, hideSchemas, hideInternal]);
307
311
  const location = useLocation();
@@ -310,10 +314,12 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideS
310
314
  const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
311
315
  const layoutOptions = React.useMemo(() => ({
312
316
  hideTryIt: hideTryIt,
317
+ hideTryItPanel,
318
+ hideSamples,
313
319
  hideServerInfo: hideServerInfo,
314
320
  hideSecurityInfo: hideSecurityInfo,
315
321
  hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService,
316
- }), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, node === null || node === void 0 ? void 0 : node.type]);
322
+ }), [hideTryIt, hideServerInfo, hideSecurityInfo, hideExport, hideTryItPanel, hideSamples, node === null || node === void 0 ? void 0 : node.type]);
317
323
  if (!node) {
318
324
  const firstSlug = findFirstNodeSlug(tree);
319
325
  if (firstSlug) {
@@ -603,7 +609,7 @@ const propsAreWithDocument = (props) => {
603
609
  return props.hasOwnProperty('apiDescriptionDocument');
604
610
  };
605
611
  const APIImpl = props => {
606
- const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryIt, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
612
+ const { layout = 'sidebar', apiDescriptionUrl = '', logo, hideTryItPanel, hideTryIt, hideSamples, hideSecurityInfo, hideServerInfo, hideSchemas, hideInternal, hideExport, tryItCredentialsPolicy, tryItCorsProxy, maxRefDepth, renderExtensionAddon, } = props;
607
613
  const location = useLocation();
608
614
  const apiDescriptionDocument = propsAreWithDocument(props) ? props.apiDescriptionDocument : undefined;
609
615
  const { isResponsiveLayoutEnabled } = useResponsiveLayout();
@@ -633,9 +639,9 @@ const APIImpl = props => {
633
639
  React.createElement(NonIdealState, { title: "Failed to parse OpenAPI file", description: "Please make sure your OpenAPI file is valid and try again" })));
634
640
  }
635
641
  return (React.createElement(InlineRefResolverProvider, { document: parsedDocument, maxRefDepth: maxRefDepth },
636
- layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
637
- layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
638
- layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
642
+ layout === 'stacked' && (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideSamples: hideSamples, hideTryItPanel: hideTryItPanel, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, location: location })),
643
+ layout === 'sidebar' && (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon })),
644
+ layout === 'responsive' && (React.createElement(APIWithResponsiveSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryItPanel: hideTryItPanel, hideTryIt: hideTryIt, hideSamples: hideSamples, hideSecurityInfo: hideSecurityInfo, hideServerInfo: hideServerInfo, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy, renderExtensionAddon: renderExtensionAddon, compact: isResponsiveLayoutEnabled }))));
639
645
  };
640
646
  const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
641
647
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements",
3
- "version": "8.3.4",
3
+ "version": "8.4.0",
4
4
  "description": "UI components for composing beautiful developer documentation.",
5
5
  "keywords": [],
6
6
  "main": "./index.js",
@@ -26,10 +26,10 @@
26
26
  "react-dom": ">=16.8"
27
27
  },
28
28
  "dependencies": {
29
- "@stoplight/elements-core": "~8.3.4",
29
+ "@stoplight/elements-core": "~8.4.0",
30
30
  "@stoplight/http-spec": "^7.1.0",
31
31
  "@stoplight/json": "^3.18.1",
32
- "@stoplight/mosaic": "^1.53.1",
32
+ "@stoplight/mosaic": "^1.53.3",
33
33
  "@stoplight/types": "^14.1.1",
34
34
  "@stoplight/yaml": "^4.3.0",
35
35
  "classnames": "^2.2.6",