@elice/material-quiz 1.240718.0-trasncript.1 → 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 (127) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +423 -0
  2. package/cjs/components/eb-sortable/EbDraggable.js +42 -33
  3. package/cjs/components/eb-sortable/EbDroppable.js +27 -20
  4. package/cjs/components/markdown-editor/index.d.ts +1 -2
  5. package/cjs/components/markdown-editor/index.js +19 -10
  6. package/cjs/components/material-quiz/MaterialQuiz.js +114 -83
  7. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +36 -29
  8. package/cjs/components/material-quiz/MaterialQuizInfo.js +151 -149
  9. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +175 -127
  10. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +360 -286
  11. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +172 -126
  12. package/cjs/components/material-quiz/MaterialQuizShimmer.js +46 -39
  13. package/cjs/components/material-quiz/MaterialQuizText.js +163 -115
  14. package/cjs/components/material-quiz/QuizResultBadge.js +32 -22
  15. package/cjs/components/material-quiz/QuizSubmitStatusText.js +21 -16
  16. package/cjs/components/material-quiz/constants/color.js +5 -5
  17. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  18. package/cjs/components/material-quiz/context/MaterialQuizContext.js +156 -93
  19. package/cjs/components/material-quiz/index.js +9 -0
  20. package/cjs/components/material-quiz/locales/index.js +13 -0
  21. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +259 -161
  22. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +134 -100
  23. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +130 -101
  24. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +64 -52
  25. package/cjs/components/material-quiz/material-quiz-group/context/context.js +5 -1
  26. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +47 -36
  27. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +280 -232
  28. package/cjs/components/material-quiz-edit/context.js +8 -2
  29. package/cjs/components/material-quiz-edit/index.js +7 -0
  30. package/cjs/components/material-quiz-edit/locales/index.js +13 -0
  31. package/cjs/components/material-quiz-edit/options/OptionEditor.js +70 -46
  32. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +174 -148
  33. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +175 -149
  34. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +164 -144
  35. package/cjs/components/material-quiz-edit/options/OptionText.js +90 -82
  36. package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
  37. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +156 -112
  38. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +288 -196
  39. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +88 -75
  40. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +108 -92
  41. package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
  42. package/cjs/components/material-quiz-edit/utils/editValue.js +21 -12
  43. package/cjs/components/shared/QuestionBox.js +198 -165
  44. package/cjs/components/shared/QuizDraggbleDroppedOption.js +11 -12
  45. package/cjs/components/shared/QuizDraggbleDummyOption.js +23 -16
  46. package/cjs/components/shared/QuizDraggbleOption.js +65 -59
  47. package/cjs/components/shared/StyledMarkdown.js +5 -1
  48. package/cjs/components/shared/index.js +19 -0
  49. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
  50. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  51. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
  52. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +59 -68
  53. package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
  54. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  55. package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
  56. package/cjs/components/shared/question-radio/QuestionRadioOption.js +52 -59
  57. package/cjs/components/shared/utils/getQuestionStatusStyle.js +7 -9
  58. package/cjs/components/shared/utils/mergeRefs.js +15 -6
  59. package/cjs/constant/element.js +3 -3
  60. package/cjs/constant/index.js +9 -0
  61. package/cjs/helpers/index.js +8 -10
  62. package/cjs/hooks/index.js +7 -0
  63. package/cjs/hooks/useCaculatePassage.js +21 -20
  64. package/es/_virtual/_rollupPluginBabelHelpers.js +408 -0
  65. package/es/components/eb-sortable/EbDraggable.js +37 -33
  66. package/es/components/eb-sortable/EbDroppable.js +22 -20
  67. package/es/components/markdown-editor/index.d.ts +1 -2
  68. package/es/components/markdown-editor/index.js +15 -10
  69. package/es/components/material-quiz/MaterialQuiz.js +109 -83
  70. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +32 -29
  71. package/es/components/material-quiz/MaterialQuizInfo.js +148 -150
  72. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +171 -127
  73. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +356 -287
  74. package/es/components/material-quiz/MaterialQuizSelectOne.js +168 -126
  75. package/es/components/material-quiz/MaterialQuizShimmer.js +42 -39
  76. package/es/components/material-quiz/MaterialQuizText.js +158 -115
  77. package/es/components/material-quiz/QuizResultBadge.js +27 -22
  78. package/es/components/material-quiz/QuizSubmitStatusText.js +17 -16
  79. package/es/components/material-quiz/constants/color.js +5 -5
  80. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  81. package/es/components/material-quiz/context/MaterialQuizContext.js +153 -94
  82. package/es/components/material-quiz/index.js +2 -0
  83. package/es/components/material-quiz/locales/index.js +4 -0
  84. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +253 -161
  85. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +129 -100
  86. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +125 -101
  87. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +60 -52
  88. package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
  89. package/es/components/material-quiz-edit/MaterialQuizEdit.js +43 -36
  90. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +272 -229
  91. package/es/components/material-quiz-edit/context.js +4 -2
  92. package/es/components/material-quiz-edit/index.js +1 -0
  93. package/es/components/material-quiz-edit/locales/index.js +4 -0
  94. package/es/components/material-quiz-edit/options/OptionEditor.js +64 -46
  95. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +170 -148
  96. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +171 -149
  97. package/es/components/material-quiz-edit/options/OptionSelectOne.js +159 -144
  98. package/es/components/material-quiz-edit/options/OptionText.js +86 -82
  99. package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
  100. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +151 -112
  101. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +283 -197
  102. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +83 -75
  103. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +103 -92
  104. package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
  105. package/es/components/material-quiz-edit/utils/editValue.js +17 -12
  106. package/es/components/shared/QuestionBox.js +192 -165
  107. package/es/components/shared/QuizDraggbleDroppedOption.js +11 -12
  108. package/es/components/shared/QuizDraggbleDummyOption.js +19 -16
  109. package/es/components/shared/QuizDraggbleOption.js +61 -59
  110. package/es/components/shared/StyledMarkdown.js +1 -1
  111. package/es/components/shared/index.js +7 -0
  112. package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
  113. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  114. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
  115. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +54 -68
  116. package/es/components/shared/question-radio/QuestionRadio.js +9 -7
  117. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  118. package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
  119. package/es/components/shared/question-radio/QuestionRadioOption.js +47 -59
  120. package/es/components/shared/utils/getQuestionStatusStyle.js +7 -9
  121. package/es/components/shared/utils/mergeRefs.js +15 -6
  122. package/es/constant/element.js +3 -3
  123. package/es/constant/index.js +1 -0
  124. package/es/helpers/index.js +8 -10
  125. package/es/hooks/index.js +1 -0
  126. package/es/hooks/useCaculatePassage.js +21 -20
  127. package/package.json +12 -15
