@stoplight/elements-core 7.7.0 → 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.
- package/components/Docs/story-helper.d.ts +7 -3
- package/context/RouterType.d.ts +2 -1
- package/index.esm.js +18 -8
- package/index.js +18 -8
- package/index.mjs +18 -8
- 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/context/RouterType.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { RouterType } from '../types';
|
|
3
|
-
export declare const RouterTypeContext: React.Context<RouterType>;
|
|
3
|
+
export declare const RouterTypeContext: React.Context<RouterType | null>;
|
|
4
|
+
export declare const useRouterType: () => RouterType | null;
|
package/index.esm.js
CHANGED
|
@@ -2088,9 +2088,17 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
|
|
|
2088
2088
|
return description;
|
|
2089
2089
|
}
|
|
2090
2090
|
|
|
2091
|
-
const RouterTypeContext = React.createContext(
|
|
2091
|
+
const RouterTypeContext = React.createContext(null);
|
|
2092
|
+
const useRouterType = () => {
|
|
2093
|
+
return React.useContext(RouterTypeContext);
|
|
2094
|
+
};
|
|
2092
2095
|
|
|
2093
|
-
const LinkHeading = React.memo(function LinkHeading(
|
|
2096
|
+
const LinkHeading = React.memo(function LinkHeading(props) {
|
|
2097
|
+
const isUsingRouter = !!useRouterType();
|
|
2098
|
+
const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
|
|
2099
|
+
return React.createElement(Comp, Object.assign({}, props));
|
|
2100
|
+
});
|
|
2101
|
+
const CustomLinkHeading = React.memo(function LinkHeading(_a) {
|
|
2094
2102
|
var { id: _id } = _a, props = __rest(_a, ["id"]);
|
|
2095
2103
|
const { pathname } = useLocation();
|
|
2096
2104
|
const routerKind = React.useContext(RouterTypeContext);
|
|
@@ -2172,7 +2180,6 @@ const Parameters = ({ parameters, parameterType }) => {
|
|
|
2172
2180
|
};
|
|
2173
2181
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
2174
2182
|
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2175
|
-
var _a, _b, _c;
|
|
2176
2183
|
if (!parameters || !parameters.length)
|
|
2177
2184
|
return null;
|
|
2178
2185
|
const schema = {
|
|
@@ -2182,19 +2189,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2182
2189
|
const sortedParams = sortBy(parameters, ['required', 'name']);
|
|
2183
2190
|
for (const p of sortedParams) {
|
|
2184
2191
|
const { name, description, required, deprecated, examples, style } = p;
|
|
2192
|
+
const paramSchema = isPlainObject$1(p.schema) ? p.schema : {};
|
|
2185
2193
|
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2186
2194
|
if (isNodeExample(example)) {
|
|
2187
2195
|
return example.value;
|
|
2188
2196
|
}
|
|
2189
2197
|
return example.externalValue;
|
|
2190
2198
|
})) || [];
|
|
2191
|
-
const schemaExamples =
|
|
2199
|
+
const schemaExamples = paramSchema.examples;
|
|
2192
2200
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2193
|
-
const paramDescription = description ||
|
|
2194
|
-
const paramDeprecated = deprecated ||
|
|
2201
|
+
const paramDescription = description || paramSchema.description;
|
|
2202
|
+
const paramDeprecated = !!(deprecated || paramSchema.deprecated);
|
|
2195
2203
|
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2196
|
-
|
|
2197
|
-
|
|
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)) {
|
|
2198
2208
|
schema.required.push(name);
|
|
2199
2209
|
}
|
|
2200
2210
|
}
|
package/index.js
CHANGED
|
@@ -2142,9 +2142,17 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
|
|
|
2142
2142
|
return description;
|
|
2143
2143
|
}
|
|
2144
2144
|
|
|
2145
|
-
const RouterTypeContext = React__namespace.createContext(
|
|
2145
|
+
const RouterTypeContext = React__namespace.createContext(null);
|
|
2146
|
+
const useRouterType = () => {
|
|
2147
|
+
return React__namespace.useContext(RouterTypeContext);
|
|
2148
|
+
};
|
|
2146
2149
|
|
|
2147
|
-
const LinkHeading = React__namespace.memo(function LinkHeading(
|
|
2150
|
+
const LinkHeading = React__namespace.memo(function LinkHeading(props) {
|
|
2151
|
+
const isUsingRouter = !!useRouterType();
|
|
2152
|
+
const Comp = isUsingRouter ? CustomLinkHeading : mosaic.LinkHeading;
|
|
2153
|
+
return React__namespace.createElement(Comp, Object.assign({}, props));
|
|
2154
|
+
});
|
|
2155
|
+
const CustomLinkHeading = React__namespace.memo(function LinkHeading(_a) {
|
|
2148
2156
|
var { id: _id } = _a, props = tslib.__rest(_a, ["id"]);
|
|
2149
2157
|
const { pathname } = reactRouterDom.useLocation();
|
|
2150
2158
|
const routerKind = React__namespace.useContext(RouterTypeContext);
|
|
@@ -2226,7 +2234,6 @@ const Parameters = ({ parameters, parameterType }) => {
|
|
|
2226
2234
|
};
|
|
2227
2235
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
2228
2236
|
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2229
|
-
var _a, _b, _c;
|
|
2230
2237
|
if (!parameters || !parameters.length)
|
|
2231
2238
|
return null;
|
|
2232
2239
|
const schema = {
|
|
@@ -2236,19 +2243,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2236
2243
|
const sortedParams = sortBy__default["default"](parameters, ['required', 'name']);
|
|
2237
2244
|
for (const p of sortedParams) {
|
|
2238
2245
|
const { name, description, required, deprecated, examples, style } = p;
|
|
2246
|
+
const paramSchema = json.isPlainObject(p.schema) ? p.schema : {};
|
|
2239
2247
|
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2240
2248
|
if (isNodeExample(example)) {
|
|
2241
2249
|
return example.value;
|
|
2242
2250
|
}
|
|
2243
2251
|
return example.externalValue;
|
|
2244
2252
|
})) || [];
|
|
2245
|
-
const schemaExamples =
|
|
2253
|
+
const schemaExamples = paramSchema.examples;
|
|
2246
2254
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2247
|
-
const paramDescription = description ||
|
|
2248
|
-
const paramDeprecated = deprecated ||
|
|
2255
|
+
const paramDescription = description || paramSchema.description;
|
|
2256
|
+
const paramDeprecated = !!(deprecated || paramSchema.deprecated);
|
|
2249
2257
|
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2250
|
-
|
|
2251
|
-
|
|
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)) {
|
|
2252
2262
|
schema.required.push(name);
|
|
2253
2263
|
}
|
|
2254
2264
|
}
|
package/index.mjs
CHANGED
|
@@ -2088,9 +2088,17 @@ ${scopes.map(([key, value]) => `- \`${key}\` - ${value}`).join('\n')}`;
|
|
|
2088
2088
|
return description;
|
|
2089
2089
|
}
|
|
2090
2090
|
|
|
2091
|
-
const RouterTypeContext = React.createContext(
|
|
2091
|
+
const RouterTypeContext = React.createContext(null);
|
|
2092
|
+
const useRouterType = () => {
|
|
2093
|
+
return React.useContext(RouterTypeContext);
|
|
2094
|
+
};
|
|
2092
2095
|
|
|
2093
|
-
const LinkHeading = React.memo(function LinkHeading(
|
|
2096
|
+
const LinkHeading = React.memo(function LinkHeading(props) {
|
|
2097
|
+
const isUsingRouter = !!useRouterType();
|
|
2098
|
+
const Comp = isUsingRouter ? CustomLinkHeading : LinkHeading$1;
|
|
2099
|
+
return React.createElement(Comp, Object.assign({}, props));
|
|
2100
|
+
});
|
|
2101
|
+
const CustomLinkHeading = React.memo(function LinkHeading(_a) {
|
|
2094
2102
|
var { id: _id } = _a, props = __rest(_a, ["id"]);
|
|
2095
2103
|
const { pathname } = useLocation();
|
|
2096
2104
|
const routerKind = React.useContext(RouterTypeContext);
|
|
@@ -2172,7 +2180,6 @@ const Parameters = ({ parameters, parameterType }) => {
|
|
|
2172
2180
|
};
|
|
2173
2181
|
Parameters.displayName = 'HttpOperation.Parameters';
|
|
2174
2182
|
const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
2175
|
-
var _a, _b, _c;
|
|
2176
2183
|
if (!parameters || !parameters.length)
|
|
2177
2184
|
return null;
|
|
2178
2185
|
const schema = {
|
|
@@ -2182,19 +2189,22 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
|
|
|
2182
2189
|
const sortedParams = sortBy(parameters, ['required', 'name']);
|
|
2183
2190
|
for (const p of sortedParams) {
|
|
2184
2191
|
const { name, description, required, deprecated, examples, style } = p;
|
|
2192
|
+
const paramSchema = isPlainObject$1(p.schema) ? p.schema : {};
|
|
2185
2193
|
const paramExamples = (examples === null || examples === void 0 ? void 0 : examples.map(example => {
|
|
2186
2194
|
if (isNodeExample(example)) {
|
|
2187
2195
|
return example.value;
|
|
2188
2196
|
}
|
|
2189
2197
|
return example.externalValue;
|
|
2190
2198
|
})) || [];
|
|
2191
|
-
const schemaExamples =
|
|
2199
|
+
const schemaExamples = paramSchema.examples;
|
|
2192
2200
|
const schemaExamplesArray = Array.isArray(schemaExamples) ? schemaExamples : [];
|
|
2193
|
-
const paramDescription = description ||
|
|
2194
|
-
const paramDeprecated = deprecated ||
|
|
2201
|
+
const paramDescription = description || paramSchema.description;
|
|
2202
|
+
const paramDeprecated = !!(deprecated || paramSchema.deprecated);
|
|
2195
2203
|
const paramStyle = style && defaultStyle[parameterType] !== style ? readableStyles[style] || style : undefined;
|
|
2196
|
-
|
|
2197
|
-
|
|
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)) {
|
|
2198
2208
|
schema.required.push(name);
|
|
2199
2209
|
}
|
|
2200
2210
|
}
|