@stoplight/elements-core 7.7.13 → 7.7.15
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -28,6 +28,6 @@ export declare function mapSchemaPropertiesToParameters(properties: {
|
|
|
28
28
|
schema: import("json-schema").JSONSchema7 | undefined;
|
|
29
29
|
examples: {
|
|
30
30
|
key: string;
|
|
31
|
-
value:
|
|
31
|
+
value: any;
|
|
32
32
|
}[] | undefined;
|
|
33
33
|
}[];
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest, __awaiter } from 'tslib';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useContext, useMemo } from 'react';
|
|
4
4
|
import { convertToJsonSchema } from '@stoplight/http-spec/oas';
|
|
@@ -256,12 +256,22 @@ const MarkdownViewer = (props) => {
|
|
|
256
256
|
};
|
|
257
257
|
MarkdownViewer.displayName = 'MarkdownViewer';
|
|
258
258
|
|
|
259
|
-
const
|
|
259
|
+
const ArticleComponentForHashRouter = React.memo(({ data }) => {
|
|
260
260
|
const { pathname } = useLocation();
|
|
261
|
-
const
|
|
262
|
-
|
|
261
|
+
const basePath = `#${pathname.split('#')[0]}`;
|
|
262
|
+
return React.createElement(BaseArticleComponent, { data: data, tocBasePath: basePath });
|
|
263
|
+
});
|
|
264
|
+
const BaseArticleComponent = React.memo((_a) => {
|
|
265
|
+
var { data } = _a, props = __rest(_a, ["data"]);
|
|
263
266
|
return (React.createElement(Box, { className: "sl-elements-article" },
|
|
264
|
-
React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true,
|
|
267
|
+
React.createElement(MarkdownViewer, Object.assign({ className: "sl-elements-article-content", markdown: data, includeToc: true }, props))));
|
|
268
|
+
});
|
|
269
|
+
const ArticleComponent = React.memo(({ data }) => {
|
|
270
|
+
const routerKind = useRouterType();
|
|
271
|
+
if (routerKind === 'hash') {
|
|
272
|
+
return React.createElement(ArticleComponentForHashRouter, { data: data });
|
|
273
|
+
}
|
|
274
|
+
return React.createElement(BaseArticleComponent, { data: data });
|
|
265
275
|
});
|
|
266
276
|
const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
267
277
|
|
|
@@ -1121,7 +1131,9 @@ const initialParameterValues = params => {
|
|
|
1121
1131
|
return mapValues(paramsByName, param => getInitialValueForParameter(param));
|
|
1122
1132
|
};
|
|
1123
1133
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1124
|
-
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples
|
|
1134
|
+
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples && schema.examples[0]
|
|
1135
|
+
? [{ key: 'example', value: schema.examples[0] }]
|
|
1136
|
+
: undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
|
|
1125
1137
|
}
|
|
1126
1138
|
|
|
1127
1139
|
const ParameterEditor = ({ parameter, value, onChange, isOptional, onChangeOptional, canChangeOptional, validate, }) => {
|
package/index.js
CHANGED
|
@@ -309,12 +309,22 @@ const MarkdownViewer = (props) => {
|
|
|
309
309
|
};
|
|
310
310
|
MarkdownViewer.displayName = 'MarkdownViewer';
|
|
311
311
|
|
|
312
|
-
const
|
|
312
|
+
const ArticleComponentForHashRouter = React__namespace.memo(({ data }) => {
|
|
313
313
|
const { pathname } = reactRouterDom.useLocation();
|
|
314
|
-
const
|
|
315
|
-
|
|
314
|
+
const basePath = `#${pathname.split('#')[0]}`;
|
|
315
|
+
return React__namespace.createElement(BaseArticleComponent, { data: data, tocBasePath: basePath });
|
|
316
|
+
});
|
|
317
|
+
const BaseArticleComponent = React__namespace.memo((_a) => {
|
|
318
|
+
var { data } = _a, props = tslib.__rest(_a, ["data"]);
|
|
316
319
|
return (React__namespace.createElement(mosaic.Box, { className: "sl-elements-article" },
|
|
317
|
-
React__namespace.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true,
|
|
320
|
+
React__namespace.createElement(MarkdownViewer, Object.assign({ className: "sl-elements-article-content", markdown: data, includeToc: true }, props))));
|
|
321
|
+
});
|
|
322
|
+
const ArticleComponent = React__namespace.memo(({ data }) => {
|
|
323
|
+
const routerKind = useRouterType();
|
|
324
|
+
if (routerKind === 'hash') {
|
|
325
|
+
return React__namespace.createElement(ArticleComponentForHashRouter, { data: data });
|
|
326
|
+
}
|
|
327
|
+
return React__namespace.createElement(BaseArticleComponent, { data: data });
|
|
318
328
|
});
|
|
319
329
|
const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
320
330
|
|
|
@@ -1174,7 +1184,9 @@ const initialParameterValues = params => {
|
|
|
1174
1184
|
return mapValues__default["default"](paramsByName, param => getInitialValueForParameter(param));
|
|
1175
1185
|
};
|
|
1176
1186
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1177
|
-
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples
|
|
1187
|
+
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples && schema.examples[0]
|
|
1188
|
+
? [{ key: 'example', value: schema.examples[0] }]
|
|
1189
|
+
: undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
|
|
1178
1190
|
}
|
|
1179
1191
|
|
|
1180
1192
|
const ParameterEditor = ({ parameter, value, onChange, isOptional, onChangeOptional, canChangeOptional, validate, }) => {
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest, __awaiter } from 'tslib';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useContext, useMemo } from 'react';
|
|
4
4
|
import { convertToJsonSchema } from '@stoplight/http-spec/oas';
|
|
@@ -256,12 +256,22 @@ const MarkdownViewer = (props) => {
|
|
|
256
256
|
};
|
|
257
257
|
MarkdownViewer.displayName = 'MarkdownViewer';
|
|
258
258
|
|
|
259
|
-
const
|
|
259
|
+
const ArticleComponentForHashRouter = React.memo(({ data }) => {
|
|
260
260
|
const { pathname } = useLocation();
|
|
261
|
-
const
|
|
262
|
-
|
|
261
|
+
const basePath = `#${pathname.split('#')[0]}`;
|
|
262
|
+
return React.createElement(BaseArticleComponent, { data: data, tocBasePath: basePath });
|
|
263
|
+
});
|
|
264
|
+
const BaseArticleComponent = React.memo((_a) => {
|
|
265
|
+
var { data } = _a, props = __rest(_a, ["data"]);
|
|
263
266
|
return (React.createElement(Box, { className: "sl-elements-article" },
|
|
264
|
-
React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true,
|
|
267
|
+
React.createElement(MarkdownViewer, Object.assign({ className: "sl-elements-article-content", markdown: data, includeToc: true }, props))));
|
|
268
|
+
});
|
|
269
|
+
const ArticleComponent = React.memo(({ data }) => {
|
|
270
|
+
const routerKind = useRouterType();
|
|
271
|
+
if (routerKind === 'hash') {
|
|
272
|
+
return React.createElement(ArticleComponentForHashRouter, { data: data });
|
|
273
|
+
}
|
|
274
|
+
return React.createElement(BaseArticleComponent, { data: data });
|
|
265
275
|
});
|
|
266
276
|
const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
267
277
|
|
|
@@ -1121,7 +1131,9 @@ const initialParameterValues = params => {
|
|
|
1121
1131
|
return mapValues(paramsByName, param => getInitialValueForParameter(param));
|
|
1122
1132
|
};
|
|
1123
1133
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1124
|
-
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples
|
|
1134
|
+
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples && schema.examples[0]
|
|
1135
|
+
? [{ key: 'example', value: schema.examples[0] }]
|
|
1136
|
+
: undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
|
|
1125
1137
|
}
|
|
1126
1138
|
|
|
1127
1139
|
const ParameterEditor = ({ parameter, value, onChange, isOptional, onChangeOptional, canChangeOptional, validate, }) => {
|