@stoplight/elements-core 7.16.6 → 8.0.1

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.
Files changed (33) hide show
  1. package/components/Docs/Article/Article.stories.d.ts +4 -4
  2. package/components/Docs/Docs.stories.d.ts +1 -1
  3. package/components/Docs/HttpOperation/HttpOperation.d.ts +2 -2
  4. package/components/Docs/HttpOperation/HttpOperation.stories.d.ts +2 -2
  5. package/components/Docs/HttpOperation/Request.d.ts +2 -2
  6. package/components/Docs/HttpService/HttpService.stories.d.ts +2 -2
  7. package/components/Docs/Model/Model.stories.d.ts +2 -2
  8. package/components/Layout/MobileTopNav.d.ts +9 -0
  9. package/components/Layout/ResponsiveSidebarLayout.d.ts +22 -0
  10. package/components/Logo.d.ts +4 -10
  11. package/components/RequestSamples/RequestSamples.stories.d.ts +2 -2
  12. package/components/ResponseExamples/ResponseExamples.d.ts +2 -2
  13. package/components/ResponseExamples/ResponseExamples.stories.d.ts +2 -2
  14. package/components/{MosaicTableOfContents → TableOfContents}/constants.d.ts +6 -4
  15. package/components/{MosaicTableOfContents → TableOfContents}/index.d.ts +1 -0
  16. package/components/{MosaicTableOfContents → TableOfContents}/types.d.ts +2 -1
  17. package/components/TryIt/Parameters/useOperationParameters.d.ts +2 -2
  18. package/components/TryIt/TryIt.d.ts +2 -2
  19. package/components/TryIt/TryIt.stories.d.ts +11 -11
  20. package/components/TryIt/TryItWithRequestSamples.stories.d.ts +3 -3
  21. package/hooks/useResponsiveLayout.d.ts +13 -0
  22. package/index.d.ts +7 -4
  23. package/index.esm.js +387 -191
  24. package/index.js +388 -188
  25. package/index.mjs +387 -191
  26. package/package.json +3 -3
  27. package/styles.min.css +1 -1
  28. package/types.d.ts +10 -1
  29. package/utils/guards.d.ts +2 -1
  30. /package/components/{MosaicTableOfContents → TableOfContents}/TableOfContents.d.ts +0 -0
  31. /package/components/{MosaicTableOfContents → TableOfContents}/TableOfContents.spec.d.ts +0 -0
  32. /package/components/{MosaicTableOfContents → TableOfContents}/TableOfContents.stories.d.ts +0 -0
  33. /package/components/{MosaicTableOfContents → TableOfContents}/utils.d.ts +0 -0
