@redocly/theme 0.25.3 → 0.27.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.
Files changed (72) hide show
  1. package/lib/components/Feedback/Comment.d.ts +1 -1
  2. package/lib/components/Feedback/Comment.js +28 -9
  3. package/lib/components/Feedback/Emotions.js +8 -25
  4. package/lib/components/Feedback/Feedback.js +6 -0
  5. package/lib/components/Feedback/Mood.js +127 -47
  6. package/lib/components/Feedback/Rating.d.ts +1 -0
  7. package/lib/components/Feedback/Rating.js +81 -42
  8. package/lib/components/Feedback/Reasons.d.ts +1 -1
  9. package/lib/components/Feedback/Reasons.js +4 -16
  10. package/lib/components/Feedback/Scale.d.ts +4 -0
  11. package/lib/components/Feedback/Scale.js +178 -0
  12. package/lib/components/Feedback/Sentiment.js +105 -35
  13. package/lib/components/Feedback/Stars.d.ts +8 -0
  14. package/lib/components/Feedback/Stars.js +54 -0
  15. package/lib/components/Feedback/Thumbs.d.ts +2 -6
  16. package/lib/components/Feedback/Thumbs.js +9 -46
  17. package/lib/components/Feedback/index.d.ts +1 -0
  18. package/lib/components/Feedback/index.js +3 -1
  19. package/lib/components/Feedback/types.d.ts +27 -6
  20. package/lib/components/Feedback/useReportDialog.js +3 -1
  21. package/lib/components/Markdown/MarkdownLayout.js +1 -0
  22. package/lib/config.d.ts +7 -4
  23. package/lib/config.js +3 -2
  24. package/lib/icons/CheckboxIcon/CheckboxIcon.js +3 -3
  25. package/lib/icons/ColorModeIcon/ColorModeIcon.js +4 -4
  26. package/lib/icons/DissatisfiedIcon/DissatisfiedIcon.js +5 -5
  27. package/lib/icons/NeutralIcon/NeutralIcon.js +5 -5
  28. package/lib/icons/RadioCheckButtonIcon/RadioCheckButtonIcon.d.ts +4 -0
  29. package/lib/icons/RadioCheckButtonIcon/RadioCheckButtonIcon.js +16 -0
  30. package/lib/icons/RadioCheckButtonIcon/index.d.ts +1 -0
  31. package/lib/icons/RadioCheckButtonIcon/index.js +18 -0
  32. package/lib/icons/SatisfiedIcon/SatisfiedIcon.js +5 -5
  33. package/lib/icons/ThumbDownIcon/ThumbDownIcon.d.ts +4 -0
  34. package/lib/icons/ThumbDownIcon/ThumbDownIcon.js +14 -0
  35. package/lib/icons/ThumbDownIcon/index.d.ts +1 -0
  36. package/lib/icons/ThumbDownIcon/index.js +18 -0
  37. package/lib/icons/ThumbUpIcon/ThumbUpIcon.d.ts +4 -0
  38. package/lib/icons/ThumbUpIcon/ThumbUpIcon.js +14 -0
  39. package/lib/icons/ThumbUpIcon/index.d.ts +1 -0
  40. package/lib/icons/ThumbUpIcon/index.js +18 -0
  41. package/lib/types/portal/src/shared/constants.d.ts +2 -1
  42. package/lib/types/portal/src/shared/constants.js +1 -0
  43. package/lib/types/portal/src/shared/types/feedback.d.ts +2 -2
  44. package/package.json +2 -2
  45. package/src/components/Feedback/Comment.tsx +53 -20
  46. package/src/components/Feedback/Emotions.tsx +11 -32
  47. package/src/components/Feedback/Feedback.tsx +13 -1
  48. package/src/components/Feedback/Mood.tsx +177 -80
  49. package/src/components/Feedback/Rating.tsx +106 -79
  50. package/src/components/Feedback/Reasons.tsx +3 -19
  51. package/src/components/Feedback/Scale.tsx +229 -0
  52. package/src/components/Feedback/Sentiment.tsx +150 -56
  53. package/src/components/Feedback/Stars.tsx +51 -0
  54. package/src/components/Feedback/Thumbs.tsx +9 -106
  55. package/src/components/Feedback/index.ts +1 -0
  56. package/src/components/Feedback/types.ts +24 -5
  57. package/src/components/Feedback/useReportDialog.ts +3 -1
  58. package/src/components/Markdown/MarkdownLayout.tsx +1 -0
  59. package/src/config.ts +3 -2
  60. package/src/icons/CheckboxIcon/CheckboxIcon.tsx +4 -4
  61. package/src/icons/ColorModeIcon/ColorModeIcon.tsx +4 -4
  62. package/src/icons/DissatisfiedIcon/DissatisfiedIcon.tsx +5 -15
  63. package/src/icons/NeutralIcon/NeutralIcon.tsx +5 -14
  64. package/src/icons/RadioCheckButtonIcon/RadioCheckButtonIcon.tsx +19 -0
  65. package/src/icons/RadioCheckButtonIcon/index.ts +1 -0
  66. package/src/icons/SatisfiedIcon/SatisfiedIcon.tsx +5 -9
  67. package/src/icons/ThumbDownIcon/ThumbDownIcon.tsx +15 -0
  68. package/src/icons/ThumbDownIcon/index.ts +1 -0
  69. package/src/icons/ThumbUpIcon/ThumbUpIcon.tsx +15 -0
  70. package/src/icons/ThumbUpIcon/index.ts +1 -0
  71. package/src/types/portal/src/shared/constants.ts +1 -0
  72. package/src/types/portal/src/shared/types/feedback.ts +2 -2
