@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.
- package/cjs/components/eb-sortable/EbDraggable.js +33 -42
- package/cjs/components/eb-sortable/EbDroppable.js +20 -27
- package/cjs/components/markdown-editor/index.d.ts +2 -1
- package/cjs/components/markdown-editor/index.js +10 -19
- package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
- package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
- package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
- package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
- 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 +93 -156
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
- package/cjs/components/material-quiz-edit/context.js +2 -8
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
- package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
- package/cjs/components/shared/QuestionBox.js +165 -198
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
- package/cjs/components/shared/QuizDraggbleOption.js +59 -65
- package/cjs/components/shared/StyledMarkdown.js +1 -5
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/cjs/components/shared/utils/mergeRefs.js +6 -15
- package/cjs/constant/element.js +3 -3
- package/cjs/helpers/index.js +10 -8
- package/cjs/hooks/useCaculatePassage.js +20 -21
- package/es/components/eb-sortable/EbDraggable.js +33 -37
- package/es/components/eb-sortable/EbDroppable.js +20 -22
- package/es/components/markdown-editor/index.d.ts +2 -1
- package/es/components/markdown-editor/index.js +10 -15
- package/es/components/material-quiz/MaterialQuiz.js +83 -109
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
- package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
- package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
- package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
- package/es/components/material-quiz/MaterialQuizText.js +115 -158
- package/es/components/material-quiz/QuizResultBadge.js +22 -27
- package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
- 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 +94 -153
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
- package/es/components/material-quiz-edit/context.js +2 -4
- package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
- package/es/components/material-quiz-edit/options/OptionText.js +82 -86
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/es/components/material-quiz-edit/utils/editValue.js +12 -17
- package/es/components/shared/QuestionBox.js +165 -192
- package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
- package/es/components/shared/QuizDraggbleOption.js +59 -61
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
- package/es/components/shared/question-radio/QuestionRadio.js +7 -9
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
- package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
- package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/es/components/shared/utils/mergeRefs.js +6 -15
- package/es/constant/element.js +3 -3
- package/es/helpers/index.js +10 -8
- package/es/hooks/useCaculatePassage.js +20 -21
- package/package.json +15 -12
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
- package/cjs/components/material-quiz/index.js +0 -9
- package/cjs/components/material-quiz/locales/index.js +0 -13
- package/cjs/components/material-quiz-edit/index.js +0 -7
- package/cjs/components/material-quiz-edit/locales/index.js +0 -13
- package/cjs/components/shared/index.js +0 -19
- package/cjs/constant/index.js +0 -9
- package/cjs/hooks/index.js +0 -7
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
- package/es/components/material-quiz/index.js +0 -2
- package/es/components/material-quiz/locales/index.js +0 -4
- package/es/components/material-quiz-edit/index.js +0 -1
- package/es/components/material-quiz-edit/locales/index.js +0 -4
- package/es/components/shared/index.js +0 -7
- package/es/constant/index.js +0 -1
- package/es/hooks/index.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setValue
|
|
28
|
-
watch
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
47
|
+
const handleRemoveItem = index => {
|
|
45
48
|
var _a;
|
|
46
|
-
|
|
47
|
-
|
|
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(
|
|
54
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
128
|
-
return
|
|
107
|
+
const renderAnswerOptionList = () => {
|
|
108
|
+
return React.createElement(SortableListGroup, {
|
|
129
109
|
onSortEnd: onSortEnd,
|
|
130
|
-
useDragHandle: true
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
-
|
|
148
|
-
return
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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
|
|
205
|
-
column: true
|
|
206
|
-
|
|
207
|
-
});
|
|
166
|
+
return React.createElement(Flex, {
|
|
167
|
+
column: true
|
|
168
|
+
}, renderAnswerTitle(), renderAnswerOptionList(), renderAnswerOptionAddButton());
|
|
208
169
|
};
|
|
209
170
|
|
|
210
171
|
export { OptionGroupAnswerInfo as default };
|