@redocly/theme 0.28.2 → 0.29.0
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/components/Button/Button.d.ts +1 -0
- package/lib/components/CodeBlock/CodeBlockControls.js +2 -2
- package/lib/components/Feedback/useReportDialog.js +8 -4
- package/lib/config.d.ts +19 -0
- package/lib/config.js +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.tsx +2 -0
- package/src/components/CodeBlock/CodeBlockControls.tsx +1 -1
- package/src/components/Feedback/useReportDialog.ts +8 -4
- package/src/config.ts +4 -0
|
@@ -16,6 +16,7 @@ export interface ButtonProps {
|
|
|
16
16
|
icon?: JSX.Element;
|
|
17
17
|
title?: string;
|
|
18
18
|
onClick?: (e?: any) => void;
|
|
19
|
+
type?: 'button' | 'submit' | 'reset';
|
|
19
20
|
}
|
|
20
21
|
export declare const baseButtonStyles: FlattenSimpleInterpolation;
|
|
21
22
|
export declare const Button: import("styled-components").StyledComponent<React.FC<ButtonProps>, any, {}, never>;
|
|
@@ -12,7 +12,7 @@ const icons_1 = require("../../icons");
|
|
|
12
12
|
const hooks_1 = require("../../hooks");
|
|
13
13
|
const telemetry_1 = require("../../mocks/telemetry");
|
|
14
14
|
function CodeBlockControls({ children, className, title, controls, }) {
|
|
15
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16
16
|
const { codeSnippet } = (0, hooks_1.useThemeConfig)();
|
|
17
17
|
const controlsType = (codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.controlsStyle) || 'icon';
|
|
18
18
|
const { copy, expand, collapse, select, deselect, report } = controls
|
|
@@ -29,7 +29,7 @@ function CodeBlockControls({ children, className, title, controls, }) {
|
|
|
29
29
|
collapse && !((_c = codeSnippet === null || codeSnippet === void 0 ? void 0 : codeSnippet.collapse) === null || _c === void 0 ? void 0 : _c.hide) ? (react_1.default.createElement(CodeBlock_1.CodeBlockControlButton, { "data-cy": "collapse-all", "data-testid": "collapse-all", asIcon: controlsType === 'icon', onClick: collapse === null || collapse === void 0 ? void 0 : collapse.onClick, title: (collapse === null || collapse === void 0 ? void 0 : collapse.tooltipText) || 'Collapse all' }, controlsType === 'icon' ? (react_1.default.createElement(icons_1.CollapseIcon, null)) : (collapse === null || collapse === void 0 ? void 0 : collapse.label) ? (collapse.label) : ('Collapse all'))) : null,
|
|
30
30
|
select ? (react_1.default.createElement(CodeBlock_1.CodeBlockControlButton, { "data-cy": "select-all", "data-testid": "select-all", asIcon: controlsType === 'icon', onClick: select === null || select === void 0 ? void 0 : select.onClick, title: select === null || select === void 0 ? void 0 : select.tooltipText }, controlsType === 'icon' ? react_1.default.createElement(icons_1.SelectIcon, null) : (select === null || select === void 0 ? void 0 : select.label) ? select.label : 'Select all')) : null,
|
|
31
31
|
deselect ? (react_1.default.createElement(CodeBlock_1.CodeBlockControlButton, { "data-cy": "clear-all", "data-testid": "clear-all", asIcon: controlsType === 'icon', onClick: deselect === null || deselect === void 0 ? void 0 : deselect.onClick, title: deselect === null || deselect === void 0 ? void 0 : deselect.tooltipText }, controlsType === 'icon' ? (react_1.default.createElement(icons_1.DeselectIcon, null)) : (deselect === null || deselect === void 0 ? void 0 : deselect.label) ? (deselect.label) : ('Clear all'))) : null,
|
|
32
|
-
report && ((_d = report === null || report === void 0 ? void 0 : report.props) === null || _d === void 0 ? void 0 : _d.visible) ? (react_1.default.createElement(CodeBlock_1.CodeBlockControlButton, Object.assign({ "data-cy": "report-button", "data-testid": "report-button", asIcon: controlsType === 'icon', title: report.
|
|
32
|
+
report && ((_d = report === null || report === void 0 ? void 0 : report.props) === null || _d === void 0 ? void 0 : _d.visible) ? (react_1.default.createElement(CodeBlock_1.CodeBlockControlButton, Object.assign({ "data-cy": "report-button", "data-testid": "report-button", asIcon: controlsType === 'icon', title: (_e = report.props) === null || _e === void 0 ? void 0 : _e.tooltip }, report.props), controlsType === 'icon' ? react_1.default.createElement(icons_1.ReportIcon, null) : ((_f = report.props) === null || _f === void 0 ? void 0 : _f.buttonText) || 'Report')) : null))) : null;
|
|
33
33
|
return children || controls ? (react_1.default.createElement(ContainerWraper, { "data-component-name": "CodeBlock/CodeBlockControls", className: className }, children ? children : defaultControls)) : null;
|
|
34
34
|
}
|
|
35
35
|
exports.CodeBlockControls = CodeBlockControls;
|
|
@@ -9,6 +9,7 @@ function useReportDialog() {
|
|
|
9
9
|
const { codeSnippet: { report = {} } = {} } = (0, hooks_2.useThemeConfig)();
|
|
10
10
|
const [isReportDialogShown, setIsReportDialogShown] = (0, react_1.useState)(false);
|
|
11
11
|
const isReportButtonShown = (report === null || report === void 0 ? void 0 : report.hide) !== true;
|
|
12
|
+
const { tooltipText, buttonText, label } = report;
|
|
12
13
|
const { translate } = (0, hooks_1.useTranslate)();
|
|
13
14
|
const { submitFeedback } = (0, useSubmitFeedback_1.useSubmitFeedback)();
|
|
14
15
|
const showReportDialog = () => {
|
|
@@ -19,18 +20,21 @@ function useReportDialog() {
|
|
|
19
20
|
setIsReportDialogShown(false);
|
|
20
21
|
}, 1000);
|
|
21
22
|
};
|
|
23
|
+
const closeReportDialog = () => {
|
|
24
|
+
setIsReportDialogShown(false);
|
|
25
|
+
};
|
|
22
26
|
const reportButtonProps = {
|
|
23
27
|
onClick: showReportDialog,
|
|
24
|
-
buttonText: translate('theme.codeSnippet.report.buttonText', 'Report'),
|
|
25
|
-
tooltip: translate('theme.codeSnippet.report.tooltipText', 'Report a problem'),
|
|
28
|
+
buttonText: buttonText || translate('theme.codeSnippet.report.buttonText', 'Report'),
|
|
29
|
+
tooltip: tooltipText || translate('theme.codeSnippet.report.tooltipText', 'Report a problem'),
|
|
26
30
|
visible: isReportButtonShown,
|
|
27
31
|
};
|
|
28
32
|
const reportDialogProps = {
|
|
29
33
|
settings: {
|
|
30
|
-
label: translate('theme.codeSnippet.report.label', 'What is wrong with this code?'),
|
|
34
|
+
label: label || translate('theme.codeSnippet.report.label', 'What is wrong with this code?'),
|
|
31
35
|
},
|
|
32
36
|
onSubmit: hideReportDialog,
|
|
33
|
-
onCancel:
|
|
37
|
+
onCancel: closeReportDialog,
|
|
34
38
|
submitFeedback,
|
|
35
39
|
};
|
|
36
40
|
return {
|
package/lib/config.d.ts
CHANGED
|
@@ -1249,6 +1249,15 @@ export declare const themeConfigSchema: {
|
|
|
1249
1249
|
readonly hide: {
|
|
1250
1250
|
readonly type: "boolean";
|
|
1251
1251
|
};
|
|
1252
|
+
readonly tooltipText: {
|
|
1253
|
+
readonly type: "string";
|
|
1254
|
+
};
|
|
1255
|
+
readonly buttonText: {
|
|
1256
|
+
readonly type: "string";
|
|
1257
|
+
};
|
|
1258
|
+
readonly label: {
|
|
1259
|
+
readonly type: "string";
|
|
1260
|
+
};
|
|
1252
1261
|
};
|
|
1253
1262
|
readonly additionalProperties: false;
|
|
1254
1263
|
readonly default: {
|
|
@@ -2284,6 +2293,15 @@ export declare const productThemeOverrideSchema: {
|
|
|
2284
2293
|
readonly hide: {
|
|
2285
2294
|
readonly type: "boolean";
|
|
2286
2295
|
};
|
|
2296
|
+
readonly tooltipText: {
|
|
2297
|
+
readonly type: "string";
|
|
2298
|
+
};
|
|
2299
|
+
readonly buttonText: {
|
|
2300
|
+
readonly type: "string";
|
|
2301
|
+
};
|
|
2302
|
+
readonly label: {
|
|
2303
|
+
readonly type: "string";
|
|
2304
|
+
};
|
|
2287
2305
|
};
|
|
2288
2306
|
readonly additionalProperties: false;
|
|
2289
2307
|
readonly default: {
|
|
@@ -2360,6 +2378,7 @@ export type ThemeUIConfig = ThemeConfig & {
|
|
|
2360
2378
|
title: string | undefined;
|
|
2361
2379
|
}[];
|
|
2362
2380
|
devLogin?: boolean;
|
|
2381
|
+
loginUrls?: Record<string, string>;
|
|
2363
2382
|
};
|
|
2364
2383
|
search?: {
|
|
2365
2384
|
shortcuts?: string[];
|
package/lib/config.js
CHANGED
|
@@ -499,7 +499,7 @@ exports.themeConfigSchema = {
|
|
|
499
499
|
},
|
|
500
500
|
report: {
|
|
501
501
|
type: 'object',
|
|
502
|
-
properties: Object.assign({}, hideConfigSchema.properties),
|
|
502
|
+
properties: Object.assign({ tooltipText: { type: 'string' }, buttonText: { type: 'string' }, label: { type: 'string' } }, hideConfigSchema.properties),
|
|
503
503
|
additionalProperties: false,
|
|
504
504
|
default: { hide: false },
|
|
505
505
|
},
|
package/package.json
CHANGED
|
@@ -140,7 +140,7 @@ export function CodeBlockControls({
|
|
|
140
140
|
data-cy="report-button"
|
|
141
141
|
data-testid="report-button"
|
|
142
142
|
asIcon={controlsType === 'icon'}
|
|
143
|
-
title={report.
|
|
143
|
+
title={report.props?.tooltip}
|
|
144
144
|
{...report.props}
|
|
145
145
|
>
|
|
146
146
|
{controlsType === 'icon' ? <ReportIcon /> : report.props?.buttonText || 'Report'}
|
|
@@ -20,6 +20,7 @@ export function useReportDialog(): Record<string, ReportComponentsProps> {
|
|
|
20
20
|
const { codeSnippet: { report = {} } = {} } = useThemeConfig();
|
|
21
21
|
const [isReportDialogShown, setIsReportDialogShown] = useState(false);
|
|
22
22
|
const isReportButtonShown = report?.hide !== true;
|
|
23
|
+
const { tooltipText, buttonText, label } = report;
|
|
23
24
|
const { translate } = useTranslate();
|
|
24
25
|
const { submitFeedback } = useSubmitFeedback();
|
|
25
26
|
|
|
@@ -31,18 +32,21 @@ export function useReportDialog(): Record<string, ReportComponentsProps> {
|
|
|
31
32
|
setIsReportDialogShown(false);
|
|
32
33
|
}, 1000);
|
|
33
34
|
};
|
|
35
|
+
const closeReportDialog = () => {
|
|
36
|
+
setIsReportDialogShown(false);
|
|
37
|
+
};
|
|
34
38
|
const reportButtonProps: ReportButtonProps = {
|
|
35
39
|
onClick: showReportDialog,
|
|
36
|
-
buttonText: translate('theme.codeSnippet.report.buttonText', 'Report'),
|
|
37
|
-
tooltip: translate('theme.codeSnippet.report.tooltipText', 'Report a problem'),
|
|
40
|
+
buttonText: buttonText || translate('theme.codeSnippet.report.buttonText', 'Report'),
|
|
41
|
+
tooltip: tooltipText || translate('theme.codeSnippet.report.tooltipText', 'Report a problem'),
|
|
38
42
|
visible: isReportButtonShown,
|
|
39
43
|
};
|
|
40
44
|
const reportDialogProps: Partial<ReportDialogProps> = {
|
|
41
45
|
settings: {
|
|
42
|
-
label: translate('theme.codeSnippet.report.label', 'What is wrong with this code?'),
|
|
46
|
+
label: label || translate('theme.codeSnippet.report.label', 'What is wrong with this code?'),
|
|
43
47
|
},
|
|
44
48
|
onSubmit: hideReportDialog,
|
|
45
|
-
onCancel:
|
|
49
|
+
onCancel: closeReportDialog,
|
|
46
50
|
submitFeedback,
|
|
47
51
|
};
|
|
48
52
|
|
package/src/config.ts
CHANGED
|
@@ -576,6 +576,9 @@ export const themeConfigSchema = {
|
|
|
576
576
|
report: {
|
|
577
577
|
type: 'object',
|
|
578
578
|
properties: {
|
|
579
|
+
tooltipText: { type: 'string' },
|
|
580
|
+
buttonText: { type: 'string' },
|
|
581
|
+
label: { type: 'string' },
|
|
579
582
|
...hideConfigSchema.properties,
|
|
580
583
|
},
|
|
581
584
|
additionalProperties: false,
|
|
@@ -704,6 +707,7 @@ export type ThemeUIConfig = ThemeConfig & {
|
|
|
704
707
|
title: string | undefined;
|
|
705
708
|
}[];
|
|
706
709
|
devLogin?: boolean;
|
|
710
|
+
loginUrls?: Record<string, string>;
|
|
707
711
|
};
|
|
708
712
|
search?: {
|
|
709
713
|
shortcuts?: string[];
|