@stoplight/elements-core 7.7.1 → 7.7.2

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.
@@ -1,9 +1,13 @@
1
- import { Meta, Story } from '@storybook/react';
1
+ import type { ErrorBoundaryProps } from '@stoplight/react-error-boundary';
2
+ import type { Meta, Story } from '@storybook/react';
2
3
  import * as React from 'react';
3
- interface HelperReturn<P> {
4
+ declare type DocsProps = {
5
+ data: unknown;
6
+ } & ErrorBoundaryProps;
7
+ interface HelperReturn<P extends Partial<DocsProps>> {
4
8
  meta: Meta<P>;
5
9
  createStory(name: string, input: Partial<P>): Story<P>;
6
10
  createHoistedStory(input: Partial<P>): Story<P>;
7
11
  }
8
- export declare const createStoriesForDocsComponent: <P>(Component: React.ComponentType<P>, title?: string | undefined) => HelperReturn<P>;
12
+ export declare const createStoriesForDocsComponent: <P extends Partial<DocsProps> = DocsProps>(Component: React.ComponentType<P>, title?: string | undefined) => HelperReturn<P>;
9
13
  export {};
package/index.esm.js CHANGED
@@ -2180,7 +2180,6 @@ const Parameters = ({ parameters, parameterType }) => {
2180
2180
  };
2181
2181
  Parameters.displayName = 'HttpOperation.Parameters';
2182
2182
  const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2183
- var _a, _b, _c;
2184
2183
  if (!parameters || !parameters.length)
2185
2184
  return null;
2186
2185
  const schema = {
@@ -2190,19 +2189,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2190
2189
  const sortedParams = sortBy(parameters, ['required', 'name']);
2191
2190
  for (const p of sortedParams) {
2192
2191
  const { name, description, required, deprecated, examples, style } = p;
2192
+ const paramSchema = isPlainObject$1(p.schema) ? p.schema : {};
2193
2193
  const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
2194
2194
  if (isNodeExample(example)) {
2195
2195
  return example.value;
2196
2196
  }
2197
2197
  return example.externalValue;
2198
2198
  })) || [];
2199
- const schemaExamples = (_a = p.schema) === null || _a === void 0 ? void 0 : _a.examples;
2199
+ const schemaExamples = paramSchema.examples;
2200
2200
  const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
2201
- const paramDescription = description || ((_b = p.schema) === null || _b === void 0 ? void 0 : _b.description);
2202
- const paramDeprecated = deprecated || p.schema.deprecated;
2201
+ const paramDescription = description || paramSchema.description;
2202
+ const paramDeprecated = !!(deprecated || paramSchema.deprecated);
2203
2203
  const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
2204
- schema.properties[p.name] = Object.assign(Object.assign({}, (p.schema || {})), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (((_c = p.schema) === null || _c === void 0 ? void 0 : _c['x-stoplight']) || {})), { id: p.id }) });
2205
- if (required) {
2204
+ if (isPlainObject$1(schema.properties)) {
2205
+ schema.properties[p.name] = Object.assign(Object.assign({}, paramSchema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (isPlainObject$1(paramSchema['x-stoplight']) ? paramSchema['x-stoplight'] : {})), { id: p.id }) });
2206
+ }
2207
+ if (required && Array.isArray(schema.required)) {
2206
2208
  schema.required.push(name);
2207
2209
  }
2208
2210
  }
package/index.js CHANGED
@@ -2234,7 +2234,6 @@ const Parameters = ({ parameters, parameterType }) => {
2234
2234
  };
2235
2235
  Parameters.displayName = 'HttpOperation.Parameters';
2236
2236
  const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2237
- var _a, _b, _c;
2238
2237
  if (!parameters || !parameters.length)
2239
2238
  return null;
