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