package/index.mjs CHANGED
@@ -7,10 +7,10 @@ import isArray from 'lodash/isArray.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, useBreakpoints, Panel, CopyButton, Menu, Button, Text, Flex, Input, Icon, Select, FieldButton, Image, Link, useThemeIsDark, HStack, VStack, InvertTheme, Tooltip, Badge, LinkHeading as LinkHeading$1, NodeAnnotation, Callout, useModalState, Modal, ListBox, ListBoxItem, TabList, Tab, Tabs, TabPanels, TabPanel, Heading, useClipboard, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
10
+ import { isArray as isArray$1, Box, useBreakpoints, Panel, CopyButton, Menu, Button, Text, Flex, Input, Icon, Select, FieldButton, Image, Link, useThemeIsDark, HStack, VStack, InvertTheme, Tooltip, Badge, LinkHeading as LinkHeading$1, NodeAnnotation, Callout, useModalState, Modal, ListBox, ListBoxItem, TabList, Tab, Tabs, TabPanels, TabPanel, Heading, useClipboard, Drawer, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
11
11
  import isObject from 'lodash/isObject.js';
12
12
  import { withErrorBoundary } from '@stoplight/react-error-boundary';
13
- import { useLocation, BrowserRouter, MemoryRouter, HashRouter, StaticRouter, Route } from 'react-router-dom';
13
+ import { useLocation, Link as Link$1, BrowserRouter, MemoryRouter, HashRouter, StaticRouter, Route } from 'react-router-dom';
14
14
  import { MarkdownViewer as MarkdownViewer$1, DefaultSMDComponents, MarkdownViewerProvider } from '@stoplight/markdown-viewer';
15
15
  export { DefaultSMDComponents } from '@stoplight/markdown-viewer';
16
16
  import cn from 'classnames';
@@ -180,6 +180,11 @@ function isHttpService(maybeHttpService) {
180
180
  function isHttpOperation(maybeHttpOperation) {
181
181
  return isStoplightNode(maybeHttpOperation) && 'method' in maybeHttpOperation && 'path' in maybeHttpOperation;
182
182
  }
183
+ function isHttpWebhookOperation(maybeHttpWebhookOperation) {
184
+ return (isStoplightNode(maybeHttpWebhookOperation) &&
185
+ 'method' in maybeHttpWebhookOperation &&
186
+ 'name' in maybeHttpWebhookOperation);
187
+ }
183
188
  const properUrl = new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/);
184
189
  function isProperUrl(url) {
185
190
  return properUrl.test(url);
@@ -191,6 +196,7 @@ function useParsedData(nodeType, data) {
191
196
  const parserMap = {
192
197
  [NodeType.Article]: parseArticleData,
193
198
  [NodeType.HttpOperation]: parseHttpOperation,
199
+ [NodeType.HttpWebhook]: parseHttpWebhookOperation,
194
200
  [NodeType.HttpService]: parseHttpService,
195
201
  [NodeType.Model]: parseModel,
196
202
  [NodeType.HttpServer]: parseUnknown,
@@ -223,6 +229,16 @@ function parseHttpOperation(rawData) {
223
229
  }
224
230
  return undefined;
225
231
  }
232
+ function parseHttpWebhookOperation(rawData) {
233
+ const data = tryParseYamlOrObject(rawData);
234
+ if (isHttpWebhookOperation(data)) {
235
+ return {
236
+ type: NodeType.HttpWebhook,
237
+ data: data,
238
+ };
239
+ }
240
+ return undefined;
241
+ }
226
242
  function parseHttpService(rawData) {
227
243
  const data = tryParseYamlOrObject(rawData);
228
244
  if (isHttpService(data)) {
@@ -292,6 +308,11 @@ const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data']
292
308
  * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
293
309
  * Copyright 2022 Fonticons, Inc.
294
310
  */
311
+ var faBars = {
312
+ prefix: 'fas',
313
+ iconName: 'bars',
314
+ icon: [448, 512, ["navicon"], "f0c9", "M0 96C0 78.33 14.33 64 32 64H416C433.7 64 448 78.33 448 96C448 113.7 433.7 128 416 128H32C14.33 128 0 113.7 0 96zM0 256C0 238.3 14.33 224 32 224H416C433.7 224 448 238.3 448 256C448 273.7 433.7 288 416 288H32C14.33 288 0 273.7 0 256zM416 448H32C14.33 448 0 433.7 0 416C0 398.3 14.33 384 32 384H416C433.7 384 448 398.3 448 416C448 433.7 433.7 448 416 448z"]
315
+ };
295
316
  var faBolt = {
296
317
  prefix: 'fas',
297
318
  iconName: 'bolt',
@@ -338,6 +359,16 @@ var faDatabase = {
338
359
  iconName: 'database',
339
360
  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"]
340
361
  };
362
+ var faEnvelope = {
363
+ prefix: 'fas',
364
+ iconName: 'envelope',
365
+ icon: [512, 512, [128386, 61443, 9993], "f0e0", "M464 64C490.5 64 512 85.49 512 112C512 127.1 504.9 141.3 492.8 150.4L275.2 313.6C263.8 322.1 248.2 322.1 236.8 313.6L19.2 150.4C7.113 141.3 0 127.1 0 112C0 85.49 21.49 64 48 64H464zM217.6 339.2C240.4 356.3 271.6 356.3 294.4 339.2L512 176V384C512 419.3 483.3 448 448 448H64C28.65 448 0 419.3 0 384V176L217.6 339.2z"]
366
+ };
367
+ var faEnvelopesBulk = {
368
+ prefix: 'fas',
369
+ iconName: 'envelopes-bulk',
370
+ icon: [640, 512, ["mail-bulk"], "f674", "M191.9 448.6c-9.766 0-19.48-2.969-27.78-8.891L32 340.2V480c0 17.62 14.38 32 32 32h256c17.62 0 32-14.38 32-32v-139.8L220.2 439.5C211.7 445.6 201.8 448.6 191.9 448.6zM192 192c0-35.25 28.75-64 64-64h224V32c0-17.62-14.38-32-32-32H128C110.4 0 96 14.38 96 32v192h96V192zM320 256H64C46.38 256 32 270.4 32 288v12.18l151 113.8c5.25 3.719 12.7 3.734 18.27-.25L352 300.2V288C352 270.4 337.6 256 320 256zM576 160H256C238.4 160 224 174.4 224 192v32h96c33.25 0 60.63 25.38 63.75 57.88L384 416h192c17.62 0 32-14.38 32-32V192C608 174.4 593.6 160 576 160zM544 288h-64V224h64V288z"]
371
+ };
341
372
  var faEye = {
342
373
  prefix: 'fas',
343
374
  iconName: 'eye',
@@ -353,9 +384,15 @@ var faServer = {
353
384
  iconName: 'server',
354
385
  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"]
355
386
  };
387
+ var faX = {
388
+ prefix: 'fas',
389
+ iconName: 'x',
390
+ icon: [384, 512, [120], "58", "M376.6 427.5c11.31 13.58 9.484 33.75-4.094 45.06c-5.984 4.984-13.25 7.422-20.47 7.422c-9.172 0-18.27-3.922-24.59-11.52L192 305.1l-135.4 162.5c-6.328 7.594-15.42 11.52-24.59 11.52c-7.219 0-14.48-2.438-20.47-7.422c-13.58-11.31-15.41-31.48-4.094-45.06l142.9-171.5L7.422 84.5C-3.891 70.92-2.063 50.75 11.52 39.44c13.56-11.34 33.73-9.516 45.06 4.094L192 206l135.4-162.5c11.3-13.58 31.48-15.42 45.06-4.094c13.58 11.31 15.41 31.48 4.094 45.06l-142.9 171.5L376.6 427.5z"]
391
+ };
356
392
 
357
393
  const NodeTypeColors = {
358
394
  http_operation: '#6a6acb',
395
+ http_webhook: 'primary',
359
396
  http_service: '#e056fd',
360
397
  article: '#399da6',
361
398
  model: '#ef932b',
@@ -372,6 +409,7 @@ const NodeTypeColors = {
372
409
  };
373
410
  const NodeTypePrettyName = {
374
411
  http_operation: 'Endpoint',
412
+ http_webhook: 'Webhook',
375
413
  http_service: 'API',
376
414
  article: 'Article',
377
415
  model: 'Model',
@@ -388,6 +426,7 @@ const NodeTypePrettyName = {
388
426
  };
389
427
  const NodeTypeIconDefs = {
390
428
  http_operation: faCrosshairs,
429
+ http_webhook: faEnvelope,
391
430
  http_service: faCloud,
392
431
  article: faBookOpen,
393
432
  model: faCube,
@@ -2137,7 +2176,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2137
2176
  }, [servers, firstServer, chosenServer, setChosenServer]);
2138
2177
  React.useEffect(() => {
2139
2178
  let isMounted = true;
2140
- if (onRequestChange || embeddedInMd) {
2179
+ if (isHttpOperation(httpOperation) && (onRequestChange || embeddedInMd)) {
2141
2180
  buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, serverVariableValues,
2142
2181
  httpOperation, bodyInput: formDataState.isFormDataBody ? getValues() : textRequestBody, auth: operationAuthValue }, (isMockingEnabled && { mockData: getMockData(mockUrl, httpOperation, mockingOptions) })), { chosenServer,
2143
2182
  corsProxy })).then(request => {
@@ -2170,7 +2209,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2170
2209
  ]);
2171
2210
  const handleSendRequest = () => __awaiter(void 0, void 0, void 0, function* () {
2172
2211
  setValidateParameters(true);
2173
- if (hasRequiredButEmptyParameters)
2212
+ if (hasRequiredButEmptyParameters || !isHttpOperation(httpOperation))
2174
2213
  return;
2175
2214
  try {
2176
2215
  setLoading(true);
@@ -2218,23 +2257,33 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2218
2257
  const isOnlySendButton = !((_d = httpOperation.security) === null || _d === void 0 ? void 0 : _d.length) && !allParameters.length && !formDataState.isFormDataBody && !mediaTypeContent;
2219
2258
  const tryItPanelContents = (React.createElement(React.Fragment, null,
2220
2259
  ((_e = httpOperation.security) === null || _e === void 0 ? void 0 : _e.length) ? (React.createElement(TryItAuth, { operationSecuritySchemes: httpOperation.security, operationAuthValue: operationAuthValue, setOperationAuthValue: setOperationAuthValue, setCurrentScheme: setCurrentScheme })) : null,
2221
- serverVariables.length > 0 && (React.createElement(ServerVariables, { variables: serverVariables, values: serverVariableValues, onChangeValue: updateServerVariableValue })),
2260
+ isHttpOperation(httpOperation) && serverVariables.length > 0 && (React.createElement(ServerVariables, { variables: serverVariables, values: serverVariableValues, onChangeValue: updateServerVariableValue })),
2222
2261
  allParameters.length > 0 && (React.createElement(OperationParameters, { parameters: allParameters, values: parameterValuesWithDefaults, onChangeValue: updateParameterValue, validate: validateParameters })),
2223
- formDataState.isFormDataBody ? (React.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues, onChangeParameterAllow: setAllowedEmptyValues, isAllowedEmptyValues: isAllowedEmptyValues })) : mediaTypeContent ? (React.createElement(RequestBody, { examples: (_f = mediaTypeContent.examples) !== null && _f !== void 0 ? _f : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null,
2224
- React.createElement(Panel.Content, { className: "SendButtonHolder", mt: 4, pt: !isOnlySendButton && !embeddedInMd ? 0 : undefined },
2262
+ React.createElement(Box, { pb: 1 }, formDataState.isFormDataBody ? (React.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues, onChangeParameterAllow: setAllowedEmptyValues, isAllowedEmptyValues: isAllowedEmptyValues })) : mediaTypeContent ? (React.createElement(RequestBody, { examples: (_f = mediaTypeContent.examples) !== null && _f !== void 0 ? _f : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null),
2263
+ isHttpOperation(httpOperation) ? (React.createElement(Panel.Content, { className: "SendButtonHolder", pt: !isOnlySendButton && !embeddedInMd ? 0 : undefined },
2225
2264
  React.createElement(HStack, { alignItems: "center", spacing: 2 },
2226
2265
  React.createElement(Button, { appearance: "primary", loading: loading, disabled: loading, onPress: handleSendRequest, size: "sm" }, "Send API Request"),
2227
2266
  servers.length > 1 && React.createElement(ServersDropdown, { servers: servers }),
2228
2267
  isMockingEnabled && (React.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
2229
2268
  validateParameters && hasRequiredButEmptyParameters && (React.createElement(Box, { mt: 4, color: "danger-light", fontSize: "sm" },
2230
2269
  React.createElement(Icon, { icon: ['fas', 'exclamation-triangle'], className: "sl-mr-1" }),
2231
- "You didn't provide all of the required parameters!")))));
2270
+ "You didn't provide all of the required parameters!")))) : null));
2232
2271
  let tryItPanelElem;
2233
2272
  if (embeddedInMd) {
2273
+ let path;
2274
+ if (isHttpOperation(httpOperation)) {
2275
+ path = httpOperation.path;
2276
+ }
2277
+ else if (isHttpWebhookOperation(httpOperation)) {
2278
+ path = httpOperation.name;
2279
+ }
2280
+ else {
2281
+ throw new RangeError('unsupported type');
2282
+ }
2234
2283
  tryItPanelElem = (React.createElement(Panel, { isCollapsible: false, p: 0, className: "TryItPanel" },
2235
2284
  React.createElement(Panel.Titlebar, { bg: "canvas-300" },
2236
2285
  React.createElement(Box, { fontWeight: "bold", color: !isDark ? HttpMethodColors[httpOperation.method] : undefined }, httpOperation.method.toUpperCase()),
2237
- React.createElement(Box, { fontWeight: "medium", ml: 2, textOverflow: "truncate", overflowX: "hidden" }, `${(chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || ''}${httpOperation.path}`)),
2286
+ React.createElement(Box, { fontWeight: "medium", ml: 2, textOverflow: "truncate", overflowX: "hidden" }, `${(chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || ''}${path}`)),
2238
2287
  tryItPanelContents));
2239
2288
  }
2240
2289
  else {
@@ -2712,7 +2761,17 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
2712
2761
  const [requestBodyIndex, setTextRequestBodyIndex] = React.useState(0);
2713
2762
  const prettyName = (data.summary || data.iid || '').trim();
2714
2763
  const hasBadges = isDeprecated || isInternal;
2715
- const header = (React.createElement(OperationHeader, { id: data.id, method: data.method, path: data.path, noHeading: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading, hasBadges: hasBadges, name: prettyName, isDeprecated: isDeprecated, isInternal: isInternal }));
2764
+ let path;
2765
+ if (isHttpOperation(data)) {
2766
+ path = data.path;
2767
+ }
2768
+ else if (isHttpWebhookOperation(data)) {
2769
+ path = data.name;
2770
+ }
2771
+ else {
2772
+ throw new RangeError('unsupported node type');
2773
+ }
2774
+ const header = (React.createElement(OperationHeader, { id: data.id, method: data.method, path: path, noHeading: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading, hasBadges: hasBadges, name: prettyName, isDeprecated: isDeprecated, isInternal: isInternal, hideServerUrl: !isHttpOperation(data) }));
2716
2775
  const tryItPanel = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryItPanel) && (React.createElement(TryItWithRequestSamples, { httpOperation: data, responseMediaType: responseMediaType, responseStatusCode: responseStatusCode, requestBodyIndex: requestBodyIndex, hideTryIt: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryIt, tryItCredentialsPolicy: tryItCredentialsPolicy, mockUrl: mocking.hideMocking ? undefined : mocking.mockUrl, corsProxy: tryItCorsProxy }));
2717
2776
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: data.id, attr: 'description' });
2718
2777
  const description = (React.createElement(VStack, { spacing: 10 },
@@ -3035,6 +3094,7 @@ const ParsedDocs = (_a) => {
3035
3094
  case 'article':
3036
3095
  return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
3037
3096
  case 'http_operation':
3097
+ case 'http_webhook':
3038
3098
  return React.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
3039
3099
  case 'http_service':
3040
3100
  return React.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
@@ -3046,188 +3106,53 @@ const ParsedDocs = (_a) => {
3046
3106
  }
3047
3107
  };
3048
3108
 
3049
- const MAX_CONTENT_WIDTH = 1800;
3050
- const SIDEBAR_MIN_WIDTH = 300;
3051
- const SIDEBAR_MAX_WIDTH = 1.5 * SIDEBAR_MIN_WIDTH;
3052
- const SidebarLayout = React.forwardRef(({ sidebar, children, maxContentWidth = MAX_CONTENT_WIDTH, sidebarWidth = SIDEBAR_MIN_WIDTH }, ref) => {
3053
- const scrollRef = React.useRef(null);
3054
- const [sidebarRef, currentSidebarWidth, startResizing] = useResizer(sidebarWidth);
3055
- const { pathname } = useLocation();
3056
- React.useEffect(() => {
3057
- var _a;
3058
- (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
3059
- }, [pathname]);
3060
- return (React.createElement(Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
3061
- React.createElement(Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH}px` } },
3062
- React.createElement(Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
3063
- paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
3064
- width: `${currentSidebarWidth}px`,
3065
- minWidth: `${SIDEBAR_MIN_WIDTH}px`,
3066
- } }, sidebar),
3067
- React.createElement(Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } })),
3068
- React.createElement(Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full", overflowY: "auto" },
3069
- React.createElement(Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
3070
- });
3071
- function useResizer(sidebarWidth) {
3072
- const sidebarRef = React.useRef(null);
3073
- const [isResizing, setIsResizing] = React.useState(false);
3074
- const [currentSidebarWidth, setCurrentSidebarWidth] = React.useState(sidebarWidth);
3075
- const startResizing = React.useCallback(() => {
3076
- setIsResizing(true);
3077
- }, []);
3078
- const stopResizing = React.useCallback(() => {
3079
- setIsResizing(false);
3080
- }, []);
3081
- const resize = React.useCallback(mouseMoveEvent => {
3082
- if (isResizing) {
3083
- const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
3084
- setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH, value), SIDEBAR_MAX_WIDTH));
3085
- }
3086
- }, [isResizing]);
3087
- React.useEffect(() => {
3088
- window.addEventListener('mousemove', resize);
3089
- window.addEventListener('mouseup', stopResizing, { passive: true });
3090
- return () => {
3091
- window.removeEventListener('mousemove', resize);
3092
- window.removeEventListener('mouseup', stopResizing);
3093
- };
3094
- }, [resize, stopResizing]);
3095
- return [sidebarRef, currentSidebarWidth, startResizing];
3096
- }
3097
-
3098
- const Logo = ({ logo }) => {
3099
- var _a;
3100
- return (React.createElement(Box, { display: "inline", mr: 3, rounded: "lg", overflowY: "hidden", overflowX: "hidden", style: { backgroundColor: (_a = logo.backgroundColor) !== null && _a !== void 0 ? _a : 'transparent' } }, logo.href ? (React.createElement("a", { href: logo.href, target: "_blank", rel: "noopener noreferrer" },
3101
- React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
3102
- };
3103
-
3104
- function getDisplayName(WrappedComponent) {
3105
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
3106
- }
3107
-
3108
- const PersistenceContextProvider = Provider;
3109
- function withPersistenceBoundary(WrappedComponent) {
3110
- const WithPersistenceBoundary = props => {
3111
- return (React.createElement(PersistenceContextProvider, null,
3112
- React.createElement(WrappedComponent, Object.assign({}, props))));
3113
- };
3114
- WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
3115
- return WithPersistenceBoundary;
3116
- }
3117
-
3118
- function useParsedValue(value) {
3119
- return React.useMemo(() => {
3120
- let parsedValue = value;
3121
- if (typeof value === 'string') {
3122
- try {
3123
- parsedValue = parse(value);
3124
- }
3125
- catch (error) {
3126
- }
3127
- }
3128
- return parsedValue;
3129
- }, [value]);
3130
- }
3131
-
3132
- function isPartialHttpRequest(maybeHttpRequest) {
3133
- return (isObject(maybeHttpRequest) &&
3134
- 'method' in maybeHttpRequest &&
3135
- typeof maybeHttpRequest['method'] === 'string' &&
3136
- 'url' in maybeHttpRequest &&
3137
- typeof maybeHttpRequest['url'] === 'string');
3138
- }
3139
- const SchemaAndDescription = ({ title: titleProp, schema }) => {
3140
- const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3141
- const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
3142
- return (React__default.createElement(Box, { py: 2 },
3143
- title && (React__default.createElement(Flex, { alignItems: "center", p: 2 },
3144
- React__default.createElement(Icon, { icon: NodeTypeIconDefs[NodeType.Model], color: NodeTypeColors[NodeType.Model] }),
3145
- React__default.createElement(Box, { color: "muted", px: 2 }, title))),
3146
- React__default.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema) })));
3109
+ const ElementsBreakpoints = {
3110
+ docs: 700,
3147
3111
  };
3148
- const CodeComponent = props => {
3149
- const { title, jsonSchema, http, resolved, children } = props;
3150
- const resolver = useInlineRefResolver();
3151
- const value = resolved || String(Array.isArray(children) ? children[0] : children);
3152
- const parsedValue = useParsedValue(value);
3153
- if (jsonSchema) {
3154
- if (!isJSONSchema(parsedValue)) {
3155
- return null;
3156
- }
3157
- return (React__default.createElement(InlineRefResolverProvider, { document: parsedValue, resolver: resolver === null || resolver === void 0 ? void 0 : resolver.resolver, maxRefDepth: resolver === null || resolver === void 0 ? void 0 : resolver.maxRefDepth },
3158
- React__default.createElement(SchemaAndDescription, { title: title, schema: parsedValue })));
3112
+ var ScreenType;
3113
+ (function (ScreenType) {
3114
+ ScreenType[ScreenType["Phone"] = 415] = "Phone";
3115
+ ScreenType[ScreenType["Tablet"] = 750] = "Tablet";
3116
+ ScreenType[ScreenType["Resized_Browser"] = 980] = "Resized_Browser";
3117
+ ScreenType[ScreenType["Normal_Browser"] = 1000000] = "Normal_Browser";
3118
+ })(ScreenType || (ScreenType = {}));
3119
+ const getScreenType = () => {
3120
+ if ((window === null || window === void 0 ? void 0 : window.innerWidth) <= ScreenType.Phone) {
3121
+ return ScreenType.Phone;
3159
3122
  }
3160
- if (http) {
3161
- if (!isObject(parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
3162
- return null;
3163
- }
3164
- return (React__default.createElement(PersistenceContextProvider, null,
3165
- React__default.createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
3123
+ else if ((window === null || window === void 0 ? void 0 : window.innerWidth) <= ScreenType.Tablet) {
3124
+ return ScreenType.Tablet;
3166
3125
  }
3167
- const DefaultCode = DefaultSMDComponents.code;
3168
- return React__default.createElement(DefaultCode, Object.assign({}, props));
3126
+ else if ((window === null || window === void 0 ? void 0 : window.innerWidth) <= ScreenType.Resized_Browser) {
3127
+ return ScreenType.Resized_Browser;
3128
+ }
3129
+ return ScreenType.Normal_Browser;
3169
3130
  };
3170
- function parseHttpRequest(data) {
3171
- const uri = URI(data.url);
3172
- const pathParam = data.url.match(/[^{\}]+(?=})/g);
3131
+ const useResponsiveLayout = () => {
3132
+ const [screenType, setScreenType] = React.useState();
3133
+ const getElementsBreakpoint = (node) => {
3134
+ return ElementsBreakpoints[node];
3135
+ };
3136
+ React.useLayoutEffect(() => {
3137
+ function handleResize() {
3138
+ setScreenType(getScreenType());
3139
+ }
3140
+ window === null || window === void 0 ? void 0 : window.addEventListener('resize', handleResize);
3141
+ handleResize();
3142
+ return () => window === null || window === void 0 ? void 0 : window.removeEventListener('resize', handleResize);
3143
+ }, []);
3144
+ const isResponsiveLayoutEnabled = screenType !== ScreenType.Normal_Browser;
3173
3145
  return {
3174
- id: '?http-operation-id?',
3175
- method: data.method,
3176
- path: uri.is('absolute') ? uri.path() : data.url,
3177
- servers: [{ id: `?http-server-${uri.href()}?`, url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
3178
- request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => {
3179
- const defaultVal = Array.isArray(value) ? value[0] : value;
3180
- return {
3181
- id: `?http-query-${key}-id?`,
3182
- name: key,
3183
- style: HttpParamStyles.Form,
3184
- schema: { default: defaultVal },
3185
- required: isHttpRequestParamRequired(defaultVal),
3186
- };
3187
- }), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
3188
- id: `?http-header-${key}-id?`,
3189
- name: key,
3190
- style: HttpParamStyles.Simple,
3191
- schema: { default: value },
3192
- required: isHttpRequestParamRequired(value),
3193
- })), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
3194
- id: `?http-param-${name}-id?`,
3195
- name,
3196
- style: HttpParamStyles.Simple,
3197
- required: true,
3198
- })) }, (data.body
3199
- ? {
3200
- body: {
3201
- id: '?http-request-body?',
3202
- contents: [
3203
- {
3204
- id: '?http-request-body-media?',
3205
- mediaType: 'application/json',
3206
- schema: { default: data.body },
3207
- },
3208
- ],
3209
- },
3210
- }
3211
- : null)),
3212
- responses: [],
3146
+ isResponsiveLayoutEnabled,
3147
+ screenType,
3148
+ getElementsBreakpoint,
3213
3149
  };
3214
- }
3215
- function isHttpRequestParamRequired(value) {
3216
- return typeof value !== 'undefined';
3217
- }
3218
-
3219
- const MarkdownComponentsProvider = ({ value, children }) => {
3220
- return React.createElement(MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
3221
3150
  };
3222
3151
 
3223
- const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
3224
- const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
3225
- const href = to || _href;
3226
- const isExternal = href !== undefined && externalRegex.test(href);
3227
- if (isExternal) {
3228
- return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
3229
- }
3230
- return (React__default.createElement(HashLink, { to: href, title: title }, children));
3152
+ const Logo = ({ logo }) => {
3153
+ var _a;
3154
+ return (React.createElement(Box, { display: "inline", mr: 3, rounded: "lg", overflowY: "hidden", overflowX: "hidden", style: { backgroundColor: (_a = logo.backgroundColor) !== null && _a !== void 0 ? _a : 'transparent' } }, logo.href ? (React.createElement("a", { href: logo.href, target: "_blank", rel: "noopener noreferrer" },
3155
+ React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
3231
3156
  };
3232
3157
 
3233
3158
  function useFirstRender() {
@@ -3240,21 +3165,26 @@ function useFirstRender() {
3240
3165
  const NODE_TYPE_TITLE_ICON = {
3241
3166
  http_service: faCloud,
3242
3167
  http_operation: faBullseye,
3168
+ http_webhook: faEnvelope,
3243
3169
  model: faCube,
3244
3170
  };
3245
- const NODE_TITLE_ICON = {
3246
- Schemas: faCubes,
3171
+ const NODE_GROUP_ICON = {
3172
+ http_webhook: faEnvelopesBulk,
3173
+ model: faCubes,
3247
3174
  };
3248
3175
  const NODE_TYPE_META_ICON = {
3176
+ webhook: faEnvelope,
3249
3177
  model: faCube,
3250
3178
  };
3251
3179
  const NODE_TYPE_ICON_COLOR = {
3252
3180
  model: 'warning',
3253
3181
  http_service: '#D812EA',
3254
3182
  http_operation: '#9747FF',
3183
+ http_webhook: 'primary',
3255
3184
  };
3256
- const NODE_TITLE_ICON_COLOR = {
3257
- Schemas: 'warning',
3185
+ const NODE_GROUP_ICON_COLOR = {
3186
+ http_webhook: 'primary',
3187
+ model: 'warning',
3258
3188
  };
3259
3189
  const NODE_META_COLOR = {
3260
3190
  get: 'success',
@@ -3307,7 +3237,7 @@ function isDivider(item) {
3307
3237
  return Object.keys(item).length === 1 && 'title' in item;
3308
3238
  }
3309
3239
  function isGroup(item) {
3310
- return Object.keys(item).length === 2 && 'title' in item && 'items' in item;
3240
+ return Object.keys(item).length >= 2 && 'title' in item && 'items' in item;
3311
3241
  }
3312
3242
  function isNodeGroup(item) {
3313
3243
  return 'title' in item && 'items' in item && 'slug' in item && 'id' in item && 'meta' in item && 'type' in item;
@@ -3321,6 +3251,7 @@ function isExternalLink(item) {
3321
3251
 
3322
3252
  const ActiveIdContext = React.createContext(undefined);
3323
3253
  const LinkContext = React.createContext(undefined);
3254
+ LinkContext.displayName = 'LinkContext';
3324
3255
  const TableOfContents = React.memo(({ tree, activeId, Link, maxDepthOpenByDefault, externalScrollbar = false, isInResponsiveMode = false, onLinkClick, }) => {
3325
3256
  const container = React.useRef(null);
3326
3257
  const child = React.useRef(null);
@@ -3349,9 +3280,11 @@ const TableOfContents = React.memo(({ tree, activeId, Link, maxDepthOpenByDefaul
3349
3280
  return (React.createElement(GroupItem, { key: key, item: item, depth: 0, maxDepthOpenByDefault: maxDepthOpenByDefault, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode, makeSlugAbsoluteRoute: makeSlugAbsoluteRoute }));
3350
3281
  }))))));
3351
3282
  });
3283
+ TableOfContents.displayName = 'TableOfContents';
3352
3284
  const Divider = React.memo(({ item, isInResponsiveMode = false }) => {
3353
3285
  return (React.createElement(Box, { pl: 4, mb: 2, mt: 6, textTransform: "uppercase", fontSize: isInResponsiveMode ? 'lg' : 'sm', lineHeight: "relaxed", letterSpacing: "wide", fontWeight: "bold" }, item.title));
3354
3286
  });
3287
+ Divider.displayName = 'Divider';
3355
3288
  const GroupItem = React.memo(({ item, depth, maxDepthOpenByDefault, isInResponsiveMode, makeSlugAbsoluteRoute, onLinkClick }) => {
3356
3289
  if (isExternalLink(item)) {
3357
3290
  return (React.createElement(Box, { as: "a", href: item.url, target: "_blank", rel: "noopener noreferrer", display: "block" },
@@ -3367,6 +3300,7 @@ const GroupItem = React.memo(({ item, depth, maxDepthOpenByDefault, isInResponsi
3367
3300
  }
3368
3301
  return null;
3369
3302
  });
3303
+ GroupItem.displayName = 'GroupItem';
3370
3304
  const Group = React.memo(({ depth, item, maxDepthOpenByDefault, isInResponsiveMode, makeSlugAbsoluteRoute, onLinkClick = () => { } }) => {
3371
3305
  const activeId = React.useContext(ActiveIdContext);
3372
3306
  const [isOpen, setIsOpen] = React.useState(() => isGroupOpenByDefault(depth, item, activeId, maxDepthOpenByDefault));
@@ -3398,7 +3332,8 @@ const Group = React.memo(({ depth, item, maxDepthOpenByDefault, isInResponsiveMo
3398
3332
  elem = (React.createElement(Node, { depth: depth, item: item, meta: meta, showAsActive: showAsActive, onClick: handleClick, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode, makeSlugAbsoluteRoute: makeSlugAbsoluteRoute }));
3399
3333
  }
3400
3334
  else {
3401
- elem = (React.createElement(Item, { isInResponsiveMode: isInResponsiveMode, title: item.title, meta: meta, onClick: handleClick, depth: depth, isActive: showAsActive, icon: NODE_TITLE_ICON[item.title] && (React.createElement(Box, { as: Icon, color: NODE_TITLE_ICON_COLOR[item.title], icon: NODE_TITLE_ICON[item.title] })) }));
3335
+ elem = (React.createElement(Item, { isInResponsiveMode: isInResponsiveMode, title: item.title, meta: meta, onClick: handleClick, depth: depth, isActive: showAsActive, icon: item.itemsType &&
3336
+ NODE_GROUP_ICON[item.itemsType] && (React.createElement(Box, { as: Icon, color: NODE_GROUP_ICON_COLOR[item.itemsType], icon: NODE_GROUP_ICON[item.itemsType] })) }));
3402
3337
  }
3403
3338
  return (React.createElement(React.Fragment, null,
3404
3339
  elem,
@@ -3407,6 +3342,7 @@ const Group = React.memo(({ depth, item, maxDepthOpenByDefault, isInResponsiveMo
3407
3342
  return (React.createElement(GroupItem, { key: key, item: groupItem, depth: depth + 1, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode, makeSlugAbsoluteRoute: makeSlugAbsoluteRoute }));
3408
3343
  })));
3409
3344
  });
3345
+ Group.displayName = 'Group';
3410
3346
  const Item = React.memo(({ depth, isActive, id, title, meta, icon, isInResponsiveMode, onClick }) => {
3411
3347
  return (React.createElement(Flex, { id: id, bg: {
3412
3348
  default: isInResponsiveMode ? 'canvas' : isActive ? 'primary-tint' : 'canvas-100',
@@ -3416,6 +3352,7 @@ const Item = React.memo(({ depth, isActive, id, title, meta, icon, isInResponsiv
3416
3352
  React.createElement(Box, { alignItems: "center", flex: 1, mr: meta ? 1.5 : undefined, ml: icon && 1.5, textOverflow: "truncate", fontSize: isInResponsiveMode ? 'lg' : 'base' }, title),
3417
3353
  React.createElement(Flex, { alignItems: "center", fontSize: isInResponsiveMode ? 'base' : 'xs' }, meta)));
3418
3354
  });
3355
+ Item.displayName = 'Item';
3419
3356
  const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode, makeSlugAbsoluteRoute, onClick, onLinkClick = () => { } }) => {
3420
3357
  const activeId = React.useContext(ActiveIdContext);
3421
3358
  const isActive = activeId === item.slug || activeId === item.id;
@@ -3435,11 +3372,270 @@ const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode,
3435
3372
  return (React.createElement(Box, { as: LinkComponent, to: makeSlugAbsoluteRoute && !item.slug.startsWith('/') ? `/${item.slug}` : item.slug, display: "block", textDecoration: "no-underline", className: "ElementsTableOfContentsItem" },
3436
3373
  React.createElement(Item, { id: getHtmlIdFromItemId(item.slug || item.id), isActive: isActive || showAsActive, depth: depth, title: item.title, icon: NODE_TYPE_TITLE_ICON[item.type] && (React.createElement(Box, { as: Icon, color: NODE_TYPE_ICON_COLOR[item.type], icon: NODE_TYPE_TITLE_ICON[item.type] })), meta: meta, isInResponsiveMode: isInResponsiveMode, onClick: handleClick })));
3437
3374
  });
3375
+ Node.displayName = 'Node';
3438
3376
  const Version = ({ value }) => {
3439
3377
  return (React.createElement(Box, { mr: 2 },
3440
3378
  React.createElement(VersionBadge, { value: value, backgroundColor: "#909DAB" })));
3441
3379
  };
3442
3380
 
3381
+ const MobileTopNav = ({ name, logo, tree, pathname, onTocClick, }) => {
3382
+ const [isSidebarOpen, setIsSidebarOpen] = React.useState(false);
3383
+ const handleTocClick = () => {
3384
+ onTocClick();
3385
+ setIsSidebarOpen(false);
3386
+ };
3387
+ return (React.createElement(Flex, { className: "TopNav--mosaic", alignItems: "center", h: "3xl", pl: 4, pr: 4, bg: "canvas", borderB: true, pos: "fixed", w: "full", zIndex: 20 },
3388
+ React.createElement(Flex, { "data-test": "mobile-top-nav", w: "full", alignItems: "center", justifyContent: "between" },
3389
+ React.createElement(Button, { "data-test": "show-left-sidebar-btn", onPress: () => setIsSidebarOpen(true), appearance: "minimal" },
3390
+ React.createElement(Icon, { size: "lg", icon: faBars })),
3391
+ React.createElement(NavHeading, { heading: name })),
3392
+ React.createElement(Drawer, { isOpen: isSidebarOpen, position: "left" },
3393
+ React.createElement(Flex, { justifyContent: "end" },
3394
+ React.createElement(Button, { className: "sl-mr-4 sl-mt-2", onPress: () => setIsSidebarOpen(false), appearance: "minimal", justifySelf: "end" },
3395
+ React.createElement(Icon, { size: "lg", icon: faX }))),
3396
+ React.createElement(Sidebar, { name: name, logo: logo, tree: tree, pathname: pathname, onTocClick: () => handleTocClick(), isInResponsiveMode: true }))));
3397
+ };
3398
+ const NavHeading = ({ heading }) => (React.createElement(Flex, { flex: 1, "data-test": "mobile-project-top-nav", style: { minWidth: 0 } },
3399
+ React.createElement(Box, { fontSize: "xl", fontWeight: "semibold", whitespace: "nowrap", textOverflow: "overflow-ellipsis", overflowX: "hidden", overflowY: "hidden", w: "full", textAlign: "center" }, heading)));
3400
+
3401
+ const MAX_CONTENT_WIDTH$1 = 1800;
3402
+ const SIDEBAR_MIN_WIDTH$1 = 300;
3403
+ const SIDEBAR_MAX_WIDTH$1 = 1.5 * SIDEBAR_MIN_WIDTH$1;
3404
+ const ResponsiveSidebarLayout = React.forwardRef(({ children, name, logo, tree, onTocClick, maxContentWidth = MAX_CONTENT_WIDTH$1, sidebarWidth = SIDEBAR_MIN_WIDTH$1 }, ref) => {
3405
+ const scrollRef = React.useRef(null);
3406
+ const [sidebarRef, currentSidebarWidth, startResizing] = useResizer$1(sidebarWidth);
3407
+ const { pathname } = useLocation();
3408
+ React.useEffect(() => {
3409
+ var _a;
3410
+ (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
3411
+ }, [pathname]);
3412
+ const { isResponsiveLayoutEnabled } = useResponsiveLayout();
3413
+ return (React.createElement(Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
3414
+ !isResponsiveLayoutEnabled ? (React.createElement(Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH$1}px` } },
3415
+ React.createElement(Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
3416
+ paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
3417
+ width: `${currentSidebarWidth}px`,
3418
+ minWidth: `${SIDEBAR_MIN_WIDTH$1}px`,
3419
+ } },
3420
+ React.createElement(Sidebar, { name: name, logo: logo, tree: tree, pathname: pathname, onTocClick: onTocClick, isInResponsiveMode: false })),
3421
+ React.createElement(Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } }))) : (React.createElement(MobileTopNav, { onTocClick: onTocClick, name: name, logo: logo, tree: tree, pathname: pathname })),
3422
+ React.createElement(Box, { ref: scrollRef, bg: "canvas", px: !isResponsiveLayoutEnabled ? 24 : 6, flex: 1, w: "full", overflowY: "auto" },
3423
+ React.createElement(Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
3424
+ });
3425
+ const Sidebar = ({ name, logo, tree, pathname, onTocClick, isInResponsiveMode, }) => {
3426
+ return (React.createElement(React.Fragment, null,
3427
+ React.createElement(Flex, { ml: 4, mb: 5, alignItems: "center" },
3428
+ typeof logo === 'string' ? (React.createElement(Logo, { logo: { url: logo, altText: 'logo' } })) : (typeof logo === 'object' && React.createElement(Logo, { logo: logo })),
3429
+ React.createElement(Heading, { size: 4 }, name)),
3430
+ React.createElement(Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
3431
+ React.createElement(TableOfContents, { tree: tree, activeId: pathname, Link: Link$1, onLinkClick: onTocClick, isInResponsiveMode: isInResponsiveMode })),
3432
+ React.createElement(PoweredByLink, { source: name, pathname: pathname, packageType: "elements" })));
3433
+ };
3434
+ function useResizer$1(sidebarWidth) {
3435
+ const sidebarRef = React.useRef(null);
3436
+ const [isResizing, setIsResizing] = React.useState(false);
3437
+ const [currentSidebarWidth, setCurrentSidebarWidth] = React.useState(sidebarWidth);
3438
+ const startResizing = React.useCallback(() => {
3439
+ setIsResizing(true);
3440
+ }, []);
3441
+ const stopResizing = React.useCallback(() => {
3442
+ setIsResizing(false);
3443
+ }, []);
3444
+ const resize = React.useCallback(mouseMoveEvent => {
3445
+ if (isResizing) {
3446
+ const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
3447
+ setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH$1, value), SIDEBAR_MAX_WIDTH$1));
3448
+ }
3449
+ }, [isResizing]);
3450
+ React.useEffect(() => {
3451
+ window === null || window === void 0 ? void 0 : window.addEventListener('mousemove', resize);
3452
+ window === null || window === void 0 ? void 0 : window.addEventListener('mouseup', stopResizing, { passive: true });
3453
+ return () => {
3454
+ window === null || window === void 0 ? void 0 : window.removeEventListener('mousemove', resize);
3455
+ window === null || window === void 0 ? void 0 : window.removeEventListener('mouseup', stopResizing);
3456
+ };
3457
+ }, [resize, stopResizing]);
3458
+ return [sidebarRef, currentSidebarWidth, startResizing];
3459
+ }
3460
+
3461
+ const MAX_CONTENT_WIDTH = 1800;
3462
+ const SIDEBAR_MIN_WIDTH = 300;
3463
+ const SIDEBAR_MAX_WIDTH = 1.5 * SIDEBAR_MIN_WIDTH;
3464
+ const SidebarLayout = React.forwardRef(({ sidebar, children, maxContentWidth = MAX_CONTENT_WIDTH, sidebarWidth = SIDEBAR_MIN_WIDTH }, ref) => {
3465
+ const scrollRef = React.useRef(null);
3466
+ const [sidebarRef, currentSidebarWidth, startResizing] = useResizer(sidebarWidth);
3467
+ const { pathname } = useLocation();
3468
+ React.useEffect(() => {
3469
+ var _a;
3470
+ (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
3471
+ }, [pathname]);
3472
+ return (React.createElement(Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
3473
+ React.createElement(Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH}px` } },
3474
+ React.createElement(Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
3475
+ paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
3476
+ width: `${currentSidebarWidth}px`,
3477
+ minWidth: `${SIDEBAR_MIN_WIDTH}px`,
3478
+ } }, sidebar),
3479
+ React.createElement(Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } })),
3480
+ React.createElement(Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full", overflowY: "auto" },
3481
+ React.createElement(Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
3482
+ });
3483
+ function useResizer(sidebarWidth) {
3484
+ const sidebarRef = React.useRef(null);
3485
+ const [isResizing, setIsResizing] = React.useState(false);
3486
+ const [currentSidebarWidth, setCurrentSidebarWidth] = React.useState(sidebarWidth);
3487
+ const startResizing = React.useCallback(() => {
3488
+ setIsResizing(true);
3489
+ }, []);
3490
+ const stopResizing = React.useCallback(() => {
3491
+ setIsResizing(false);
3492
+ }, []);
3493
+ const resize = React.useCallback(mouseMoveEvent => {
3494
+ if (isResizing) {
3495
+ const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
3496
+ setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH, value), SIDEBAR_MAX_WIDTH));
3497
+ }
3498
+ }, [isResizing]);
3499
+ React.useEffect(() => {
3500
+ window.addEventListener('mousemove', resize);
3501
+ window.addEventListener('mouseup', stopResizing, { passive: true });
3502
+ return () => {
3503
+ window.removeEventListener('mousemove', resize);
3504
+ window.removeEventListener('mouseup', stopResizing);
3505
+ };
3506
+ }, [resize, stopResizing]);
3507
+ return [sidebarRef, currentSidebarWidth, startResizing];
3508
+ }
3509
+
3510
+ function getDisplayName(WrappedComponent) {
3511
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
3512
+ }
3513
+
3514
+ const PersistenceContextProvider = Provider;
3515
+ function withPersistenceBoundary(WrappedComponent) {
3516
+ const WithPersistenceBoundary = props => {
3517
+ return (React.createElement(PersistenceContextProvider, null,
3518
+ React.createElement(WrappedComponent, Object.assign({}, props))));
3519
+ };
3520
+ WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
3521
+ return WithPersistenceBoundary;
3522
+ }
3523
+
3524
+ function useParsedValue(value) {
3525
+ return React.useMemo(() => {
3526
+ let parsedValue = value;
3527
+ if (typeof value === 'string') {
3528
+ try {
3529
+ parsedValue = parse(value);
3530
+ }
3531
+ catch (error) {
3532
+ }
3533
+ }
3534
+ return parsedValue;
3535
+ }, [value]);
3536
+ }
3537
+
3538
+ function isPartialHttpRequest(maybeHttpRequest) {
3539
+ return (isObject(maybeHttpRequest) &&
3540
+ 'method' in maybeHttpRequest &&
3541
+ typeof maybeHttpRequest['method'] === 'string' &&
3542
+ 'url' in maybeHttpRequest &&
3543
+ typeof maybeHttpRequest['url'] === 'string');
3544
+ }
3545
+ const SchemaAndDescription = ({ title: titleProp, schema }) => {
3546
+ const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3547
+ const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
3548
+ return (React__default.createElement(Box, { py: 2 },
3549
+ title && (React__default.createElement(Flex, { alignItems: "center", p: 2 },
3550
+ React__default.createElement(Icon, { icon: NodeTypeIconDefs[NodeType.Model], color: NodeTypeColors[NodeType.Model] }),
3551
+ React__default.createElement(Box, { color: "muted", px: 2 }, title))),
3552
+ React__default.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema) })));
3553
+ };
3554
+ const CodeComponent = props => {
3555
+ const { title, jsonSchema, http, resolved, children } = props;
3556
+ const resolver = useInlineRefResolver();
3557
+ const value = resolved || String(Array.isArray(children) ? children[0] : children);
3558
+ const parsedValue = useParsedValue(value);
3559
+ if (jsonSchema) {
3560
+ if (!isJSONSchema(parsedValue)) {
3561
+ return null;
3562
+ }
3563
+ return (React__default.createElement(InlineRefResolverProvider, { document: parsedValue, resolver: resolver === null || resolver === void 0 ? void 0 : resolver.resolver, maxRefDepth: resolver === null || resolver === void 0 ? void 0 : resolver.maxRefDepth },
3564
+ React__default.createElement(SchemaAndDescription, { title: title, schema: parsedValue })));
3565
+ }
3566
+ if (http) {
3567
+ if (!isObject(parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
3568
+ return null;
3569
+ }
3570
+ return (React__default.createElement(PersistenceContextProvider, null,
3571
+ React__default.createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
3572
+ }
3573
+ const DefaultCode = DefaultSMDComponents.code;
3574
+ return React__default.createElement(DefaultCode, Object.assign({}, props));
3575
+ };
3576
+ function parseHttpRequest(data) {
3577
+ const uri = URI(data.url);
3578
+ const pathParam = data.url.match(/[^{\}]+(?=})/g);
3579
+ return {
3580
+ id: '?http-operation-id?',
3581
+ method: data.method,
3582
+ path: uri.is('absolute') ? uri.path() : data.url,
3583
+ servers: [{ id: `?http-server-${uri.href()}?`, url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
3584
+ request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => {
3585
+ const defaultVal = Array.isArray(value) ? value[0] : value;
3586
+ return {
3587
+ id: `?http-query-${key}-id?`,
3588
+ name: key,
3589
+ style: HttpParamStyles.Form,
3590
+ schema: { default: defaultVal },
3591
+ required: isHttpRequestParamRequired(defaultVal),
3592
+ };
3593
+ }), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
3594
+ id: `?http-header-${key}-id?`,
3595
+ name: key,
3596
+ style: HttpParamStyles.Simple,
3597
+ schema: { default: value },
3598
+ required: isHttpRequestParamRequired(value),
3599
+ })), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
3600
+ id: `?http-param-${name}-id?`,
3601
+ name,
3602
+ style: HttpParamStyles.Simple,
3603
+ required: true,
3604
+ })) }, (data.body
3605
+ ? {
3606
+ body: {
3607
+ id: '?http-request-body?',
3608
+ contents: [
3609
+ {
3610
+ id: '?http-request-body-media?',
3611
+ mediaType: 'application/json',
3612
+ schema: { default: data.body },
3613
+ },
3614
+ ],
3615
+ },
3616
+ }
3617
+ : null)),
3618
+ responses: [],
3619
+ };
3620
+ }
3621
+ function isHttpRequestParamRequired(value) {
3622
+ return typeof value !== 'undefined';
3623
+ }
3624
+
3625
+ const MarkdownComponentsProvider = ({ value, children }) => {
3626
+ return React.createElement(MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
3627
+ };
3628
+
3629
+ const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
3630
+ const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
3631
+ const href = to || _href;
3632
+ const isExternal = href !== undefined && externalRegex.test(href);
3633
+ if (isExternal) {
3634
+ return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
3635
+ }
3636
+ return (React__default.createElement(HashLink, { to: href, title: title }, children));
3637
+ };
3638
+
3443
3639
  const NonIdealState = ({ description, icon, title }) => {
3444
3640
  return (React.createElement(Flex, { flexDirection: "col", alignItems: "center", justifyContent: "center", textAlign: "center", w: "full", h: "full" },
3445
3641
  React.createElement(Box, { as: Icon, icon: icon || ['fas', 'exclamation-triangle'], color: "light", fontSize: "6xl", mb: 4 }),
@@ -3698,4 +3894,4 @@ const createElementClass = (Component, propDescriptors) => {
3698
3894
  };
3699
3895
  };
3700
3896
 
3701
- export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, RouterTypeContext, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, slugify, useBundleRefsIntoDocument, useParsedData, useParsedValue, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
3897
+ export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, LinkHeading, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, ResponsiveSidebarLayout, RouterTypeContext, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, isHttpWebhookOperation, slugify, useBundleRefsIntoDocument, useParsedData, useParsedValue, useResponsiveLayout, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };