@elice/material-quiz 1.240718.0-trasncript.2 → 1.240718.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/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 { Icon, Text } from '@elice/blocks';
|
|
3
3
|
import { base } from '@elice/design-tokens';
|
|
4
4
|
import { eilDraggableVertical } from '@elice/icons';
|
|
@@ -7,23 +7,25 @@ import EbDraggable from '../eb-sortable/EbDraggable.js';
|
|
|
7
7
|
import { useMaterialQuizState } from '../material-quiz/context/MaterialQuizContext.js';
|
|
8
8
|
import StyledMarkdown from './StyledMarkdown.js';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const StyledQuizDraggbleOptionHandle = styled.div.withConfig({
|
|
11
11
|
componentId: "sc-19b0zkq-0"
|
|
12
12
|
})(["display:flex;align-items:center;justify-content:center;background-color:", ";width:1.5rem;flex:none;"], base.color.navy5);
|
|
13
|
-
|
|
13
|
+
const StyledQuizDraggbleOptionContent = styled.div.withConfig({
|
|
14
14
|
componentId: "sc-19b0zkq-1"
|
|
15
|
-
})(["display:flex;justify-content:space-between;min-width:0;align-items:center;flex:auto;padding:0.875rem 1rem;line-height:24px;border:", ";background-color:", ";"],
|
|
16
|
-
|
|
15
|
+
})(["display:flex;justify-content:space-between;min-width:0;align-items:center;flex:auto;padding:0.875rem 1rem;line-height:24px;border:", ";background-color:", ";"], ({
|
|
16
|
+
role
|
|
17
|
+
}) => {
|
|
17
18
|
switch (role) {
|
|
18
19
|
case 'correct':
|
|
19
|
-
return
|
|
20
|
+
return `1px solid ${base.color.primary6}`;
|
|
20
21
|
case 'wrong':
|
|
21
|
-
return
|
|
22
|
+
return `1px solid ${base.color.red6}`;
|
|
22
23
|
default:
|
|
23
24
|
return '';
|
|
24
25
|
}
|
|
25
|
-
},
|
|
26
|
-
|
|
26
|
+
}, ({
|
|
27
|
+
role
|
|
28
|
+
}) => {
|
|
27
29
|
switch (role) {
|
|
28
30
|
case 'answer':
|
|
29
31
|
return base.color.primary6;
|
|
@@ -31,13 +33,14 @@ var StyledQuizDraggbleOptionContent = styled.div.withConfig({
|
|
|
31
33
|
return '';
|
|
32
34
|
}
|
|
33
35
|
});
|
|
34
|
-
|
|
36
|
+
const StyledOrder = styled.div.withConfig({
|
|
35
37
|
componentId: "sc-19b0zkq-2"
|
|
36
38
|
})(["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;"], base.color.navy0, base.color.navy4);
|
|
37
|
-
|
|
39
|
+
const StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
38
40
|
componentId: "sc-19b0zkq-3"
|
|
39
|
-
})(["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);}"], base.color.navy4, base.color.navy5, StyledQuizDraggbleOptionHandle,
|
|
40
|
-
|
|
41
|
+
})(["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);}"], base.color.navy4, base.color.navy5, StyledQuizDraggbleOptionHandle, ({
|
|
42
|
+
role
|
|
43
|
+
}) => {
|
|
41
44
|
switch (role) {
|
|
42
45
|
case 'answer':
|
|
43
46
|
return base.color.primary4;
|
|
@@ -49,8 +52,9 @@ var StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
|
49
52
|
default:
|
|
50
53
|
return base.color.navy3;
|
|
51
54
|
}
|
|
52
|
-
},
|
|
53
|
-
|
|
55
|
+
}, ({
|
|
56
|
+
role
|
|
57
|
+
}) => {
|
|
54
58
|
switch (role) {
|
|
55
59
|
case 'answer':
|
|
56
60
|
return base.color.primary9;
|
|
@@ -62,8 +66,9 @@ var StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
|
62
66
|
default:
|
|
63
67
|
return base.color.navy5;
|
|
64
68
|
}
|
|
65
|
-
}, StyledQuizDraggbleOptionContent,
|
|
66
|
-
|
|
69
|
+
}, StyledQuizDraggbleOptionContent, ({
|
|
70
|
+
role
|
|
71
|
+
}) => {
|
|
67
72
|
switch (role) {
|
|
68
73
|
case 'answer':
|
|
69
74
|
return base.color.primary1;
|
|
@@ -75,8 +80,9 @@ var StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
|
75
80
|
default:
|
|
76
81
|
return base.color.navy5;
|
|
77
82
|
}
|
|
78
|
-
},
|
|
79
|
-
|
|
83
|
+
}, ({
|
|
84
|
+
role
|
|
85
|
+
}) => {
|
|
80
86
|
switch (role) {
|
|
81
87
|
case 'answer':
|
|
82
88
|
return base.color.primary9;
|
|
@@ -88,8 +94,9 @@ var StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
|
88
94
|
default:
|
|
89
95
|
return base.color.navy0;
|
|
90
96
|
}
|
|
91
|
-
}, StyledOrder,
|
|
92
|
-
|
|
97
|
+
}, StyledOrder, ({
|
|
98
|
+
role
|
|
99
|
+
}) => {
|
|
93
100
|
switch (role) {
|
|
94
101
|
case 'answer':
|
|
95
102
|
return base.color.primary3;
|
|
@@ -101,8 +108,9 @@ var StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
|
101
108
|
default:
|
|
102
109
|
return base.color.navy4;
|
|
103
110
|
}
|
|
104
|
-
},
|
|
105
|
-
|
|
111
|
+
}, ({
|
|
112
|
+
role
|
|
113
|
+
}) => {
|
|
106
114
|
switch (role) {
|
|
107
115
|
case 'answer':
|
|
108
116
|
return base.color.primary9;
|
|
@@ -115,49 +123,39 @@ var StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
|
115
123
|
return base.color.navy0;
|
|
116
124
|
}
|
|
117
125
|
}, base.color.navy0, StyledQuizDraggbleOptionHandle, base.color.navy5, StyledQuizDraggbleOptionContent, base.color.navy4, base.color.navy4, StyledOrder, base.color.navy0, base.color.navy5, base.color.navy0);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
vertical = _useMaterialQuizState.vertical;
|
|
133
|
-
return jsxs(StyledQuizDraggbleOption, {
|
|
126
|
+
const QuizDraggbleOption = ({
|
|
127
|
+
id,
|
|
128
|
+
className,
|
|
129
|
+
content,
|
|
130
|
+
disabled = false,
|
|
131
|
+
role = 'default',
|
|
132
|
+
indexOrder,
|
|
133
|
+
clone = false,
|
|
134
|
+
isMarkdown = false
|
|
135
|
+
}) => {
|
|
136
|
+
const {
|
|
137
|
+
vertical
|
|
138
|
+
} = useMaterialQuizState();
|
|
139
|
+
return React.createElement(StyledQuizDraggbleOption, {
|
|
134
140
|
id: id,
|
|
135
141
|
className: className,
|
|
136
142
|
disabled: disabled,
|
|
137
143
|
role: role,
|
|
138
144
|
clone: clone,
|
|
139
|
-
vertical: vertical
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
wordBreak: "break-all",
|
|
154
|
-
role: role === 'answer' ? 'white' : 'default',
|
|
155
|
-
children: content
|
|
156
|
-
}), indexOrder ? jsx(StyledOrder, {
|
|
157
|
-
children: indexOrder
|
|
158
|
-
}) : null]
|
|
159
|
-
})]
|
|
160
|
-
});
|
|
145
|
+
vertical: vertical
|
|
146
|
+
}, React.createElement(StyledQuizDraggbleOptionHandle, null, React.createElement(Icon, {
|
|
147
|
+
size: "large",
|
|
148
|
+
icon: eilDraggableVertical
|
|
149
|
+
})), React.createElement(StyledQuizDraggbleOptionContent, null, isMarkdown ? React.createElement(StyledMarkdown, {
|
|
150
|
+
children: content,
|
|
151
|
+
dark: true,
|
|
152
|
+
paddingx: 0,
|
|
153
|
+
paddingy: 0
|
|
154
|
+
}) : React.createElement(Text, {
|
|
155
|
+
userSelect: "none",
|
|
156
|
+
wordBreak: "break-all",
|
|
157
|
+
role: role === 'answer' ? 'white' : 'default'
|
|
158
|
+
}, content), indexOrder ? React.createElement(StyledOrder, null, indexOrder) : null));
|
|
161
159
|
};
|
|
162
160
|
|
|
163
161
|
export { QuizDraggbleOption as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Markdown } from '@elice/markdown';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const StyledMarkdown = styled(Markdown).withConfig({
|
|
5
5
|
componentId: "sc-l6r531-0"
|
|
6
6
|
})(["p{margin:0 !important;}code{white-space:pre-wrap;word-break:break-all;}"]);
|
|
7
7
|
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { QuestionCheckboxContextProvider } from './QuestionCheckboxContext.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const StyledQuestionCheckbox = styled.div.withConfig({
|
|
7
7
|
componentId: "sc-1jgy6x5-0"
|
|
8
8
|
})(["display:flex;flex-direction:column;"]);
|
|
9
|
-
|
|
10
|
-
var
|
|
9
|
+
const QuestionCheckbox = _a => {
|
|
10
|
+
var {
|
|
11
|
+
children
|
|
12
|
+
} = _a,
|
|
11
13
|
props = __rest(_a, ["children"]);
|
|
12
|
-
return
|
|
13
|
-
children: jsx(StyledQuestionCheckbox, {
|
|
14
|
-
children: children
|
|
15
|
-
})
|
|
16
|
-
}));
|
|
14
|
+
return React.createElement(QuestionCheckboxContextProvider, Object.assign({}, props), React.createElement(StyledQuestionCheckbox, null, children));
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
export { QuestionCheckbox as default };
|
|
@@ -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,29 +1,26 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const QuestionCheckboxContext = React.createContext(undefined);
|
|
5
4
|
QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
|
|
6
|
-
function QuestionCheckboxContextProvider(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function QuestionCheckboxContextProvider({
|
|
6
|
+
selectedOptions,
|
|
7
|
+
onSelect,
|
|
8
|
+
disabled,
|
|
9
|
+
children
|
|
10
|
+
}) {
|
|
11
11
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
value: value,
|
|
22
|
-
children: children
|
|
23
|
-
});
|
|
12
|
+
const onSelectValue = React.useCallback(onSelect, []);
|
|
13
|
+
const value = React.useMemo(() => ({
|
|
14
|
+
selectedOptions,
|
|
15
|
+
disabled,
|
|
16
|
+
onSelect: onSelectValue
|
|
17
|
+
}), [selectedOptions, disabled, onSelectValue]);
|
|
18
|
+
return React.createElement(QuestionCheckboxContext.Provider, {
|
|
19
|
+
value: value
|
|
20
|
+
}, children);
|
|
24
21
|
}
|
|
25
22
|
function useQuestionCheckboxContext() {
|
|
26
|
-
|
|
23
|
+
const context = React.useContext(QuestionCheckboxContext);
|
|
27
24
|
if (context === undefined) {
|
|
28
25
|
throw new Error('useQuestionCheckboxContext must be used within a QuestionCheckboxContextProvider');
|
|
29
26
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { base } from '@elice/design-tokens';
|
|
4
3
|
import styled from 'styled-components';
|
|
5
4
|
import { getQuestionStatusStyle } from '../utils/getQuestionStatusStyle.js';
|
|
6
5
|
import { useQuestionCheckboxContext } from './QuestionCheckboxContext.js';
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
const StyledQuestionCheckboxOption = styled.div.withConfig({
|
|
9
8
|
componentId: "sc-1erloup-0"
|
|
10
|
-
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""],
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
})(["display:flex;align-items:center;padding:0.875rem 1rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
|
|
10
|
+
checked,
|
|
11
|
+
status
|
|
12
|
+
}) => {
|
|
13
13
|
switch (status) {
|
|
14
14
|
case 'correct':
|
|
15
15
|
return base.color.green1;
|
|
@@ -18,21 +18,20 @@ var StyledQuestionCheckboxOption = styled.div.withConfig({
|
|
|
18
18
|
default:
|
|
19
19
|
return checked ? base.color.primary1 : base.color.navy6;
|
|
20
20
|
}
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
var StyledCustomCheckboxButton = styled.span.withConfig({
|
|
21
|
+
}, ({
|
|
22
|
+
disabled
|
|
23
|
+
}) => disabled ? 'not-allowed' : 'pointer', ({
|
|
24
|
+
isAnswer
|
|
25
|
+
}) => isAnswer ? `border: 3px solid ${base.color.green5}` : '');
|
|
26
|
+
const StyledCustomCheckboxButton = styled.span.withConfig({
|
|
29
27
|
componentId: "sc-1erloup-1"
|
|
30
28
|
})([""]);
|
|
31
|
-
|
|
29
|
+
const StyledQuestionCheckboxInput = styled.input.withConfig({
|
|
32
30
|
componentId: "sc-1erloup-2"
|
|
33
|
-
})(["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:", ";", ""],
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
})(["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:", ";", ""], ({
|
|
32
|
+
checked,
|
|
33
|
+
status
|
|
34
|
+
}) => {
|
|
36
35
|
switch (status) {
|
|
37
36
|
case 'correct':
|
|
38
37
|
return base.color.green9;
|
|
@@ -41,21 +40,23 @@ var StyledQuestionCheckboxInput = styled.input.withConfig({
|
|
|
41
40
|
default:
|
|
42
41
|
return checked ? base.color.primary6 : 'transparent';
|
|
43
42
|
}
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
}, ({
|
|
44
|
+
checked,
|
|
45
|
+
status
|
|
46
|
+
}) => {
|
|
47
47
|
switch (status) {
|
|
48
48
|
case 'correct':
|
|
49
49
|
return base.color.green9;
|
|
50
50
|
case 'wrong':
|
|
51
51
|
return base.color.red9;
|
|
52
52
|
default:
|
|
53
|
-
return checked ? base.color.primary6 :
|
|
53
|
+
return checked ? base.color.primary6 : `1px solid ${base.color.gray3}`;
|
|
54
54
|
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
}, ({
|
|
56
|
+
status,
|
|
57
|
+
checked
|
|
58
|
+
}) => {
|
|
59
|
+
let bgColor;
|
|
59
60
|
switch (status) {
|
|
60
61
|
case 'correct':
|
|
61
62
|
bgColor = base.color.green9;
|
|
@@ -67,7 +68,7 @@ var StyledQuestionCheckboxInput = styled.input.withConfig({
|
|
|
67
68
|
bgColor = 'transparent';
|
|
68
69
|
break;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
let borderColor;
|
|
71
72
|
switch (status) {
|
|
72
73
|
case 'correct':
|
|
73
74
|
borderColor = base.color.green1;
|
|
@@ -79,46 +80,59 @@ var StyledQuestionCheckboxInput = styled.input.withConfig({
|
|
|
79
80
|
borderColor = checked ? base.color.primary1 : status ? base.color.navy5 : 'transparent';
|
|
80
81
|
break;
|
|
81
82
|
}
|
|
82
|
-
return
|
|
83
|
+
return `
|
|
84
|
+
&:after {
|
|
85
|
+
content: '';
|
|
86
|
+
position: absolute;
|
|
87
|
+
top: 50%;
|
|
88
|
+
left: 50%;
|
|
89
|
+
width: 3px;
|
|
90
|
+
height: 7px;
|
|
91
|
+
border: solid ${borderColor};
|
|
92
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
93
|
+
border-width: 0 2px 2px 0;
|
|
94
|
+
background-color: ${bgColor};
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
83
97
|
});
|
|
84
|
-
|
|
98
|
+
const StyledLabel = styled.label.withConfig({
|
|
85
99
|
componentId: "sc-1erloup-3"
|
|
86
100
|
})(["word-break:break-all;margin-right:0.875rem;font-size:", ";line-height:24px;", ""], base.size.body3, getQuestionStatusStyle());
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
101
|
+
const QuestionCheckboxOption = React.memo(({
|
|
102
|
+
value,
|
|
103
|
+
status,
|
|
104
|
+
isAnswer,
|
|
105
|
+
children
|
|
106
|
+
}) => {
|
|
107
|
+
const {
|
|
108
|
+
selectedOptions,
|
|
109
|
+
disabled,
|
|
110
|
+
onSelect
|
|
111
|
+
} = useQuestionCheckboxContext();
|
|
112
|
+
const checked = selectedOptions.includes(value);
|
|
113
|
+
return React.createElement(StyledQuestionCheckboxOption, {
|
|
98
114
|
isAnswer: isAnswer,
|
|
99
115
|
disabled: disabled,
|
|
100
116
|
checked: checked,
|
|
101
|
-
onClick:
|
|
117
|
+
onClick: e => {
|
|
102
118
|
e.preventDefault();
|
|
103
119
|
if (disabled) {
|
|
104
120
|
return;
|
|
105
121
|
}
|
|
106
122
|
onSelect(value);
|
|
107
123
|
},
|
|
108
|
-
status: status
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})]
|
|
121
|
-
});
|
|
124
|
+
status: status
|
|
125
|
+
}, React.createElement(StyledCustomCheckboxButton, null), React.createElement(StyledQuestionCheckboxInput, {
|
|
126
|
+
id: value,
|
|
127
|
+
readOnly: true,
|
|
128
|
+
type: "checkbox",
|
|
129
|
+
checked: checked,
|
|
130
|
+
status: status
|
|
131
|
+
}), React.createElement(StyledLabel, {
|
|
132
|
+
htmlFor: value,
|
|
133
|
+
checked: checked,
|
|
134
|
+
status: status
|
|
135
|
+
}, children));
|
|
122
136
|
});
|
|
123
137
|
|
|
124
138
|
export { QuestionCheckboxOption as default };
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { QuestionRadioContextProvider } from './QuestionRadioContext.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const StyledQuestionRadio = styled.div.withConfig({
|
|
7
7
|
componentId: "sc-s7wqiy-0"
|
|
8
8
|
})(["display:flex;flex-direction:column;"]);
|
|
9
|
-
|
|
10
|
-
var
|
|
9
|
+
const QuestionRadio = _a => {
|
|
10
|
+
var {
|
|
11
|
+
children
|
|
12
|
+
} = _a,
|
|
11
13
|
props = __rest(_a, ["children"]);
|
|
12
|
-
return
|
|
13
|
-
children: jsx(StyledQuestionRadio, {
|
|
14
|
-
children: children
|
|
15
|
-
})
|
|
16
|
-
}));
|
|
14
|
+
return React.createElement(QuestionRadioContextProvider, Object.assign({}, props), React.createElement(StyledQuestionRadio, null, children));
|
|
17
15
|
};
|
|
18
16
|
|
|
19
17
|
export { QuestionRadio as default };
|
|
@@ -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,29 +1,26 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const QuestionRadioContext = React.createContext(undefined);
|
|
5
4
|
QuestionRadioContext.displayName = 'QuestionRadioContext';
|
|
6
|
-
function QuestionRadioContextProvider(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function QuestionRadioContextProvider({
|
|
6
|
+
selectedValue,
|
|
7
|
+
onSelect,
|
|
8
|
+
disabled,
|
|
9
|
+
children
|
|
10
|
+
}) {
|
|
11
11
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
value: value,
|
|
22
|
-
children: children
|
|
23
|
-
});
|
|
12
|
+
const onSelectValue = React.useCallback(onSelect, []);
|
|
13
|
+
const value = React.useMemo(() => ({
|
|
14
|
+
selectedValue,
|
|
15
|
+
disabled,
|
|
16
|
+
onSelect: onSelectValue
|
|
17
|
+
}), [selectedValue, disabled, onSelectValue]);
|
|
18
|
+
return React.createElement(QuestionRadioContext.Provider, {
|
|
19
|
+
value: value
|
|
20
|
+
}, children);
|
|
24
21
|
}
|
|
25
22
|
function useQuestionRadioContext() {
|
|
26
|
-
|
|
23
|
+
const context = React.useContext(QuestionRadioContext);
|
|
27
24
|
if (context === undefined) {
|
|
28
25
|
throw new Error('useQuestionRadioContext must be used within a QuestionRadioContextProvider');
|
|
29
26
|
}
|