@stoplight/elements-core 7.5.20 → 7.6.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.
@@ -22,6 +22,7 @@ interface BaseDocsProps {
22
22
  hideServerInfo?: boolean;
23
23
  hideSecurityInfo?: boolean;
24
24
  hideExport?: boolean;
25
+ compact?: number | boolean;
25
26
  };
26
27
  }
27
28
  export interface DocsProps extends BaseDocsProps {
@@ -5,4 +5,4 @@ export interface TwoColumnLayoutProps {
5
5
  left: React.ReactNode;
6
6
  className?: string;
7
7
  }
8
- export declare const TwoColumnLayout: ({ header, right, left, className }: TwoColumnLayoutProps) => JSX.Element;
8
+ export declare const TwoColumnLayout: React.ForwardRefExoticComponent<TwoColumnLayoutProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,6 @@
1
+ import { Ref } from 'react';
2
+ import { DocsProps } from '../components/Docs';
3
+ export declare function useIsCompact(layoutOptions: DocsProps['layoutOptions']): {
4
+ ref: Ref<HTMLDivElement>;
5
+ isCompact: boolean;
6
+ };
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Docs, ParsedDocs } from './components/Docs';
1
+ export { Docs, DocsProps, ParsedDocs } from './components/Docs';
2
2
  export { DeprecatedBadge } from './components/Docs/HttpOperation/Badges';
3
3
  export { ExportButton, ExportButtonProps } from './components/Docs/HttpService/ExportButton';
4
4
  export { SidebarLayout } from './components/Layout/SidebarLayout';
package/index.esm.js CHANGED
@@ -7,13 +7,12 @@ import isObject from 'lodash/isObject.js';
7
7
  import isPlainObject from 'lodash/isPlainObject.js';
8
8
  import { NodeType, HttpParamStyles } from '@stoplight/types';
9
9
  import { parse } from '@stoplight/yaml';