2240
2239
  const schema = {
@@ -2244,19 +2243,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2244
2243
  const sortedParams = sortBy__default["default"](parameters, ['required', 'name']);
2245
2244
  for (const p of sortedParams) {
2246
2245
  const { name, description, required, deprecated, examples, style } = p;
2246
+ const paramSchema = json.isPlainObject(p.schema) ? p.schema : {};
2247
2247
  const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
2248
2248
  if (isNodeExample(example)) {
2249
2249
  return example.value;
2250
2250
  }
2251
2251
  return example.externalValue;
2252
2252
  })) || [];
2253
- const schemaExamples = (_a = p.schema) === null || _a === void 0 ? void 0 : _a.examples;
2253
+ const schemaExamples = paramSchema.examples;
2254
2254
  const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
2255
- const paramDescription = description || ((_b = p.schema) === null || _b === void 0 ? void 0 : _b.description);
2256
- const paramDeprecated = deprecated || p.schema.deprecated;
2255
+ const paramDescription = description || paramSchema.description;
2256
+ const paramDeprecated = !!(deprecated || paramSchema.deprecated);
2257
2257
  const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
2258
- schema.properties[p.name] = Object.assign(Object.assign({}, (p.schema || {})), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (((_c = p.schema) === null || _c === void 0 ? void 0 : _c['x-stoplight']) || {})), { id: p.id }) });
2259
- if (required) {
2258
+ if (json.isPlainObject(schema.properties)) {
2259
+ schema.properties[p.name] = Object.assign(Object.assign({}, paramSchema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (json.isPlainObject(paramSchema['x-stoplight']) ? paramSchema['x-stoplight'] : {})), { id: p.id }) });
2260
+ }
2261
+ if (required && Array.isArray(schema.required)) {
2260
2262
  schema.required.push(name);
2261
2263
  }
2262
2264
  }
package/index.mjs CHANGED
@@ -2180,7 +2180,6 @@ const Parameters = ({ parameters, parameterType }) => {
2180
2180
  };
2181
2181
  Parameters.displayName = 'HttpOperation.Parameters';
2182
2182
  const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2183
- var _a, _b, _c;
2184
2183
  if (!parameters || !parameters.length)
2185
2184
  return null;
2186
2185
  const schema = {
@@ -2190,19 +2189,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
2190
2189
  const sortedParams = sortBy(parameters, ['required', 'name']);
2191
2190
  for (const p of sortedParams) {
2192
2191
  const { name, description, required, deprecated, examples, style } = p;
2192
+ const paramSchema = isPlainObject$1(p.schema) ? p.schema : {};
2193
2193
  const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
2194
2194
  if (isNodeExample(example)) {
2195
2195
  return example.value;
2196
2196
  }
2197
2197
  return example.externalValue;
2198
2198
  })) || [];
2199
- const schemaExamples = (_a = p.schema) === null || _a === void 0 ? void 0 : _a.examples;
2199
+ const schemaExamples = paramSchema.examples;
2200
2200
  const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
2201
- const paramDescription = description || ((_b = p.schema) === null || _b === void 0 ? void 0 : _b.description);
2202
- const paramDeprecated = deprecated || p.schema.deprecated;
2201
+ const paramDescription = description || paramSchema.description;
2202
+ const paramDeprecated = !!(deprecated || paramSchema.deprecated);
2203
2203
  const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
2204
- schema.properties[p.name] = Object.assign(Object.assign({}, (p.schema || {})), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (((_c = p.schema) === null || _c === void 0 ? void 0 : _c['x-stoplight']) || {})), { id: p.id }) });
2205
- if (required) {
2204
+ if (isPlainObject$1(schema.properties)) {
2205
+ schema.properties[p.name] = Object.assign(Object.assign({}, paramSchema), { description: paramDescription, examples: [...paramExamples, ...schemaExamplesArray], deprecated: paramDeprecated, style: paramStyle, 'x-stoplight': Object.assign(Object.assign({}, (isPlainObject$1(paramSchema['x-stoplight']) ? paramSchema['x-stoplight'] : {})), { id: p.id }) });
2206
+ }
2207
+ if (required && Array.isArray(schema.required)) {
2206
2208
  schema.required.push(name);
2207
2209
  }
2208
2210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.7.1",
3
+ "version": "7.7.2",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",