@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,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useFormContext, useFieldArray, useWatch } from 'react-hook-form';
|
|
3
3
|
import { arrayMove } from 'react-sortable-hoc';
|
|
4
4
|
import { Flex, Text, SortableListGroup, Tooltip, Button, Icon } from '@elice/blocks';
|
|
@@ -10,53 +10,50 @@ import { useMaterialQuizEditContext } from '../../context.js';
|
|
|
10
10
|
import { createRandomId } from '../../utils/randomId.js';
|
|
11
11
|
import OptionGroupGroupListItem from './OptionGroupGroupListItem.js';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var MAX_GROUP_INFO_COUNT = 6;
|
|
14
|
+
var StyledSortableList = styled.div.withConfig({
|
|
15
15
|
componentId: "sc-9aq3yn-0"
|
|
16
16
|
})(["margin:1rem 0;padding:0;"]);
|
|
17
17
|
//
|
|
18
18
|
//
|
|
19
19
|
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
control,
|
|
24
|
-
setValue
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
const watchedGroups = useWatch({
|
|
39
|
-
control,
|
|
20
|
+
var OptionGroupGroupInfo = function OptionGroupGroupInfo() {
|
|
21
|
+
var intl = useRawEliceIntl();
|
|
22
|
+
var _useFormContext = useFormContext(),
|
|
23
|
+
control = _useFormContext.control,
|
|
24
|
+
setValue = _useFormContext.setValue;
|
|
25
|
+
var _useMaterialQuizEditC = useMaterialQuizEditContext(),
|
|
26
|
+
disabled = _useMaterialQuizEditC.disabled;
|
|
27
|
+
var _useFieldArray = useFieldArray({
|
|
28
|
+
name: 'groups',
|
|
29
|
+
keyName: 'id',
|
|
30
|
+
shouldUnregister: true
|
|
31
|
+
}),
|
|
32
|
+
groupInfoFields = _useFieldArray.fields,
|
|
33
|
+
appendGroupInfoFieldItem = _useFieldArray.append,
|
|
34
|
+
removeGroupInfoFieldItem = _useFieldArray.remove;
|
|
35
|
+
var watchedGroups = useWatch({
|
|
36
|
+
control: control,
|
|
40
37
|
name: 'groups'
|
|
41
38
|
});
|
|
42
|
-
|
|
43
|
-
control,
|
|
39
|
+
var watchedAnswerInfo = useWatch({
|
|
40
|
+
control: control,
|
|
44
41
|
name: 'answerInfoDefault'
|
|
45
42
|
});
|
|
46
|
-
|
|
43
|
+
var isMaximumGroups = groupInfoFields.length >= MAX_GROUP_INFO_COUNT;
|
|
47
44
|
/**
|
|
48
45
|
*
|
|
49
46
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
var addGroupAnswerInfo = function addGroupAnswerInfo() {
|
|
48
|
+
var cloneAnswerList = cloneDeep(watchedAnswerInfo);
|
|
52
49
|
cloneAnswerList[groupInfoFields.length] = [];
|
|
53
50
|
setValue('answerInfoDefault', cloneAnswerList);
|
|
54
51
|
};
|
|
55
52
|
/**
|
|
56
53
|
*
|
|
57
54
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
var removeGroupAnswerInfo = function removeGroupAnswerInfo(index) {
|
|
56
|
+
var cloneAnswerList = cloneDeep(watchedAnswerInfo);
|
|
60
57
|
cloneAnswerList.splice(index, 1);
|
|
61
58
|
setValue('answerInfoDefault', cloneAnswerList.filter(Boolean));
|
|
62
59
|
removeGroupInfoFieldItem(Number(index));
|
|
@@ -64,12 +61,11 @@ const OptionGroupGroupInfo = () => {
|
|
|
64
61
|
/**
|
|
65
62
|
*
|
|
66
63
|
*/
|
|
67
|
-
|
|
68
|
-
oldIndex,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const temp = cloneAnswerList[oldIndex];
|
|
64
|
+
var onSortEnd = function onSortEnd(_ref) {
|
|
65
|
+
var oldIndex = _ref.oldIndex,
|
|
66
|
+
newIndex = _ref.newIndex;
|
|
67
|
+
var cloneAnswerList = cloneDeep(watchedAnswerInfo);
|
|
68
|
+
var temp = cloneAnswerList[oldIndex];
|
|
73
69
|
cloneAnswerList[oldIndex] = cloneAnswerList[newIndex];
|
|
74
70
|
cloneAnswerList[newIndex] = temp;
|
|
75
71
|
setValue('groups', arrayMove(watchedGroups, oldIndex, newIndex), {
|
|
@@ -80,57 +76,69 @@ const OptionGroupGroupInfo = () => {
|
|
|
80
76
|
/**
|
|
81
77
|
*
|
|
82
78
|
*/
|
|
83
|
-
|
|
84
|
-
return
|
|
79
|
+
var renderGroupOptionList = function renderGroupOptionList() {
|
|
80
|
+
return jsx(SortableListGroup, {
|
|
85
81
|
onSortEnd: onSortEnd,
|
|
86
|
-
useDragHandle: true
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
useDragHandle: true,
|
|
83
|
+
children: jsx(StyledSortableList, {
|
|
84
|
+
children: groupInfoFields.map(function (group, index) {
|
|
85
|
+
return jsx(OptionGroupGroupListItem, {
|
|
86
|
+
disabled: disabled,
|
|
87
|
+
groupId: index,
|
|
88
|
+
groupsCount: groupInfoFields.length,
|
|
89
|
+
onRemoveOption: function onRemoveOption() {
|
|
90
|
+
return removeGroupAnswerInfo(index);
|
|
91
|
+
}
|
|
92
|
+
}, group.id);
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
});
|
|
94
96
|
};
|
|
95
97
|
/**
|
|
96
98
|
*
|
|
97
99
|
*/
|
|
98
|
-
|
|
99
|
-
return
|
|
100
|
+
var renderGroupOptionAddButton = function renderGroupOptionAddButton() {
|
|
101
|
+
return jsx(Tooltip, {
|
|
100
102
|
title: isMaximumGroups ? intl.formatMessage({
|
|
101
103
|
id: 'group.option.tooltip.maxDisabled'
|
|
102
104
|
}) : undefined,
|
|
103
|
-
placement: "top"
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
105
|
+
placement: "top",
|
|
106
|
+
children: jsx("span", {
|
|
107
|
+
children: jsx(Button, {
|
|
108
|
+
borderDashed: true,
|
|
109
|
+
block: true,
|
|
110
|
+
transparent: true,
|
|
111
|
+
icon: jsx(Icon, {
|
|
112
|
+
icon: eilMathsignAddBasic
|
|
113
|
+
}),
|
|
114
|
+
disabled: isMaximumGroups || disabled,
|
|
115
|
+
onClick: function onClick() {
|
|
116
|
+
appendGroupInfoFieldItem({
|
|
117
|
+
id: createRandomId(),
|
|
118
|
+
group: ''
|
|
119
|
+
});
|
|
120
|
+
addGroupAnswerInfo();
|
|
121
|
+
},
|
|
122
|
+
children: intl.formatMessage({
|
|
123
|
+
id: 'group.option.addButton'
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
});
|
|
122
128
|
};
|
|
123
129
|
//
|
|
124
130
|
//
|
|
125
131
|
//
|
|
126
|
-
return
|
|
127
|
-
column: true
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
return jsxs(Flex, {
|
|
133
|
+
column: true,
|
|
134
|
+
children: [jsx(Text, {
|
|
135
|
+
size: "small",
|
|
136
|
+
bold: true,
|
|
137
|
+
children: intl.formatMessage({
|
|
138
|
+
id: 'group.option.title'
|
|
139
|
+
})
|
|
140
|
+
}), renderGroupOptionList(), renderGroupOptionAddButton()]
|
|
141
|
+
});
|
|
134
142
|
};
|
|
135
143
|
|
|
136
144
|
export { OptionGroupGroupInfo as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useFormContext, useWatch, Controller } from 'react-hook-form';
|
|
3
3
|
import { SortableListItem, Input, Flex, Hspace, Tooltip, IconButton, Text } from '@elice/blocks';
|
|
4
4
|
import { base } from '@elice/design-tokens';
|
|
@@ -7,126 +7,137 @@ import { useRawEliceIntl } from '@elice/intl';
|
|
|
7
7
|
import trim from 'lodash-es/trim';
|
|
8
8
|
import styled from 'styled-components';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var SHEET_Z_INDEX = 982;
|
|
11
|
+
var MIN_GROUP_INFO_COUNT = 2;
|
|
12
|
+
var StyledSortableListItem = styled(SortableListItem).withConfig({
|
|
13
13
|
componentId: "sc-hj5nic-0"
|
|
14
14
|
})(["display:flex;z-index:", ";width:100%;padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
|
|
15
|
-
|
|
15
|
+
var StyledSortableListItemOptionWrapper = styled.div.withConfig({
|
|
16
16
|
componentId: "sc-hj5nic-1"
|
|
17
|
-
})(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border-radius:4px;border:1px solid ", ";background:", ";"], ({
|
|
18
|
-
isGroupChildAnswer
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
})(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border-radius:4px;border:1px solid ", ";background:", ";"], function (_ref) {
|
|
18
|
+
var isGroupChildAnswer = _ref.isGroupChildAnswer;
|
|
19
|
+
return isGroupChildAnswer ? base.color.red8 : base.color.gray3;
|
|
20
|
+
}, base.color.white);
|
|
21
|
+
var StyledInputGroup = styled(Input).withConfig({
|
|
21
22
|
componentId: "sc-hj5nic-2"
|
|
22
23
|
})(["& > div{border:0;}"]);
|
|
23
|
-
|
|
24
|
-
disabled,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}) => {
|
|
24
|
+
var OptionGroupGroupListItem = function OptionGroupGroupListItem(_ref2) {
|
|
25
|
+
var disabled = _ref2.disabled,
|
|
26
|
+
groupId = _ref2.groupId,
|
|
27
|
+
groupsCount = _ref2.groupsCount,
|
|
28
|
+
onRemoveOption = _ref2.onRemoveOption;
|
|
29
29
|
var _a, _b, _c, _d, _e;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
control,
|
|
33
|
-
formState
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
control,
|
|
30
|
+
var intl = useRawEliceIntl();
|
|
31
|
+
var _useFormContext = useFormContext(),
|
|
32
|
+
control = _useFormContext.control,
|
|
33
|
+
formState = _useFormContext.formState;
|
|
34
|
+
var watchedAnswerInfo = useWatch({
|
|
35
|
+
control: control,
|
|
37
36
|
name: 'answerInfoDefault'
|
|
38
37
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
var isGroupChildAnswer = Boolean((_a = watchedAnswerInfo[groupId]) === null || _a === void 0 ? void 0 : _a.length);
|
|
39
|
+
var isMinimumGroups = groupsCount <= MIN_GROUP_INFO_COUNT;
|
|
40
|
+
var errorMessage = (_e = (_d = (_c = (_b = formState.errors) === null || _b === void 0 ? void 0 : _b.groups) === null || _c === void 0 ? void 0 : _c[groupId]) === null || _d === void 0 ? void 0 : _d.group) === null || _e === void 0 ? void 0 : _e.message;
|
|
42
41
|
/**
|
|
43
42
|
*
|
|
44
43
|
*/
|
|
45
|
-
|
|
46
|
-
return
|
|
47
|
-
isGroupChildAnswer: !isGroupChildAnswer
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
id: 'group.option.errorMessage.required'
|
|
56
|
-
})
|
|
57
|
-
},
|
|
58
|
-
validate: e => {
|
|
59
|
-
if (!trim(e).length) {
|
|
60
|
-
return intl.formatMessage({
|
|
44
|
+
var renderOptionGroupInput = function renderOptionGroupInput() {
|
|
45
|
+
return jsx(StyledSortableListItemOptionWrapper, {
|
|
46
|
+
isGroupChildAnswer: !isGroupChildAnswer,
|
|
47
|
+
children: jsx(Controller, {
|
|
48
|
+
control: control,
|
|
49
|
+
name: "groups.".concat(groupId, ".group"),
|
|
50
|
+
rules: {
|
|
51
|
+
required: {
|
|
52
|
+
value: true,
|
|
53
|
+
message: intl.formatMessage({
|
|
61
54
|
id: 'group.option.errorMessage.required'
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
})
|
|
56
|
+
},
|
|
57
|
+
validate: function validate(e) {
|
|
58
|
+
if (!trim(e).length) {
|
|
59
|
+
return intl.formatMessage({
|
|
60
|
+
id: 'group.option.errorMessage.required'
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (!isGroupChildAnswer) {
|
|
64
|
+
return intl.formatMessage({
|
|
65
|
+
id: 'group.option.errorMessage.notChild'
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
68
|
}
|
|
69
|
+
},
|
|
70
|
+
render: function render(_ref3) {
|
|
71
|
+
var field = _ref3.field,
|
|
72
|
+
fieldState = _ref3.fieldState;
|
|
73
|
+
return jsx(StyledInputGroup, Object.assign({
|
|
74
|
+
invalid: fieldState.invalid || !isGroupChildAnswer,
|
|
75
|
+
width: "full",
|
|
76
|
+
disabled: disabled
|
|
77
|
+
}, field, {
|
|
78
|
+
ref: null
|
|
79
|
+
}));
|
|
69
80
|
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
field,
|
|
73
|
-
fieldState
|
|
74
|
-
}) => React.createElement(StyledInputGroup, Object.assign({
|
|
75
|
-
invalid: fieldState.invalid || !isGroupChildAnswer,
|
|
76
|
-
width: "full",
|
|
77
|
-
disabled: disabled
|
|
78
|
-
}, field, {
|
|
79
|
-
ref: null
|
|
80
|
-
}))
|
|
81
|
-
}));
|
|
81
|
+
})
|
|
82
|
+
});
|
|
82
83
|
};
|
|
83
84
|
/**
|
|
84
85
|
*
|
|
85
86
|
*/
|
|
86
|
-
|
|
87
|
-
return
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
var renderOptionRemoveButton = function renderOptionRemoveButton() {
|
|
88
|
+
return jsxs(Fragment, {
|
|
89
|
+
children: [jsx(Hspace, {
|
|
90
|
+
width: 0.5
|
|
91
|
+
}), jsx(Tooltip, {
|
|
92
|
+
title: isMinimumGroups ? intl.formatMessage({
|
|
93
|
+
id: 'group.option.tooltip.minDisabled'
|
|
94
|
+
}) : undefined,
|
|
95
|
+
placement: "top",
|
|
96
|
+
children: jsx("span", {
|
|
97
|
+
children: jsx(IconButton, {
|
|
98
|
+
transparent: true,
|
|
99
|
+
icon: eilMathsignMultiplyBasic,
|
|
100
|
+
role: "gray6",
|
|
101
|
+
size: "micro",
|
|
102
|
+
border: false,
|
|
103
|
+
disabled: isMinimumGroups || disabled,
|
|
104
|
+
onClick: onRemoveOption
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
})]
|
|
108
|
+
});
|
|
103
109
|
};
|
|
104
110
|
/**
|
|
105
111
|
*
|
|
106
112
|
*/
|
|
107
|
-
|
|
113
|
+
var renderErrorMessage = function renderErrorMessage() {
|
|
108
114
|
if (!errorMessage) {
|
|
109
115
|
return null;
|
|
110
116
|
}
|
|
111
|
-
return
|
|
112
|
-
paddingleft: "0.25rem"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
return jsx(Flex, {
|
|
118
|
+
paddingleft: "0.25rem",
|
|
119
|
+
children: jsx(Text, {
|
|
120
|
+
size: "small",
|
|
121
|
+
role: "danger",
|
|
122
|
+
children: errorMessage
|
|
123
|
+
})
|
|
124
|
+
});
|
|
117
125
|
};
|
|
118
126
|
//
|
|
119
127
|
//
|
|
120
128
|
//
|
|
121
|
-
return
|
|
122
|
-
index: groupId
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
return jsx(StyledSortableListItem, {
|
|
130
|
+
index: groupId,
|
|
131
|
+
children: jsxs(Flex, {
|
|
132
|
+
justify: "center",
|
|
133
|
+
width: "100%",
|
|
134
|
+
column: true,
|
|
135
|
+
children: [jsxs(Flex, {
|
|
136
|
+
align: "center",
|
|
137
|
+
children: [renderOptionGroupInput(), renderOptionRemoveButton()]
|
|
138
|
+
}), renderErrorMessage()]
|
|
139
|
+
})
|
|
140
|
+
});
|
|
130
141
|
};
|
|
131
142
|
|
|
132
143
|
export { OptionGroupGroupListItem as default };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
function checkTwoDimensionArray(answerInfo) {
|
|
2
2
|
try {
|
|
3
|
-
return answerInfo.every(
|
|
3
|
+
return answerInfo.every(function (i) {
|
|
4
|
+
return i.every(function (j) {
|
|
5
|
+
return typeof j === 'number';
|
|
6
|
+
});
|
|
7
|
+
});
|
|
4
8
|
} catch (_a) {
|
|
5
9
|
return false;
|
|
6
10
|
}
|
|
@@ -8,7 +8,7 @@ function manipulateValue(v) {
|
|
|
8
8
|
return Object.assign(Object.assign({}, v), {
|
|
9
9
|
// convert string array to object array
|
|
10
10
|
// - ref: https://github.com/react-hook-form/react-hook-form/issues/7622#issuecomment-1018893318
|
|
11
|
-
optionsDefault: Array.isArray(v.optionsDefault) ? v.optionsDefault.map(option
|
|
11
|
+
optionsDefault: Array.isArray(v.optionsDefault) ? v.optionsDefault.map(function (option) {
|
|
12
12
|
var _a, _b;
|
|
13
13
|
return {
|
|
14
14
|
id: createRandomId(),
|
|
@@ -16,10 +16,12 @@ function manipulateValue(v) {
|
|
|
16
16
|
content: (_b = option === null || option === void 0 ? void 0 : option.content) !== null && _b !== void 0 ? _b : ''
|
|
17
17
|
};
|
|
18
18
|
}) : [],
|
|
19
|
-
groups: Array.isArray(v.groups) ? v.groups.map(group
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
groups: Array.isArray(v.groups) ? v.groups.map(function (group) {
|
|
20
|
+
return {
|
|
21
|
+
id: createRandomId(),
|
|
22
|
+
group: group
|
|
23
|
+
};
|
|
24
|
+
}) : []
|
|
23
25
|
});
|
|
24
26
|
}
|
|
25
27
|
/**
|
|
@@ -27,14 +29,17 @@ function manipulateValue(v) {
|
|
|
27
29
|
*/
|
|
28
30
|
function restoreValue(v) {
|
|
29
31
|
return Object.assign(Object.assign({}, v), {
|
|
30
|
-
optionsDefault: v.optionsDefault.length ? v.optionsDefault.map(option
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
optionsDefault: v.optionsDefault.length ? v.optionsDefault.map(function (option) {
|
|
33
|
+
return {
|
|
34
|
+
title: trim(option.title),
|
|
35
|
+
content: option.content
|
|
36
|
+
};
|
|
37
|
+
}) : null,
|
|
34
38
|
answerInfoDefault: Array.isArray(v.answerInfoDefault) || typeof v.answerInfoDefault === 'string' ? v.answerInfoDefault : undefined,
|
|
35
|
-
groups: v.groups.length ? v.groups.map(({
|
|
36
|
-
group
|
|
37
|
-
|
|
39
|
+
groups: v.groups.length ? v.groups.map(function (_ref) {
|
|
40
|
+
var group = _ref.group;
|
|
41
|
+
return trim(group);
|
|
42
|
+
}) : null
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
|