10
- import { isArray as isArray$1, Box, Panel, CopyButton, Menu, Button, Text, Flex, Input, Icon, Select, FieldButton, Image, Link, useThemeIsDark, HStack, VStack, InvertTheme, Tooltip, Badge, LinkHeading, Tabs, TabList, Tab, TabPanels, TabPanel, Heading, useClipboard, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
10
+ import { isArray as isArray$1, Box, Panel, CopyButton, Menu, Button, Text, Flex, Input, Icon, Select, FieldButton, Image, Link, useThemeIsDark, HStack, VStack, InvertTheme, Tooltip, Badge, LinkHeading, Tabs, TabList, Tab, TabPanels, TabPanel, Heading, useClipboard, useBreakpoints, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
11
11
  import { withErrorBoundary } from '@stoplight/react-error-boundary';
12
12
  import { MarkdownViewer as MarkdownViewer$1, DefaultSMDComponents, MarkdownViewerProvider } from '@stoplight/markdown-viewer';
13
13
  export { DefaultSMDComponents } from '@stoplight/markdown-viewer';
14
14
  import cn from 'classnames';
15
15
  import { atomWithStorage, useAtomValue } from 'jotai/utils';
16
- import { faCrosshairs, faCloud, faBookOpen, faCube, faDatabase, faQuestionCircle, faExclamationCircle, faServer, faExclamationTriangle, faEye, faBolt, faCopy, faCheck } from '@fortawesome/free-solid-svg-icons';
17
16
  import { atom, useAtom, Provider } from 'jotai';
18
17
  import URI from 'urijs';
19
18
  import { CodeViewer } from '@stoplight/mosaic-code-viewer';
@@ -226,6 +225,58 @@ const ArticleComponent = React.memo(({ data }) => {
226
225
  });
227
226
  const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
228
227
 
228
+ /*!
229
+ * Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
230
+ * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
231
+ * Copyright 2022 Fonticons, Inc.
232
+ */
233
+ var faBolt = {
234
+ prefix: 'fas',
235
+ iconName: 'bolt',
236
+ icon: [384, 512, [9889, "zap"], "f0e7", "M240.5 224H352C365.3 224 377.3 232.3 381.1 244.7C386.6 257.2 383.1 271.3 373.1 280.1L117.1 504.1C105.8 513.9 89.27 514.7 77.19 505.9C65.1 497.1 60.7 481.1 66.59 467.4L143.5 288H31.1C18.67 288 6.733 279.7 2.044 267.3C-2.645 254.8 .8944 240.7 10.93 231.9L266.9 7.918C278.2-1.92 294.7-2.669 306.8 6.114C318.9 14.9 323.3 30.87 317.4 44.61L240.5 224z"]
237
+ };
238
+ var faBookOpen = {
239
+ prefix: 'fas',
240
+ iconName: 'book-open',
241
+ icon: [576, 512, [128366, 128214], "f518", "M144.3 32.04C106.9 31.29 63.7 41.44 18.6 61.29c-11.42 5.026-18.6 16.67-18.6 29.15l0 357.6c0 11.55 11.99 19.55 22.45 14.65c126.3-59.14 219.8 11 223.8 14.01C249.1 478.9 252.5 480 256 480c12.4 0 16-11.38 16-15.98V80.04c0-5.203-2.531-10.08-6.781-13.08C263.3 65.58 216.7 33.35 144.3 32.04zM557.4 61.29c-45.11-19.79-88.48-29.61-125.7-29.26c-72.44 1.312-118.1 33.55-120.9 34.92C306.5 69.96 304 74.83 304 80.04v383.1C304 468.4 307.5 480 320 480c3.484 0 6.938-1.125 9.781-3.328c3.925-3.018 97.44-73.16 223.8-14c10.46 4.896 22.45-3.105 22.45-14.65l.0001-357.6C575.1 77.97 568.8 66.31 557.4 61.29z"]
242
+ };
243
+ var faCircleQuestion = {
244
+ prefix: 'fas',
245
+ iconName: 'circle-question',
246
+ icon: [512, 512, [62108, "question-circle"], "f059", "M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256s256-114.6 256-256S397.4 0 256 0zM256 400c-18 0-32-14-32-32s13.1-32 32-32c17.1 0 32 14 32 32S273.1 400 256 400zM325.1 258L280 286V288c0 13-11 24-24 24S232 301 232 288V272c0-8 4-16 12-21l57-34C308 213 312 206 312 198C312 186 301.1 176 289.1 176h-51.1C225.1 176 216 186 216 198c0 13-11 24-24 24s-24-11-24-24C168 159 199 128 237.1 128h51.1C329 128 360 159 360 198C360 222 347 245 325.1 258z"]
247
+ };
248
+ var faQuestionCircle = faCircleQuestion;
249
+ var faCloud = {
250
+ prefix: 'fas',
251
+ iconName: 'cloud',
252
+ icon: [640, 512, [9729], "f0c2", "M96.2 200.1C96.07 197.4 96 194.7 96 192C96 103.6 167.6 32 256 32C315.3 32 367 64.25 394.7 112.2C409.9 101.1 428.3 96 448 96C501 96 544 138.1 544 192C544 204.2 541.7 215.8 537.6 226.6C596 238.4 640 290.1 640 352C640 422.7 582.7 480 512 480H144C64.47 480 0 415.5 0 336C0 273.2 40.17 219.8 96.2 200.1z"]
253
+ };
254
+ var faCrosshairs = {
255
+ prefix: 'fas',
256
+ iconName: 'crosshairs',
257
+ icon: [512, 512, [], "f05b", "M224 256C224 238.3 238.3 224 256 224C273.7 224 288 238.3 288 256C288 273.7 273.7 288 256 288C238.3 288 224 273.7 224 256zM256 0C273.7 0 288 14.33 288 32V42.35C381.7 56.27 455.7 130.3 469.6 224H480C497.7 224 512 238.3 512 256C512 273.7 497.7 288 480 288H469.6C455.7 381.7 381.7 455.7 288 469.6V480C288 497.7 273.7 512 256 512C238.3 512 224 497.7 224 480V469.6C130.3 455.7 56.27 381.7 42.35 288H32C14.33 288 0 273.7 0 256C0 238.3 14.33 224 32 224H42.35C56.27 130.3 130.3 56.27 224 42.35V32C224 14.33 238.3 0 256 0V0zM224 404.6V384C224 366.3 238.3 352 256 352C273.7 352 288 366.3 288 384V404.6C346.3 392.1 392.1 346.3 404.6 288H384C366.3 288 352 273.7 352 256C352 238.3 366.3 224 384 224H404.6C392.1 165.7 346.3 119.9 288 107.4V128C288 145.7 273.7 160 256 160C238.3 160 224 145.7 224 128V107.4C165.7 119.9 119.9 165.7 107.4 224H128C145.7 224 160 238.3 160 256C160 273.7 145.7 288 128 288H107.4C119.9 346.3 165.7 392.1 224 404.6z"]
258
+ };
259
+ var faCube = {
260
+ prefix: 'fas',
261
+ iconName: 'cube',
262
+ icon: [512, 512, [], "f1b2", "M234.5 5.709C248.4 .7377 263.6 .7377 277.5 5.709L469.5 74.28C494.1 83.38 512 107.5 512 134.6V377.4C512 404.5 494.1 428.6 469.5 437.7L277.5 506.3C263.6 511.3 248.4 511.3 234.5 506.3L42.47 437.7C17 428.6 0 404.5 0 377.4V134.6C0 107.5 17 83.38 42.47 74.28L234.5 5.709zM256 65.98L82.34 128L256 190L429.7 128L256 65.98zM288 434.6L448 377.4V189.4L288 246.6V434.6z"]
263
+ };
264
+ var faDatabase = {
265
+ prefix: 'fas',
266
+ iconName: 'database',
267
+ icon: [448, 512, [], "f1c0", "M448 80V128C448 172.2 347.7 208 224 208C100.3 208 0 172.2 0 128V80C0 35.82 100.3 0 224 0C347.7 0 448 35.82 448 80zM393.2 214.7C413.1 207.3 433.1 197.8 448 186.1V288C448 332.2 347.7 368 224 368C100.3 368 0 332.2 0 288V186.1C14.93 197.8 34.02 207.3 54.85 214.7C99.66 230.7 159.5 240 224 240C288.5 240 348.3 230.7 393.2 214.7V214.7zM54.85 374.7C99.66 390.7 159.5 400 224 400C288.5 400 348.3 390.7 393.2 374.7C413.1 367.3 433.1 357.8 448 346.1V432C448 476.2 347.7 512 224 512C100.3 512 0 476.2 0 432V346.1C14.93 357.8 34.02 367.3 54.85 374.7z"]
268
+ };
269
+ var faEye = {
270
+ prefix: 'fas',
271
+ iconName: 'eye',
272
+ icon: [576, 512, [128065], "f06e", "M279.6 160.4C282.4 160.1 285.2 160 288 160C341 160 384 202.1 384 256C384 309 341 352 288 352C234.1 352 192 309 192 256C192 253.2 192.1 250.4 192.4 247.6C201.7 252.1 212.5 256 224 256C259.3 256 288 227.3 288 192C288 180.5 284.1 169.7 279.6 160.4zM480.6 112.6C527.4 156 558.7 207.1 573.5 243.7C576.8 251.6 576.8 260.4 573.5 268.3C558.7 304 527.4 355.1 480.6 399.4C433.5 443.2 368.8 480 288 480C207.2 480 142.5 443.2 95.42 399.4C48.62 355.1 17.34 304 2.461 268.3C-.8205 260.4-.8205 251.6 2.461 243.7C17.34 207.1 48.62 156 95.42 112.6C142.5 68.84 207.2 32 288 32C368.8 32 433.5 68.84 480.6 112.6V112.6zM288 112C208.5 112 144 176.5 144 256C144 335.5 208.5 400 288 400C367.5 400 432 335.5 432 256C432 176.5 367.5 112 288 112z"]
273
+ };
274
+ var faServer = {
275
+ prefix: 'fas',
276
+ iconName: 'server',
277
+ icon: [512, 512, [], "f233", "M480 288H32c-17.62 0-32 14.38-32 32v128c0 17.62 14.38 32 32 32h448c17.62 0 32-14.38 32-32v-128C512 302.4 497.6 288 480 288zM352 408c-13.25 0-24-10.75-24-24s10.75-24 24-24s24 10.75 24 24S365.3 408 352 408zM416 408c-13.25 0-24-10.75-24-24s10.75-24 24-24s24 10.75 24 24S429.3 408 416 408zM480 32H32C14.38 32 0 46.38 0 64v128c0 17.62 14.38 32 32 32h448c17.62 0 32-14.38 32-32V64C512 46.38 497.6 32 480 32zM352 152c-13.25 0-24-10.75-24-24S338.8 104 352 104S376 114.8 376 128S365.3 152 352 152zM416 152c-13.25 0-24-10.75-24-24S402.8 104 416 104S440 114.8 440 128S429.3 152 416 152z"]
278
+ };
279
+
229
280
  const NodeTypeColors = {
230
281
  http_operation: '#6a6acb',
231
282
  http_service: '#e056fd',
@@ -1605,7 +1656,7 @@ const TryItResponse = ({ response }) => {
1605
1656
  ? parseBody(response.bodyText, responseType)
1606
1657
  : response.bodyText })) : response.blob && responseType === 'image' ? (React.createElement(Flex, { justifyContent: "center" },
1607
1658
  React.createElement(Image, { src: URL.createObjectURL(response.blob), alt: "response image" }))) : (React.createElement("p", null,
1608
- React.createElement(Box, { as: Icon, icon: faExclamationCircle, mr: 2 }),
1659
+ React.createElement(Box, { as: Icon, icon: ['fas', 'exclamation-circle'], mr: 2 }),
1609
1660
  "No supported response body returned"))))));
