@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,125 +1,184 @@
1
+ import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsx } from 'react/jsx-runtime';
1
3
  import React, { useEffect } from 'react';
2
- import { config, postOrgMaterialQuizOptionsSetSelect, getOrgMaterialQuizGet, getOrgCourseGet, getOrgLectureGet } from '@elice/api-client';
4
+ import { config, getOrgMaterialQuizGet, postOrgMaterialQuizOptionsSetSelect, getOrgLectureGet, getOrgCourseGet } from '@elice/api-client';
3
5
  import { useMaterialConfigApiClientUpdate, useMaterialFetchRaw } from '@elice/material-shared-utils';
4
6
  import { enums } from '@elice/types';
5
7
 
6
- const StateContext = React.createContext(undefined);
7
- const DispatchContext = React.createContext(undefined);
8
+ var StateContext = React.createContext(undefined);
9
+ var DispatchContext = React.createContext(undefined);
8
10
  StateContext.displayName = 'MaterialQuizStateContext';
9
11
  DispatchContext.displayName = 'MaterialQuizDispatchContext';
10
- function MaterialQuizProvider({
11
- materialQuizId,
12
- userId,
13
- onSubmit = () => void 0,
14
- onDirty,
15
- onNext,
16
- children
17
- }) {
18
- const [course, setCourse] = React.useState();
19
- const [lecture, setLecture] = React.useState();
20
- const [initStatus, setInitStatus] = React.useState('idle');
21
- const [vertical, setVertical] = React.useState(false);
22
- const [isLongPassage, setIsLongPassage] = React.useState(false);
23
- const [isInitialLoading, setIsInitialLoading] = React.useState(true);
24
- const canInit = useMaterialConfigApiClientUpdate(config.init);
25
- const resetLayout = () => {
12
+ function MaterialQuizProvider(_ref) {
13
+ var materialQuizId = _ref.materialQuizId,
14
+ userId = _ref.userId,
15
+ _ref$onSubmit = _ref.onSubmit,
16
+ onSubmit = _ref$onSubmit === void 0 ? function () {
17
+ return void 0;
18
+ } : _ref$onSubmit,
19
+ onDirty = _ref.onDirty,
20
+ onNext = _ref.onNext,
21
+ children = _ref.children;
22
+ var _React$useState = React.useState(),
23
+ _React$useState2 = _slicedToArray(_React$useState, 2),
24
+ course = _React$useState2[0],
25
+ setCourse = _React$useState2[1];
26
+ var _React$useState3 = React.useState(),
27
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
28
+ lecture = _React$useState4[0],
29
+ setLecture = _React$useState4[1];
30
+ var _React$useState5 = React.useState('idle'),
31
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
32
+ initStatus = _React$useState6[0],
33
+ setInitStatus = _React$useState6[1];
34
+ var _React$useState7 = React.useState(false),
35
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
36
+ vertical = _React$useState8[0],
37
+ setVertical = _React$useState8[1];
38
+ var _React$useState9 = React.useState(false),
39
+ _React$useState10 = _slicedToArray(_React$useState9, 2),
40
+ isLongPassage = _React$useState10[0],
41
+ setIsLongPassage = _React$useState10[1];
42
+ var _React$useState11 = React.useState(true),
43
+ _React$useState12 = _slicedToArray(_React$useState11, 2),
44
+ isInitialLoading = _React$useState12[0],
45
+ setIsInitialLoading = _React$useState12[1];
46
+ var canInit = useMaterialConfigApiClientUpdate(config.init);
47
+ var resetLayout = function resetLayout() {
26
48
  setIsInitialLoading(true);
27
49
  setIsLongPassage(false);
28
50
  };
29
- const {
30
- materialQuiz,
31
- materialLecturePage,
32
- refetch: refreshOrgMaterialQuiz
33
- } = useMaterialFetchRaw(enums.LectureMaterialType.Quiz, React.useCallback(async signal => {
34
- await postOrgMaterialQuizOptionsSetSelect({
35
- materialQuizId
36
- }, {
37
- signal
38
- });
39
- return await getOrgMaterialQuizGet({
40
- materialQuizId,
41
- userId
42
- }, {
43
- signal
44
- });
45
- }, [materialQuizId, userId]), canInit);
46
- const init = React.useCallback(async () => {
47
- const controller = new AbortController();
48
- const {
49
- signal
50
- } = controller;
51
- try {
52
- setInitStatus('pending');
53
- if (!materialLecturePage) {
54
- throw new Error('materialSurvey is not ready');
51
+ var _useMaterialFetchRaw = useMaterialFetchRaw(enums.LectureMaterialType.Quiz, React.useCallback( /*#__PURE__*/function () {
52
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(signal) {
53
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
54
+ while (1) switch (_context.prev = _context.next) {
55
+ case 0:
56
+ _context.next = 2;
57
+ return postOrgMaterialQuizOptionsSetSelect({
58
+ materialQuizId: materialQuizId
59
+ }, {
60
+ signal: signal
61
+ });
62
+ case 2:
63
+ _context.next = 4;
64
+ return getOrgMaterialQuizGet({
65
+ materialQuizId: materialQuizId,
66
+ userId: userId
67
+ }, {
68
+ signal: signal
69
+ });
70
+ case 4:
71
+ return _context.abrupt("return", _context.sent);
72
+ case 5:
73
+ case "end":
74
+ return _context.stop();
75
+ }
76
+ }, _callee);
77
+ }));
78
+ return function (_x) {
79
+ return _ref2.apply(this, arguments);
80
+ };
81
+ }(), [materialQuizId, userId]), canInit),
82
+ materialQuiz = _useMaterialFetchRaw.materialQuiz,
83
+ materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
84
+ refreshOrgMaterialQuiz = _useMaterialFetchRaw.refetch;
85
+ var init = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
86
+ var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
87
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
88
+ while (1) switch (_context2.prev = _context2.next) {
89
+ case 0:
90
+ controller = new AbortController();
91
+ signal = controller.signal;
92
+ _context2.prev = 2;
93
+ setInitStatus('pending');
94
+ if (materialLecturePage) {
95
+ _context2.next = 6;
96
+ break;
97
+ }
98
+ throw new Error('materialSurvey is not ready');
99
+ case 6:
100
+ _context2.next = 8;
101
+ return getOrgCourseGet({
102
+ courseId: materialLecturePage.courseId
103
+ }, {
104
+ signal: signal
105
+ });
106
+ case 8:
107
+ _yield$getOrgCourseGe = _context2.sent;
108
+ _course = _yield$getOrgCourseGe.course;
109
+ _context2.next = 12;
110
+ return getOrgLectureGet({
111
+ lectureId: materialLecturePage.lectureId
112
+ }, {
113
+ signal: signal
114
+ });
115
+ case 12:
116
+ _yield$getOrgLectureG = _context2.sent;
117
+ _lecture = _yield$getOrgLectureG.lecture;
118
+ setCourse(_course);
119
+ setLecture(_lecture);
120
+ setInitStatus('resolved');
121
+ _context2.next = 23;
122
+ break;
123
+ case 19:
124
+ _context2.prev = 19;
125
+ _context2.t0 = _context2["catch"](2);
126
+ console.error(_context2.t0);
127
+ setInitStatus('rejected');
128
+ case 23:
129
+ return _context2.abrupt("return", function () {
130
+ return controller.abort();
131
+ });
132
+ case 24:
133
+ case "end":
134
+ return _context2.stop();
55
135
  }
56
- // fetch course
57
- const {
58
- course
59
- } = await getOrgCourseGet({
60
- courseId: materialLecturePage.courseId
61
- }, {
62
- signal
63
- });
64
- // fetch lecture
65
- const {
66
- lecture
67
- } = await getOrgLectureGet({
68
- lectureId: materialLecturePage.lectureId
69
- }, {
70
- signal
71
- });
72
- setCourse(course);
73
- setLecture(lecture);
74
- setInitStatus('resolved');
75
- } catch (error) {
76
- console.error(error);
77
- setInitStatus('rejected');
78
- }
79
- return () => controller.abort();
80
- }, [materialLecturePage]);
81
- useEffect(() => {
136
+ }, _callee2, null, [[2, 19]]);
137
+ })), [materialLecturePage]);
138
+ useEffect(function () {
82
139
  if (materialQuizId) {
83
140
  resetLayout();
84
141
  }
85
142
  }, [materialQuizId]);
