@elice/material-quiz 1.240718.0-trasncript.1 → 1.240718.0-trasncript.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +423 -0
  2. package/cjs/components/eb-sortable/EbDraggable.js +42 -33
  3. package/cjs/components/eb-sortable/EbDroppable.js +27 -20
  4. package/cjs/components/markdown-editor/index.d.ts +1 -2
  5. package/cjs/components/markdown-editor/index.js +19 -10
  6. package/cjs/components/material-quiz/MaterialQuiz.js +114 -83
  7. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +36 -29
  8. package/cjs/components/material-quiz/MaterialQuizInfo.js +151 -149
  9. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +175 -127
  10. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +360 -286
  11. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +172 -126
  12. package/cjs/components/material-quiz/MaterialQuizShimmer.js +46 -39
  13. package/cjs/components/material-quiz/MaterialQuizText.js +163 -115
  14. package/cjs/components/material-quiz/QuizResultBadge.js +32 -22
  15. package/cjs/components/material-quiz/QuizSubmitStatusText.js +21 -16
  16. package/cjs/components/material-quiz/constants/color.js +5 -5
  17. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  18. package/cjs/components/material-quiz/context/MaterialQuizContext.js +156 -93
  19. package/cjs/components/material-quiz/index.js +9 -0
  20. package/cjs/components/material-quiz/locales/index.js +13 -0
  21. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +259 -161
  22. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +134 -100
  23. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +130 -101
  24. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +64 -52
  25. package/cjs/components/material-quiz/material-quiz-group/context/context.js +5 -1
  26. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +47 -36
  27. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +280 -232
  28. package/cjs/components/material-quiz-edit/context.js +8 -2
  29. package/cjs/components/material-quiz-edit/index.js +7 -0
  30. package/cjs/components/material-quiz-edit/locales/index.js +13 -0
  31. package/cjs/components/material-quiz-edit/options/OptionEditor.js +70 -46
  32. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +174 -148
  33. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +175 -149
  34. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +164 -144
  35. package/cjs/components/material-quiz-edit/options/OptionText.js +90 -82
  36. package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
  37. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +156 -112
  38. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +288 -196
  39. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +88 -75
  40. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +108 -92
  41. package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
  42. package/cjs/components/material-quiz-edit/utils/editValue.js +21 -12
  43. package/cjs/components/shared/QuestionBox.js +198 -165
  44. package/cjs/components/shared/QuizDraggbleDroppedOption.js +11 -12
  45. package/cjs/components/shared/QuizDraggbleDummyOption.js +23 -16
  46. package/cjs/components/shared/QuizDraggbleOption.js +65 -59
  47. package/cjs/components/shared/StyledMarkdown.js +5 -1
  48. package/cjs/components/shared/index.js +19 -0
  49. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
  50. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  51. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
  52. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +59 -68
  53. package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
  54. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  55. package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
  56. package/cjs/components/shared/question-radio/QuestionRadioOption.js +52 -59
  57. package/cjs/components/shared/utils/getQuestionStatusStyle.js +7 -9
  58. package/cjs/components/shared/utils/mergeRefs.js +15 -6
  59. package/cjs/constant/element.js +3 -3
  60. package/cjs/constant/index.js +9 -0
  61. package/cjs/helpers/index.js +8 -10
  62. package/cjs/hooks/index.js +7 -0
  63. package/cjs/hooks/useCaculatePassage.js +21 -20
  64. package/es/_virtual/_rollupPluginBabelHelpers.js +408 -0
  65. package/es/components/eb-sortable/EbDraggable.js +37 -33
  66. package/es/components/eb-sortable/EbDroppable.js +22 -20
  67. package/es/components/markdown-editor/index.d.ts +1 -2
  68. package/es/components/markdown-editor/index.js +15 -10
  69. package/es/components/material-quiz/MaterialQuiz.js +109 -83
  70. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +32 -29
  71. package/es/components/material-quiz/MaterialQuizInfo.js +148 -150
  72. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +171 -127
  73. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +356 -287
  74. package/es/components/material-quiz/MaterialQuizSelectOne.js +168 -126
  75. package/es/components/material-quiz/MaterialQuizShimmer.js +42 -39
  76. package/es/components/material-quiz/MaterialQuizText.js +158 -115
  77. package/es/components/material-quiz/QuizResultBadge.js +27 -22
  78. package/es/components/material-quiz/QuizSubmitStatusText.js +17 -16
  79. package/es/components/material-quiz/constants/color.js +5 -5
  80. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  81. package/es/components/material-quiz/context/MaterialQuizContext.js +153 -94
  82. package/es/components/material-quiz/index.js +2 -0
  83. package/es/components/material-quiz/locales/index.js +4 -0
  84. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +253 -161
  85. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +129 -100
  86. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +125 -101
  87. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +60 -52
  88. package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
  89. package/es/components/material-quiz-edit/MaterialQuizEdit.js +43 -36
  90. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +272 -229
  91. package/es/components/material-quiz-edit/context.js +4 -2
  92. package/es/components/material-quiz-edit/index.js +1 -0
  93. package/es/components/material-quiz-edit/locales/index.js +4 -0
  94. package/es/components/material-quiz-edit/options/OptionEditor.js +64 -46
  95. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +170 -148
  96. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +171 -149
  97. package/es/components/material-quiz-edit/options/OptionSelectOne.js +159 -144
  98. package/es/components/material-quiz-edit/options/OptionText.js +86 -82
  99. package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
  100. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +151 -112
  101. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +283 -197
  102. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +83 -75
  103. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +103 -92
  104. package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
  105. package/es/components/material-quiz-edit/utils/editValue.js +17 -12
  106. package/es/components/shared/QuestionBox.js +192 -165
  107. package/es/components/shared/QuizDraggbleDroppedOption.js +11 -12
  108. package/es/components/shared/QuizDraggbleDummyOption.js +19 -16
  109. package/es/components/shared/QuizDraggbleOption.js +61 -59
  110. package/es/components/shared/StyledMarkdown.js +1 -1
  111. package/es/components/shared/index.js +7 -0
  112. package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
  113. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  114. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
  115. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +54 -68
  116. package/es/components/shared/question-radio/QuestionRadio.js +9 -7
  117. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  118. package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
  119. package/es/components/shared/question-radio/QuestionRadioOption.js +47 -59
  120. package/es/components/shared/utils/getQuestionStatusStyle.js +7 -9
  121. package/es/components/shared/utils/mergeRefs.js +15 -6
  122. package/es/constant/element.js +3 -3
  123. package/es/constant/index.js +1 -0
  124. package/es/helpers/index.js +8 -10
  125. package/es/hooks/index.js +1 -0
  126. package/es/hooks/useCaculatePassage.js +21 -20
  127. package/package.json +12 -15
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { IconButton, Text } from '@elice/blocks';
3
3
  import { base } from '@elice/design-tokens';