1610
1661
  };
1611
1662
  const ResponseMenu = ({ types, type, onChange }) => {
@@ -1785,7 +1836,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
1785
1836
  servers.length > 1 && React.createElement(ServersDropdown, { servers: servers }),
1786
1837
  isMockingEnabled && (React.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
1787
1838
  validateParameters && hasRequiredButEmptyParameters && (React.createElement(Box, { mt: 4, color: "danger-light", fontSize: "sm" },
1788
- React.createElement(Icon, { icon: faExclamationTriangle, className: "sl-mr-1" }),
1839
+ React.createElement(Icon, { icon: ['fas', 'exclamation-triangle'], className: "sl-mr-1" }),
1789
1840
  "You didn't provide all of the required parameters!")))));
1790
1841
  let tryItPanelElem;
1791
1842
  if (embeddedInMd) {
@@ -1835,7 +1886,7 @@ const ResponseExamples = ({ httpOperation, responseMediaType, responseStatusCode
1835
1886
  return null;
1836
1887
  const examplesSelect = userDefinedExamples && userDefinedExamples.length > 1 && (React__default.createElement(Select, { "aria-label": "Response Example", value: String(chosenExampleIndex), options: userDefinedExamples.map((example, index) => ({ value: index, label: example.key })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Response Example: " }));
1837
1888
  return (React__default.createElement(Panel, { rounded: true, isCollapsible: false },
1838
- React__default.createElement(Panel.Titlebar, null, examplesSelect || React__default.createElement(Text, { color: "body" }, "Response Example")),
1889
+ React__default.createElement(Panel.Titlebar, { rightComponent: React__default.createElement(CopyButton, { size: "sm", copyValue: responseExample || '' }) }, examplesSelect || React__default.createElement(Text, { color: "body" }, "Response Example")),
1839
1890
  React__default.createElement(Panel.Content, { p: 0 }, show || !exceedsSize(responseExample) ? (React__default.createElement(CodeViewer, { "aria-label": responseExample, noCopyButton: true, maxHeight: "500px", language: "json", value: responseExample, showLineNumbers: true, style: {
1840
1891
  '--fs-code': 12,
1841
1892
  } })) : (React__default.createElement(LoadMore, { loading: loading, onClick: handleLoadMore })))));
@@ -1852,13 +1903,13 @@ const TryItWithRequestSamples = (_a) => {
1852
1903
  React.createElement(ResponseExamples, Object.assign({}, props))));
1853
1904
  };
1854
1905
 
1855
- const TwoColumnLayout = ({ header, right, left, className }) => (React__default.createElement(VStack, { w: "full", className: className, spacing: 8 },
1906
+ const TwoColumnLayout = React__default.forwardRef(({ header, right, left, className }, ref) => (React__default.createElement(VStack, { ref: ref, w: "full", className: className, spacing: 8 },
1856
1907
  header,
1857
1908
  React__default.createElement(Flex, null,
1858
- React__default.createElement(Box, { w: 0, flex: 1 }, left),
1859
- right && (React__default.createElement(Box, { ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right)))));
1909
+ React__default.createElement(Box, { "data-testid": "two-column-left", w: 0, flex: 1 }, left),
1910
+ right && (React__default.createElement(Box, { "data-testid": "two-column-right", ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right))))));
1860
1911
 
1861
- const DeprecatedBadge = () => (React__default.createElement(Tooltip, { renderTrigger: React__default.createElement(Badge, { intent: "warning", icon: faExclamationCircle, "data-testid": "badge-deprecated" }, "Deprecated") }, "This operation has been marked as deprecated, which means it could be removed at some point in the future."));
1912
+ const DeprecatedBadge = () => (React__default.createElement(Tooltip, { renderTrigger: React__default.createElement(Badge, { intent: "warning", icon: ['fas', 'exclamation-circle'], "data-testid": "badge-deprecated" }, "Deprecated") }, "This operation has been marked as deprecated, which means it could be removed at some point in the future."));
1862
1913
  const InternalBadge = ({ isHttpService }) => (React__default.createElement(Tooltip, { renderTrigger: React__default.createElement(Badge, { icon: faEye, "data-testid": "badge-internal", bg: "danger" }, "Internal") }, `This ${isHttpService ? 'operation' : 'model'} is marked as internal and won't be visible in public docs.`));
1863
1914
  const VersionBadge = ({ value, backgroundColor }) => (React__default.createElement(Badge, { appearance: "solid", size: "sm", border: 0, style: {
1864
1915
  backgroundColor: backgroundColor || badgeDefaultBackgroundColor,
@@ -2249,10 +2300,10 @@ const ServerUrl = ({ description, url, marginBottom = true }) => {
2249
2300
  React.createElement(Tooltip, { placement: "right", renderTrigger: () => React.createElement(Text, { "aria-label": description }, url) },
2250
2301
  !hasCopied && (React.createElement(Box, { p: 1, onClick: onCopy, cursor: "pointer" },
2251
2302
  "Copy Server URL ",
2252
- React.createElement(Icon, { className: "sl-ml-1", icon: faCopy }))),
2303
+ React.createElement(Icon, { className: "sl-ml-1", icon: ['fas', 'copy'] }))),
2253
2304
  hasCopied && (React.createElement(Box, { p: 1 },
2254
2305
  "Copied Server URL ",
2255
- React.createElement(Icon, { className: "sl-ml-1", icon: faCheck }))))));
2306
+ React.createElement(Icon, { className: "sl-ml-1", icon: ['fas', 'check'] }))))));
2256
2307
  };
2257
2308
 
2258
2309
  const HttpServiceComponent = React.memo(({ data, location = {}, layoutOptions, exportProps }) => {
@@ -2276,35 +2327,58 @@ const HttpServiceComponent = React.memo(({ data, location = {}, layoutOptions, e
2276
2327
  HttpServiceComponent.displayName = 'HttpService.Component';
2277
2328
  const HttpService = withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
2278
2329
 
2330
+ const getBreakpoints = (compact) => {
2331
+ if (!compact)
2332
+ return undefined;
2333
+ if (typeof compact === 'number') {
2334
+ return [
2335
+ ['compact', compact],
2336
+ ['regular', Infinity],
2337
+ ];
2338
+ }
2339
+ return [['compact', Infinity]];
2340
+ };
2341
+ function useIsCompact(layoutOptions) {
2342
+ const { ref, breakpoint } = useBreakpoints(getBreakpoints(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.compact));
2343
+ return { ref: ref, isCompact: breakpoint === 'compact' };
2344
+ }
2345
+
2279
2346
  const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
2280
2347
  var _a;
2281
- const [chosenExampleIndex, setChosenExampleIndex] = React.useState(0);
2282
- const [show, setShow] = React.useState(false);
2283
- const [loading, setLoading] = React.useState(false);
2284
2348
  const resolveRef = useInlineRefResolver();
2285
2349
  const data = useResolvedObject(unresolvedData);
2350
+ const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
2286
2351
  const title = (_a = data.title) !== null && _a !== void 0 ? _a : nodeTitle;
2287
2352
  const isInternal = !!data['x-internal'];
2288
- const handleLoadMorePress = () => {
2289
- setLoading(true);
2290
- setTimeout(() => setShow(true), 50);
2291
- };
2292
- const examples = React.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
2293
2353
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
2294
2354
  const header = (shouldDisplayHeader || isInternal) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
2295
2355
  React.createElement(HStack, { spacing: 5 },
2296
2356
  title && (React.createElement(Heading, { size: 1, fontWeight: "semibold" }, title)),
2297
2357
  React.createElement(HStack, { spacing: 2 }, isInternal && React.createElement(InternalBadge, null))),
2298
2358
  exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React.createElement(ExportButton, Object.assign({}, exportProps))));
2359
+ const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
2299
2360
  const description = (React.createElement(VStack, { spacing: 10 },
2300
2361
  data.description && data.type === 'object' && React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
2362
+ isCompact && modelExamples,
2301
2363
  React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(data) })));
2302
- const examplesSelect = examples.length > 1 && (React.createElement(Select, { "aria-label": "Example", value: String(chosenExampleIndex), options: examples.map(({ label }, index) => ({ value: index, label })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Example: " }));
2303
- const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && (React.createElement(Panel, { rounded: true, isCollapsible: false },
2304
- React.createElement(Panel.Titlebar, null, examplesSelect || (React.createElement(Text, { color: "body", role: "heading" }, "Example"))),
2305
- React.createElement(Panel.Content, { p: 0 }, show || !exceedsSize(examples[chosenExampleIndex].data) ? (React.createElement(CodeViewer, { "aria-label": examples[chosenExampleIndex].data, noCopyButton: true, maxHeight: "500px", language: "json", value: examples[chosenExampleIndex].data, showLineNumbers: true })) : (React.createElement(LoadMore, { loading: loading, onClick: handleLoadMorePress })))));
2306
- return (React.createElement(TwoColumnLayout, { className: cn('Model', className), header: header, left: description, right: modelExamples }));
2364
+ return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
2307
2365
  };
2366
+ const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
2367
+ var _a;
2368
+ const [chosenExampleIndex, setChosenExampleIndex] = React.useState(0);
2369
+ const [show, setShow] = React.useState(false);
2370
+ const [loading, setLoading] = React.useState(false);
2371
+ const examples = React.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
2372
+ const selectedExample = (_a = examples[chosenExampleIndex]) === null || _a === void 0 ? void 0 : _a.data;
2373
+ const handleLoadMorePress = React.useCallback(() => {
2374
+ setLoading(true);
2375
+ setTimeout(() => setShow(true), 50);
2376
+ }, []);
2377
+ const examplesSelect = examples.length > 1 && (React.createElement(Select, { "aria-label": "Example", value: String(chosenExampleIndex), options: examples.map(({ label }, index) => ({ value: index, label })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Example: " }));
2378
+ return (React.createElement(Panel, { rounded: true, isCollapsible: isCollapsible, defaultIsOpen: !isCollapsible },
2379
+ React.createElement(Panel.Titlebar, { rightComponent: selectedExample ? React.createElement(CopyButton, { size: "sm", copyValue: selectedExample }) : null }, examplesSelect || (React.createElement(Text, { color: "body", role: "heading" }, "Example"))),
2380
+ React.createElement(Panel.Content, { p: 0 }, show || !exceedsSize(selectedExample) ? (React.createElement(CodeViewer, { "aria-label": selectedExample, noCopyButton: true, maxHeight: "500px", language: "json", value: selectedExample, showLineNumbers: true })) : (React.createElement(LoadMore, { loading: loading, onClick: handleLoadMorePress })))));
2381
+ });
2308
2382
  const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
2309
2383
 
2310
2384
  const Docs = React.memo((_a) => {
@@ -2663,7 +2737,7 @@ const Version = ({ value }) => {
2663
2737
 
2664
2738
  const NonIdealState = ({ description, icon, title }) => {
2665
2739
  return (React.createElement(Flex, { flexDirection: "col", alignItems: "center", justifyContent: "center", textAlign: "center", w: "full", h: "full" },
2666
- React.createElement(Box, { as: Icon, icon: icon || faExclamationTriangle, color: "light", fontSize: "6xl", mb: 4 }),
2740
+ React.createElement(Box, { as: Icon, icon: icon || ['fas', 'exclamation-triangle'], color: "light", fontSize: "6xl", mb: 4 }),
2667
2741
  React.createElement(Heading, { size: 4, mb: 4 }, title),
2668
2742
  React.createElement(Text, null, description)));
2669
2743
  };
package/index.js CHANGED
@@ -15,7 +15,6 @@ var reactErrorBoundary = require('@stoplight/react-error-boundary');
15
15
  var markdownViewer = require('@stoplight/markdown-viewer');
16
16
  var cn = require('classnames');
17
17
  var utils = require('jotai/utils');
18
- var freeSolidSvgIcons = require('@fortawesome/free-solid-svg-icons');
19
18
  var jotai = require('jotai');
20
19
  var URI = require('urijs');
21
20
  var mosaicCodeViewer = require('@stoplight/mosaic-code-viewer');
@@ -280,6 +279,58 @@ const ArticleComponent = React__namespace.memo(({ data }) => {
280
279
  });
281
280
  const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
282
281
 
282
+ /*!
283
+ * Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com
284
+ * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
285
+ * Copyright 2022 Fonticons, Inc.
286
+ */
287
+ var faBolt = {
288
+ prefix: 'fas',
289
+ iconName: 'bolt',
290
+ icon: [384, 512, [9889, "zap"], "f0e7", "M240.5 224H352C365.3 224 377.3 232.3 381.1 244.7C386.6 257.2 383.1 271.3 373.1 280.1L117.1 504.1C105.8 513.9 89.27 514.7 77.19 505.9C65.1 497.1 60.7 481.1 66.59 467.4L143.5 288H31.1C18.67 288 6.733 279.7 2.044 267.3C-2.645 254.8 .8944 240.7 10.93 231.9L266.9 7.918C278.2-1.92 294.7-2.669 306.8 6.114C318.9 14.9 323.3 30.87 317.4 44.61L240.5 224z"]
291
+ };
292
+ var faBookOpen = {
293
+ prefix: 'fas',
294
+ iconName: 'book-open',
295
+ icon: [576, 512, [128366, 128214], "f518", "M144.3 32.04C106.9 31.29 63.7 41.44 18.6 61.29c-11.42 5.026-18.6 16.67-18.6 29.15l0 357.6c0 11.55 11.99 19.55 22.45 14.65c126.3-59.14 219.8 11 223.8 14.01C249.1 478.9 252.5 480 256 480c12.4 0 16-11.38 16-15.98V80.04c0-5.203-2.531-10.08-6.781-13.08C263.3 65.58 216.7 33.35 144.3 32.04zM557.4 61.29c-45.11-19.79-88.48-29.61-125.7-29.26c-72.44 1.312-118.1 33.55-120.9 34.92C306.5 69.96 304 74.83 304 80.04v383.1C304 468.4 307.5 480 320 480c3.484 0 6.938-1.125 9.781-3.328c3.925-3.018 97.44-73.16 223.8-14c10.46 4.896 22.45-3.105 22.45-14.65l.0001-357.6C575.1 77.97 568.8 66.31 557.4 61.29z"]
296
+ };
297
+ var faCircleQuestion = {
298
+ prefix: 'fas',
299
+ iconName: 'circle-question',
300
+ icon: [512, 512, [62108, "question-circle"], "f059", "M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256s256-114.6 256-256S397.4 0 256 0zM256 400c-18 0-32-14-32-32s13.1-32 32-32c17.1 0 32 14 32 32S273.1 400 256 400zM325.1 258L280 286V288c0 13-11 24-24 24S232 301 232 288V272c0-8 4-16 12-21l57-34C308 213 312 206 312 198C312 186 301.1 176 289.1 176h-51.1C225.1 176 216 186 216 198c0 13-11 24-24 24s-24-11-24-24C168 159 199 128 237.1 128h51.1C329 128 360 159 360 198C360 222 347 245 325.1 258z"]
301
+ };
302
+ var faQuestionCircle = faCircleQuestion;
303
+ var faCloud = {
304
+ prefix: 'fas',
305
+ iconName: 'cloud',
306
+ icon: [640, 512, [9729], "f0c2", "M96.2 200.1C96.07 197.4 96 194.7 96 192C96 103.6 167.6 32 256 32C315.3 32 367 64.25 394.7 112.2C409.9 101.1 428.3 96 448 96C501 96 544 138.1 544 192C544 204.2 541.7 215.8 537.6 226.6C596 238.4 640 290.1 640 352C640 422.7 582.7 480 512 480H144C64.47 480 0 415.5 0 336C0 273.2 40.17 219.8 96.2 200.1z"]
307
+ };
308
+ var faCrosshairs = {
309
+ prefix: 'fas',
310
+ iconName: 'crosshairs',
311
+ icon: [512, 512, [], "f05b", "M224 256C224 238.3 238.3 224 256 224C273.7 224 288 238.3 288 256C288 273.7 273.7 288 256 288C238.3 288 224 273.7 224 256zM256 0C273.7 0 288 14.33 288 32V42.35C381.7 56.27 455.7 130.3 469.6 224H480C497.7 224 512 238.3 512 256C512 273.7 497.7 288 480 288H469.6C455.7 381.7 381.7 455.7 288 469.6V480C288 497.7 273.7 512 256 512C238.3 512 224 497.7 224 480V469.6C130.3 455.7 56.27 381.7 42.35 288H32C14.33 288 0 273.7 0 256C0 238.3 14.33 224 32 224H42.35C56.27 130.3 130.3 56.27 224 42.35V32C224 14.33 238.3 0 256 0V0zM224 404.6V384C224 366.3 238.3 352 256 352C273.7 352 288 366.3 288 384V404.6C346.3 392.1 392.1 346.3 404.6 288H384C366.3 288 352 273.7 352 256C352 238.3 366.3 224 384 224H404.6C392.1 165.7 346.3 119.9 288 107.4V128C288 145.7 273.7 160 256 160C238.3 160 224 145.7 224 128V107.4C165.7 119.9 119.9 165.7 107.4 224H128C145.7 224 160 238.3 160 256C160 273.7 145.7 288 128 288H107.4C119.9 346.3 165.7 392.1 224 404.6z"]
312
+ };
313
+ var faCube = {
314
+ prefix: 'fas',
315
+ iconName: 'cube',
316
+ icon: [512, 512, [], "f1b2", "M234.5 5.709C248.4 .7377 263.6 .7377 277.5 5.709L469.5 74.28C494.1 83.38 512 107.5 512 134.6V377.4C512 404.5 494.1 428.6 469.5 437.7L277.5 506.3C263.6 511.3 248.4 511.3 234.5 506.3L42.47 437.7C17 428.6 0 404.5 0 377.4V134.6C0 107.5 17 83.38 42.47 74.28L234.5 5.709zM256 65.98L82.34 128L256 190L429.7 128L256 65.98zM288 434.6L448 377.4V189.4L288 246.6V434.6z"]
317
+ };
318
+ var faDatabase = {
319
+ prefix: 'fas',
320
+ iconName: 'database',
321
+ icon: [448, 512, [], "f1c0", "M448 80V128C448 172.2 347.7 208 224 208C100.3 208 0 172.2 0 128V80C0 35.82 100.3 0 224 0C347.7 0 448 35.82 448 80zM393.2 214.7C413.1 207.3 433.1 197.8 448 186.1V288C448 332.2 347.7 368 224 368C100.3 368 0 332.2 0 288V186.1C14.93 197.8 34.02 207.3 54.85 214.7C99.66 230.7 159.5 240 224 240C288.5 240 348.3 230.7 393.2 214.7V214.7zM54.85 374.7C99.66 390.7 159.5 400 224 400C288.5 400 348.3 390.7 393.2 374.7C413.1 367.3 433.1 357.8 448 346.1V432C448 476.2 347.7 512 224 512C100.3 512 0 476.2 0 432V346.1C14.93 357.8 34.02 367.3 54.85 374.7z"]
322
+ };
323
+ var faEye = {
324
+ prefix: 'fas',
325
+ iconName: 'eye',
326
+ icon: [576, 512, [128065], "f06e", "M279.6 160.4C282.4 160.1 285.2 160 288 160C341 160 384 202.1 384 256C384 309 341 352 288 352C234.1 352 192 309 192 256C192 253.2 192.1 250.4 192.4 247.6C201.7 252.1 212.5 256 224 256C259.3 256 288 227.3 288 192C288 180.5 284.1 169.7 279.6 160.4zM480.6 112.6C527.4 156 558.7 207.1 573.5 243.7C576.8 251.6 576.8 260.4 573.5 268.3C558.7 304 527.4 355.1 480.6 399.4C433.5 443.2 368.8 480 288 480C207.2 480 142.5 443.2 95.42 399.4C48.62 355.1 17.34 304 2.461 268.3C-.8205 260.4-.8205 251.6 2.461 243.7C17.34 207.1 48.62 156 95.42 112.6C142.5 68.84 207.2 32 288 32C368.8 32 433.5 68.84 480.6 112.6V112.6zM288 112C208.5 112 144 176.5 144 256C144 335.5 208.5 400 288 400C367.5 400 432 335.5 432 256C432 176.5 367.5 112 288 112z"]
327
+ };
328
+ var faServer = {
329
+ prefix: 'fas',
330
+ iconName: 'server',
331
+ icon: [512, 512, [], "f233", "M480 288H32c-17.62 0-32 14.38-32 32v128c0 17.62 14.38 32 32 32h448c17.62 0 32-14.38 32-32v-128C512 302.4 497.6 288 480 288zM352 408c-13.25 0-24-10.75-24-24s10.75-24 24-24s24 10.75 24 24S365.3 408 352 408zM416 408c-13.25 0-24-10.75-24-24s10.75-24 24-24s24 10.75 24 24S429.3 408 416 408zM480 32H32C14.38 32 0 46.38 0 64v128c0 17.62 14.38 32 32 32h448c17.62 0 32-14.38 32-32V64C512 46.38 497.6 32 480 32zM352 152c-13.25 0-24-10.75-24-24S338.8 104 352 104S376 114.8 376 128S365.3 152 352 152zM416 152c-13.25 0-24-10.75-24-24S402.8 104 416 104S440 114.8 440 128S429.3 152 416 152z"]
332
+ };
333
+
283
334
  const NodeTypeColors = {
284
335
  http_operation: '#6a6acb',
285
336
  http_service: '#e056fd',
@@ -305,16 +356,16 @@ const NodeTypePrettyName = {
305
356
  styleguide: '',
306
357
  };
307
358
  const NodeTypeIconDefs = {
308
- http_operation: freeSolidSvgIcons.faCrosshairs,
309
- http_service: freeSolidSvgIcons.faCloud,
310
- article: freeSolidSvgIcons.faBookOpen,
311
- model: freeSolidSvgIcons.faCube,
312
- http_server: freeSolidSvgIcons.faDatabase,
313
- unknown: freeSolidSvgIcons.faQuestionCircle,
314
- generic: freeSolidSvgIcons.faQuestionCircle,
315
- table_of_contents: freeSolidSvgIcons.faQuestionCircle,
316
- spectral_ruleset: freeSolidSvgIcons.faQuestionCircle,
317
- styleguide: freeSolidSvgIcons.faQuestionCircle,
359
+ http_operation: faCrosshairs,
360
+ http_service: faCloud,
361
+ article: faBookOpen,
362
+ model: faCube,
363
+ http_server: faDatabase,
364
+ unknown: faQuestionCircle,
365
+ generic: faQuestionCircle,
366
+ table_of_contents: faQuestionCircle,
367
+ spectral_ruleset: faQuestionCircle,
368
+ styleguide: faQuestionCircle,
318
369
  };
319
370
  const HttpMethodColors = {
320
371
  get: 'success',
@@ -1659,7 +1710,7 @@ const TryItResponse = ({ response }) => {
1659
1710
  ? parseBody(response.bodyText, responseType)
1660
1711
  : response.bodyText })) : response.blob && responseType === 'image' ? (React__namespace.createElement(mosaic.Flex, { justifyContent: "center" },
1661
1712
  React__namespace.createElement(mosaic.Image, { src: URL.createObjectURL(response.blob), alt: "response image" }))) : (React__namespace.createElement("p", null,
1662
- React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faExclamationCircle, mr: 2 }),
1713
+ React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: ['fas', 'exclamation-circle'], mr: 2 }),
1663
1714
  "No supported response body returned"))))));
1664
1715
  };
1665
1716
  const ResponseMenu = ({ types, type, onChange }) => {
@@ -1711,7 +1762,7 @@ const ServersDropdown = ({ servers }) => {
1711
1762
  ],
1712
1763
  },
1713
1764
  ];
