@redocly/theme 0.9.0-beta.2 → 0.9.0-beta.4
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/lib/Button/Button.d.ts +1 -1
- package/lib/Button/Button.js +14 -2
- package/lib/Catalog/Filter.js +1 -3
- package/lib/Markdown/Admonition.d.ts +4 -1
- package/lib/Markdown/Admonition.js +2 -2
- package/lib/Markdown/CodeSample/CodeSample.d.ts +3 -1
- package/lib/Markdown/CodeSample/CodeSample.js +2 -2
- package/lib/Markdown/Heading.d.ts +3 -1
- package/lib/Markdown/Heading.js +6 -4
- package/lib/Markdown/Mermaid.d.ts +3 -1
- package/lib/Markdown/Mermaid.js +2 -2
- package/lib/Profile/Profile.js +1 -1
- package/lib/ReferenceDocs/ClearButton.d.ts +8 -0
- package/lib/ReferenceDocs/ClearButton.js +48 -0
- package/lib/ReferenceDocs/DevOnboardingTryItSecurity.d.ts +3 -0
- package/lib/ReferenceDocs/DevOnboardingTryItSecurity.js +158 -0
- package/lib/ReferenceDocs/Dropdown.d.ts +28 -0
- package/lib/ReferenceDocs/Dropdown.js +150 -0
- package/lib/ReferenceDocs/TryItSecurity.d.ts +7 -0
- package/lib/ReferenceDocs/TryItSecurity.js +15 -0
- package/lib/ReferenceDocs/index.d.ts +1 -0
- package/lib/ReferenceDocs/index.js +18 -0
- package/lib/Sidebar/FooterWrapper.d.ts +3 -0
- package/lib/Sidebar/FooterWrapper.js +15 -0
- package/lib/Sidebar/HeaderWrapper.d.ts +3 -0
- package/lib/Sidebar/HeaderWrapper.js +15 -0
- package/lib/Sidebar/MenuGroup.js +1 -1
- package/lib/Sidebar/SidebarLayout.d.ts +1 -1
- package/lib/Sidebar/SidebarLayout.js +5 -42
- package/lib/Sidebar/index.d.ts +2 -0
- package/lib/Sidebar/index.js +2 -0
- package/lib/SourceCode/SourceCode.d.ts +3 -2
- package/lib/SourceCode/SourceCode.js +5 -5
- package/lib/globalStyle.js +3 -1
- package/lib/icons/AnchorIcon/AnchorIcon.d.ts +7 -0
- package/lib/icons/AnchorIcon/AnchorIcon.js +23 -0
- package/lib/icons/AnchorIcon/index.d.ts +2 -0
- package/lib/icons/AnchorIcon/index.js +6 -0
- package/lib/icons/ArrowIcon/ArrowIcon.d.ts +1 -0
- package/lib/icons/ArrowIcon/ArrowIcon.js +1 -0
- package/lib/icons/index.d.ts +1 -0
- package/lib/icons/index.js +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/mocks/useGlobalData.d.ts +1 -0
- package/lib/mocks/useGlobalData.js +8 -0
- package/package.json +1 -1
- package/src/Button/Button.tsx +22 -5
- package/src/Catalog/Filter.tsx +1 -1
- package/src/Markdown/Admonition.tsx +13 -1
- package/src/Markdown/CodeSample/CodeSample.tsx +15 -2
- package/src/Markdown/Heading.tsx +12 -18
- package/src/Markdown/Mermaid.tsx +9 -1
- package/src/Profile/Profile.tsx +1 -1
- package/src/ReferenceDocs/ClearButton.tsx +30 -0
- package/src/ReferenceDocs/DevOnboardingTryItSecurity.tsx +161 -0
- package/src/ReferenceDocs/Dropdown.tsx +202 -0
- package/src/ReferenceDocs/TryItSecurity.tsx +17 -0
- package/src/ReferenceDocs/index.ts +1 -0
- package/src/Sidebar/FooterWrapper.tsx +9 -0
- package/src/Sidebar/HeaderWrapper.tsx +9 -0
- package/src/Sidebar/MenuGroup.tsx +4 -1
- package/src/Sidebar/SidebarLayout.tsx +2 -46
- package/src/Sidebar/index.ts +2 -0
- package/src/SourceCode/SourceCode.tsx +6 -0
- package/src/globalStyle.ts +3 -1
- package/src/icons/AnchorIcon/AnchorIcon.tsx +36 -0
- package/src/icons/AnchorIcon/index.ts +2 -0
- package/src/icons/ArrowIcon/ArrowIcon.tsx +2 -0
- package/src/icons/index.ts +1 -0
- package/src/index.ts +2 -0
- package/src/mocks/useGlobalData.tsx +3 -0
package/lib/Button/Button.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { FlattenSimpleInterpolation } from 'styled-components';
|
|
3
3
|
export type ButtonSize = 'small' | 'medium' | 'large' | 'xlarge' | string;
|
|
4
|
-
export type ButtonColor = 'primary' | 'secondary' | 'default' | string;
|
|
4
|
+
export type ButtonColor = 'primary' | 'secondary' | 'tertiary' | 'default' | string;
|
|
5
5
|
export type ButtonVariant = 'outlined' | 'contained';
|
|
6
6
|
export interface ButtonProps {
|
|
7
7
|
color?: ButtonColor;
|
package/lib/Button/Button.js
CHANGED
|
@@ -73,8 +73,8 @@ exports.baseButtonStyles = (0, styled_components_1.css) `
|
|
|
73
73
|
box-shadow: var(--button-active-box-shadow);
|
|
74
74
|
}
|
|
75
75
|
`;
|
|
76
|
-
const StyledButton = styled_components_1.default.button.attrs(({ color = 'default', extraClass }) => ({
|
|
77
|
-
className: `button-color-${color}${extraClass ? ` ${extraClass}` : ''}`,
|
|
76
|
+
const StyledButton = styled_components_1.default.button.attrs(({ color = 'default', extraClass, variant }) => ({
|
|
77
|
+
className: `button-color-${color}${variant ? ` ${variant}` : ''}${extraClass ? ` ${extraClass}` : ''}`,
|
|
78
78
|
'data-component-name': 'Button/Button',
|
|
79
79
|
})) `
|
|
80
80
|
text-decoration: none;
|
|
@@ -131,6 +131,18 @@ const StyledButton = styled_components_1.default.button.attrs(({ color = 'defaul
|
|
|
131
131
|
animation: ${getBlink()} 1.2s infinite;
|
|
132
132
|
`}
|
|
133
133
|
|
|
134
|
+
${({ color }) => color === 'tertiary' &&
|
|
135
|
+
(0, styled_components_1.css) `
|
|
136
|
+
background-color: transparent;
|
|
137
|
+
border: none;
|
|
138
|
+
color: var(--text-color);
|
|
139
|
+
|
|
140
|
+
:hover {
|
|
141
|
+
border: none;
|
|
142
|
+
background: rgba(255, 255, 255, 0.65);
|
|
143
|
+
}
|
|
144
|
+
`}
|
|
145
|
+
|
|
134
146
|
${({ disabled }) => disabled &&
|
|
135
147
|
(0, styled_components_1.css) `
|
|
136
148
|
&,
|
package/lib/Catalog/Filter.js
CHANGED
|
@@ -12,9 +12,7 @@ function Filter({ filter }) {
|
|
|
12
12
|
if (!filter.parentUsed)
|
|
13
13
|
return null;
|
|
14
14
|
return (react_1.default.createElement(FilterGroup, { key: filter.property + filter.title },
|
|
15
|
-
react_1.default.createElement(FilterTitle, null,
|
|
16
|
-
filter.title,
|
|
17
|
-
" filter"),
|
|
15
|
+
react_1.default.createElement(FilterTitle, null, filter.title),
|
|
18
16
|
filter.type === 'select' ? (react_1.default.createElement(StyledSelect, { onChange: (e) => filter.selectOption(e.target.value), value: ((_a = filter.selectedOptions.values().next()) === null || _a === void 0 ? void 0 : _a.value) || '' },
|
|
19
17
|
react_1.default.createElement("option", { key: "none", value: "" }, "All"),
|
|
20
18
|
filter.filteredOptions.map((value) => (react_1.default.createElement("option", { key: value.value, value: value.value },
|
|
@@ -4,6 +4,9 @@ interface AdmonitionTypeProps {
|
|
|
4
4
|
}
|
|
5
5
|
export interface AdmonitionProps extends Partial<AdmonitionTypeProps> {
|
|
6
6
|
name?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
'data-source'?: string;
|
|
9
|
+
'data-hash'?: string;
|
|
7
10
|
}
|
|
8
|
-
export declare function Admonition({ type, name, children, }: React.PropsWithChildren<AdmonitionProps>): JSX.Element;
|
|
11
|
+
export declare function Admonition({ type, name, children, className, 'data-source': dataSource, 'data-hash': dataHash, }: React.PropsWithChildren<AdmonitionProps>): JSX.Element;
|
|
9
12
|
export {};
|
|
@@ -7,8 +7,8 @@ exports.Admonition = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
9
|
const AlertIcon_1 = require("../icons/AlertIcon/AlertIcon");
|
|
10
|
-
function Admonition({ type = 'info', name, children, }) {
|
|
11
|
-
return (react_1.default.createElement(Wrapper, { type: type, "data-component-name": "Markdown/Admonition" },
|
|
10
|
+
function Admonition({ type = 'info', name, children, className, 'data-source': dataSource, 'data-hash': dataHash, }) {
|
|
11
|
+
return (react_1.default.createElement(Wrapper, { type: type, className: className, "data-component-name": "Markdown/Admonition", "data-source": dataSource, "data-hash": dataHash },
|
|
12
12
|
react_1.default.createElement(AlertIcon_1.AlertIcon, { type: type }),
|
|
13
13
|
name ? react_1.default.createElement(Heading, { type: type }, name) : null,
|
|
14
14
|
react_1.default.createElement(Content, null, children)));
|
|
@@ -3,5 +3,7 @@ export type CodeSampleProps = {
|
|
|
3
3
|
language: string;
|
|
4
4
|
highlighted: string;
|
|
5
5
|
rawContent: string;
|
|
6
|
+
'data-source'?: string;
|
|
7
|
+
'data-hash'?: string;
|
|
6
8
|
};
|
|
7
|
-
export declare function CodeSample({ rawContent, highlighted, language }: CodeSampleProps): JSX.Element;
|
|
9
|
+
export declare function CodeSample({ rawContent, highlighted, language, 'data-source': dataSource, 'data-hash': dataHash, }: CodeSampleProps): JSX.Element;
|
|
@@ -29,7 +29,7 @@ const styled_components_1 = __importStar(require("styled-components"));
|
|
|
29
29
|
const ClipboardService_1 = require("../../utils/ClipboardService");
|
|
30
30
|
const useThemeConfig_1 = require("../../hooks/useThemeConfig");
|
|
31
31
|
const Feedback_1 = require("../../Feedback");
|
|
32
|
-
function CodeSample({ rawContent, highlighted, language }) {
|
|
32
|
+
function CodeSample({ rawContent, highlighted, language, 'data-source': dataSource, 'data-hash': dataHash, }) {
|
|
33
33
|
const langClassName = language ? `language-${language}` : '';
|
|
34
34
|
const { codeSnippet: { copy = {}, report = {} } = {} } = (0, useThemeConfig_1.useThemeConfig)();
|
|
35
35
|
const [isCopied, setIsCopied] = (0, react_1.useState)(false);
|
|
@@ -39,7 +39,7 @@ function CodeSample({ rawContent, highlighted, language }) {
|
|
|
39
39
|
setIsCopied(true);
|
|
40
40
|
setTimeout(() => setIsCopied(false), copy.toasterDuration || 1500);
|
|
41
41
|
};
|
|
42
|
-
return (react_1.default.createElement(Wrapper, { className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample" },
|
|
42
|
+
return (react_1.default.createElement(Wrapper, { className: "code-sample", "data-component-name": "Markdown/CodeSample/CodeSample", "data-source": dataSource, "data-hash": dataHash },
|
|
43
43
|
react_1.default.createElement(CodeSampleButtonContainer, null,
|
|
44
44
|
!copy.hide && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
45
45
|
!isCopied && (react_1.default.createElement(Button, { onClick: () => copyCode(rawContent), title: copy.tooltipText || 'Copy to clipboard' }, copy.buttonText || 'Copy')),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
export declare function Heading({ level, id, children, }: PropsWithChildren<{
|
|
2
|
+
export declare function Heading({ level, id, children, 'data-source': dataSource, 'data-hash': dataHash, }: PropsWithChildren<{
|
|
3
3
|
level: number;
|
|
4
4
|
id: string;
|
|
5
|
+
'data-source'?: string;
|
|
6
|
+
'data-hash'?: string;
|
|
5
7
|
}>): JSX.Element;
|
package/lib/Markdown/Heading.js
CHANGED
|
@@ -26,18 +26,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Heading = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const utils_1 = require("../utils");
|
|
29
|
+
const icons_1 = require("../icons");
|
|
29
30
|
/**
|
|
30
31
|
* Class name for all MD tags
|
|
31
32
|
*/
|
|
32
33
|
const mdClassName = 'md';
|
|
33
|
-
|
|
34
|
-
react_1.default.createElement("
|
|
35
|
-
|
|
36
|
-
const linkEl = (react_1.default.createElement("a", { href: `#${id}`, className: (0, utils_1.concatClassNames)('anchor', 'before') }, SvgIcon));
|
|
34
|
+
function Heading({ level, id, children, 'data-source': dataSource, 'data-hash': dataHash, }) {
|
|
35
|
+
const linkEl = (react_1.default.createElement("a", { href: `#${id}`, className: (0, utils_1.concatClassNames)('anchor', 'before') },
|
|
36
|
+
react_1.default.createElement(icons_1.AnchorIcon, null)));
|
|
37
37
|
return (0, react_1.createElement)(`h${level}`, {
|
|
38
38
|
id,
|
|
39
39
|
className: (0, utils_1.concatClassNames)('heading-anchor', mdClassName),
|
|
40
40
|
'data-component-name': 'Markdown/Heading',
|
|
41
|
+
'data-source': dataSource,
|
|
42
|
+
'data-hash': dataHash,
|
|
41
43
|
}, react_1.default.createElement(react_1.default.Fragment, null,
|
|
42
44
|
linkEl,
|
|
43
45
|
children));
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
type MermaidProps = {
|
|
3
3
|
diagramHtml: string;
|
|
4
|
+
'data-source'?: string;
|
|
5
|
+
'data-hash'?: string;
|
|
4
6
|
};
|
|
5
|
-
export declare function Mermaid({ diagramHtml }: MermaidProps): JSX.Element;
|
|
7
|
+
export declare function Mermaid({ diagramHtml, 'data-source': dataSource, 'data-hash': dataHash, }: MermaidProps): JSX.Element;
|
|
6
8
|
export {};
|
package/lib/Markdown/Mermaid.js
CHANGED
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Mermaid = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
-
function Mermaid({ diagramHtml }) {
|
|
10
|
-
return (react_1.default.createElement(Wrapper, { className: "mermaid-wrapper", dangerouslySetInnerHTML: { __html: diagramHtml }, "data-component-name": "Markdown/Mermaid" }));
|
|
9
|
+
function Mermaid({ diagramHtml, 'data-source': dataSource, 'data-hash': dataHash, }) {
|
|
10
|
+
return (react_1.default.createElement(Wrapper, { className: "mermaid-wrapper", dangerouslySetInnerHTML: { __html: diagramHtml }, "data-component-name": "Markdown/Mermaid", "data-source": dataSource, "data-hash": dataHash }));
|
|
11
11
|
}
|
|
12
12
|
exports.Mermaid = Mermaid;
|
|
13
13
|
const Wrapper = styled_components_1.default.div `
|
package/lib/Profile/Profile.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.Profile = void 0;
|
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const styled_components_1 = __importStar(require("styled-components"));
|
|
29
29
|
const utils_1 = require("../utils");
|
|
30
|
-
function ProfileComponent({ name, imageUrl, onClick, color }) {
|
|
30
|
+
function ProfileComponent({ name = 'User', imageUrl, onClick, color }) {
|
|
31
31
|
var _a;
|
|
32
32
|
if (imageUrl) {
|
|
33
33
|
return (react_1.default.createElement(ProfileWrapper, { onClick: onClick },
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ClearButtonProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: React.CSSProperties;
|
|
5
|
+
handleClear?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const ClearButton: import("styled-components").StyledComponent<React.NamedExoticComponent<ClearButtonProps>, any, {}, never>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ClearButton = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const ClearButtonComponent = ({ className, style, handleClear }) => (react_1.default.createElement("button", { className: className, style: style, onClick: handleClear }, "\u2715"));
|
|
33
|
+
exports.ClearButton = (0, styled_components_1.default)((0, react_1.memo)(ClearButtonComponent)) `
|
|
34
|
+
z-index: 1;
|
|
35
|
+
position: absolute;
|
|
36
|
+
right: 24px;
|
|
37
|
+
top: 50%;
|
|
38
|
+
transform: translateY(-50%);
|
|
39
|
+
color: #89949f;
|
|
40
|
+
background: none;
|
|
41
|
+
border: none;
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
|
|
44
|
+
&:hover {
|
|
45
|
+
color: #fff;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
//# sourceMappingURL=ClearButton.js.map
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.DevOnboardingTryItSecurity = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const _theme_1 = require("../index.js");
|
|
32
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
33
|
+
const usePageData_1 = require("../mocks/hooks/usePageData");
|
|
34
|
+
const Dropdown_1 = require("./Dropdown");
|
|
35
|
+
function DevOnboardingTryItSecurity(props) {
|
|
36
|
+
const apiId = props.apiId;
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
const { userData } = (0, usePageData_1.usePageData)('userData') || {};
|
|
39
|
+
// TODO: handle error
|
|
40
|
+
const [_error, setError] = React.useState();
|
|
41
|
+
const [apps, setApps] = React.useState();
|
|
42
|
+
const [appId, setAppId] = React.useState('');
|
|
43
|
+
const [loading, setLoading] = React.useState(true);
|
|
44
|
+
const [appLoading, setAppLoading] = React.useState(false);
|
|
45
|
+
const [selectedAppSecret, setSelectedAppSecret] = React.useState();
|
|
46
|
+
const [acceptValueUpdate, setAcceptValueUpdate] = React.useState(true);
|
|
47
|
+
const initialRender = React.useRef(true);
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
if (!props.value && initialRender.current)
|
|
50
|
+
return;
|
|
51
|
+
if (acceptValueUpdate) {
|
|
52
|
+
setAcceptValueUpdate(false);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
setAppId('');
|
|
56
|
+
}
|
|
57
|
+
}, [props.value]);
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
initialRender.current = false;
|
|
60
|
+
const prevAppId = sessionStorage.getItem('redocly_onboarding:prevAppId');
|
|
61
|
+
if (prevAppId) {
|
|
62
|
+
setAppId(prevAppId);
|
|
63
|
+
}
|
|
64
|
+
if (userData === null || userData === void 0 ? void 0 : userData.isAuthenticated) {
|
|
65
|
+
fetch(`/api/api-keys/api-products/${apiId}/access?expand=1`).then((res) => {
|
|
66
|
+
return res
|
|
67
|
+
.json()
|
|
68
|
+
.then((data) => {
|
|
69
|
+
if (res.ok) {
|
|
70
|
+
setApps(data.apps);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
setError(data.message);
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.catch(() => setError('Something went wrong'))
|
|
77
|
+
.finally(() => setLoading(false));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}, []);
|
|
81
|
+
React.useEffect(() => {
|
|
82
|
+
sessionStorage.setItem('redocly_onboarding:prevAppId', appId || '');
|
|
83
|
+
}, [appId]);
|
|
84
|
+
if (!apiId) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const loadAppCredentials = (appId) => {
|
|
88
|
+
setAppLoading(true);
|
|
89
|
+
fetch(`/api/api-keys/apps/${appId}`).then((res) => {
|
|
90
|
+
return res
|
|
91
|
+
.json()
|
|
92
|
+
.then((data) => {
|
|
93
|
+
if (res.ok) {
|
|
94
|
+
const cred = data.credentials.find((cred) => cred.status === 'approved');
|
|
95
|
+
setAcceptValueUpdate(true);
|
|
96
|
+
setSelectedAppSecret(cred.clientSecret);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
setError(data.message);
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
.catch(() => setError('Something went wrong'))
|
|
103
|
+
.finally(() => setAppLoading(false));
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const placeholder = loading ? 'Loading your apps...' : undefined;
|
|
107
|
+
return (React.createElement(React.Fragment, null,
|
|
108
|
+
React.createElement(FormLabel, { htmlFor: "server" }, "Select app: "),
|
|
109
|
+
React.createElement(FormControl, null,
|
|
110
|
+
React.createElement(TryItDropdown, { placeholder: placeholder, value: appId || placeholder, options: (apps === null || apps === void 0 ? void 0 : apps.map((app) => ({ title: app.title, value: app.id }))) || [], fullWidth: true, onChange: ({ value }) => {
|
|
111
|
+
setAppId(value);
|
|
112
|
+
loadAppCredentials(value);
|
|
113
|
+
} }),
|
|
114
|
+
React.createElement(UseKeyButton, { disabled: !selectedAppSecret || appLoading, color: "secondary", blinking: appLoading, onClick: () => selectedAppSecret && props.onChange(selectedAppSecret) }, "Use key"))));
|
|
115
|
+
}
|
|
116
|
+
exports.DevOnboardingTryItSecurity = DevOnboardingTryItSecurity;
|
|
117
|
+
const TryItDropdown = (0, styled_components_1.default)(Dropdown_1.Dropdown) `
|
|
118
|
+
.dropdown-select,
|
|
119
|
+
label {
|
|
120
|
+
background-color: var(--panel-try-it-dropdown-background-color);
|
|
121
|
+
border: var(--panel-try-it-dropdown-border);
|
|
122
|
+
color: var(--panel-try-it-dropdown-color);
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
const FormControl = styled_components_1.default.div `
|
|
126
|
+
width: 100%;
|
|
127
|
+
/* font-family: var(--code-font-family); */
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
margin-bottom: 10px;
|
|
131
|
+
|
|
132
|
+
&:last-child {
|
|
133
|
+
margin-bottom: 0;
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
const FormLabel = styled_components_1.default.label `
|
|
137
|
+
padding-bottom: 6px;
|
|
138
|
+
display: block;
|
|
139
|
+
white-space: nowrap;
|
|
140
|
+
line-height: 1em;
|
|
141
|
+
|
|
142
|
+
${({ required }) => required &&
|
|
143
|
+
`
|
|
144
|
+
&:after {
|
|
145
|
+
display: inline-block;
|
|
146
|
+
content: '*';
|
|
147
|
+
margin-left: 4px;
|
|
148
|
+
color: var(--color-error-500);
|
|
149
|
+
}
|
|
150
|
+
`}
|
|
151
|
+
`;
|
|
152
|
+
const UseKeyButton = (0, styled_components_1.default)(_theme_1.Button) `
|
|
153
|
+
width: 100px;
|
|
154
|
+
align-self: flex-end;
|
|
155
|
+
margin-top: 16px;
|
|
156
|
+
margin-right: 0;
|
|
157
|
+
`;
|
|
158
|
+
//# sourceMappingURL=DevOnboardingTryItSecurity.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface DropdownOption {
|
|
3
|
+
idx?: number;
|
|
4
|
+
value: string;
|
|
5
|
+
title?: string;
|
|
6
|
+
serverUrl?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DropdownProps {
|
|
10
|
+
options: DropdownOption[];
|
|
11
|
+
onChange: (option: DropdownOption) => void;
|
|
12
|
+
handleClear?: () => void;
|
|
13
|
+
clearable?: boolean;
|
|
14
|
+
ariaLabel?: string;
|
|
15
|
+
className?: string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
value?: string;
|
|
18
|
+
dense?: boolean;
|
|
19
|
+
fullWidth?: boolean;
|
|
20
|
+
variant?: 'dark' | 'light';
|
|
21
|
+
}
|
|
22
|
+
export interface ArrowIconProps {
|
|
23
|
+
className?: string;
|
|
24
|
+
variant?: 'light' | 'dark';
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
}
|
|
27
|
+
export declare const Dropdown: import("styled-components").StyledComponent<React.NamedExoticComponent<DropdownProps>, any, {}, never>;
|
|
28
|
+
export declare const normalizeText: (description?: string | Record<string, any>) => string;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.normalizeText = exports.Dropdown = void 0;
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
+
const ClearButton_1 = require("./ClearButton");
|
|
33
|
+
const ArrowSvg = ({ className, style }) => (react_1.default.createElement("svg", { className: className, style: style, xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" },
|
|
34
|
+
react_1.default.createElement("polyline", { points: "6 9 12 15 18 9" })));
|
|
35
|
+
const ArrowIcon = (0, styled_components_1.default)(ArrowSvg) `
|
|
36
|
+
position: absolute;
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
z-index: 1;
|
|
39
|
+
top: 50%;
|
|
40
|
+
-webkit-transform: translateY(-50%);
|
|
41
|
+
-ms-transform: translateY(-50%);
|
|
42
|
+
transform: translateY(-50%);
|
|
43
|
+
right: 8px;
|
|
44
|
+
margin: auto;
|
|
45
|
+
text-align: center;
|
|
46
|
+
polyline {
|
|
47
|
+
color: ${(props) => props.variant === 'dark' && 'white'};
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const DropdownComponent = ({ options, onChange, handleClear, clearable, placeholder, value = '', className, variant = 'light', }) => {
|
|
51
|
+
var _a;
|
|
52
|
+
const handleOnChange = (event) => {
|
|
53
|
+
const { selectedIndex } = event.target;
|
|
54
|
+
const index = placeholder || !value ? selectedIndex - 1 : selectedIndex;
|
|
55
|
+
onChange(options[index]);
|
|
56
|
+
};
|
|
57
|
+
const renderOptions = (0, react_1.useMemo)(() => options.map(({ idx, value, title }, index) => {
|
|
58
|
+
const normalizedValue = (0, exports.normalizeText)(value);
|
|
59
|
+
return (react_1.default.createElement("option", { key: idx || normalizedValue + index, value: normalizedValue, className: "dropdown-option" }, title || normalizedValue));
|
|
60
|
+
}), [options]);
|
|
61
|
+
const normalizedValue = (0, exports.normalizeText)(value);
|
|
62
|
+
const title = ((_a = options.find((option) => option.value === value)) === null || _a === void 0 ? void 0 : _a.title) || normalizedValue;
|
|
63
|
+
return (react_1.default.createElement("div", { className: className + ' dropdown-wrapper' },
|
|
64
|
+
react_1.default.createElement(ArrowIcon, { variant: variant }),
|
|
65
|
+
clearable && (normalizedValue === null || normalizedValue === void 0 ? void 0 : normalizedValue.length) > 0 && react_1.default.createElement(ClearButton_1.ClearButton, { handleClear: handleClear }),
|
|
66
|
+
react_1.default.createElement("select", { onChange: handleOnChange, value: normalizedValue, className: "dropdown-select" },
|
|
67
|
+
placeholder && (react_1.default.createElement("option", { disabled: true, hidden: true, value: placeholder }, placeholder)),
|
|
68
|
+
!normalizedValue && !placeholder && react_1.default.createElement("option", { disabled: true }),
|
|
69
|
+
renderOptions),
|
|
70
|
+
react_1.default.createElement("label", null, title)));
|
|
71
|
+
};
|
|
72
|
+
exports.Dropdown = (0, styled_components_1.default)((0, react_1.memo)(DropdownComponent)) `
|
|
73
|
+
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
outline: none;
|
|
76
|
+
display: inline-block;
|
|
77
|
+
border-radius: var(--border-radius);
|
|
78
|
+
vertical-align: bottom;
|
|
79
|
+
position: relative;
|
|
80
|
+
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
81
|
+
cursor: pointer;
|
|
82
|
+
text-transform: none;
|
|
83
|
+
|
|
84
|
+
label {
|
|
85
|
+
box-sizing: border-box;
|
|
86
|
+
min-width: 90px;
|
|
87
|
+
height: 36px;
|
|
88
|
+
outline: none;
|
|
89
|
+
display: inline-block;
|
|
90
|
+
color: var(--dropdown-text-color);
|
|
91
|
+
border-radius: var(--border-radius);
|
|
92
|
+
border: var(--dropdown-border);
|
|
93
|
+
padding: var(--dropdown-padding);
|
|
94
|
+
vertical-align: bottom;
|
|
95
|
+
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'auto')};
|
|
96
|
+
text-transform: none;
|
|
97
|
+
line-height: inherit;
|
|
98
|
+
font-size: var(--dropdown-font-size);
|
|
99
|
+
font-family: inherit;
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
white-space: nowrap;
|
|
103
|
+
|
|
104
|
+
&,
|
|
105
|
+
&:hover,
|
|
106
|
+
&:focus-within {
|
|
107
|
+
border: 1px solid var(--border-color);
|
|
108
|
+
box-shadow: none;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
${({ variant }) => (variant === 'dark' ? darkDropdownStyle : '')};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.dropdown-select {
|
|
115
|
+
position: absolute;
|
|
116
|
+
top: 0;
|
|
117
|
+
left: 0;
|
|
118
|
+
width: 100%;
|
|
119
|
+
height: 100%;
|
|
120
|
+
opacity: 0;
|
|
121
|
+
border: none;
|
|
122
|
+
appearance: none;
|
|
123
|
+
cursor: pointer;
|
|
124
|
+
|
|
125
|
+
color: var(--text-color);
|
|
126
|
+
line-height: inherit;
|
|
127
|
+
font-size: 14px;
|
|
128
|
+
font-family: inherit;
|
|
129
|
+
padding: var(--dropdown-padding);
|
|
130
|
+
${({ variant }) => (variant === 'dark' ? darkDropdownStyle : '')};
|
|
131
|
+
|
|
132
|
+
`;
|
|
133
|
+
const darkDropdownStyle = `
|
|
134
|
+
background-color: var(--panel-samples-dropdown-background-color);
|
|
135
|
+
border: var(--panel-samples-dropdown-border);
|
|
136
|
+
color: var(--panel-samples-dropdown-color);
|
|
137
|
+
|
|
138
|
+
&,
|
|
139
|
+
&:hover,
|
|
140
|
+
&:focus-within {
|
|
141
|
+
border: none;
|
|
142
|
+
box-shadow: none;
|
|
143
|
+
}
|
|
144
|
+
`;
|
|
145
|
+
function isString(value) {
|
|
146
|
+
return typeof value === 'string';
|
|
147
|
+
}
|
|
148
|
+
const normalizeText = (description) => isString(description) ? description : description === null || description === void 0 ? void 0 : description.raw;
|
|
149
|
+
exports.normalizeText = normalizeText;
|
|
150
|
+
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TryItSecurity = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const useGlobalData_1 = require("../mocks/useGlobalData");
|
|
9
|
+
const DevOnboardingTryItSecurity_1 = require("./DevOnboardingTryItSecurity");
|
|
10
|
+
function TryItSecurity(props) {
|
|
11
|
+
const { hasDeveloperOnboarding } = (0, useGlobalData_1.useGlobalData)() || {};
|
|
12
|
+
return hasDeveloperOnboarding && props.apiId ? react_1.default.createElement(DevOnboardingTryItSecurity_1.DevOnboardingTryItSecurity, Object.assign({}, props)) : null;
|
|
13
|
+
}
|
|
14
|
+
exports.TryItSecurity = TryItSecurity;
|
|
15
|
+
//# sourceMappingURL=TryItSecurity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './TryItSecurity';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./TryItSecurity"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FooterWrapper = void 0;
|
|
7
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
+
exports.FooterWrapper = styled_components_1.default.div.attrs(() => ({
|
|
9
|
+
'data-component-name': 'Sidebar/FooterWrapper',
|
|
10
|
+
})) `
|
|
11
|
+
margin: var(--sidebar-offset-top) 0 var(--sidebar-spacing-unit) var(--sidebar-offset-left);
|
|
12
|
+
padding-top: var(--sidebar-spacing-unit);
|
|
13
|
+
border-top: solid 1px #daddde;
|
|
14
|
+
`;
|
|
15
|
+
//# sourceMappingURL=FooterWrapper.js.map
|