@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.
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +423 -0
- package/cjs/components/eb-sortable/EbDraggable.js +42 -33
- package/cjs/components/eb-sortable/EbDroppable.js +27 -20
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-quiz/MaterialQuiz.js +114 -83
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +36 -29
- package/cjs/components/material-quiz/MaterialQuizInfo.js +151 -149
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +175 -127
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +360 -286
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +172 -126
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +46 -39
- package/cjs/components/material-quiz/MaterialQuizText.js +163 -115
- package/cjs/components/material-quiz/QuizResultBadge.js +32 -22
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +21 -16
- package/cjs/components/material-quiz/constants/color.js +5 -5
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +156 -93
- package/cjs/components/material-quiz/index.js +9 -0
- package/cjs/components/material-quiz/locales/index.js +13 -0
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +259 -161
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +134 -100
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +130 -101
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +64 -52
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +5 -1
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +47 -36
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +280 -232
- package/cjs/components/material-quiz-edit/context.js +8 -2
- package/cjs/components/material-quiz-edit/index.js +7 -0
- package/cjs/components/material-quiz-edit/locales/index.js +13 -0
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +70 -46
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +174 -148
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +175 -149
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +164 -144
- package/cjs/components/material-quiz-edit/options/OptionText.js +90 -82
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +156 -112
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +288 -196
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +88 -75
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +108 -92
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/cjs/components/material-quiz-edit/utils/editValue.js +21 -12
- package/cjs/components/shared/QuestionBox.js +198 -165
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/cjs/components/shared/QuizDraggbleDummyOption.js +23 -16
- package/cjs/components/shared/QuizDraggbleOption.js +65 -59
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/index.js +19 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +59 -68
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +52 -59
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/cjs/components/shared/utils/mergeRefs.js +15 -6
- package/cjs/constant/element.js +3 -3
- package/cjs/constant/index.js +9 -0
- package/cjs/helpers/index.js +8 -10
- package/cjs/hooks/index.js +7 -0
- package/cjs/hooks/useCaculatePassage.js +21 -20
- package/es/_virtual/_rollupPluginBabelHelpers.js +408 -0
- package/es/components/eb-sortable/EbDraggable.js +37 -33
- package/es/components/eb-sortable/EbDroppable.js +22 -20
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-quiz/MaterialQuiz.js +109 -83
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +32 -29
- package/es/components/material-quiz/MaterialQuizInfo.js +148 -150
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +171 -127
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +356 -287
- package/es/components/material-quiz/MaterialQuizSelectOne.js +168 -126
- package/es/components/material-quiz/MaterialQuizShimmer.js +42 -39
- package/es/components/material-quiz/MaterialQuizText.js +158 -115
- package/es/components/material-quiz/QuizResultBadge.js +27 -22
- package/es/components/material-quiz/QuizSubmitStatusText.js +17 -16
- package/es/components/material-quiz/constants/color.js +5 -5
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/es/components/material-quiz/context/MaterialQuizContext.js +153 -94
- package/es/components/material-quiz/index.js +2 -0
- package/es/components/material-quiz/locales/index.js +4 -0
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +253 -161
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +129 -100
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +125 -101
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +60 -52
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +43 -36
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +272 -229
- package/es/components/material-quiz-edit/context.js +4 -2
- package/es/components/material-quiz-edit/index.js +1 -0
- package/es/components/material-quiz-edit/locales/index.js +4 -0
- package/es/components/material-quiz-edit/options/OptionEditor.js +64 -46
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +170 -148
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +171 -149
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +159 -144
- package/es/components/material-quiz-edit/options/OptionText.js +86 -82
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +151 -112
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +283 -197
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +83 -75
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +103 -92
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/es/components/material-quiz-edit/utils/editValue.js +17 -12
- package/es/components/shared/QuestionBox.js +192 -165
- package/es/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/es/components/shared/QuizDraggbleDummyOption.js +19 -16
- package/es/components/shared/QuizDraggbleOption.js +61 -59
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/index.js +7 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +54 -68
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +47 -59
- package/es/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/es/components/shared/utils/mergeRefs.js +15 -6
- package/es/constant/element.js +3 -3
- package/es/constant/index.js +1 -0
- package/es/helpers/index.js +8 -10
- package/es/hooks/index.js +1 -0
- package/es/hooks/useCaculatePassage.js +21 -20
- package/package.json +12 -15
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setValue,
|
|
28
|
-
watch
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
44
|
+
var handleRemoveItem = function handleRemoveItem(index) {
|
|
48
45
|
var _a;
|
|
49
|
-
|
|
50
|
-
|
|
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(
|
|
55
|
-
|
|
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
|
-
|
|
63
|
-
oldIndex,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
80
|
-
return
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
108
|
-
return
|
|
127
|
+
var renderAnswerOptionList = function renderAnswerOptionList() {
|
|
128
|
+
return jsx(SortableListGroup, {
|
|
109
129
|
onSortEnd: onSortEnd,
|
|
110
|
-
useDragHandle: true
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
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
|
|
167
|
-
column: true
|
|
168
|
-
|
|
204
|
+
return jsxs(Flex, {
|
|
205
|
+
column: true,
|
|
206
|
+
children: [renderAnswerTitle(), renderAnswerOptionList(), renderAnswerOptionAddButton()]
|
|
207
|
+
});
|
|
169
208
|
};
|
|
170
209
|
|
|
171
210
|
export { OptionGroupAnswerInfo as default };
|