1714
- return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Server", items: serverItems, closeOnPress: true, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { icon: freeSolidSvgIcons.faServer, size: "sm", active: isOpen }, (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.name) || (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.description) || 'Server')) }));
1765
+ return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Server", items: serverItems, closeOnPress: true, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.FieldButton, { icon: faServer, size: "sm", active: isOpen }, (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.name) || (chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.description) || 'Server')) }));
1715
1766
  };
1716
1767
  ServersDropdown.displayName = 'ServersDropdown';
1717
1768
 
@@ -1839,7 +1890,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
1839
1890
  servers.length > 1 && React__namespace.createElement(ServersDropdown, { servers: servers }),
1840
1891
  isMockingEnabled && (React__namespace.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
1841
1892
  validateParameters && hasRequiredButEmptyParameters && (React__namespace.createElement(mosaic.Box, { mt: 4, color: "danger-light", fontSize: "sm" },
1842
- React__namespace.createElement(mosaic.Icon, { icon: freeSolidSvgIcons.faExclamationTriangle, className: "sl-mr-1" }),
1893
+ React__namespace.createElement(mosaic.Icon, { icon: ['fas', 'exclamation-triangle'], className: "sl-mr-1" }),
1843
1894
  "You didn't provide all of the required parameters!")))));
