x-star-design 0.0.47 → 0.0.49
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/dist/feedback/index.d.ts +7 -3
- package/dist/feedback/index.js +32 -20
- package/package.json +1 -1
package/dist/feedback/index.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
type feedbackItem = {
|
|
3
|
-
value: string;
|
|
3
|
+
value: string | number;
|
|
4
4
|
label: string;
|
|
5
5
|
};
|
|
6
6
|
interface FeedbackProps {
|
|
7
7
|
/**
|
|
8
|
-
* @description Radio.Group 的选项
|
|
8
|
+
* @description 好评 Radio.Group 的选项
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
feedbackListGood?: feedbackItem[];
|
|
11
|
+
/**
|
|
12
|
+
* @description 差评 Radio.Group 的选项
|
|
13
|
+
*/
|
|
14
|
+
feedbackListBad?: feedbackItem[];
|
|
11
15
|
/**
|
|
12
16
|
* @description 选中的颜色
|
|
13
17
|
*/
|
package/dist/feedback/index.js
CHANGED
|
@@ -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
|
|
13
|
+
var feedbackListGood = _ref.feedbackListGood,
|
|
14
|
+
feedbackListBad = _ref.feedbackListBad,
|
|
14
15
|
activeColor = _ref.activeColor,
|
|
15
16
|
onSubmit = _ref.onSubmit,
|
|
16
17
|
feedbackKey = _ref.feedbackKey,
|
|
@@ -30,6 +31,13 @@ var Feedback = function Feedback(_ref) {
|
|
|
30
31
|
var _useLocale = useLocale('Feedback'),
|
|
31
32
|
t = _useLocale.format;
|
|
32
33
|
var mainContainer = useRef(null);
|
|
34
|
+
var choiceTypeList = function choiceTypeList() {
|
|
35
|
+
if (choiceType === 2) {
|
|
36
|
+
return feedbackListGood;
|
|
37
|
+
} else {
|
|
38
|
+
return feedbackListBad;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
33
41
|
var submittedContent = function submittedContent() {
|
|
34
42
|
return /*#__PURE__*/React.createElement(Space, {
|
|
35
43
|
direction: "vertical",
|
|
@@ -42,6 +50,7 @@ var Feedback = function Feedback(_ref) {
|
|
|
42
50
|
}, /*#__PURE__*/React.createElement(CoffeeOutlined, null)), /*#__PURE__*/React.createElement("div", null, t('FEEDBACK_RESPONSE')));
|
|
43
51
|
};
|
|
44
52
|
var submitFormContent = function submitFormContent() {
|
|
53
|
+
var _choiceTypeList, _choiceTypeList2;
|
|
45
54
|
return /*#__PURE__*/React.createElement(Form, {
|
|
46
55
|
form: form,
|
|
47
56
|
onFinish: function onFinish(val) {
|
|
@@ -68,28 +77,28 @@ var Feedback = function Feedback(_ref) {
|
|
|
68
77
|
padding: '20px 0 10px 0'
|
|
69
78
|
}
|
|
70
79
|
}, /*#__PURE__*/React.createElement(Radio, {
|
|
71
|
-
value:
|
|
72
|
-
"data-testid": "feedbackKey-testId",
|
|
80
|
+
value: 2,
|
|
81
|
+
"data-testid": "feedbackKey-testId-like",
|
|
73
82
|
onClick: function onClick() {
|
|
74
|
-
setChoiceType(
|
|
83
|
+
setChoiceType(2);
|
|
75
84
|
},
|
|
76
85
|
style: {
|
|
77
|
-
color: choiceType ===
|
|
86
|
+
color: choiceType === 2 ? activeColor : '#d9d9d9',
|
|
78
87
|
transition: 'color 0.3s ease-in-out',
|
|
79
88
|
fontSize: '36px'
|
|
80
89
|
}
|
|
81
90
|
}, /*#__PURE__*/React.createElement(LikeFilled, null)), /*#__PURE__*/React.createElement(Radio, {
|
|
82
|
-
value:
|
|
91
|
+
value: 1,
|
|
83
92
|
"data-testid": "feedbackKey-testId-dislike",
|
|
84
93
|
style: {
|
|
85
|
-
color: choiceType ===
|
|
94
|
+
color: choiceType === 1 ? activeColor : '#d9d9d9',
|
|
86
95
|
transition: 'color 0.3s ease-in-out',
|
|
87
96
|
fontSize: '36px'
|
|
88
97
|
},
|
|
89
98
|
onClick: function onClick() {
|
|
90
|
-
setChoiceType(
|
|
99
|
+
setChoiceType(1);
|
|
91
100
|
}
|
|
92
|
-
}, /*#__PURE__*/React.createElement(DislikeFilled, null))))), /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
}, /*#__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", {
|
|
93
102
|
style: {
|
|
94
103
|
marginBottom: 10
|
|
95
104
|
}
|
|
@@ -114,14 +123,14 @@ var Feedback = function Feedback(_ref) {
|
|
|
114
123
|
style: {
|
|
115
124
|
width: '100%'
|
|
116
125
|
}
|
|
117
|
-
},
|
|
126
|
+
}, (_choiceTypeList2 = choiceTypeList()) === null || _choiceTypeList2 === void 0 ? void 0 : _choiceTypeList2.map(function (item) {
|
|
118
127
|
return /*#__PURE__*/React.createElement(Col, {
|
|
119
128
|
span: 8,
|
|
120
129
|
key: item.value
|
|
121
130
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
|
122
131
|
value: item.value
|
|
123
132
|
}, item.label));
|
|
124
|
-
})))), /*#__PURE__*/React.createElement(Form.Item, {
|
|
133
|
+
}))))), /*#__PURE__*/React.createElement(Form.Item, {
|
|
125
134
|
name: feedbackTextAreaKey,
|
|
126
135
|
rules: [{
|
|
127
136
|
required: true,
|
|
@@ -138,7 +147,10 @@ var Feedback = function Feedback(_ref) {
|
|
|
138
147
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
139
148
|
type: "primary",
|
|
140
149
|
className: classNames("".concat(prefix, "-feedbackButton")),
|
|
141
|
-
htmlType: "submit"
|
|
150
|
+
htmlType: "submit",
|
|
151
|
+
onClick: function onClick() {
|
|
152
|
+
return form.setFieldValue(feedbackKey, choiceType);
|
|
153
|
+
}
|
|
142
154
|
}, t('SUBMIT')))));
|
|
143
155
|
};
|
|
144
156
|
var content = /*#__PURE__*/React.createElement("div", {
|
|
@@ -154,7 +166,7 @@ var Feedback = function Feedback(_ref) {
|
|
|
154
166
|
getPopupContainer: function getPopupContainer() {
|
|
155
167
|
return mainContainer.current;
|
|
156
168
|
},
|
|
157
|
-
|
|
169
|
+
mouseLeaveDelay: 0.4,
|
|
158
170
|
onOpenChange: function onOpenChange(open) {
|
|
159
171
|
if (open) {
|
|
160
172
|
setShowSubmitContent(false);
|
|
@@ -163,7 +175,7 @@ var Feedback = function Feedback(_ref) {
|
|
|
163
175
|
}
|
|
164
176
|
},
|
|
165
177
|
overlayInnerStyle: {
|
|
166
|
-
width: '
|
|
178
|
+
width: '425px',
|
|
167
179
|
minHeight: '320px',
|
|
168
180
|
padding: 20
|
|
169
181
|
}
|
|
@@ -172,26 +184,26 @@ var Feedback = function Feedback(_ref) {
|
|
|
172
184
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
173
185
|
type: "link",
|
|
174
186
|
"data-testid": "feedback-button-like",
|
|
175
|
-
icon: choiceType ===
|
|
187
|
+
icon: choiceType === 2 ? /*#__PURE__*/React.createElement(LikeFilled, {
|
|
176
188
|
style: {
|
|
177
189
|
color: activeColor
|
|
178
190
|
}
|
|
179
191
|
}) : /*#__PURE__*/React.createElement(LikeOutlined, null),
|
|
180
192
|
onClick: function onClick() {
|
|
181
|
-
setChoiceType(
|
|
182
|
-
form.setFieldsValue(_defineProperty({}, "".concat(feedbackKey),
|
|
193
|
+
setChoiceType(2);
|
|
194
|
+
form.setFieldsValue(_defineProperty({}, "".concat(feedbackKey), 2));
|
|
183
195
|
}
|
|
184
196
|
}, t('ACCLAIM')), /*#__PURE__*/React.createElement(Button, {
|
|
185
197
|
type: "link",
|
|
186
198
|
"data-testid": "feedback-button-dislike",
|
|
187
|
-
icon: choiceType ===
|
|
199
|
+
icon: choiceType === 1 ? /*#__PURE__*/React.createElement(DislikeFilled, {
|
|
188
200
|
style: {
|
|
189
201
|
color: activeColor
|
|
190
202
|
}
|
|
191
203
|
}) : /*#__PURE__*/React.createElement(DislikeOutlined, null),
|
|
192
204
|
onClick: function onClick() {
|
|
193
|
-
setChoiceType(
|
|
194
|
-
form.setFieldsValue(_defineProperty({}, "".concat(feedbackKey),
|
|
205
|
+
setChoiceType(1);
|
|
206
|
+
form.setFieldsValue(_defineProperty({}, "".concat(feedbackKey), 1));
|
|
195
207
|
}
|
|
196
208
|
}, t('BAD_REVIEW'))))));
|
|
197
209
|
};
|