@elice/material-quiz 1.240718.0-trasncript.0 → 1.240718.0-trasncript.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +423 -0
- package/cjs/components/eb-sortable/EbDraggable.js +42 -33
- package/cjs/components/eb-sortable/EbDroppable.js +27 -20
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-quiz/MaterialQuiz.js +114 -83
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +36 -29
- package/cjs/components/material-quiz/MaterialQuizInfo.js +151 -149
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +175 -127
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +360 -286
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +172 -126
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +46 -39
- package/cjs/components/material-quiz/MaterialQuizText.js +163 -115
- package/cjs/components/material-quiz/QuizResultBadge.js +32 -22
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +21 -16
- package/cjs/components/material-quiz/constants/color.js +5 -5
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +156 -93
- package/cjs/components/material-quiz/index.js +9 -0
- package/cjs/components/material-quiz/locales/index.js +13 -0
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +259 -161
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +134 -100
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +130 -101
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +64 -52
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +5 -1
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +47 -36
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +280 -232
- package/cjs/components/material-quiz-edit/context.js +8 -2
- package/cjs/components/material-quiz-edit/index.js +7 -0
- package/cjs/components/material-quiz-edit/locales/index.js +13 -0
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +70 -46
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +174 -148
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +175 -149
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +164 -144
- package/cjs/components/material-quiz-edit/options/OptionText.js +90 -82
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +156 -112
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +288 -196
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +88 -75
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +108 -92
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/cjs/components/material-quiz-edit/utils/editValue.js +21 -12
- package/cjs/components/shared/QuestionBox.js +198 -165
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/cjs/components/shared/QuizDraggbleDummyOption.js +23 -16
- package/cjs/components/shared/QuizDraggbleOption.js +65 -59
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/index.js +19 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +59 -68
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +52 -59
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/cjs/components/shared/utils/mergeRefs.js +15 -6
- package/cjs/constant/element.js +3 -3
- package/cjs/constant/index.js +9 -0
- package/cjs/helpers/index.js +8 -10
- package/cjs/hooks/index.js +7 -0
- package/cjs/hooks/useCaculatePassage.js +21 -20
- package/es/_virtual/_rollupPluginBabelHelpers.js +408 -0
- package/es/components/eb-sortable/EbDraggable.js +37 -33
- package/es/components/eb-sortable/EbDroppable.js +22 -20
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-quiz/MaterialQuiz.js +109 -83
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +32 -29
- package/es/components/material-quiz/MaterialQuizInfo.js +148 -150
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +171 -127
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +356 -287
- package/es/components/material-quiz/MaterialQuizSelectOne.js +168 -126
- package/es/components/material-quiz/MaterialQuizShimmer.js +42 -39
- package/es/components/material-quiz/MaterialQuizText.js +158 -115
- package/es/components/material-quiz/QuizResultBadge.js +27 -22
- package/es/components/material-quiz/QuizSubmitStatusText.js +17 -16
- package/es/components/material-quiz/constants/color.js +5 -5
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/es/components/material-quiz/context/MaterialQuizContext.js +153 -94
- package/es/components/material-quiz/index.js +2 -0
- package/es/components/material-quiz/locales/index.js +4 -0
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +253 -161
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +129 -100
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +125 -101
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +60 -52
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +43 -36
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +272 -229
- package/es/components/material-quiz-edit/context.js +4 -2
- package/es/components/material-quiz-edit/index.js +1 -0
- package/es/components/material-quiz-edit/locales/index.js +4 -0
- package/es/components/material-quiz-edit/options/OptionEditor.js +64 -46
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +170 -148
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +171 -149
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +159 -144
- package/es/components/material-quiz-edit/options/OptionText.js +86 -82
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +151 -112
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +283 -197
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +83 -75
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +103 -92
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
- package/es/components/material-quiz-edit/utils/editValue.js +17 -12
- package/es/components/shared/QuestionBox.js +192 -165
- package/es/components/shared/QuizDraggbleDroppedOption.js +11 -12
- package/es/components/shared/QuizDraggbleDummyOption.js +19 -16
- package/es/components/shared/QuizDraggbleOption.js +61 -59
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/index.js +7 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +54 -68
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +47 -59
- package/es/components/shared/utils/getQuestionStatusStyle.js +7 -9
- package/es/components/shared/utils/mergeRefs.js +15 -6
- package/es/constant/element.js +3 -3
- package/es/constant/index.js +1 -0
- package/es/helpers/index.js +8 -10
- package/es/hooks/index.js +1 -0
- package/es/hooks/useCaculatePassage.js +21 -20
- package/package.json +12 -15
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
3
|
import { useFormContext, useWatch, Controller } from 'react-hook-form';
|
|
3
4
|
import { config, postGlobalRemoteFileAttachmentUpload } from '@elice/api-client';
|
|
4
|
-
import { SortableListItem, Input, Dropdown, Flex, Text, Hspace, IconButton,
|
|
5
|
+
import { SortableListItem, Input, Dropdown, Flex, Text, Hspace, IconButton, Tooltip, Notification } from '@elice/blocks';
|
|
5
6
|
import { base } from '@elice/design-tokens';
|
|
6
7
|
import { eilMathsignMultiplyBasic } from '@elice/icons';
|
|
7
8
|
import { useRawEliceIntl } from '@elice/intl';
|
|
@@ -11,84 +12,107 @@ import trim from 'lodash-es/trim';
|
|
|
11
12
|
import styled, { css } from 'styled-components';
|
|
12
13
|
import { checkTwoDimensionArray } from '../../utils/checkTwoDimensionArray.js';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
var SHEET_Z_INDEX = 982;
|
|
16
|
+
var DEFAULT_OPTION_VALUE = -1;
|
|
17
|
+
var MIN_OPTION_INFO_COUNT = 2;
|
|
18
|
+
var FILE_LABEL = 'file-label';
|
|
19
|
+
var FILE_ACCEPT = '.mp3, .mp4, .mov, .png, .jpg, .svg, .gif';
|
|
20
|
+
var MAX_FILE_SIZE = 3 * 1024 * 1024;
|
|
21
|
+
var StyledSortableListItem = styled(SortableListItem).withConfig({
|
|
21
22
|
componentId: "sc-18q96lt-0"
|
|
22
23
|
})(["display:flex;flex:1;z-index:", ";padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
|
|
23
|
-
|
|
24
|
+
var StyledSortableListItemOptionWrapper = styled.div.withConfig({
|
|
24
25
|
componentId: "sc-18q96lt-1"
|
|
25
26
|
})(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border:1px solid ", ";border-radius:4px;background:", ";"], base.color.gray3, base.color.white);
|
|
26
|
-
|
|
27
|
+
var StyledSortableListItemOption = styled.div.withConfig({
|
|
27
28
|
componentId: "sc-18q96lt-2"
|
|
28
|
-
})(["height:3.5rem;&:not(:last-child){border-right:1px solid ", ";}", ";"], base.color.gray3,
|
|
29
|
-
|
|
29
|
+
})(["height:3.5rem;&:not(:last-child){border-right:1px solid ", ";}", ";"], base.color.gray3, function (props) {
|
|
30
|
+
return props['aria-disabled'] && css(["background-color:", ";border-radius:0;"], base.color.gray2);
|
|
31
|
+
});
|
|
32
|
+
var StyledQuizOptionContent = styled.div.withConfig({
|
|
30
33
|
componentId: "sc-18q96lt-3"
|
|
31
34
|
})(["display:flex;align-items:center;width:100%;height:100%;padding:0 1rem;"]);
|
|
32
|
-
|
|
35
|
+
var StyledQuizOptionContentLabel = styled.label.withConfig({
|
|
33
36
|
componentId: "sc-18q96lt-4"
|
|
34
37
|
})(["display:flex;align-items:center;width:100%;height:100%;padding:0 1rem;cursor:pointer;"]);
|
|
35
|
-
|
|
38
|
+
var StyledQuizOptionTextInput = styled(Input).withConfig({
|
|
36
39
|
componentId: "sc-18q96lt-5"
|
|
37
40
|
})(["& > div{border:0;}"]);
|
|
38
|
-
|
|
41
|
+
var StyledQuizOptionContentInput = styled.input.withConfig({
|
|
39
42
|
componentId: "sc-18q96lt-6"
|
|
40
43
|
})(["display:none;"]);
|
|
41
|
-
|
|
44
|
+
var StyledDropdown = styled(Dropdown).withConfig({
|
|
42
45
|
componentId: "sc-18q96lt-7"
|
|
43
46
|
})(["border:0;&.eb-dropdown__inner{width:100%;height:3.5rem;}"]);
|
|
44
47
|
//
|
|
45
48
|
//
|
|
46
49
|
//
|
|
47
|
-
|
|
48
|
-
optionId,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}) => {
|
|
50
|
+
var OptionGroupAnswerListItem = function OptionGroupAnswerListItem(_ref) {
|
|
51
|
+
var optionId = _ref.optionId,
|
|
52
|
+
disabled = _ref.disabled,
|
|
53
|
+
onRemoveItem = _ref.onRemoveItem;
|
|
52
54
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
control,
|
|
56
|
-
formState,
|
|
57
|
-
setValue
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
control,
|
|
55
|
+
var intl = useRawEliceIntl();
|
|
56
|
+
var _useFormContext = useFormContext(),
|
|
57
|
+
control = _useFormContext.control,
|
|
58
|
+
formState = _useFormContext.formState,
|
|
59
|
+
setValue = _useFormContext.setValue;
|
|
60
|
+
var watchedAnswerInfo = useWatch({
|
|
61
|
+
control: control,
|
|
61
62
|
name: 'answerInfoDefault'
|
|
62
63
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
var _useWatch = useWatch({
|
|
65
|
+
control: control,
|
|
66
|
+
name: ['optionsDefault', 'groups']
|
|
67
|
+
}),
|
|
68
|
+
_useWatch2 = _slicedToArray(_useWatch, 2),
|
|
69
|
+
watchedOptions = _useWatch2[0],
|
|
70
|
+
watchedGroupList = _useWatch2[1];
|
|
71
|
+
var errorMessage = (_d = (_c = (_b = (_a = formState.errors) === null || _a === void 0 ? void 0 : _a.optionsDefault) === null || _b === void 0 ? void 0 : _b[optionId]) === null || _c === void 0 ? void 0 : _c.title) === null || _d === void 0 ? void 0 : _d.message;
|
|
72
|
+
var groupIndex = watchedAnswerInfo.findIndex(function (answer) {
|
|
73
|
+
return answer === null || answer === void 0 ? void 0 : answer.includes(optionId);
|
|
66
74
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const isOptionTitle = (_f = (_e = watchedOptions[optionId]) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f.length;
|
|
71
|
-
const isOptionContent = (_h = (_g = watchedOptions[optionId]) === null || _g === void 0 ? void 0 : _g.content) === null || _h === void 0 ? void 0 : _h.length;
|
|
75
|
+
var isReady = useMaterialConfigApiClientUpdate(config.init);
|
|
76
|
+
var isOptionTitle = (_f = (_e = watchedOptions[optionId]) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f.length;
|
|
77
|
+
var isOptionContent = (_h = (_g = watchedOptions[optionId]) === null || _g === void 0 ? void 0 : _g.content) === null || _h === void 0 ? void 0 : _h.length;
|
|
72
78
|
/**
|
|
73
79
|
* File upload function.
|
|
74
80
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
var uploadContentFile = /*#__PURE__*/function () {
|
|
82
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(attachmentFile) {
|
|
83
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
84
|
+
while (1) switch (_context.prev = _context.next) {
|
|
85
|
+
case 0:
|
|
86
|
+
if (isReady) {
|
|
87
|
+
_context.next = 2;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
return _context.abrupt("return");
|
|
91
|
+
case 2:
|
|
92
|
+
return _context.abrupt("return", postGlobalRemoteFileAttachmentUpload({
|
|
93
|
+
attachmentFile: attachmentFile
|
|
94
|
+
}).then(function (res) {
|
|
95
|
+
return res.url;
|
|
96
|
+
}).catch(function (err) {
|
|
97
|
+
console.error(err);
|
|
98
|
+
throw err;
|
|
99
|
+
}));
|
|
100
|
+
case 3:
|
|
101
|
+
case "end":
|
|
102
|
+
return _context.stop();
|
|
103
|
+
}
|
|
104
|
+
}, _callee);
|
|
105
|
+
}));
|
|
106
|
+
return function uploadContentFile(_x) {
|
|
107
|
+
return _ref2.apply(this, arguments);
|
|
108
|
+
};
|
|
109
|
+
}();
|
|
86
110
|
/**
|
|
87
111
|
*
|
|
88
112
|
*/
|
|
89
|
-
|
|
113
|
+
var getContentUrl = function getContentUrl(contentUrl) {
|
|
90
114
|
if (contentUrl.includes('![]')) {
|
|
91
|
-
|
|
115
|
+
var optionContentUrl = contentUrl === null || contentUrl === void 0 ? void 0 : contentUrl.substring(contentUrl.indexOf('(') + 1, contentUrl.indexOf(')'));
|
|
92
116
|
return optionContentUrl;
|
|
93
117
|
}
|
|
94
118
|
return contentUrl;
|
|
@@ -96,174 +120,231 @@ const OptionGroupAnswerListItem = ({
|
|
|
96
120
|
/**
|
|
97
121
|
*
|
|
98
122
|
*/
|
|
99
|
-
|
|
100
|
-
return
|
|
123
|
+
var renderOptionTitleInput = function renderOptionTitleInput() {
|
|
124
|
+
return jsx(StyledSortableListItemOption, {
|
|
101
125
|
style: {
|
|
102
126
|
width: '33.3%'
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
id: 'answer.option.errorMessage'
|
|
112
|
-
})
|
|
113
|
-
},
|
|
114
|
-
validate: e => {
|
|
115
|
-
if (!trim(e).length) {
|
|
116
|
-
return intl.formatMessage({
|
|
127
|
+
},
|
|
128
|
+
children: jsx(Controller, {
|
|
129
|
+
control: control,
|
|
130
|
+
name: "optionsDefault.".concat(optionId, ".title"),
|
|
131
|
+
rules: {
|
|
132
|
+
required: {
|
|
133
|
+
value: !isOptionTitle && !isOptionContent,
|
|
134
|
+
message: intl.formatMessage({
|
|
117
135
|
id: 'answer.option.errorMessage'
|
|
118
|
-
})
|
|
136
|
+
})
|
|
137
|
+
},
|
|
138
|
+
validate: function validate(e) {
|
|
139
|
+
if (!trim(e).length) {
|
|
140
|
+
return intl.formatMessage({
|
|
141
|
+
id: 'answer.option.errorMessage'
|
|
142
|
+
});
|
|
143
|
+
}
|
|
119
144
|
}
|
|
145
|
+
},
|
|
146
|
+
render: function render(_ref3) {
|
|
147
|
+
var field = _ref3.field;
|
|
148
|
+
return jsx(StyledQuizOptionTextInput, Object.assign({}, field, {
|
|
149
|
+
width: "full",
|
|
150
|
+
disabled: disabled
|
|
151
|
+
}));
|
|
120
152
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
field
|
|
124
|
-
}) => React.createElement(StyledQuizOptionTextInput, Object.assign({}, field, {
|
|
125
|
-
width: "full",
|
|
126
|
-
disabled: disabled
|
|
127
|
-
}))
|
|
128
|
-
}));
|
|
153
|
+
})
|
|
154
|
+
});
|
|
129
155
|
};
|
|
130
156
|
/**
|
|
131
157
|
*
|
|
132
158
|
*/
|
|
133
|
-
|
|
134
|
-
return
|
|
159
|
+
var renderOptionContentInput = function renderOptionContentInput() {
|
|
160
|
+
return jsx(StyledSortableListItemOption, {
|
|
135
161
|
style: {
|
|
136
162
|
width: '33.3%'
|
|
137
163
|
},
|
|
138
|
-
"aria-disabled": disabled
|
|
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
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
164
|
+
"aria-disabled": disabled,
|
|
165
|
+
children: jsx(Controller, {
|
|
166
|
+
control: control,
|
|
167
|
+
name: "optionsDefault.".concat(optionId, ".content"),
|
|
168
|
+
render: function render(_ref4) {
|
|
169
|
+
var field = _ref4.field;
|
|
170
|
+
return jsx(Fragment, {
|
|
171
|
+
children: field.value ? jsx(StyledQuizOptionContent, {
|
|
172
|
+
children: jsxs(Flex, {
|
|
173
|
+
justify: "space-between",
|
|
174
|
+
align: "center",
|
|
175
|
+
width: "100%",
|
|
176
|
+
height: "100%",
|
|
177
|
+
children: [jsx(Text, {
|
|
178
|
+
ellipsis: true,
|
|
179
|
+
children: jsx("a", {
|
|
180
|
+
href: getContentUrl(field.value),
|
|
181
|
+
target: "_blank",
|
|
182
|
+
rel: "noreferrer",
|
|
183
|
+
children: getContentUrl(field.value)
|
|
184
|
+
})
|
|
185
|
+
}), jsxs(Flex, {
|
|
186
|
+
align: "center",
|
|
187
|
+
children: [jsx(Hspace, {
|
|
188
|
+
width: 0.5
|
|
189
|
+
}), jsx(IconButton, {
|
|
190
|
+
disabled: disabled,
|
|
191
|
+
icon: eilMathsignMultiplyBasic,
|
|
192
|
+
role: "gray6",
|
|
193
|
+
size: "micro",
|
|
194
|
+
border: false,
|
|
195
|
+
transparent: true,
|
|
196
|
+
onClick: function onClick() {
|
|
197
|
+
return field.onChange('');
|
|
198
|
+
}
|
|
199
|
+
})]
|
|
200
|
+
})]
|
|
201
|
+
})
|
|
202
|
+
}) : jsxs(Fragment, {
|
|
203
|
+
children: [jsx(StyledQuizOptionContentLabel, {
|
|
204
|
+
htmlFor: "".concat(FILE_LABEL, "_").concat(optionId),
|
|
205
|
+
children: jsx(Text, {
|
|
206
|
+
role: "primary",
|
|
207
|
+
underline: true,
|
|
208
|
+
children: intl.formatMessage({
|
|
209
|
+
id: 'answer.option.file.label'
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
}), jsx(StyledQuizOptionContentInput, Object.assign({}, field, {
|
|
213
|
+
id: "".concat(FILE_LABEL, "_").concat(optionId),
|
|
214
|
+
type: "file",
|
|
215
|
+
accept: FILE_ACCEPT,
|
|
216
|
+
disabled: disabled,
|
|
217
|
+
onChange: function () {
|
|
218
|
+
var _onChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
|
|
219
|
+
var _a, _b, file, contentFileUrl;
|
|
220
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
221
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
222
|
+
case 0:
|
|
223
|
+
file = (_b = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
|
|
224
|
+
if (file) {
|
|
225
|
+
_context2.next = 3;
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
return _context2.abrupt("return");
|
|
229
|
+
case 3:
|
|
230
|
+
if (!(file.size > MAX_FILE_SIZE)) {
|
|
231
|
+
_context2.next = 5;
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
return _context2.abrupt("return", Notification.error(intl.formatMessage({
|
|
235
|
+
id: 'answer.option.file.errorMessage.maxSize'
|
|
236
|
+
}, {
|
|
237
|
+
size: 3
|
|
238
|
+
})));
|
|
239
|
+
case 5:
|
|
240
|
+
_context2.next = 7;
|
|
241
|
+
return uploadContentFile(file);
|
|
242
|
+
case 7:
|
|
243
|
+
contentFileUrl = _context2.sent;
|
|
244
|
+
field.onChange(", ")"));
|
|
245
|
+
case 9:
|
|
246
|
+
case "end":
|
|
247
|
+
return _context2.stop();
|
|
248
|
+
}
|
|
249
|
+
}, _callee2);
|
|
250
|
+
}));
|
|
251
|
+
function onChange(_x2) {
|
|
252
|
+
return _onChange.apply(this, arguments);
|
|
253
|
+
}
|
|
254
|
+
return onChange;
|
|
255
|
+
}()
|
|
256
|
+
}))]
|
|
257
|
+
})
|
|
258
|
+
});
|
|
194
259
|
}
|
|
195
|
-
})
|
|
196
|
-
})
|
|
260
|
+
})
|
|
261
|
+
});
|
|
197
262
|
};
|
|
198
263
|
/**
|
|
199
264
|
*
|
|
200
265
|
*/
|
|
201
|
-
|
|
202
|
-
return
|
|
266
|
+
var renderOptionGroupDropdown = function renderOptionGroupDropdown() {
|
|
267
|
+
return jsx(StyledSortableListItemOption, {
|
|
203
268
|
style: {
|
|
204
269
|
width: '33.3%'
|
|
205
270
|
},
|
|
206
|
-
"aria-disabled": disabled
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
271
|
+
"aria-disabled": disabled,
|
|
272
|
+
children: jsxs(StyledDropdown, {
|
|
273
|
+
disabled: disabled,
|
|
274
|
+
value: groupIndex,
|
|
275
|
+
onChange: function onChange(e) {
|
|
276
|
+
var cloneAnswerList = cloneDeep(watchedAnswerInfo);
|
|
277
|
+
var answerList = cloneAnswerList.map(function (answers) {
|
|
278
|
+
return answers.filter(function (answer) {
|
|
279
|
+
return answer !== optionId;
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
if (e === DEFAULT_OPTION_VALUE) {
|
|
283
|
+
return setValue('answerInfoDefault', answerList);
|
|
284
|
+
}
|
|
285
|
+
if (answerList[e]) {
|
|
286
|
+
answerList[e] = [].concat(_toConsumableArray(answerList[e]), [optionId]);
|
|
287
|
+
} else {
|
|
288
|
+
answerList[e] = [optionId];
|
|
289
|
+
}
|
|
290
|
+
setValue('answerInfoDefault', answerList);
|
|
291
|
+
},
|
|
292
|
+
children: [jsx("option", {
|
|
293
|
+
value: DEFAULT_OPTION_VALUE,
|
|
294
|
+
children: intl.formatMessage({
|
|
295
|
+
id: 'answer.option.default.group'
|
|
296
|
+
})
|
|
297
|
+
}), watchedGroupList.map(function (group, index) {
|
|
298
|
+
return jsx("option", {
|
|
299
|
+
value: index,
|
|
300
|
+
children: group.group
|
|
301
|
+
}, index);
|
|
302
|
+
})]
|
|
303
|
+
})
|
|
304
|
+
});
|
|
231
305
|
};
|
|
232
306
|
/**
|
|
233
307
|
*
|
|
234
308
|
*/
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
309
|
+
var renderOptionRemoveButton = function renderOptionRemoveButton() {
|
|
310
|
+
var isMinimumOptions = (watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.length) <= MIN_OPTION_INFO_COUNT;
|
|
311
|
+
return jsxs(Fragment, {
|
|
312
|
+
children: [jsx(Hspace, {
|
|
313
|
+
width: 0.5
|
|
314
|
+
}), jsx(Tooltip, {
|
|
315
|
+
title: isMinimumOptions ? intl.formatMessage({
|
|
316
|
+
id: 'answer.option.tooltip.minDisabled'
|
|
317
|
+
}) : undefined,
|
|
318
|
+
placement: "top",
|
|
319
|
+
children: jsx("span", {
|
|
320
|
+
children: jsx(IconButton, {
|
|
321
|
+
transparent: true,
|
|
322
|
+
icon: eilMathsignMultiplyBasic,
|
|
323
|
+
role: "gray6",
|
|
324
|
+
size: "micro",
|
|
325
|
+
border: false,
|
|
326
|
+
disabled: disabled || isMinimumOptions,
|
|
327
|
+
onClick: onRemoveItem
|
|
328
|
+
})
|
|
329
|
+
})
|
|
330
|
+
})]
|
|
331
|
+
});
|
|
253
332
|
};
|
|
254
333
|
/**
|
|
255
334
|
*
|
|
256
335
|
*/
|
|
257
|
-
|
|
336
|
+
var renderErrorMessage = function renderErrorMessage() {
|
|
258
337
|
if (!errorMessage) {
|
|
259
338
|
return null;
|
|
260
339
|
}
|
|
261
|
-
return
|
|
262
|
-
paddingleft: "0.25rem"
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
340
|
+
return jsx(Flex, {
|
|
341
|
+
paddingleft: "0.25rem",
|
|
342
|
+
children: jsx(Text, {
|
|
343
|
+
size: "small",
|
|
344
|
+
role: "danger",
|
|
345
|
+
children: errorMessage
|
|
346
|
+
})
|
|
347
|
+
});
|
|
267
348
|
};
|
|
268
349
|
//
|
|
269
350
|
//
|
|
@@ -271,16 +352,21 @@ const OptionGroupAnswerListItem = ({
|
|
|
271
352
|
if (!checkTwoDimensionArray(watchedAnswerInfo)) {
|
|
272
353
|
return null;
|
|
273
354
|
}
|
|
274
|
-
return
|
|
355
|
+
return jsx(StyledSortableListItem, {
|
|
275
356
|
index: optionId,
|
|
276
|
-
disabled: disabled
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
357
|
+
disabled: disabled,
|
|
358
|
+
children: jsxs(Flex, {
|
|
359
|
+
justify: "center",
|
|
360
|
+
width: "calc(100% - 1.5rem)",
|
|
361
|
+
column: true,
|
|
362
|
+
children: [jsxs(Flex, {
|
|
363
|
+
align: "center",
|
|
364
|
+
children: [jsxs(StyledSortableListItemOptionWrapper, {
|
|
365
|
+
children: [renderOptionTitleInput(), renderOptionContentInput(), renderOptionGroupDropdown()]
|
|
366
|
+
}), renderOptionRemoveButton()]
|
|
367
|
+
}), renderErrorMessage()]
|
|
368
|
+
})
|
|
369
|
+
});
|
|
284
370
|
};
|
|
285
371
|
|
|
286
372
|
export { OptionGroupAnswerListItem as default };
|