1844
1895
  let tryItPanelElem;
1845
1896
  if (embeddedInMd) {
@@ -1889,7 +1940,7 @@ const ResponseExamples = ({ httpOperation, responseMediaType, responseStatusCode
1889
1940
  return null;
1890
1941
  const examplesSelect = userDefinedExamples && userDefinedExamples.length > 1 && (React__default["default"].createElement(mosaic.Select, { "aria-label": "Response Example", value: String(chosenExampleIndex), options: userDefinedExamples.map((example, index) => ({ value: index, label: example.key })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Response Example: " }));
1891
1942
  return (React__default["default"].createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
1892
- React__default["default"].createElement(mosaic.Panel.Titlebar, null, examplesSelect || React__default["default"].createElement(mosaic.Text, { color: "body" }, "Response Example")),
1943
+ React__default["default"].createElement(mosaic.Panel.Titlebar, { rightComponent: React__default["default"].createElement(mosaic.CopyButton, { size: "sm", copyValue: responseExample || '' }) }, examplesSelect || React__default["default"].createElement(mosaic.Text, { color: "body" }, "Response Example")),
1893
1944
  React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(responseExample) ? (React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": responseExample, noCopyButton: true, maxHeight: "500px", language: "json", value: responseExample, showLineNumbers: true, style: {
1894
1945
  '--fs-code': 12,
1895
1946
  } })) : (React__default["default"].createElement(LoadMore, { loading: loading, onClick: handleLoadMore })))));
@@ -1906,14 +1957,14 @@ const TryItWithRequestSamples = (_a) => {
1906
1957
  React__namespace.createElement(ResponseExamples, Object.assign({}, props))));
1907
1958
  };
