@redocly/theme 0.44.9 → 0.45.1
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/Feedback/Mood.d.ts +5 -5
- package/lib/components/Feedback/Mood.js +34 -4
- package/lib/components/Feedback/Sentiment.d.ts +4 -5
- package/lib/components/Feedback/Sentiment.js +38 -4
- package/lib/components/Search/SearchDialog.js +1 -2
- package/lib/core/types/l10n.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Feedback/Mood.tsx +45 -9
- package/src/components/Feedback/Sentiment.tsx +52 -9
- package/src/components/Search/SearchDialog.tsx +0 -4
- package/src/core/types/l10n.ts +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReasonsSettingsSchema } from '@redocly/config';
|
|
1
2
|
export declare enum MOOD_STATES {
|
|
2
3
|
SATISFIED = "satisfied",
|
|
3
4
|
NEUTRAL = "neutral",
|
|
@@ -18,11 +19,10 @@ export type MoodProps = {
|
|
|
18
19
|
neutralLabel?: string;
|
|
19
20
|
dissatisfiedLabel?: string;
|
|
20
21
|
};
|
|
21
|
-
reasons?: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
items: string[];
|
|
22
|
+
reasons?: ReasonsSettingsSchema & {
|
|
23
|
+
satisfied?: ReasonsSettingsSchema;
|
|
24
|
+
neutral?: ReasonsSettingsSchema;
|
|
25
|
+
dissatisfied?: ReasonsSettingsSchema;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
28
|
className?: string;
|
|
@@ -53,6 +53,16 @@ function Mood({ settings, onSubmit, className }) {
|
|
|
53
53
|
const [reasons, setReasons] = React.useState([]);
|
|
54
54
|
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
55
55
|
const { translate } = useTranslate();
|
|
56
|
+
const checkIfShouldDisplayReasons = (score) => {
|
|
57
|
+
if (!score || !reasonsSettings) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const scoreSpecificReasonsSettings = reasonsSettings[score];
|
|
61
|
+
if (typeof (scoreSpecificReasonsSettings === null || scoreSpecificReasonsSettings === void 0 ? void 0 : scoreSpecificReasonsSettings.hide) === 'undefined') {
|
|
62
|
+
return !reasonsSettings.hide;
|
|
63
|
+
}
|
|
64
|
+
return !(scoreSpecificReasonsSettings === null || scoreSpecificReasonsSettings === void 0 ? void 0 : scoreSpecificReasonsSettings.hide);
|
|
65
|
+
};
|
|
56
66
|
const renderCommentLabel = (score) => {
|
|
57
67
|
if (!commentSettings || (commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.hide) === true)
|
|
58
68
|
return '';
|
|
@@ -70,7 +80,27 @@ function Mood({ settings, onSubmit, className }) {
|
|
|
70
80
|
return translate('feedback.settings.comment.satisfiedLabel', 'What can we improve?');
|
|
71
81
|
}
|
|
72
82
|
};
|
|
73
|
-
const
|
|
83
|
+
const renderReasonsLabel = (score) => {
|
|
84
|
+
var _a;
|
|
85
|
+
if (!reasonsSettings || (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.hide) === true)
|
|
86
|
+
return '';
|
|
87
|
+
return (_a = reasonsSettings[score]) === null || _a === void 0 ? void 0 : _a.label;
|
|
88
|
+
};
|
|
89
|
+
const resolveReasonsItems = (score) => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
if (!reasonsSettings) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const defaultReasonsItems = (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.items) || [];
|
|
95
|
+
return defaultReasonsItems.concat((_b = (_a = reasonsSettings[score]) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : []);
|
|
96
|
+
};
|
|
97
|
+
const resolveReasonsComponent = (score) => {
|
|
98
|
+
var _a;
|
|
99
|
+
if (!reasonsSettings || (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.hide) === true)
|
|
100
|
+
return 'checkbox';
|
|
101
|
+
return (_a = reasonsSettings[score]) === null || _a === void 0 ? void 0 : _a.component;
|
|
102
|
+
};
|
|
103
|
+
const displayReasons = checkIfShouldDisplayReasons(score);
|
|
74
104
|
const displayComment = !!(score && !(commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.hide));
|
|
75
105
|
const displaySubmitBnt = !!(score && (displayReasons || displayComment));
|
|
76
106
|
const onSubmitMoodForm = () => {
|
|
@@ -113,9 +143,9 @@ function Mood({ settings, onSubmit, className }) {
|
|
|
113
143
|
}, icon: React.createElement(FaceSatisfiedIcon_1.FaceSatisfiedIcon, null) }))),
|
|
114
144
|
(displayReasons || displayComment) && (React.createElement(StyledFormOptionalFields, null,
|
|
115
145
|
displayReasons && (React.createElement(Reasons_1.Reasons, { settings: {
|
|
116
|
-
label:
|
|
117
|
-
items: (
|
|
118
|
-
component:
|
|
146
|
+
label: renderReasonsLabel(score),
|
|
147
|
+
items: resolveReasonsItems(score),
|
|
148
|
+
component: resolveReasonsComponent(score),
|
|
119
149
|
}, onChange: setReasons })),
|
|
120
150
|
displayComment && (React.createElement(Comment_1.Comment, { standAlone: false, onSubmit: ({ comment }) => setComment(comment), settings: { label: renderCommentLabel(score) } })))),
|
|
121
151
|
displaySubmitBnt && (React.createElement(ButtonsContainer, null,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReasonsSettingsSchema } from '@redocly/config';
|
|
1
2
|
export type SentimentProps = {
|
|
2
3
|
onSubmit: (value: {
|
|
3
4
|
score: number;
|
|
@@ -12,11 +13,9 @@ export type SentimentProps = {
|
|
|
12
13
|
likeLabel?: string;
|
|
13
14
|
dislikeLabel?: string;
|
|
14
15
|
};
|
|
15
|
-
reasons?: {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
component?: string;
|
|
19
|
-
items: string[];
|
|
16
|
+
reasons?: ReasonsSettingsSchema & {
|
|
17
|
+
like?: ReasonsSettingsSchema;
|
|
18
|
+
dislike?: ReasonsSettingsSchema;
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
className?: string;
|
|
@@ -45,7 +45,27 @@ function Sentiment({ settings, onSubmit, className }) {
|
|
|
45
45
|
const [reasons, setReasons] = React.useState([]);
|
|
46
46
|
const { useTranslate } = (0, hooks_1.useThemeHooks)();
|
|
47
47
|
const { translate } = useTranslate();
|
|
48
|
-
const
|
|
48
|
+
const getScoreSpecificReasonSettings = (score) => {
|
|
49
|
+
switch (score) {
|
|
50
|
+
case 1:
|
|
51
|
+
return reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.like;
|
|
52
|
+
case -1:
|
|
53
|
+
return reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.dislike;
|
|
54
|
+
default:
|
|
55
|
+
return reasonsSettings;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const checkIfShouldDisplayReasons = (score) => {
|
|
59
|
+
if (!score || !reasonsSettings) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
const scoreSpecificReasonsSettings = getScoreSpecificReasonSettings(score);
|
|
63
|
+
if (typeof (scoreSpecificReasonsSettings === null || scoreSpecificReasonsSettings === void 0 ? void 0 : scoreSpecificReasonsSettings.hide) === 'undefined') {
|
|
64
|
+
return !reasonsSettings.hide;
|
|
65
|
+
}
|
|
66
|
+
return !(scoreSpecificReasonsSettings === null || scoreSpecificReasonsSettings === void 0 ? void 0 : scoreSpecificReasonsSettings.hide);
|
|
67
|
+
};
|
|
68
|
+
const displayReasons = checkIfShouldDisplayReasons(score);
|
|
49
69
|
const displayComment = !!(score && !(commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.hide));
|
|
50
70
|
const displaySubmitBnt = !!(score && (displayReasons || displayComment));
|
|
51
71
|
const commentLabel = score === 1
|
|
@@ -53,6 +73,20 @@ function Sentiment({ settings, onSubmit, className }) {
|
|
|
53
73
|
translate('feedback.settings.comment.likeLabel', 'What was most helpful?')
|
|
54
74
|
: (commentSettings && commentSettings.dislikeLabel) ||
|
|
55
75
|
translate('feedback.settings.comment.dislikeLabel', 'What can we improve?');
|
|
76
|
+
const renderReasonsLabel = (score) => {
|
|
77
|
+
const scoreSpecificReasonSettings = getScoreSpecificReasonSettings(score);
|
|
78
|
+
return scoreSpecificReasonSettings === null || scoreSpecificReasonSettings === void 0 ? void 0 : scoreSpecificReasonSettings.label;
|
|
79
|
+
};
|
|
80
|
+
const resolveReasonsItems = (score) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const defaultReasonsItems = (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.items) || [];
|
|
83
|
+
const scoreSpecificReasonSettings = getScoreSpecificReasonSettings(score);
|
|
84
|
+
return defaultReasonsItems.concat((_a = scoreSpecificReasonSettings === null || scoreSpecificReasonSettings === void 0 ? void 0 : scoreSpecificReasonSettings.items) !== null && _a !== void 0 ? _a : []);
|
|
85
|
+
};
|
|
86
|
+
const resolveReasonsComponent = (score) => {
|
|
87
|
+
const scoreSpecificReasonSettings = getScoreSpecificReasonSettings(score);
|
|
88
|
+
return scoreSpecificReasonSettings === null || scoreSpecificReasonSettings === void 0 ? void 0 : scoreSpecificReasonSettings.component;
|
|
89
|
+
};
|
|
56
90
|
const onSubmitSentimentForm = () => {
|
|
57
91
|
onSubmit({
|
|
58
92
|
score,
|
|
@@ -90,9 +124,9 @@ function Sentiment({ settings, onSubmit, className }) {
|
|
|
90
124
|
}, "aria-label": "Dislike", icon: React.createElement(ThumbDownIcon_1.ThumbDownIcon, null) }))),
|
|
91
125
|
(displayReasons || displayComment) && (React.createElement(StyledFormOptionalFields, null,
|
|
92
126
|
displayReasons && (React.createElement(Reasons_1.Reasons, { settings: {
|
|
93
|
-
label:
|
|
94
|
-
items: (
|
|
95
|
-
component:
|
|
127
|
+
label: renderReasonsLabel(score),
|
|
128
|
+
items: resolveReasonsItems(score),
|
|
129
|
+
component: resolveReasonsComponent(score),
|
|
96
130
|
}, onChange: setReasons })),
|
|
97
131
|
displayComment && (React.createElement(Comment_1.Comment, { standAlone: false, onSubmit: ({ comment }) => setComment(comment), settings: { label: commentLabel } })))),
|
|
98
132
|
displaySubmitBnt && (React.createElement(ButtonsContainer, null,
|
|
@@ -130,8 +130,7 @@ function SearchDialog({ onClose, className }) {
|
|
|
130
130
|
})) : isSearchLoading ? (react_1.default.createElement(SearchMessage, null,
|
|
131
131
|
react_1.default.createElement(SpinnerLoader_1.SpinnerLoader, { size: "26px", color: "var(--search-input-icon-color)" }),
|
|
132
132
|
translate('search.loading', 'Loading...'))) : (react_1.default.createElement(SearchMessage, { "data-translation-key": "search.noResults" },
|
|
133
|
-
react_1.default.createElement("b", null, translate('search.noResults.title', 'No results')),
|
|
134
|
-
translate('search.noResults.description', 'Prease, try with a different query.')))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
133
|
+
react_1.default.createElement("b", null, translate('search.noResults.title', 'No results'))))) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
135
134
|
react_1.default.createElement(SearchRecent_1.SearchRecent, { onSelect: setQuery }),
|
|
136
135
|
react_1.default.createElement(SearchSuggestedPages_1.SearchSuggestedPages, null)))),
|
|
137
136
|
advancedSearch && mode === 'search' && isFilterOpen && (react_1.default.createElement(SearchDialogBodyFilterView, null,
|
package/lib/core/types/l10n.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TOptions } from 'i18next';
|
|
2
|
-
export type TranslationKey = 'dev.newApp' | 'dev.newApp.text' | 'dev.sidebar.header' | 'dev.sidebar.footer.text' | 'dev.create.app.dialog.appName.placeholder' | 'dev.create.app.dialog.appName.error' | 'dev.create.app.dialog.selectAPIs' | 'dev.create.app.dialog.description' | 'dev.create.app.dialog.description.placeholder' | 'dev.create.app.dialog.create' | 'dev.create.app.dialog.cancel' | 'dev.main.tab.appKeys' | 'dev.main.tab.logs' | 'dev.app.description.title' | 'dev.edit.description.dialog.title' | 'dev.edit.description.dialog.save' | 'dev.edit.description.dialog.cancel' | 'dev.edit.apis.dialog.selectedAPIs' | 'dev.app.key.create' | 'dev.create.key.dialog.title' | 'dev.create.key.dialog.create' | 'dev.create.key.dialog.cancel' | 'dev.app.edit' | 'dev.app.delete' | 'dev.edit.app.dialog.title' | 'dev.edit.app.dialog.save' | 'dev.edit.app.dialog.cancel' | 'dev.delete.app.dialog.title' | 'dev.delete.app.dialog.confirmation' | 'dev.delete.app.dialog.delete' | 'dev.delete.app.dialog.cancel' | 'dev.app.key.roll' | 'dev.roll.key.dialog.title' | 'dev.roll.key.dialog.apiKey' | 'dev.roll.key.dialog.expires' | 'dev.roll.key.dialog.confirmation' | 'dev.roll.key.dialog.cancel' | 'dev.roll.key.dialog.roll' | 'dev.update.key.dialog.title' | 'dev.update.key.dialog.update' | 'dev.update.key.dialog.cancel' | 'dev.app.key.api.name' | 'dev.app.key.api.status' | 'dev.app.key.api.edit' | 'dev.edit.apis.dialog.title' | 'dev.edit.apis.dialog.apiKey' | 'dev.edit.apis.dialog.save' | 'dev.edit.apis.dialog.cancel' | 'dev.select.placeholder' | 'dev.app.overview.status.pending' | 'dev.app.overview.status.approved' | 'dev.app.overview.status.revoked' | 'dev.app.overview.status' | 'dev.app.overview.non-production' | 'dev.app.overview.production' | 'dev.app.overview.clientId' | 'dev.app.overview.apiKey' | 'dev.app.key.revoke' | 'dev.revoke.key.dialog.title' | 'dev.revoke.key.dialog.apiKey' | 'dev.revoke.key.dialog.expires' | 'dev.revoke.key.dialog.confirmation' | 'dev.revoke.key.dialog.revoke' | 'dev.revoke.key.dialog.cancel' | 'dev.app.overview.expires' | 'dev.app.overview.created' | 'dev.app.overview.visibilityToggle.hide' | 'dev.app.overview.visibilityToggle.show' | 'search.loading' | 'search.noResults.title' | 'search.
|
|
2
|
+
export type TranslationKey = 'dev.newApp' | 'dev.newApp.text' | 'dev.sidebar.header' | 'dev.sidebar.footer.text' | 'dev.create.app.dialog.appName.placeholder' | 'dev.create.app.dialog.appName.error' | 'dev.create.app.dialog.selectAPIs' | 'dev.create.app.dialog.description' | 'dev.create.app.dialog.description.placeholder' | 'dev.create.app.dialog.create' | 'dev.create.app.dialog.cancel' | 'dev.main.tab.appKeys' | 'dev.main.tab.logs' | 'dev.app.description.title' | 'dev.edit.description.dialog.title' | 'dev.edit.description.dialog.save' | 'dev.edit.description.dialog.cancel' | 'dev.edit.apis.dialog.selectedAPIs' | 'dev.app.key.create' | 'dev.create.key.dialog.title' | 'dev.create.key.dialog.create' | 'dev.create.key.dialog.cancel' | 'dev.app.edit' | 'dev.app.delete' | 'dev.edit.app.dialog.title' | 'dev.edit.app.dialog.save' | 'dev.edit.app.dialog.cancel' | 'dev.delete.app.dialog.title' | 'dev.delete.app.dialog.confirmation' | 'dev.delete.app.dialog.delete' | 'dev.delete.app.dialog.cancel' | 'dev.app.key.roll' | 'dev.roll.key.dialog.title' | 'dev.roll.key.dialog.apiKey' | 'dev.roll.key.dialog.expires' | 'dev.roll.key.dialog.confirmation' | 'dev.roll.key.dialog.cancel' | 'dev.roll.key.dialog.roll' | 'dev.update.key.dialog.title' | 'dev.update.key.dialog.update' | 'dev.update.key.dialog.cancel' | 'dev.app.key.api.name' | 'dev.app.key.api.status' | 'dev.app.key.api.edit' | 'dev.edit.apis.dialog.title' | 'dev.edit.apis.dialog.apiKey' | 'dev.edit.apis.dialog.save' | 'dev.edit.apis.dialog.cancel' | 'dev.select.placeholder' | 'dev.app.overview.status.pending' | 'dev.app.overview.status.approved' | 'dev.app.overview.status.revoked' | 'dev.app.overview.status' | 'dev.app.overview.non-production' | 'dev.app.overview.production' | 'dev.app.overview.clientId' | 'dev.app.overview.apiKey' | 'dev.app.key.revoke' | 'dev.revoke.key.dialog.title' | 'dev.revoke.key.dialog.apiKey' | 'dev.revoke.key.dialog.expires' | 'dev.revoke.key.dialog.confirmation' | 'dev.revoke.key.dialog.revoke' | 'dev.revoke.key.dialog.cancel' | 'dev.app.overview.expires' | 'dev.app.overview.created' | 'dev.app.overview.visibilityToggle.hide' | 'dev.app.overview.visibilityToggle.show' | 'search.loading' | 'search.noResults.title' | 'search.keys.navigate' | 'search.keys.select' | 'search.keys.exit' | 'search.label' | 'search.cancel' | 'search.recent' | 'search.navbar.label' | 'search.suggested' | 'search.showMore' | 'search.filter.title' | 'search.filter.reset' | 'search.filter.field.reset' | 'search.ai.thinkingText' | 'search.ai.resourcesFound' | 'search.aiButton' | 'search.ai.label' | 'toc.header' | 'footer.copyrightText' | 'page.homeButton' | 'page.forbidden.title' | 'page.notFound.title' | 'page.notFound.description' | 'page.lastUpdated.timeago' | 'page.lastUpdated.on' | 'catalog.filters.placeholder' | 'catalog.filters.title' | 'catalog.filters.clearAll' | 'catalog.filters.select.addFilter' | 'catalog.filters.select.all' | 'catalog.filters.done' | 'sidebar.menu.backLabel' | 'sidebar.actions.show' | 'sidebar.actions.hide' | 'sidebar.actions.changeLayout' | 'versionPicker.label' | 'versionPicker.unversioned' | 'codeSnippet.copy.buttonText' | 'codeSnippet.copy.tooltipText' | 'codeSnippet.copy.toasterText' | 'markdown.editPage.text' | 'feedback.settings.comment.submitText' | 'feedback.settings.comment.label' | 'feedback.settings.comment.send' | 'feedback.settings.comment.cancel' | 'feedback.settings.comment.satisfiedLabel' | 'feedback.settings.comment.neutralLabel' | 'feedback.settings.comment.dissatisfiedLabel' | 'feedback.settings.submitText' | 'feedback.settings.label' | 'feedback.settings.reasons.label' | 'feedback.settings.reasons.send' | 'feedback.settings.comment.likeLabel' | 'feedback.settings.comment.dislikeLabel' | 'feedback.sentiment.thumbUp' | 'feedback.sentiment.thumbDown' | 'feedback.settings.leftScaleLabel' | 'feedback.settings.rightScaleLabel' | 'codeSnippet.report.buttonText' | 'codeSnippet.report.tooltipText' | 'codeSnippet.report.label' | 'userMenu.login' | 'userMenu.logout' | 'userMenu.devOnboardingLabel' | 'mobileMenu.mainMenu' | 'mobileMenu.previous' | 'mobileMenu.products' | 'page.nextButton' | 'page.previousButton' | 'openapi.download.description.title' | 'openapi.info.title' | 'openapi.info.contact.url' | 'openapi.info.contact.name' | 'openapi.info.license' | 'openapi.info.termsOfService' | 'openapi.info.metadata.title' | 'openapi.key' | 'openapi.value' | 'openapi.enum' | 'openapi.items' | 'openapi.default' | 'openapi.variable' | 'openapi.variables' | 'openapi.actions.show' | 'openapi.actions.hide' | 'openapi.actions.more' | 'openapi.languages.title' | 'openapi.servers.title' | 'openapi.operations' | 'openapi.webhooks' | 'openapi.description' | 'openapi.badges.deprecated' | 'openapi.badges.required' | 'openapi.badges.webhook' | 'openapi.request' | 'openapi.path' | 'openapi.query' | 'openapi.cookie' | 'openapi.header' | 'openapi.body' | 'openapi.responses' | 'openapi.response' | 'openapi.callbacks' | 'openapi.callbackRequest' | 'openapi.callbackResponse' | 'openapi.payload' | 'openapi.discriminator' | 'openapi.contentType' | 'openapi.tryIt' | 'openapi.loading' | 'openapi.example' | 'openapi.examples' | 'openapi.additionalProperties' | 'openapi.patternProperties' | 'openapi.required' | 'openapi.recursive' | 'openapi.deprecated' | 'openapi.hideExample' | 'openapi.showExample' | 'openapi.expandAll' | 'openapi.collapseAll' | 'openapi.noResponseExample' | 'openapi.noRequestPayload' | 'openapi.hidePattern' | 'openapi.showPattern' | 'openapi.authorizationUrl' | 'openapi.tokenUrl' | 'openapi.refreshUrl' | 'openapi.scopes' | 'openapi.security' | 'openapi.httpAuthorizationScheme' | 'openapi.bearerFormat' | 'openapi.parameterName' | 'openapi.flowType' | 'openapi.connectUrl' | 'openapi.requiredScopes' | 'openapi.unsupportedLanguage' | 'openapi.failedToGenerateCodeSample' | 'graphql.queries' | 'graphql.mutations' | 'graphql.subscriptions' | 'graphql.directives' | 'graphql.objects' | 'graphql.interfaces' | 'graphql.unions' | 'graphql.enums' | 'graphql.inputs' | 'graphql.scalars' | 'graphql.arguments.label' | 'graphql.arguments.show' | 'graphql.arguments.hide' | 'graphql.arguments.here' | 'graphql.returnTypes.label' | 'graphql.returnTypes.show' | 'graphql.returnTypes.hide' | 'graphql.possibleTypes' | 'graphql.defaultValue' | 'graphql.deprecationReason' | 'graphql.implementedInterfaces' | 'graphql.nonNull' | 'graphql.required' | 'graphql.deprecated' | 'graphql.variables' | 'graphql.querySample' | 'graphql.mutationSample' | 'graphql.subscriptionSample' | 'graphql.responseSample' | 'graphql.locations' | 'graphql.sample' | 'graphql.referenced';
|
|
3
3
|
export type Locale = {
|
|
4
4
|
code: string;
|
|
5
5
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.1",
|
|
4
4
|
"description": "Shared UI components lib",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"theme",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"timeago.js": "4.0.2",
|
|
82
82
|
"i18next": "22.4.15",
|
|
83
83
|
"nprogress": "0.2.0",
|
|
84
|
-
"@redocly/config": "0.
|
|
84
|
+
"@redocly/config": "0.16.0"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"watch": "tsc -p tsconfig.build.json && (concurrently \"tsc -w -p tsconfig.build.json\" \"tsc-alias -w -p tsconfig.build.json\")",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
+
import { ReasonsSettingsSchema } from '@redocly/config';
|
|
4
5
|
|
|
5
6
|
import type { ReasonsProps } from '@redocly/theme/components/Feedback/Reasons';
|
|
6
7
|
|
|
@@ -30,11 +31,10 @@ export type MoodProps = {
|
|
|
30
31
|
neutralLabel?: string;
|
|
31
32
|
dissatisfiedLabel?: string;
|
|
32
33
|
};
|
|
33
|
-
reasons?: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
items: string[];
|
|
34
|
+
reasons?: ReasonsSettingsSchema & {
|
|
35
|
+
satisfied?: ReasonsSettingsSchema;
|
|
36
|
+
neutral?: ReasonsSettingsSchema;
|
|
37
|
+
dissatisfied?: ReasonsSettingsSchema;
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
className?: string;
|
|
@@ -49,6 +49,20 @@ export function Mood({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
49
49
|
const { useTranslate } = useThemeHooks();
|
|
50
50
|
const { translate } = useTranslate();
|
|
51
51
|
|
|
52
|
+
const checkIfShouldDisplayReasons = (score: string) => {
|
|
53
|
+
if (!score || !reasonsSettings) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const scoreSpecificReasonsSettings = reasonsSettings[score as MOOD_STATES];
|
|
58
|
+
|
|
59
|
+
if (typeof scoreSpecificReasonsSettings?.hide === 'undefined') {
|
|
60
|
+
return !reasonsSettings.hide;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return !scoreSpecificReasonsSettings?.hide;
|
|
64
|
+
};
|
|
65
|
+
|
|
52
66
|
const renderCommentLabel = (score: string) => {
|
|
53
67
|
if (!commentSettings || commentSettings?.hide === true) return '';
|
|
54
68
|
|
|
@@ -73,7 +87,29 @@ export function Mood({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
73
87
|
}
|
|
74
88
|
};
|
|
75
89
|
|
|
76
|
-
const
|
|
90
|
+
const renderReasonsLabel = (score: string) => {
|
|
91
|
+
if (!reasonsSettings || reasonsSettings?.hide === true) return '';
|
|
92
|
+
|
|
93
|
+
return reasonsSettings[score as MOOD_STATES]?.label;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const resolveReasonsItems = (score: string) => {
|
|
97
|
+
if (!reasonsSettings) {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const defaultReasonsItems = reasonsSettings?.items || [];
|
|
102
|
+
|
|
103
|
+
return defaultReasonsItems.concat(reasonsSettings[score as MOOD_STATES]?.items ?? []);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const resolveReasonsComponent = (score: string) => {
|
|
107
|
+
if (!reasonsSettings || reasonsSettings?.hide === true) return 'checkbox';
|
|
108
|
+
|
|
109
|
+
return reasonsSettings[score as MOOD_STATES]?.component;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const displayReasons = checkIfShouldDisplayReasons(score);
|
|
77
113
|
const displayComment = !!(score && !commentSettings?.hide);
|
|
78
114
|
const displaySubmitBnt = !!(score && (displayReasons || displayComment));
|
|
79
115
|
|
|
@@ -160,9 +196,9 @@ export function Mood({ settings, onSubmit, className }: MoodProps): JSX.Element
|
|
|
160
196
|
{displayReasons && (
|
|
161
197
|
<Reasons
|
|
162
198
|
settings={{
|
|
163
|
-
label:
|
|
164
|
-
items:
|
|
165
|
-
component:
|
|
199
|
+
label: renderReasonsLabel(score),
|
|
200
|
+
items: resolveReasonsItems(score),
|
|
201
|
+
component: resolveReasonsComponent(score),
|
|
166
202
|
}}
|
|
167
203
|
onChange={setReasons}
|
|
168
204
|
/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { useEffect } from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
|
+
import { ReasonsSettingsSchema } from '@redocly/config';
|
|
4
5
|
|
|
5
6
|
import type { ReasonsProps } from '@redocly/theme/components/Feedback/Reasons';
|
|
6
7
|
|
|
@@ -22,11 +23,9 @@ export type SentimentProps = {
|
|
|
22
23
|
likeLabel?: string;
|
|
23
24
|
dislikeLabel?: string;
|
|
24
25
|
};
|
|
25
|
-
reasons?: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
component?: string;
|
|
29
|
-
items: string[];
|
|
26
|
+
reasons?: ReasonsSettingsSchema & {
|
|
27
|
+
like?: ReasonsSettingsSchema;
|
|
28
|
+
dislike?: ReasonsSettingsSchema;
|
|
30
29
|
};
|
|
31
30
|
};
|
|
32
31
|
className?: string;
|
|
@@ -41,7 +40,32 @@ export function Sentiment({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
41
40
|
const { useTranslate } = useThemeHooks();
|
|
42
41
|
const { translate } = useTranslate();
|
|
43
42
|
|
|
44
|
-
const
|
|
43
|
+
const getScoreSpecificReasonSettings = (score: number) => {
|
|
44
|
+
switch (score) {
|
|
45
|
+
case 1:
|
|
46
|
+
return reasonsSettings?.like;
|
|
47
|
+
case -1:
|
|
48
|
+
return reasonsSettings?.dislike;
|
|
49
|
+
default:
|
|
50
|
+
return reasonsSettings;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const checkIfShouldDisplayReasons = (score: number) => {
|
|
55
|
+
if (!score || !reasonsSettings) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const scoreSpecificReasonsSettings = getScoreSpecificReasonSettings(score);
|
|
60
|
+
|
|
61
|
+
if (typeof scoreSpecificReasonsSettings?.hide === 'undefined') {
|
|
62
|
+
return !reasonsSettings.hide;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return !scoreSpecificReasonsSettings?.hide;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const displayReasons = checkIfShouldDisplayReasons(score);
|
|
45
69
|
const displayComment = !!(score && !commentSettings?.hide);
|
|
46
70
|
const displaySubmitBnt = !!(score && (displayReasons || displayComment));
|
|
47
71
|
|
|
@@ -52,6 +76,25 @@ export function Sentiment({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
52
76
|
: (commentSettings && commentSettings.dislikeLabel) ||
|
|
53
77
|
translate('feedback.settings.comment.dislikeLabel', 'What can we improve?');
|
|
54
78
|
|
|
79
|
+
const renderReasonsLabel = (score: number) => {
|
|
80
|
+
const scoreSpecificReasonSettings = getScoreSpecificReasonSettings(score);
|
|
81
|
+
|
|
82
|
+
return scoreSpecificReasonSettings?.label;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const resolveReasonsItems = (score: number) => {
|
|
86
|
+
const defaultReasonsItems = reasonsSettings?.items || [];
|
|
87
|
+
const scoreSpecificReasonSettings = getScoreSpecificReasonSettings(score);
|
|
88
|
+
|
|
89
|
+
return defaultReasonsItems.concat(scoreSpecificReasonSettings?.items ?? []);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const resolveReasonsComponent = (score: number) => {
|
|
93
|
+
const scoreSpecificReasonSettings = getScoreSpecificReasonSettings(score);
|
|
94
|
+
|
|
95
|
+
return scoreSpecificReasonSettings?.component;
|
|
96
|
+
};
|
|
97
|
+
|
|
55
98
|
const onSubmitSentimentForm = () => {
|
|
56
99
|
onSubmit({
|
|
57
100
|
score,
|
|
@@ -126,9 +169,9 @@ export function Sentiment({ settings, onSubmit, className }: SentimentProps): JS
|
|
|
126
169
|
{displayReasons && (
|
|
127
170
|
<Reasons
|
|
128
171
|
settings={{
|
|
129
|
-
label:
|
|
130
|
-
items:
|
|
131
|
-
component:
|
|
172
|
+
label: renderReasonsLabel(score),
|
|
173
|
+
items: resolveReasonsItems(score),
|
|
174
|
+
component: resolveReasonsComponent(score),
|
|
132
175
|
}}
|
|
133
176
|
onChange={setReasons}
|
|
134
177
|
/>
|
|
@@ -198,10 +198,6 @@ export function SearchDialog({ onClose, className }: SearchDialogProps): JSX.Ele
|
|
|
198
198
|
) : (
|
|
199
199
|
<SearchMessage data-translation-key="search.noResults">
|
|
200
200
|
<b>{translate('search.noResults.title', 'No results')}</b>
|
|
201
|
-
{translate(
|
|
202
|
-
'search.noResults.description',
|
|
203
|
-
'Prease, try with a different query.',
|
|
204
|
-
)}
|
|
205
201
|
</SearchMessage>
|
|
206
202
|
)
|
|
207
203
|
) : (
|
package/src/core/types/l10n.ts
CHANGED