@@ -0,0 +1,178 @@
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.Scale = exports.MAX_SCALE = void 0;
30
+ const React = __importStar(require("react"));
31
+ const react_1 = require("react");
32
+ const styled_components_1 = __importDefault(require("styled-components"));
33
+ const hooks_1 = require("../../mocks/hooks");
34
+ const media_css_1 = require("../../mocks/media-css");
35
+ const Feedback_1 = require("../../components/Feedback");
36
+ const RadioCheckButtonIcon_1 = require("../../icons/RadioCheckButtonIcon");
37
+ const components_1 = require("../../components");
38
+ exports.MAX_SCALE = 10;
39
+ const Scale = ({ settings, onSubmit, className }) => {
40
+ const { label, submitText, leftScaleLabel, rightScaleLabel, comment: commentSettings, reasons: reasonsSettings, } = settings || {};
41
+ const [score, setScore] = React.useState(0);
42
+ const [isSubmitted, setIsSubmitted] = React.useState(false);
43
+ const [comment, setComment] = React.useState('');
44
+ const [reasons, setReasons] = React.useState([]);
45
+ const { translate } = (0, hooks_1.useTranslate)();
46
+ const scaleOptions = [];
47
+ for (let i = 1; i <= exports.MAX_SCALE; i++) {
48
+ scaleOptions.push(React.createElement(ScaleOption, { id: `scale-option-${i}`, key: `scale-option-${i}`, onClick: () => setScore(i), className: `${score === i ? 'active' : ''}` }, i));
49
+ }
50
+ const displayReasons = !!score && (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.enable);
51
+ const displayComment = !!score && (commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.enable);
52
+ const displaySubmitBnt = !!score && (displayReasons || displayComment);
53
+ const onSubmitScaleForm = () => {
54
+ onSubmit({
55
+ score,
56
+ comment,
57
+ reasons,
58
+ max: exports.MAX_SCALE,
59
+ });
60
+ setIsSubmitted(true);
61
+ };
62
+ (0, react_1.useEffect)(() => {
63
+ if (score && !displayComment && !displayReasons) {
64
+ onSubmitScaleForm();
65
+ }
66
+ // eslint-disable-next-line react-hooks/exhaustive-deps
67
+ }, [score, displayComment, displayReasons]);
68
+ if (isSubmitted) {
69
+ return (React.createElement(Wrapper, null,
70
+ React.createElement(Label, { "data-translation-key": "theme.feedback.settings.submitText" }, translate('theme.feedback.settings.submitText', submitText || 'Thank you for helping improve our documentation!')),
71
+ React.createElement(RadioCheckButtonIcon_1.RadioCheckButtonIcon, null)));
72
+ }
73
+ return (React.createElement(Wrapper, { "data-component-name": "Feedback/Scale", className: className },
74
+ React.createElement(StyledForm, null,
75
+ React.createElement(StyledFormMandatoryFields, null,
76
+ React.createElement(Label, { "data-translation-key": "theme.feedback.settings.label" }, translate('theme.feedback.settings.label', label || 'How helpful was this page?')),
77
+ React.createElement(ScaleWrapper, null, scaleOptions),
78
+ React.createElement(SubLabelContainer, null,
79
+ React.createElement(SubLabel, { "data-translation-key": "theme.feedback.settings.leftScaleLabel" }, translate('theme.feedback.settings.leftScaleLabel', leftScaleLabel || 'Not helpful at all')),
80
+ React.createElement(SubLabel, { "data-translation-key": "theme.feedback.settings.rightScaleLabel" }, translate('theme.feedback.settings.rightScaleLabel', rightScaleLabel || 'Extremely helpful')))),
81
+ React.createElement(StyledFormOptionalFields, null,
82
+ displayReasons && (React.createElement(Feedback_1.Reasons, { settings: {
83
+ label: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.label,
84
+ items: (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.items) || [],
85
+ multi: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.multi,
86
+ }, onChange: setReasons })),
87
+ displayComment && (React.createElement(Feedback_1.Comment, { standAlone: false, onSubmit: ({ comment }) => setComment(comment), settings: { label: commentSettings.label } }))),
88
+ displaySubmitBnt && (React.createElement(ButtonsContainer, null,
89
+ React.createElement(SubmitButton, { onClick: onSubmitScaleForm }, "Submit"))))));
90
+ };
91
+ exports.Scale = Scale;
92
+ const Wrapper = styled_components_1.default.div `
93
+ font-family: var(--font-family-base);
94
+ display: flex;
95
+ justify-content: space-between;
96
+ align-items: center;
97
+ padding: 16px 24px;
98
+ width: 502px;
99
+ border-radius: 8px;
100
+ background: var(--bg-raised);
101
+
102
+ @media screen and (max-width: ${media_css_1.breakpoints.small}) {
103
+ width: 100%;
104
+ }
105
+ `;
106
+ const Label = styled_components_1.default.h3 `
107
+ margin-right: 15px;
108
+ font-family: var(--h4-font-family);
109
+ font-weight: var(--h4-font-weight);
110
+ font-size: var(--h4-font-size);
111
+ line-height: var(--h4-line-height);
112
+ color: var(--h3-text-color);
113
+ `;
114
+ const SubLabelContainer = styled_components_1.default.div `
115
+ display: flex;
116
+ justify-content: space-between;
117
+ width: 100%;
118
+ flex-direction: row;
119
+ `;
120
+ const SubLabel = styled_components_1.default.h3 `
121
+ font-family: var(--h4-font-family);
122
+ font-weight: var(--h4-font-weight);
123
+ font-size: var(--h4-font-size);
124
+ line-height: var(--h4-line-height);
125
+ color: var(--text-description);
126
+ `;
127
+ const StyledForm = styled_components_1.default.form `
128
+ width: 100%;
129
+ `;
130
+ const SubmitButton = (0, styled_components_1.default)(components_1.Button).attrs(() => ({
131
+ color: 'primary',
132
+ })) `
133
+ width: 100px;
134
+ margin-left: 0;
135
+ margin-right: 0;
136
+ `;
137
+ const ButtonsContainer = styled_components_1.default.div `
138
+ display: flex;
139
+ justify-content: end;
140
+ `;
141
+ const StyledFormOptionalFields = styled_components_1.default.div `
142
+ display: flex;
143
+ flex-flow: column;
144
+ `;
145
+ const StyledFormMandatoryFields = styled_components_1.default.div `
146
+ display: flex;
147
+ flex-direction: column;
148
+ align-items: center;
149
+ `;
150
+ const ScaleOption = styled_components_1.default.div `
151
+ cursor: pointer;
152
+ border-radius: 6px;
153
+ background: var(--bg-overlay);
154
+ display: flex;
155
+ padding: 8px 16px;
156
+ flex-direction: column;
157
+ justify-content: center;
158
+ align-items: center;
159
+ &.active {
160
+ border: 1px solid var(--text-primary);
161
+ }
162
+
163
+ @media screen and (max-width: ${media_css_1.breakpoints.small}) {
164
+ padding: 4px 8px;
165
+ }
166
+ `;
167
+ const ScaleWrapper = styled_components_1.default.div `
168
+ display: flex;
169
+ justify-content: space-between;
170
+ flex-direction: row;
171
+ gap: 4px;
172
+ width: 100%;
173
+
174
+ @media screen and (max-width: ${media_css_1.breakpoints.small}) {
175
+ gap: 1px;
176
+ }
177
+ `;
178
+ //# sourceMappingURL=Scale.js.map
@@ -28,10 +28,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Sentiment = void 0;
30
30
  const React = __importStar(require("react"));
