@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,3 @@
|
|
|
1
|
-
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { useFormContext, useFieldArray, useWatch, Controller } from 'react-hook-form';
|
|
4
3
|
import { arrayMove } from 'react-sortable-hoc';
|
|
@@ -12,47 +11,50 @@ import { useMaterialQuizEditContext } from '../context.js';
|
|
|
12
11
|
import { createRandomId } from '../utils/randomId.js';
|
|
13
12
|
import OptionEditor from './OptionEditor.js';
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const MIN_OPTION_INFO_COUNT = 2;
|
|
15
|
+
const MAX_OPTION_INFO_COUNT = 20;
|
|
16
|
+
const StyledWrap = styled.div.withConfig({
|
|
18
17
|
componentId: "sc-vizer2-0"
|
|
19
18
|
})(["& > ul{display:flex;flex-direction:column;gap:0.75rem;}"]);
|
|
20
|
-
|
|
19
|
+
const StyledInputGroup = styled(SortableListGroup).withConfig({
|
|
21
20
|
componentId: "sc-vizer2-1"
|
|
22
21
|
})(["width:100%;.em-option-editor{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
|
|
23
|
-
|
|
22
|
+
const StyledInputPrefixRadioOption = styled(RadioOption).withConfig({
|
|
24
23
|
componentId: "sc-vizer2-2"
|
|
25
24
|
})([".eb-radio-option__label{display:none;}"]);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
disabled
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
const OptionSelectOne = () => {
|
|
26
|
+
const intl = useRawEliceIntl();
|
|
27
|
+
const {
|
|
28
|
+
disabled
|
|
29
|
+
} = useMaterialQuizEditContext();
|
|
30
|
+
const {
|
|
31
|
+
control,
|
|
32
|
+
getValues,
|
|
33
|
+
setValue
|
|
34
|
+
} = useFormContext();
|
|
35
|
+
const {
|
|
36
|
+
fields: optionInfoFields,
|
|
37
|
+
append: appendOptionInfoFieldItem,
|
|
38
|
+
remove: removeOptionInfoFieldItem,
|
|
39
|
+
move: moveOptionInfoFieldItem
|
|
40
|
+
} = useFieldArray({
|
|
41
|
+
name: 'optionsDefault',
|
|
42
|
+
keyName: 'id',
|
|
43
|
+
shouldUnregister: true
|
|
44
|
+
});
|
|
45
|
+
const watchedAnswerInfo = useWatch({
|
|
46
|
+
control,
|
|
45
47
|
name: 'answerInfoDefault'
|
|
46
48
|
});
|
|
47
|
-
|
|
48
|
-
control
|
|
49
|
+
const watchedOptions = useWatch({
|
|
50
|
+
control,
|
|
49
51
|
name: 'optionsDefault'
|
|
50
52
|
});
|
|
51
53
|
/**
|
|
52
54
|
* Update answer info.
|
|
53
55
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
const updateAnswerInfo = index => {
|
|
57
|
+
const prevAnswerInfo = getValues('answerInfoDefault');
|
|
56
58
|
if (!Array.isArray(prevAnswerInfo)) {
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
@@ -64,7 +66,7 @@ var OptionSelectOne = function OptionSelectOne() {
|
|
|
64
66
|
/**
|
|
65
67
|
* Append option info.
|
|
66
68
|
*/
|
|
67
|
-
|
|
69
|
+
const appendOptionInfo = () => {
|
|
68
70
|
appendOptionInfoFieldItem({
|
|
69
71
|
id: createRandomId(),
|
|
70
72
|
title: '',
|
|
@@ -74,10 +76,10 @@ var OptionSelectOne = function OptionSelectOne() {
|
|
|
74
76
|
/**
|
|
75
77
|
* Remove item from option info at index.
|
|
76
78
|
*/
|
|
77
|
-
|
|
79
|
+
const removeOptionInfo = index => {
|
|
78
80
|
// set answer info to 0 index,
|
|
79
81
|
// if this option is selected as answer.
|
|
80
|
-
|
|
82
|
+
const curAnswerInfo = getValues('answerInfoDefault');
|
|
81
83
|
if (Array.isArray(curAnswerInfo) && curAnswerInfo.includes(index)) {
|
|
82
84
|
updateAnswerInfo(0);
|
|
83
85
|
}
|
|
@@ -86,19 +88,16 @@ var OptionSelectOne = function OptionSelectOne() {
|
|
|
86
88
|
/**
|
|
87
89
|
* Sort options based on the old and new index.
|
|
88
90
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
var updatedAnswer = updatedOptions.findIndex(function (option) {
|
|
100
|
-
return option.isAnswer;
|
|
101
|
-
});
|
|
91
|
+
const handleSortEnd = ({
|
|
92
|
+
oldIndex,
|
|
93
|
+
newIndex
|
|
94
|
+
}) => {
|
|
95
|
+
const prevAnswerInfo = cloneDeep(watchedAnswerInfo);
|
|
96
|
+
const prevOptions = cloneDeep(watchedOptions).map((option, index) => Object.assign(Object.assign({}, option), {
|
|
97
|
+
isAnswer: prevAnswerInfo.includes(index)
|
|
98
|
+
}));
|
|
99
|
+
const updatedOptions = arrayMove(prevOptions, oldIndex, newIndex);
|
|
100
|
+
const updatedAnswer = updatedOptions.findIndex(option => option.isAnswer);
|
|
102
101
|
setValue('answerInfoDefault', [updatedAnswer]);
|
|
103
102
|
moveOptionInfoFieldItem(oldIndex, newIndex);
|
|
104
103
|
};
|
|
@@ -108,123 +107,109 @@ var OptionSelectOne = function OptionSelectOne() {
|
|
|
108
107
|
if (!Array.isArray(watchedAnswerInfo)) {
|
|
109
108
|
return null;
|
|
110
109
|
}
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
return true;
|
|
110
|
+
return React.createElement(StyledWrap, null, React.createElement(Controller, {
|
|
111
|
+
name: "answerInfoDefault",
|
|
112
|
+
control: control,
|
|
113
|
+
rules: {
|
|
114
|
+
validate: v => {
|
|
115
|
+
if (Array.isArray(v) && v.length < 1) {
|
|
116
|
+
return intl.formatMessage({
|
|
117
|
+
id: 'content.option.errorMessage.required'
|
|
118
|
+
});
|
|
123
119
|
}
|
|
124
|
-
|
|
125
|
-
render: function render(_ref2) {
|
|
126
|
-
var fieldState = _ref2.fieldState;
|
|
127
|
-
var _a;
|
|
128
|
-
return jsx(Transition, {
|
|
129
|
-
in: fieldState.invalid,
|
|
130
|
-
timeout: 0,
|
|
131
|
-
mountOnEnter: true,
|
|
132
|
-
unmountOnExit: true,
|
|
133
|
-
children: jsxs(Fragment, {
|
|
134
|
-
children: [jsx(StatusText, {
|
|
135
|
-
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
136
|
-
role: "danger"
|
|
137
|
-
}), jsx(Vspace, {
|
|
138
|
-
height: 0.5
|
|
139
|
-
})]
|
|
140
|
-
})
|
|
141
|
-
});
|
|
120
|
+
return true;
|
|
142
121
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
onChange: updateAnswerInfo,
|
|
176
|
-
children: [jsx(StyledInputPrefixRadioOption, {
|
|
177
|
-
value: index
|
|
178
|
-
}), jsx(React.Fragment, {})]
|
|
179
|
-
}),
|
|
180
|
-
suffix: jsx(Tooltip, {
|
|
181
|
-
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
182
|
-
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
183
|
-
}) : undefined,
|
|
184
|
-
placement: "top-start",
|
|
185
|
-
children: jsx("span", {
|
|
186
|
-
children: jsx(IconButton, {
|
|
187
|
-
icon: eilMathsignMultiplyBasic,
|
|
188
|
-
size: "tiny",
|
|
189
|
-
role: "grey9",
|
|
190
|
-
border: false,
|
|
191
|
-
transparent: true,
|
|
192
|
-
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
193
|
-
onClick: function onClick() {
|
|
194
|
-
return removeOptionInfo(index);
|
|
195
|
-
}
|
|
196
|
-
})
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
}, field));
|
|
200
|
-
}
|
|
201
|
-
}, id);
|
|
202
|
-
})
|
|
203
|
-
}), jsx(Vspace, {
|
|
204
|
-
height: 0.5
|
|
205
|
-
}), jsx(Tooltip, {
|
|
206
|
-
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
207
|
-
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
208
|
-
}) : undefined,
|
|
209
|
-
placement: "bottom",
|
|
210
|
-
children: jsx("span", {
|
|
211
|
-
children: jsx(Button, {
|
|
212
|
-
block: true,
|
|
213
|
-
size: "micro",
|
|
214
|
-
borderDashed: true,
|
|
215
|
-
transparent: true,
|
|
216
|
-
icon: jsx(Icon, {
|
|
217
|
-
icon: eilMathsignAddCircle
|
|
218
|
-
}),
|
|
219
|
-
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
220
|
-
onClick: appendOptionInfo,
|
|
221
|
-
children: intl.formatMessage({
|
|
222
|
-
id: 'option.common.select.addButton'
|
|
223
|
-
})
|
|
122
|
+
},
|
|
123
|
+
render: ({
|
|
124
|
+
fieldState
|
|
125
|
+
}) => {
|
|
126
|
+
var _a;
|
|
127
|
+
return React.createElement(Transition, {
|
|
128
|
+
in: fieldState.invalid,
|
|
129
|
+
timeout: 0,
|
|
130
|
+
mountOnEnter: true,
|
|
131
|
+
unmountOnExit: true
|
|
132
|
+
}, React.createElement(React.Fragment, null, React.createElement(StatusText, {
|
|
133
|
+
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
134
|
+
role: "danger"
|
|
135
|
+
}), React.createElement(Vspace, {
|
|
136
|
+
height: 0.5
|
|
137
|
+
})));
|
|
138
|
+
}
|
|
139
|
+
}), React.createElement(StyledInputGroup, {
|
|
140
|
+
useDragHandle: true,
|
|
141
|
+
pressDelay: 100,
|
|
142
|
+
onSortEnd: handleSortEnd
|
|
143
|
+
}, optionInfoFields.map(({
|
|
144
|
+
id
|
|
145
|
+
}, index) => React.createElement(Controller, {
|
|
146
|
+
key: id,
|
|
147
|
+
control: control,
|
|
148
|
+
name: `optionsDefault.${index}.content`,
|
|
149
|
+
rules: {
|
|
150
|
+
required: {
|
|
151
|
+
value: true,
|
|
152
|
+
message: intl.formatMessage({
|
|
153
|
+
id: 'option.common.select.errorMessage.required'
|
|
224
154
|
})
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
render: ({
|
|
158
|
+
field,
|
|
159
|
+
fieldState
|
|
160
|
+
}) => {
|
|
161
|
+
var _a;
|
|
162
|
+
return React.createElement(OptionEditor, Object.assign({
|
|
163
|
+
index: index,
|
|
164
|
+
invalid: fieldState.invalid,
|
|
165
|
+
invalidText: (_a = fieldState === null || fieldState === void 0 ? void 0 : fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
166
|
+
placeholder: intl.formatMessage({
|
|
167
|
+
id: 'option.common.select.placeholder'
|
|
168
|
+
}),
|
|
169
|
+
readOnly: disabled,
|
|
170
|
+
prefix: React.createElement(Radio, {
|
|
171
|
+
value: watchedAnswerInfo[0],
|
|
172
|
+
disabled: disabled,
|
|
173
|
+
onChange: updateAnswerInfo
|
|
174
|
+
}, React.createElement(StyledInputPrefixRadioOption, {
|
|
175
|
+
value: index
|
|
176
|
+
}), React.createElement(React.Fragment, null)),
|
|
177
|
+
suffix: React.createElement(Tooltip, {
|
|
178
|
+
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
179
|
+
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
180
|
+
}) : undefined,
|
|
181
|
+
placement: "top-start"
|
|
182
|
+
}, React.createElement("span", null, React.createElement(IconButton, {
|
|
183
|
+
icon: eilMathsignMultiplyBasic,
|
|
184
|
+
size: "tiny",
|
|
185
|
+
role: "grey9",
|
|
186
|
+
border: false,
|
|
187
|
+
transparent: true,
|
|
188
|
+
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
189
|
+
onClick: () => removeOptionInfo(index)
|
|
190
|
+
})))
|
|
191
|
+
}, field));
|
|
192
|
+
}
|
|
193
|
+
}))), React.createElement(Vspace, {
|
|
194
|
+
height: 0.5
|
|
195
|
+
}), React.createElement(Tooltip, {
|
|
196
|
+
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
197
|
+
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
198
|
+
}) : undefined,
|
|
199
|
+
placement: "bottom"
|
|
200
|
+
}, React.createElement("span", null, React.createElement(Button, {
|
|
201
|
+
block: true,
|
|
202
|
+
size: "micro",
|
|
203
|
+
borderDashed: true,
|
|
204
|
+
transparent: true,
|
|
205
|
+
icon: React.createElement(Icon, {
|
|
206
|
+
icon: eilMathsignAddCircle
|
|
207
|
+
}),
|
|
208
|
+
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
209
|
+
onClick: appendOptionInfo
|
|
210
|
+
}, intl.formatMessage({
|
|
211
|
+
id: 'option.common.select.addButton'
|
|
212
|
+
})))));
|
|
228
213
|
};
|
|
229
214
|
|
|
230
215
|
export { OptionSelectOne as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _styled from '@emotion/styled/base';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { useFormContext, useWatch, Controller } from 'react-hook-form';
|
|
4
4
|
import { Vspace, Checkbox, Input } from '@elice/blocks';
|
|
5
5
|
import { base } from '@elice/design-tokens';
|
|
@@ -10,105 +10,101 @@ import { useMaterialQuizEditContext } from '../context.js';
|
|
|
10
10
|
//
|
|
11
11
|
//
|
|
12
12
|
//
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const MIN_TEXT_LENGTH = 1;
|
|
14
|
+
const MAX_TEXT_LENGTH = 128;
|
|
15
15
|
//
|
|
16
16
|
//
|
|
17
17
|
//
|
|
18
|
-
|
|
18
|
+
const StyledInput = /*#__PURE__*/_styled(Input, {
|
|
19
19
|
target: "edimfaf0"
|
|
20
|
-
})("&>:first-child{",
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}, ";}");
|
|
20
|
+
})("&>:first-child{", ({
|
|
21
|
+
disabled
|
|
22
|
+
}) => disabled && /*#__PURE__*/css("background-color:", base.color.gray2, ";"), ";}");
|
|
24
23
|
//
|
|
25
24
|
//
|
|
26
25
|
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
disabled
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
const OptionText = () => {
|
|
27
|
+
const intl = useRawEliceIntl();
|
|
28
|
+
const {
|
|
29
|
+
disabled
|
|
30
|
+
} = useMaterialQuizEditContext();
|
|
31
|
+
const {
|
|
32
|
+
control
|
|
33
|
+
} = useFormContext();
|
|
34
|
+
const watchedIsAutoGrade = useWatch({
|
|
35
|
+
control,
|
|
35
36
|
name: 'isAutoGrade'
|
|
36
37
|
});
|
|
37
38
|
//
|
|
38
39
|
//
|
|
39
40
|
//
|
|
40
|
-
return
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
},
|
|
51
|
-
minLength: {
|
|
52
|
-
value: MIN_TEXT_LENGTH,
|
|
53
|
-
message: intl.formatMessage({
|
|
54
|
-
id: 'common.errorMessage.range'
|
|
55
|
-
}, {
|
|
56
|
-
min: MIN_TEXT_LENGTH,
|
|
57
|
-
max: MAX_TEXT_LENGTH
|
|
58
|
-
})
|
|
59
|
-
},
|
|
60
|
-
maxLength: {
|
|
61
|
-
value: MAX_TEXT_LENGTH,
|
|
62
|
-
message: intl.formatMessage({
|
|
63
|
-
id: 'common.errorMessage.range'
|
|
64
|
-
}, {
|
|
65
|
-
min: MIN_TEXT_LENGTH,
|
|
66
|
-
max: MAX_TEXT_LENGTH
|
|
67
|
-
})
|
|
68
|
-
}
|
|
41
|
+
return React.createElement(React.Fragment, null, React.createElement(Controller, {
|
|
42
|
+
control: control,
|
|
43
|
+
name: "answerInfoDefault",
|
|
44
|
+
rules: {
|
|
45
|
+
required: {
|
|
46
|
+
value: watchedIsAutoGrade,
|
|
47
|
+
message: intl.formatMessage({
|
|
48
|
+
id: 'option.text.answerInfo.errorMessage.required'
|
|
49
|
+
})
|
|
69
50
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
value: field.value
|
|
88
|
-
}));
|
|
89
|
-
}
|
|
90
|
-
}), jsx(Vspace, {
|
|
91
|
-
height: 0.5
|
|
92
|
-
}), jsx(Controller, {
|
|
93
|
-
control: control,
|
|
94
|
-
name: "isAutoGrade",
|
|
95
|
-
render: function render(_ref3) {
|
|
96
|
-
var field = _ref3.field;
|
|
97
|
-
return jsx(Checkbox, Object.assign({
|
|
98
|
-
size: "small"
|
|
99
|
-
}, field, {
|
|
100
|
-
value: !field.value,
|
|
101
|
-
checked: !field.value,
|
|
102
|
-
onChange: function onChange(v) {
|
|
103
|
-
return field.onChange(!v);
|
|
104
|
-
},
|
|
105
|
-
children: intl.formatMessage({
|
|
106
|
-
id: 'option.text.isAutoGrade.checkbox.label'
|
|
107
|
-
})
|
|
108
|
-
}));
|
|
51
|
+
minLength: {
|
|
52
|
+
value: MIN_TEXT_LENGTH,
|
|
53
|
+
message: intl.formatMessage({
|
|
54
|
+
id: 'common.errorMessage.range'
|
|
55
|
+
}, {
|
|
56
|
+
min: MIN_TEXT_LENGTH,
|
|
57
|
+
max: MAX_TEXT_LENGTH
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
maxLength: {
|
|
61
|
+
value: MAX_TEXT_LENGTH,
|
|
62
|
+
message: intl.formatMessage({
|
|
63
|
+
id: 'common.errorMessage.range'
|
|
64
|
+
}, {
|
|
65
|
+
min: MIN_TEXT_LENGTH,
|
|
66
|
+
max: MAX_TEXT_LENGTH
|
|
67
|
+
})
|
|
109
68
|
}
|
|
110
|
-
}
|
|
111
|
-
|
|
69
|
+
},
|
|
70
|
+
render: ({
|
|
71
|
+
field,
|
|
72
|
+
fieldState
|
|
73
|
+
}) => {
|
|
74
|
+
var _a;
|
|
75
|
+
return React.createElement(StyledInput, Object.assign({
|
|
76
|
+
size: "small",
|
|
77
|
+
width: "full",
|
|
78
|
+
minLength: MIN_TEXT_LENGTH,
|
|
79
|
+
maxLength: MAX_TEXT_LENGTH,
|
|
80
|
+
readOnly: disabled,
|
|
81
|
+
disabled: !watchedIsAutoGrade,
|
|
82
|
+
invalid: fieldState.invalid,
|
|
83
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
84
|
+
helpText: intl.formatMessage({
|
|
85
|
+
id: 'option.text.answerInfo.hintText'
|
|
86
|
+
})
|
|
87
|
+
}, field, {
|
|
88
|
+
value: field.value
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
}), React.createElement(Vspace, {
|
|
92
|
+
height: 0.5
|
|
93
|
+
}), React.createElement(Controller, {
|
|
94
|
+
control: control,
|
|
95
|
+
name: "isAutoGrade",
|
|
96
|
+
render: ({
|
|
97
|
+
field
|
|
98
|
+
}) => React.createElement(Checkbox, Object.assign({
|
|
99
|
+
size: "small"
|
|
100
|
+
}, field, {
|
|
101
|
+
value: !field.value,
|
|
102
|
+
checked: !field.value,
|
|
103
|
+
onChange: v => field.onChange(!v)
|
|
104
|
+
}), intl.formatMessage({
|
|
105
|
+
id: 'option.text.isAutoGrade.checkbox.label'
|
|
106
|
+
}))
|
|
107
|
+
}));
|
|
112
108
|
};
|
|
113
109
|
|
|
114
110
|
export { OptionText as default };
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { Flex, Hr } from '@elice/blocks';
|
|
3
3
|
import OptionGroupAnswerInfo from './OptionGroupAnswerInfo.js';
|
|
4
4
|
import OptionGroupGroupInfo from './OptionGroupGroupInfo.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const OptionGroup = () => {
|
|
7
7
|
//
|
|
8
8
|
//
|
|
9
9
|
//
|
|
10
|
-
return
|
|
10
|
+
return React.createElement(Flex, {
|
|
11
11
|
column: true,
|
|
12
|
-
margintop: "1.5rem"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
12
|
+
margintop: "1.5rem"
|
|
13
|
+
}, React.createElement(OptionGroupGroupInfo, null), React.createElement(Hr, {
|
|
14
|
+
marginStart: "1.5rem",
|
|
15
|
+
marginEnd: "1.5rem"
|
|
16
|
+
}), React.createElement(OptionGroupAnswerInfo, null));
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
export { OptionGroup as default };
|