@elice/material-survey 1.240718.0-trasncript.0 → 1.240718.0-trasncript.2

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 (67) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +399 -0
  2. package/cjs/components/markdown-editor/index.d.ts +1 -2
  3. package/cjs/components/markdown-editor/index.js +19 -10
  4. package/cjs/components/material-survey/MaterialSurvey.js +82 -57
  5. package/cjs/components/material-survey/MaterialSurveyInfo.js +69 -59
  6. package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +131 -90
  7. package/cjs/components/material-survey/MaterialSurveySelectOne.js +125 -86
  8. package/cjs/components/material-survey/MaterialSurveyShimmer.js +47 -40
  9. package/cjs/components/material-survey/MaterialSurveyText.js +114 -75
  10. package/cjs/components/material-survey/SurveyResultBadge.js +17 -10
  11. package/cjs/components/material-survey/SurveySubmitStatusText.js +21 -16
  12. package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
  13. package/cjs/components/material-survey/context/MaterialSurveyContext.js +115 -74
  14. package/cjs/components/material-survey/index.js +9 -0
  15. package/cjs/components/material-survey/locales/index.js +13 -0
  16. package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +49 -36
  17. package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +113 -91
  18. package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +100 -87
  19. package/cjs/components/material-survey-edit/context.js +8 -2
  20. package/cjs/components/material-survey-edit/index.js +7 -0
  21. package/cjs/components/material-survey-edit/locales/index.js +13 -0
  22. package/cjs/components/material-survey-edit/utils/editValue.js +17 -11
  23. package/cjs/components/shared/StyledMarkdown.js +5 -1
  24. package/cjs/components/shared/SurveyContentBox.js +85 -74
  25. package/cjs/components/shared/index.js +13 -0
  26. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
  27. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  28. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
  29. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +66 -89
  30. package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
  31. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  32. package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
  33. package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -80
  34. package/es/_virtual/_rollupPluginBabelHelpers.js +386 -0
  35. package/es/components/markdown-editor/index.d.ts +1 -2
  36. package/es/components/markdown-editor/index.js +15 -10
  37. package/es/components/material-survey/MaterialSurvey.js +77 -57
  38. package/es/components/material-survey/MaterialSurveyInfo.js +65 -59
  39. package/es/components/material-survey/MaterialSurveySelectMultiple.js +127 -90
  40. package/es/components/material-survey/MaterialSurveySelectOne.js +121 -86
  41. package/es/components/material-survey/MaterialSurveyShimmer.js +43 -40
  42. package/es/components/material-survey/MaterialSurveyText.js +109 -75
  43. package/es/components/material-survey/SurveyResultBadge.js +13 -10
  44. package/es/components/material-survey/SurveySubmitStatusText.js +17 -16
  45. package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
  46. package/es/components/material-survey/context/MaterialSurveyContext.js +112 -75
  47. package/es/components/material-survey/index.js +2 -0
  48. package/es/components/material-survey/locales/index.js +4 -0
  49. package/es/components/material-survey-edit/MaterialSurveyEdit.js +45 -36
  50. package/es/components/material-survey-edit/MaterialSurveyEditContent.js +107 -90
  51. package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +96 -87
  52. package/es/components/material-survey-edit/context.js +4 -2
  53. package/es/components/material-survey-edit/index.js +1 -0
  54. package/es/components/material-survey-edit/locales/index.js +4 -0
  55. package/es/components/material-survey-edit/utils/editValue.js +17 -11
  56. package/es/components/shared/StyledMarkdown.js +1 -1
  57. package/es/components/shared/SurveyContentBox.js +81 -74
  58. package/es/components/shared/index.js +4 -0
  59. package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
  60. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  61. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
  62. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +61 -89
  63. package/es/components/shared/question-radio/QuestionRadio.js +9 -7
  64. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  65. package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
  66. package/es/components/shared/question-radio/QuestionRadioOption.js +54 -80
  67. package/package.json +9 -12
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var React = require('react');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
6
  var blocks = require('@elice/blocks');
7
7
  var designTokens = require('@elice/design-tokens');
8
8
  var markdown = require('@elice/markdown');
@@ -11,66 +11,76 @@ var styled = require('styled-components');
11
11
  var SurveyContentBox = require('../shared/SurveyContentBox.js');
12
12
  var MaterialSurveyContext = require('./context/MaterialSurveyContext.js');
13
13
 