31
+ const react_1 = require("react");
31
32
  const styled_components_1 = __importDefault(require("styled-components"));
32
33
  const Feedback_1 = require("../../components/Feedback");
33
34
  const Thumbs_1 = require("../../components/Feedback/Thumbs");
34
35
  const hooks_1 = require("../../mocks/hooks");
36
+ const components_1 = require("../../components");
37
+ const RadioCheckButtonIcon_1 = require("../../icons/RadioCheckButtonIcon");
38
+ const media_css_1 = require("../../mocks/media-css");
35
39
  const Sentiment = ({ settings, onSubmit, className }) => {
36
40
  const { label, submitText, comment: commentSettings, reasons: reasonsSettings } = settings || {};
37
41
  const [isSubmitted, setIsSubmitted] = React.useState(false);
@@ -39,56 +43,122 @@ const Sentiment = ({ settings, onSubmit, className }) => {
39
43
  const [comment, setComment] = React.useState('');
40
44
  const [reasons, setReasons] = React.useState([]);
41
45
  const { translate } = (0, hooks_1.useTranslate)();
42
- if (score && (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.enable) && !reasons.length) {
43
- const { label: reasonsLabel, items, multi } = reasonsSettings;
44
- const buttonText = (commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.enable) ? 'Next' : 'Send';
45
- return (React.createElement(Feedback_1.Reasons, { onSubmit: ({ reasons }) => setReasons(reasons), settings: { label: reasonsLabel, items, multi, buttonText } }));
46
- }
47
- if (score && (commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.enable) && !comment) {
48
- const commentLabel = score === 1
49
- ? translate('theme.feedback.settings.comment.likeLabel', commentSettings.likeLabel || 'What was most helpful?')
50
- : translate('theme.feedback.settings.comment.dislikeLabel', commentSettings.dislikeLabel || 'What can we improve?');
51
- return (React.createElement(Feedback_1.Comment, { onSubmit: ({ comment }) => setComment(comment), settings: { label: commentLabel } }));
52
- }
53
- if (score) {
54
- if (!isSubmitted) {
55
- onSubmit({
56
- score,
57
- comment,
58
- reasons,
59
- });
60
- setIsSubmitted(true);
46
+ const displayReasons = !!score && (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.enable);
47
+ const displayComment = !!score && (commentSettings === null || commentSettings === void 0 ? void 0 : commentSettings.enable);
48
+ const displaySubmitBnt = !!score && (displayReasons || displayComment);
49
+ const commentLabel = score === 1
50
+ ? translate('theme.feedback.settings.comment.likeLabel', (commentSettings && commentSettings.likeLabel) || 'What was most helpful?')
51
+ : translate('theme.feedback.settings.comment.dislikeLabel', (commentSettings && commentSettings.dislikeLabel) || 'What can we improve?');
52
+ const onSubmitSentimentForm = () => {
53
+ onSubmit({
54
+ score,
55
+ comment,
56
+ reasons,
57
+ });
58
+ setIsSubmitted(true);
59
+ };
60
+ (0, react_1.useEffect)(() => {
61
+ if (score && !displayComment && !displayReasons) {
62
+ onSubmitSentimentForm();
61
63
  }
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
65
+ }, [score, displayComment, displayReasons]);
66
+ if (isSubmitted) {
62
67
  return (React.createElement(Wrapper, null,
63
- React.createElement(Label, { "data-translation-key": "theme.feedback.settings.submitText" }, translate('theme.feedback.settings.submitText', submitText || 'Thank you for helping improve our documentation!'))));
68
+ React.createElement(Label, { "data-translation-key": "theme.feedback.settings.submitText" }, translate('theme.feedback.settings.submitText', submitText || 'Thank you for helping improve our documentation!')),
69
+ React.createElement(RadioCheckButtonIcon_1.RadioCheckButtonIcon, null)));
64
70
  }
65
71
  return (React.createElement(Wrapper, { "data-component-name": "Feedback/Sentiment", className: className },
66
- React.createElement(Label, { "data-translation-key": "theme.feedback.settings.label" }, translate('theme.feedback.settings.label', label || 'Was this page helpful?')),
67
- React.createElement(Vote, { onClick: () => {
68
- setScore(1);
69
- } },
70
- React.createElement(Thumbs_1.ThumbUp, { text: "Yes" })),
71
- React.createElement(Vote, { onClick: () => {
72
- setScore(-1);
73
- } },
74
- React.createElement(Thumbs_1.ThumbDown, null))));
72
+ React.createElement(StyledForm, null,
73
+ React.createElement(StyledFormMandatoryFields, null,
74
+ React.createElement(Label, { "data-translation-key": "theme.feedback.settings.label" }, translate('theme.feedback.settings.label', label || 'Was this page helpful?')),
75
+ React.createElement(StyledMandatoryFieldContainer, null,
76
+ React.createElement(React.Fragment, null,
77
+ React.createElement(Vote, { className: `${score === 1 ? 'active' : ''}`, onClick: () => {
78
+ setScore(1);
79
+ } },
80
+ React.createElement(Thumbs_1.ThumbUp, null)),
81
+ React.createElement(Vote, { className: `${score === -1 ? 'active' : ''}`, onClick: () => {
82
+ setScore(-1);
83
+ } },
84
+ React.createElement(Thumbs_1.ThumbDown, null))))),
85
+ React.createElement(StyledFormOptionalFields, null,
86
+ displayReasons && (React.createElement(Feedback_1.Reasons, { settings: {
87
+ label: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.label,
88
+ items: (reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.items) || [],
89
+ multi: reasonsSettings === null || reasonsSettings === void 0 ? void 0 : reasonsSettings.multi,
90
+ }, onChange: setReasons })),
91
+ displayComment && (React.createElement(Feedback_1.Comment, { standAlone: false, onSubmit: ({ comment }) => setComment(comment), settings: { label: commentLabel } }))),
92
+ displaySubmitBnt && (React.createElement(ButtonsContainer, null,
93
+ React.createElement(SubmitButton, { onClick: onSubmitSentimentForm }, "Submit"))))));
75
94
  };