4
4
  import { eilMathsignMultiplyBasic } from '@elice/icons';
@@ -7,55 +7,59 @@ import styled from 'styled-components';
7
7
  import EbDraggable from '../../eb-sortable/EbDraggable.js';
8
8
  import { useMaterialQuizState } from '../context/MaterialQuizContext.js';
9
9
 
10
- const StyledDraggbleOption = styled(EbDraggable).withConfig({
10
+ var StyledDraggbleOption = styled(EbDraggable).withConfig({
11
11
  componentId: "sc-1b3vxse-0"
12
- })(["display:flex;flex-direction:column;flex-shrink:", ";overflow:hidden;max-width:", ";height:fit-content;border-radius:0.5rem;background:", ";"], ({
13
- vertical
14
- }) => vertical ? 0 : 1, ({
15
- vertical
16
- }) => vertical ? '10.25rem' : '11.5rem', base.color.navy8);
17
- const StyledOptionTitle = styled.div.withConfig({
12
+ })(["display:flex;flex-direction:column;flex-shrink:", ";overflow:hidden;max-width:", ";height:fit-content;border-radius:0.5rem;background:", ";"], function (_ref) {
13
+ var vertical = _ref.vertical;
14
+ return vertical ? 0 : 1;
15
+ }, function (_ref2) {
16
+ var vertical = _ref2.vertical;
17
+ return vertical ? '10.25rem' : '11.5rem';
18
+ }, base.color.navy8);
19
+ var StyledOptionTitle = styled.div.withConfig({
18
20
  componentId: "sc-1b3vxse-1"
19
- })(["display:flex;justify-content:center;align-items:center;width:", ";height:", ";padding:0.5rem;background:", ";"], ({
20
- vertical,
21
- isOptionContent
22
- }) => isOptionContent ? '100%' : vertical ? '10.25rem' : '11.5rem', ({
23
- vertical,
24
- isOptionContent
25
- }) => isOptionContent ? 'auto' : vertical ? '10.25rem' : '11.5rem', base.color.white);
26
- const StyledOptionContent = styled.div.withConfig({
21
+ })(["display:flex;justify-content:center;align-items:center;width:", ";height:", ";padding:0.5rem;background:", ";"], function (_ref3) {
22
+ var vertical = _ref3.vertical,
23
+ isOptionContent = _ref3.isOptionContent;
24
+ return isOptionContent ? '100%' : vertical ? '10.25rem' : '11.5rem';
25
+ }, function (_ref4) {
26
+ var vertical = _ref4.vertical,
27
+ isOptionContent = _ref4.isOptionContent;
28
+ return isOptionContent ? 'auto' : vertical ? '10.25rem' : '11.5rem';
29
+ }, base.color.white);
30
+ var StyledOptionContent = styled.div.withConfig({
27
31
  componentId: "sc-1b3vxse-2"
28
- })(["display:flex;align-items:center;width:", ";height:", ";background:", ";& p{line-height:1;}"], ({
29
- vertical
30
- }) => vertical ? '10.25rem' : '11.5rem', ({
31
- vertical
32
- }) => vertical ? '10.25rem' : '11.5rem', base.color.navy8);
33
- const StyledOptionRemoveIcon = styled(IconButton).withConfig({
32
+ })(["display:flex;align-items:center;width:", ";height:", ";background:", ";& p{line-height:1;}"], function (_ref5) {
33
+ var vertical = _ref5.vertical;
34
+ return vertical ? '10.25rem' : '11.5rem';
35
+ }, function (_ref6) {
36
+ var vertical = _ref6.vertical;
37
+ return vertical ? '10.25rem' : '11.5rem';
38
+ }, base.color.navy8);
39
+ var StyledOptionRemoveIcon = styled(IconButton).withConfig({
34
40
  componentId: "sc-1b3vxse-3"
35
41
  })(["position:absolute;top:0.5rem;right:0.5rem;border-radius:1rem;"]);
36
- const MaterialQuizGroupOptionItem = ({
37
- option,
38
- onClose
39
- }) => {
42
+ var MaterialQuizGroupOptionItem = function MaterialQuizGroupOptionItem(_ref7) {
43
+ var option = _ref7.option,
44
+ onClose = _ref7.onClose;
40
45
  var _a;
41
- const {
42
- vertical,
43
- userId
44
- } = useMaterialQuizState();
45
- const isOptionTitle = Boolean(option.options.title);
46
- const isOptionContent = Boolean(option.options.content);
47
- const renderRemoveItem = () => {
46
+ var _useMaterialQuizState = useMaterialQuizState(),
47
+ vertical = _useMaterialQuizState.vertical,
48
+ userId = _useMaterialQuizState.userId;
49
+ var isOptionTitle = Boolean(option.options.title);
50
+ var isOptionContent = Boolean(option.options.content);
51
+ var renderRemoveItem = function renderRemoveItem() {
48
52
  if (typeof onClose !== 'function') {
49
53
  return null;
50
54
  }
51
55
  if (!!userId) {
52
56
  return null;
53
57
  }
54
- return React.createElement(StyledOptionRemoveIcon, {
58
+ return jsx(StyledOptionRemoveIcon, {
55
59
  icon: eilMathsignMultiplyBasic,
56
60
  role: "gray1",
57
61
  size: "micro",
58
- onClick: e => {
62
+ onClick: function onClick(e) {
59
63
  e.stopPropagation();
60
64
  onClose();
61
65
  }
@@ -64,27 +68,31 @@ const MaterialQuizGroupOptionItem = ({
64
68
  //
65
69
  //
66
70
  //
67
- return React.createElement(StyledDraggbleOption, {
71
+ return jsxs(StyledDraggbleOption, {
68
72
  disabled: !!userId || vertical,
69
73
  id: option.order.toString(),
70
74
  className: "quiz-answer",
71
- vertical: vertical
72
- }, isOptionContent ? React.createElement(StyledOptionContent, {
73
- vertical: vertical
74
- }, React.createElement(MarkdownSSR, {
75
- children: (_a = option.options.content) !== null && _a !== void 0 ? _a : '',
76
- paddingx: 0,
77
- paddingy: 0,
78
- dark: true
79
- })) : null, isOptionTitle ? React.createElement(StyledOptionTitle, {
80
75
  vertical: vertical,
81
- isOptionContent: isOptionContent
82
- }, React.createElement(Text, {
83
- size: vertical ? 'small' : 'default',
84
- textAlign: "center",
85
- wordBreak: "break-all",
86
- bold: true
87
- }, option.options.title)) : null, renderRemoveItem());
76
+ children: [isOptionContent ? jsx(StyledOptionContent, {
77
+ vertical: vertical,
78
+ children: jsx(MarkdownSSR, {
79
+ children: (_a = option.options.content) !== null && _a !== void 0 ? _a : '',
80
+ paddingx: 0,
81
+ paddingy: 0,
82
+ dark: true
83
+ })
84
+ }) : null, isOptionTitle ? jsx(StyledOptionTitle, {
85
+ vertical: vertical,
86
+ isOptionContent: isOptionContent,
87
+ children: jsx(Text, {
88
+ size: vertical ? 'small' : 'default',
89
+ textAlign: "center",
90
+ wordBreak: "break-all",
91
+ bold: true,
92
+ children: option.options.title
93
+ })
94
+ }) : null, renderRemoveItem()]
95
+ });
88
96
  };
89
97
 
90
98
  export { MaterialQuizGroupOptionItem as default };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
 
3
- const QuizGroupContext = React.createContext(null);
3
+ var QuizGroupContext = React.createContext(null);
4
4
 
5
5
  export { QuizGroupContext as default };
@@ -1,3 +1,4 @@
1
+ import { jsx } from 'react/jsx-runtime';
1
2
  import React, { forwardRef } from 'react';
2
3
  import { useForm, FormProvider } from 'react-hook-form';
3
4
  import { RawEliceIntlProvider, IntlComponentBuilder } from '@elice/intl';
@@ -8,29 +9,28 @@ import messageEn from './locales/en.json.js';
8
9
  import messageKo from './locales/ko.json.js';
9
10
  import MaterialQuizEditContent from './MaterialQuizEditContent.js';
10
11
 
11
- const MaterialQuizEdit = forwardRef(({
12
- value,
13
- disabled = false,
14
- onChange,
15
- onFormStateChange,
16
- onFileUploadRequest,
17
- __intl
18
- }, ref) => {
19
- const formElRef = React.useRef(null);
20
- const useFormMethods = useForm({
12
+ var MaterialQuizEdit = forwardRef(function (_ref, ref) {
13
+ var value = _ref.value,
14
+ _ref$disabled = _ref.disabled,
15
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
16
+ onChange = _ref.onChange,
17
+ onFormStateChange = _ref.onFormStateChange,
18
+ onFileUploadRequest = _ref.onFileUploadRequest,
19
+ __intl = _ref.__intl;
20
+ var formElRef = React.useRef(null);
21
+ var useFormMethods = useForm({
21
22
  defaultValues: manipulateValue(value),
22
23
  mode: 'onBlur'
23
24
  });
24
- const watchedMaterialQuizEditValue = useFormMethods.watch();
25
- const {
26
- isDirty,
27
- isValid
28
- } = useFormMethods.formState;
25
+ var watchedMaterialQuizEditValue = useFormMethods.watch();
26
+ var _useFormMethods$formS = useFormMethods.formState,
27
+ isDirty = _useFormMethods$formS.isDirty,
28
+ isValid = _useFormMethods$formS.isValid;
29
29
  //
30
30
  // Reset from value, when `value` changes.
31
31
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
32
32
  //
33
- useDeepClonedCompareEffect(() => {
33
+ useDeepClonedCompareEffect(function () {
34
34
  useFormMethods.reset(manipulateValue(value), {
35
35
  keepDirty: true,
36
36
  keepErrors: true,
@@ -44,17 +44,17 @@ const MaterialQuizEdit = forwardRef(({
44
44
  // Emit `onChange` handler when form value changed.
45
45
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
46
46
  //
47
- useDeepClonedCompareEffect(() => {
47
+ useDeepClonedCompareEffect(function () {
48
48
  onChange(restoreValue(watchedMaterialQuizEditValue));
49
49
  }, [watchedMaterialQuizEditValue]);
50
50
  //
51
51
  // Emit `onFormStateChange` handler when form state change.
52
52
  //
53
- React.useEffect(() => {
53
+ React.useEffect(function () {
54
54
  if (typeof onFormStateChange === 'function') {
55
55
  onFormStateChange({
56
- isDirty,
57
- isValid
56
+ isDirty: isDirty,
57
+ isValid: isValid
58
58
  });
59
59
  }
60
60
  },
@@ -63,25 +63,32 @@ const MaterialQuizEdit = forwardRef(({
63
63
  //
64
64
  // Set ref.
65
65
  //
66
- React.useImperativeHandle(ref, () => Object.assign(Object.assign({}, formElRef.current), {
67
- reset: () => {
68
- useFormMethods.reset(manipulateValue(value));
69
- void useFormMethods.trigger();
70
- }
71
- }), [useFormMethods, value]);
66
+ React.useImperativeHandle(ref, function () {
67
+ return Object.assign(Object.assign({}, formElRef.current), {
68
+ reset: function reset() {
69
+ useFormMethods.reset(manipulateValue(value));
70
+ void useFormMethods.trigger();
71
+ }
72
+ });
73
+ }, [useFormMethods, value]);
72
74
  //
73
75
  //
74
76
  //
75
- return React.createElement(RawEliceIntlProvider, {
76
- value: __intl
77
- }, React.createElement("form", {
78
- ref: formElRef
79
- }, React.createElement(MaterialQuizEditContext.Provider, {
80
- value: {
81
- disabled,
82
- onFileUploadRequest
83
- }
84
- }, React.createElement(FormProvider, Object.assign({}, useFormMethods), React.createElement(MaterialQuizEditContent, null)))));
77
+ return jsx(RawEliceIntlProvider, {
78
+ value: __intl,
79
+ children: jsx("form", {
80
+ ref: formElRef,
81
+ children: jsx(MaterialQuizEditContext.Provider, {
82
+ value: {
83
+ disabled: disabled,
84
+ onFileUploadRequest: onFileUploadRequest
85
+ },
86
+ children: jsx(FormProvider, Object.assign({}, useFormMethods, {
87
+ children: jsx(MaterialQuizEditContent, {})
88
+ }))
89
+ })
90
+ })
91
+ });
85
92
  });
86
93
  var MaterialQuizEdit$1 = new IntlComponentBuilder(MaterialQuizEdit).add('en', messageEn).add('ko', messageKo).addAsync('th', import('./locales/th.json.js')).addAsync('ja', import('./locales/ja.json.js')).build();
87
94