@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.
- 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,3 +1,4 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { useFormContext, useFieldArray, useWatch, Controller } from 'react-hook-form';
|
|
3
4
|
import { arrayMove } from 'react-sortable-hoc';
|
|
@@ -11,50 +12,47 @@ import { useMaterialQuizEditContext } from '../context.js';
|
|
|
11
12
|
import { createRandomId } from '../utils/randomId.js';
|
|
12
13
|
import OptionEditor from './OptionEditor.js';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
var MIN_OPTION_INFO_COUNT = 2;
|
|
16
|
+
var MAX_OPTION_INFO_COUNT = 20;
|
|
17
|
+
var StyledWrap = styled.div.withConfig({
|
|
17
18
|
componentId: "sc-vizer2-0"
|
|
18
19
|
})(["& > ul{display:flex;flex-direction:column;gap:0.75rem;}"]);
|
|
19
|
-
|
|
20
|
+
var StyledInputGroup = styled(SortableListGroup).withConfig({
|
|
20
21
|
componentId: "sc-vizer2-1"
|
|
21
22
|
})(["width:100%;.em-option-editor{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
|
|
22
|
-
|
|
23
|
+
var StyledInputPrefixRadioOption = styled(RadioOption).withConfig({
|
|
23
24
|
componentId: "sc-vizer2-2"
|
|
24
25
|
})([".eb-radio-option__label{display:none;}"]);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
disabled
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
});
|
|
45
|
-
const watchedAnswerInfo = useWatch({
|
|
46
|
-
control,
|
|
26
|
+
var OptionSelectOne = function OptionSelectOne() {
|
|
27
|
+
var intl = useRawEliceIntl();
|
|
28
|
+
var _useMaterialQuizEditC = useMaterialQuizEditContext(),
|
|
29
|
+
disabled = _useMaterialQuizEditC.disabled;
|
|
30
|
+
var _useFormContext = useFormContext(),
|
|
31
|
+
control = _useFormContext.control,
|
|
32
|
+
getValues = _useFormContext.getValues,
|
|
33
|
+
setValue = _useFormContext.setValue;
|
|
34
|
+
var _useFieldArray = useFieldArray({
|
|
35
|
+
name: 'optionsDefault',
|
|
36
|
+
keyName: 'id',
|
|
37
|
+
shouldUnregister: true
|
|
38
|
+
}),
|
|
39
|
+
optionInfoFields = _useFieldArray.fields,
|
|
40
|
+
appendOptionInfoFieldItem = _useFieldArray.append,
|
|
41
|
+
removeOptionInfoFieldItem = _useFieldArray.remove,
|
|
42
|
+
moveOptionInfoFieldItem = _useFieldArray.move;
|
|
43
|
+
var watchedAnswerInfo = useWatch({
|
|
44
|
+
control: control,
|
|
47
45
|
name: 'answerInfoDefault'
|
|
48
46
|
});
|
|
49
|
-
|
|
50
|
-
control,
|
|
47
|
+
var watchedOptions = useWatch({
|
|
48
|
+
control: control,
|
|
51
49
|
name: 'optionsDefault'
|
|
52
50
|
});
|
|
53
51
|
/**
|
|
54
52
|
* Update answer info.
|
|
55
53
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
var updateAnswerInfo = function updateAnswerInfo(index) {
|
|
55
|
+
var prevAnswerInfo = getValues('answerInfoDefault');
|
|
58
56
|
if (!Array.isArray(prevAnswerInfo)) {
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
@@ -66,7 +64,7 @@ const OptionSelectOne = () => {
|
|
|
66
64
|
/**
|
|
67
65
|
* Append option info.
|
|
68
66
|
*/
|
|
69
|
-
|
|
67
|
+
var appendOptionInfo = function appendOptionInfo() {
|
|
70
68
|
appendOptionInfoFieldItem({
|
|
71
69
|
id: createRandomId(),
|
|
72
70
|
title: '',
|
|
@@ -76,10 +74,10 @@ const OptionSelectOne = () => {
|
|
|
76
74
|
/**
|
|
77
75
|
* Remove item from option info at index.
|
|
78
76
|
*/
|
|
79
|
-
|
|
77
|
+
var removeOptionInfo = function removeOptionInfo(index) {
|
|
80
78
|
// set answer info to 0 index,
|
|
81
79
|
// if this option is selected as answer.
|
|
82
|
-
|
|
80
|
+
var curAnswerInfo = getValues('answerInfoDefault');
|
|
83
81
|
if (Array.isArray(curAnswerInfo) && curAnswerInfo.includes(index)) {
|
|
84
82
|
updateAnswerInfo(0);
|
|
85
83
|
}
|
|
@@ -88,16 +86,19 @@ const OptionSelectOne = () => {
|
|
|
88
86
|
/**
|
|
89
87
|
* Sort options based on the old and new index.
|
|
90
88
|
*/
|
|
91
|
-
|
|
92
|
-
oldIndex,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
var handleSortEnd = function handleSortEnd(_ref) {
|
|
90
|
+
var oldIndex = _ref.oldIndex,
|
|
91
|
+
newIndex = _ref.newIndex;
|
|
92
|
+
var prevAnswerInfo = cloneDeep(watchedAnswerInfo);
|
|
93
|
+
var prevOptions = cloneDeep(watchedOptions).map(function (option, index) {
|
|
94
|
+
return Object.assign(Object.assign({}, option), {
|
|
95
|
+
isAnswer: prevAnswerInfo.includes(index)
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
var updatedOptions = arrayMove(prevOptions, oldIndex, newIndex);
|
|
99
|
+
var updatedAnswer = updatedOptions.findIndex(function (option) {
|
|
100
|
+
return option.isAnswer;
|
|
101
|
+
});
|
|
101
102
|
setValue('answerInfoDefault', [updatedAnswer]);
|
|
102
103
|
moveOptionInfoFieldItem(oldIndex, newIndex);
|
|
103
104
|
};
|
|
@@ -107,109 +108,123 @@ const OptionSelectOne = () => {
|
|
|
107
108
|
if (!Array.isArray(watchedAnswerInfo)) {
|
|
108
109
|
return null;
|
|
109
110
|
}
|
|
110
|
-
return
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
return jsxs(StyledWrap, {
|
|
112
|
+
children: [jsx(Controller, {
|
|
113
|
+
name: "answerInfoDefault",
|
|
114
|
+
control: control,
|
|
115
|
+
rules: {
|
|
116
|
+
validate: function validate(v) {
|
|
117
|
+
if (Array.isArray(v) && v.length < 1) {
|
|
118
|
+
return intl.formatMessage({
|
|
119
|
+
id: 'content.option.errorMessage.required'
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
119
123
|
}
|
|
120
|
-
|
|
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
|
+
});
|
|
121
142
|
}
|
|
122
|
-
},
|
|
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
|
-
|
|
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
|
-
|
|
186
|
-
|
|
143
|
+
}), jsx(StyledInputGroup, {
|
|
144
|
+
useDragHandle: true,
|
|
145
|
+
pressDelay: 100,
|
|
146
|
+
onSortEnd: handleSortEnd,
|
|
147
|
+
children: optionInfoFields.map(function (_ref3, index) {
|
|
148
|
+
var id = _ref3.id;
|
|
149
|
+
return jsx(Controller, {
|
|
150
|
+
control: control,
|
|
151
|
+
name: "optionsDefault.".concat(index, ".content"),
|
|
152
|
+
rules: {
|
|
153
|
+
required: {
|
|
154
|
+
value: true,
|
|
155
|
+
message: intl.formatMessage({
|
|
156
|
+
id: 'option.common.select.errorMessage.required'
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
render: function render(_ref4) {
|
|
161
|
+
var field = _ref4.field,
|
|
162
|
+
fieldState = _ref4.fieldState;
|
|
163
|
+
var _a;
|
|
164
|
+
return jsx(OptionEditor, Object.assign({
|
|
165
|
+
index: index,
|
|
166
|
+
invalid: fieldState.invalid,
|
|
167
|
+
invalidText: (_a = fieldState === null || fieldState === void 0 ? void 0 : fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
168
|
+
placeholder: intl.formatMessage({
|
|
169
|
+
id: 'option.common.select.placeholder'
|
|
170
|
+
}),
|
|
171
|
+
readOnly: disabled,
|
|
172
|
+
prefix: jsxs(Radio, {
|
|
173
|
+
value: watchedAnswerInfo[0],
|
|
174
|
+
disabled: disabled,
|
|
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,
|
|
187
215
|
transparent: true,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
})
|
|
199
|
-
|
|
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
|
-
})))));
|
|
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
|
+
})
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
})]
|
|
227
|
+
});
|
|
213
228
|
};
|
|
214
229
|
|
|
215
230
|
export { OptionSelectOne as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _styled from '@emotion/styled/base';
|
|
2
|
-
import
|
|
2
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
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,101 +10,105 @@ import { useMaterialQuizEditContext } from '../context.js';
|
|
|
10
10
|
//
|
|
11
11
|
//
|
|
12
12
|
//
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var MIN_TEXT_LENGTH = 1;
|
|
14
|
+
var MAX_TEXT_LENGTH = 128;
|
|
15
15
|
//
|
|
16
16
|
//
|
|
17
17
|
//
|
|
18
|
-
|
|
18
|
+
var StyledInput = /*#__PURE__*/_styled(Input, {
|
|
19
19
|
target: "edimfaf0"
|
|
20
|
-
})("&>:first-child{", ({
|
|
21
|
-
disabled
|
|
22
|
-
|
|
20
|
+
})("&>:first-child{", function (_ref) {
|
|
21
|
+
var disabled = _ref.disabled;
|
|
22
|
+
return disabled && /*#__PURE__*/css("background-color:", base.color.gray2, ";");
|
|
23
|
+
}, ";}");
|
|
23
24
|
//
|
|
24
25
|
//
|
|
25
26
|
//
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
disabled
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const watchedIsAutoGrade = useWatch({
|
|
35
|
-
control,
|
|
27
|
+
var OptionText = function OptionText() {
|
|
28
|
+
var intl = useRawEliceIntl();
|
|
29
|
+
var _useMaterialQuizEditC = useMaterialQuizEditContext(),
|
|
30
|
+
disabled = _useMaterialQuizEditC.disabled;
|
|
31
|
+
var _useFormContext = useFormContext(),
|
|
32
|
+
control = _useFormContext.control;
|
|
33
|
+
var watchedIsAutoGrade = useWatch({
|
|
34
|
+
control: control,
|
|
36
35
|
name: 'isAutoGrade'
|
|
37
36
|
});
|
|
38
37
|
//
|
|
39
38
|
//
|
|
40
39
|
//
|
|
41
|
-
return
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
return jsxs(Fragment, {
|
|
41
|
+
children: [jsx(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
|
+
})
|
|
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
|
+
}
|
|
59
69
|
},
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
render: function render(_ref2) {
|
|
71
|
+
var field = _ref2.field,
|
|
72
|
+
fieldState = _ref2.fieldState;
|
|
73
|
+
var _a;
|
|
74
|
+
return jsx(StyledInput, Object.assign({
|
|
75
|
+
size: "small",
|
|
76
|
+
width: "full",
|
|
77
|
+
minLength: MIN_TEXT_LENGTH,
|
|
78
|
+
maxLength: MAX_TEXT_LENGTH,
|
|
79
|
+
readOnly: disabled,
|
|
80
|
+
disabled: !watchedIsAutoGrade,
|
|
81
|
+
invalid: fieldState.invalid,
|
|
82
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
83
|
+
helpText: intl.formatMessage({
|
|
84
|
+
id: 'option.text.answerInfo.hintText'
|
|
85
|
+
})
|
|
86
|
+
}, field, {
|
|
87
|
+
value: field.value
|
|
88
|
+
}));
|
|
68
89
|
}
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
}));
|
|
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
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
})]
|
|
111
|
+
});
|
|
108
112
|
};
|
|
109
113
|
|
|
110
114
|
export { OptionText as default };
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
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
|
+
var OptionGroup = function OptionGroup() {
|
|
7
7
|
//
|
|
8
8
|
//
|
|
9
9
|
//
|
|
10
|
-
return
|
|
10
|
+
return jsxs(Flex, {
|
|
11
11
|
column: true,
|
|
12
|
-
margintop: "1.5rem"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
margintop: "1.5rem",
|
|
13
|
+
children: [jsx(OptionGroupGroupInfo, {}), jsx(Hr, {
|
|
14
|
+
marginStart: "1.5rem",
|
|
15
|
+
marginEnd: "1.5rem"
|
|
16
|
+
}), jsx(OptionGroupAnswerInfo, {})]
|
|
17
|
+
});
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export { OptionGroup as default };
|