76
95
  exports.Sentiment = Sentiment;
77
96
  const Wrapper = styled_components_1.default.div `
78
97
  font-family: var(--font-family-base);
79
98
  display: flex;
99
+ justify-content: space-between;
80
100
  align-items: center;
101
+ padding: 16px 24px;
102
+ width: 424px;
103
+ border-radius: 8px;
104
+ background: var(--bg-raised);
105
+
106
+ @media screen and (max-width: ${media_css_1.breakpoints.small}) {
107
+ width: 100%;
108
+ }
81
109
  `;
82
110
  const Label = styled_components_1.default.h3 `
83
- font-family: var(--h3-font-family);
84
- font-weight: var(--h3-font-weight);
85
- font-size: var(--h3-font-size);
86
- line-height: var(--h3-line-height);
87
- color: var(--h3-text-color);
88
111
  margin-right: 15px;
112
+ font-family: var(--h4-font-family);
113
+ font-weight: var(--h4-font-weight);
114
+ font-size: var(--h4-font-size);
115
+ line-height: var(--h4-line-height);
116
+ color: var(--h3-text-color);
89
117
  `;
90
118
  const Vote = styled_components_1.default.div `
119
+ height: 32px;
120
+ width: 32px;
91
121
  cursor: pointer;
92
- margin: 0 10px;
122
+ display: flex;
123
+ align-items: center;
124
+ flex-flow: row-reverse;
125
+ color: var(--text-description);
126
+ &.active {
127
+ color: var(--text-primary);
128
+ }
129
+ &:hover {
130
+ color: var(--text-primary);
131
+ svg {
132
+ > g {
133
+ fill: var(--text-primary);
134
+ }
135
+ }
136
+ }
137
+ `;
138
+ const StyledForm = styled_components_1.default.form `
139
+ width: 100%;
140
+ `;
141
+ const StyledFormOptionalFields = styled_components_1.default.div `
142
+ display: flex;
143
+ flex-flow: column;
144
+ `;
145
+ const StyledFormMandatoryFields = styled_components_1.default.div `
146
+ display: flex;
147
+ justify-content: space-between;
148
+ `;
149
+ const StyledMandatoryFieldContainer = styled_components_1.default.div `
150
+ display: flex;
151
+ align-items: center;
152
+ `;
153
+ const SubmitButton = (0, styled_components_1.default)(components_1.Button).attrs(() => ({
154
+ color: 'primary',
155
+ })) `
156
+ width: 100px;
157
+ margin-left: 0;
158
+ margin-right: 0;
159
+ `;
160
+ const ButtonsContainer = styled_components_1.default.div `
161
+ display: flex;
162
+ justify-content: end;
93
163
  `;
