@elice/material-quiz 1.240718.0-trasncript.2 → 1.240718.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/eb-sortable/EbDraggable.js +33 -42
- package/cjs/components/eb-sortable/EbDroppable.js +20 -27
- package/cjs/components/markdown-editor/index.d.ts +2 -1
- package/cjs/components/markdown-editor/index.js +10 -19
- package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
- package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
- package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
- package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
- package/cjs/components/material-quiz/constants/color.js +5 -5
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +93 -156
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
- package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
- package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
- package/cjs/components/material-quiz-edit/context.js +2 -8
- package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
- package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
- package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
- package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
- package/cjs/components/shared/QuestionBox.js +165 -198
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
- package/cjs/components/shared/QuizDraggbleOption.js +59 -65
- package/cjs/components/shared/StyledMarkdown.js +1 -5
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
- package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/cjs/components/shared/utils/mergeRefs.js +6 -15
- package/cjs/constant/element.js +3 -3
- package/cjs/helpers/index.js +10 -8
- package/cjs/hooks/useCaculatePassage.js +20 -21
- package/es/components/eb-sortable/EbDraggable.js +33 -37
- package/es/components/eb-sortable/EbDroppable.js +20 -22
- package/es/components/markdown-editor/index.d.ts +2 -1
- package/es/components/markdown-editor/index.js +10 -15
- package/es/components/material-quiz/MaterialQuiz.js +83 -109
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
- package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
- package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
- package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
- package/es/components/material-quiz/MaterialQuizText.js +115 -158
- package/es/components/material-quiz/QuizResultBadge.js +22 -27
- package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
- package/es/components/material-quiz/constants/color.js +5 -5
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
- package/es/components/material-quiz/context/MaterialQuizContext.js +94 -153
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
- package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
- package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
- package/es/components/material-quiz-edit/context.js +2 -4
- package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
- package/es/components/material-quiz-edit/options/OptionText.js +82 -86
- package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
- package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
- package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
- package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
- package/es/components/material-quiz-edit/utils/editValue.js +12 -17
- package/es/components/shared/QuestionBox.js +165 -192
- package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
- package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
- package/es/components/shared/QuizDraggbleOption.js +59 -61
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
- package/es/components/shared/question-radio/QuestionRadio.js +7 -9
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
- package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
- package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
- package/es/components/shared/utils/mergeRefs.js +6 -15
- package/es/constant/element.js +3 -3
- package/es/helpers/index.js +10 -8
- package/es/hooks/useCaculatePassage.js +20 -21
- package/package.json +15 -12
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
- package/cjs/components/material-quiz/index.js +0 -9
- package/cjs/components/material-quiz/locales/index.js +0 -13
- package/cjs/components/material-quiz-edit/index.js +0 -7
- package/cjs/components/material-quiz-edit/locales/index.js +0 -13
- package/cjs/components/shared/index.js +0 -19
- package/cjs/constant/index.js +0 -9
- package/cjs/hooks/index.js +0 -7
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
- package/es/components/material-quiz/index.js +0 -2
- package/es/components/material-quiz/locales/index.js +0 -4
- package/es/components/material-quiz-edit/index.js +0 -1
- package/es/components/material-quiz-edit/locales/index.js +0 -4
- package/es/components/shared/index.js +0 -7
- package/es/constant/index.js +0 -1
- package/es/hooks/index.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var blocks = require('@elice/blocks');
|
|
7
7
|
var designTokens = require('@elice/design-tokens');
|
|
8
8
|
var icons = require('@elice/icons');
|
|
@@ -11,27 +11,25 @@ var EbDraggable = require('../eb-sortable/EbDraggable.js');
|
|
|
11
11
|
var MaterialQuizContext = require('../material-quiz/context/MaterialQuizContext.js');
|
|
12
12
|
var StyledMarkdown = require('./StyledMarkdown.js');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
17
|
-
|
|
18
|
-
var StyledQuizDraggbleOptionHandle = styled__default.default.div.withConfig({
|
|
14
|
+
const StyledQuizDraggbleOptionHandle = styled.div.withConfig({
|
|
19
15
|
componentId: "sc-19b0zkq-0"
|
|
20
16
|
})(["display:flex;align-items:center;justify-content:center;background-color:", ";width:1.5rem;flex:none;"], designTokens.base.color.navy5);
|
|
21
|
-
|
|
17
|
+
const StyledQuizDraggbleOptionContent = styled.div.withConfig({
|
|
22
18
|
componentId: "sc-19b0zkq-1"
|
|
23
|
-
})(["display:flex;justify-content:space-between;min-width:0;align-items:center;flex:auto;padding:0.875rem 1rem;line-height:24px;border:", ";background-color:", ";"],
|
|
24
|
-
|
|
19
|
+
})(["display:flex;justify-content:space-between;min-width:0;align-items:center;flex:auto;padding:0.875rem 1rem;line-height:24px;border:", ";background-color:", ";"], ({
|
|
20
|
+
role
|
|
21
|
+
}) => {
|
|
25
22
|
switch (role) {
|
|
26
23
|
case 'correct':
|
|
27
|
-
return
|
|
24
|
+
return `1px solid ${designTokens.base.color.primary6}`;
|
|
28
25
|
case 'wrong':
|
|
29
|
-
return
|
|
26
|
+
return `1px solid ${designTokens.base.color.red6}`;
|
|
30
27
|
default:
|
|
31
28
|
return '';
|
|
32
29
|
}
|
|
33
|
-
},
|
|
34
|
-
|
|
30
|
+
}, ({
|
|
31
|
+
role
|
|
32
|
+
}) => {
|
|
35
33
|
switch (role) {
|
|
36
34
|
case 'answer':
|
|
37
35
|
return designTokens.base.color.primary6;
|
|
@@ -39,13 +37,14 @@ var StyledQuizDraggbleOptionContent = styled__default.default.div.withConfig({
|
|
|
39
37
|
return '';
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
|
-
|
|
40
|
+
const StyledOrder = styled.div.withConfig({
|
|
43
41
|
componentId: "sc-19b0zkq-2"
|
|
44
42
|
})(["width:1.5rem;height:1.5rem;display:flex;border-radius:4px;align-items:center;justify-content:center;color:", ";background-color:", ";flex:none;margin-left:0.5rem;"], designTokens.base.color.navy0, designTokens.base.color.navy4);
|
|
45
|
-
|
|
43
|
+
const StyledQuizDraggbleOption = styled(EbDraggable.default).withConfig({
|
|
46
44
|
componentId: "sc-19b0zkq-3"
|
|
47
|
-
})(["display:flex;border-radius:8px;border:1px solid ", ";background-color:", ";overflow:hidden;z-index:980 !important;&:not(:last-of-type){margin-bottom:1rem;}", "{background-color:", ";color:", ";}", "{background-color:", ";& *{color:", ";}}", "{background-color:", ";color:", ";}&.ui-draggable-dragging{z-index:1000 !important;color:", " !important;border:none !important;", "{background-color:", ";}", "{background-color:", ";border:1px solid ", " !important;}", "{color:", ";background-color:", ";}& *{color:", " !important;}}&.ui-draggable-dragging.quiz-answer{width:calc(100% - 1rem * 2);}"], designTokens.base.color.navy4, designTokens.base.color.navy5, StyledQuizDraggbleOptionHandle,
|
|
48
|
-
|
|
45
|
+
})(["display:flex;border-radius:8px;border:1px solid ", ";background-color:", ";overflow:hidden;z-index:980 !important;&:not(:last-of-type){margin-bottom:1rem;}", "{background-color:", ";color:", ";}", "{background-color:", ";& *{color:", ";}}", "{background-color:", ";color:", ";}&.ui-draggable-dragging{z-index:1000 !important;color:", " !important;border:none !important;", "{background-color:", ";}", "{background-color:", ";border:1px solid ", " !important;}", "{color:", ";background-color:", ";}& *{color:", " !important;}}&.ui-draggable-dragging.quiz-answer{width:calc(100% - 1rem * 2);}"], designTokens.base.color.navy4, designTokens.base.color.navy5, StyledQuizDraggbleOptionHandle, ({
|
|
46
|
+
role
|
|
47
|
+
}) => {
|
|
49
48
|
switch (role) {
|
|
50
49
|
case 'answer':
|
|
51
50
|
return designTokens.base.color.primary4;
|
|
@@ -57,8 +56,9 @@ var StyledQuizDraggbleOption = styled__default.default(EbDraggable.default).with
|
|
|
57
56
|
default:
|
|
58
57
|
return designTokens.base.color.navy3;
|
|
59
58
|
}
|
|
60
|
-
},
|
|
61
|
-
|
|
59
|
+
}, ({
|
|
60
|
+
role
|
|
61
|
+
}) => {
|
|
62
62
|
switch (role) {
|
|
63
63
|
case 'answer':
|
|
64
64
|
return designTokens.base.color.primary9;
|
|
@@ -70,8 +70,9 @@ var StyledQuizDraggbleOption = styled__default.default(EbDraggable.default).with
|
|
|
70
70
|
default:
|
|
71
71
|
return designTokens.base.color.navy5;
|
|
72
72
|
}
|
|
73
|
-
}, StyledQuizDraggbleOptionContent,
|
|
74
|
-
|
|
73
|
+
}, StyledQuizDraggbleOptionContent, ({
|
|
74
|
+
role
|
|
75
|
+
}) => {
|
|
75
76
|
switch (role) {
|
|
76
77
|
case 'answer':
|
|
77
78
|
return designTokens.base.color.primary1;
|
|
@@ -83,8 +84,9 @@ var StyledQuizDraggbleOption = styled__default.default(EbDraggable.default).with
|
|
|
83
84
|
default:
|
|
84
85
|
return designTokens.base.color.navy5;
|
|
85
86
|
}
|
|
86
|
-
},
|
|
87
|
-
|
|
87
|
+
}, ({
|
|
88
|
+
role
|
|
89
|
+
}) => {
|
|
88
90
|
switch (role) {
|
|
89
91
|
case 'answer':
|
|
90
92
|
return designTokens.base.color.primary9;
|
|
@@ -96,8 +98,9 @@ var StyledQuizDraggbleOption = styled__default.default(EbDraggable.default).with
|
|
|
96
98
|
default:
|
|
97
99
|
return designTokens.base.color.navy0;
|
|
98
100
|
}
|
|
99
|
-
}, StyledOrder,
|
|
100
|
-
|
|
101
|
+
}, StyledOrder, ({
|
|
102
|
+
role
|
|
103
|
+
}) => {
|
|
101
104
|
switch (role) {
|
|
102
105
|
case 'answer':
|
|
103
106
|
return designTokens.base.color.primary3;
|
|
@@ -109,8 +112,9 @@ var StyledQuizDraggbleOption = styled__default.default(EbDraggable.default).with
|
|
|
109
112
|
default:
|
|
110
113
|
return designTokens.base.color.navy4;
|
|
111
114
|
}
|
|
112
|
-
},
|
|
113
|
-
|
|
115
|
+
}, ({
|
|
116
|
+
role
|
|
117
|
+
}) => {
|
|
114
118
|
switch (role) {
|
|
115
119
|
case 'answer':
|
|
116
120
|
return designTokens.base.color.primary9;
|
|
@@ -123,49 +127,39 @@ var StyledQuizDraggbleOption = styled__default.default(EbDraggable.default).with
|
|
|
123
127
|
return designTokens.base.color.navy0;
|
|
124
128
|
}
|
|
125
129
|
}, designTokens.base.color.navy0, StyledQuizDraggbleOptionHandle, designTokens.base.color.navy5, StyledQuizDraggbleOptionContent, designTokens.base.color.navy4, designTokens.base.color.navy4, StyledOrder, designTokens.base.color.navy0, designTokens.base.color.navy5, designTokens.base.color.navy0);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
vertical = _useMaterialQuizState.vertical;
|
|
141
|
-
return jsxRuntime.jsxs(StyledQuizDraggbleOption, {
|
|
130
|
+
const QuizDraggbleOption = ({
|
|
131
|
+
id,
|
|
132
|
+
className,
|
|
133
|
+
content,
|
|
134
|
+
disabled = false,
|
|
135
|
+
role = 'default',
|
|
136
|
+
indexOrder,
|
|
137
|
+
clone = false,
|
|
138
|
+
isMarkdown = false
|
|
139
|
+
}) => {
|
|
140
|
+
const {
|
|
141
|
+
vertical
|
|
142
|
+
} = MaterialQuizContext.useMaterialQuizState();
|
|
143
|
+
return React.createElement(StyledQuizDraggbleOption, {
|
|
142
144
|
id: id,
|
|
143
145
|
className: className,
|
|
144
146
|
disabled: disabled,
|
|
145
147
|
role: role,
|
|
146
148
|
clone: clone,
|
|
147
|
-
vertical: vertical
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
wordBreak: "break-all",
|
|
162
|
-
role: role === 'answer' ? 'white' : 'default',
|
|
163
|
-
children: content
|
|
164
|
-
}), indexOrder ? jsxRuntime.jsx(StyledOrder, {
|
|
165
|
-
children: indexOrder
|
|
166
|
-
}) : null]
|
|
167
|
-
})]
|
|
168
|
-
});
|
|
149
|
+
vertical: vertical
|
|
150
|
+
}, React.createElement(StyledQuizDraggbleOptionHandle, null, React.createElement(blocks.Icon, {
|
|
151
|
+
size: "large",
|
|
152
|
+
icon: icons.eilDraggableVertical
|
|
153
|
+
})), React.createElement(StyledQuizDraggbleOptionContent, null, isMarkdown ? React.createElement(StyledMarkdown.default, {
|
|
154
|
+
children: content,
|
|
155
|
+
dark: true,
|
|
156
|
+
paddingx: 0,
|
|
157
|
+
paddingy: 0
|
|
158
|
+
}) : React.createElement(blocks.Text, {
|
|
159
|
+
userSelect: "none",
|
|
160
|
+
wordBreak: "break-all",
|
|
161
|
+
role: role === 'answer' ? 'white' : 'default'
|
|
162
|
+
}, content), indexOrder ? React.createElement(StyledOrder, null, indexOrder) : null));
|
|
169
163
|
};
|
|
170
164
|
|
|
171
165
|
exports.default = QuizDraggbleOption;
|
|
@@ -5,11 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var markdown = require('@elice/markdown');
|
|
6
6
|
var styled = require('styled-components');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
11
|
-
|
|
12
|
-
var StyledMarkdown = styled__default.default(markdown.Markdown).withConfig({
|
|
8
|
+
const StyledMarkdown = styled(markdown.Markdown).withConfig({
|
|
13
9
|
componentId: "sc-l6r531-0"
|
|
14
10
|
})(["p{margin:0 !important;}code{white-space:pre-wrap;word-break:break-all;}"]);
|
|
15
11
|
|
|
@@ -3,25 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
7
|
var styled = require('styled-components');
|
|
8
8
|
var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
13
|
-
|
|
14
|
-
var StyledQuestionCheckbox = styled__default.default.div.withConfig({
|
|
10
|
+
const StyledQuestionCheckbox = styled.div.withConfig({
|
|
15
11
|
componentId: "sc-1jgy6x5-0"
|
|
16
12
|
})(["display:flex;flex-direction:column;"]);
|
|
17
|
-
|
|
18
|
-
var
|
|
13
|
+
const QuestionCheckbox = _a => {
|
|
14
|
+
var {
|
|
15
|
+
children
|
|
16
|
+
} = _a,
|
|
19
17
|
props = tslib.__rest(_a, ["children"]);
|
|
20
|
-
return
|
|
21
|
-
children: jsxRuntime.jsx(StyledQuestionCheckbox, {
|
|
22
|
-
children: children
|
|
23
|
-
})
|
|
24
|
-
}));
|
|
18
|
+
return React.createElement(QuestionCheckboxContext.QuestionCheckboxContextProvider, Object.assign({}, props), React.createElement(StyledQuestionCheckbox, null, children));
|
|
25
19
|
};
|
|
26
20
|
|
|
27
21
|
exports.default = QuestionCheckbox;
|
|
@@ -4,6 +4,6 @@ type Value = Pick<QuestionCheckboxProps, 'selectedOptions' | 'disabled' | 'onSel
|
|
|
4
4
|
interface QuestionCheckboxProviderProps extends QuestionCheckboxProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
-
declare function QuestionCheckboxContextProvider({ selectedOptions, onSelect, disabled, children, }: QuestionCheckboxProviderProps): JSX.Element;
|
|
7
|
+
declare function QuestionCheckboxContextProvider({ selectedOptions, onSelect, disabled, children, }: QuestionCheckboxProviderProps): React.JSX.Element;
|
|
8
8
|
declare function useQuestionCheckboxContext(): Value;
|
|
9
9
|
export { QuestionCheckboxContextProvider, useQuestionCheckboxContext };
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
3
|
var React = require('react');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
9
|
-
|
|
10
|
-
var QuestionCheckboxContext = React__default.default.createContext(undefined);
|
|
5
|
+
const QuestionCheckboxContext = React.createContext(undefined);
|
|
11
6
|
QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
|
|
12
|
-
function QuestionCheckboxContextProvider(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
function QuestionCheckboxContextProvider({
|
|
8
|
+
selectedOptions,
|
|
9
|
+
onSelect,
|
|
10
|
+
disabled,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
17
13
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value: value,
|
|
28
|
-
children: children
|
|
29
|
-
});
|
|
14
|
+
const onSelectValue = React.useCallback(onSelect, []);
|
|
15
|
+
const value = React.useMemo(() => ({
|
|
16
|
+
selectedOptions,
|
|
17
|
+
disabled,
|
|
18
|
+
onSelect: onSelectValue
|
|
19
|
+
}), [selectedOptions, disabled, onSelectValue]);
|
|
20
|
+
return React.createElement(QuestionCheckboxContext.Provider, {
|
|
21
|
+
value: value
|
|
22
|
+
}, children);
|
|
30
23
|
}
|
|
31
24
|
function useQuestionCheckboxContext() {
|
|
32
|
-
|
|
25
|
+
const context = React.useContext(QuestionCheckboxContext);
|
|
33
26
|
if (context === undefined) {
|
|
34
27
|
throw new Error('useQuestionCheckboxContext must be used within a QuestionCheckboxContextProvider');
|
|
35
28
|
}
|
|
@@ -2,23 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var designTokens = require('@elice/design-tokens');
|
|
8
7
|
var styled = require('styled-components');
|
|
9
8
|
var getQuestionStatusStyle = require('../utils/getQuestionStatusStyle.js');
|
|
10
9
|
var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
15
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
16
|
-
|
|
17
|
-
var StyledQuestionCheckboxOption = styled__default.default.div.withConfig({
|
|
11
|
+
const StyledQuestionCheckboxOption = styled.div.withConfig({
|
|
18
12
|
componentId: "sc-1erloup-0"
|
|
19
|
-
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""],
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
|
|
14
|
+
checked,
|
|
15
|
+
status
|
|
16
|
+
}) => {
|
|
22
17
|
switch (status) {
|
|
23
18
|
case 'correct':
|
|
24
19
|
return designTokens.base.color.green1;
|
|
@@ -27,21 +22,20 @@ var StyledQuestionCheckboxOption = styled__default.default.div.withConfig({
|
|
|
27
22
|
default:
|
|
28
23
|
return checked ? designTokens.base.color.primary1 : designTokens.base.color.navy6;
|
|
29
24
|
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
37
|
-
var StyledCustomCheckboxButton = styled__default.default.span.withConfig({
|
|
25
|
+
}, ({
|
|
26
|
+
disabled
|
|
27
|
+
}) => disabled ? 'not-allowed' : 'pointer', ({
|
|
28
|
+
isAnswer
|
|
29
|
+
}) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
|
|
30
|
+
const StyledCustomCheckboxButton = styled.span.withConfig({
|
|
38
31
|
componentId: "sc-1erloup-1"
|
|
39
32
|
})([""]);
|
|
40
|
-
|
|
33
|
+
const StyledQuestionCheckboxInput = styled.input.withConfig({
|
|
41
34
|
componentId: "sc-1erloup-2"
|
|
42
|
-
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;width:1rem;height:1rem;margin-right:0.875rem;background-color:", ";border:", ";", ""],
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;width:1rem;height:1rem;margin-right:0.875rem;background-color:", ";border:", ";", ""], ({
|
|
36
|
+
checked,
|
|
37
|
+
status
|
|
38
|
+
}) => {
|
|
45
39
|
switch (status) {
|
|
46
40
|
case 'correct':
|
|
47
41
|
return designTokens.base.color.green9;
|
|
@@ -50,21 +44,23 @@ var StyledQuestionCheckboxInput = styled__default.default.input.withConfig({
|
|
|
50
44
|
default:
|
|
51
45
|
return checked ? designTokens.base.color.primary6 : 'transparent';
|
|
52
46
|
}
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
}, ({
|
|
48
|
+
checked,
|
|
49
|
+
status
|
|
50
|
+
}) => {
|
|
56
51
|
switch (status) {
|
|
57
52
|
case 'correct':
|
|
58
53
|
return designTokens.base.color.green9;
|
|
59
54
|
case 'wrong':
|
|
60
55
|
return designTokens.base.color.red9;
|
|
61
56
|
default:
|
|
62
|
-
return checked ? designTokens.base.color.primary6 :
|
|
57
|
+
return checked ? designTokens.base.color.primary6 : `1px solid ${designTokens.base.color.gray3}`;
|
|
63
58
|
}
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
59
|
+
}, ({
|
|
60
|
+
status,
|
|
61
|
+
checked
|
|
62
|
+
}) => {
|
|
63
|
+
let bgColor;
|
|
68
64
|
switch (status) {
|
|
69
65
|
case 'correct':
|
|
70
66
|
bgColor = designTokens.base.color.green9;
|
|
@@ -76,7 +72,7 @@ var StyledQuestionCheckboxInput = styled__default.default.input.withConfig({
|
|
|
76
72
|
bgColor = 'transparent';
|
|
77
73
|
break;
|
|
78
74
|
}
|
|
79
|
-
|
|
75
|
+
let borderColor;
|
|
80
76
|
switch (status) {
|
|
81
77
|
case 'correct':
|
|
82
78
|
borderColor = designTokens.base.color.green1;
|
|
@@ -88,46 +84,59 @@ var StyledQuestionCheckboxInput = styled__default.default.input.withConfig({
|
|
|
88
84
|
borderColor = checked ? designTokens.base.color.primary1 : status ? designTokens.base.color.navy5 : 'transparent';
|
|
89
85
|
break;
|
|
90
86
|
}
|
|
91
|
-
return
|
|
87
|
+
return `
|
|
88
|
+
&:after {
|
|
89
|
+
content: '';
|
|
90
|
+
position: absolute;
|
|
91
|
+
top: 50%;
|
|
92
|
+
left: 50%;
|
|
93
|
+
width: 3px;
|
|
94
|
+
height: 7px;
|
|
95
|
+
border: solid ${borderColor};
|
|
96
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
97
|
+
border-width: 0 2px 2px 0;
|
|
98
|
+
background-color: ${bgColor};
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
92
101
|
});
|
|
93
|
-
|
|
102
|
+
const StyledLabel = styled.label.withConfig({
|
|
94
103
|
componentId: "sc-1erloup-3"
|
|
95
104
|
})(["word-break:break-all;margin-right:0.875rem;font-size:", ";line-height:24px;", ""], designTokens.base.size.body3, getQuestionStatusStyle.getQuestionStatusStyle());
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
const QuestionCheckboxOption = React.memo(({
|
|
106
|
+
value,
|
|
107
|
+
status,
|
|
108
|
+
isAnswer,
|
|
109
|
+
children
|
|
110
|
+
}) => {
|
|
111
|
+
const {
|
|
112
|
+
selectedOptions,
|
|
113
|
+
disabled,
|
|
114
|
+
onSelect
|
|
115
|
+
} = QuestionCheckboxContext.useQuestionCheckboxContext();
|
|
116
|
+
const checked = selectedOptions.includes(value);
|
|
117
|
+
return React.createElement(StyledQuestionCheckboxOption, {
|
|
107
118
|
isAnswer: isAnswer,
|
|
108
119
|
disabled: disabled,
|
|
109
120
|
checked: checked,
|
|
110
|
-
onClick:
|
|
121
|
+
onClick: e => {
|
|
111
122
|
e.preventDefault();
|
|
112
123
|
if (disabled) {
|
|
113
124
|
return;
|
|
114
125
|
}
|
|
115
126
|
onSelect(value);
|
|
116
127
|
},
|
|
117
|
-
status: status
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
})]
|
|
130
|
-
});
|
|
128
|
+
status: status
|
|
129
|
+
}, React.createElement(StyledCustomCheckboxButton, null), React.createElement(StyledQuestionCheckboxInput, {
|
|
130
|
+
id: value,
|
|
131
|
+
readOnly: true,
|
|
132
|
+
type: "checkbox",
|
|
133
|
+
checked: checked,
|
|
134
|
+
status: status
|
|
135
|
+
}), React.createElement(StyledLabel, {
|
|
136
|
+
htmlFor: value,
|
|
137
|
+
checked: checked,
|
|
138
|
+
status: status
|
|
139
|
+
}, children));
|
|
131
140
|
});
|
|
132
141
|
|
|
133
142
|
exports.default = QuestionCheckboxOption;
|
|
@@ -3,25 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
7
|
var styled = require('styled-components');
|
|
8
8
|
var QuestionRadioContext = require('./QuestionRadioContext.js');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
13
|
-
|
|
14
|
-
var StyledQuestionRadio = styled__default.default.div.withConfig({
|
|
10
|
+
const StyledQuestionRadio = styled.div.withConfig({
|
|
15
11
|
componentId: "sc-s7wqiy-0"
|
|
16
12
|
})(["display:flex;flex-direction:column;"]);
|
|
17
|
-
|
|
18
|
-
var
|
|
13
|
+
const QuestionRadio = _a => {
|
|
14
|
+
var {
|
|
15
|
+
children
|
|
16
|
+
} = _a,
|
|
19
17
|
props = tslib.__rest(_a, ["children"]);
|
|
20
|
-
return
|
|
21
|
-
children: jsxRuntime.jsx(StyledQuestionRadio, {
|
|
22
|
-
children: children
|
|
23
|
-
})
|
|
24
|
-
}));
|
|
18
|
+
return React.createElement(QuestionRadioContext.QuestionRadioContextProvider, Object.assign({}, props), React.createElement(StyledQuestionRadio, null, children));
|
|
25
19
|
};
|
|
26
20
|
|
|
27
21
|
exports.default = QuestionRadio;
|
|
@@ -4,6 +4,6 @@ type Value = Pick<QuestionRadioProps, 'selectedValue' | 'disabled' | 'onSelect'>
|
|
|
4
4
|
interface QuestionRadioProviderProps extends QuestionRadioProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
-
declare function QuestionRadioContextProvider({ selectedValue, onSelect, disabled, children, }: QuestionRadioProviderProps): JSX.Element;
|
|
7
|
+
declare function QuestionRadioContextProvider({ selectedValue, onSelect, disabled, children, }: QuestionRadioProviderProps): React.JSX.Element;
|
|
8
8
|
declare function useQuestionRadioContext(): Value;
|
|
9
9
|
export { QuestionRadioContextProvider, useQuestionRadioContext };
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
3
|
var React = require('react');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
9
|
-
|
|
10
|
-
var QuestionRadioContext = React__default.default.createContext(undefined);
|
|
5
|
+
const QuestionRadioContext = React.createContext(undefined);
|
|
11
6
|
QuestionRadioContext.displayName = 'QuestionRadioContext';
|
|
12
|
-
function QuestionRadioContextProvider(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
function QuestionRadioContextProvider({
|
|
8
|
+
selectedValue,
|
|
9
|
+
onSelect,
|
|
10
|
+
disabled,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
17
13
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value: value,
|
|
28
|
-
children: children
|
|
29
|
-
});
|
|
14
|
+
const onSelectValue = React.useCallback(onSelect, []);
|
|
15
|
+
const value = React.useMemo(() => ({
|
|
16
|
+
selectedValue,
|
|
17
|
+
disabled,
|
|
18
|
+
onSelect: onSelectValue
|
|
19
|
+
}), [selectedValue, disabled, onSelectValue]);
|
|
20
|
+
return React.createElement(QuestionRadioContext.Provider, {
|
|
21
|
+
value: value
|
|
22
|
+
}, children);
|
|
30
23
|
}
|
|
31
24
|
function useQuestionRadioContext() {
|
|
32
|
-
|
|
25
|
+
const context = React.useContext(QuestionRadioContext);
|
|
33
26
|
if (context === undefined) {
|
|
34
27
|
throw new Error('useQuestionRadioContext must be used within a QuestionRadioContextProvider');
|
|
35
28
|
}
|