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