@stoplight/elements-core 7.7.2 → 7.7.4

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 (4) hide show
  1. package/index.esm.js +27 -14
  2. package/index.js +27 -14
  3. package/index.mjs +27 -14
  4. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1334,6 +1334,11 @@ const getServerUrl = ({ chosenServer, httpOperation, mockData, corsProxy, }) =>
1334
1334
  }
1335
1335
  return serverUrl;
1336
1336
  };
1337
+ const delimiter = {
1338
+ [HttpParamStyles.Form]: ',',
1339
+ [HttpParamStyles.SpaceDelimited]: ' ',
1340
+ [HttpParamStyles.PipeDelimited]: '|',
1341
+ };
1337
1342
  const getQueryParams = ({ httpOperation, parameterValues, }) => {
1338
1343
  var _a;
1339
1344
  const query = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.query;
@@ -1370,9 +1375,16 @@ const getQueryParams = ({ httpOperation, parameterValues, }) => {
1370
1375
  else if (((_d = param.schema) === null || _d === void 0 ? void 0 : _d.type) === 'array' && value) {
1371
1376
  let nested;
1372
1377
  try {
1373
- nested = JSON.parse(value);
1374
- if (!Array.isArray(nested))
1378
+ const parsed = JSON.parse(value);
1379
+ if (typeof parsed === 'string') {
1380
+ nested = parsed.split(delimiter[param.style]);
1381
+ }
1382
+ else if (Array.isArray(parsed)) {
1383
+ nested = parsed;
1384
+ }
1385
+ else {
1375
1386
  throw Error();
1387
+ }
1376
1388
  }
1377
1389
  catch (e) {
1378
1390
  throw new Error(`Cannot use param value "${value}". JSON array expected.`);
@@ -1381,11 +1393,6 @@ const getQueryParams = ({ httpOperation, parameterValues, }) => {
1381
1393
  acc.push(...nested.map(value => ({ name: param.name, value: value.toString() })));
1382
1394
  }
1383
1395
  else {
1384
- const delimiter = {
1385
- [HttpParamStyles.Form]: ',',
1386
- [HttpParamStyles.SpaceDelimited]: ' ',
1387
- [HttpParamStyles.PipeDelimited]: '|',
1388
- };
1389
1396
  acc.push({
1390
1397
  name: param.name,
1391
1398
  value: nested.join((_e = delimiter[param.style]) !== null && _e !== void 0 ? _e : delimiter[HttpParamStyles.Form]),
@@ -1908,10 +1915,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
1908
1915
  if (response) {
1909
1916
  const contentType = response.headers.get('Content-Type');
1910
1917
  const type = contentType ? getResponseType(contentType) : undefined;
1918
+ const bodyText = type !== 'image' ? yield response.text() : undefined;
1919
+ const blob = type === 'image' ? yield response.blob() : undefined;
1920
+ setResponse(undefined);
1911
1921
  setResponse({
1912
1922
  status: response.status,
1913
- bodyText: type !== 'image' ? yield response.text() : undefined,
1914
- blob: type === 'image' ? yield response.blob() : undefined,
1923
+ bodyText,
1924
+ blob,
1915
1925
  contentType,
1916
1926
  });
1917
1927
  }
@@ -2108,9 +2118,9 @@ const CustomLinkHeading = React.memo(function LinkHeading(_a) {
2108
2118
  });
2109
2119
 
2110
2120
  const SectionTitle = ({ title, id, size = 2, children }) => {
2111
- return (React.createElement(HStack, { spacing: 6 },
2112
- React.createElement(Box, { as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
2113
- children));
2121
+ return (React.createElement(Flex, { flexWrap: true },
2122
+ React.createElement(Box, { py: 1, pr: 6, as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
2123
+ React.createElement(Box, { alignSelf: 'center', py: 1 }, children)));
2114
2124
  };
2115
2125
  const SectionSubtitle = props => {
2116
2126
  return React.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
@@ -2525,14 +2535,17 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
2525
2535
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
2526
2536
  const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
2527
2537
  const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
2538
+ const isDeprecated = !!data['deprecated'];
2528
2539
  const isInternal = !!data['x-internal'];
2529
2540
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
2530
2541
  const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
2531
- const header = (shouldDisplayHeader || isInternal) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
2542
+ const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
2532
2543
  React.createElement(Box, { pos: "relative" },
2533
2544
  React.createElement(HStack, { spacing: 5 },
2534
2545
  title && (React.createElement(Heading, { size: 1, fontWeight: "semibold" }, title)),
2535
- React.createElement(HStack, { spacing: 2 }, isInternal && React.createElement(InternalBadge, null))),
2546
+ React.createElement(HStack, { spacing: 2 },
2547
+ isDeprecated && React.createElement(DeprecatedBadge, null),
2548
+ isInternal && React.createElement(InternalBadge, null))),
2536
2549
  React.createElement(NodeAnnotation, { change: titleChanged })),
2537
2550
  exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React.createElement(ExportButton, Object.assign({}, exportProps))));
2538
2551
  const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
package/index.js CHANGED
@@ -1388,6 +1388,11 @@ const getServerUrl = ({ chosenServer, httpOperation, mockData, corsProxy, }) =>
1388
1388
  }
1389
1389
  return serverUrl;
1390
1390
  };
1391
+ const delimiter = {
1392
+ [types.HttpParamStyles.Form]: ',',
1393
+ [types.HttpParamStyles.SpaceDelimited]: ' ',
1394
+ [types.HttpParamStyles.PipeDelimited]: '|',
1395
+ };
1391
1396
  const getQueryParams = ({ httpOperation, parameterValues, }) => {
1392
1397
  var _a;
1393
1398
  const query = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.query;
@@ -1424,9 +1429,16 @@ const getQueryParams = ({ httpOperation, parameterValues, }) => {
1424
1429
  else if (((_d = param.schema) === null || _d === void 0 ? void 0 : _d.type) === 'array' && value) {
1425
1430
  let nested;
1426
1431
  try {
1427
- nested = JSON.parse(value);
1428
- if (!Array.isArray(nested))
1432
+ const parsed = JSON.parse(value);
1433
+ if (typeof parsed === 'string') {
1434
+ nested = parsed.split(delimiter[param.style]);
1435
+ }
1436
+ else if (Array.isArray(parsed)) {
1437
+ nested = parsed;
1438
+ }
1439
+ else {
1429
1440
  throw Error();
1441
+ }
1430
1442
  }
1431
1443
  catch (e) {
1432
1444
  throw new Error(`Cannot use param value "${value}". JSON array expected.`);
@@ -1435,11 +1447,6 @@ const getQueryParams = ({ httpOperation, parameterValues, }) => {
1435
1447
  acc.push(...nested.map(value => ({ name: param.name, value: value.toString() })));
1436
1448
  }
1437
1449
  else {
1438
- const delimiter = {
1439
- [types.HttpParamStyles.Form]: ',',
1440
- [types.HttpParamStyles.SpaceDelimited]: ' ',
1441
- [types.HttpParamStyles.PipeDelimited]: '|',
1442
- };
1443
1450
  acc.push({
1444
1451
  name: param.name,
1445
1452
  value: nested.join((_e = delimiter[param.style]) !== null && _e !== void 0 ? _e : delimiter[types.HttpParamStyles.Form]),
@@ -1962,10 +1969,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
1962
1969
  if (response) {
1963
1970
  const contentType = response.headers.get('Content-Type');
1964
1971
  const type = contentType ? getResponseType(contentType) : undefined;
1972
+ const bodyText = type !== 'image' ? yield response.text() : undefined;
1973
+ const blob = type === 'image' ? yield response.blob() : undefined;
1974
+ setResponse(undefined);
1965
1975
  setResponse({
1966
1976
  status: response.status,
1967
- bodyText: type !== 'image' ? yield response.text() : undefined,
1968
- blob: type === 'image' ? yield response.blob() : undefined,
1977
+ bodyText,
1978
+ blob,
1969
1979
  contentType,
1970
1980
  });
1971
1981
  }
@@ -2162,9 +2172,9 @@ const CustomLinkHeading = React__namespace.memo(function LinkHeading(_a) {
2162
2172
  });
2163
2173
 
2164
2174
  const SectionTitle = ({ title, id, size = 2, children }) => {
2165
- return (React__namespace.createElement(mosaic.HStack, { spacing: 6 },
2166
- React__namespace.createElement(mosaic.Box, { as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
2167
- children));
2175
+ return (React__namespace.createElement(mosaic.Flex, { flexWrap: true },
2176
+ React__namespace.createElement(mosaic.Box, { py: 1, pr: 6, as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
2177
+ React__namespace.createElement(mosaic.Box, { alignSelf: 'center', py: 1 }, children)));
2168
2178
  };
2169
2179
  const SectionSubtitle = props => {
2170
2180
  return React__namespace.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
@@ -2579,14 +2589,17 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
2579
2589
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
2580
2590
  const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
2581
2591
  const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
2592
+ const isDeprecated = !!data['deprecated'];
2582
2593
  const isInternal = !!data['x-internal'];
2583
2594
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
2584
2595
  const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
2585
- const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
2596
+ const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
2586
2597
  React__namespace.createElement(mosaic.Box, { pos: "relative" },
2587
2598
  React__namespace.createElement(mosaic.HStack, { spacing: 5 },
2588
2599
  title && (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, title)),
2589
- React__namespace.createElement(mosaic.HStack, { spacing: 2 }, isInternal && React__namespace.createElement(InternalBadge, null))),
2600
+ React__namespace.createElement(mosaic.HStack, { spacing: 2 },
2601
+ isDeprecated && React__namespace.createElement(DeprecatedBadge, null),
2602
+ isInternal && React__namespace.createElement(InternalBadge, null))),
2590
2603
  React__namespace.createElement(mosaic.NodeAnnotation, { change: titleChanged })),
2591
2604
  exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
2592
2605
  const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React__namespace.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
package/index.mjs CHANGED
@@ -1334,6 +1334,11 @@ const getServerUrl = ({ chosenServer, httpOperation, mockData, corsProxy, }) =>
1334
1334
  }
1335
1335
  return serverUrl;
1336
1336
  };
1337
+ const delimiter = {
1338
+ [HttpParamStyles.Form]: ',',
1339
+ [HttpParamStyles.SpaceDelimited]: ' ',
1340
+ [HttpParamStyles.PipeDelimited]: '|',
1341
+ };
1337
1342
  const getQueryParams = ({ httpOperation, parameterValues, }) => {
1338
1343
  var _a;
1339
1344
  const query = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.query;
@@ -1370,9 +1375,16 @@ const getQueryParams = ({ httpOperation, parameterValues, }) => {
1370
1375
  else if (((_d = param.schema) === null || _d === void 0 ? void 0 : _d.type) === 'array' && value) {
1371
1376
  let nested;
1372
1377
  try {
1373
- nested = JSON.parse(value);
1374
- if (!Array.isArray(nested))
1378
+ const parsed = JSON.parse(value);
1379
+ if (typeof parsed === 'string') {
1380
+ nested = parsed.split(delimiter[param.style]);
1381
+ }
1382
+ else if (Array.isArray(parsed)) {
1383
+ nested = parsed;
1384
+ }
1385
+ else {
1375
1386
  throw Error();
1387
+ }
1376
1388
  }
1377
1389
  catch (e) {
1378
1390
  throw new Error(`Cannot use param value "${value}". JSON array expected.`);
@@ -1381,11 +1393,6 @@ const getQueryParams = ({ httpOperation, parameterValues, }) => {
1381
1393
  acc.push(...nested.map(value => ({ name: param.name, value: value.toString() })));
1382
1394
  }
1383
1395
  else {
1384
- const delimiter = {
1385
- [HttpParamStyles.Form]: ',',
1386
- [HttpParamStyles.SpaceDelimited]: ' ',
1387
- [HttpParamStyles.PipeDelimited]: '|',
1388
- };
1389
1396
  acc.push({
1390
1397
  name: param.name,
1391
1398
  value: nested.join((_e = delimiter[param.style]) !== null && _e !== void 0 ? _e : delimiter[HttpParamStyles.Form]),
@@ -1908,10 +1915,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
1908
1915
  if (response) {
1909
1916
  const contentType = response.headers.get('Content-Type');
1910
1917
  const type = contentType ? getResponseType(contentType) : undefined;
1918
+ const bodyText = type !== 'image' ? yield response.text() : undefined;
1919
+ const blob = type === 'image' ? yield response.blob() : undefined;
1920
+ setResponse(undefined);
1911
1921
  setResponse({
1912
1922
  status: response.status,
1913
- bodyText: type !== 'image' ? yield response.text() : undefined,
1914
- blob: type === 'image' ? yield response.blob() : undefined,
1923
+ bodyText,
1924
+ blob,
1915
1925
  contentType,
1916
1926
  });
1917
1927
  }
@@ -2108,9 +2118,9 @@ const CustomLinkHeading = React.memo(function LinkHeading(_a) {
2108
2118
  });
2109
2119
 
2110
2120
  const SectionTitle = ({ title, id, size = 2, children }) => {
2111
- return (React.createElement(HStack, { spacing: 6 },
2112
- React.createElement(Box, { as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
2113
- children));
2121
+ return (React.createElement(Flex, { flexWrap: true },
2122
+ React.createElement(Box, { py: 1, pr: 6, as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
2123
+ React.createElement(Box, { alignSelf: 'center', py: 1 }, children)));
2114
2124
  };
2115
2125
  const SectionSubtitle = props => {
2116
2126
  return React.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
@@ -2525,14 +2535,17 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
2525
2535
  const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
2526
2536
  const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
2527
2537
  const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
2538
+ const isDeprecated = !!data['deprecated'];
2528
2539
  const isInternal = !!data['x-internal'];
2529
2540
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
2530
2541
  const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
2531
- const header = (shouldDisplayHeader || isInternal) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
2542
+ const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
2532
2543
  React.createElement(Box, { pos: "relative" },
2533
2544
  React.createElement(HStack, { spacing: 5 },
2534
2545
  title && (React.createElement(Heading, { size: 1, fontWeight: "semibold" }, title)),
2535
- React.createElement(HStack, { spacing: 2 }, isInternal && React.createElement(InternalBadge, null))),
2546
+ React.createElement(HStack, { spacing: 2 },
2547
+ isDeprecated && React.createElement(DeprecatedBadge, null),
2548
+ isInternal && React.createElement(InternalBadge, null))),
2536
2549
  React.createElement(NodeAnnotation, { change: titleChanged })),
2537
2550
  exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React.createElement(ExportButton, Object.assign({}, exportProps))));
2538
2551
  const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.7.2",
3
+ "version": "7.7.4",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",