94
164
  //# sourceMappingURL=Sentiment.js.map
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export type StarsProps = {
3
+ max?: number;
4
+ name?: string;
5
+ value?: number;
6
+ onChange: (value: number) => void;
7
+ };
8
+ export declare const Stars: ({ max, onChange, value }: StarsProps) => JSX.Element;
@@ -0,0 +1,54 @@
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.Stars = void 0;
30
+ const React = __importStar(require("react"));
31
+ const styled_components_1 = __importDefault(require("styled-components"));
32
+ const Stars = ({ max = 5, onChange, value }) => {
33
+ const [hovered, setHovered] = React.useState(value || 0);
34
+ const stars = [];
35
+ for (let index = 1; index <= max; index++) {
36
+ stars.push(React.createElement(Star, { key: index, onClick: () => onChange(index), onMouseOver: () => setHovered(index), onMouseLeave: () => !value && setHovered(0) },
37
+ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 20 20" }, hovered < index ? (React.createElement("g", { fill: "#e8c002" },
38
+ React.createElement("path", { d: "M20 7h-7L10 .5 7 7H0l5.46 5.47-1.64 7 6.18-3.7 6.18 3.73-1.63-7zm-10 6.9-3.76 2.27 1-4.28L3.5 8.5h4.61L10 4.6l1.9 3.9h4.6l-3.73 3.4 1 4.28z" }))) : (React.createElement("g", { fill: "#e8c002" },
39
+ React.createElement("path", { d: "M20 7h-7L10 .5 7 7H0l5.46 5.47-1.64 7 6.18-3.7 6.18 3.73-1.63-7z" }))))));
40
+ }
41
+ return React.createElement(StarsWrapper, null, stars);
42
+ };
43
+ exports.Stars = Stars;
44
+ const StarsWrapper = styled_components_1.default.div `
45
+ display: flex;
46
+ gap: 8px;
47
+ flex-direction: row;
48
+ align-items: center;
49
+ `;
50
+ const Star = styled_components_1.default.span `
51
+ cursor: pointer;
52
+ gap: 8px;
53
+ `;
54
+ //# sourceMappingURL=Stars.js.map
@@ -1,7 +1,3 @@
1
1
  /// <reference types="react" />
2
- export declare const ThumbUp: ({ text }: {
3
- text?: string | undefined;
4
- }) => JSX.Element;
5
- export declare const ThumbDown: ({ text }: {
6
- text?: string | undefined;
7
- }) => JSX.Element;
2
+ export declare const ThumbUp: () => JSX.Element;
3
+ export declare const ThumbDown: () => JSX.Element;
@@ -29,58 +29,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.ThumbDown = exports.ThumbUp = void 0;
30
30
  const React = __importStar(require("react"));
31
31
  const styled_components_1 = __importDefault(require("styled-components"));
