x-star-design 0.0.48 → 0.0.50

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.
@@ -4,6 +4,11 @@ type feedbackItem = {
4
4
  label: string;
5
5
  };
6
6
  interface FeedbackProps {
7
+ /**
8
+ * @description 标题
9
+ * @default 您对本题目的反馈
10
+ */
11
+ title?: string;
7
12
  /**
8
13
  * @description 好评 Radio.Group 的选项
9
14
  */
@@ -21,7 +26,7 @@ interface FeedbackProps {
21
26
  */
22
27
  onSubmit?: (value: any) => void;
23
28
  /**
24
- * @description 好评、差评的Form.Item name
29
+ * @description 好评、差评的Form.Item name 1:差评 2:好评
25
30
  */
26
31
  feedbackKey: string;
27
32
  /**
@@ -10,7 +10,8 @@ import { prefix } from "../utils/global";
10
10
  var Text = Typography.Text;
11
11
  var TextArea = Input.TextArea;
12
12
  var Feedback = function Feedback(_ref) {
13
- var feedbackListGood = _ref.feedbackListGood,
13
+ var title = _ref.title,
14
+ feedbackListGood = _ref.feedbackListGood,
14
15
  feedbackListBad = _ref.feedbackListBad,
15
16
  activeColor = _ref.activeColor,
16
17
  onSubmit = _ref.onSubmit,
@@ -26,8 +27,12 @@ var Feedback = function Feedback(_ref) {
26
27
  setChoiceType = _useState2[1];
27
28
  var _useState3 = useState(false),
28
29
  _useState4 = _slicedToArray(_useState3, 2),
29
- showSubmitContent = _useState4[0],
30
- setShowSubmitContent = _useState4[1];
30
+ open = _useState4[0],
31
+ setOpen = _useState4[1];
32
+ var _useState5 = useState(false),
33
+ _useState6 = _slicedToArray(_useState5, 2),
34
+ showSubmitContent = _useState6[0],
35
+ setShowSubmitContent = _useState6[1];
31
36
  var _useLocale = useLocale('Feedback'),
32
37
  t = _useLocale.format;
33
38
  var mainContainer = useRef(null);
@@ -50,9 +55,10 @@ var Feedback = function Feedback(_ref) {
50
55
  }, /*#__PURE__*/React.createElement(CoffeeOutlined, null)), /*#__PURE__*/React.createElement("div", null, t('FEEDBACK_RESPONSE')));
51
56
  };
52
57
  var submitFormContent = function submitFormContent() {
53
- var _choiceTypeList;
58
+ var _choiceTypeList, _choiceTypeList2;
54
59
  return /*#__PURE__*/React.createElement(Form, {
55
60
  form: form,
61
+ "data-testid": "feedback-form-testId",
56
62
  onFinish: function onFinish(val) {
57
63
  onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(val);
58
64
  setShowSubmitContent(true);
@@ -69,13 +75,14 @@ var Feedback = function Feedback(_ref) {
69
75
  name: feedbackKey,
70
76
  rules: [{
71
77
  required: true,
72
- message: t('PLEASE_SELECT_FEEDBACK_TYPE')
78
+ message: t('FEEDBACK_MESSAGE_1')
73
79
  }]
74
80
  }, /*#__PURE__*/React.createElement(Radio.Group, {
75
81
  className: classNames("".concat(prefix, "-feedbackRadioGroup")),
76
82
  style: {
77
83
  padding: '20px 0 10px 0'
78
- }
84
+ },
85
+ "data-testid": "radioGroup-testId"
79
86
  }, /*#__PURE__*/React.createElement(Radio, {
80
87
  value: 2,
81
88
  "data-testid": "feedbackKey-testId-like",
@@ -98,7 +105,7 @@ var Feedback = function Feedback(_ref) {
98
105
  onClick: function onClick() {
99
106
  setChoiceType(1);
100
107
  }
101
- }, /*#__PURE__*/React.createElement(DislikeFilled, null))))), /*#__PURE__*/React.createElement("div", {
108
+ }, /*#__PURE__*/React.createElement(DislikeFilled, null))))), ((_choiceTypeList = choiceTypeList()) === null || _choiceTypeList === void 0 ? void 0 : _choiceTypeList.length) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
102
109
  style: {
103
110
  marginBottom: 10
104
111
  }
