@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,3 +1,4 @@
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
1
2
  import React from 'react';
2
3
  import { Flex, Button, Vspace, Text, Icon } from '@elice/blocks';
3
4
  import { base } from '@elice/design-tokens';
@@ -9,141 +10,169 @@ import { useMaterialQuizState } from '../context/MaterialQuizContext.js';
9
10
  import QuizGroupContext from './context/context.js';
10
11
  import MaterialQuizGroupOptionItem from './MaterialQuizGroupOptionItem.js';
11
12
 
12
- const QUIZ_OPTIONS_CONTENT_WIDTH = 534;
13
- const StyledQuizAnswerWrapper = styled.div.withConfig({
13
+ var QUIZ_OPTIONS_CONTENT_WIDTH = 534;
14
+ var StyledQuizAnswerWrapper = styled.div.withConfig({
14
15
  componentId: "sc-18trt81-0"
15
16
  })(["display:flex;flex-direction:column;flex:0 0 calc((100% - ", "px) / 2);"], QUIZ_OPTIONS_CONTENT_WIDTH);
16
- const StyledQuizAnswerDropzoneWrapper = styled.div.withConfig({
17
+ var StyledQuizAnswerDropzoneWrapper = styled.div.withConfig({
17
18
  componentId: "sc-18trt81-1"
18
19
  })(["padding:1rem;border-radius:0.5rem;background:", ";&:not(:last-child){margin-bottom:1rem;}"], base.color.white);
19
- const StyledQuizAnswerDropzone = styled(EbDroppable).withConfig({
20
+ var StyledQuizAnswerDropzone = styled(EbDroppable).withConfig({
20
21
  componentId: "sc-18trt81-2"
21
- })(["display:flex;flex-wrap:wrap;gap:0.5rem;justify-content:", ";align-items:", ";min-width:12.5rem;min-height:16.25rem;padding:0.5rem;border-radius:0.5rem;background:", ";text-align:center;outline:1px dashed ", ";&.ui-droppable-hover{outline:1px dashed ", ";}"], ({
22
- isGroupAnswer
23
- }) => isGroupAnswer ? 'flex-start' : 'center', ({
24
- isGroupAnswer
25
- }) => isGroupAnswer ? 'flex-start' : 'center', base.color.gray1, base.color.gray3, base.color.navy4);
26
- const StyledQuizOptions = styled.div.withConfig({
22
+ })(["display:flex;flex-wrap:wrap;gap:0.5rem;justify-content:", ";align-items:", ";min-width:12.5rem;min-height:16.25rem;padding:0.5rem;border-radius:0.5rem;background:", ";text-align:center;outline:1px dashed ", ";&.ui-droppable-hover{outline:1px dashed ", ";}"], function (_ref) {
23
+ var isGroupAnswer = _ref.isGroupAnswer;
24
+ return isGroupAnswer ? 'flex-start' : 'center';
25
+ }, function (_ref2) {
26
+ var isGroupAnswer = _ref2.isGroupAnswer;
27
+ return isGroupAnswer ? 'flex-start' : 'center';
28
+ }, base.color.gray1, base.color.gray3, base.color.navy4);
29
+ var StyledQuizOptions = styled.div.withConfig({
27
30
  componentId: "sc-18trt81-3"
28
31
  })(["display:flex;flex-direction:column;width:26.125rem;height:fit-content;padding:1rem;background-color:", ";border-radius:0.5rem;outline:1px dashed ", ";"], base.color.navy6, base.color.navy4);
29
- const StyledQuizOptionsDropzone = styled(EbDroppable).withConfig({
32
+ var StyledQuizOptionsDropzone = styled(EbDroppable).withConfig({
30
33
  componentId: "sc-18trt81-4"
31
34
  })(["display:flex;flex-wrap:wrap;gap:1rem;min-height:10.25rem;border-radius:0.5rem;outline:1px dashed ", ";&.ui-droppable-hover{outline:1px dashed ", ";}"], base.color.navy4, base.color.gray4);
32
- const MaterialQuizGroupDesktop = () => {
33
- const intl = useRawEliceIntl();
34
- const {
35
- userId
36
- } = useMaterialQuizState();
37
- const {
38
- groupList,
39
- currentAnswerList,
40
- currentOptionList,
41
- updateCurrentAnswer,
42
- updateCurrentOption,
43
- handleAnswerReset
44
- } = React.useContext(QuizGroupContext);
35
+ var MaterialQuizGroupDesktop = function MaterialQuizGroupDesktop() {
36
+ var intl = useRawEliceIntl();
37
+ var _useMaterialQuizState = useMaterialQuizState(),
38
+ userId = _useMaterialQuizState.userId;
39
+ var _React$useContext = React.useContext(QuizGroupContext),
40
+ groupList = _React$useContext.groupList,
41
+ currentAnswerList = _React$useContext.currentAnswerList,
42
+ currentOptionList = _React$useContext.currentOptionList,
43
+ updateCurrentAnswer = _React$useContext.updateCurrentAnswer,
44
+ updateCurrentOption = _React$useContext.updateCurrentOption,
45
+ handleAnswerReset = _React$useContext.handleAnswerReset;
45
46
  /**
46
47
  *
47
48
  */
48
- const renderQuizContentSortation = () => {
49
- return React.createElement(Flex, {
49
+ var renderQuizContentSortation = function renderQuizContentSortation() {
50
+ return jsx(Flex, {
50
51
  align: "center",
51
- margin: "0 1.25rem"
52
- }, React.createElement(Icon, {
53
- size: "large",
54
- icon: eilSortItem,
55
- rotate: 90,
56
- color: "white"
57
- }));
52
+ margin: "0 1.25rem",
53
+ children: jsx(Icon, {
54
+ size: "large",
55
+ icon: eilSortItem,
56
+ rotate: 90,
57
+ color: "white"
58
+ })
59
+ });
58
60
  };
59
61
  /**
60
62
  *
61
63
  */
62
- const renderQuizGroupAnswer = (title, dropzoneIndex) => {
64
+ var renderQuizGroupAnswer = function renderQuizGroupAnswer(title, dropzoneIndex) {
63
65
  var _a, _b;
64
- const isGroupAnswer = Boolean((_a = currentAnswerList[dropzoneIndex]) === null || _a === void 0 ? void 0 : _a.length);
65
- return React.createElement(StyledQuizAnswerDropzoneWrapper, null, React.createElement(Text, {
66
- size: "large",
67
- bold: true
68
- }, title), React.createElement(Vspace, {
69
- height: 1
70
- }), React.createElement(StyledQuizAnswerDropzone, {
71
- accept: ".quiz-answer",
72
- disabled: !!userId,
73
- isGroupAnswer: isGroupAnswer,
74
- onDrop: (event, ui) => {
75
- const targetId = Number(ui.draggable[0].id);
76
- updateCurrentAnswer(targetId, dropzoneIndex);
77
- }
78
- }, isGroupAnswer ? (_b = currentAnswerList[dropzoneIndex]) === null || _b === void 0 ? void 0 : _b.map((answer, index) => React.createElement(MaterialQuizGroupOptionItem, {
79
- key: index,
80
- option: answer
81
- })) : React.createElement(Text, {
82
- role: "gray5",
83
- bold: true
84
- }, intl.formatMessage({
85
- id: 'materialQuiz.dropzone.desktop.answerEmpty'
86
- }))));
66
+ var isGroupAnswer = Boolean((_a = currentAnswerList[dropzoneIndex]) === null || _a === void 0 ? void 0 : _a.length);
67
+ return jsxs(StyledQuizAnswerDropzoneWrapper, {
68
+ children: [jsx(Text, {
69
+ size: "large",
70
+ bold: true,
71
+ children: title
72
+ }), jsx(Vspace, {
73
+ height: 1
74
+ }), jsx(StyledQuizAnswerDropzone, {
75
+ accept: ".quiz-answer",
76
+ disabled: !!userId,
77
+ isGroupAnswer: isGroupAnswer,
78
+ onDrop: function onDrop(event, ui) {
79
+ var targetId = Number(ui.draggable[0].id);
80
+ updateCurrentAnswer(targetId, dropzoneIndex);
81
+ },
82
+ children: isGroupAnswer ? (_b = currentAnswerList[dropzoneIndex]) === null || _b === void 0 ? void 0 : _b.map(function (answer, index) {
83
+ return jsx(MaterialQuizGroupOptionItem, {
84
+ option: answer
85
+ }, index);
86
+ }) : jsx(Text, {
87
+ role: "gray5",
88
+ bold: true,
89
+ children: intl.formatMessage({
90
+ id: 'materialQuiz.dropzone.desktop.answerEmpty'
91
+ })
92
+ })
93
+ })]
94
+ });
87
95
  };
88
96
  /**
89
97
  *
90
98
  */
91
- const renderQuizContentLeft = () => {
92
- return React.createElement(StyledQuizAnswerWrapper, null, groupList.filter((_, index) => !(index % 2)).map((group, index) => React.createElement(React.Fragment, {
93
- key: index
94
- }, renderQuizGroupAnswer(group, index * 2))));
99
+ var renderQuizContentLeft = function renderQuizContentLeft() {
100
+ return jsx(StyledQuizAnswerWrapper, {
101
+ children: groupList.filter(function (_, index) {
102
+ return !(index % 2);
103
+ }).map(function (group, index) {
104
+ return jsx(React.Fragment, {
105
+ children: renderQuizGroupAnswer(group, index * 2)
106
+ }, index);
107
+ })
108
+ });
95
109
  };
96
110
  /**
97
111
  *
98
112
  */
99
- const renderQuizContentRight = () => {
100
- return React.createElement(StyledQuizAnswerWrapper, null, groupList.filter((_, index) => index % 2).map((group, index) => React.createElement(React.Fragment, {
101
- key: index
102
- }, renderQuizGroupAnswer(group, index * 2 + 1))));
113
+ var renderQuizContentRight = function renderQuizContentRight() {
114
+ return jsx(StyledQuizAnswerWrapper, {
115
+ children: groupList.filter(function (_, index) {
116
+ return index % 2;
117
+ }).map(function (group, index) {
118
+ return jsx(React.Fragment, {
119
+ children: renderQuizGroupAnswer(group, index * 2 + 1)
120
+ }, index);
121
+ })
122
+ });
103
123
  };
104
124
  /**
105
125
  *
106
126
  */
107
- const renderQuizContentOption = () => {
108
- return React.createElement(Flex, {
109
- height: "fit-content"
110
- }, renderQuizContentSortation(), React.createElement(StyledQuizOptions, null, React.createElement(Button, {
111
- role: "white",
112
- size: "small",
113
- disabled: !!userId,
114
- onClick: handleAnswerReset
115
- }, intl.formatMessage({
116
- id: 'materialQuiz.dropzone.optionReset'
117
- })), React.createElement(Vspace, {
118
- height: 1
119
- }), React.createElement(StyledQuizOptionsDropzone, {
120
- accept: ".quiz-answer",
121
- onDrop: (event, ui) => {
122
- const targetId = Number(ui.draggable[0].id);
123
- updateCurrentOption(targetId);
124
- }
125
- }, currentOptionList.length ? currentOptionList.map((option, index) => React.createElement(MaterialQuizGroupOptionItem, {
126
- key: index,
127
- option: option
128
- })) : React.createElement(Flex, {
129
- justify: "center",
130
- align: "center",
131
- width: "100%"
132
- }, React.createElement(Text, {
133
- role: "navy",
134
- textAlign: "center",
135
- bold: true
136
- }, intl.formatMessage({
137
- id: 'materialQuiz.dropzone.optionEmpty'
138
- }))))), renderQuizContentSortation());
127
+ var renderQuizContentOption = function renderQuizContentOption() {
128
+ return jsxs(Flex, {
129
+ height: "fit-content",
130
+ children: [renderQuizContentSortation(), jsxs(StyledQuizOptions, {
131
+ children: [jsx(Button, {
132
+ role: "white",
133
+ size: "small",
134
+ disabled: !!userId,
135
+ onClick: handleAnswerReset,
136
+ children: intl.formatMessage({
137
+ id: 'materialQuiz.dropzone.optionReset'
138
+ })
139
+ }), jsx(Vspace, {
140
+ height: 1
141
+ }), jsx(StyledQuizOptionsDropzone, {
142
+ accept: ".quiz-answer",
143
+ onDrop: function onDrop(event, ui) {
144
+ var targetId = Number(ui.draggable[0].id);
145
+ updateCurrentOption(targetId);
146
+ },
147
+ children: currentOptionList.length ? currentOptionList.map(function (option, index) {
148
+ return jsx(MaterialQuizGroupOptionItem, {
149
+ option: option
150
+ }, index);
151
+ }) : jsx(Flex, {
152
+ justify: "center",
153
+ align: "center",
154
+ width: "100%",
155
+ children: jsx(Text, {
156
+ role: "navy",
157
+ textAlign: "center",
158
+ bold: true,
159
+ children: intl.formatMessage({
160
+ id: 'materialQuiz.dropzone.optionEmpty'
161
+ })
162
+ })
163
+ })
164
+ })]
165
+ }), renderQuizContentSortation()]
166
+ });
139
167
  };
140
168
  //
141
169
  //
142
170
  //
143
- return React.createElement(Flex, {
171
+ return jsxs(Flex, {
144
172
  width: "100%",
145
- height: "100%"
146
- }, renderQuizContentLeft(), renderQuizContentOption(), renderQuizContentRight());
173
+ height: "100%",
174
+ children: [renderQuizContentLeft(), renderQuizContentOption(), renderQuizContentRight()]
175
+ });
147
176
  };
148
177
 
149
178
  export { MaterialQuizGroupDesktop as default };
@@ -1,3 +1,5 @@
1
+ import { slicedToArray as _slicedToArray } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
1
3
  import React from 'react';
2
4
  import { Button, Vspace, Text, BottomSheet } from '@elice/blocks';
3
5
  import { base } from '@elice/design-tokens';
@@ -7,136 +9,158 @@ import { useMaterialQuizState } from '../context/MaterialQuizContext.js';
7
9
  import QuizGroupContext from './context/context.js';
8
10
  import MaterialQuizGroupOptionItem from './MaterialQuizGroupOptionItem.js';
9
11
 
10
- const StyledQuizGroupWrapper = styled.div.withConfig({
12
+ var StyledQuizGroupWrapper = styled.div.withConfig({
11
13
  componentId: "sc-bftjpj-0"
12
14
  })(["display:flex;flex-direction:column;overflow:hidden;width:100%;padding:1rem;background:", ";border-radius:0.5rem;&:hover{cursor:pointer;}&:not(:last-child){margin-bottom:1rem;}"], base.color.white);
13
- const StyledQuizOptionList = styled.div.withConfig({
15
+ var StyledQuizOptionList = styled.div.withConfig({
14
16
  componentId: "sc-bftjpj-1"
15
- })(["display:flex;align-items:", ";gap:0.5rem;overflow-x:auto;min-height:223px;padding:1rem;border-radius:0.5rem;background:", ";outline-color:", ";"], ({
16
- isCurrentOptionList
17
- }) => isCurrentOptionList ? 'flex-start' : 'center', base.color.gray1, base.color.gray3);
18
- const StyledQuizOptionItem = styled.div.withConfig({
17
+ })(["display:flex;align-items:", ";gap:0.5rem;overflow-x:auto;min-height:223px;padding:1rem;border-radius:0.5rem;background:", ";outline-color:", ";"], function (_ref) {
18
+ var isCurrentOptionList = _ref.isCurrentOptionList;
19
+ return isCurrentOptionList ? 'flex-start' : 'center';
20
+ }, base.color.gray1, base.color.gray3);
21
+ var StyledQuizOptionItem = styled.div.withConfig({
19
22
  componentId: "sc-bftjpj-2"
20
23
  })(["&:hover{cursor:pointer;}"]);
21
- const StyledBottomSheetWrapper = styled(StyledQuizOptionList).withConfig({
24
+ var StyledBottomSheetWrapper = styled(StyledQuizOptionList).withConfig({
22
25
  componentId: "sc-bftjpj-3"
23
- })(["align-items:", ";padding:0.5rem;"], ({
24
- vertical,
25
- isCurrentOptionList
26
- }) => vertical && isCurrentOptionList ? 'flex-start' : 'center');
27
- const MaterialQuizGroupMobile = () => {
28
- const intl = useRawEliceIntl();
26
+ })(["align-items:", ";padding:0.5rem;"], function (_ref2) {
27
+ var vertical = _ref2.vertical,
28
+ isCurrentOptionList = _ref2.isCurrentOptionList;
29
+ return vertical && isCurrentOptionList ? 'flex-start' : 'center';
30
+ });
31
+ var MaterialQuizGroupMobile = function MaterialQuizGroupMobile() {
32
+ var intl = useRawEliceIntl();
29
33
  // context
30
- const {
31
- materialQuiz,
32
- userId,
33
- vertical
34
- } = useMaterialQuizState();
35
- const {
36
- currentOptionList,
37
- currentAnswerList,
38
- updateCurrentAnswer,
39
- updateCurrentOption,
40
- handleAnswerReset
41
- } = React.useContext(QuizGroupContext);
42
- const [dropzoneIndex, setDropzoneIndex] = React.useState(null);
34
+ var _useMaterialQuizState = useMaterialQuizState(),
35
+ materialQuiz = _useMaterialQuizState.materialQuiz,
36
+ userId = _useMaterialQuizState.userId,
37
+ vertical = _useMaterialQuizState.vertical;
38
+ var _React$useContext = React.useContext(QuizGroupContext),
39
+ currentOptionList = _React$useContext.currentOptionList,
40
+ currentAnswerList = _React$useContext.currentAnswerList,
41
+ updateCurrentAnswer = _React$useContext.updateCurrentAnswer,
42
+ updateCurrentOption = _React$useContext.updateCurrentOption,
43
+ handleAnswerReset = _React$useContext.handleAnswerReset;
44
+ var _React$useState = React.useState(null),
45
+ _React$useState2 = _slicedToArray(_React$useState, 2),
46
+ dropzoneIndex = _React$useState2[0],
47
+ setDropzoneIndex = _React$useState2[1];
43
48
  /**
44
49
  *
45
50
  */
46
- const renderResetButton = () => {
47
- return React.createElement(React.Fragment, null, React.createElement(Button, {
48
- role: "white",
49
- size: "small",
50
- disabled: !!userId,
51
- onClick: handleAnswerReset,
52
- block: true
53
- }, intl.formatMessage({
54
- id: 'materialQuiz.dropzone.optionReset'
55
- })), React.createElement(Vspace, {
56
- height: 1
57
- }));
51
+ var renderResetButton = function renderResetButton() {
52
+ return jsxs(Fragment, {
53
+ children: [jsx(Button, {
54
+ role: "white",
55
+ size: "small",
56
+ disabled: !!userId,
57
+ onClick: handleAnswerReset,
58
+ block: true,
59
+ children: intl.formatMessage({
60
+ id: 'materialQuiz.dropzone.optionReset'
61
+ })
62
+ }), jsx(Vspace, {
63
+ height: 1
64
+ })]
65
+ });
58
66
  };
59
67
  /**
60
68
  *
61
69
  */
62
- const renderGroupList = () => {
70
+ var renderGroupList = function renderGroupList() {
63
71
  var _a;
64
- return React.createElement(React.Fragment, null, (_a = materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.groups) === null || _a === void 0 ? void 0 : _a.map((group, index) => {
65
- var _a;
66
- const isCurrentOptionList = Boolean((_a = currentAnswerList === null || currentAnswerList === void 0 ? void 0 : currentAnswerList[index]) === null || _a === void 0 ? void 0 : _a.length);
67
- return React.createElement(StyledQuizGroupWrapper, {
68
- key: index,
69
- onClick: () => setDropzoneIndex(index)
70
- }, React.createElement(Text, {
71
- size: "small",
72
- bold: true
73
- }, group), React.createElement(Vspace, {
74
- height: 0.5
75
- }), React.createElement(StyledQuizOptionList, {
76
- isCurrentOptionList: isCurrentOptionList
77
- }, isCurrentOptionList ? currentAnswerList[index].map(answer => React.createElement(MaterialQuizGroupOptionItem, {
78
- key: answer.order,
79
- option: answer,
80
- onClose: () => {
81
- const targetId = answer.order;
82
- updateCurrentOption(targetId);
83
- }
84
- })) : React.createElement(Text, {
85
- role: "gray6",
86
- size: "small",
87
- textAlign: "center",
88
- bold: true,
89
- block: true
90
- }, intl.formatMessage({
91
- id: 'materialQuiz.dropzone.mobile.answerEmpty'
92
- }))));
93
- }));
72
+ return jsx(Fragment, {
73
+ children: (_a = materialQuiz === null || materialQuiz === void 0 ? void 0 : materialQuiz.groups) === null || _a === void 0 ? void 0 : _a.map(function (group, index) {
74
+ var _a;
75
+ var isCurrentOptionList = Boolean((_a = currentAnswerList === null || currentAnswerList === void 0 ? void 0 : currentAnswerList[index]) === null || _a === void 0 ? void 0 : _a.length);
76
+ return jsxs(StyledQuizGroupWrapper, {
77
+ onClick: function onClick() {
78
+ return setDropzoneIndex(index);
79
+ },
80
+ children: [jsx(Text, {
81
+ size: "small",
82
+ bold: true,
83
+ children: group
84
+ }), jsx(Vspace, {
85
+ height: 0.5
86
+ }), jsx(StyledQuizOptionList, {
87
+ isCurrentOptionList: isCurrentOptionList,
88
+ children: isCurrentOptionList ? currentAnswerList[index].map(function (answer) {
89
+ return jsx(MaterialQuizGroupOptionItem, {
90
+ option: answer,
91
+ onClose: function onClose() {
92
+ var targetId = answer.order;
93
+ updateCurrentOption(targetId);
94
+ }
95
+ }, answer.order);
96
+ }) : jsx(Text, {
97
+ role: "gray6",
98
+ size: "small",
99
+ textAlign: "center",
100
+ bold: true,
101
+ block: true,
102
+ children: intl.formatMessage({
103
+ id: 'materialQuiz.dropzone.mobile.answerEmpty'
104
+ })
105
+ })
106
+ })]
107
+ }, index);
108
+ })
109
+ });
94
110
  };
95
111
  /**
96
112
  *
97
113
  */
98
- const renderOptionListBottomSheet = () => {
99
- const isCurrentOptionList = Boolean(currentOptionList.length);
100
- return React.createElement(BottomSheet, {
114
+ var renderOptionListBottomSheet = function renderOptionListBottomSheet() {
115
+ var isCurrentOptionList = Boolean(currentOptionList.length);
116
+ return jsx(BottomSheet, {
101
117
  show: dropzoneIndex !== null,
102
118
  title: intl.formatMessage({
103
119
  id: 'materialQuiz.bottomSheet.title'
104
120
  }),
105
121
  contentsText: "",
106
122
  disableSwipeGesture: true,
107
- onClose: () => setDropzoneIndex(null)
108
- }, React.createElement(StyledBottomSheetWrapper, {
109
- vertical: vertical,
110
- isCurrentOptionList: isCurrentOptionList
111
- }, isCurrentOptionList ? currentOptionList === null || currentOptionList === void 0 ? void 0 : currentOptionList.map((option, index) => React.createElement(StyledQuizOptionItem, {
112
- key: index,
113
- onClick: () => {
114
- const targetId = option.order;
115
- if (dropzoneIndex === null) {
116
- return;
117
- }
118
- if (!!userId) {
119
- return;
120
- }
121
- updateCurrentAnswer(targetId, dropzoneIndex);
122
- }
123
- }, React.createElement(MaterialQuizGroupOptionItem, {
124
- key: index,
125
- option: option
126
- }))) : React.createElement(Text, {
127
- role: "gray6",
128
- size: "small",
129
- textAlign: "center",
130
- bold: true,
131
- block: true
132
- }, intl.formatMessage({
133
- id: 'materialQuiz.bottomSheet.optionEmpty'
134
- }))));
123
+ onClose: function onClose() {
124
+ return setDropzoneIndex(null);
125
+ },
126
+ children: jsx(StyledBottomSheetWrapper, {
127
+ vertical: vertical,
128
+ isCurrentOptionList: isCurrentOptionList,
129
+ children: isCurrentOptionList ? currentOptionList === null || currentOptionList === void 0 ? void 0 : currentOptionList.map(function (option, index) {
130
+ return jsx(StyledQuizOptionItem, {
131
+ onClick: function onClick() {
132
+ var targetId = option.order;
133
+ if (dropzoneIndex === null) {
134
+ return;
135
+ }
136
+ if (!!userId) {
137
+ return;
138
+ }
139
+ updateCurrentAnswer(targetId, dropzoneIndex);
140
+ },
141
+ children: jsx(MaterialQuizGroupOptionItem, {
142
+ option: option
143
+ }, index)
144
+ }, index);
145
+ }) : jsx(Text, {
146
+ role: "gray6",
147
+ size: "small",
148
+ textAlign: "center",
149
+ bold: true,
150
+ block: true,
151
+ children: intl.formatMessage({
152
+ id: 'materialQuiz.bottomSheet.optionEmpty'
153
+ })
154
+ })
155
+ })
156
+ });
135
157
  };
136
158
  //
137
159
  //
138
160
  //
139
- return React.createElement(React.Fragment, null, renderResetButton(), renderGroupList(), renderOptionListBottomSheet());
161
+ return jsxs(Fragment, {
162
+ children: [renderResetButton(), renderGroupList(), renderOptionListBottomSheet()]
163
+ });
140
164
  };
141
165
 
142
166
  export { MaterialQuizGroupMobile as default };