32
- const hooks_1 = require("../../mocks/hooks");
33
- const ThumbUp = ({ text }) => {
34
- const { translate } = (0, hooks_1.useTranslate)();
35
- return (React.createElement(Wrapper, { style: { alignItems: 'normal' } },
36
- React.createElement(Icon, null,
37
- React.createElement("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", x: "0px", y: "0px", viewBox: "0 0 512 512" },
38
- React.createElement("g", null,
39
- React.createElement("g", null,
40
- React.createElement("g", null,
41
- React.createElement("path", { d: "M495.736,290.773C509.397,282.317,512,269.397,512,260.796c0-22.4-18.253-47.462-42.667-47.462H349.918\n c-4.284-0.051-25.651-1.51-25.651-25.6c0-4.71-3.814-8.533-8.533-8.533s-8.533,3.823-8.533,8.533\n c0,33.749,27.913,42.667,42.667,42.667h119.467c14.182,0,25.6,16.631,25.6,30.396c0,4.437,0,17.946-26.53,20.855\n c-4.506,0.495-7.834,4.42-7.586,8.951c0.239,4.523,3.985,8.064,8.516,8.064c14.114,0,25.6,11.486,25.6,25.6\n s-11.486,25.6-25.6,25.6h-17.067c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c14.114,0,25.6,11.486,25.6,25.6\n s-11.486,25.6-25.6,25.6h-25.6c-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c8.934,0,17.067,8.132,17.067,17.067\n c0,8.61-8.448,17.067-17.067,17.067h-128c-35.627,0-48.444-7.074-63.292-15.258c-12.553-6.921-26.786-14.763-54.963-18.79\n c-4.668-0.674-8.994,2.577-9.66,7.236c-0.666,4.668,2.569,8.994,7.236,9.66c25.105,3.584,37.325,10.325,49.152,16.845\n c15.497,8.542,31.505,17.374,71.526,17.374h128c17.869,0,34.133-16.273,34.133-34.133c0-6.229-1.775-12.134-4.83-17.229\n c21.794-1.877,38.963-20.224,38.963-42.505c0-10.829-4.062-20.736-10.735-28.271C500.42,358.212,512,342.571,512,324.267\n C512,310.699,505.634,298.59,495.736,290.773z" }),
42
- React.createElement("path", { d: "M76.8,443.733c9.412,0,17.067-7.654,17.067-17.067S86.212,409.6,76.8,409.6c-9.412,0-17.067,7.654-17.067,17.067\n S67.388,443.733,76.8,443.733z" }),
43
- React.createElement("path", { d: "M179.2,247.467c25.353,0,57.429-28.297,74.3-45.167c36.634-36.634,36.634-82.167,36.634-151.1\n c0-5.342,3.191-8.533,8.533-8.533c29.508,0,42.667,13.158,42.667,42.667v102.4c0,4.71,3.814,8.533,8.533,8.533\n s8.533-3.823,8.533-8.533v-102.4c0-39.083-20.659-59.733-59.733-59.733c-14.831,0-25.6,10.769-25.6,25.6\n c0,66.978,0,107.401-31.633,139.034C216.661,215.006,192.811,230.4,179.2,230.4c-4.719,0-8.533,3.823-8.533,8.533\n S174.481,247.467,179.2,247.467z" }),
44
- React.createElement("path", { d: "M145.067,213.333H8.533c-4.719,0-8.533,3.823-8.533,8.533v256c0,4.71,3.814,8.533,8.533,8.533h136.533\n c4.719,0,8.533-3.823,8.533-8.533v-256C153.6,217.156,149.786,213.333,145.067,213.333z M136.533,469.333H17.067V230.4h119.467\n V469.333z" })))))),
45
- React.createElement("span", null, translate('theme.feedback.sentiment.thumbUp', text || 'Yes'))));
32
+ const ThumbDownIcon_1 = require("../../icons/ThumbDownIcon");
33
+ const ThumbUpIcon_1 = require("../../icons/ThumbUpIcon");
34
+ const ThumbUp = () => {
35
+ return (React.createElement(Wrapper, null,
36
+ React.createElement(ThumbUpIcon_1.ThumbUpIcon, null)));
46
37
  };
47
38
  exports.ThumbUp = ThumbUp;
