@stoplight/elements-core 7.7.1 → 7.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Docs/story-helper.d.ts +7 -3
- package/index.esm.js +21 -13
- package/index.js +21 -13
- package/index.mjs +21 -13
- package/package.json +1 -1
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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
|
@@ -1908,10 +1908,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1908
1908
|
if (response) {
|
|
1909
1909
|
const contentType = response.headers.get('Content-Type');
|
|
1910
1910
|
const type = contentType ? getResponseType(contentType) : undefined;
|
|
1911
|
+
const bodyText = type !== 'image' ? yield response.text() : undefined;
|
|
1912
|
+
const blob = type === 'image' ? yield response.blob() : undefined;
|
|
1913
|
+
setResponse(undefined);
|
|
1911
1914
|
setResponse({
|
|
1912
1915
|
status: response.status,
|
|
1913
|
-
bodyText
|
|
1914
|
-
blob
|
|
1916
|
+
bodyText,
|
|
1917
|
+
blob,
|
|
1915
1918
|
contentType,
|
|
1916
1919
|
});
|
|
1917
1920
|
}
|
|
@@ -2108,9 +2111,9 @@ const CustomLinkHeading = React.memo(function LinkHeading(_a) {
|
|
|
2108
2111
|
});
|
|
2109
2112
|
|
|
2110
2113
|
const SectionTitle = ({ title, id, size = 2, children }) => {
|
|
2111
|
-
return (React.createElement(
|
|
2112
|
-
React.createElement(Box, { as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
2113
|
-
children));
|
|
2114
|
+
return (React.createElement(Flex, { flexWrap: true },
|
|
2115
|
+
React.createElement(Box, { py: 1, pr: 6, as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
2116
|
+
React.createElement(Box, { alignSelf: 'center', py: 1 }, children)));
|
|
2114
2117
|
};
|
|
2115
2118
|
const SectionSubtitle = props => {
|
|
2116
2119
|
return React.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
|
|
@@ -2180,7 +2183,6 @@ const Parameters = ({ parameters, parameterType }) => {
|
|
|
2180
2183
|
};
|
|
2181
2184
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
2182
2185
|
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2183
|
-
var _a, _b, _c;
|
|
2184
2186
|
if (!parameters || !parameters.length)
|
|
2185
2187
|
return null;
|
|
2186
2188
|
const schema = {
|
|
@@ -2190,19 +2192,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2190
2192
|
const sortedParams = sortBy(parameters, ['required', 'name']);
|
|
2191
2193
|
for (const p of sortedParams) {
|
|
2192
2194
|
const { name, description, required, deprecated, examples, style } = p;
|
|
2195
|
+
const paramSchema = isPlainObject$1(p.schema) ? p.schema : {};
|
|
2193
2196
|
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2194
2197
|
if (isNodeExample(example)) {
|
|
2195
2198
|
return example.value;
|
|
2196
2199
|
}
|
|
2197
2200
|
return example.externalValue;
|
|
2198
2201
|
})) || [];
|
|
2199
|
-
const schemaExamples =
|
|
2202
|
+
const schemaExamples = paramSchema.examples;
|
|
2200
2203
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2201
|
-
const paramDescription = description ||
|
|
2202
|
-
const paramDeprecated = deprecated ||
|
|
2204
|
+
const paramDescription = description || paramSchema.description;
|
|
2205
|
+
const paramDeprecated = !!(deprecated || paramSchema.deprecated);
|
|
2203
2206
|
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2204
|
-
|
|
2205
|
-
|
|
2207
|
+
if (isPlainObject$1(schema.properties)) {
|
|
2208
|
+
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 }) });
|
|
2209
|
+
}
|
|
2210
|
+
if (required && Array.isArray(schema.required)) {
|
|
2206
2211
|
schema.required.push(name);
|
|
2207
2212
|
}
|
|
2208
2213
|
}
|
|
@@ -2523,14 +2528,17 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2523
2528
|
const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
|
|
2524
2529
|
const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
|
|
2525
2530
|
const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
|
|
2531
|
+
const isDeprecated = !!data['deprecated'];
|
|
2526
2532
|
const isInternal = !!data['x-internal'];
|
|
2527
2533
|
const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
|
|
2528
2534
|
const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
|
|
2529
|
-
const header = (shouldDisplayHeader || isInternal) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
|
|
2535
|
+
const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
|
|
2530
2536
|
React.createElement(Box, { pos: "relative" },
|
|
2531
2537
|
React.createElement(HStack, { spacing: 5 },
|
|
2532
2538
|
title && (React.createElement(Heading, { size: 1, fontWeight: "semibold" }, title)),
|
|
2533
|
-
React.createElement(HStack, { spacing: 2 },
|
|
2539
|
+
React.createElement(HStack, { spacing: 2 },
|
|
2540
|
+
isDeprecated && React.createElement(DeprecatedBadge, null),
|
|
2541
|
+
isInternal && React.createElement(InternalBadge, null))),
|
|
2534
2542
|
React.createElement(NodeAnnotation, { change: titleChanged })),
|
|
2535
2543
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
2536
2544
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
package/index.js
CHANGED
|
@@ -1962,10 +1962,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1962
1962
|
if (response) {
|
|
1963
1963
|
const contentType = response.headers.get('Content-Type');
|
|
1964
1964
|
const type = contentType ? getResponseType(contentType) : undefined;
|
|
1965
|
+
const bodyText = type !== 'image' ? yield response.text() : undefined;
|
|
1966
|
+
const blob = type === 'image' ? yield response.blob() : undefined;
|
|
1967
|
+
setResponse(undefined);
|
|
1965
1968
|
setResponse({
|
|
1966
1969
|
status: response.status,
|
|
1967
|
-
bodyText
|
|
1968
|
-
blob
|
|
1970
|
+
bodyText,
|
|
1971
|
+
blob,
|
|
1969
1972
|
contentType,
|
|
1970
1973
|
});
|
|
1971
1974
|
}
|
|
@@ -2162,9 +2165,9 @@ const CustomLinkHeading = React__namespace.memo(function LinkHeading(_a) {
|
|
|
2162
2165
|
});
|
|
2163
2166
|
|
|
2164
2167
|
const SectionTitle = ({ title, id, size = 2, children }) => {
|
|
2165
|
-
return (React__namespace.createElement(mosaic.
|
|
2166
|
-
React__namespace.createElement(mosaic.Box, { as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
2167
|
-
children));
|
|
2168
|
+
return (React__namespace.createElement(mosaic.Flex, { flexWrap: true },
|
|
2169
|
+
React__namespace.createElement(mosaic.Box, { py: 1, pr: 6, as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
2170
|
+
React__namespace.createElement(mosaic.Box, { alignSelf: 'center', py: 1 }, children)));
|
|
2168
2171
|
};
|
|
2169
2172
|
const SectionSubtitle = props => {
|
|
2170
2173
|
return React__namespace.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
|
|
@@ -2234,7 +2237,6 @@ const Parameters = ({ parameters, parameterType }) => {
|
|
|
2234
2237
|
};
|
|
2235
2238
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
2236
2239
|
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2237
|
-
var _a, _b, _c;
|
|
2238
2240
|
if (!parameters || !parameters.length)
|
|
2239
2241
|
return null;
|
|
2240
2242
|
const schema = {
|
|
@@ -2244,19 +2246,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2244
2246
|
const sortedParams = sortBy__default["default"](parameters, ['required', 'name']);
|
|
2245
2247
|
for (const p of sortedParams) {
|
|
2246
2248
|
const { name, description, required, deprecated, examples, style } = p;
|
|
2249
|
+
const paramSchema = json.isPlainObject(p.schema) ? p.schema : {};
|
|
2247
2250
|
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2248
2251
|
if (isNodeExample(example)) {
|
|
2249
2252
|
return example.value;
|
|
2250
2253
|
}
|
|
2251
2254
|
return example.externalValue;
|
|
2252
2255
|
})) || [];
|
|
2253
|
-
const schemaExamples =
|
|
2256
|
+
const schemaExamples = paramSchema.examples;
|
|
2254
2257
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2255
|
-
const paramDescription = description ||
|
|
2256
|
-
const paramDeprecated = deprecated ||
|
|
2258
|
+
const paramDescription = description || paramSchema.description;
|
|
2259
|
+
const paramDeprecated = !!(deprecated || paramSchema.deprecated);
|
|
2257
2260
|
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2258
|
-
|
|
2259
|
-
|
|
2261
|
+
if (json.isPlainObject(schema.properties)) {
|
|
2262
|
+
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 }) });
|
|
2263
|
+
}
|
|
2264
|
+
if (required && Array.isArray(schema.required)) {
|
|
2260
2265
|
schema.required.push(name);
|
|
2261
2266
|
}
|
|
2262
2267
|
}
|
|
@@ -2577,14 +2582,17 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2577
2582
|
const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
|
|
2578
2583
|
const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
|
|
2579
2584
|
const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
|
|
2585
|
+
const isDeprecated = !!data['deprecated'];
|
|
2580
2586
|
const isInternal = !!data['x-internal'];
|
|
2581
2587
|
const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
|
|
2582
2588
|
const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
|
|
2583
|
-
const header = (shouldDisplayHeader || isInternal) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
|
|
2589
|
+
const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
|
|
2584
2590
|
React__namespace.createElement(mosaic.Box, { pos: "relative" },
|
|
2585
2591
|
React__namespace.createElement(mosaic.HStack, { spacing: 5 },
|
|
2586
2592
|
title && (React__namespace.createElement(mosaic.Heading, { size: 1, fontWeight: "semibold" }, title)),
|
|
2587
|
-
React__namespace.createElement(mosaic.HStack, { spacing: 2 },
|
|
2593
|
+
React__namespace.createElement(mosaic.HStack, { spacing: 2 },
|
|
2594
|
+
isDeprecated && React__namespace.createElement(DeprecatedBadge, null),
|
|
2595
|
+
isInternal && React__namespace.createElement(InternalBadge, null))),
|
|
2588
2596
|
React__namespace.createElement(mosaic.NodeAnnotation, { change: titleChanged })),
|
|
2589
2597
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React__namespace.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
2590
2598
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React__namespace.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|
package/index.mjs
CHANGED
|
@@ -1908,10 +1908,13 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
|
|
|
1908
1908
|
if (response) {
|
|
1909
1909
|
const contentType = response.headers.get('Content-Type');
|
|
1910
1910
|
const type = contentType ? getResponseType(contentType) : undefined;
|
|
1911
|
+
const bodyText = type !== 'image' ? yield response.text() : undefined;
|
|
1912
|
+
const blob = type === 'image' ? yield response.blob() : undefined;
|
|
1913
|
+
setResponse(undefined);
|
|
1911
1914
|
setResponse({
|
|
1912
1915
|
status: response.status,
|
|
1913
|
-
bodyText
|
|
1914
|
-
blob
|
|
1916
|
+
bodyText,
|
|
1917
|
+
blob,
|
|
1915
1918
|
contentType,
|
|
1916
1919
|
});
|
|
1917
1920
|
}
|
|
@@ -2108,9 +2111,9 @@ const CustomLinkHeading = React.memo(function LinkHeading(_a) {
|
|
|
2108
2111
|
});
|
|
2109
2112
|
|
|
2110
2113
|
const SectionTitle = ({ title, id, size = 2, children }) => {
|
|
2111
|
-
return (React.createElement(
|
|
2112
|
-
React.createElement(Box, { as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
2113
|
-
children));
|
|
2114
|
+
return (React.createElement(Flex, { flexWrap: true },
|
|
2115
|
+
React.createElement(Box, { py: 1, pr: 6, as: LinkHeading, size: size, "aria-label": title, id: id || slugify(title) }, title),
|
|
2116
|
+
React.createElement(Box, { alignSelf: 'center', py: 1 }, children)));
|
|
2114
2117
|
};
|
|
2115
2118
|
const SectionSubtitle = props => {
|
|
2116
2119
|
return React.createElement(SectionTitle, Object.assign({}, props, { size: 3 }));
|
|
@@ -2180,7 +2183,6 @@ const Parameters = ({ parameters, parameterType }) => {
|
|
|
2180
2183
|
};
|
|
2181
2184
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
2182
2185
|
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2183
|
-
var _a, _b, _c;
|
|
2184
2186
|
if (!parameters || !parameters.length)
|
|
2185
2187
|
return null;
|
|
2186
2188
|
const schema = {
|
|
@@ -2190,19 +2192,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2190
2192
|
const sortedParams = sortBy(parameters, ['required', 'name']);
|
|
2191
2193
|
for (const p of sortedParams) {
|
|
2192
2194
|
const { name, description, required, deprecated, examples, style } = p;
|
|
2195
|
+
const paramSchema = isPlainObject$1(p.schema) ? p.schema : {};
|
|
2193
2196
|
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2194
2197
|
if (isNodeExample(example)) {
|
|
2195
2198
|
return example.value;
|
|
2196
2199
|
}
|
|
2197
2200
|
return example.externalValue;
|
|
2198
2201
|
})) || [];
|
|
2199
|
-
const schemaExamples =
|
|
2202
|
+
const schemaExamples = paramSchema.examples;
|
|
2200
2203
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2201
|
-
const paramDescription = description ||
|
|
2202
|
-
const paramDeprecated = deprecated ||
|
|
2204
|
+
const paramDescription = description || paramSchema.description;
|
|
2205
|
+
const paramDeprecated = !!(deprecated || paramSchema.deprecated);
|
|
2203
2206
|
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2204
|
-
|
|
2205
|
-
|
|
2207
|
+
if (isPlainObject$1(schema.properties)) {
|
|
2208
|
+
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 }) });
|
|
2209
|
+
}
|
|
2210
|
+
if (required && Array.isArray(schema.required)) {
|
|
2206
2211
|
schema.required.push(name);
|
|
2207
2212
|
}
|
|
2208
2213
|
}
|
|
@@ -2523,14 +2528,17 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
|
|
|
2523
2528
|
const { ref: layoutRef, isCompact } = useIsCompact(layoutOptions);
|
|
2524
2529
|
const nodeId = (_a = data === null || data === void 0 ? void 0 : data['x-stoplight']) === null || _a === void 0 ? void 0 : _a.id;
|
|
2525
2530
|
const title = (_b = data.title) !== null && _b !== void 0 ? _b : nodeTitle;
|
|
2531
|
+
const isDeprecated = !!data['deprecated'];
|
|
2526
2532
|
const isInternal = !!data['x-internal'];
|
|
2527
2533
|
const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
|
|
2528
2534
|
const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
|
|
2529
|
-
const header = (shouldDisplayHeader || isInternal) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
|
|
2535
|
+
const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
|
|
2530
2536
|
React.createElement(Box, { pos: "relative" },
|
|
2531
2537
|
React.createElement(HStack, { spacing: 5 },
|
|
2532
2538
|
title && (React.createElement(Heading, { size: 1, fontWeight: "semibold" }, title)),
|
|
2533
|
-
React.createElement(HStack, { spacing: 2 },
|
|
2539
|
+
React.createElement(HStack, { spacing: 2 },
|
|
2540
|
+
isDeprecated && React.createElement(DeprecatedBadge, null),
|
|
2541
|
+
isInternal && React.createElement(InternalBadge, null))),
|
|
2534
2542
|
React.createElement(NodeAnnotation, { change: titleChanged })),
|
|
2535
2543
|
exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && React.createElement(ExportButton, Object.assign({}, exportProps))));
|
|
2536
2544
|
const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
|