@@ -1,127 +1,190 @@
1
1
  'use strict';
2
2
 
3
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
4
+ var jsxRuntime = require('react/jsx-runtime');
3
5
  var React = require('react');
4
6
  var apiClient = require('@elice/api-client');
5
7
  var materialSharedUtils = require('@elice/material-shared-utils');
6
8
  var types = require('@elice/types');
7
9
 
8
- const StateContext = React.createContext(undefined);
9
- const DispatchContext = React.createContext(undefined);
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
13
+
14
+ var StateContext = React__default.default.createContext(undefined);
15
+ var DispatchContext = React__default.default.createContext(undefined);
10
16
  StateContext.displayName = 'MaterialQuizStateContext';
11
17
  DispatchContext.displayName = 'MaterialQuizDispatchContext';
12
- function MaterialQuizProvider({
13
- materialQuizId,
14
- userId,
15
- onSubmit = () => void 0,
16
- onDirty,
17
- onNext,
18
- children
19
- }) {
20
- const [course, setCourse] = React.useState();
21
- const [lecture, setLecture] = React.useState();
22
- const [initStatus, setInitStatus] = React.useState('idle');
23
- const [vertical, setVertical] = React.useState(false);
24
- const [isLongPassage, setIsLongPassage] = React.useState(false);
25
- const [isInitialLoading, setIsInitialLoading] = React.useState(true);
26
- const canInit = materialSharedUtils.useMaterialConfigApiClientUpdate(apiClient.config.init);
27
- const resetLayout = () => {
18
+ function MaterialQuizProvider(_ref) {
19
+ var materialQuizId = _ref.materialQuizId,
20
+ userId = _ref.userId,
21
+ _ref$onSubmit = _ref.onSubmit,
22
+ onSubmit = _ref$onSubmit === void 0 ? function () {
23
+ return void 0;
24
+ } : _ref$onSubmit,
25
+ onDirty = _ref.onDirty,
26
+ onNext = _ref.onNext,
27
+ children = _ref.children;
28
+ var _React$useState = React__default.default.useState(),
29
+ _React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
30
+ course = _React$useState2[0],
31
+ setCourse = _React$useState2[1];
32
+ var _React$useState3 = React__default.default.useState(),
33
+ _React$useState4 = _rollupPluginBabelHelpers.slicedToArray(_React$useState3, 2),
34
+ lecture = _React$useState4[0],
35
+ setLecture = _React$useState4[1];
36
+ var _React$useState5 = React__default.default.useState('idle'),
37
+ _React$useState6 = _rollupPluginBabelHelpers.slicedToArray(_React$useState5, 2),
38
+ initStatus = _React$useState6[0],
39
+ setInitStatus = _React$useState6[1];
40
+ var _React$useState7 = React__default.default.useState(false),
41
+ _React$useState8 = _rollupPluginBabelHelpers.slicedToArray(_React$useState7, 2),
42
+ vertical = _React$useState8[0],
43
+ setVertical = _React$useState8[1];
44
+ var _React$useState9 = React__default.default.useState(false),
45
+ _React$useState10 = _rollupPluginBabelHelpers.slicedToArray(_React$useState9, 2),
46
+ isLongPassage = _React$useState10[0],
47
+ setIsLongPassage = _React$useState10[1];
48
+ var _React$useState11 = React__default.default.useState(true),
49
+ _React$useState12 = _rollupPluginBabelHelpers.slicedToArray(_React$useState11, 2),
50
+ isInitialLoading = _React$useState12[0],
51
+ setIsInitialLoading = _React$useState12[1];
52
+ var canInit = materialSharedUtils.useMaterialConfigApiClientUpdate(apiClient.config.init);
53
+ var resetLayout = function resetLayout() {
28
54
  setIsInitialLoading(true);
29
55
  setIsLongPassage(false);
30
56
  };
31
- const {
32
- materialQuiz,
33
- materialLecturePage,
34
- refetch: refreshOrgMaterialQuiz
35
- } = materialSharedUtils.useMaterialFetchRaw(types.enums.LectureMaterialType.Quiz, React.useCallback(async signal => {
36
- await apiClient.postOrgMaterialQuizOptionsSetSelect({
37
- materialQuizId
38
- }, {
39
- signal
40
- });
41
- return await apiClient.getOrgMaterialQuizGet({
42
- materialQuizId,
43
- userId
44
- }, {
45
- signal
46
- });
47
- }, [materialQuizId, userId]), canInit);
48
- const init = React.useCallback(async () => {
49
- const controller = new AbortController();
50
- const {
51
- signal
52
- } = controller;
53
- try {
54
- setInitStatus('pending');
55
- if (!materialLecturePage) {
56
- throw new Error('materialSurvey is not ready');
57
+ var _useMaterialFetchRaw = materialSharedUtils.useMaterialFetchRaw(types.enums.LectureMaterialType.Quiz, React__default.default.useCallback( /*#__PURE__*/function () {
58
+ var _ref2 = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee(signal) {
59
+ return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee$(_context) {
60
+ while (1) switch (_context.prev = _context.next) {
61
+ case 0:
62
+ _context.next = 2;
63
+ return apiClient.postOrgMaterialQuizOptionsSetSelect({
64
+ materialQuizId: materialQuizId
65
+ }, {
66
+ signal: signal
67
+ });
68
+ case 2:
69
+ _context.next = 4;
70
+ return apiClient.getOrgMaterialQuizGet({
71
+ materialQuizId: materialQuizId,
72
+ userId: userId
73
+ }, {
74
+ signal: signal
75
+ });
76
+ case 4:
77
+ return _context.abrupt("return", _context.sent);
78
+ case 5:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }, _callee);
83
+ }));
84
+ return function (_x) {
85
+ return _ref2.apply(this, arguments);
86
+ };
87
+ }(), [materialQuizId, userId]), canInit),
88
+ materialQuiz = _useMaterialFetchRaw.materialQuiz,
89
+ materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
90
+ refreshOrgMaterialQuiz = _useMaterialFetchRaw.refetch;
91
+ var init = React__default.default.useCallback( /*#__PURE__*/_rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/_rollupPluginBabelHelpers.regeneratorRuntime().mark(function _callee2() {
92
+ var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
93
+ return _rollupPluginBabelHelpers.regeneratorRuntime().wrap(function _callee2$(_context2) {
94
+ while (1) switch (_context2.prev = _context2.next) {
95
+ case 0:
96
+ controller = new AbortController();
97
+ signal = controller.signal;
98
+ _context2.prev = 2;
99
+ setInitStatus('pending');
100
+ if (materialLecturePage) {
101
+ _context2.next = 6;
102
+ break;
103
+ }
104
+ throw new Error('materialSurvey is not ready');
105
+ case 6:
106
+ _context2.next = 8;
107
+ return apiClient.getOrgCourseGet({
108
+ courseId: materialLecturePage.courseId
109
+ }, {
110
+ signal: signal
111
+ });
112
+ case 8:
113
+ _yield$getOrgCourseGe = _context2.sent;
114
+ _course = _yield$getOrgCourseGe.course;
115
+ _context2.next = 12;
116
+ return apiClient.getOrgLectureGet({
117
+ lectureId: materialLecturePage.lectureId
118
+ }, {
119
+ signal: signal
120
+ });
121
+ case 12:
122
+ _yield$getOrgLectureG = _context2.sent;
123
+ _lecture = _yield$getOrgLectureG.lecture;
124
+ setCourse(_course);
125
+ setLecture(_lecture);
126
+ setInitStatus('resolved');
127
+ _context2.next = 23;
128
+ break;
129
+ case 19:
130
+ _context2.prev = 19;
131
+ _context2.t0 = _context2["catch"](2);
132
+ console.error(_context2.t0);
133
+ setInitStatus('rejected');
134
+ case 23:
135
+ return _context2.abrupt("return", function () {
136
+ return controller.abort();
137
+ });
138
+ case 24:
139
+ case "end":
140
+ return _context2.stop();
57
141
  }
58
- // fetch course
59
- const {
60
- course
61
- } = await apiClient.getOrgCourseGet({
62
- courseId: materialLecturePage.courseId
63
- }, {
64
- signal
65
- });
66
- // fetch lecture
67
- const {
68
- lecture
69
- } = await apiClient.getOrgLectureGet({
70
- lectureId: materialLecturePage.lectureId
71
- }, {
72
- signal
73
- });
74
- setCourse(course);
75
- setLecture(lecture);
76
- setInitStatus('resolved');
77
- } catch (error) {
78
- console.error(error);
79
- setInitStatus('rejected');
80
- }
81
- return () => controller.abort();
82
- }, [materialLecturePage]);
83
- React.useEffect(() => {
142
+ }, _callee2, null, [[2, 19]]);
143
+ })), [materialLecturePage]);
144
+ React.useEffect(function () {
84
145
  if (materialQuizId) {
85
146
  resetLayout();
86
147
  }
87
148
  }, [materialQuizId]);
88
- React.useEffect(() => {
149
+ React__default.default.useEffect(function () {
89
150
  if (canInit && materialLecturePage) {
90
151
  void init();
91
152
  }
92
153
  }, [canInit, materialLecturePage, init]);
93
- return React.createElement(StateContext.Provider, {
154
+ return jsxRuntime.jsx(StateContext.Provider, {
94
155
  value: {
95
- course,
96
- lecture,
156
+ course: course,
157
+ lecture: lecture,
97
158
  materialQuiz: materialQuiz !== null && materialQuiz !== void 0 ? materialQuiz : undefined,
98
- userId,
99
- vertical,
100
- initStatus,
101
- isLongPassage,
102
- isInitialLoading
103
- }
104
- }, React.createElement(DispatchContext.Provider, {
105
- value: {
106
- onSubmit,
107
- onDirty,
108
- onNext,
109
- refreshOrgMaterialQuiz,
110
- setVertical,
111
- setIsLongPassage,
112
- setIsInitialLoading
113
- }
114
- }, children));
159
+ userId: userId,
160
+ vertical: vertical,
161
+ initStatus: initStatus,
162
+ isLongPassage: isLongPassage,
163
+ isInitialLoading: isInitialLoading
164
+ },
165
+ children: jsxRuntime.jsx(DispatchContext.Provider, {
166
+ value: {
167
+ onSubmit: onSubmit,
168
+ onDirty: onDirty,
169
+ onNext: onNext,
170
+ refreshOrgMaterialQuiz: refreshOrgMaterialQuiz,
171
+ setVertical: setVertical,
172
+ setIsLongPassage: setIsLongPassage,
173
+ setIsInitialLoading: setIsInitialLoading
174
+ },
175
+ children: children
176
+ })
177
+ });
115
178
  }
116
179
  function useMaterialQuizState() {
117
- const context = React.useContext(StateContext);
180
+ var context = React__default.default.useContext(StateContext);
118
181
  if (context === undefined) {
119
182
  throw new Error('useMaterialQuizState must be used within a MaterialQuizProvider');
120
183
  }
121
184
  return context;
122
185
  }
123
186
  function useMaterialQuizDispatch() {
124
- const context = React.useContext(DispatchContext);
187
+ var context = React__default.default.useContext(DispatchContext);
125
188
  if (context === undefined) {
126
189
  throw new Error('useMaterialQuizDispatch must be used within a MaterialQuizProvider');
127
190
  }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var MaterialQuiz = require('./MaterialQuiz.js');
4
+ var MaterialQuizInfo = require('./MaterialQuizInfo.js');
5
+
6
+
7
+
8
+ exports.MaterialQuiz = MaterialQuiz.default;
9
+ exports.MaterialQuizInfo = MaterialQuizInfo.default;
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var en = require('./en.json.js');
4
+ var ko = require('./ko.json.js');
5
+ var th = require('./th.json.js');
6
+ var ja = require('./ja.json.js');
7
+
8
+
9
+
10
+ exports.messageEn = en.default;
11
+ exports.messageKo = ko.default;
12
+ exports.messageTh = th.default;
13
+ exports.messageJa = ja.default;