48
- const ThumbDown = ({ text }) => {
49
- const { translate } = (0, hooks_1.useTranslate)();
50
- return (React.createElement(Wrapper, { style: { alignItems: 'end' } },
51
- React.createElement(Icon, null,
52
- React.createElement("svg", { version: "1.1", xmlns: "http://www.w3.org/2000/svg", x: "0px", y: "0px", viewBox: "0 0 512 512" },
53
- React.createElement("g", null,
54
- React.createElement("g", null,
55
- React.createElement("g", null,
56
- React.createElement("path", { d: "M76.8,247.467c9.412,0,17.067-7.654,17.067-17.067c0-9.412-7.654-17.067-17.067-17.067\n\t\t\t\tc-9.412,0-17.067,7.654-17.067,17.067C59.733,239.812,67.388,247.467,76.8,247.467z" }),
57
- React.createElement("path", { d: "M495.736,221.227C505.634,213.41,512,201.301,512,187.733c0-18.295-11.58-33.946-27.802-39.996\n\t\t\t\tc6.673-7.535,10.735-17.434,10.735-28.271c0-22.281-17.169-40.627-38.963-42.505c3.055-5.094,4.83-10.999,4.83-17.229\n\t\t\t\tc0-17.86-16.265-34.133-34.133-34.133h-128c-40.021,0-56.03,8.832-71.526,17.374c-11.827,6.519-24.047,13.261-49.152,16.845\n\t\t\t\tc-4.668,0.666-7.902,4.992-7.236,9.66c0.666,4.659,4.949,7.885,9.66,7.236c28.177-4.028,42.411-11.87,54.963-18.79\n\t\t\t\tc14.848-8.183,27.665-15.258,63.292-15.258h128c8.619,0,17.067,8.456,17.067,17.067c0,8.934-8.132,17.067-17.067,17.067\n\t\t\t\tc-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533h25.6c14.114,0,25.6,11.486,25.6,25.6s-11.486,25.6-25.6,25.6\n\t\t\t\tc-4.719,0-8.533,3.823-8.533,8.533c0,4.71,3.814,8.533,8.533,8.533h17.067c14.114,0,25.6,11.486,25.6,25.6\n\t\t\t\ts-11.486,25.6-25.6,25.6c-4.531,0-8.277,3.541-8.516,8.064c-0.247,4.531,3.081,8.457,7.586,8.951\n\t\t\t\tc26.53,2.91,26.53,16.418,26.53,20.847c0,13.773-11.418,30.404-25.6,30.404H349.867c-14.763,0-42.667,8.917-42.667,42.667\n\t\t\t\tc0,4.71,3.814,8.533,8.533,8.533s8.533-3.823,8.533-8.533c0-24.09,21.367-25.549,25.6-25.6h119.467\n\t\t\t\tc24.414,0,42.667-25.054,42.667-47.471C512,242.603,509.397,229.683,495.736,221.227z" }),
58
- React.createElement("path", { d: "M349.867,315.733c-4.719,0-8.533,3.823-8.533,8.533v102.4c0,29.508-13.158,42.667-42.667,42.667\n\t\t\t\tc-5.342,0-8.533-3.192-8.533-8.533c0-68.932,0-114.466-36.634-151.1c-16.87-16.87-48.947-45.167-74.3-45.167\n\t\t\t\tc-4.719,0-8.533,3.823-8.533,8.533s3.814,8.533,8.533,8.533c13.611,0,37.461,15.394,62.234,40.166\n\t\t\t\tc31.633,31.633,31.633,72.055,31.633,139.034c0,14.831,10.769,25.6,25.6,25.6c39.074,0,59.733-20.651,59.733-59.733v-102.4\n\t\t\t\tC358.4,319.556,354.586,315.733,349.867,315.733z" }),
59
- React.createElement("path", { d: "M145.067,25.6H8.533C3.814,25.6,0,29.423,0,34.133v256c0,4.71,3.814,8.533,8.533,8.533h136.533\n\t\t\t\tc4.719,0,8.533-3.823,8.533-8.533v-256C153.6,29.423,149.786,25.6,145.067,25.6z M136.533,281.6H17.067V42.667h119.467V281.6z" })))))),
60
- React.createElement("span", null, translate('theme.feedback.sentiment.thumbDown', text || 'No'))));
39
+ const ThumbDown = () => {
40
+ return (React.createElement(Wrapper, null,
41
+ React.createElement(ThumbDownIcon_1.ThumbDownIcon, null)));
61
42
  };
62
43
  exports.ThumbDown = ThumbDown;
63
44
  const Wrapper = styled_components_1.default.div `
64
45
  font-family: var(--font-family-base);
65
46
  display: flex;
66
- color: var(--color-info-text);
67
- &:hover {
68
- color: var(--color-info-text-active);
69
- svg {
70
- > g {
71
- fill: var(--color-info-text-active);
72
- }
73
- }
74
- }
75
- `;
76
- const Icon = styled_components_1.default.div `
77
- width: 18px;
78
- height: 18px;
79
- margin-right: 5px;
80
- > svg {
81
- > g {
82
- fill: var(--color-info-text);
83
- }
84
- }
47
+ align-items: center;
85
48
  `;
86
49
  //# sourceMappingURL=Thumbs.js.map
@@ -2,6 +2,7 @@ export { Feedback } from '../../components/Feedback/Feedback';
2
2
  export { Rating } from '../../components/Feedback/Rating';
3
3
  export { Sentiment } from '../../components/Feedback/Sentiment';
4
4
  export { Mood } from '../../components/Feedback/Mood';
5
+ export { Scale } from '../../components/Feedback/Scale';
5
6
  export { Comment } from '../../components/Feedback/Comment';
6
7
  export { Reasons } from '../../components/Feedback/Reasons';
7
8
  export { ReportDialog } from '../../components/Feedback/ReportDialog';
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.useReportDialog = exports.ReportDialog = exports.Reasons = exports.Comment = exports.Mood = exports.Sentiment = exports.Rating = exports.Feedback = void 0;
17
+ exports.useReportDialog = exports.ReportDialog = exports.Reasons = exports.Comment = exports.Scale = exports.Mood = exports.Sentiment = exports.Rating = exports.Feedback = void 0;
18
18
  var Feedback_1 = require("../../components/Feedback/Feedback");
19
19
  Object.defineProperty(exports, "Feedback", { enumerable: true, get: function () { return Feedback_1.Feedback; } });
20
20
  var Rating_1 = require("../../components/Feedback/Rating");
@@ -23,6 +23,8 @@ var Sentiment_1 = require("../../components/Feedback/Sentiment");
23
23
  Object.defineProperty(exports, "Sentiment", { enumerable: true, get: function () { return Sentiment_1.Sentiment; } });
24
24
  var Mood_1 = require("../../components/Feedback/Mood");
25
25
  Object.defineProperty(exports, "Mood", { enumerable: true, get: function () { return Mood_1.Mood; } });
26
+ var Scale_1 = require("../../components/Feedback/Scale");
27
+ Object.defineProperty(exports, "Scale", { enumerable: true, get: function () { return Scale_1.Scale; } });
26
28
  var Comment_1 = require("../../components/Feedback/Comment");
27
29
  Object.defineProperty(exports, "Comment", { enumerable: true, get: function () { return Comment_1.Comment; } });
28
30
  var Reasons_1 = require("../../components/Feedback/Reasons");
@@ -8,8 +8,32 @@ export type RatingProps = {
8
8
  }) => void;
