@stoplight/elements-core 7.3.7 → 7.3.11
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/Article/index.d.ts +1 -2
- package/components/Docs/HttpOperation/HttpOperation.d.ts +1 -2
- package/components/Docs/HttpService/HttpService.d.ts +1 -2
- package/components/Docs/Model/Model.d.ts +1 -2
- package/components/MosaicTableOfContents/types.d.ts +0 -1
- package/context/InlineRefResolver.d.ts +3 -4
- package/context/InlineRefResolver.spec.d.ts +1 -0
- package/hoc/withMosaicProvider.spec.d.ts +1 -0
- package/hoc/withQueryClientProvider.spec.d.ts +1 -0
- package/index.d.ts +1 -0
- package/index.esm.js +41 -23
- package/index.js +87 -67
- package/index.mjs +41 -23
- package/package.json +6 -7
- package/styles.min.css +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MDAST } from '@stoplight/markdown';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
declare type ArticleProps = DocsComponentProps<string | MDAST.Root>;
|
|
5
|
-
export declare const Article:
|
|
4
|
+
export declare const Article: import("react").FunctionComponent<ArticleProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
6
5
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IHttpOperation } from '@stoplight/types';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
export declare type HttpOperationProps = DocsComponentProps<IHttpOperation>;
|
|
5
|
-
export declare const HttpOperation:
|
|
4
|
+
export declare const HttpOperation: import("react").FunctionComponent<HttpOperationProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IHttpService } from '@stoplight/types';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
export declare type HttpServiceProps = DocsComponentProps<Partial<IHttpService>>;
|
|
5
|
-
export declare const HttpService:
|
|
4
|
+
export declare const HttpService: import("react").FunctionComponent<HttpServiceProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
|
2
|
-
import * as React from 'react';
|
|
3
2
|
import { DocsComponentProps } from '..';
|
|
4
3
|
export declare type ModelProps = DocsComponentProps<JSONSchema7>;
|
|
5
|
-
export declare const Model:
|
|
4
|
+
export declare const Model: import("react").FunctionComponent<ModelProps & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
|
|
@@ -10,7 +10,6 @@ export declare type TableOfContentsProps = {
|
|
|
10
10
|
export declare type CustomLinkComponent = React.ComponentType<{
|
|
11
11
|
to: string;
|
|
12
12
|
className?: string;
|
|
13
|
-
hash?: string;
|
|
14
13
|
children: React.ReactNode;
|
|
15
14
|
}>;
|
|
16
15
|
export declare type TableOfContentsItem = TableOfContentsDivider | TableOfContentsGroupItem;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ReferenceResolver } from '../utils/ref-resolving/ReferenceResolver';
|
|
3
3
|
declare type InlineRefResolverProviderProps = {
|
|
4
|
-
document
|
|
5
|
-
|
|
6
|
-
resolver: ReferenceResolver;
|
|
4
|
+
document?: unknown;
|
|
5
|
+
resolver?: ReferenceResolver;
|
|
7
6
|
};
|
|
8
7
|
export declare const InlineRefResolverProvider: React.FC<InlineRefResolverProviderProps>;
|
|
9
8
|
export declare const useInlineRefResolver: () => ReferenceResolver | undefined;
|
|
10
|
-
export declare const useDocument: () =>
|
|
9
|
+
export declare const useDocument: () => object | undefined;
|
|
11
10
|
export declare const useResolvedObject: (currentObject: object) => object;
|
|
12
11
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { ExportButton, ExportButtonProps } from './components/Docs/HttpService/E
|
|
|
4
4
|
export { SidebarLayout } from './components/Layout/SidebarLayout';
|
|
5
5
|
export { Logo } from './components/Logo';
|
|
6
6
|
export { CustomComponentMapping, DefaultSMDComponents, MarkdownComponentsProvider, } from './components/MarkdownViewer/CustomComponents/Provider';
|
|
7
|
+
export { ReactRouterMarkdownLink } from './components/MarkdownViewer/CustomComponents/ReactRouterLink';
|
|
7
8
|
export { TableOfContents } from './components/MosaicTableOfContents';
|
|
8
9
|
export { CustomLinkComponent, TableOfContentsItem, TableOfContentsNode, TableOfContentsNodeGroup, } from './components/MosaicTableOfContents/types';
|
|
9
10
|
export { findFirstNode } from './components/MosaicTableOfContents/utils';
|
package/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { __rest, __awaiter } from 'tslib';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useContext, useMemo } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { resolveInlineRef, isPlainObject as isPlainObject$1, safeParse, safeStringify } from '@stoplight/json';
|
|
5
|
+
import _, { isObject, isPlainObject, isArray, throttle, filter, capitalize, flatten, curry, map, omit, pickBy, isString, compact, uniq, uniqBy, orderBy, sortBy, get, omitBy, isEmpty, keys, entries, mapValues, isEqual } from 'lodash';
|
|
6
6
|
import { parse } from '@stoplight/markdown';
|
|
7
7
|
import { NodeType, HttpParamStyles } from '@stoplight/types';
|
|
8
8
|
import { parse as parse$1 } from '@stoplight/yaml';
|
|
9
|
-
import { isArray as isArray$1, Flex, Box, Popover, Button, Panel, CopyButton, Menu, Text, Input, Icon, Select, Image, Link, useThemeIsDark, Tooltip, VStack, InvertTheme, Badge, Tabs, TabList, Tab, TabPanels, TabPanel, Heading as Heading$1, HStack, useClipboard, Provider as Provider$1 } from '@stoplight/mosaic';
|
|
9
|
+
import { isArray as isArray$1, Flex, Box, Popover, Button, Panel, CopyButton, Menu, Text, Input, Icon, Select, Image, Link, useThemeIsDark, Tooltip, VStack, InvertTheme, Badge, Tabs, TabList, Tab, TabPanels, TabPanel, Heading as Heading$1, HStack, useClipboard, useMosaicContext, Provider as Provider$1 } from '@stoplight/mosaic';
|
|
10
10
|
import { withErrorBoundary } from '@stoplight/react-error-boundary';
|
|
11
11
|
import { MarkdownViewer as MarkdownViewer$1, DefaultSMDComponents, MarkdownViewerProvider } from '@stoplight/markdown-viewer';
|
|
12
12
|
export { DefaultSMDComponents } from '@stoplight/markdown-viewer';
|
|
@@ -19,14 +19,13 @@ import URI from 'urijs';
|
|
|
19
19
|
import { CodeViewer } from '@stoplight/mosaic-code-viewer';
|
|
20
20
|
import HTTPSnippet from 'httpsnippet';
|
|
21
21
|
import { nanoid } from 'nanoid';
|
|
22
|
-
import { pipe, keyBy, mapValues } from 'lodash/fp';
|
|
23
22
|
import { CodeEditor } from '@stoplight/mosaic-code-editor';
|
|
24
23
|
import * as Sampler from '@stoplight/json-schema-sampler';
|
|
25
24
|
import formatXml from 'xml-formatter';
|
|
26
25
|
import { Link as Link$1, useLocation, BrowserRouter, MemoryRouter, HashRouter, Route } from 'react-router-dom';
|
|
27
26
|
import { JsonSchemaViewer, Validations } from '@stoplight/json-schema-viewer';
|
|
28
|
-
import { QueryClient, QueryClientProvider } from 'react-query';
|
|
29
27
|
import { HashLink } from 'react-router-hash-link';
|
|
28
|
+
import { QueryClient, useQueryClient, QueryClientProvider } from 'react-query';
|
|
30
29
|
import $RefParser from '@stoplight/json-schema-ref-parser';
|
|
31
30
|
import * as PropTypes from 'prop-types';
|
|
32
31
|
import * as ReactDOM from 'react-dom';
|
|
@@ -95,10 +94,10 @@ const InlineRefResolverContext = React.createContext(undefined);
|
|
|
95
94
|
InlineRefResolverContext.displayName = 'InlineRefResolverContext';
|
|
96
95
|
const DocumentContext = React.createContext(undefined);
|
|
97
96
|
DocumentContext.displayName = 'DocumentContext';
|
|
98
|
-
const InlineRefResolverProvider = (
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
return (React.createElement(InlineRefResolverContext.Provider, { value:
|
|
97
|
+
const InlineRefResolverProvider = ({ children, document: maybeDocument, resolver, }) => {
|
|
98
|
+
const document = isPlainObject$1(maybeDocument) ? maybeDocument : undefined;
|
|
99
|
+
const computedResolver = React.useMemo(() => resolver || (document !== undefined ? defaultResolver(document) : undefined), [document, resolver]);
|
|
100
|
+
return (React.createElement(InlineRefResolverContext.Provider, { value: computedResolver },
|
|
102
101
|
React.createElement(DocumentContext.Provider, { value: document }, children)));
|
|
103
102
|
};
|
|
104
103
|
const useInlineRefResolver = () => useContext(InlineRefResolverContext);
|
|
@@ -106,7 +105,7 @@ const useDocument = () => useContext(DocumentContext);
|
|
|
106
105
|
const useResolvedObject = (currentObject) => {
|
|
107
106
|
const document = useDocument();
|
|
108
107
|
const resolver = useInlineRefResolver();
|
|
109
|
-
return createResolvedObject(currentObject, { contextObject: document, resolver });
|
|
108
|
+
return React.useMemo(() => createResolvedObject(currentObject, { contextObject: document, resolver }), [currentObject, document, resolver]);
|
|
110
109
|
};
|
|
111
110
|
|
|
112
111
|
function isSMDASTRoot(maybeAst) {
|
|
@@ -1006,7 +1005,12 @@ const getInitialValueForParameter = (parameter) => {
|
|
|
1006
1005
|
return '';
|
|
1007
1006
|
return getValueForParameter(parameter);
|
|
1008
1007
|
};
|
|
1009
|
-
const initialParameterValues =
|
|
1008
|
+
const initialParameterValues = params => {
|
|
1009
|
+
return _.chain(params)
|
|
1010
|
+
.keyBy((param) => param.name)
|
|
1011
|
+
.mapValues(param => getInitialValueForParameter(param))
|
|
1012
|
+
.value();
|
|
1013
|
+
};
|
|
1010
1014
|
function mapSchemaPropertiesToParameters(properties, required) {
|
|
1011
1015
|
return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples ? [{ key: 'example', value: schema.examples }] : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
|
|
1012
1016
|
}
|
|
@@ -2334,6 +2338,15 @@ const MarkdownComponentsProvider = ({ value, children }) => {
|
|
|
2334
2338
|
return React.createElement(MarkdownViewerProvider, { components: Object.assign({ code: CodeComponent }, value) }, children);
|
|
2335
2339
|
};
|
|
2336
2340
|
|
|
2341
|
+
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2342
|
+
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2343
|
+
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2344
|
+
if (isExternal) {
|
|
2345
|
+
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2346
|
+
}
|
|
2347
|
+
return (React__default.createElement(HashLink, { to: href, title: title }, children));
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2337
2350
|
const NODE_TYPE_TITLE_ICON = {
|
|
2338
2351
|
http_service: faCloud,
|
|
2339
2352
|
};
|
|
@@ -2525,6 +2538,14 @@ function withPersistenceBoundary(WrappedComponent) {
|
|
|
2525
2538
|
|
|
2526
2539
|
function withMosaicProvider(WrappedComponent) {
|
|
2527
2540
|
const WithMosaicProvider = (props) => {
|
|
2541
|
+
try {
|
|
2542
|
+
const mosaicContext = useMosaicContext();
|
|
2543
|
+
if (mosaicContext === null || mosaicContext === void 0 ? void 0 : mosaicContext.providerId) {
|
|
2544
|
+
return React__default.createElement(WrappedComponent, Object.assign({}, props));
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
catch (_a) {
|
|
2548
|
+
}
|
|
2528
2549
|
return (React__default.createElement(Provider$1, { style: { height: '100%' } },
|
|
2529
2550
|
React__default.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2530
2551
|
};
|
|
@@ -2542,6 +2563,12 @@ const queryClient = new QueryClient({
|
|
|
2542
2563
|
});
|
|
2543
2564
|
function withQueryClientProvider(WrappedComponent) {
|
|
2544
2565
|
const WithQueryClientProvider = (props) => {
|
|
2566
|
+
try {
|
|
2567
|
+
useQueryClient();
|
|
2568
|
+
return React__default.createElement(WrappedComponent, Object.assign({}, props));
|
|
2569
|
+
}
|
|
2570
|
+
catch (_a) {
|
|
2571
|
+
}
|
|
2545
2572
|
return (React__default.createElement(QueryClientProvider, { client: queryClient },
|
|
2546
2573
|
React__default.createElement(WrappedComponent, Object.assign({}, props))));
|
|
2547
2574
|
};
|
|
@@ -2549,15 +2576,6 @@ function withQueryClientProvider(WrappedComponent) {
|
|
|
2549
2576
|
return WithQueryClientProvider;
|
|
2550
2577
|
}
|
|
2551
2578
|
|
|
2552
|
-
const externalRegex = new RegExp('^(?:[a-z]+:)?//', 'i');
|
|
2553
|
-
const ReactRouterMarkdownLink = ({ title, href, children }) => {
|
|
2554
|
-
const isExternal = href !== undefined && externalRegex.test(href);
|
|
2555
|
-
if (isExternal) {
|
|
2556
|
-
return (React__default.createElement("a", { target: "_blank", rel: "noreferrer noopener", href: href, title: title }, children));
|
|
2557
|
-
}
|
|
2558
|
-
return (React__default.createElement(HashLink, { to: href, title: title }, children));
|
|
2559
|
-
};
|
|
2560
|
-
|
|
2561
2579
|
const RouterComponent = {
|
|
2562
2580
|
history: BrowserRouter,
|
|
2563
2581
|
memory: MemoryRouter,
|
|
@@ -2654,7 +2672,7 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2654
2672
|
constructor() {
|
|
2655
2673
|
super();
|
|
2656
2674
|
this._props = {};
|
|
2657
|
-
Object.defineProperties(this, mapValues
|
|
2675
|
+
Object.defineProperties(this, mapValues(propDescriptors, (_, key) => ({
|
|
2658
2676
|
get: () => {
|
|
2659
2677
|
return this._props[key];
|
|
2660
2678
|
},
|
|
@@ -2741,11 +2759,11 @@ const createElementClass = (Component, propDescriptors) => {
|
|
|
2741
2759
|
}
|
|
2742
2760
|
_renderComponent() {
|
|
2743
2761
|
if (this._mountPoint) {
|
|
2744
|
-
const props = mapValues
|
|
2762
|
+
const props = mapValues(propDescriptors, (descriptor, key) => { var _a; return (_a = this._props[key]) !== null && _a !== void 0 ? _a : descriptor.defaultValue; });
|
|
2745
2763
|
ReactDOM.render(React.createElement(Component, props), this._mountPoint);
|
|
2746
2764
|
}
|
|
2747
2765
|
}
|
|
2748
2766
|
};
|
|
2749
2767
|
};
|
|
2750
2768
|
|
|
2751
|
-
export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, useBundleRefsIntoDocument, useParsedData, useParsedValue, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
|
|
2769
|
+
export { DeprecatedBadge, Docs, ExportButton, HttpMethodColors, InlineRefResolverProvider, Logo, MarkdownComponentsProvider, MockingProvider, NodeTypeColors, NodeTypeIconDefs, NodeTypePrettyName, NonIdealState, ParsedDocs, PersistenceContextProvider, PoweredByLink, ReactRouterMarkdownLink, SidebarLayout, Styled, TableOfContents, TryIt, TryItWithRequestSamples, createElementClass, createResolvedObject, findFirstNode, isHttpOperation, isHttpService, useBundleRefsIntoDocument, useParsedData, useParsedValue, useRouter, withMosaicProvider, withPersistenceBoundary, withQueryClientProvider, withRouter, withStyles };
|