@@ -111,7 +118,7 @@ var Feedback = function Feedback(_ref) {
111
118
  name: feedbackTypeKey,
112
119
  rules: [{
113
120
  required: true,
114
- message: t('PLEASE_SELECT_FEEDBACK_TYPE')
121
+ message: t('FEEDBACK_MESSAGE_2')
115
122
  }]
116
123
  }, /*#__PURE__*/React.createElement(Checkbox.Group, {
117
124
  style: {
@@ -123,18 +130,18 @@ var Feedback = function Feedback(_ref) {
123
130
  style: {
124
131
  width: '100%'
125
132
  }
126
- }, (_choiceTypeList = choiceTypeList()) === null || _choiceTypeList === void 0 ? void 0 : _choiceTypeList.map(function (item) {
133
+ }, (_choiceTypeList2 = choiceTypeList()) === null || _choiceTypeList2 === void 0 ? void 0 : _choiceTypeList2.map(function (item) {
127
134
  return /*#__PURE__*/React.createElement(Col, {
128
- span: 8,
135
+ span: 24,
129
136
  key: item.value
130
137
  }, /*#__PURE__*/React.createElement(Checkbox, {
131
138
  value: item.value
132
139
  }, item.label));
133
- })))), /*#__PURE__*/React.createElement(Form.Item, {
140
+ }))))), /*#__PURE__*/React.createElement(Form.Item, {
134
141
  name: feedbackTextAreaKey,
135
142
  rules: [{
136
143
  required: true,
137
- message: t('PLEASE_SELECT_FEEDBACK_TYPE')
144
+ message: t('FEEDBACK_MESSAGE_3')
138
145
  }]
139
146
  }, /*#__PURE__*/React.createElement(TextArea, {
140
147
  "data-testid": "feedbackTextAreaKey-testId",
@@ -147,7 +154,10 @@ var Feedback = function Feedback(_ref) {
147
154
  }, /*#__PURE__*/React.createElement(Button, {
148
155
  type: "primary",
149
156
  className: classNames("".concat(prefix, "-feedbackButton")),
150
- htmlType: "submit"
157
+ htmlType: "submit",
158
+ onClick: function onClick() {
159
+ return form.setFieldValue(feedbackKey, choiceType);
160
+ }
151
161
  }, t('SUBMIT')))));
152
162
  };
153
163
  var content = /*#__PURE__*/React.createElement("div", {
@@ -158,8 +168,9 @@ var Feedback = function Feedback(_ref) {
158
168
  className: classNames("".concat(prefix, "-feedbackContainer"))
159
169
  }, /*#__PURE__*/React.createElement(Popover, {
160
170
  content: content,
161
- title: t('FEEDBACK_ON_THE_PROBLEM'),
171
+ title: title !== null && title !== void 0 ? title : t('FEEDBACK_ON_THE_PROBLEM'),
162
172
  placement: "bottom",
173
+ trigger: ['click'],
163
174
  getPopupContainer: function getPopupContainer() {
164
175
  return mainContainer.current;
165
176
  },
@@ -167,17 +178,20 @@ var Feedback = function Feedback(_ref) {
167
178
  onOpenChange: function onOpenChange(open) {
168
179
  if (open) {
169
180
  setShowSubmitContent(false);
181
+ setOpen(true);
170
182
  } else {
171
183
  form.resetFields();
184
+ setOpen(false);
172
185
  }
173
186
  },
174
187
  overlayInnerStyle: {
175
- width: '425px',
188
+ width: '350px',
176
189
  minHeight: '320px',
177
190
  padding: 20
178
191
  }
179
192
  }, /*#__PURE__*/React.createElement(Space, {
180
- size: 0
193
+ size: 0,
194
+ "data-testid": "popover-testId"
181
195
  }, /*#__PURE__*/React.createElement(Button, {
182
196
  type: "link",
183
197
  "data-testid": "feedback-button-like",
@@ -186,9 +200,12 @@ var Feedback = function Feedback(_ref) {
186
200
  color: activeColor
187
201
  }
188
202
  }) : /*#__PURE__*/React.createElement(LikeOutlined, null),
189
- onClick: function onClick() {
203
+ onClick: function onClick(e) {
190
204
  setChoiceType(2);
191
205
  form.setFieldsValue(_defineProperty({}, "".concat(feedbackKey), 2));
206
+ if (open) {
207
+ e.stopPropagation();
208
+ }
192
209
  }
193
210
  }, t('ACCLAIM')), /*#__PURE__*/React.createElement(Button, {
194
211
  type: "link",
@@ -198,9 +215,12 @@ var Feedback = function Feedback(_ref) {
198
215
  color: activeColor
199
216
  }
200
217
  }) : /*#__PURE__*/React.createElement(DislikeOutlined, null),
201
- onClick: function onClick() {
218
+ onClick: function onClick(e) {
202
219
  setChoiceType(1);
203
220
  form.setFieldsValue(_defineProperty({}, "".concat(feedbackKey), 1));
221
+ if (open) {
222
+ e.stopPropagation();
223
+ }
204
224
  }
205
225
  }, t('BAD_REVIEW'))))));