9
9
  settings?: {
10
10
  label?: string;
11
+ submitText?: string;
12
+ comment?: {
13
+ enable: boolean;
14
+ label?: string;
15
+ };
16
+ reasons?: {
17
+ enable: boolean;
18
+ label?: string;
19
+ multi?: boolean;
20
+ items: string[];
21
+ };
22
+ };
23
+ className?: string;
24
+ };
25
+ export type ScaleProps = {
26
+ onSubmit: (value: {
27
+ score: number;
28
+ comment?: string;
29
+ reasons?: string[];
11
30
  max?: number;
31
+ }) => void;
32
+ settings?: {
33
+ label?: string;
12
34
  submitText?: string;
35
+ leftScaleLabel?: string;
36
+ rightScaleLabel?: string;
13
37
  comment?: {
14
38
  enable: boolean;
15
39
  label?: string;
@@ -25,7 +49,7 @@ export type RatingProps = {
25
49
  };
26
50
  export type MoodProps = {
27
51
  onSubmit: (value: {
28
- score: string;
52
+ score: number;
29
53
  comment?: string;
30
54
  reasons?: string[];
31
55
  }) => void;
@@ -79,18 +103,15 @@ export type CommentProps = {
79
103
  label?: string;
80
104
  submitText?: string;
81
105
  };
106
+ standAlone?: boolean;
82
107
  className?: string;
83
108
  };
84
109
  export type ReasonsProps = {
85
- onSubmit: (value: {
86
- reasons: string[];
87
- }) => void;
110
+ onChange: (value: string[]) => void;
88
111
  settings: {
89
112
  label?: string;
90
113
  multi?: boolean;
91
114
  items: string[];
92
- submitText?: string;
93
- buttonText?: string;
94
115
  };
95
116
  className?: string;
96
117
  };
@@ -15,7 +15,9 @@ function useReportDialog() {
15
15
  setIsReportDialogShown(true);
16
16
  };
17
17
  const hideReportDialog = () => {
18
- setIsReportDialogShown(false);
18
+ setTimeout(function () {
19
+ setIsReportDialogShown(false);
20
+ }, 1000);
19
21
  };
20
22
  const reportButtonProps = {
21
23
  onClick: showReportDialog,
@@ -38,6 +38,7 @@ const Breadcrumbs = (0, styled_components_1.default)(Breadcrumbs_1.Breadcrumbs)
38
38
  margin-bottom: var(--breadcrumbs-margin-bottom);
39
39
  `;
40
40
  const LayoutBottom = (0, styled_components_1.default)(LayoutTop) `
41
+ justify-content: center;
41
42
  > * {
42
43
  margin: 25px 5px;
43
44
  }
package/lib/config.d.ts CHANGED
@@ -1035,7 +1035,7 @@ export declare const themeConfigSchema: {
1035
1035
  };
1036
1036
  readonly type: {
1037
1037
  readonly type: "string";
1038
- readonly enum: readonly ["rating", "sentiment", "comment", "reasons", "mood"];
1038
+ readonly enum: readonly ["rating", "sentiment", "comment", "reasons", "mood", "scale"];
1039
1039
  readonly default: "sentiment";
1040
1040
  };
1041
1041
  readonly settings: {
@@ -1050,9 +1050,6 @@ export declare const themeConfigSchema: {
1050
1050
  readonly submitText: {
1051
1051
  readonly type: "string";
1052
1052
  };
1053
- readonly max: {
1054
- readonly type: "number";
1055
- };
1056
1053
  readonly buttonText: {
1057
1054
  readonly type: "string";
1058
1055
  };
@@ -1066,6 +1063,12 @@ export declare const themeConfigSchema: {
1066
1063
  };
1067
1064
  readonly minItems: 1;
1068
1065
  };
1066
+ readonly leftScaleLabel: {
1067
+ readonly type: "string";
1068
+ };
1069
+ readonly rightScaleLabel: {
1070
+ readonly type: "string";
1071
+ };
1069
1072
  readonly reasons: {
1070
1073
  readonly type: "object";
1071
1074
  readonly properties: {