@stoplight/elements 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/index.esm.js +21 -18
- package/index.js +21 -18
- package/index.mjs +21 -18
- package/package.json +3 -3
- package/styles.min.css +1 -1
- package/web-components.min.js +1 -1
package/index.esm.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { isHttpOperation, isHttpService, Logo, TableOfContents, PoweredByLink, SidebarLayout, ParsedDocs, HttpMethodColors, DeprecatedBadge, TryItWithRequestSamples, Docs, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
2
2
|
import { Flex, Heading, Box, Icon, Tabs, TabList, Tab, TabPanels, TabPanel } from '@stoplight/mosaic';
|
|
3
|
-
import {
|
|
3
|
+
import { defaults, isObject, get, last, flow } from 'lodash';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useQuery } from 'react-query';
|
|
6
6
|
import { NodeType } from '@stoplight/types';
|
|
7
7
|
import { useLocation, Redirect, Link } from 'react-router-dom';
|
|
8
|
-
import { defaults, isObject, get, last } from 'lodash';
|
|
9
8
|
import cn from 'classnames';
|
|
10
9
|
import { safeStringify } from '@stoplight/yaml';
|
|
11
10
|
import { saveAs } from 'file-saver';
|
|
@@ -88,21 +87,24 @@ const computeAPITree = (serviceNode, config = {}) => {
|
|
|
88
87
|
});
|
|
89
88
|
});
|
|
90
89
|
groups.forEach(group => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
meta: operationNode.data.method,
|
|
103
|
-
};
|
|
104
|
-
}),
|
|
90
|
+
const items = group.items.flatMap(operationNode => {
|
|
91
|
+
if (mergedConfig.hideInternal && operationNode.data.internal) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
id: operationNode.uri,
|
|
96
|
+
slug: operationNode.uri,
|
|
97
|
+
title: operationNode.name,
|
|
98
|
+
type: operationNode.type,
|
|
99
|
+
meta: operationNode.data.method,
|
|
100
|
+
};
|
|
105
101
|
});
|
|
102
|
+
if (items.length > 0) {
|
|
103
|
+
tree.push({
|
|
104
|
+
title: group.title,
|
|
105
|
+
items,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
106
108
|
});
|
|
107
109
|
}
|
|
108
110
|
let schemaNodes = serviceNode.children.filter(node => node.type === NodeType.Model);
|
|
@@ -157,6 +159,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
157
159
|
const { pathname } = location;
|
|
158
160
|
const isRootPath = !pathname || pathname === '/';
|
|
159
161
|
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
162
|
+
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
|
160
163
|
if (!node) {
|
|
161
164
|
const firstSlug = findFirstNodeSlug(tree);
|
|
162
165
|
if (firstSlug) {
|
|
@@ -178,7 +181,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
178
181
|
React.createElement(Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
|
|
179
182
|
React.createElement(TableOfContents, { tree: tree, activeId: pathname, Link: Link, onLinkClick: handleTocClick })),
|
|
180
183
|
React.createElement(PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
|
|
181
|
-
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions:
|
|
184
|
+
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, allowRouting: true, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
182
185
|
};
|
|
183
186
|
|
|
184
187
|
const itemMatchesHash = (hash, item) => {
|
|
@@ -510,6 +513,6 @@ const APIImpl = props => {
|
|
|
510
513
|
}
|
|
511
514
|
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
512
515
|
};
|
|
513
|
-
const API =
|
|
516
|
+
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
514
517
|
|
|
515
518
|
export { API };
|
package/index.js
CHANGED
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var elementsCore = require('@stoplight/elements-core');
|
|
6
6
|
var mosaic = require('@stoplight/mosaic');
|
|
7
|
-
var
|
|
7
|
+
var lodash = require('lodash');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var reactQuery = require('react-query');
|
|
10
10
|
var types = require('@stoplight/types');
|
|
11
11
|
var reactRouterDom = require('react-router-dom');
|
|
12
|
-
var lodash = require('lodash');
|
|
13
12
|
var cn = require('classnames');
|
|
14
13
|
var yaml = require('@stoplight/yaml');
|
|
15
14
|
var fileSaver = require('file-saver');
|
|
@@ -115,21 +114,24 @@ const computeAPITree = (serviceNode, config = {}) => {
|
|
|
115
114
|
});
|
|
116
115
|
});
|
|
117
116
|
groups.forEach(group => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
meta: operationNode.data.method,
|
|
130
|
-
};
|
|
131
|
-
}),
|
|
117
|
+
const items = group.items.flatMap(operationNode => {
|
|
118
|
+
if (mergedConfig.hideInternal && operationNode.data.internal) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
id: operationNode.uri,
|
|
123
|
+
slug: operationNode.uri,
|
|
124
|
+
title: operationNode.name,
|
|
125
|
+
type: operationNode.type,
|
|
126
|
+
meta: operationNode.data.method,
|
|
127
|
+
};
|
|
132
128
|
});
|
|
129
|
+
if (items.length > 0) {
|
|
130
|
+
tree.push({
|
|
131
|
+
title: group.title,
|
|
132
|
+
items,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
133
135
|
});
|
|
134
136
|
}
|
|
135
137
|
let schemaNodes = serviceNode.children.filter(node => node.type === types.NodeType.Model);
|
|
@@ -184,6 +186,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
184
186
|
const { pathname } = location;
|
|
185
187
|
const isRootPath = !pathname || pathname === '/';
|
|
186
188
|
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
189
|
+
const layoutOptions = React__namespace.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== types.NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
|
187
190
|
if (!node) {
|
|
188
191
|
const firstSlug = findFirstNodeSlug(tree);
|
|
189
192
|
if (firstSlug) {
|
|
@@ -205,7 +208,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
205
208
|
React__namespace.createElement(mosaic.Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
|
|
206
209
|
React__namespace.createElement(elementsCore.TableOfContents, { tree: tree, activeId: pathname, Link: reactRouterDom.Link, onLinkClick: handleTocClick })),
|
|
207
210
|
React__namespace.createElement(elementsCore.PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
|
|
208
|
-
return (React__namespace.createElement(elementsCore.SidebarLayout, { ref: container, sidebar: sidebar }, node && (React__namespace.createElement(elementsCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions:
|
|
211
|
+
return (React__namespace.createElement(elementsCore.SidebarLayout, { ref: container, sidebar: sidebar }, node && (React__namespace.createElement(elementsCore.ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, allowRouting: true, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
209
212
|
};
|
|
210
213
|
|
|
211
214
|
const itemMatchesHash = (hash, item) => {
|
|
@@ -537,6 +540,6 @@ const APIImpl = props => {
|
|
|
537
540
|
}
|
|
538
541
|
return (React__namespace.createElement(elementsCore.InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React__namespace.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React__namespace.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
539
542
|
};
|
|
540
|
-
const API =
|
|
543
|
+
const API = lodash.flow(elementsCore.withRouter, elementsCore.withStyles, elementsCore.withPersistenceBoundary, elementsCore.withMosaicProvider, elementsCore.withQueryClientProvider)(APIImpl);
|
|
541
544
|
|
|
542
545
|
exports.API = API;
|
package/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { isHttpOperation, isHttpService, Logo, TableOfContents, PoweredByLink, SidebarLayout, ParsedDocs, HttpMethodColors, DeprecatedBadge, TryItWithRequestSamples, Docs, withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider, useParsedValue, useBundleRefsIntoDocument, NonIdealState, InlineRefResolverProvider } from '@stoplight/elements-core';
|
|
2
2
|
import { Flex, Heading, Box, Icon, Tabs, TabList, Tab, TabPanels, TabPanel } from '@stoplight/mosaic';
|
|
3
|
-
import {
|
|
3
|
+
import { defaults, isObject, get, last, flow } from 'lodash';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useQuery } from 'react-query';
|
|
6
6
|
import { NodeType } from '@stoplight/types';
|
|
7
7
|
import { useLocation, Redirect, Link } from 'react-router-dom';
|
|
8
|
-
import { defaults, isObject, get, last } from 'lodash';
|
|
9
8
|
import cn from 'classnames';
|
|
10
9
|
import { safeStringify } from '@stoplight/yaml';
|
|
11
10
|
import { saveAs } from 'file-saver';
|
|
@@ -88,21 +87,24 @@ const computeAPITree = (serviceNode, config = {}) => {
|
|
|
88
87
|
});
|
|
89
88
|
});
|
|
90
89
|
groups.forEach(group => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
meta: operationNode.data.method,
|
|
103
|
-
};
|
|
104
|
-
}),
|
|
90
|
+
const items = group.items.flatMap(operationNode => {
|
|
91
|
+
if (mergedConfig.hideInternal && operationNode.data.internal) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
id: operationNode.uri,
|
|
96
|
+
slug: operationNode.uri,
|
|
97
|
+
title: operationNode.name,
|
|
98
|
+
type: operationNode.type,
|
|
99
|
+
meta: operationNode.data.method,
|
|
100
|
+
};
|
|
105
101
|
});
|
|
102
|
+
if (items.length > 0) {
|
|
103
|
+
tree.push({
|
|
104
|
+
title: group.title,
|
|
105
|
+
items,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
106
108
|
});
|
|
107
109
|
}
|
|
108
110
|
let schemaNodes = serviceNode.children.filter(node => node.type === NodeType.Model);
|
|
@@ -157,6 +159,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
157
159
|
const { pathname } = location;
|
|
158
160
|
const isRootPath = !pathname || pathname === '/';
|
|
159
161
|
const node = isRootPath ? serviceNode : serviceNode.children.find(child => child.uri === pathname);
|
|
162
|
+
const layoutOptions = React.useMemo(() => ({ hideTryIt: hideTryIt, hideExport: hideExport || (node === null || node === void 0 ? void 0 : node.type) !== NodeType.HttpService }), [hideTryIt, hideExport, node]);
|
|
160
163
|
if (!node) {
|
|
161
164
|
const firstSlug = findFirstNodeSlug(tree);
|
|
162
165
|
if (firstSlug) {
|
|
@@ -178,7 +181,7 @@ const APIWithSidebarLayout = ({ serviceNode, logo, hideTryIt, hideSchemas, hideI
|
|
|
178
181
|
React.createElement(Flex, { flexGrow: true, flexShrink: true, overflowY: "auto", direction: "col" },
|
|
179
182
|
React.createElement(TableOfContents, { tree: tree, activeId: pathname, Link: Link, onLinkClick: handleTocClick })),
|
|
180
183
|
React.createElement(PoweredByLink, { source: serviceNode.name, pathname: pathname, packageType: "elements" })));
|
|
181
|
-
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions:
|
|
184
|
+
return (React.createElement(SidebarLayout, { ref: container, sidebar: sidebar }, node && (React.createElement(ParsedDocs, { key: pathname, uri: pathname, node: node, nodeTitle: node.name, layoutOptions: layoutOptions, location: location, allowRouting: true, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
182
185
|
};
|
|
183
186
|
|
|
184
187
|
const itemMatchesHash = (hash, item) => {
|
|
@@ -510,6 +513,6 @@ const APIImpl = props => {
|
|
|
510
513
|
}
|
|
511
514
|
return (React.createElement(InlineRefResolverProvider, { document: parsedDocument }, layout === 'stacked' ? (React.createElement(APIWithStackedLayout, { serviceNode: serviceNode, hideTryIt: hideTryIt, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy })) : (React.createElement(APIWithSidebarLayout, { logo: logo, serviceNode: serviceNode, hideTryIt: hideTryIt, hideSchemas: hideSchemas, hideInternal: hideInternal, hideExport: hideExport, exportProps: exportProps, tryItCredentialsPolicy: tryItCredentialsPolicy, tryItCorsProxy: tryItCorsProxy }))));
|
|
512
515
|
};
|
|
513
|
-
const API =
|
|
516
|
+
const API = flow(withRouter, withStyles, withPersistenceBoundary, withMosaicProvider, withQueryClientProvider)(APIImpl);
|
|
514
517
|
|
|
515
518
|
export { API };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.11",
|
|
4
4
|
"description": "UI components for composing beautiful developer documentation.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "./index.js",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@fortawesome/fontawesome-svg-core": "^1.2.31",
|
|
30
30
|
"@fortawesome/free-solid-svg-icons": "^5.14.0",
|
|
31
31
|
"@fortawesome/react-fontawesome": "^0.1.11",
|
|
32
|
-
"@stoplight/elements-core": "~7.3.
|
|
32
|
+
"@stoplight/elements-core": "~7.3.10",
|
|
33
33
|
"@stoplight/http-spec": "^4.2.2",
|
|
34
34
|
"@stoplight/json": "^3.10.0",
|
|
35
|
-
"@stoplight/mosaic": "^1.
|
|
35
|
+
"@stoplight/mosaic": "^1.12.4",
|
|
36
36
|
"@stoplight/types": "^12.0.0",
|
|
37
37
|
"classnames": "^2.2.6",
|
|
38
38
|
"file-saver": "^2.0.5",
|