1908
1959
 
1909
- const TwoColumnLayout = ({ header, right, left, className }) => (React__default["default"].createElement(mosaic.VStack, { w: "full", className: className, spacing: 8 },
1960
+ const TwoColumnLayout = React__default["default"].forwardRef(({ header, right, left, className }, ref) => (React__default["default"].createElement(mosaic.VStack, { ref: ref, w: "full", className: className, spacing: 8 },
1910
1961
  header,
1911
1962
  React__default["default"].createElement(mosaic.Flex, null,
1912
- React__default["default"].createElement(mosaic.Box, { w: 0, flex: 1 }, left),
1913
- right && (React__default["default"].createElement(mosaic.Box, { ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right)))));
1963
+ React__default["default"].createElement(mosaic.Box, { "data-testid": "two-column-left", w: 0, flex: 1 }, left),
1964
+ right && (React__default["default"].createElement(mosaic.Box, { "data-testid": "two-column-right", ml: 16, pos: "relative", w: "2/5", style: { maxWidth: 500 } }, right))))));
1914
1965
 
1915
- const DeprecatedBadge = () => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { intent: "warning", icon: freeSolidSvgIcons.faExclamationCircle, "data-testid": "badge-deprecated" }, "Deprecated") }, "This operation has been marked as deprecated, which means it could be removed at some point in the future."));
1916
- const InternalBadge = ({ isHttpService }) => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { icon: freeSolidSvgIcons.faEye, "data-testid": "badge-internal", bg: "danger" }, "Internal") }, `This ${isHttpService ? 'operation' : 'model'} is marked as internal and won't be visible in public docs.`));
1966
+ const DeprecatedBadge = () => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { intent: "warning", icon: ['fas', 'exclamation-circle'], "data-testid": "badge-deprecated" }, "Deprecated") }, "This operation has been marked as deprecated, which means it could be removed at some point in the future."));
1967
+ const InternalBadge = ({ isHttpService }) => (React__default["default"].createElement(mosaic.Tooltip, { renderTrigger: React__default["default"].createElement(mosaic.Badge, { icon: faEye, "data-testid": "badge-internal", bg: "danger" }, "Internal") }, `This ${isHttpService ? 'operation' : 'model'} is marked as internal and won't be visible in public docs.`));
1917
1968
  const VersionBadge = ({ value, backgroundColor }) => (React__default["default"].createElement(mosaic.Badge, { appearance: "solid", size: "sm", border: 0, style: {
1918
1969
  backgroundColor: backgroundColor || badgeDefaultBackgroundColor,
1919
1970
  color: badgeDefaultColor,
@@ -2230,7 +2281,7 @@ function MethodPathInner({ method, path, chosenServerUrl }) {
2230
2281
 
2231
2282
  const PoweredByLink = ({ source, pathname, packageType, layout = 'sidebar' }) => {
2232
2283
  return (React__namespace.createElement(mosaic.Flex, { as: "a", align: "center", borderT: layout === 'stacked' ? undefined : true, px: layout === 'stacked' ? 1 : 4, py: 3, justify: layout === 'stacked' ? 'end' : undefined, href: `https://stoplight.io/?utm_source=${packageType}&utm_medium=${source}&utm_campaign=powered_by&utm_content=${pathname}`, target: "_blank", rel: "noopener noreferrer" },
2233
- React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: freeSolidSvgIcons.faBolt, mr: 1, className: "fa-fw", style: { color: 'rgba(144, 97, 249, 1)' } }),
2284
+ React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: faBolt, mr: 1, className: "fa-fw", style: { color: 'rgba(144, 97, 249, 1)' } }),
2234
2285
  React__namespace.createElement(mosaic.Box, null,
2235
2286
  "powered by\u00A0",
2236
2287
  React__namespace.createElement("strong", null, "Stoplight"))));
@@ -2303,10 +2354,10 @@ const ServerUrl = ({ description, url, marginBottom = true }) => {
2303
2354
  React__namespace.createElement(mosaic.Tooltip, { placement: "right", renderTrigger: () => React__namespace.createElement(mosaic.Text, { "aria-label": description }, url) },
2304
2355
  !hasCopied && (React__namespace.createElement(mosaic.Box, { p: 1, onClick: onCopy, cursor: "pointer" },
2305
2356
  "Copy Server URL ",
2306
- React__namespace.createElement(mosaic.Icon, { className: "sl-ml-1", icon: freeSolidSvgIcons.faCopy }))),
2357
+ React__namespace.createElement(mosaic.Icon, { className: "sl-ml-1", icon: ['fas', 'copy'] }))),
2307
2358
  hasCopied && (React__namespace.createElement(mosaic.Box, { p: 1 },
2308
2359
  "Copied Server URL ",
2309
- React__namespace.createElement(mosaic.Icon, { className: "sl-ml-1", icon: freeSolidSvgIcons.faCheck }))))));
2360
+ React__namespace.createElement(mosaic.Icon, { className: "sl-ml-1", icon: ['fas', 'check'] }))))));
2310
2361
  };
