@stoplight/elements-core 7.5.18 → 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.
- package/components/Docs/Docs.d.ts +1 -0
- package/components/Docs/TwoColumnLayout.d.ts +1 -1
- package/hooks/useIsCompact.d.ts +6 -0
- package/index.d.ts +1 -1
- package/index.esm.js +99 -25
- package/index.js +113 -39
- package/index.mjs +99 -25
- package/package.json +10 -11
- package/styles.min.css +1 -1
package/index.mjs
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:
|
|
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:
|
|
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,
|
|
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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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 ||
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements-core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.0",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"web-components.min.js",
|
|
@@ -24,19 +24,18 @@
|
|
|
24
24
|
"react-dom": ">=16.8"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@stoplight/json": "^3.18.0",
|
|
27
|
+
"@stoplight/json": "^3.18.1",
|
|
29
28
|
"@stoplight/json-schema-ref-parser": "^9.0.5",
|
|
30
29
|
"@stoplight/json-schema-sampler": "0.2.2",
|
|
31
|
-
"@stoplight/json-schema-viewer": "^4.
|
|
32
|
-
"@stoplight/markdown-viewer": "^5.
|
|
33
|
-
"@stoplight/mosaic": "^1.
|
|
34
|
-
"@stoplight/mosaic-code-editor": "^1.
|
|
35
|
-
"@stoplight/mosaic-code-viewer": "^1.
|
|
30
|
+
"@stoplight/json-schema-viewer": "^4.7.0",
|
|
31
|
+
"@stoplight/markdown-viewer": "^5.5.0",
|
|
32
|
+
"@stoplight/mosaic": "^1.24.0",
|
|
33
|
+
"@stoplight/mosaic-code-editor": "^1.24.0",
|
|
34
|
+
"@stoplight/mosaic-code-viewer": "^1.24.0",
|
|
36
35
|
"@stoplight/path": "^1.3.2",
|
|
37
36
|
"@stoplight/react-error-boundary": "^2.0.0",
|
|
38
37
|
"@stoplight/types": "^13.0.0",
|
|
39
|
-
"@stoplight/yaml": "^4.2.
|
|
38
|
+
"@stoplight/yaml": "^4.2.3",
|
|
40
39
|
"classnames": "^2.2.6",
|
|
41
40
|
"httpsnippet": "^1.24.0",
|
|
42
41
|
"jotai": "1.3.9",
|
|
@@ -44,13 +43,13 @@
|
|
|
44
43
|
"lodash": "^4.17.19",
|
|
45
44
|
"nanoid": "^3.1.32",
|
|
46
45
|
"prop-types": "^15.7.2",
|
|
47
|
-
"react-query": "^3.
|
|
46
|
+
"react-query": "^3.34.19",
|
|
48
47
|
"react-router-dom": "^5.2.0",
|
|
49
48
|
"react-router-hash-link": "^2.1.0",
|
|
50
49
|
"tslib": "^2.1.0",
|
|
51
50
|
"urijs": "^1.19.11",
|
|
52
51
|
"util": "^0.12.4",
|
|
53
|
-
"xml-formatter": "^2.
|
|
52
|
+
"xml-formatter": "^2.6.1"
|
|
54
53
|
},
|
|
55
54
|
"type": "commonjs",
|
|
56
55
|
"exports": {
|