86
- React.useEffect(() => {
143
+ React.useEffect(function () {
87
144
  if (canInit && materialLecturePage) {
88
145
  void init();
89
146
  }
90
147
  }, [canInit, materialLecturePage, init]);
91
- return React.createElement(StateContext.Provider, {
148
+ return jsx(StateContext.Provider, {
92
149
  value: {
93
- course,
94
- lecture,
150
+ course: course,
151
+ lecture: lecture,
95
152
  materialQuiz: materialQuiz !== null && materialQuiz !== void 0 ? materialQuiz : undefined,
96
- userId,
97
- vertical,
98
- initStatus,
99
- isLongPassage,
100
- isInitialLoading
101
- }
102
- }, React.createElement(DispatchContext.Provider, {
103
- value: {
104
- onSubmit,
105
- onDirty,
106
- onNext,
107
- refreshOrgMaterialQuiz,
108
- setVertical,
109
- setIsLongPassage,
110
- setIsInitialLoading
111
- }
112
- }, children));
153
+ userId: userId,
154
+ vertical: vertical,
155
+ initStatus: initStatus,
156
+ isLongPassage: isLongPassage,
157
+ isInitialLoading: isInitialLoading
158
+ },
159
+ children: jsx(DispatchContext.Provider, {
160
+ value: {
161
+ onSubmit: onSubmit,
162
+ onDirty: onDirty,
163
+ onNext: onNext,
164
+ refreshOrgMaterialQuiz: refreshOrgMaterialQuiz,
165
+ setVertical: setVertical,
166
+ setIsLongPassage: setIsLongPassage,
167
+ setIsInitialLoading: setIsInitialLoading
168
+ },
169
+ children: children
170
+ })
171
+ });
113
172
  }
114
173
  function useMaterialQuizState() {
115
- const context = React.useContext(StateContext);
174
+ var context = React.useContext(StateContext);
116
175
  if (context === undefined) {
117
176
  throw new Error('useMaterialQuizState must be used within a MaterialQuizProvider');
118
177
  }
119
178
  return context;
120
179
  }
121
180
  function useMaterialQuizDispatch() {
122
- const context = React.useContext(DispatchContext);
181
+ var context = React.useContext(DispatchContext);
123
182
  if (context === undefined) {
124
183
  throw new Error('useMaterialQuizDispatch must be used within a MaterialQuizProvider');
125
184
  }
@@ -0,0 +1,2 @@
1
+ export { default as MaterialQuiz } from './MaterialQuiz.js';
2
+ export { default as MaterialQuizInfo } from './MaterialQuizInfo.js';
@@ -0,0 +1,4 @@
1
+ export { default as messageEn } from './en.json.js';
2
+ export { default as messageKo } from './ko.json.js';
3
+ export { default as messageTh } from './th.json.js';
4
+ export { default as messageJa } from './ja.json.js';