@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
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
var React = require('react');
|
|
7
6
|
var reactHookForm = require('react-hook-form');
|
|
8
7
|
var reactSortableHoc = require('react-sortable-hoc');
|
|
9
8
|
var reactTransitionGroup = require('react-transition-group');
|
|
@@ -16,60 +15,55 @@ var context = require('../context.js');
|
|
|
16
15
|
var randomId = require('../utils/randomId.js');
|
|
17
16
|
var OptionEditor = require('./OptionEditor.js');
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var MIN_OPTION_INFO_COUNT = 2;
|
|
24
|
-
var MAX_OPTION_INFO_COUNT = 20;
|
|
25
|
-
var StyledWrap = styled__default.default.div.withConfig({
|
|
18
|
+
const MIN_OPTION_INFO_COUNT = 2;
|
|
19
|
+
const MAX_OPTION_INFO_COUNT = 20;
|
|
20
|
+
const StyledWrap = styled.div.withConfig({
|
|
26
21
|
componentId: "sc-1xufc1p-0"
|
|
27
22
|
})(["& > ul{display:flex;flex-direction:column;gap:0.75rem;}"]);
|
|
28
|
-
|
|
23
|
+
const StyledInputGroup = styled(blocks.SortableListGroup).withConfig({
|
|
29
24
|
componentId: "sc-1xufc1p-1"
|
|
30
25
|
})(["width:100%;.em-option-editor{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
disabled
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
const OptionSelectMultipleOrder = () => {
|
|
27
|
+
const intl$1 = intl.useRawEliceIntl();
|
|
28
|
+
const {
|
|
29
|
+
disabled
|
|
30
|
+
} = context.useMaterialQuizEditContext();
|
|
31
|
+
const {
|
|
32
|
+
control,
|
|
33
|
+
getValues,
|
|
34
|
+
setValue
|
|
35
|
+
} = reactHookForm.useFormContext();
|
|
36
|
+
const {
|
|
37
|
+
fields: optionInfoFields,
|
|
38
|
+
append: appendOptionInfoFieldItem,
|
|
39
|
+
remove: removeOptionInfoFieldItem,
|
|
40
|
+
move: moveOptionInfoFieldItem
|
|
41
|
+
} = reactHookForm.useFieldArray({
|
|
42
|
+
name: 'optionsDefault',
|
|
43
|
+
keyName: 'id',
|
|
44
|
+
shouldUnregister: true
|
|
45
|
+
});
|
|
46
|
+
const watchedAnswerInfo = reactHookForm.useWatch({
|
|
47
|
+
control,
|
|
50
48
|
name: 'answerInfoDefault'
|
|
51
49
|
});
|
|
52
|
-
|
|
53
|
-
control
|
|
50
|
+
const watchedOptions = reactHookForm.useWatch({
|
|
51
|
+
control,
|
|
54
52
|
name: 'optionsDefault'
|
|
55
53
|
});
|
|
56
54
|
/**
|
|
57
55
|
* Update answer info.
|
|
58
56
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const updateAnswerInfo = option => {
|
|
58
|
+
const prevAnswerInfo = getValues('answerInfoDefault');
|
|
61
59
|
if (!Array.isArray(prevAnswerInfo)) {
|
|
62
60
|
return;
|
|
63
61
|
}
|
|
64
|
-
setValue('answerInfoDefault', !option.checked ? prevAnswerInfo.filter(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
answerIndex < option.index ? answerIndex : answerIndex - 1 :
|
|
70
|
-
// or maintain current answer index
|
|
71
|
-
answerIndex;
|
|
72
|
-
}) : [].concat(_rollupPluginBabelHelpers.toConsumableArray(prevAnswerInfo), [option.index]), {
|
|
62
|
+
setValue('answerInfoDefault', !option.checked ? prevAnswerInfo.filter(answerIndex => answerIndex !== option.index).map(answerIndex => option.removed ?
|
|
63
|
+
// if answer removed, re-calculate answer index
|
|
64
|
+
answerIndex < option.index ? answerIndex : answerIndex - 1 :
|
|
65
|
+
// or maintain current answer index
|
|
66
|
+
answerIndex) : [...prevAnswerInfo, option.index], {
|
|
73
67
|
shouldDirty: true,
|
|
74
68
|
shouldValidate: true
|
|
75
69
|
});
|
|
@@ -77,7 +71,7 @@ var OptionSelectMultipleOrder = function OptionSelectMultipleOrder() {
|
|
|
77
71
|
/**
|
|
78
72
|
* Append option info.
|
|
79
73
|
*/
|
|
80
|
-
|
|
74
|
+
const appendOptionInfo = () => {
|
|
81
75
|
appendOptionInfoFieldItem({
|
|
82
76
|
id: randomId.createRandomId(),
|
|
83
77
|
title: '',
|
|
@@ -87,9 +81,9 @@ var OptionSelectMultipleOrder = function OptionSelectMultipleOrder() {
|
|
|
87
81
|
/**
|
|
88
82
|
* Remove item from option info at index.
|
|
89
83
|
*/
|
|
90
|
-
|
|
84
|
+
const removeOptionInfo = index => {
|
|
91
85
|
updateAnswerInfo({
|
|
92
|
-
index
|
|
86
|
+
index,
|
|
93
87
|
checked: false,
|
|
94
88
|
removed: true
|
|
95
89
|
});
|
|
@@ -98,20 +92,15 @@ var OptionSelectMultipleOrder = function OptionSelectMultipleOrder() {
|
|
|
98
92
|
/**
|
|
99
93
|
* Sort options based on the old and new index.
|
|
100
94
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
var updatedAnswerInfo = watchedAnswerInfo.map(function (answerIndex) {
|
|
111
|
-
return updatedOptions.findIndex(function (option) {
|
|
112
|
-
return option.originIndex === answerIndex;
|
|
113
|
-
});
|
|
114
|
-
});
|
|
95
|
+
const handleSortEnd = ({
|
|
96
|
+
oldIndex,
|
|
97
|
+
newIndex
|
|
98
|
+
}) => {
|
|
99
|
+
const prevOptions = lodashEs.cloneDeep(watchedOptions).map((option, index) => Object.assign(Object.assign({}, option), {
|
|
100
|
+
originIndex: index
|
|
101
|
+
}));
|
|
102
|
+
const updatedOptions = reactSortableHoc.arrayMove(prevOptions, oldIndex, newIndex);
|
|
103
|
+
const updatedAnswerInfo = watchedAnswerInfo.map(answerIndex => updatedOptions.findIndex(option => option.originIndex === answerIndex));
|
|
115
104
|
setValue('answerInfoDefault', updatedAnswerInfo);
|
|
116
105
|
moveOptionInfoFieldItem(oldIndex, newIndex);
|
|
117
106
|
};
|
|
@@ -121,125 +110,110 @@ var OptionSelectMultipleOrder = function OptionSelectMultipleOrder() {
|
|
|
121
110
|
if (!Array.isArray(watchedAnswerInfo)) {
|
|
122
111
|
return null;
|
|
123
112
|
}
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return true;
|
|
113
|
+
return React.createElement(StyledWrap, null, React.createElement(reactHookForm.Controller, {
|
|
114
|
+
name: "answerInfoDefault",
|
|
115
|
+
control: control,
|
|
116
|
+
rules: {
|
|
117
|
+
validate: v => {
|
|
118
|
+
if (Array.isArray(v) && v.length < 1) {
|
|
119
|
+
return intl$1.formatMessage({
|
|
120
|
+
id: 'content.option.errorMessage.required'
|
|
121
|
+
});
|
|
136
122
|
}
|
|
137
|
-
|
|
138
|
-
render: function render(_ref2) {
|
|
139
|
-
var fieldState = _ref2.fieldState;
|
|
140
|
-
var _a;
|
|
141
|
-
return jsxRuntime.jsx(reactTransitionGroup.Transition, {
|
|
142
|
-
in: fieldState.invalid,
|
|
143
|
-
timeout: 0,
|
|
144
|
-
mountOnEnter: true,
|
|
145
|
-
unmountOnExit: true,
|
|
146
|
-
children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
147
|
-
children: [jsxRuntime.jsx(blocks.StatusText, {
|
|
148
|
-
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
149
|
-
role: "danger"
|
|
150
|
-
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
151
|
-
height: 0.5
|
|
152
|
-
})]
|
|
153
|
-
})
|
|
154
|
-
});
|
|
123
|
+
return true;
|
|
155
124
|
}
|
|
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
|
-
|
|
187
|
-
index: index,
|
|
188
|
-
checked: checked
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}),
|
|
192
|
-
suffix: jsxRuntime.jsx(blocks.Tooltip, {
|
|
193
|
-
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
194
|
-
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
195
|
-
}) : undefined,
|
|
196
|
-
placement: "top-start",
|
|
197
|
-
children: jsxRuntime.jsx("span", {
|
|
198
|
-
children: jsxRuntime.jsx(blocks.IconButton, {
|
|
199
|
-
icon: icons.eilMathsignMultiplyBasic,
|
|
200
|
-
size: "tiny",
|
|
201
|
-
role: "grey9",
|
|
202
|
-
border: false,
|
|
203
|
-
transparent: true,
|
|
204
|
-
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
205
|
-
onClick: function onClick() {
|
|
206
|
-
return removeOptionInfo(index);
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
})
|
|
210
|
-
}),
|
|
211
|
-
readOnly: disabled,
|
|
212
|
-
invalid: fieldState.invalid,
|
|
213
|
-
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
214
|
-
}, field));
|
|
215
|
-
}
|
|
216
|
-
}, id);
|
|
217
|
-
})
|
|
218
|
-
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
219
|
-
height: 0.5
|
|
220
|
-
}), jsxRuntime.jsx(blocks.Tooltip, {
|
|
221
|
-
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
222
|
-
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
223
|
-
}) : undefined,
|
|
224
|
-
placement: "bottom",
|
|
225
|
-
children: jsxRuntime.jsx("span", {
|
|
226
|
-
children: jsxRuntime.jsx(blocks.Button, {
|
|
227
|
-
block: true,
|
|
228
|
-
size: "micro",
|
|
229
|
-
borderDashed: true,
|
|
230
|
-
transparent: true,
|
|
231
|
-
icon: jsxRuntime.jsx(blocks.Icon, {
|
|
232
|
-
icon: icons.eilMathsignAddCircle
|
|
233
|
-
}),
|
|
234
|
-
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
235
|
-
onClick: appendOptionInfo,
|
|
236
|
-
children: intl$1.formatMessage({
|
|
237
|
-
id: 'option.common.select.addButton'
|
|
238
|
-
})
|
|
125
|
+
},
|
|
126
|
+
render: ({
|
|
127
|
+
fieldState
|
|
128
|
+
}) => {
|
|
129
|
+
var _a;
|
|
130
|
+
return React.createElement(reactTransitionGroup.Transition, {
|
|
131
|
+
in: fieldState.invalid,
|
|
132
|
+
timeout: 0,
|
|
133
|
+
mountOnEnter: true,
|
|
134
|
+
unmountOnExit: true
|
|
135
|
+
}, React.createElement(React.Fragment, null, React.createElement(blocks.StatusText, {
|
|
136
|
+
children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
137
|
+
role: "danger"
|
|
138
|
+
}), React.createElement(blocks.Vspace, {
|
|
139
|
+
height: 0.5
|
|
140
|
+
})));
|
|
141
|
+
}
|
|
142
|
+
}), React.createElement(StyledInputGroup, {
|
|
143
|
+
useDragHandle: true,
|
|
144
|
+
onSortEnd: handleSortEnd
|
|
145
|
+
}, optionInfoFields.map(({
|
|
146
|
+
id
|
|
147
|
+
}, index) => React.createElement(reactHookForm.Controller, {
|
|
148
|
+
key: id,
|
|
149
|
+
control: control,
|
|
150
|
+
name: `optionsDefault.${index}.content`,
|
|
151
|
+
rules: {
|
|
152
|
+
required: {
|
|
153
|
+
value: true,
|
|
154
|
+
message: intl$1.formatMessage({
|
|
155
|
+
id: 'option.common.select.errorMessage.required'
|
|
239
156
|
})
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
render: ({
|
|
160
|
+
field,
|
|
161
|
+
fieldState
|
|
162
|
+
}) => {
|
|
163
|
+
var _a;
|
|
164
|
+
return React.createElement(OptionEditor.default, Object.assign({
|
|
165
|
+
index: index,
|
|
166
|
+
placeholder: intl$1.formatMessage({
|
|
167
|
+
id: 'option.common.select.placeholder'
|
|
168
|
+
}),
|
|
169
|
+
prefix: React.createElement(blocks.Checkbox, {
|
|
170
|
+
disabled: disabled,
|
|
171
|
+
checked: watchedAnswerInfo.includes(index),
|
|
172
|
+
altChar: watchedAnswerInfo.indexOf(index) + 1,
|
|
173
|
+
onChange: checked => updateAnswerInfo({
|
|
174
|
+
index,
|
|
175
|
+
checked
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
suffix: React.createElement(blocks.Tooltip, {
|
|
179
|
+
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
180
|
+
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
181
|
+
}) : undefined,
|
|
182
|
+
placement: "top-start"
|
|
183
|
+
}, React.createElement("span", null, React.createElement(blocks.IconButton, {
|
|
184
|
+
icon: icons.eilMathsignMultiplyBasic,
|
|
185
|
+
size: "tiny",
|
|
186
|
+
role: "grey9",
|
|
187
|
+
border: false,
|
|
188
|
+
transparent: true,
|
|
189
|
+
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
190
|
+
onClick: () => removeOptionInfo(index)
|
|
191
|
+
}))),
|
|
192
|
+
readOnly: disabled,
|
|
193
|
+
invalid: fieldState.invalid,
|
|
194
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
195
|
+
}, field));
|
|
196
|
+
}
|
|
197
|
+
}))), React.createElement(blocks.Vspace, {
|
|
198
|
+
height: 0.5
|
|
199
|
+
}), React.createElement(blocks.Tooltip, {
|
|
200
|
+
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
201
|
+
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
202
|
+
}) : undefined,
|
|
203
|
+
placement: "bottom"
|
|
204
|
+
}, React.createElement("span", null, React.createElement(blocks.Button, {
|
|
205
|
+
block: true,
|
|
206
|
+
size: "micro",
|
|
207
|
+
borderDashed: true,
|
|
208
|
+
transparent: true,
|
|
209
|
+
icon: React.createElement(blocks.Icon, {
|
|
210
|
+
icon: icons.eilMathsignAddCircle
|
|
211
|
+
}),
|
|
212
|
+
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
213
|
+
onClick: appendOptionInfo
|
|
214
|
+
}, intl$1.formatMessage({
|
|
215
|
+
id: 'option.common.select.addButton'
|
|
216
|
+
})))));
|
|
243
217
|
};
|
|
244
218
|
|
|
245
219
|
exports.default = OptionSelectMultipleOrder;
|