2311
2362
 
2312
2363
  const HttpServiceComponent = React__namespace.memo(({ data, location = {}, layoutOptions, exportProps }) => {
@@ -2330,35 +2381,58 @@ const HttpServiceComponent = React__namespace.memo(({ data, location = {}, layou
2330
2381
  HttpServiceComponent.displayName = 'HttpService.Component';
2331
2382
  const HttpService = reactErrorBoundary.withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
2332
2383
 
2384
+ const getBreakpoints = (compact) => {
2385
+ if (!compact)
2386
+ return undefined;
2387
+ if (typeof compact === 'number') {
2388
+ return [
2389
+ ['compact', compact],
2390
+ ['regular', Infinity],
2391
+ ];
2392
+ }
2393
+ return [['compact', Infinity]];
2394
+ };
2395
+ function useIsCompact(layoutOptions) {
2396
+ const { ref, breakpoint } = mosaic.useBreakpoints(getBreakpoints(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.compact));
2397
+ return { ref: ref, isCompact: breakpoint === 'compact' };
2398
+ }
2399
+
2333
2400
  const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
2334
2401
  var _a;
2335
- const [chosenExampleIndex, setChosenExampleIndex] = React__namespace.useState(0);
2336
- const [show, setShow] = React__namespace.useState(false);
2337
- const [loading, setLoading] = React__namespace.useState(false);
2338
2402
  const resolveRef = useInlineRefResolver();
2339
2403
  const data = useResolvedObject(unresolvedData);
2404
+ const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
2340
2405
  const title = (_a = data.title) !== null && _a !== void 0 ? _a : nodeTitle;
2341
2406
  const isInternal = !!data['x-internal'];
2342
- const handleLoadMorePress = () => {
2343
- setLoading(true);
2344
- setTimeout(() => setShow(true), 50);
2345
- };
2346
- const examples = React__namespace.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
2347
2407
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
2348
2408
  const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
2349
2409
  React__namespace.createElement(mosaic.HStack, { spacing: 5 },
2350
2410
  title && (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, title)),
2351
2411
  React__namespace.createElement(mosaic.HStack, { spacing: 2 }, isInternal && React__namespace.createElement(InternalBadge, null))),
2352
2412
  exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
2413
+ const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React__namespace.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
2353
2414
  const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
2354
2415
  data.description && data.type === 'object' && React__namespace.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
2416
+ isCompact && modelExamples,
2355
2417
  React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, schema: getOriginalObject(data) })));
