@elice/material-quiz 1.240718.0-trasncript.2 → 1.240718.1

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/components/eb-sortable/EbDraggable.js +33 -42
  2. package/cjs/components/eb-sortable/EbDroppable.js +20 -27
  3. package/cjs/components/markdown-editor/index.d.ts +2 -1
  4. package/cjs/components/markdown-editor/index.js +10 -19
  5. package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
  6. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
  7. package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
  8. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
  9. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
  10. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
  11. package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
  12. package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
  13. package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
  14. package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
  15. package/cjs/components/material-quiz/constants/color.js +5 -5
  16. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  17. package/cjs/components/material-quiz/context/MaterialQuizContext.js +93 -156
  18. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
  19. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
  20. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
  21. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
  22. package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
  23. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
  24. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
  25. package/cjs/components/material-quiz-edit/context.js +2 -8
  26. package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
  27. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
  28. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
  29. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
  30. package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
  31. package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  32. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
  33. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
  34. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
  35. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
  36. package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  37. package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
  38. package/cjs/components/shared/QuestionBox.js +165 -198
  39. package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
  40. package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
  41. package/cjs/components/shared/QuizDraggbleOption.js +59 -65
  42. package/cjs/components/shared/StyledMarkdown.js +1 -5
  43. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
  44. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  45. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
  46. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
  47. package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
  48. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  49. package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
  50. package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
  51. package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
  52. package/cjs/components/shared/utils/mergeRefs.js +6 -15
  53. package/cjs/constant/element.js +3 -3
  54. package/cjs/helpers/index.js +10 -8
  55. package/cjs/hooks/useCaculatePassage.js +20 -21
  56. package/es/components/eb-sortable/EbDraggable.js +33 -37
  57. package/es/components/eb-sortable/EbDroppable.js +20 -22
  58. package/es/components/markdown-editor/index.d.ts +2 -1
  59. package/es/components/markdown-editor/index.js +10 -15
  60. package/es/components/material-quiz/MaterialQuiz.js +83 -109
  61. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
  62. package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
  63. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
  64. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
  65. package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
  66. package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
  67. package/es/components/material-quiz/MaterialQuizText.js +115 -158
  68. package/es/components/material-quiz/QuizResultBadge.js +22 -27
  69. package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
  70. package/es/components/material-quiz/constants/color.js +5 -5
  71. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  72. package/es/components/material-quiz/context/MaterialQuizContext.js +94 -153
  73. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
  74. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
  75. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
  76. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
  77. package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
  78. package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
  79. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
  80. package/es/components/material-quiz-edit/context.js +2 -4
  81. package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
  82. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
  83. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
  84. package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
  85. package/es/components/material-quiz-edit/options/OptionText.js +82 -86
  86. package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  87. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
  88. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
  89. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
  90. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
  91. package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  92. package/es/components/material-quiz-edit/utils/editValue.js +12 -17
  93. package/es/components/shared/QuestionBox.js +165 -192
  94. package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
  95. package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
  96. package/es/components/shared/QuizDraggbleOption.js +59 -61
  97. package/es/components/shared/StyledMarkdown.js +1 -1
  98. package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
  99. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  100. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
  101. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
  102. package/es/components/shared/question-radio/QuestionRadio.js +7 -9
  103. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  104. package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
  105. package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
  106. package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
  107. package/es/components/shared/utils/mergeRefs.js +6 -15
  108. package/es/constant/element.js +3 -3
  109. package/es/helpers/index.js +10 -8
  110. package/es/hooks/useCaculatePassage.js +20 -21
  111. package/package.json +15 -12
  112. package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
  113. package/cjs/components/material-quiz/index.js +0 -9
  114. package/cjs/components/material-quiz/locales/index.js +0 -13
  115. package/cjs/components/material-quiz-edit/index.js +0 -7
  116. package/cjs/components/material-quiz-edit/locales/index.js +0 -13
  117. package/cjs/components/shared/index.js +0 -19
  118. package/cjs/constant/index.js +0 -9
  119. package/cjs/hooks/index.js +0 -7
  120. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
  121. package/es/components/material-quiz/index.js +0 -2
  122. package/es/components/material-quiz/locales/index.js +0 -4
  123. package/es/components/material-quiz-edit/index.js +0 -1
  124. package/es/components/material-quiz-edit/locales/index.js +0 -4
  125. package/es/components/shared/index.js +0 -7
  126. package/es/constant/index.js +0 -1
  127. package/es/hooks/index.js +0 -1
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
1
+ import React from 'react';
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,75 +11,63 @@ import { checkTwoDimensionArray } from '../../utils/checkTwoDimensionArray.js';
11
11
  import { createRandomId } from '../../utils/randomId.js';
