@elice/material-quiz 1.220803.0
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/README.md +3 -0
- package/cjs/components/eb-sortable/EbDraggable.d.ts +18 -0
- package/cjs/components/eb-sortable/EbDraggable.js +112 -0
- package/cjs/components/eb-sortable/EbDroppable.d.ts +13 -0
- package/cjs/components/eb-sortable/EbDroppable.js +60 -0
- package/cjs/components/eb-sortable/EbSortable.d.ts +17 -0
- package/cjs/components/material-quiz/MaterialQuiz.d.ts +4 -0
- package/cjs/components/material-quiz/MaterialQuiz.i18n.d.ts +25 -0
- package/cjs/components/material-quiz/MaterialQuiz.i18n.js +55 -0
- package/cjs/components/material-quiz/MaterialQuiz.js +114 -0
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +55 -0
- package/cjs/components/material-quiz/MaterialQuizError.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizInfo.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizInfo.js +74 -0
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +203 -0
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +468 -0
- package/cjs/components/material-quiz/MaterialQuizSelectOne.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizSelectOne.js +191 -0
- package/cjs/components/material-quiz/MaterialQuizShimmer.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizShimmer.js +61 -0
- package/cjs/components/material-quiz/MaterialQuizText.d.ts +3 -0
- package/cjs/components/material-quiz/MaterialQuizText.js +181 -0
- package/cjs/components/material-quiz/QuizResultBadge.d.ts +7 -0
- package/cjs/components/material-quiz/QuizResultBadge.js +48 -0
- package/cjs/components/material-quiz/QuizSubmitStatusText.d.ts +7 -0
- package/cjs/components/material-quiz/QuizSubmitStatusText.js +38 -0
- package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +31 -0
- package/cjs/components/material-quiz/context/MaterialQuizContext.js +134 -0
- package/cjs/components/material-quiz/index.d.ts +3 -0
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.d.ts +25 -0
- package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +91 -0
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.d.ts +3 -0
- package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +463 -0
- package/cjs/components/material-quiz-edit/context.d.ts +6 -0
- package/cjs/components/material-quiz-edit/context.js +15 -0
- package/cjs/components/material-quiz-edit/index.d.ts +2 -0
- package/cjs/components/material-quiz-edit/locales.d.ts +34 -0
- package/cjs/components/material-quiz-edit/locales.js +73 -0
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.d.ts +3 -0
- package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +204 -0
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.d.ts +3 -0
- package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +205 -0
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.d.ts +3 -0
- package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +207 -0
- package/cjs/components/material-quiz-edit/options/OptionText.d.ts +3 -0
- package/cjs/components/material-quiz-edit/options/OptionText.js +99 -0
- package/cjs/components/material-quiz-edit/utils/editValue.d.ts +15 -0
- package/cjs/components/material-quiz-edit/utils/editValue.js +37 -0
- package/cjs/components/material-quiz-edit/utils/randomId.d.ts +4 -0
- package/cjs/components/material-quiz-edit/utils/randomId.js +12 -0
- package/cjs/components/shared/QuestionBox.d.ts +16 -0
- package/cjs/components/shared/QuestionBox.js +111 -0
- package/cjs/components/shared/QuizDraggbleDroppedOption.d.ts +12 -0
- package/cjs/components/shared/QuizDraggbleDroppedOption.js +31 -0
- package/cjs/components/shared/QuizDraggbleDummyOption.d.ts +8 -0
- package/cjs/components/shared/QuizDraggbleDummyOption.js +36 -0
- package/cjs/components/shared/QuizDraggbleOption.d.ts +14 -0
- package/cjs/components/shared/QuizDraggbleOption.js +191 -0
- package/cjs/components/shared/StyledMarkdown.d.ts +3 -0
- package/cjs/components/shared/StyledMarkdown.js +14 -0
- package/cjs/components/shared/index.d.ts +7 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +26 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +42 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +188 -0
- package/cjs/components/shared/question-radio/QuestionRadio.d.ts +8 -0
- package/cjs/components/shared/question-radio/QuestionRadio.js +26 -0
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +42 -0
- package/cjs/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +156 -0
- package/cjs/helpers/index.d.ts +50 -0
- package/cjs/helpers/index.js +86 -0
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +27 -0
- package/es/components/eb-sortable/EbDraggable.d.ts +18 -0
- package/es/components/eb-sortable/EbDraggable.js +105 -0
- package/es/components/eb-sortable/EbDroppable.d.ts +13 -0
- package/es/components/eb-sortable/EbDroppable.js +53 -0
- package/es/components/eb-sortable/EbSortable.d.ts +17 -0
- package/es/components/material-quiz/MaterialQuiz.d.ts +4 -0
- package/es/components/material-quiz/MaterialQuiz.i18n.d.ts +25 -0
- package/es/components/material-quiz/MaterialQuiz.i18n.js +50 -0
- package/es/components/material-quiz/MaterialQuiz.js +106 -0
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +48 -0
- package/es/components/material-quiz/MaterialQuizError.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizInfo.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizInfo.js +68 -0
- package/es/components/material-quiz/MaterialQuizSelectMultiple.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizSelectMultiple.js +197 -0
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +461 -0
- package/es/components/material-quiz/MaterialQuizSelectOne.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizSelectOne.js +185 -0
- package/es/components/material-quiz/MaterialQuizShimmer.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizShimmer.js +54 -0
- package/es/components/material-quiz/MaterialQuizText.d.ts +3 -0
- package/es/components/material-quiz/MaterialQuizText.js +174 -0
- package/es/components/material-quiz/QuizResultBadge.d.ts +7 -0
- package/es/components/material-quiz/QuizResultBadge.js +42 -0
- package/es/components/material-quiz/QuizSubmitStatusText.d.ts +7 -0
- package/es/components/material-quiz/QuizSubmitStatusText.js +32 -0
- package/es/components/material-quiz/context/MaterialQuizContext.d.ts +31 -0
- package/es/components/material-quiz/context/MaterialQuizContext.js +124 -0
- package/es/components/material-quiz/index.d.ts +3 -0
- package/es/components/material-quiz-edit/MaterialQuizEdit.d.ts +25 -0
- package/es/components/material-quiz-edit/MaterialQuizEdit.js +86 -0
- package/es/components/material-quiz-edit/MaterialQuizEditContent.d.ts +3 -0
- package/es/components/material-quiz-edit/MaterialQuizEditContent.js +456 -0
- package/es/components/material-quiz-edit/context.d.ts +6 -0
- package/es/components/material-quiz-edit/context.js +6 -0
- package/es/components/material-quiz-edit/index.d.ts +2 -0
- package/es/components/material-quiz-edit/locales.d.ts +34 -0
- package/es/components/material-quiz-edit/locales.js +68 -0
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.d.ts +3 -0
- package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +197 -0
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.d.ts +3 -0
- package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +198 -0
- package/es/components/material-quiz-edit/options/OptionSelectOne.d.ts +3 -0
- package/es/components/material-quiz-edit/options/OptionSelectOne.js +200 -0
- package/es/components/material-quiz-edit/options/OptionText.d.ts +3 -0
- package/es/components/material-quiz-edit/options/OptionText.js +93 -0
- package/es/components/material-quiz-edit/utils/editValue.d.ts +15 -0
- package/es/components/material-quiz-edit/utils/editValue.js +32 -0
- package/es/components/material-quiz-edit/utils/randomId.d.ts +4 -0
- package/es/components/material-quiz-edit/utils/randomId.js +8 -0
- package/es/components/shared/QuestionBox.d.ts +16 -0
- package/es/components/shared/QuestionBox.js +101 -0
- package/es/components/shared/QuizDraggbleDroppedOption.d.ts +12 -0
- package/es/components/shared/QuizDraggbleDroppedOption.js +25 -0
- package/es/components/shared/QuizDraggbleDummyOption.d.ts +8 -0
- package/es/components/shared/QuizDraggbleDummyOption.js +29 -0
- package/es/components/shared/QuizDraggbleOption.d.ts +14 -0
- package/es/components/shared/QuizDraggbleOption.js +184 -0
- package/es/components/shared/StyledMarkdown.d.ts +3 -0
- package/es/components/shared/StyledMarkdown.js +8 -0
- package/es/components/shared/index.d.ts +7 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +19 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +33 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +181 -0
- package/es/components/shared/question-radio/QuestionRadio.d.ts +8 -0
- package/es/components/shared/question-radio/QuestionRadio.js +19 -0
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
- package/es/components/shared/question-radio/QuestionRadioContext.js +33 -0
- package/es/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
- package/es/components/shared/question-radio/QuestionRadioOption.js +149 -0
- package/es/helpers/index.d.ts +50 -0
- package/es/helpers/index.js +78 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +10 -0
- package/package.json +75 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useFormContext, Controller } from 'react-hook-form';
|
|
3
|
+
import { useIntl, FormattedMessage } from 'react-intl';
|
|
4
|
+
import { Input, Vspace, Checkbox } from '@elice/blocks';
|
|
5
|
+
import { useMaterialQuizEditContext } from '../context.js';
|
|
6
|
+
|
|
7
|
+
const MIN_TEXT_LENGTH = 1;
|
|
8
|
+
const MAX_TEXT_LENGTH = 128;
|
|
9
|
+
|
|
10
|
+
const OptionText = () => {
|
|
11
|
+
const intl = useIntl();
|
|
12
|
+
const {
|
|
13
|
+
disabled
|
|
14
|
+
} = useMaterialQuizEditContext();
|
|
15
|
+
const {
|
|
16
|
+
control,
|
|
17
|
+
watch
|
|
18
|
+
} = useFormContext();
|
|
19
|
+
const watchedIsAutoGrade = watch('isAutoGrade'); //
|
|
20
|
+
//
|
|
21
|
+
//
|
|
22
|
+
|
|
23
|
+
return React.createElement(React.Fragment, null, React.createElement(Controller, {
|
|
24
|
+
control: control,
|
|
25
|
+
name: "answerInfo",
|
|
26
|
+
rules: {
|
|
27
|
+
required: {
|
|
28
|
+
value: watchedIsAutoGrade,
|
|
29
|
+
message: intl.formatMessage({
|
|
30
|
+
id: 'option.text.answerInfo.errorMessage.required'
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
minLength: {
|
|
34
|
+
value: MIN_TEXT_LENGTH,
|
|
35
|
+
message: intl.formatMessage({
|
|
36
|
+
id: 'common.errorMessage.range'
|
|
37
|
+
}, {
|
|
38
|
+
min: MIN_TEXT_LENGTH,
|
|
39
|
+
max: MAX_TEXT_LENGTH
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
maxLength: {
|
|
43
|
+
value: MAX_TEXT_LENGTH,
|
|
44
|
+
message: intl.formatMessage({
|
|
45
|
+
id: 'common.errorMessage.range'
|
|
46
|
+
}, {
|
|
47
|
+
min: MIN_TEXT_LENGTH,
|
|
48
|
+
max: MAX_TEXT_LENGTH
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
render: ({
|
|
53
|
+
field,
|
|
54
|
+
fieldState
|
|
55
|
+
}) => {
|
|
56
|
+
var _a;
|
|
57
|
+
|
|
58
|
+
return React.createElement(Input, Object.assign({
|
|
59
|
+
size: "small",
|
|
60
|
+
width: "full",
|
|
61
|
+
minLength: MIN_TEXT_LENGTH,
|
|
62
|
+
maxLength: MAX_TEXT_LENGTH,
|
|
63
|
+
readOnly: disabled,
|
|
64
|
+
disabled: !watchedIsAutoGrade,
|
|
65
|
+
invalid: fieldState.invalid,
|
|
66
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
|
|
67
|
+
helpText: intl.formatMessage({
|
|
68
|
+
id: 'option.text.answerInfo.hintText'
|
|
69
|
+
})
|
|
70
|
+
}, field, {
|
|
71
|
+
value: field.value
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
}), React.createElement(Vspace, {
|
|
75
|
+
height: 0.5
|
|
76
|
+
}), React.createElement(Controller, {
|
|
77
|
+
control: control,
|
|
78
|
+
name: "isAutoGrade",
|
|
79
|
+
render: ({
|
|
80
|
+
field
|
|
81
|
+
}) => React.createElement(Checkbox, Object.assign({
|
|
82
|
+
size: "small"
|
|
83
|
+
}, field, {
|
|
84
|
+
value: !field.value,
|
|
85
|
+
checked: !field.value,
|
|
86
|
+
onChange: v => field.onChange(!v)
|
|
87
|
+
}), React.createElement(FormattedMessage, {
|
|
88
|
+
id: "option.text.isAutoGrade.checkbox.label"
|
|
89
|
+
}))
|
|
90
|
+
}));
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export { OptionText as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MaterialQuizEditValue } from '../MaterialQuizEdit';
|
|
2
|
+
export declare type _QuizEditValue = Omit<MaterialQuizEditValue, 'optionInfo'> & {
|
|
3
|
+
optionInfo: {
|
|
4
|
+
id: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function manipulateValue(v: MaterialQuizEditValue): _QuizEditValue;
|
|
12
|
+
/**
|
|
13
|
+
* Restore manipulation from `manipulateValue()`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function restoreValue(v: _QuizEditValue): MaterialQuizEditValue;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createRandomId } from './randomId.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
function manipulateValue(v) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
|
|
10
|
+
return Object.assign(Object.assign({}, v), {
|
|
11
|
+
// convert string array to object array
|
|
12
|
+
// - ref: https://github.com/react-hook-form/react-hook-form/issues/7622#issuecomment-1018893318
|
|
13
|
+
optionInfo: Array.isArray(v.optionInfo) ? v.optionInfo.map(option => ({
|
|
14
|
+
id: createRandomId(),
|
|
15
|
+
value: option
|
|
16
|
+
})) : [],
|
|
17
|
+
// remove `"` mark around value
|
|
18
|
+
answerInfo: typeof v.answerInfo === 'string' ? (_b = (_a = /^"?([^"]*)"?$/.exec(v.answerInfo)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '' : v.answerInfo
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Restore manipulation from `manipulateValue()`.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
function restoreValue(v) {
|
|
26
|
+
return Object.assign(Object.assign({}, v), {
|
|
27
|
+
optionInfo: v.optionInfo.length ? v.optionInfo.map(option => option.value) : null,
|
|
28
|
+
answerInfo: Array.isArray(v.answerInfo) ? v.answerInfo : typeof v.answerInfo === 'object' || typeof v.answerInfo === 'undefined' ? undefined : `"${v.answerInfo}"`
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { manipulateValue, restoreValue };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ButtonProps } from '@elice/blocks';
|
|
3
|
+
interface QuestionBoxProps {
|
|
4
|
+
footerActions?: ButtonProps[];
|
|
5
|
+
title?: string;
|
|
6
|
+
submitResult?: React.ReactNode;
|
|
7
|
+
submitStatus?: React.ReactNode;
|
|
8
|
+
onNext?: () => void;
|
|
9
|
+
isNextActive?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const StyledQuestionBox: import("styled-components").StyledComponent<"div", any, {
|
|
12
|
+
vertical: boolean;
|
|
13
|
+
hasFooter: boolean;
|
|
14
|
+
}, never>;
|
|
15
|
+
declare const QuestionBox: React.FC<QuestionBoxProps>;
|
|
16
|
+
export default QuestionBox;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { Text, Button, Box } from '@elice/blocks';
|
|
5
|
+
import { base } from '@elice/design-tokens';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import { useMaterialQuizState } from '../material-quiz/context/MaterialQuizContext.js';
|
|
8
|
+
|
|
9
|
+
const StyledQuestionBox = styled.div.withConfig({
|
|
10
|
+
componentId: "sc-6qfyxj-0"
|
|
11
|
+
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;max-height:", ";min-height:", ";"], ({
|
|
12
|
+
vertical
|
|
13
|
+
}) => vertical ? '0' : '8px', ({
|
|
14
|
+
hasFooter
|
|
15
|
+
}) => hasFooter ? '100%' : '', ({
|
|
16
|
+
hasFooter
|
|
17
|
+
}) => hasFooter ? '' : '100%');
|
|
18
|
+
const StyledQuestionBoxHeader = styled.div.withConfig({
|
|
19
|
+
componentId: "sc-6qfyxj-1"
|
|
20
|
+
})(["display:flex;justify-content:space-between;background-color:", ";padding:1rem 1.5rem;flex:none;height:3.5rem;"], base.color.navy6);
|
|
21
|
+
const StyledQuestionBoxBody = styled.div.withConfig({
|
|
22
|
+
componentId: "sc-6qfyxj-2"
|
|
23
|
+
})(["padding:1.5rem;background-color:", ";flex:auto;", ""], base.color.navy7, ({
|
|
24
|
+
hasFooter
|
|
25
|
+
}) => hasFooter ? 'height: 100%; overflow-y: auto;' : '');
|
|
26
|
+
const StyledQuestionBoxFooter = styled.div.withConfig({
|
|
27
|
+
componentId: "sc-6qfyxj-3"
|
|
28
|
+
})(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], base.color.navy6, ({
|
|
29
|
+
vertical
|
|
30
|
+
}) => {
|
|
31
|
+
return vertical ? `
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
align-items: flex-start;
|
|
34
|
+
` : '';
|
|
35
|
+
});
|
|
36
|
+
const StyledQuestionBoxFooterActions = styled.div.withConfig({
|
|
37
|
+
componentId: "sc-6qfyxj-4"
|
|
38
|
+
})(["display:flex;"]);
|
|
39
|
+
const StyledQuestionBoxFooterStatus = styled.div.withConfig({
|
|
40
|
+
componentId: "sc-6qfyxj-5"
|
|
41
|
+
})(["margin-left:0.75rem;", ""], ({
|
|
42
|
+
vertical
|
|
43
|
+
}) => {
|
|
44
|
+
return vertical ? `
|
|
45
|
+
margin-left: 0;
|
|
46
|
+
margin-top: 0.75rem;
|
|
47
|
+
` : '';
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const QuestionBox = _a => {
|
|
51
|
+
var {
|
|
52
|
+
children,
|
|
53
|
+
footerActions = [],
|
|
54
|
+
title,
|
|
55
|
+
submitResult,
|
|
56
|
+
submitStatus,
|
|
57
|
+
onNext,
|
|
58
|
+
isNextActive
|
|
59
|
+
} = _a,
|
|
60
|
+
props = __rest(_a, ["children", "footerActions", "title", "submitResult", "submitStatus", "onNext", "isNextActive"]);
|
|
61
|
+
|
|
62
|
+
const intl = useIntl();
|
|
63
|
+
const {
|
|
64
|
+
vertical
|
|
65
|
+
} = useMaterialQuizState();
|
|
66
|
+
const hasFooter = footerActions.length > 0;
|
|
67
|
+
const header = React.createElement(StyledQuestionBoxHeader, null, React.createElement(Text, {
|
|
68
|
+
bold: true,
|
|
69
|
+
customStyles: {
|
|
70
|
+
color: base.color.navy0
|
|
71
|
+
}
|
|
72
|
+
}, title || ' '), submitResult ? submitResult : null);
|
|
73
|
+
const body = React.createElement(StyledQuestionBoxBody, {
|
|
74
|
+
hasFooter: hasFooter
|
|
75
|
+
}, children);
|
|
76
|
+
const footer = React.createElement(StyledQuestionBoxFooter, {
|
|
77
|
+
vertical: vertical
|
|
78
|
+
}, React.createElement(StyledQuestionBoxFooterActions, null, footerActions.map((action, index) => React.createElement(Button, Object.assign({
|
|
79
|
+
key: index,
|
|
80
|
+
size: "small"
|
|
81
|
+
}, action), action.children)), isNextActive ? React.createElement(Box, {
|
|
82
|
+
marginleft: "0.75rem"
|
|
83
|
+
}, React.createElement(Button, {
|
|
84
|
+
size: "small",
|
|
85
|
+
border: true,
|
|
86
|
+
tabIndex: 0,
|
|
87
|
+
transparent: false,
|
|
88
|
+
role: "lightpurple",
|
|
89
|
+
onClick: onNext
|
|
90
|
+
}, intl.formatMessage({
|
|
91
|
+
id: 'materialQuiz.next'
|
|
92
|
+
}))) : null), React.createElement(StyledQuestionBoxFooterStatus, {
|
|
93
|
+
vertical: vertical
|
|
94
|
+
}, submitStatus));
|
|
95
|
+
return React.createElement(StyledQuestionBox, Object.assign({}, props, {
|
|
96
|
+
hasFooter: hasFooter,
|
|
97
|
+
vertical: vertical
|
|
98
|
+
}), header, body, footerActions.length > 0 ? footer : null);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { StyledQuestionBox, QuestionBox as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuizDraggbleOptionRole } from './QuizDraggbleOption';
|
|
3
|
+
interface QuizDraggbleDroppedOptionProps {
|
|
4
|
+
id: string;
|
|
5
|
+
content: string;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
role: QuizDraggbleOptionRole;
|
|
8
|
+
indexOrder?: number;
|
|
9
|
+
isMarkdown?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const QuizDraggbleDroppedOption: React.FC<QuizDraggbleDroppedOptionProps>;
|
|
12
|
+
export default QuizDraggbleDroppedOption;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import QuizDraggbleOption from './QuizDraggbleOption.js';
|
|
3
|
+
|
|
4
|
+
const QuizDraggbleDroppedOption = ({
|
|
5
|
+
id,
|
|
6
|
+
content,
|
|
7
|
+
disabled = false,
|
|
8
|
+
role,
|
|
9
|
+
indexOrder,
|
|
10
|
+
isMarkdown
|
|
11
|
+
}) => {
|
|
12
|
+
return React.createElement(QuizDraggbleOption, {
|
|
13
|
+
id: id,
|
|
14
|
+
key: id,
|
|
15
|
+
content: content,
|
|
16
|
+
className: "quiz-answer",
|
|
17
|
+
disabled: disabled,
|
|
18
|
+
role: role,
|
|
19
|
+
indexOrder: indexOrder,
|
|
20
|
+
clone: true,
|
|
21
|
+
isMarkdown: isMarkdown
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { QuizDraggbleDroppedOption as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { EbDroppableProps } from '../eb-sortable/EbDroppable';
|
|
3
|
+
interface QuizDraggbleDummyOptionProps {
|
|
4
|
+
indexOrder: number;
|
|
5
|
+
onDrop: EbDroppableProps['onDrop'];
|
|
6
|
+
}
|
|
7
|
+
declare const QuizDraggbleDummyOption: React.FC<QuizDraggbleDummyOptionProps>;
|
|
8
|
+
export default QuizDraggbleDummyOption;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from '@elice/blocks';
|
|
3
|
+
import { base } from '@elice/design-tokens';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import EbDroppable from '../eb-sortable/EbDroppable.js';
|
|
6
|
+
|
|
7
|
+
const StyledQuizDraggbleDummyOption = styled(EbDroppable).withConfig({
|
|
8
|
+
componentId: "sc-1ayp8c1-0"
|
|
9
|
+
})(["display:flex;justify-content:space-between;align-items:center;border:1px dashed ", ";border-radius:8px;overflow:hidden;background-color:", ";padding:0.875rem;color:", ";font-size:0.875rem;&.ui-droppable-hover{outline:1px dashed ", ";}"], base.color.navy4, base.color.navy5, base.color.navy0, base.color.navy0);
|
|
10
|
+
const StyledOrder = styled.div.withConfig({
|
|
11
|
+
componentId: "sc-1ayp8c1-1"
|
|
12
|
+
})(["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);
|
|
13
|
+
|
|
14
|
+
const QuizDraggbleDummyOption = ({
|
|
15
|
+
indexOrder,
|
|
16
|
+
onDrop
|
|
17
|
+
}) => {
|
|
18
|
+
return React.createElement(StyledQuizDraggbleDummyOption, {
|
|
19
|
+
onDrop: onDrop
|
|
20
|
+
}, React.createElement(Text, {
|
|
21
|
+
size: "small",
|
|
22
|
+
wordBreak: "break-all",
|
|
23
|
+
customStyles: {
|
|
24
|
+
color: base.color.navy0
|
|
25
|
+
}
|
|
26
|
+
}, '답안을 드래그 앤 드롭하세요.'), React.createElement(StyledOrder, null, indexOrder));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { QuizDraggbleDummyOption as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type QuizDraggbleOptionRole = 'default' | 'correct' | 'wrong' | 'answer';
|
|
3
|
+
export interface QuizDraggbleOptionProps {
|
|
4
|
+
id: string;
|
|
5
|
+
className: string;
|
|
6
|
+
content: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
role?: QuizDraggbleOptionRole;
|
|
9
|
+
indexOrder?: number;
|
|
10
|
+
clone?: boolean;
|
|
11
|
+
isMarkdown?: boolean;
|
|
12
|
+
}
|
|
13
|
+
declare const QuizDraggbleOption: React.FC<QuizDraggbleOptionProps>;
|
|
14
|
+
export default QuizDraggbleOption;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, Text } from '@elice/blocks';
|
|
3
|
+
import { base } from '@elice/design-tokens';
|
|
4
|
+
import { eilDraggableVertical } from '@elice/icons';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import EbDraggable from '../eb-sortable/EbDraggable.js';
|
|
7
|
+
import { useMaterialQuizState } from '../material-quiz/context/MaterialQuizContext.js';
|
|
8
|
+
import StyledMarkdown from './StyledMarkdown.js';
|
|
9
|
+
|
|
10
|
+
const StyledQuizDraggbleOptionHandle = styled.div.withConfig({
|
|
11
|
+
componentId: "sc-19b0zkq-0"
|
|
12
|
+
})(["display:flex;align-items:center;justify-content:center;background-color:", ";width:1.5rem;flex:none;"], base.color.navy3);
|
|
13
|
+
const StyledQuizDraggbleOptionContent = styled.div.withConfig({
|
|
14
|
+
componentId: "sc-19b0zkq-1"
|
|
15
|
+
})(["display:flex;justify-content:space-between;min-width:0;align-items:center;flex:auto;padding:0.875rem;border:", ";background-color:", ";"], ({
|
|
16
|
+
role
|
|
17
|
+
}) => {
|
|
18
|
+
switch (role) {
|
|
19
|
+
case 'correct':
|
|
20
|
+
return `1px solid ${base.color.primary6}`;
|
|
21
|
+
|
|
22
|
+
case 'wrong':
|
|
23
|
+
return `1px solid ${base.color.red6}`;
|
|
24
|
+
|
|
25
|
+
default:
|
|
26
|
+
return '';
|
|
27
|
+
}
|
|
28
|
+
}, ({
|
|
29
|
+
role
|
|
30
|
+
}) => {
|
|
31
|
+
switch (role) {
|
|
32
|
+
case 'answer':
|
|
33
|
+
return base.color.primary6;
|
|
34
|
+
|
|
35
|
+
default:
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const StyledOrder = styled.div.withConfig({
|
|
40
|
+
componentId: "sc-19b0zkq-2"
|
|
41
|
+
})(["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);
|
|
42
|
+
const StyledQuizDraggbleOption = styled(EbDraggable).withConfig({
|
|
43
|
+
componentId: "sc-19b0zkq-3"
|
|
44
|
+
})(["display:flex;border-radius:8px;border:1px solid ", ";background-color:", ";overflow:hidden;z-index:999 !important;", "{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, ({
|
|
45
|
+
role
|
|
46
|
+
}) => {
|
|
47
|
+
switch (role) {
|
|
48
|
+
case 'answer':
|
|
49
|
+
return base.color.primary4;
|
|
50
|
+
// todos
|
|
51
|
+
|
|
52
|
+
case 'correct':
|
|
53
|
+
return base.color.green4;
|
|
54
|
+
|
|
55
|
+
case 'wrong':
|
|
56
|
+
return base.color.red4;
|
|
57
|
+
|
|
58
|
+
default:
|
|
59
|
+
return base.color.navy3;
|
|
60
|
+
}
|
|
61
|
+
}, ({
|
|
62
|
+
role
|
|
63
|
+
}) => {
|
|
64
|
+
switch (role) {
|
|
65
|
+
case 'answer':
|
|
66
|
+
return base.color.primary9;
|
|
67
|
+
// todos
|
|
68
|
+
|
|
69
|
+
case 'correct':
|
|
70
|
+
return base.color.green9;
|
|
71
|
+
|
|
72
|
+
case 'wrong':
|
|
73
|
+
return base.color.red9;
|
|
74
|
+
|
|
75
|
+
default:
|
|
76
|
+
return base.color.navy5;
|
|
77
|
+
}
|
|
78
|
+
}, StyledQuizDraggbleOptionContent, ({
|
|
79
|
+
role
|
|
80
|
+
}) => {
|
|
81
|
+
switch (role) {
|
|
82
|
+
case 'answer':
|
|
83
|
+
return base.color.primary1;
|
|
84
|
+
// todos
|
|
85
|
+
|
|
86
|
+
case 'correct':
|
|
87
|
+
return base.color.green1;
|
|
88
|
+
|
|
89
|
+
case 'wrong':
|
|
90
|
+
return base.color.red1;
|
|
91
|
+
|
|
92
|
+
default:
|
|
93
|
+
return base.color.navy5;
|
|
94
|
+
}
|
|
95
|
+
}, ({
|
|
96
|
+
role
|
|
97
|
+
}) => {
|
|
98
|
+
switch (role) {
|
|
99
|
+
case 'answer':
|
|
100
|
+
return base.color.primary9;
|
|
101
|
+
// todos
|
|
102
|
+
|
|
103
|
+
case 'correct':
|
|
104
|
+
return base.color.green9;
|
|
105
|
+
|
|
106
|
+
case 'wrong':
|
|
107
|
+
return base.color.red9;
|
|
108
|
+
|
|
109
|
+
default:
|
|
110
|
+
return base.color.navy0;
|
|
111
|
+
}
|
|
112
|
+
}, StyledOrder, ({
|
|
113
|
+
role
|
|
114
|
+
}) => {
|
|
115
|
+
switch (role) {
|
|
116
|
+
case 'answer':
|
|
117
|
+
return base.color.primary3;
|
|
118
|
+
// todos
|
|
119
|
+
|
|
120
|
+
case 'correct':
|
|
121
|
+
return base.color.green3;
|
|
122
|
+
|
|
123
|
+
case 'wrong':
|
|
124
|
+
return base.color.red3;
|
|
125
|
+
|
|
126
|
+
default:
|
|
127
|
+
return base.color.navy4;
|
|
128
|
+
}
|
|
129
|
+
}, ({
|
|
130
|
+
role
|
|
131
|
+
}) => {
|
|
132
|
+
switch (role) {
|
|
133
|
+
case 'answer':
|
|
134
|
+
return base.color.primary9;
|
|
135
|
+
// todos
|
|
136
|
+
|
|
137
|
+
case 'correct':
|
|
138
|
+
return base.color.green9;
|
|
139
|
+
|
|
140
|
+
case 'wrong':
|
|
141
|
+
return base.color.red9;
|
|
142
|
+
|
|
143
|
+
default:
|
|
144
|
+
return base.color.navy0;
|
|
145
|
+
}
|
|
146
|
+
}, base.color.navy0, StyledQuizDraggbleOptionHandle, base.color.navy5, StyledQuizDraggbleOptionContent, base.color.navy4, base.color.navy4, StyledOrder, base.color.navy0, base.color.navy5, base.color.navy0);
|
|
147
|
+
|
|
148
|
+
const QuizDraggbleOption = ({
|
|
149
|
+
id,
|
|
150
|
+
className,
|
|
151
|
+
content,
|
|
152
|
+
disabled = false,
|
|
153
|
+
role = 'default',
|
|
154
|
+
indexOrder,
|
|
155
|
+
clone = false,
|
|
156
|
+
isMarkdown = false
|
|
157
|
+
}) => {
|
|
158
|
+
const {
|
|
159
|
+
vertical
|
|
160
|
+
} = useMaterialQuizState();
|
|
161
|
+
return React.createElement(StyledQuizDraggbleOption, {
|
|
162
|
+
id: id,
|
|
163
|
+
className: className,
|
|
164
|
+
disabled: disabled,
|
|
165
|
+
role: role,
|
|
166
|
+
clone: clone,
|
|
167
|
+
vertical: vertical
|
|
168
|
+
}, React.createElement(StyledQuizDraggbleOptionHandle, null, React.createElement(Icon, {
|
|
169
|
+
size: "large",
|
|
170
|
+
icon: eilDraggableVertical
|
|
171
|
+
})), React.createElement(StyledQuizDraggbleOptionContent, null, isMarkdown ? React.createElement(StyledMarkdown, {
|
|
172
|
+
children: content,
|
|
173
|
+
dark: true,
|
|
174
|
+
paddingx: 0,
|
|
175
|
+
paddingy: 0
|
|
176
|
+
}) : React.createElement(Text, {
|
|
177
|
+
size: "small",
|
|
178
|
+
userSelect: "none",
|
|
179
|
+
wordBreak: "break-all",
|
|
180
|
+
role: role === 'answer' ? 'white' : 'default'
|
|
181
|
+
}, content), indexOrder ? React.createElement(StyledOrder, null, indexOrder) : null));
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export { QuizDraggbleOption as default };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const StyledMarkdown: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elice/markdown").MarkdownProps & import("react").RefAttributes<HTMLParagraphElement>>, any, {}, never>;
|
|
3
|
+
export default StyledMarkdown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as QuizDraggbleDroppedOption } from './QuizDraggbleDroppedOption';
|
|
2
|
+
export { default as QuizDraggbleDummyOption } from './QuizDraggbleDummyOption';
|
|
3
|
+
export { default as QuizDraggbleOption } from './QuizDraggbleOption';
|
|
4
|
+
export { default as QuestionRadio } from './question-radio/QuestionRadio';
|
|
5
|
+
export { default as QuestionRadioOption } from './question-radio/QuestionRadioOption';
|
|
6
|
+
export { default as QuestionCheckbox } from './question-checkbox/QuestionCheckbox';
|
|
7
|
+
export { default as QuestionCheckboxOption } from './question-checkbox/QuestionCheckboxOption';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __rest } from 'tslib';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { QuestionCheckboxContextProvider } from './QuestionCheckboxContext.js';
|
|
5
|
+
|
|
6
|
+
const StyledQuestionCheckbox = styled.div.withConfig({
|
|
7
|
+
componentId: "sc-1jgy6x5-0"
|
|
8
|
+
})(["display:flex;flex-direction:column;"]);
|
|
9
|
+
|
|
10
|
+
const QuestionCheckbox = _a => {
|
|
11
|
+
var {
|
|
12
|
+
children
|
|
13
|
+
} = _a,
|
|
14
|
+
props = __rest(_a, ["children"]);
|
|
15
|
+
|
|
16
|
+
return React.createElement(QuestionCheckboxContextProvider, Object.assign({}, props), React.createElement(StyledQuestionCheckbox, null, children));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { QuestionCheckbox as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { QuestionCheckboxProps } from './QuestionCheckbox';
|
|
3
|
+
declare type Value = Pick<QuestionCheckboxProps, 'selectedOptions' | 'disabled' | 'onSelect'>;
|
|
4
|
+
interface QuestionCheckboxProviderProps extends QuestionCheckboxProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare function QuestionCheckboxContextProvider({ selectedOptions, onSelect, disabled, children, }: QuestionCheckboxProviderProps): JSX.Element;
|
|
8
|
+
declare function useQuestionCheckboxContext(): Value;
|
|
9
|
+
export { QuestionCheckboxContextProvider, useQuestionCheckboxContext };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const QuestionCheckboxContext = React.createContext(undefined);
|
|
4
|
+
QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
|
|
5
|
+
|
|
6
|
+
function QuestionCheckboxContextProvider({
|
|
7
|
+
selectedOptions,
|
|
8
|
+
onSelect,
|
|
9
|
+
disabled,
|
|
10
|
+
children
|
|
11
|
+
}) {
|
|
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);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function useQuestionCheckboxContext() {
|
|
24
|
+
const context = React.useContext(QuestionCheckboxContext);
|
|
25
|
+
|
|
26
|
+
if (context === undefined) {
|
|
27
|
+
throw new Error('useQuestionCheckboxContext must be used within a QuestionCheckboxContextProvider');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return context;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { QuestionCheckboxContextProvider, useQuestionCheckboxContext };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare type Status = 'correct' | 'wrong' | 'answer';
|
|
3
|
+
interface QuestionCheckboxOptionProps {
|
|
4
|
+
value: any;
|
|
5
|
+
status?: Status;
|
|
6
|
+
isAnswer?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const QuestionCheckboxOption: React.FC<QuestionCheckboxOptionProps>;
|
|
9
|
+
export default QuestionCheckboxOption;
|