14
- const StyledMarkdownSSR = styled(markdown.MarkdownSSR).withConfig({
14
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
15
+
16
+ var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
17
+
18
+ var StyledMarkdownSSR = styled__default.default(markdown.MarkdownSSR).withConfig({
15
19
  componentId: "sc-1b9l43w-0"
16
20
  })(["", ""], wysiwyg.EliceWysiwygEditorTheme.resetMarkdownSSR);
17
- const MaterialSurveyInfo = () => {
18
- const {
19
- materialSurvey
20
- } = MaterialSurveyContext.useMaterialSurveyState();
21
- return React.createElement(SurveyContentBox.default, {
22
- title: materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.title
23
- }, materialSurvey ? React.createElement(blocks.Flex, null, React.createElement(blocks.Text, {
24
- bold: true,
25
- size: "large",
26
- customStyles: {
27
- color: designTokens.base.color.primary3,
28
- marginRight: '0.5rem'
29
- }
30
- }, 'Q.'), React.createElement(blocks.Text, {
31
- bold: true,
32
- role: "white",
33
- size: "large",
34
- wordBreak: "break-word"
35
- }, materialSurvey.questionInfoList[0].questionTitle)) : React.createElement(blocks.Shimmer, {
36
- dark: true,
37
- borderRadius: '4px',
38
- width: "80%",
39
- height: '40px'
40
- }), React.createElement(blocks.Vspace, {
41
- height: 1
42
- }), materialSurvey ? React.createElement(StyledMarkdownSSR, {
43
- children: materialSurvey.questionInfoList[0].questionDescription,
44
- dark: true,
45
- paddingx: 0,
46
- paddingy: 0
47
- }) : React.createElement(React.Fragment, null, React.createElement(blocks.Shimmer, {
48
- dark: true,
49
- borderRadius: '4px',
50
- width: "80%",
51
- height: '40px'
52
- }), React.createElement(blocks.Vspace, {
53
- height: 1
54
- }), React.createElement(blocks.Shimmer, {
55
- dark: true,
56
- borderRadius: '4px',
57
- width: "100%",
58
- height: '40px'
59
- }), React.createElement(blocks.Vspace, {
60
- height: 1
61
- }), React.createElement(blocks.Shimmer, {
62
- dark: true,
63
- borderRadius: '4px',
64
- width: "100%",
65
- height: '40px'
66
- }), React.createElement(blocks.Vspace, {
67
- height: 1
68
- }), React.createElement(blocks.Shimmer, {
69
- dark: true,
70
- borderRadius: '4px',
71
- width: "100%",
72
- height: '40px'
73
- })));
21
+ var MaterialSurveyInfo = function MaterialSurveyInfo() {
22
+ var _useMaterialSurveySta = MaterialSurveyContext.useMaterialSurveyState(),
23
+ materialSurvey = _useMaterialSurveySta.materialSurvey;
24
+ return jsxRuntime.jsxs(SurveyContentBox.default, {
25
+ title: materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.title,
26
+ children: [materialSurvey ? jsxRuntime.jsxs(blocks.Flex, {
27
+ children: [jsxRuntime.jsx(blocks.Text, {
28
+ bold: true,
29
+ size: "large",
30
+ customStyles: {
31
+ color: designTokens.base.color.primary3,
32
+ marginRight: '0.5rem'
33
+ },
34
+ children: 'Q.'
35
+ }), jsxRuntime.jsx(blocks.Text, {
36
+ bold: true,
37
+ role: "white",
38
+ size: "large",
39
+ wordBreak: "break-word",
40
+ children: materialSurvey.questionInfoList[0].questionTitle
41
+ })]
42
+ }) : jsxRuntime.jsx(blocks.Shimmer, {
43
+ dark: true,
44
+ borderRadius: '4px',
45
+ width: "80%",
46
+ height: '40px'
47
+ }), jsxRuntime.jsx(blocks.Vspace, {
48
+ height: 1
49
+ }), materialSurvey ? jsxRuntime.jsx(StyledMarkdownSSR, {
50
+ children: materialSurvey.questionInfoList[0].questionDescription,
51
+ dark: true,
52
+ paddingx: 0,
53
+ paddingy: 0
54
+ }) : jsxRuntime.jsxs(jsxRuntime.Fragment, {
55
+ children: [jsxRuntime.jsx(blocks.Shimmer, {
56
+ dark: true,
57
+ borderRadius: '4px',
58
+ width: "80%",
59
+ height: '40px'
60
+ }), jsxRuntime.jsx(blocks.Vspace, {
61
+ height: 1
62
+ }), jsxRuntime.jsx(blocks.Shimmer, {
63
+ dark: true,
64
+ borderRadius: '4px',
65
+ width: "100%",
66
+ height: '40px'
67
+ }), jsxRuntime.jsx(blocks.Vspace, {
68
+ height: 1
69
+ }), jsxRuntime.jsx(blocks.Shimmer, {
70
+ dark: true,
71
+ borderRadius: '4px',
72
+ width: "100%",
73
+ height: '40px'
74
+ }), jsxRuntime.jsx(blocks.Vspace, {
75
+ height: 1
76
+ }), jsxRuntime.jsx(blocks.Shimmer, {
77
+ dark: true,
78
+ borderRadius: '4px',
79
+ width: "100%",
80
+ height: '40px'
81
+ })]
82
+ })]
83
+ });
74
84
  };
75
85
 
76
86
  exports.default = MaterialSurveyInfo;
@@ -2,6 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var jsxRuntime = require('react/jsx-runtime');
5
7
  var React = require('react');
6
8
  var apiClient = require('@elice/api-client');
7
9
  var intl = require('@elice/intl');
@@ -16,52 +18,61 @@ var MaterialSurveyContext = require('./context/MaterialSurveyContext.js');
16
18
  var SurveyResultBadge = require('./SurveyResultBadge.js');
17
19
  var SurveySubmitStatusText = require('./SurveySubmitStatusText.js');
18
20
 
19
- const MaterialSurveySelectMultiple = () => {
21
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
22
+
23
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
24
+
25
+ var MaterialSurveySelectMultiple = function MaterialSurveySelectMultiple() {
20
26
  var _a;
21
27
  // context
22
- const {
23
- course,
24
- lecture,
25
- materialSurvey,
26
- userId
27
- } = MaterialSurveyContext.useMaterialSurveyState();
28
- const {
29
- onSubmit,
30
- onNext,
31
- refreshOrgMaterialSurvey
32
- } = MaterialSurveyContext.useMaterialSurveyDispatch();
28
+ var _useMaterialSurveySta = MaterialSurveyContext.useMaterialSurveyState(),
29
+ course = _useMaterialSurveySta.course,
30
+ lecture = _useMaterialSurveySta.lecture,
31
+ materialSurvey = _useMaterialSurveySta.materialSurvey,
32
+ userId = _useMaterialSurveySta.userId;
33
+ var _useMaterialSurveyDis = MaterialSurveyContext.useMaterialSurveyDispatch(),
34
+ onSubmit = _useMaterialSurveyDis.onSubmit,
35
+ onNext = _useMaterialSurveyDis.onNext,
36
+ refreshOrgMaterialSurvey = _useMaterialSurveyDis.refreshOrgMaterialSurvey;
33
37
  // state
34
- const intl$1 = intl.useRawEliceIntl();
35
- const [selectedAnswer, setSelectedAnswer] = React.useState([]);
36
- const [materialSurveyResponse, setMaterialSurveyResponse] = React.useState();
37
- const [submitStatus, setSubmitStatus] = React.useState('idle');
38
+ var intl$1 = intl.useRawEliceIntl();
39
+ var _React$useState = React__default.default.useState([]),
40
+ _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
41
+ selectedAnswer = _React$useState2[0],
42
+ setSelectedAnswer = _React$useState2[1];
43
+ var _React$useState3 = React__default.default.useState(),
44
+ _React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
45
+ materialSurveyResponse = _React$useState4[0],
46
+ setMaterialSurveyResponse = _React$useState4[1];
47
+ var _React$useState5 = React__default.default.useState('idle'),
48
+ _React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
49
+ submitStatus = _React$useState6[0],
50
+ setSubmitStatus = _React$useState6[1];
38
51
  // survey response fetcher
39
- React.useEffect(() => {
52
+ React__default.default.useEffect(function () {
40
53
  if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
41
- const controller = new AbortController();
42
- const {
43
- signal
44
- } = controller;
54
+ var controller = new AbortController();
55
+ var signal = controller.signal;
45
56
  apiClient.getOrgMaterialSurveyResponseGet({
46
57
  surveyResponseId: materialSurvey.lastSurveyResponseId
47
58
  }, {
48
- signal
49
- }).then(response => {
59
+ signal: signal
60
+ }).then(function (response) {
50
61
  setMaterialSurveyResponse(response.surveyResponse);
51
62
  setSelectedAnswer(response.surveyResponse.answers[0]);
52
- }).catch(error => {
63
+ }).catch(function (error) {
53
64
  console.error(error);
54
65
  });
55
- return () => controller.abort();
66
+ return function () {
67
+ return controller.abort();
68
+ };
56
69
  }
57
70
  }, [materialSurvey, userId]);
58
71
  // survey response fetcher
59
- React.useEffect(() => {
72
+ React__default.default.useEffect(function () {
60
73
  if (userId && materialSurvey) {
61
- const controller = new AbortController();
62
- const {
63
- signal
64
- } = controller;
74
+ var controller = new AbortController();
75
+ var signal = controller.signal;
65
76
  apiClient.getOrgMaterialSurveyResponseList({
66
77
  materialSurveyId: materialSurvey.id,
67
78
  filterUserIds: [userId],
@@ -70,10 +81,10 @@ const MaterialSurveySelectMultiple = () => {
70
81
  offset: 0,
71
82
  count: 1
72
83
  }, {
73
- signal
74
- }).then(response => {
75
- const surveyResponse = response.surveyResponses[0];
76
- const getAnswer = () => {
84
+ signal: signal
85
+ }).then(function (response) {
86
+ var surveyResponse = response.surveyResponses[0];
87
+ var getAnswer = function getAnswer() {
77
88
  if (!surveyResponse) {
78
89
  return [];
79
90
  }
@@ -87,49 +98,75 @@ const MaterialSurveySelectMultiple = () => {
87
98
  };
88
99
  setMaterialSurveyResponse(surveyResponse);
89
100
  setSelectedAnswer(getAnswer());
90
- }).catch(error => {
101
+ }).catch(function (error) {
91
102
  console.error(error);
92
103
  });
93
- return () => controller.abort();
104
+ return function () {
105
+ return controller.abort();
106
+ };
94
107
  }
95
108
  }, [materialSurvey, userId]);
96
109
  // submit handler
97
- const handleSubmit = async () => {
98
- if (!materialSurvey) {
99
- return;
100
- }
101
- setSubmitStatus('pending');
102
- try {
103
- const {
104
- surveyResponseId
105
- } = await apiClient.postOrgMaterialSurveyResponseAdd({
106
- materialSurveyId: materialSurvey.id,
107
- answers: [selectedAnswer]
108
- });
109
- const {
110
- surveyResponse
111
- } = await apiClient.getOrgMaterialSurveyResponseGet({
112
- surveyResponseId
113
- });
114
- setMaterialSurveyResponse(surveyResponse);
115
- void refreshOrgMaterialSurvey();
116
- onSubmit(true);
117
- setSubmitStatus('resolved');
118
- } catch (error) {
119
- console.error(error);
120
- onSubmit(false);
121
- setSubmitStatus('rejected');
122
- }
123
- };
124
- return React.createElement(SurveyContentBox.default, {
110
+ var handleSubmit = /*#__PURE__*/function () {
111
+ var _ref = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee() {
112
+ var _yield$postOrgMateria, surveyResponseId, _yield$getOrgMaterial, surveyResponse;
113
+ return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
114
+ while (1) switch (_context.prev = _context.next) {
115
+ case 0:
116
+ if (materialSurvey) {
117
+ _context.next = 2;
118
+ break;
119
+ }
120
+ return _context.abrupt("return");
121
+ case 2:
122
+ setSubmitStatus('pending');
123
+ _context.prev = 3;
124
+ _context.next = 6;
125
+ return apiClient.postOrgMaterialSurveyResponseAdd({
126
+ materialSurveyId: materialSurvey.id,
127
+ answers: [selectedAnswer]
128
+ });
129
+ case 6:
130
+ _yield$postOrgMateria = _context.sent;
131
+ surveyResponseId = _yield$postOrgMateria.surveyResponseId;
132
+ _context.next = 10;
133
+ return apiClient.getOrgMaterialSurveyResponseGet({
134
+ surveyResponseId: surveyResponseId
135
+ });
136
+ case 10:
137
+ _yield$getOrgMaterial = _context.sent;
138
+ surveyResponse = _yield$getOrgMaterial.surveyResponse;
139
+ setMaterialSurveyResponse(surveyResponse);
140
+ void refreshOrgMaterialSurvey();
141
+ onSubmit(true);
142
+ setSubmitStatus('resolved');
143
+ _context.next = 23;
144
+ break;
145
+ case 18:
146
+ _context.prev = 18;
147
+ _context.t0 = _context["catch"](3);
148
+ console.error(_context.t0);
149
+ onSubmit(false);
150
+ setSubmitStatus('rejected');
151
+ case 23:
152
+ case "end":
153
+ return _context.stop();
154
+ }
155
+ }, _callee, null, [[3, 18]]);
156
+ }));
157
+ return function handleSubmit() {
158
+ return _ref.apply(this, arguments);
159
+ };
160
+ }();
161
+ return jsxRuntime.jsx(SurveyContentBox.default, {
125
162
  title: intl$1.formatMessage({
126
163
  id: 'materialSurvey.myAnswer'
127
164
  }),
128
165
  onNext: onNext,
129
- submitResult: React.createElement(SurveyResultBadge.default, {
166
+ submitResult: jsxRuntime.jsx(SurveyResultBadge.default, {
130
167
  materialSurveyResponse: materialSurveyResponse
131
168
  }),
132
- submitStatus: React.createElement(SurveySubmitStatusText.default, {
169
+ submitStatus: jsxRuntime.jsx(SurveySubmitStatusText.default, {
133
170
  status: submitStatus
134
171
  }),
135
172
  footerActions: [{
@@ -143,30 +180,34 @@ const MaterialSurveySelectMultiple = () => {
143
180
  children: intl$1.formatMessage({
144
181
  id: 'materialSurvey.submit'
145
182
  })
146
- }]
147
- }, React.createElement(QuestionCheckbox.default, {
148
- onSelect: index$1 => {
149
- if (index.checkUserLectureTestEnded(lecture) || !!userId) {
150
- return;
151
- }
152
- setSelectedAnswer(prevState => {
153
- const newState = prevState.includes(index$1) ? prevState.filter(ident => ident !== index$1) : [...prevState, index$1];
154
- return newState;
155
- });
156
- },
157
- selectedOptions: selectedAnswer,
158
- disabled: submitStatus === 'pending' || index.checkUserLectureTestEnded(lecture) || !!userId
159
- }, (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0]) ? (_a = materialSurvey.questionInfoList[0].optionInfo) === null || _a === void 0 ? void 0 : _a.map((option, index) => {
160
- return React.createElement(QuestionCheckboxOption.default, {
161
- key: index,
162
- value: index
163
- }, (course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInSurveyOptions) ? React.createElement(StyledMarkdown.default, {
164
- dark: false,
165
- children: option,
166
- paddingx: 0,
167
- paddingy: 0
168
- }) : option);
169
- }) : null));
183
+ }],
184
+ children: jsxRuntime.jsx(QuestionCheckbox.default, {
185
+ onSelect: function onSelect(index$1) {
186
+ if (index.checkUserLectureTestEnded(lecture) || !!userId) {
187
+ return;
188
+ }
189
+ setSelectedAnswer(function (prevState) {
190
+ var newState = prevState.includes(index$1) ? prevState.filter(function (ident) {
191
+ return ident !== index$1;
192
+ }) : [].concat(_rollupPluginBabelHelpers.toConsumableArray(prevState), [index$1]);
193
+ return newState;
194
+ });
195
+ },
196
+ selectedOptions: selectedAnswer,
197
+ disabled: submitStatus === 'pending' || index.checkUserLectureTestEnded(lecture) || !!userId,
198
+ children: (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.questionInfoList[0]) ? (_a = materialSurvey.questionInfoList[0].optionInfo) === null || _a === void 0 ? void 0 : _a.map(function (option, index) {
199
+ return jsxRuntime.jsx(QuestionCheckboxOption.default, {
200
+ value: index,
201
+ children: (course === null || course === void 0 ? void 0 : course.preference.renderMarkdownInSurveyOptions) ? jsxRuntime.jsx(StyledMarkdown.default, {
202
+ dark: false,
203
+ children: option,
204
+ paddingx: 0,
205
+ paddingy: 0
206
+ }) : option
207
+ }, index);
208
+ }) : null
209
+ })
210
+ });
170
211
  };
171
212
 
172
213
  exports.default = MaterialSurveySelectMultiple;