12
12
  import OptionGroupAnswerListItem from './OptionGroupAnswerListItem.js';
13
13
 
14
- var MAX_OPTION_INFO_COUNT = 20;
15
- var StyledSortableList = styled.div.withConfig({
14
+ const MAX_OPTION_INFO_COUNT = 20;
15
+ const StyledSortableList = styled.div.withConfig({
16
16
  componentId: "sc-14yoda7-0"
17
17
  })(["margin:1rem 0;padding:0;"]);
18
- var StyledOptionTitle = styled.div.withConfig({
18
+ const 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
- 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;
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;
41
44
  /**
42
45
  *
43
46
  */
44
- var handleRemoveItem = function handleRemoveItem(index) {
47
+ const handleRemoveItem = index => {
45
48
  var _a;
46
- var cloneAnswerList = cloneDeep(watchedAnswerInfo);
47
- var answerIndex = cloneAnswerList.findIndex(function (answers) {
48
- return answers.includes(index);
49
- });
49
+ const cloneAnswerList = cloneDeep(watchedAnswerInfo);
50
+ const answerIndex = cloneAnswerList.findIndex(answers => answers.includes(index));
50
51
  if (!cloneAnswerList[answerIndex]) {
51
52
  return removeOptionInfoFieldItem(index);
52
53
  }
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
- });
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));
61
56
  removeOptionInfoFieldItem(index);
62
57
  setValue('answerInfoDefault', recalculationAnswerList);
63
58
  };
64
59
  /**
65
60
  *
66
61
  */
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
- });
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)));
83
71
  setValue('answerInfoDefault', updatedAnswerInfo);
84
72
  setValue('optionsDefault', updatedOptions, {
85
73
  shouldDirty: true
@@ -88,112 +76,86 @@ var OptionGroupAnswerInfo = function OptionGroupAnswerInfo() {
88
76
  /**
89
77
  *
90
78
  */
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
- });
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
+ }))));
123
103
  };
124
104
  /**
125
105
  *
126
106
  */
127
- var renderAnswerOptionList = function renderAnswerOptionList() {
128
- return jsx(SortableListGroup, {
107
+ const renderAnswerOptionList = () => {
108
+ return React.createElement(SortableListGroup, {
129
109
  onSortEnd: onSortEnd,
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
- });
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
+ }))));
143
117
  };
144
118
  /**
145
119
  *
146
120
  */
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
- });
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
+ }))));
197
159
  };
198
160
  //
199
161
  //
@@ -201,10 +163,9 @@ var OptionGroupAnswerInfo = function OptionGroupAnswerInfo() {
201
163
  if (!checkTwoDimensionArray(watchedAnswerInfo)) {
202
164
  return null;
203
165
  }
204
- return jsxs(Flex, {
205
- column: true,
206
- children: [renderAnswerTitle(), renderAnswerOptionList(), renderAnswerOptionAddButton()]
207
- });
166
+ return React.createElement(Flex, {
167
+ column: true
168
+ }, renderAnswerTitle(), renderAnswerOptionList(), renderAnswerOptionAddButton());
208
169
  };
209
170
 
210
171
  export { OptionGroupAnswerInfo as default };