@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.js CHANGED
@@ -237,6 +237,11 @@ function isHttpService(maybeHttpService) {
237
237
  function isHttpOperation(maybeHttpOperation) {
238
238
  return isStoplightNode(maybeHttpOperation) && 'method' in maybeHttpOperation && 'path' in maybeHttpOperation;
239
239
  }
240
+ function isHttpWebhookOperation(maybeHttpWebhookOperation) {
241
+ return (isStoplightNode(maybeHttpWebhookOperation) &&
242
+ 'method' in maybeHttpWebhookOperation &&
243
+ 'name' in maybeHttpWebhookOperation);
244
+ }
240
245
  const properUrl = new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/);
241
246
  function isProperUrl(url) {
242
247
  return properUrl.test(url);
@@ -248,6 +253,7 @@ function useParsedData(nodeType, data) {
248
253
  const parserMap = {
249
254
  [types.NodeType.Article]: parseArticleData,
250
255
  [types.NodeType.HttpOperation]: parseHttpOperation,
256
+ [types.NodeType.HttpWebhook]: parseHttpWebhookOperation,
251
257
  [types.NodeType.HttpService]: parseHttpService,
252
258
  [types.NodeType.Model]: parseModel,
253
259
  [types.NodeType.HttpServer]: parseUnknown,
@@ -280,6 +286,16 @@ function parseHttpOperation(rawData) {
280
286
  }
281
287
  return undefined;
282
288
  }
289
+ function parseHttpWebhookOperation(rawData) {
290
+ const data = tryParseYamlOrObject(rawData);
291
+ if (isHttpWebhookOperation(data)) {
292
+ return {
293
+ type: types.NodeType.HttpWebhook,
294
+ data: data,
295
+ };
296
+ }
297
+ return undefined;
298
+ }
283
299
  function parseHttpService(rawData) {
284
300
  const data = tryParseYamlOrObject(rawData);
285
301
  if (isHttpService(data)) {
@@ -349,6 +365,11 @@ const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recover
349
365
  * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
350
366
  * Copyright 2022 Fonticons, Inc.
351
367
  */
368
+ var faBars = {
369
+ prefix: 'fas',
370
+ iconName: 'bars',
371
+ 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"]
372
+ };
352
373
  var faBolt = {
353
374
  prefix: 'fas',
354
375
  iconName: 'bolt',
@@ -395,6 +416,16 @@ var faDatabase = {
395
416
  iconName: 'database',
396
417
  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"]
397
418
  };
419
+ var faEnvelope = {
420
+ prefix: 'fas',
421
+ iconName: 'envelope',
422
+ 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"]
423
+ };
424
+ var faEnvelopesBulk = {
425
+ prefix: 'fas',
426
+ iconName: 'envelopes-bulk',
427
+ 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"]
428
+ };
398
429
  var faEye = {
399
430
  prefix: 'fas',
400
431
  iconName: 'eye',
@@ -410,9 +441,15 @@ var faServer = {
410
441
  iconName: 'server',
411
442
  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"]
412
443
  };
444
+ var faX = {
445
+ prefix: 'fas',
446
+ iconName: 'x',
447
+ 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"]
448
+ };
413
449
 
414
450
  const NodeTypeColors = {
415
451
  http_operation: '#6a6acb',
452
+ http_webhook: 'primary',
416
453
  http_service: '#e056fd',
417
454
  article: '#399da6',
418
455
  model: '#ef932b',
@@ -429,6 +466,7 @@ const NodeTypeColors = {
429
466
  };
430
467
  const NodeTypePrettyName = {
431
468
  http_operation: 'Endpoint',
469
+ http_webhook: 'Webhook',
432
470
  http_service: 'API',
433
471
  article: 'Article',
434
472
  model: 'Model',
@@ -445,6 +483,7 @@ const NodeTypePrettyName = {
445
483
  };
446
484
  const NodeTypeIconDefs = {
447
485
  http_operation: faCrosshairs,
486
+ http_webhook: faEnvelope,
448
487
  http_service: faCloud,
449
488
  article: faBookOpen,
450
489
  model: faCube,
@@ -2194,7 +2233,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2194
2233
  }, [servers, firstServer, chosenServer, setChosenServer]);
2195
2234
  React__namespace.useEffect(() => {
2196
2235
  let isMounted = true;
2197
- if (onRequestChange || embeddedInMd) {
2236
+ if (isHttpOperation(httpOperation) && (onRequestChange || embeddedInMd)) {
2198
2237
  buildHarRequest(Object.assign(Object.assign({ mediaTypeContent, parameterValues: parameterValuesWithDefaults, serverVariableValues,
2199
2238
  httpOperation, bodyInput: formDataState.isFormDataBody ? getValues() : textRequestBody, auth: operationAuthValue }, (isMockingEnabled && { mockData: getMockData(mockUrl, httpOperation, mockingOptions) })), { chosenServer,
2200
2239
  corsProxy })).then(request => {
@@ -2227,7 +2266,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2227
2266
  ]);
2228
2267
  const handleSendRequest = () => tslib.__awaiter(void 0, void 0, void 0, function* () {
2229
2268
  setValidateParameters(true);
2230
- if (hasRequiredButEmptyParameters)
2269
+ if (hasRequiredButEmptyParameters || !isHttpOperation(httpOperation))
2231
2270
  return;
2232
2271
  try {
2233
2272
  setLoading(true);
@@ -2275,23 +2314,33 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2275
2314
  const isOnlySendButton = !((_d = httpOperation.security) === null || _d === void 0 ? void 0 : _d.length) && !allParameters.length && !formDataState.isFormDataBody && !mediaTypeContent;
2276
2315
  const tryItPanelContents = (React__namespace.createElement(React__namespace.Fragment, null,
2277
2316
  ((_e = httpOperation.security) === null || _e === void 0 ? void 0 : _e.length) ? (React__namespace.createElement(TryItAuth, { operationSecuritySchemes: httpOperation.security, operationAuthValue: operationAuthValue, setOperationAuthValue: setOperationAuthValue, setCurrentScheme: setCurrentScheme })) : null,
2278
- serverVariables.length > 0 && (React__namespace.createElement(ServerVariables, { variables: serverVariables, values: serverVariableValues, onChangeValue: updateServerVariableValue })),
2317
+ isHttpOperation(httpOperation) && serverVariables.length > 0 && (React__namespace.createElement(ServerVariables, { variables: serverVariables, values: serverVariableValues, onChangeValue: updateServerVariableValue })),
2279
2318
  allParameters.length > 0 && (React__namespace.createElement(OperationParameters, { parameters: allParameters, values: parameterValuesWithDefaults, onChangeValue: updateParameterValue, validate: validateParameters })),
2280
- formDataState.isFormDataBody ? (React__namespace.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues, onChangeParameterAllow: setAllowedEmptyValues, isAllowedEmptyValues: isAllowedEmptyValues })) : mediaTypeContent ? (React__namespace.createElement(RequestBody, { examples: (_f = mediaTypeContent.examples) !== null && _f !== void 0 ? _f : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null,
2281
- React__namespace.createElement(mosaic.Panel.Content, { className: "SendButtonHolder", mt: 4, pt: !isOnlySendButton && !embeddedInMd ? 0 : undefined },
2319
+ React__namespace.createElement(mosaic.Box, { pb: 1 }, formDataState.isFormDataBody ? (React__namespace.createElement(FormDataBody, { specification: formDataState.bodySpecification, values: bodyParameterValues, onChangeValues: setBodyParameterValues, onChangeParameterAllow: setAllowedEmptyValues, isAllowedEmptyValues: isAllowedEmptyValues })) : mediaTypeContent ? (React__namespace.createElement(RequestBody, { examples: (_f = mediaTypeContent.examples) !== null && _f !== void 0 ? _f : [], requestBody: textRequestBody, onChange: setTextRequestBody })) : null),
2320
+ isHttpOperation(httpOperation) ? (React__namespace.createElement(mosaic.Panel.Content, { className: "SendButtonHolder", pt: !isOnlySendButton && !embeddedInMd ? 0 : undefined },
2282
2321
  React__namespace.createElement(mosaic.HStack, { alignItems: "center", spacing: 2 },
2283
2322
  React__namespace.createElement(mosaic.Button, { appearance: "primary", loading: loading, disabled: loading, onPress: handleSendRequest, size: "sm" }, "Send API Request"),
2284
2323
  servers.length > 1 && React__namespace.createElement(ServersDropdown, { servers: servers }),
2285
2324
  isMockingEnabled && (React__namespace.createElement(MockingButton, { options: mockingOptions, onOptionsChange: setMockingOptions, operation: httpOperation }))),
2286
2325
  validateParameters && hasRequiredButEmptyParameters && (React__namespace.createElement(mosaic.Box, { mt: 4, color: "danger-light", fontSize: "sm" },
2287
2326
  React__namespace.createElement(mosaic.Icon, { icon: ['fas', 'exclamation-triangle'], className: "sl-mr-1" }),
2288
- "You didn't provide all of the required parameters!")))));
2327
+ "You didn't provide all of the required parameters!")))) : null));
2289
2328
  let tryItPanelElem;
2290
2329
  if (embeddedInMd) {
2330
+ let path;
2331
+ if (isHttpOperation(httpOperation)) {
2332
+ path = httpOperation.path;
2333
+ }
2334
+ else if (isHttpWebhookOperation(httpOperation)) {
2335
+ path = httpOperation.name;
2336
+ }
2337
+ else {
2338
+ throw new RangeError('unsupported type');
2339
+ }
2291
2340
  tryItPanelElem = (React__namespace.createElement(mosaic.Panel, { isCollapsible: false, p: 0, className: "TryItPanel" },
2292
2341
  React__namespace.createElement(mosaic.Panel.Titlebar, { bg: "canvas-300" },
2293
2342
  React__namespace.createElement(mosaic.Box, { fontWeight: "bold", color: !isDark ? HttpMethodColors[httpOperation.method] : undefined }, httpOperation.method.toUpperCase()),
2294
- React__namespace.createElement(mosaic.Box, { fontWeight: "medium", ml: 2, textOverflow: "truncate", overflowX: "hidden" }, `${(chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || ''}${httpOperation.path}`)),
2343
+ React__namespace.createElement(mosaic.Box, { fontWeight: "medium", ml: 2, textOverflow: "truncate", overflowX: "hidden" }, `${(chosenServer === null || chosenServer === void 0 ? void 0 : chosenServer.url) || ''}${path}`)),
2295
2344
  tryItPanelContents));
2296
2345
  }
2297
2346
  else {
@@ -2769,7 +2818,17 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
2769
2818
  const [requestBodyIndex, setTextRequestBodyIndex] = React__namespace.useState(0);
2770
2819
  const prettyName = (data.summary || data.iid || '').trim();
2771
2820
  const hasBadges = isDeprecated || isInternal;
2772
- const header = (React__namespace.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 }));
2821
+ let path;
2822
+ if (isHttpOperation(data)) {
2823
+ path = data.path;
2824
+ }
2825
+ else if (isHttpWebhookOperation(data)) {
2826
+ path = data.name;
2827
+ }
2828
+ else {
2829
+ throw new RangeError('unsupported node type');
2830
+ }
2831
+ const header = (React__namespace.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) }));
2773
2832
  const tryItPanel = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideTryItPanel) && (React__namespace.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 }));
2774
2833
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: data.id, attr: 'description' });
2775
2834
  const description = (React__namespace.createElement(mosaic.VStack, { spacing: 10 },
@@ -3092,6 +3151,7 @@ const ParsedDocs = (_a) => {
3092
3151
  case 'article':
3093
3152
  return React__namespace.createElement(Article, Object.assign({ data: node.data }, commonProps));
3094
3153
  case 'http_operation':
3154
+ case 'http_webhook':
3095
3155
  return React__namespace.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
3096
3156
  case 'http_service':
3097
3157
  return React__namespace.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
@@ -3103,188 +3163,53 @@ const ParsedDocs = (_a) => {
3103
3163
  }
3104
3164
  };
3105
3165
 
3106
- const MAX_CONTENT_WIDTH = 1800;
3107
- const SIDEBAR_MIN_WIDTH = 300;
3108
- const SIDEBAR_MAX_WIDTH = 1.5 * SIDEBAR_MIN_WIDTH;
3109
- const SidebarLayout = React__namespace.forwardRef(({ sidebar, children, maxContentWidth = MAX_CONTENT_WIDTH, sidebarWidth = SIDEBAR_MIN_WIDTH }, ref) => {
3110
- const scrollRef = React__namespace.useRef(null);
3111
- const [sidebarRef, currentSidebarWidth, startResizing] = useResizer(sidebarWidth);
3112
- const { pathname } = reactRouterDom.useLocation();
3113
- React__namespace.useEffect(() => {
3114
- var _a;
3115
- (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
3116
- }, [pathname]);
3117
- return (React__namespace.createElement(mosaic.Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
3118
- React__namespace.createElement(mosaic.Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH}px` } },
3119
- React__namespace.createElement(mosaic.Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
3120
- paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
3121
- width: `${currentSidebarWidth}px`,
3122
- minWidth: `${SIDEBAR_MIN_WIDTH}px`,
3123
- } }, sidebar),
3124
- React__namespace.createElement(mosaic.Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } })),
3125
- React__namespace.createElement(mosaic.Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full", overflowY: "auto" },
3126
- React__namespace.createElement(mosaic.Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
3127
- });
3128
- function useResizer(sidebarWidth) {
3129
- const sidebarRef = React__namespace.useRef(null);
3130
- const [isResizing, setIsResizing] = React__namespace.useState(false);
3131
- const [currentSidebarWidth, setCurrentSidebarWidth] = React__namespace.useState(sidebarWidth);
3132
- const startResizing = React__namespace.useCallback(() => {
3133
- setIsResizing(true);
3134
- }, []);
3135
- const stopResizing = React__namespace.useCallback(() => {
3136
- setIsResizing(false);
3137
- }, []);
3138
- const resize = React__namespace.useCallback(mouseMoveEvent => {
3139
- if (isResizing) {
3140
- const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
3141
- setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH, value), SIDEBAR_MAX_WIDTH));
3142
- }
3143
- }, [isResizing]);
3144
- React__namespace.useEffect(() => {
3145
- window.addEventListener('mousemove', resize);
3146
- window.addEventListener('mouseup', stopResizing, { passive: true });
3147
- return () => {
3148
- window.removeEventListener('mousemove', resize);
3149
- window.removeEventListener('mouseup', stopResizing);
3150
- };
3151
- }, [resize, stopResizing]);
3152
- return [sidebarRef, currentSidebarWidth, startResizing];
3153
- }
3154
-
3155
- const Logo = ({ logo }) => {
3156
- var _a;
3157
- return (React__namespace.createElement(mosaic.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__namespace.createElement("a", { href: logo.href, target: "_blank", rel: "noopener noreferrer" },
3158
- React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
3159
- };
3160
-
3161
- function getDisplayName(WrappedComponent) {
3162
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
3163
- }
3164
-
3165
- const PersistenceContextProvider = jotai.Provider;
3166
- function withPersistenceBoundary(WrappedComponent) {
3167
- const WithPersistenceBoundary = props => {
3168
- return (React__namespace.createElement(PersistenceContextProvider, null,
3169
- React__namespace.createElement(WrappedComponent, Object.assign({}, props))));
3170
- };
3171
- WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
3172
- return WithPersistenceBoundary;
3173
- }
3174
-
3175
- function useParsedValue(value) {
3176
- return React__namespace.useMemo(() => {
3177
- let parsedValue = value;
3178
- if (typeof value === 'string') {
3179
- try {
3180
- parsedValue = yaml.parse(value);
3181
- }
3182
- catch (error) {
3183
- }
3184
- }
3185
- return parsedValue;
3186
- }, [value]);
3187
- }
3188
-
3189
- function isPartialHttpRequest(maybeHttpRequest) {
3190
- return (isObject__default["default"](maybeHttpRequest) &&
3191
- 'method' in maybeHttpRequest &&
3192
- typeof maybeHttpRequest['method'] === 'string' &&
3193
- 'url' in maybeHttpRequest &&
3194
- typeof maybeHttpRequest['url'] === 'string');
3195
- }
3196
- const SchemaAndDescription = ({ title: titleProp, schema }) => {
3197
- const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3198
- const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
3199
- return (React__default["default"].createElement(mosaic.Box, { py: 2 },
3200
- title && (React__default["default"].createElement(mosaic.Flex, { alignItems: "center", p: 2 },
3201
- React__default["default"].createElement(mosaic.Icon, { icon: NodeTypeIconDefs[types.NodeType.Model], color: NodeTypeColors[types.NodeType.Model] }),
3202
- React__default["default"].createElement(mosaic.Box, { color: "muted", px: 2 }, title))),
3203
- React__default["default"].createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema) })));
3166
+ const ElementsBreakpoints = {
3167
+ docs: 700,
3204
3168
  };
3205
- const CodeComponent = props => {
3206
- const { title, jsonSchema, http, resolved, children } = props;
3207
- const resolver = useInlineRefResolver();
3208
- const value = resolved || String(Array.isArray(children) ? children[0] : children);
3209
- const parsedValue = useParsedValue(value);
3210
- if (jsonSchema) {
3211
- if (!isJSONSchema(parsedValue)) {
3212
- return null;
3213
- }
3214
- return (React__default["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 },
3215
- React__default["default"].createElement(SchemaAndDescription, { title: title, schema: parsedValue })));
3169
+ var ScreenType;
3170
+ (function (ScreenType) {
3171
+ ScreenType[ScreenType["Phone"] = 415] = "Phone";
3172
+ ScreenType[ScreenType["Tablet"] = 750] = "Tablet";
3173
+ ScreenType[ScreenType["Resized_Browser"] = 980] = "Resized_Browser";
3174
+ ScreenType[ScreenType["Normal_Browser"] = 1000000] = "Normal_Browser";
3175
+ })(ScreenType || (ScreenType = {}));
3176
+ const getScreenType = () => {
3177
+ if ((window === null || window === void 0 ? void 0 : window.innerWidth) <= ScreenType.Phone) {
3178
+ return ScreenType.Phone;
3216
3179
  }
3217
- if (http) {
3218
- if (!isObject__default["default"](parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
3219
- return null;
3220
- }
3221
- return (React__default["default"].createElement(PersistenceContextProvider, null,
3222
- React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
3180
+ else if ((window === null || window === void 0 ? void 0 : window.innerWidth) <= ScreenType.Tablet) {
3181
+ return ScreenType.Tablet;
3223
3182
  }
3224
- const DefaultCode = markdownViewer.DefaultSMDComponents.code;
3225
- return React__default["default"].createElement(DefaultCode, Object.assign({}, props));
3183
+ else if ((window === null || window === void 0 ? void 0 : window.innerWidth) <= ScreenType.Resized_Browser) {
3184
+ return ScreenType.Resized_Browser;
3185
+ }
3186
+ return ScreenType.Normal_Browser;
3226
3187
  };
3227
- function parseHttpRequest(data) {
3228
- const uri = URI__default["default"](data.url);
3229
- const pathParam = data.url.match(/[^{\}]+(?=})/g);
3188
+ const useResponsiveLayout = () => {
3189
+ const [screenType, setScreenType] = React__namespace.useState();
3190
+ const getElementsBreakpoint = (node) => {
3191
+ return ElementsBreakpoints[node];
3192
+ };
3193
+ React__namespace.useLayoutEffect(() => {
3194
+ function handleResize() {
3195
+ setScreenType(getScreenType());
3196
+ }
3197
+ window === null || window === void 0 ? void 0 : window.addEventListener('resize', handleResize);
3198
+ handleResize();
3199
+ return () => window === null || window === void 0 ? void 0 : window.removeEventListener('resize', handleResize);
3200
+ }, []);
3201
+ const isResponsiveLayoutEnabled = screenType !== ScreenType.Normal_Browser;
3230
3202
  return {
3231
- id: '?http-operation-id?',
3232
- method: data.method,
3233
- path: uri.is('absolute') ? uri.path() : data.url,
3234
- servers: [{ id: `?http-server-${uri.href()}?`, url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
3235
- request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => {
3236
- const defaultVal = Array.isArray(value) ? value[0] : value;
3237
- return {
3238
- id: `?http-query-${key}-id?`,
3239
- name: key,
3240
- style: types.HttpParamStyles.Form,
3241
- schema: { default: defaultVal },
3242
- required: isHttpRequestParamRequired(defaultVal),
3243
- };
3244
- }), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
3245
- id: `?http-header-${key}-id?`,
3246
- name: key,
3247
- style: types.HttpParamStyles.Simple,
3248
- schema: { default: value },
3249
- required: isHttpRequestParamRequired(value),
3250
- })), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
3251
- id: `?http-param-${name}-id?`,
3252
- name,
3253
- style: types.HttpParamStyles.Simple,
3254
- required: true,
3255
- })) }, (data.body
3256
- ? {
3257
- body: {
3258
- id: '?http-request-body?',
3259
- contents: [
3260
- {
3261
- id: '?http-request-body-media?',
3262
- mediaType: 'application/json',
3263
- schema: { default: data.body },
3264
- },
3265
- ],
3266
- },
3267
- }
3268
- : null)),
3269
- responses: [],
3203
+ isResponsiveLayoutEnabled,
3204
+ screenType,
3205
+ getElementsBreakpoint,
3270
3206
  };
3271
- }
3272
- function isHttpRequestParamRequired(value) {
3273
- return typeof value !== 'undefined';
3274
- }
3275
-
3276
- const MarkdownComponentsProvider = ({ value, children }) => {
3277
- return React__namespace.createElement(markdownViewer.MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
3278
3207
  };
3279
3208
 
3280
- const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
3281
- const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
3282
- const href = to || _href;
3283
- const isExternal = href !== undefined && externalRegex.test(href);
3284
- if (isExternal) {
3285
- return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
3286
- }
3287
- return (React__default["default"].createElement(reactRouterHashLink.HashLink, { to: href, title: title }, children));
3209
+ const Logo = ({ logo }) => {
3210
+ var _a;
3211
+ return (React__namespace.createElement(mosaic.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__namespace.createElement("a", { href: logo.href, target: "_blank", rel: "noopener noreferrer" },
3212
+ React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
3288
3213
  };
3289
3214
 
3290
3215
  function useFirstRender() {
@@ -3297,21 +3222,26 @@ function useFirstRender() {
3297
3222
  const NODE_TYPE_TITLE_ICON = {
3298
3223
  http_service: faCloud,
3299
3224
  http_operation: faBullseye,
3225
+ http_webhook: faEnvelope,
3300
3226
  model: faCube,
3301
3227
  };
3302
- const NODE_TITLE_ICON = {
3303
- Schemas: faCubes,
3228
+ const NODE_GROUP_ICON = {
3229
+ http_webhook: faEnvelopesBulk,
3230
+ model: faCubes,
3304
3231
  };
3305
3232
  const NODE_TYPE_META_ICON = {
3233
+ webhook: faEnvelope,
3306
3234
  model: faCube,
3307
3235
  };
3308
3236
  const NODE_TYPE_ICON_COLOR = {
3309
3237
  model: 'warning',
3310
3238
  http_service: '#D812EA',
3311
3239
  http_operation: '#9747FF',
3240
+ http_webhook: 'primary',
3312
3241
  };
3313
- const NODE_TITLE_ICON_COLOR = {
3314
- Schemas: 'warning',
3242
+ const NODE_GROUP_ICON_COLOR = {
3243
+ http_webhook: 'primary',
3244
+ model: 'warning',
3315
3245
  };
3316
3246
  const NODE_META_COLOR = {
3317
3247
  get: 'success',
@@ -3364,7 +3294,7 @@ function isDivider(item) {
3364
3294
  return Object.keys(item).length === 1 && 'title' in item;
3365
3295
  }
3366
3296
  function isGroup(item) {
3367
- return Object.keys(item).length === 2 && 'title' in item && 'items' in item;
3297
+ return Object.keys(item).length >= 2 && 'title' in item && 'items' in item;
3368
3298
  }
3369
3299
  function isNodeGroup(item) {
3370
3300
  return 'title' in item && 'items' in item && 'slug' in item && 'id' in item && 'meta' in item && 'type' in item;
@@ -3378,6 +3308,7 @@ function isExternalLink(item) {
3378
3308
 
3379
3309
  const ActiveIdContext = React__namespace.createContext(undefined);
3380
3310
  const LinkContext = React__namespace.createContext(undefined);
3311
+ LinkContext.displayName = 'LinkContext';
3381
3312
  const TableOfContents = React__namespace.memo(({ tree, activeId, Link, maxDepthOpenByDefault, externalScrollbar = false, isInResponsiveMode = false, onLinkClick, }) => {
3382
3313
  const container = React__namespace.useRef(null);
3383
3314
  const child = React__namespace.useRef(null);
@@ -3406,9 +3337,11 @@ const TableOfContents = React__namespace.memo(({ tree, activeId, Link, maxDepthO
3406
3337
  return (React__namespace.createElement(GroupItem, { key: key, item: item, depth: 0, maxDepthOpenByDefault: maxDepthOpenByDefault, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode, makeSlugAbsoluteRoute: makeSlugAbsoluteRoute }));
3407
3338
  }))))));
3408
3339
  });
3340
+ TableOfContents.displayName = 'TableOfContents';
3409
3341
  const Divider = React__namespace.memo(({ item, isInResponsiveMode = false }) => {
3410
3342
  return (React__namespace.createElement(mosaic.Box, { pl: 4, mb: 2, mt: 6, textTransform: "uppercase", fontSize: isInResponsiveMode ? 'lg' : 'sm', lineHeight: "relaxed", letterSpacing: "wide", fontWeight: "bold" }, item.title));
3411
3343
  });
3344
+ Divider.displayName = 'Divider';
3412
3345
  const GroupItem = React__namespace.memo(({ item, depth, maxDepthOpenByDefault, isInResponsiveMode, makeSlugAbsoluteRoute, onLinkClick }) => {
3413
3346
  if (isExternalLink(item)) {
3414
3347
  return (React__namespace.createElement(mosaic.Box, { as: "a", href: item.url, target: "_blank", rel: "noopener noreferrer", display: "block" },
@@ -3424,6 +3357,7 @@ const GroupItem = React__namespace.memo(({ item, depth, maxDepthOpenByDefault, i
3424
3357
  }
3425
3358
  return null;
3426
3359
  });
3360
+ GroupItem.displayName = 'GroupItem';
3427
3361
  const Group = React__namespace.memo(({ depth, item, maxDepthOpenByDefault, isInResponsiveMode, makeSlugAbsoluteRoute, onLinkClick = () => { } }) => {
3428
3362
  const activeId = React__namespace.useContext(ActiveIdContext);
3429
3363
  const [isOpen, setIsOpen] = React__namespace.useState(() => isGroupOpenByDefault(depth, item, activeId, maxDepthOpenByDefault));
@@ -3455,7 +3389,8 @@ const Group = React__namespace.memo(({ depth, item, maxDepthOpenByDefault, isInR
3455
3389
  elem = (React__namespace.createElement(Node, { depth: depth, item: item, meta: meta, showAsActive: showAsActive, onClick: handleClick, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode, makeSlugAbsoluteRoute: makeSlugAbsoluteRoute }));
3456
3390
  }
3457
3391
  else {
3458
- elem = (React__namespace.createElement(Item, { isInResponsiveMode: isInResponsiveMode, title: item.title, meta: meta, onClick: handleClick, depth: depth, isActive: showAsActive, icon: NODE_TITLE_ICON[item.title] && (React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, color: NODE_TITLE_ICON_COLOR[item.title], icon: NODE_TITLE_ICON[item.title] })) }));
3392
+ elem = (React__namespace.createElement(Item, { isInResponsiveMode: isInResponsiveMode, title: item.title, meta: meta, onClick: handleClick, depth: depth, isActive: showAsActive, icon: item.itemsType &&
3393
+ NODE_GROUP_ICON[item.itemsType] && (React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, color: NODE_GROUP_ICON_COLOR[item.itemsType], icon: NODE_GROUP_ICON[item.itemsType] })) }));
3459
3394
  }
3460
3395
  return (React__namespace.createElement(React__namespace.Fragment, null,
3461
3396
  elem,
@@ -3464,6 +3399,7 @@ const Group = React__namespace.memo(({ depth, item, maxDepthOpenByDefault, isInR
3464
3399
  return (React__namespace.createElement(GroupItem, { key: key, item: groupItem, depth: depth + 1, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode, makeSlugAbsoluteRoute: makeSlugAbsoluteRoute }));
3465
3400
  })));
3466
3401
  });
3402
+ Group.displayName = 'Group';
3467
3403
  const Item = React__namespace.memo(({ depth, isActive, id, title, meta, icon, isInResponsiveMode, onClick }) => {
3468
3404
  return (React__namespace.createElement(mosaic.Flex, { id: id, bg: {
3469
3405
  default: isInResponsiveMode ? 'canvas' : isActive ? 'primary-tint' : 'canvas-100',
@@ -3473,6 +3409,7 @@ const Item = React__namespace.memo(({ depth, isActive, id, title, meta, icon, is
3473
3409
  React__namespace.createElement(mosaic.Box, { alignItems: "center", flex: 1, mr: meta ? 1.5 : undefined, ml: icon && 1.5, textOverflow: "truncate", fontSize: isInResponsiveMode ? 'lg' : 'base' }, title),
3474
3410
  React__namespace.createElement(mosaic.Flex, { alignItems: "center", fontSize: isInResponsiveMode ? 'base' : 'xs' }, meta)));
3475
3411
  });
3412
+ Item.displayName = 'Item';
3476
3413
  const Node = React__namespace.memo(({ item, depth, meta, showAsActive, isInResponsiveMode, makeSlugAbsoluteRoute, onClick, onLinkClick = () => { } }) => {
3477
3414
  const activeId = React__namespace.useContext(ActiveIdContext);
3478
3415
  const isActive = activeId === item.slug || activeId === item.id;
@@ -3492,11 +3429,270 @@ const Node = React__namespace.memo(({ item, depth, meta, showAsActive, isInRespo
3492
3429
  return (React__namespace.createElement(mosaic.Box, { as: LinkComponent, to: makeSlugAbsoluteRoute && !item.slug.startsWith('/') ? `/${item.slug}` : item.slug, display: "block", textDecoration: "no-underline", className: "ElementsTableOfContentsItem" },
3493
3430
  React__namespace.createElement(Item, { id: getHtmlIdFromItemId(item.slug || item.id), isActive: isActive || showAsActive, depth: depth, title: item.title, icon: NODE_TYPE_TITLE_ICON[item.type] && (React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, color: NODE_TYPE_ICON_COLOR[item.type], icon: NODE_TYPE_TITLE_ICON[item.type] })), meta: meta, isInResponsiveMode: isInResponsiveMode, onClick: handleClick })));
3494
3431
  });
3432
+ Node.displayName = 'Node';
3495
3433
  const Version = ({ value }) => {
3496
3434
  return (React__namespace.createElement(mosaic.Box, { mr: 2 },
3497
3435
  React__namespace.createElement(VersionBadge, { value: value, backgroundColor: "#909DAB" })));
3498
3436
  };
3499
3437
 
3438
+ const MobileTopNav = ({ name, logo, tree, pathname, onTocClick, }) => {
3439
+ const [isSidebarOpen, setIsSidebarOpen] = React__namespace.useState(false);
3440
+ const handleTocClick = () => {
3441
+ onTocClick();
3442
+ setIsSidebarOpen(false);
3443
+ };
3444
+ return (React__namespace.createElement(mosaic.Flex, { className: "TopNav--mosaic", alignItems: "center", h: "3xl", pl: 4, pr: 4, bg: "canvas", borderB: true, pos: "fixed", w: "full", zIndex: 20 },
3445
+ React__namespace.createElement(mosaic.Flex, { "data-test": "mobile-top-nav", w: "full", alignItems: "center", justifyContent: "between" },
3446
+ React__namespace.createElement(mosaic.Button, { "data-test": "show-left-sidebar-btn", onPress: () => setIsSidebarOpen(true), appearance: "minimal" },
3447
+ React__namespace.createElement(mosaic.Icon, { size: "lg", icon: faBars })),
3448
+ React__namespace.createElement(NavHeading, { heading: name })),
3449
+ React__namespace.createElement(mosaic.Drawer, { isOpen: isSidebarOpen, position: "left" },
3450
+ React__namespace.createElement(mosaic.Flex, { justifyContent: "end" },
3451
+ React__namespace.createElement(mosaic.Button, { className: "sl-mr-4 sl-mt-2", onPress: () => setIsSidebarOpen(false), appearance: "minimal", justifySelf: "end" },
3452
+ React__namespace.createElement(mosaic.Icon, { size: "lg", icon: faX }))),
3453
+ React__namespace.createElement(Sidebar, { name: name, logo: logo, tree: tree, pathname: pathname, onTocClick: () => handleTocClick(), isInResponsiveMode: true }))));
3454
+ };
3455
+ const NavHeading = ({ heading }) => (React__namespace.createElement(mosaic.Flex, { flex: 1, "data-test": "mobile-project-top-nav", style: { minWidth: 0 } },
3456
+ React__namespace.createElement(mosaic.Box, { fontSize: "xl", fontWeight: "semibold", whitespace: "nowrap", textOverflow: "overflow-ellipsis", overflowX: "hidden", overflowY: "hidden", w: "full", textAlign: "center" }, heading)));
3457
+
3458
+ const MAX_CONTENT_WIDTH$1 = 1800;
3459
+ const SIDEBAR_MIN_WIDTH$1 = 300;
3460
+ const SIDEBAR_MAX_WIDTH$1 = 1.5 * SIDEBAR_MIN_WIDTH$1;
3461
+ const ResponsiveSidebarLayout = React__namespace.forwardRef(({ children, name, logo, tree, onTocClick, maxContentWidth = MAX_CONTENT_WIDTH$1, sidebarWidth = SIDEBAR_MIN_WIDTH$1 }, ref) => {
3462
+ const scrollRef = React__namespace.useRef(null);
3463
+ const [sidebarRef, currentSidebarWidth, startResizing] = useResizer$1(sidebarWidth);
3464
+ const { pathname } = reactRouterDom.useLocation();
3465
+ React__namespace.useEffect(() => {
3466
+ var _a;
3467
+ (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
3468
+ }, [pathname]);
3469
+ const { isResponsiveLayoutEnabled } = useResponsiveLayout();
3470
+ return (React__namespace.createElement(mosaic.Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
3471
+ !isResponsiveLayoutEnabled ? (React__namespace.createElement(mosaic.Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH$1}px` } },
3472
+ React__namespace.createElement(mosaic.Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
3473
+ paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
3474
+ width: `${currentSidebarWidth}px`,
3475
+ minWidth: `${SIDEBAR_MIN_WIDTH$1}px`,
3476
+ } },
3477
+ React__namespace.createElement(Sidebar, { name: name, logo: logo, tree: tree, pathname: pathname, onTocClick: onTocClick, isInResponsiveMode: false })),
3478
+ React__namespace.createElement(mosaic.Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } }))) : (React__namespace.createElement(MobileTopNav, { onTocClick: onTocClick, name: name, logo: logo, tree: tree, pathname: pathname })),
3479
+ React__namespace.createElement(mosaic.Box, { ref: scrollRef, bg: "canvas", px: !isResponsiveLayoutEnabled ? 24 : 6, flex: 1, w: "full", overflowY: "auto" },
3480
+ React__namespace.createElement(mosaic.Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
3481
+ });
3482
+ const Sidebar = ({ name, logo, tree, pathname, onTocClick, isInResponsiveMode, }) => {
3483
+ return (React__namespace.createElement(React__namespace.Fragment, null,
3484
+ React__namespace.createElement(mosaic.Flex, { ml: 4, mb: 5, alignItems: "center" },
3485
+ typeof logo === 'string' ? (React__namespace.createElement(Logo, { logo: { url: logo, altText: 'logo' } })) : (typeof logo === 'object' && React__namespace.createElement(Logo, { logo: logo })),
3486
+ React__namespace.createElement(mosaic.Heading, { size: 4 }, name)),
3487
+ React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
3488
+ React__namespace.createElement(TableOfContents, { tree: tree, activeId: pathname, Link: reactRouterDom.Link, onLinkClick: onTocClick, isInResponsiveMode: isInResponsiveMode })),
3489
+ React__namespace.createElement(PoweredByLink, { source: name, pathname: pathname, packageType: "elements" })));
3490
+ };
3491
+ function useResizer$1(sidebarWidth) {
3492
+ const sidebarRef = React__namespace.useRef(null);
3493
+ const [isResizing, setIsResizing] = React__namespace.useState(false);
3494
+ const [currentSidebarWidth, setCurrentSidebarWidth] = React__namespace.useState(sidebarWidth);
3495
+ const startResizing = React__namespace.useCallback(() => {
3496
+ setIsResizing(true);
3497
+ }, []);
3498
+ const stopResizing = React__namespace.useCallback(() => {
3499
+ setIsResizing(false);
3500
+ }, []);
3501
+ const resize = React__namespace.useCallback(mouseMoveEvent => {
3502
+ if (isResizing) {
3503
+ const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
3504
+ setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH$1, value), SIDEBAR_MAX_WIDTH$1));
3505
+ }
3506
+ }, [isResizing]);
3507
+ React__namespace.useEffect(() => {
3508
+ window === null || window === void 0 ? void 0 : window.addEventListener('mousemove', resize);
3509
+ window === null || window === void 0 ? void 0 : window.addEventListener('mouseup', stopResizing, { passive: true });
3510
+ return () => {
3511
+ window === null || window === void 0 ? void 0 : window.removeEventListener('mousemove', resize);
3512
+ window === null || window === void 0 ? void 0 : window.removeEventListener('mouseup', stopResizing);
3513
+ };
3514
+ }, [resize, stopResizing]);
3515
+ return [sidebarRef, currentSidebarWidth, startResizing];
3516
+ }
3517
+
3518
+ const MAX_CONTENT_WIDTH = 1800;
3519
+ const SIDEBAR_MIN_WIDTH = 300;
3520
+ const SIDEBAR_MAX_WIDTH = 1.5 * SIDEBAR_MIN_WIDTH;
3521
+ const SidebarLayout = React__namespace.forwardRef(({ sidebar, children, maxContentWidth = MAX_CONTENT_WIDTH, sidebarWidth = SIDEBAR_MIN_WIDTH }, ref) => {
3522
+ const scrollRef = React__namespace.useRef(null);
3523
+ const [sidebarRef, currentSidebarWidth, startResizing] = useResizer(sidebarWidth);
3524
+ const { pathname } = reactRouterDom.useLocation();
3525
+ React__namespace.useEffect(() => {
3526
+ var _a;
3527
+ (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
3528
+ }, [pathname]);
3529
+ return (React__namespace.createElement(mosaic.Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
3530
+ React__namespace.createElement(mosaic.Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH}px` } },
3531
+ React__namespace.createElement(mosaic.Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
3532
+ paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
3533
+ width: `${currentSidebarWidth}px`,
3534
+ minWidth: `${SIDEBAR_MIN_WIDTH}px`,
3535
+ } }, sidebar),
3536
+ React__namespace.createElement(mosaic.Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } })),
3537
+ React__namespace.createElement(mosaic.Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full", overflowY: "auto" },
3538
+ React__namespace.createElement(mosaic.Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
3539
+ });
3540
+ function useResizer(sidebarWidth) {
3541
+ const sidebarRef = React__namespace.useRef(null);
3542
+ const [isResizing, setIsResizing] = React__namespace.useState(false);
3543
+ const [currentSidebarWidth, setCurrentSidebarWidth] = React__namespace.useState(sidebarWidth);
3544
+ const startResizing = React__namespace.useCallback(() => {
3545
+ setIsResizing(true);
3546
+ }, []);
3547
+ const stopResizing = React__namespace.useCallback(() => {
3548
+ setIsResizing(false);
3549
+ }, []);
3550
+ const resize = React__namespace.useCallback(mouseMoveEvent => {
3551
+ if (isResizing) {
3552
+ const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
3553
+ setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH, value), SIDEBAR_MAX_WIDTH));
3554
+ }
3555
+ }, [isResizing]);
3556
+ React__namespace.useEffect(() => {
3557
+ window.addEventListener('mousemove', resize);
3558
+ window.addEventListener('mouseup', stopResizing, { passive: true });
3559
+ return () => {
3560
+ window.removeEventListener('mousemove', resize);
3561
+ window.removeEventListener('mouseup', stopResizing);
3562
+ };
3563
+ }, [resize, stopResizing]);
3564
+ return [sidebarRef, currentSidebarWidth, startResizing];
3565
+ }
3566
+
3567
+ function getDisplayName(WrappedComponent) {
3568
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
3569
+ }
3570
+
3571
+ const PersistenceContextProvider = jotai.Provider;
3572
+ function withPersistenceBoundary(WrappedComponent) {
3573
+ const WithPersistenceBoundary = props => {
3574
+ return (React__namespace.createElement(PersistenceContextProvider, null,
3575
+ React__namespace.createElement(WrappedComponent, Object.assign({}, props))));
3576
+ };
3577
+ WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
3578
+ return WithPersistenceBoundary;
3579
+ }
3580
+
3581
+ function useParsedValue(value) {
3582
+ return React__namespace.useMemo(() => {
3583
+ let parsedValue = value;
3584
+ if (typeof value === 'string') {
3585
+ try {
3586
+ parsedValue = yaml.parse(value);
3587
+ }
3588
+ catch (error) {
3589
+ }
3590
+ }
3591
+ return parsedValue;
3592
+ }, [value]);
3593
+ }
3594
+
3595
+ function isPartialHttpRequest(maybeHttpRequest) {
3596
+ return (isObject__default["default"](maybeHttpRequest) &&
3597
+ 'method' in maybeHttpRequest &&
3598
+ typeof maybeHttpRequest['method'] === 'string' &&
3599
+ 'url' in maybeHttpRequest &&
3600
+ typeof maybeHttpRequest['url'] === 'string');
3601
+ }
3602
+ const SchemaAndDescription = ({ title: titleProp, schema }) => {
3603
+ const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3604
+ const title = titleProp !== null && titleProp !== void 0 ? titleProp : schema.title;
3605
+ return (React__default["default"].createElement(mosaic.Box, { py: 2 },
3606
+ title && (React__default["default"].createElement(mosaic.Flex, { alignItems: "center", p: 2 },
3607
+ React__default["default"].createElement(mosaic.Icon, { icon: NodeTypeIconDefs[types.NodeType.Model], color: NodeTypeColors[types.NodeType.Model] }),
3608
+ React__default["default"].createElement(mosaic.Box, { color: "muted", px: 2 }, title))),
3609
+ React__default["default"].createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema) })));
3610
+ };
3611
+ const CodeComponent = props => {
3612
+ const { title, jsonSchema, http, resolved, children } = props;
3613
+ const resolver = useInlineRefResolver();
3614
+ const value = resolved || String(Array.isArray(children) ? children[0] : children);
3615
+ const parsedValue = useParsedValue(value);
3616
+ if (jsonSchema) {
3617
+ if (!isJSONSchema(parsedValue)) {
3618
+ return null;
3619
+ }
3620
+ return (React__default["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 },
3621
+ React__default["default"].createElement(SchemaAndDescription, { title: title, schema: parsedValue })));
3622
+ }
3623
+ if (http) {
3624
+ if (!isObject__default["default"](parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
3625
+ return null;
3626
+ }
3627
+ return (React__default["default"].createElement(PersistenceContextProvider, null,
3628
+ React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
3629
+ }
3630
+ const DefaultCode = markdownViewer.DefaultSMDComponents.code;
3631
+ return React__default["default"].createElement(DefaultCode, Object.assign({}, props));
3632
+ };
3633
+ function parseHttpRequest(data) {
3634
+ const uri = URI__default["default"](data.url);
3635
+ const pathParam = data.url.match(/[^{\}]+(?=})/g);
3636
+ return {
3637
+ id: '?http-operation-id?',
3638
+ method: data.method,
3639
+ path: uri.is('absolute') ? uri.path() : data.url,
3640
+ servers: [{ id: `?http-server-${uri.href()}?`, url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
3641
+ request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => {
3642
+ const defaultVal = Array.isArray(value) ? value[0] : value;
3643
+ return {
3644
+ id: `?http-query-${key}-id?`,
3645
+ name: key,
3646
+ style: types.HttpParamStyles.Form,
3647
+ schema: { default: defaultVal },
3648
+ required: isHttpRequestParamRequired(defaultVal),
3649
+ };
3650
+ }), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
3651
+ id: `?http-header-${key}-id?`,
3652
+ name: key,
3653
+ style: types.HttpParamStyles.Simple,
3654
+ schema: { default: value },
3655
+ required: isHttpRequestParamRequired(value),
3656
+ })), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
3657
+ id: `?http-param-${name}-id?`,
3658
+ name,
3659
+ style: types.HttpParamStyles.Simple,
3660
+ required: true,
3661
+ })) }, (data.body
3662
+ ? {
3663
+ body: {
3664
+ id: '?http-request-body?',
3665
+ contents: [
3666
+ {
3667
+ id: '?http-request-body-media?',
3668
+ mediaType: 'application/json',
3669
+ schema: { default: data.body },
3670
+ },
3671
+ ],
3672
+ },
3673
+ }
3674
+ : null)),
3675
+ responses: [],
3676
+ };
3677
+ }
3678
+ function isHttpRequestParamRequired(value) {
3679
+ return typeof value !== 'undefined';
3680
+ }
3681
+
3682
+ const MarkdownComponentsProvider = ({ value, children }) => {
3683
+ return React__namespace.createElement(markdownViewer.MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
3684
+ };
3685
+
3686
+ const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
3687
+ const ReactRouterMarkdownLink = ({ title, to, href: _href, children, }) => {
3688
+ const href = to || _href;
3689
+ const isExternal = href !== undefined && externalRegex.test(href);
3690
+ if (isExternal) {
3691
+ return (React__default["default"].createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
3692
+ }
3693
+ return (React__default["default"].createElement(reactRouterHashLink.HashLink, { to: href, title: title }, children));
3694
+ };
3695
+
3500
3696
  const NonIdealState = ({ description, icon, title }) => {
3501
3697
  return (React__namespace.createElement(mosaic.Flex, { flexDirection: "col", alignItems: "center", justifyContent: "center", textAlign: "center", w: "full", h: "full" },
3502
3698
  React__namespace.createElement(mosaic.Box, { as: mosaic.Icon, icon: icon || ['fas', 'exclamation-triangle'], color: "light", fontSize: "6xl", mb: 4 }),
@@ -3764,6 +3960,7 @@ exports.Docs = Docs;
3764
3960
  exports.ExportButton = ExportButton;
3765
3961
  exports.HttpMethodColors = HttpMethodColors;
3766
3962
  exports.InlineRefResolverProvider = InlineRefResolverProvider;
3963
+ exports.LinkHeading = LinkHeading;
3767
3964
  exports.Logo = Logo;
3768
3965
  exports.MarkdownComponentsProvider = MarkdownComponentsProvider;
3769
3966
  exports.MockingProvider = MockingProvider;
@@ -3775,6 +3972,7 @@ exports.ParsedDocs = ParsedDocs;
3775
3972
  exports.PersistenceContextProvider = PersistenceContextProvider;
3776
3973
  exports.PoweredByLink = PoweredByLink;
3777
3974
  exports.ReactRouterMarkdownLink = ReactRouterMarkdownLink;
3975
+ exports.ResponsiveSidebarLayout = ResponsiveSidebarLayout;
3778
3976
  exports.RouterTypeContext = RouterTypeContext;
3779
3977
  exports.SidebarLayout = SidebarLayout;
3780
3978
  exports.Styled = Styled;
@@ -3786,10 +3984,12 @@ exports.createResolvedObject = createResolvedObject;
3786
3984
  exports.findFirstNode = findFirstNode;
3787
3985
  exports.isHttpOperation = isHttpOperation;
3788
3986
  exports.isHttpService = isHttpService;
3987
+ exports.isHttpWebhookOperation = isHttpWebhookOperation;
3789
3988
  exports.slugify = slugify;
3790
3989
  exports.useBundleRefsIntoDocument = useBundleRefsIntoDocument;
3791
3990
  exports.useParsedData = useParsedData;
3792
3991
  exports.useParsedValue = useParsedValue;
3992
+ exports.useResponsiveLayout = useResponsiveLayout;
3793
3993
  exports.useRouter = useRouter;
3794
3994
  exports.withMosaicProvider = withMosaicProvider;
3795
3995
  exports.withPersistenceBoundary = withPersistenceBoundary;