@elice/material-quiz 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 (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
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var jsxRuntime = require('react/jsx-runtime');
5
6
  var React = require('react');
6
7
  var designTokens = require('@elice/design-tokens');
7
8
  var styled = require('styled-components');
@@ -9,12 +10,16 @@ var color = require('../../material-quiz/constants/color.js');
9
10
  var getQuestionStatusStyle = require('../utils/getQuestionStatusStyle.js');
10
11
  var QuestionRadioContext = require('./QuestionRadioContext.js');
11
12
 
12
- const StyledQuestionRadioOption = styled.div.withConfig({
13
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
14
+
15
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
16
+ var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
17
+
18
+ var StyledQuestionRadioOption = styled__default.default.div.withConfig({
13
19
  componentId: "sc-cy66me-0"
14
- })(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";overflow-x:auto;&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
15
- checked,
16
- status
17
- }) => {
20
+ })(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";overflow-x:auto;&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], function (_ref) {
21
+ var checked = _ref.checked,
22
+ status = _ref.status;
18
23
  switch (status) {
19
24
  case 'correct':
20
25
  return color.CORRECT_BACKGROUND_COLOR;
@@ -25,17 +30,18 @@ const StyledQuestionRadioOption = styled.div.withConfig({
25
30
  default:
26
31
  return checked ? designTokens.base.color.primary1 : designTokens.base.color.navy6;
27
32
  }
28
- }, ({
29
- disabled
30
- }) => disabled ? 'not-allowed' : 'pointer', ({
31
- isAnswer
32
- }) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
33
- const StyledQuestionRadioInput = styled.input.withConfig({
33
+ }, function (_ref2) {
34
+ var disabled = _ref2.disabled;
35
+ return disabled ? 'not-allowed' : 'pointer';
36
+ }, function (_ref3) {
37
+ var isAnswer = _ref3.isAnswer;
38
+ return isAnswer ? "border: 3px solid ".concat(designTokens.base.color.green5) : '';
39
+ });
40
+ var StyledQuestionRadioInput = styled__default.default.input.withConfig({
34
41
  componentId: "sc-cy66me-1"
35
- })(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;border-radius:50%;width:1rem;height:1rem;margin-right:0.875rem;border:2px solid ", ";", ""], ({
36
- checked,
37
- status
38
- }) => {
42
+ })(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;border-radius:50%;width:1rem;height:1rem;margin-right:0.875rem;border:2px solid ", ";", ""], function (_ref4) {
43
+ var checked = _ref4.checked,
44
+ status = _ref4.status;
39
45
  switch (status) {
40
46
  case 'correct':
41
47
  return designTokens.base.color.green9;
@@ -44,11 +50,10 @@ const StyledQuestionRadioInput = styled.input.withConfig({
44
50
  default:
45
51
  return checked ? designTokens.base.color.primary6 : designTokens.base.color.gray3;
46
52
  }
47
- }, ({
48
- status,
49
- checked
50
- }) => {
51
- let bgColor;
53
+ }, function (_ref5) {
54
+ var status = _ref5.status,
55
+ checked = _ref5.checked;
56
+ var bgColor;
52
57
  switch (status) {
53
58
  case 'correct':
54
59
  bgColor = designTokens.base.color.green9;
@@ -60,57 +65,45 @@ const StyledQuestionRadioInput = styled.input.withConfig({
60
65
  bgColor = checked ? designTokens.base.color.primary6 : status ? designTokens.base.color.gray3 : 'transparent';
61
66
  break;
62
67
  }
63
- return `
64
- &:after {
65
- content: '';
66
- position: absolute;
67
- top: 50%;
68
- left: 50%;
69
- transform: translate(-50%, -50%);
70
- width: 70%;
71
- height: 70%;
72
- border-radius: 50%;
73
- background-color: ${bgColor};
74
- }
75
- `;
68
+ return "\n &:after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 70%;\n height: 70%;\n border-radius: 50%;\n background-color: ".concat(bgColor, ";\n }\n ");
76
69
  });
77
- const StyledLabel = styled.label.withConfig({
70
+ var StyledLabel = styled__default.default.label.withConfig({
78
71
  componentId: "sc-cy66me-2"
79
72
  })(["word-break:break-all;margin-right:0.875rem;font-size:", ";line-height:24px;", ""], designTokens.base.size.body3, getQuestionStatusStyle.getQuestionStatusStyle());
80
- const QuestionRadioOption = React.memo(({
81
- value,
82
- status,
83
- isAnswer,
84
- children
85
- }) => {
86
- const {
87
- selectedValue,
88
- disabled,
89
- onSelect
90
- } = QuestionRadioContext.useQuestionRadioContext();
91
- return React.createElement(StyledQuestionRadioOption, {
73
+ var QuestionRadioOption = React__default.default.memo(function (_ref6) {
74
+ var value = _ref6.value,
75
+ status = _ref6.status,
76
+ isAnswer = _ref6.isAnswer,
77
+ children = _ref6.children;
78
+ var _useQuestionRadioCont = QuestionRadioContext.useQuestionRadioContext(),
79
+ selectedValue = _useQuestionRadioCont.selectedValue,
80
+ disabled = _useQuestionRadioCont.disabled,
81
+ onSelect = _useQuestionRadioCont.onSelect;
82
+ return jsxRuntime.jsxs(StyledQuestionRadioOption, {
92
83
  isAnswer: isAnswer,
93
84
  disabled: disabled,
94
85
  checked: selectedValue === value,
95
- onClick: e => {
86
+ onClick: function onClick(e) {
96
87
  e.preventDefault();
97
88
  if (disabled) {
98
89
  return;
99
90
  }
100
91
  onSelect(value);
101
92
  },
102
- status: status
103
- }, React.createElement(StyledQuestionRadioInput, {
104
- id: value,
105
- type: "radio",
106
- readOnly: true,
107
- checked: selectedValue === value,
108
- status: status
109
- }), React.createElement(StyledLabel, {
110
- htmlFor: value,
111
- checked: selectedValue === value,
112
- status: status
113
- }, children));
93
+ status: status,
94
+ children: [jsxRuntime.jsx(StyledQuestionRadioInput, {
95
+ id: value,
96
+ type: "radio",
97
+ readOnly: true,
98
+ checked: selectedValue === value,
99
+ status: status
100
+ }), jsxRuntime.jsx(StyledLabel, {
101
+ htmlFor: value,
102
+ checked: selectedValue === value,
103
+ status: status,
104
+ children: children
105
+ })]
106
+ });
114
107
  });
115
108
 
116
109
  exports.default = QuestionRadioOption;
@@ -8,10 +8,9 @@ var color = require('../../material-quiz/constants/color.js');
8
8
  * Get shared question custom style depend on checked, status values.
9
9
  */
10
10
  function getQuestionStatusStyle() {
11
- return styled.css(["&,& p,& p.elicemd.elicemd--theme-dark{color:", ";table tbody > tr:nth-child(odd) > td{background-color:", ";}}"], ({
12
- checked,
13
- status
14
- }) => {
11
+ return styled.css(["&,& p,& p.elicemd.elicemd--theme-dark{color:", ";table tbody > tr:nth-child(odd) > td{background-color:", ";}}"], function (_ref) {
12
+ var checked = _ref.checked,
13
+ status = _ref.status;
15
14
  switch (status) {
16
15
  case 'correct':
17
16
  return color.CORRECT_TEXT_COLOR;
@@ -20,11 +19,10 @@ function getQuestionStatusStyle() {
20
19
  default:
21
20
  return checked ? designTokens.base.color.primary6 : designTokens.base.color.navy0;
22
21
  }
23
- }, ({
24
- checked,
25
- status
26
- }) => {
27
- return checked || status !== 'answer' ? `rgba(0, 0, 0, 0.08);` : null;
22
+ }, function (_ref2) {
23
+ var checked = _ref2.checked,
24
+ status = _ref2.status;
25
+ return checked || status !== 'answer' ? "rgba(0, 0, 0, 0.08);" : null;
28
26
  });
29
27
  }
30
28
 
@@ -1,11 +1,20 @@
1
1
  'use strict';
2
2
 
3
- const mergeRefs = (...refs) => element => refs.forEach(ref => {
4
- if (typeof ref === 'function') {
5
- ref(element);
6
- } else if (ref && typeof ref === 'object') {
7
- ref.current = element;
3
+ var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
4
+
5
+ var mergeRefs = function mergeRefs() {
6
+ for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
7
+ refs[_key] = arguments[_key];
8
8
  }
9
- });
9
+ return function (element) {
10
+ return refs.forEach(function (ref) {
11
+ if (typeof ref === 'function') {
12
+ ref(element);
13
+ } else if (ref && _rollupPluginBabelHelpers.typeof(ref) === 'object') {
14
+ ref.current = element;
15
+ }
16
+ });
17
+ };
18
+ };
10
19
 
11
20
  exports.mergeRefs = mergeRefs;
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- const MATERIAL_QUIZ_CONTAINER_ID = 'MATERIAL_QUIZ_CONTAINER_ID';
4
- const MATERIAL_QUIZ_PASSIVE_ID = 'MATERIAL_QUIZ_PASSIVE_ID';
5
- const MATERIAL_QUIZ_ANSWER_ID = 'MATERIAL_QUIZ_ANSWER_ID';
3
+ var MATERIAL_QUIZ_CONTAINER_ID = 'MATERIAL_QUIZ_CONTAINER_ID';
4
+ var MATERIAL_QUIZ_PASSIVE_ID = 'MATERIAL_QUIZ_PASSIVE_ID';
5
+ var MATERIAL_QUIZ_ANSWER_ID = 'MATERIAL_QUIZ_ANSWER_ID';
6
6
 
7
7
  exports.MATERIAL_QUIZ_ANSWER_ID = MATERIAL_QUIZ_ANSWER_ID;
8
8
  exports.MATERIAL_QUIZ_CONTAINER_ID = MATERIAL_QUIZ_CONTAINER_ID;
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var element = require('./element.js');
4
+
5
+
6
+
7
+ exports.MATERIAL_QUIZ_ANSWER_ID = element.MATERIAL_QUIZ_ANSWER_ID;
8
+ exports.MATERIAL_QUIZ_CONTAINER_ID = element.MATERIAL_QUIZ_CONTAINER_ID;
9
+ exports.MATERIAL_QUIZ_PASSIVE_ID = element.MATERIAL_QUIZ_PASSIVE_ID;
@@ -22,12 +22,11 @@ function getQuizResultStatus(materialQuizResponse) {
22
22
  }
23
23
  return exports.QuizResultStatus.NotSubmitted;
24
24
  }
25
- const getOptionStatus = ({
26
- isSelected,
27
- isActive,
28
- materialQuizResponse
29
- }) => {
30
- const status = getQuizResultStatus(materialQuizResponse);
25
+ var getOptionStatus = function getOptionStatus(_ref) {
26
+ var isSelected = _ref.isSelected,
27
+ isActive = _ref.isActive,
28
+ materialQuizResponse = _ref.materialQuizResponse;
29
+ var status = getQuizResultStatus(materialQuizResponse);
31
30
  if (isActive) {
32
31
  return;
33
32
  }
@@ -44,9 +43,8 @@ const getOptionStatus = ({
44
43
  function checkUserLectureTestEnded(lecture) {
45
44
  return (lecture === null || lecture === void 0 ? void 0 : lecture.testAdmissionStatus) === types.enums.TestAdmissionStatus.Completed;
46
45
  }
47
- function shouldResetOptions({
48
- materialQuizResponse
49
- }) {
46
+ function shouldResetOptions(_ref2) {
47
+ var materialQuizResponse = _ref2.materialQuizResponse;
50
48
  // when score is given(correct, wrong), reset selected option in order to select options from scratch
51
49
  // score condition
52
50
  // normal quiz - score is always given(not a null) as long as a user submits the answer
@@ -54,7 +52,7 @@ function shouldResetOptions({
54
52
  return [(materialQuizResponse === null || materialQuizResponse === void 0 ? void 0 : materialQuizResponse.score) !== null].every(Boolean);
55
53
  }
56
54
  function getQuizResult(materialQuizResponse) {
57
- const status = getQuizResultStatus(materialQuizResponse);
55
+ var status = getQuizResultStatus(materialQuizResponse);
58
56
  switch (status) {
59
57
  case exports.QuizResultStatus.Correct:
60
58
  return true;
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var useCaculatePassage = require('./useCaculatePassage.js');
4
+
5
+
6
+
7
+ exports.useCaculatePassage = useCaculatePassage.useCaculatePassage;
@@ -1,33 +1,34 @@
1
1
  'use strict';
2
2
 
3
+ var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
3
4
  var React = require('react');
4
5
  var reactUse = require('react-use');
5
6
  var MaterialQuizContext = require('../components/material-quiz/context/MaterialQuizContext.js');
6
7
  var element = require('../constant/element.js');
7
8
 
8
- const useCaculatePassage = () => {
9
- const {
10
- materialQuiz,
11
- vertical
12
- } = MaterialQuizContext.useMaterialQuizState();
13
- const {
14
- setIsLongPassage,
15
- setIsInitialLoading
16
- } = MaterialQuizContext.useMaterialQuizDispatch();
17
- const [questionRef, {
18
- height: questionDetailHeight
19
- }] = reactUse.useMeasure();
20
- const [containerRef, {
21
- height: containerHeight
22
- }] = reactUse.useMeasure();
23
- React.useEffect(() => {
9
+ var useCaculatePassage = function useCaculatePassage() {
10
+ var _useMaterialQuizState = MaterialQuizContext.useMaterialQuizState(),
11
+ materialQuiz = _useMaterialQuizState.materialQuiz,
12
+ vertical = _useMaterialQuizState.vertical;
13
+ var _useMaterialQuizDispa = MaterialQuizContext.useMaterialQuizDispatch(),
14
+ setIsLongPassage = _useMaterialQuizDispa.setIsLongPassage,
15
+ setIsInitialLoading = _useMaterialQuizDispa.setIsInitialLoading;
16
+ var _useMeasure = reactUse.useMeasure(),
17
+ _useMeasure2 = _rollupPluginBabelHelpers.slicedToArray(_useMeasure, 2),
18
+ questionRef = _useMeasure2[0],
19
+ questionDetailHeight = _useMeasure2[1].height;
20
+ var _useMeasure3 = reactUse.useMeasure(),
21
+ _useMeasure4 = _rollupPluginBabelHelpers.slicedToArray(_useMeasure3, 2),
22
+ containerRef = _useMeasure4[0],
23
+ containerHeight = _useMeasure4[1].height;
24
+ React.useEffect(function () {
24
25
  var _a, _b;
25
- const currentContainerHeight = vertical ? (_b = (_a = document.getElementById(element.MATERIAL_QUIZ_CONTAINER_ID)) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0 : containerHeight;
26
+ var currentContainerHeight = vertical ? (_b = (_a = document.getElementById(element.MATERIAL_QUIZ_CONTAINER_ID)) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0 : containerHeight;
26
27
  if (currentContainerHeight && questionDetailHeight && materialQuiz) {
27
28
  setIsLongPassage(questionDetailHeight > currentContainerHeight);
28
29
  // add timeout for forcing caculate layout and render in the parent
29
30
  // finish before turning off loading
30
- setTimeout(() => {
31
+ setTimeout(function () {
31
32
  setIsInitialLoading(false);
32
33
  }, 300);
33
34
  } else if (materialQuiz && !materialQuiz.questionDescription) {
@@ -35,8 +36,8 @@ const useCaculatePassage = () => {
35
36
  }
36
37
  }, [containerHeight, questionDetailHeight, materialQuiz, setIsLongPassage, vertical, setIsInitialLoading]);
37
38
  return {
38
- questionRef,
39
- containerRef
39
+ questionRef: questionRef,
40
+ containerRef: containerRef
40
41
  };
41
42
  };
42
43