2356
- const examplesSelect = examples.length > 1 && (React__namespace.createElement(mosaic.Select, { "aria-label": "Example", value: String(chosenExampleIndex), options: examples.map(({ label }, index) => ({ value: index, label })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Example: " }));
2357
- const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && (React__namespace.createElement(mosaic.Panel, { rounded: true, isCollapsible: false },
2358
- React__namespace.createElement(mosaic.Panel.Titlebar, null, examplesSelect || (React__namespace.createElement(mosaic.Text, { color: "body", role: "heading" }, "Example"))),
2359
- React__namespace.createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(examples[chosenExampleIndex].data) ? (React__namespace.createElement(mosaicCodeViewer.CodeViewer, { "aria-label": examples[chosenExampleIndex].data, noCopyButton: true, maxHeight: "500px", language: "json", value: examples[chosenExampleIndex].data, showLineNumbers: true })) : (React__namespace.createElement(LoadMore, { loading: loading, onClick: handleLoadMorePress })))));
2360
- return (React__namespace.createElement(TwoColumnLayout, { className: cn__default["default"]('Model', className), header: header, left: description, right: modelExamples }));
2418
+ return (React__namespace.createElement(TwoColumnLayout, { ref: layoutRef, className: cn__default["default"]('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
2361
2419
  };
2420
+ const ModelExamples = React__namespace.memo(({ data, isCollapsible = false }) => {
2421
+ var _a;
2422
+ const [chosenExampleIndex, setChosenExampleIndex] = React__namespace.useState(0);
2423
+ const [show, setShow] = React__namespace.useState(false);
2424
+ const [loading, setLoading] = React__namespace.useState(false);
2425
+ const examples = React__namespace.useMemo(() => generateExamplesFromJsonSchema(data), [data]);
2426
+ const selectedExample = (_a = examples[chosenExampleIndex]) === null || _a === void 0 ? void 0 : _a.data;
2427
+ const handleLoadMorePress = React__namespace.useCallback(() => {
2428
+ setLoading(true);
2429
+ setTimeout(() => setShow(true), 50);
2430
+ }, []);
2431
+ const examplesSelect = examples.length > 1 && (React__namespace.createElement(mosaic.Select, { "aria-label": "Example", value: String(chosenExampleIndex), options: examples.map(({ label }, index) => ({ value: index, label })), onChange: (value) => setChosenExampleIndex(parseInt(String(value), 10)), size: "sm", triggerTextPrefix: "Example: " }));
2432
+ return (React__namespace.createElement(mosaic.Panel, { rounded: true, isCollapsible: isCollapsible, defaultIsOpen: !isCollapsible },
2433
+ React__namespace.createElement(mosaic.Panel.Titlebar, { rightComponent: selectedExample ? React__namespace.createElement(mosaic.CopyButton, { size: "sm", copyValue: selectedExample }) : null }, examplesSelect || (React__namespace.createElement(mosaic.Text, { color: "body", role: "heading" }, "Example"))),
2434
+ React__namespace.createElement(mosaic.Panel.Content, { p: 0 }, show || !exceedsSize(selectedExample) ? (React__namespace.createElement(mosaicCodeViewer.CodeViewer, { "aria-label": selectedExample, noCopyButton: true, maxHeight: "500px", language: "json", value: selectedExample, showLineNumbers: true })) : (React__namespace.createElement(LoadMore, { loading: loading, onClick: handleLoadMorePress })))));
2435
+ });
2362
2436
  const Model = reactErrorBoundary.withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
2363
2437
 
2364
2438
  const Docs = React__namespace.memo((_a) => {
@@ -2542,10 +2616,10 @@ const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
2542
2616
  };
2543
2617
 
2544
2618
  const NODE_TYPE_TITLE_ICON = {
2545
- http_service: freeSolidSvgIcons.faCloud,
2619
+ http_service: faCloud,
2546
2620
  };
2547
2621
  const NODE_TYPE_META_ICON = {
2548
- model: freeSolidSvgIcons.faCube,
2622
+ model: faCube,
2549
2623
  };
2550
2624
  const NODE_TYPE_ICON_COLOR = {
2551
2625
  model: 'warning',
@@ -2717,7 +2791,7 @@ const Version = ({ value }) => {
2717
2791
 
2718
2792
  const NonIdealState = ({ description, icon, title }) => {
2719
2793
  return (React__namespace.createElement(mosaic.Flex, { flexDirection: "col", alignItems: "center", justifyContent: "center", textAlign: "center", w: "full", h: "full" },
2720
- React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: icon || freeSolidSvgIcons.faExclamationTriangle, color: "light", fontSize: "6xl", mb: 4 }),
2794
+ React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: icon || ['fas', 'exclamation-triangle'], color: "light", fontSize: "6xl", mb: 4 }),
2721
2795
  React__namespace.createElement(mosaic.Heading, { size: 4, mb: 4 }, title),
2722
2796
  React__namespace.createElement(mosaic.Text, null, description)));
2723
2797
  };