206
226
  };
@@ -71,6 +71,9 @@ declare const _default: {
71
71
  readonly BAD_REVIEW: "Bad Review";
72
72
  readonly PLEASE_SELECT_FEEDBACK_TYPE: "Please fill in the feedback review";
73
73
  readonly FEEDBACK_TEXTAREA_PLACEHOLDER: "Please describe your feedback in detail and we will deal with it as soon as possible";
74
+ readonly FEEDBACK_MESSAGE_1: "Please fill in the satisfaction";
75
+ readonly FEEDBACK_MESSAGE_2: "Please check the feedback type";
76
+ readonly FEEDBACK_MESSAGE_3: "Please fill in the feedback content";
74
77
  };
75
78
  };
76
79
  export default _default;
@@ -70,6 +70,9 @@ export default {
70
70
  ACCLAIM: 'Acclaim',
71
71
  BAD_REVIEW: 'Bad Review',
72
72
  PLEASE_SELECT_FEEDBACK_TYPE: 'Please fill in the feedback review',
73
- FEEDBACK_TEXTAREA_PLACEHOLDER: 'Please describe your feedback in detail and we will deal with it as soon as possible'
73
+ FEEDBACK_TEXTAREA_PLACEHOLDER: 'Please describe your feedback in detail and we will deal with it as soon as possible',
74
+ FEEDBACK_MESSAGE_1: 'Please fill in the satisfaction',
75
+ FEEDBACK_MESSAGE_2: 'Please check the feedback type',
76
+ FEEDBACK_MESSAGE_3: 'Please fill in the feedback content'
74
77
  }
75
78
  };
@@ -82,6 +82,9 @@ export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton
82
82
  readonly BAD_REVIEW: "差评";
83
83
  readonly PLEASE_SELECT_FEEDBACK_TYPE: "请填写反馈评价";
84
84
  readonly FEEDBACK_TEXTAREA_PLACEHOLDER: "请详细描述你的反馈,我们会尽快处理";
85
+ readonly FEEDBACK_MESSAGE_1: "请填写满意度";
86
+ readonly FEEDBACK_MESSAGE_2: "请勾选反馈类型";
87
+ readonly FEEDBACK_MESSAGE_3: "请填写反馈内容";
85
88
  };
86
89
  } | {
87
90
  readonly VisualDataConfig: {
@@ -156,6 +159,9 @@ export declare const useLocale: <T extends "VisualDataConfig" | "TranslateButton
156
159
  readonly BAD_REVIEW: "Bad Review";
157
160
  readonly PLEASE_SELECT_FEEDBACK_TYPE: "Please fill in the feedback review";
158
161
  readonly FEEDBACK_TEXTAREA_PLACEHOLDER: "Please describe your feedback in detail and we will deal with it as soon as possible";
162
+ readonly FEEDBACK_MESSAGE_1: "Please fill in the satisfaction";
163
+ readonly FEEDBACK_MESSAGE_2: "Please check the feedback type";
164
+ readonly FEEDBACK_MESSAGE_3: "Please fill in the feedback content";
159
165
  };
160
166
  })[T][U];
161
167
  };
@@ -71,6 +71,9 @@ declare const _default: {
71
71
  readonly BAD_REVIEW: "差评";
72
72
  readonly PLEASE_SELECT_FEEDBACK_TYPE: "请填写反馈评价";
73
73
  readonly FEEDBACK_TEXTAREA_PLACEHOLDER: "请详细描述你的反馈,我们会尽快处理";
74
+ readonly FEEDBACK_MESSAGE_1: "请填写满意度";
75
+ readonly FEEDBACK_MESSAGE_2: "请勾选反馈类型";
76
+ readonly FEEDBACK_MESSAGE_3: "请填写反馈内容";
74
77
  };
75
78
  };
76
79
  export default _default;
@@ -70,6 +70,9 @@ export default {
70
70
  ACCLAIM: '好评',
71
71
  BAD_REVIEW: '差评',
72
72
  PLEASE_SELECT_FEEDBACK_TYPE: '请填写反馈评价',
73
- FEEDBACK_TEXTAREA_PLACEHOLDER: '请详细描述你的反馈,我们会尽快处理'
73
+ FEEDBACK_TEXTAREA_PLACEHOLDER: '请详细描述你的反馈,我们会尽快处理',
74
+ FEEDBACK_MESSAGE_1: '请填写满意度',
75
+ FEEDBACK_MESSAGE_2: '请勾选反馈类型',
76
+ FEEDBACK_MESSAGE_3: '请填写反馈内容'
74
77
  }
75
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-star-design",
3
- "version": "0.0.48",
3
+ "version": "0.0.50",
4
4
  "description": "A react component library developed by turingstar",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",