@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,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { useFormContext, useFieldArray } from 'react-hook-form';
3
3
  import { arrayMove } from 'react-sortable-hoc';
4
4
  import { Flex, Text, SortableListGroup, Tooltip, Button, Icon, Vspace, StatusText } from '@elice/blocks';
@@ -11,63 +11,75 @@ import { checkTwoDimensionArray } from '../../utils/checkTwoDimensionArray.js';
11
11
  import { createRandomId } from '../../utils/randomId.js';
12
12
  import OptionGroupAnswerListItem from './OptionGroupAnswerListItem.js';
13
13
 
14
- const MAX_OPTION_INFO_COUNT = 20;
15
- const StyledSortableList = styled.div.withConfig({
14
+ var MAX_OPTION_INFO_COUNT = 20;
15
+ var StyledSortableList = styled.div.withConfig({
16
16
  componentId: "sc-14yoda7-0"
17
17
  })(["margin:1rem 0;padding:0;"]);
18
- const StyledOptionTitle = styled.div.withConfig({
18
+ var StyledOptionTitle = styled.div.withConfig({
19
19
  componentId: "sc-14yoda7-1"
20
20
  })(["display:flex;width:calc(100% - 2rem - 1.5rem);"]);
21
21
  //
22
22
  //
23
23
  //
24
- const OptionGroupAnswerInfo = () => {
25
- const intl = useRawEliceIntl();
26
- const {
27
- setValue,
28
- watch
29
- } = useFormContext();
30
- const {
31
- disabled
32
- } = useMaterialQuizEditContext();
33
- const {
34
- append: appendOptionInfoFieldItem,
35
- remove: removeOptionInfoFieldItem
36
- } = useFieldArray({
37
- name: 'optionsDefault',
38
- keyName: 'id',
39
- shouldUnregister: true
40
- });
41
- const watchedAnswerInfo = watch('answerInfoDefault');
42
- const watchedOptions = watch('optionsDefault');
43
- const isMaximumOptions = (watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.length) >= MAX_OPTION_INFO_COUNT;
24
+ var OptionGroupAnswerInfo = function OptionGroupAnswerInfo() {
25
+ var intl = useRawEliceIntl();
26
+ var _useFormContext = useFormContext(),
27
+ setValue = _useFormContext.setValue,
28
+ watch = _useFormContext.watch;
29
+ var _useMaterialQuizEditC = useMaterialQuizEditContext(),
30
+ disabled = _useMaterialQuizEditC.disabled;
31
+ var _useFieldArray = useFieldArray({
32
+ name: 'optionsDefault',
33
+ keyName: 'id',
34
+ shouldUnregister: true
35
+ }),
36
+ appendOptionInfoFieldItem = _useFieldArray.append,
37
+ removeOptionInfoFieldItem = _useFieldArray.remove;
38
+ var watchedAnswerInfo = watch('answerInfoDefault');
39
+ var watchedOptions = watch('optionsDefault');
40
+ var isMaximumOptions = (watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.length) >= MAX_OPTION_INFO_COUNT;
44
41
  /**
45
42
  *
46
43
  */
47
- const handleRemoveItem = index => {
44
+ var handleRemoveItem = function handleRemoveItem(index) {
48
45
  var _a;
49
- const cloneAnswerList = cloneDeep(watchedAnswerInfo);
50
- const answerIndex = cloneAnswerList.findIndex(answers => answers.includes(index));
46
+ var cloneAnswerList = cloneDeep(watchedAnswerInfo);
47
+ var answerIndex = cloneAnswerList.findIndex(function (answers) {
48
+ return answers.includes(index);
49
+ });
51
50
  if (!cloneAnswerList[answerIndex]) {
52
51
  return removeOptionInfoFieldItem(index);
53
52
  }
54
- cloneAnswerList[answerIndex] = (_a = cloneAnswerList[answerIndex]) === null || _a === void 0 ? void 0 : _a.filter(answer => answer !== index);
55
- const recalculationAnswerList = cloneAnswerList.map(answers => answers.map(answer => answer > index ? answer - 1 : answer));
53
+ cloneAnswerList[answerIndex] = (_a = cloneAnswerList[answerIndex]) === null || _a === void 0 ? void 0 : _a.filter(function (answer) {
54
+ return answer !== index;
55
+ });
56
+ var recalculationAnswerList = cloneAnswerList.map(function (answers) {
57
+ return answers.map(function (answer) {
58
+ return answer > index ? answer - 1 : answer;
59
+ });
60
+ });
56
61
  removeOptionInfoFieldItem(index);
57
62
  setValue('answerInfoDefault', recalculationAnswerList);
58
63
  };
59
64
  /**
60
65
  *
61
66
  */
62
- const onSortEnd = ({
63
- oldIndex,
64
- newIndex
65
- }) => {
66
- const prevOptions = cloneDeep(watchedOptions).map((option, index) => Object.assign(Object.assign({}, option), {
67
- originIndex: index
68
- }));
69
- const updatedOptions = arrayMove(prevOptions, oldIndex, newIndex);
70
- const updatedAnswerInfo = watchedAnswerInfo.map(answerList => answerList.map(answer => updatedOptions.findIndex(option => option.originIndex === answer)));
67
+ var onSortEnd = function onSortEnd(_ref) {
68
+ var oldIndex = _ref.oldIndex,
69
+ newIndex = _ref.newIndex;
70
+ var prevOptions = cloneDeep(watchedOptions).map(function (option, index) {
71
+ return Object.assign(Object.assign({}, option), {
72
+ originIndex: index
73
+ });
74
+ });
75
+ var updatedOptions = arrayMove(prevOptions, oldIndex, newIndex);
76
+ var updatedAnswerInfo = watchedAnswerInfo.map(function (answerList) {
77
+ return answerList.map(function (answer) {
78
+ return updatedOptions.findIndex(function (option) {
79
+ return option.originIndex === answer;
80
+ });
81
+ });
82
+ });
71
83
  setValue('answerInfoDefault', updatedAnswerInfo);
72
84
  setValue('optionsDefault', updatedOptions, {
73
85
  shouldDirty: true
@@ -76,86 +88,112 @@ const OptionGroupAnswerInfo = () => {
76
88
  /**
77
89
  *
78
90
  */
79
- const renderAnswerTitle = () => {
80
- return React.createElement(StyledOptionTitle, null, React.createElement(Flex, {
81
- width: "33.3%",
82
- auto: true
83
- }, React.createElement(Text, {
84
- size: "small",
85
- bold: true
86
- }, intl.formatMessage({
87
- id: 'answer.option.title.text'
88
- }))), React.createElement(Flex, {
89
- width: "33.3%"
90
- }, React.createElement(Text, {
91
- size: "small",
92
- bold: true
93
- }, intl.formatMessage({
94
- id: 'answer.option.title.file'
95
- }))), React.createElement(Flex, {
96
- width: "calc(33.3% - 1.5rem)"
97
- }, React.createElement(Text, {
98
- size: "small",
99
- bold: true
100
- }, intl.formatMessage({
101
- id: 'answer.option.title.group'
102
- }))));
91
+ var renderAnswerTitle = function renderAnswerTitle() {
92
+ return jsxs(StyledOptionTitle, {
93
+ children: [jsx(Flex, {
94
+ width: "33.3%",
95
+ auto: true,
96
+ children: jsx(Text, {
97
+ size: "small",
98
+ bold: true,
99
+ children: intl.formatMessage({
100
+ id: 'answer.option.title.text'
101
+ })
102
+ })
103
+ }), jsx(Flex, {
104
+ width: "33.3%",
105
+ children: jsx(Text, {
106
+ size: "small",
107
+ bold: true,
108
+ children: intl.formatMessage({
109
+ id: 'answer.option.title.file'
110
+ })
111
+ })
112
+ }), jsx(Flex, {
113
+ width: "calc(33.3% - 1.5rem)",
114
+ children: jsx(Text, {
115
+ size: "small",
116
+ bold: true,
117
+ children: intl.formatMessage({
118
+ id: 'answer.option.title.group'
119
+ })
120
+ })
121
+ })]
122
+ });
103
123
  };
104
124
  /**
105
125
  *
106
126
  */
107
- const renderAnswerOptionList = () => {
108
- return React.createElement(SortableListGroup, {
127
+ var renderAnswerOptionList = function renderAnswerOptionList() {
128
+ return jsx(SortableListGroup, {
109
129
  onSortEnd: onSortEnd,
110
- useDragHandle: true
111
- }, React.createElement(StyledSortableList, null, watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.map((option, index) => React.createElement(OptionGroupAnswerListItem, {
112
- key: option.id,
113
- optionId: index,
114
- disabled: disabled,
115
- onRemoveItem: () => handleRemoveItem(index)
116
- }))));
130
+ useDragHandle: true,
131
+ children: jsx(StyledSortableList, {
132
+ children: watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.map(function (option, index) {
133
+ return jsx(OptionGroupAnswerListItem, {
134
+ optionId: index,
135
+ disabled: disabled,
136
+ onRemoveItem: function onRemoveItem() {
137
+ return handleRemoveItem(index);
138
+ }
139
+ }, option.id);
140
+ })
141
+ })
142
+ });
117
143
  };
118
144
  /**
119
145
  *
120
146
  */
121
- const renderAnswerOptionAddButton = () => {
122
- return React.createElement(React.Fragment, null, React.createElement(Tooltip, {
123
- title: isMaximumOptions ? intl.formatMessage({
124
- id: 'answer.option.tooltip.maxDisabled'
125
- }) : undefined,
126
- placement: "top"
127
- }, React.createElement("span", null, React.createElement(Button, {
128
- borderDashed: true,
129
- block: true,
130
- transparent: true,
131
- disabled: isMaximumOptions || disabled,
132
- icon: React.createElement(Icon, {
133
- icon: eilMathsignAddBasic
134
- }),
135
- onClick: () => appendOptionInfoFieldItem({
136
- id: createRandomId(),
137
- title: '',
138
- content: ''
139
- })
140
- }, intl.formatMessage({
141
- id: 'answer.option.addButton'
142
- })))), React.createElement(Vspace, {
143
- height: 0.5
144
- }), React.createElement(Flex, {
145
- column: true
146
- }, React.createElement(StatusText, {
147
- role: "description"
148
- }, intl.formatMessage({
149
- id: 'answer.option.file.description.imageSize'
150
- })), React.createElement(StatusText, {
151
- role: "description"
152
- }, intl.formatMessage({
153
- id: 'answer.option.file.description.fileSize'
154
- })), React.createElement(StatusText, {
155
- role: "description"
156
- }, intl.formatMessage({
157
- id: 'answer.option.file.description.extension'
158
- }))));
147
+ var renderAnswerOptionAddButton = function renderAnswerOptionAddButton() {
148
+ return jsxs(Fragment, {
149
+ children: [jsx(Tooltip, {
150
+ title: isMaximumOptions ? intl.formatMessage({
151
+ id: 'answer.option.tooltip.maxDisabled'
152
+ }) : undefined,
153
+ placement: "top",
154
+ children: jsx("span", {
155
+ children: jsx(Button, {
156
+ borderDashed: true,
157
+ block: true,
158
+ transparent: true,
159
+ disabled: isMaximumOptions || disabled,
160
+ icon: jsx(Icon, {
161
+ icon: eilMathsignAddBasic
162
+ }),
163
+ onClick: function onClick() {
164
+ return appendOptionInfoFieldItem({
165
+ id: createRandomId(),
166
+ title: '',
167
+ content: ''
168
+ });
169
+ },
170
+ children: intl.formatMessage({
171
+ id: 'answer.option.addButton'
172
+ })
173
+ })
174
+ })
175
+ }), jsx(Vspace, {
176
+ height: 0.5
177
+ }), jsxs(Flex, {
178
+ column: true,
179
+ children: [jsx(StatusText, {
180
+ role: "description",
181
+ children: intl.formatMessage({
182
+ id: 'answer.option.file.description.imageSize'
183
+ })
184
+ }), jsx(StatusText, {
185
+ role: "description",
186
+ children: intl.formatMessage({
187
+ id: 'answer.option.file.description.fileSize'
188
+ })
189
+ }), jsx(StatusText, {
190
+ role: "description",
191
+ children: intl.formatMessage({
192
+ id: 'answer.option.file.description.extension'
193
+ })
194
+ })]
195
+ })]
196
+ });
159
197
  };
160
198
  //
161
199
  //
@@ -163,9 +201,10 @@ const OptionGroupAnswerInfo = () => {
163
201
  if (!checkTwoDimensionArray(watchedAnswerInfo)) {
164
202
  return null;
165
203
  }
166
- return React.createElement(Flex, {
167
- column: true
168
- }, renderAnswerTitle(), renderAnswerOptionList(), renderAnswerOptionAddButton());
204
+ return jsxs(Flex, {
205
+ column: true,
206
+ children: [renderAnswerTitle(), renderAnswerOptionList(), renderAnswerOptionAddButton()]
207
+ });
169
208
  };
170
209
 
171
210
  export { OptionGroupAnswerInfo as default };