@elice/material-quiz 1.240718.0-trasncript.0 → 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,7 +1,8 @@
1
- import React from 'react';
1
+ import { slicedToArray as _slicedToArray, toConsumableArray as _toConsumableArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
3
  import { useFormContext, useWatch, Controller } from 'react-hook-form';
3
4
  import { config, postGlobalRemoteFileAttachmentUpload } from '@elice/api-client';
4
- import { SortableListItem, Input, Dropdown, Flex, Text, Hspace, IconButton, Notification, Tooltip } from '@elice/blocks';
5
+ import { SortableListItem, Input, Dropdown, Flex, Text, Hspace, IconButton, Tooltip, Notification } from '@elice/blocks';
5
6
  import { base } from '@elice/design-tokens';
6
7
  import { eilMathsignMultiplyBasic } from '@elice/icons';
7
8
  import { useRawEliceIntl } from '@elice/intl';
@@ -11,84 +12,107 @@ import trim from 'lodash-es/trim';
11
12
  import styled, { css } from 'styled-components';
12
13
  import { checkTwoDimensionArray } from '../../utils/checkTwoDimensionArray.js';
13
14
 
14
- const SHEET_Z_INDEX = 982;
15
- const DEFAULT_OPTION_VALUE = -1;
16
- const MIN_OPTION_INFO_COUNT = 2;
17
- const FILE_LABEL = 'file-label';
18
- const FILE_ACCEPT = '.mp3, .mp4, .mov, .png, .jpg, .svg, .gif';
19
- const MAX_FILE_SIZE = 3 * 1024 * 1024;
20
- const StyledSortableListItem = styled(SortableListItem).withConfig({
15
+ var SHEET_Z_INDEX = 982;
16
+ var DEFAULT_OPTION_VALUE = -1;
17
+ var MIN_OPTION_INFO_COUNT = 2;
18
+ var FILE_LABEL = 'file-label';
19
+ var FILE_ACCEPT = '.mp3, .mp4, .mov, .png, .jpg, .svg, .gif';
20
+ var MAX_FILE_SIZE = 3 * 1024 * 1024;
21
+ var StyledSortableListItem = styled(SortableListItem).withConfig({
21
22
  componentId: "sc-18q96lt-0"
22
23
  })(["display:flex;flex:1;z-index:", ";padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
23
- const StyledSortableListItemOptionWrapper = styled.div.withConfig({
24
+ var StyledSortableListItemOptionWrapper = styled.div.withConfig({
24
25
  componentId: "sc-18q96lt-1"
25
26
  })(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border:1px solid ", ";border-radius:4px;background:", ";"], base.color.gray3, base.color.white);
26
- const StyledSortableListItemOption = styled.div.withConfig({
27
+ var StyledSortableListItemOption = styled.div.withConfig({
27
28
  componentId: "sc-18q96lt-2"
28
- })(["height:3.5rem;&:not(:last-child){border-right:1px solid ", ";}", ";"], base.color.gray3, props => props['aria-disabled'] && css(["background-color:", ";border-radius:0;"], base.color.gray2));
29
- const StyledQuizOptionContent = styled.div.withConfig({
29
+ })(["height:3.5rem;&:not(:last-child){border-right:1px solid ", ";}", ";"], base.color.gray3, function (props) {
30
+ return props['aria-disabled'] && css(["background-color:", ";border-radius:0;"], base.color.gray2);
31
+ });
32
+ var StyledQuizOptionContent = styled.div.withConfig({
30
33
  componentId: "sc-18q96lt-3"
31
34
  })(["display:flex;align-items:center;width:100%;height:100%;padding:0 1rem;"]);
32
- const StyledQuizOptionContentLabel = styled.label.withConfig({
35
+ var StyledQuizOptionContentLabel = styled.label.withConfig({
33
36
  componentId: "sc-18q96lt-4"
34
37
  })(["display:flex;align-items:center;width:100%;height:100%;padding:0 1rem;cursor:pointer;"]);
35
- const StyledQuizOptionTextInput = styled(Input).withConfig({
38
+ var StyledQuizOptionTextInput = styled(Input).withConfig({
36
39
  componentId: "sc-18q96lt-5"
37
40
  })(["& > div{border:0;}"]);
38
- const StyledQuizOptionContentInput = styled.input.withConfig({
41
+ var StyledQuizOptionContentInput = styled.input.withConfig({
39
42
  componentId: "sc-18q96lt-6"
40
43
  })(["display:none;"]);
41
- const StyledDropdown = styled(Dropdown).withConfig({
44
+ var StyledDropdown = styled(Dropdown).withConfig({
42
45
  componentId: "sc-18q96lt-7"
43
46
  })(["border:0;&.eb-dropdown__inner{width:100%;height:3.5rem;}"]);
44
47
  //
45
48
  //
46
49
  //
47
- const OptionGroupAnswerListItem = ({
48
- optionId,
49
- disabled,
50
- onRemoveItem
51
- }) => {
50
+ var OptionGroupAnswerListItem = function OptionGroupAnswerListItem(_ref) {
51
+ var optionId = _ref.optionId,
52
+ disabled = _ref.disabled,
53
+ onRemoveItem = _ref.onRemoveItem;
52
54
  var _a, _b, _c, _d, _e, _f, _g, _h;
53
- const intl = useRawEliceIntl();
54
- const {
55
- control,
56
- formState,
57
- setValue
58
- } = useFormContext();
59
- const watchedAnswerInfo = useWatch({
60
- control,
55
+ var intl = useRawEliceIntl();
56
+ var _useFormContext = useFormContext(),
57
+ control = _useFormContext.control,
58
+ formState = _useFormContext.formState,
59
+ setValue = _useFormContext.setValue;
60
+ var watchedAnswerInfo = useWatch({
61
+ control: control,
61
62
  name: 'answerInfoDefault'
62
63
  });
63
- const [watchedOptions, watchedGroupList] = useWatch({
64
- control,
65
- name: ['optionsDefault', 'groups']
64
+ var _useWatch = useWatch({
65
+ control: control,
66
+ name: ['optionsDefault', 'groups']
67
+ }),
68
+ _useWatch2 = _slicedToArray(_useWatch, 2),
69
+ watchedOptions = _useWatch2[0],
70
+ watchedGroupList = _useWatch2[1];
71
+ var errorMessage = (_d = (_c = (_b = (_a = formState.errors) === null || _a === void 0 ? void 0 : _a.optionsDefault) === null || _b === void 0 ? void 0 : _b[optionId]) === null || _c === void 0 ? void 0 : _c.title) === null || _d === void 0 ? void 0 : _d.message;
72
+ var groupIndex = watchedAnswerInfo.findIndex(function (answer) {
73
+ return answer === null || answer === void 0 ? void 0 : answer.includes(optionId);
66
74
  });
67
- const errorMessage = (_d = (_c = (_b = (_a = formState.errors) === null || _a === void 0 ? void 0 : _a.optionsDefault) === null || _b === void 0 ? void 0 : _b[optionId]) === null || _c === void 0 ? void 0 : _c.title) === null || _d === void 0 ? void 0 : _d.message;
68
- const groupIndex = watchedAnswerInfo.findIndex(answer => answer === null || answer === void 0 ? void 0 : answer.includes(optionId));
69
- const isReady = useMaterialConfigApiClientUpdate(config.init);
70
- const isOptionTitle = (_f = (_e = watchedOptions[optionId]) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f.length;
71
- const isOptionContent = (_h = (_g = watchedOptions[optionId]) === null || _g === void 0 ? void 0 : _g.content) === null || _h === void 0 ? void 0 : _h.length;
75
+ var isReady = useMaterialConfigApiClientUpdate(config.init);
76
+ var isOptionTitle = (_f = (_e = watchedOptions[optionId]) === null || _e === void 0 ? void 0 : _e.title) === null || _f === void 0 ? void 0 : _f.length;
77
+ var isOptionContent = (_h = (_g = watchedOptions[optionId]) === null || _g === void 0 ? void 0 : _g.content) === null || _h === void 0 ? void 0 : _h.length;
72
78
  /**
73
79
  * File upload function.
74
80
  */
75
- const uploadContentFile = async attachmentFile => {
76
- if (!isReady) {
77
- return;
78
- }
79
- return postGlobalRemoteFileAttachmentUpload({
80
- attachmentFile
81
- }).then(res => res.url).catch(err => {
82
- console.error(err);
83
- throw err;
84
- });
85
- };
81
+ var uploadContentFile = /*#__PURE__*/function () {
82
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(attachmentFile) {
83
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
84
+ while (1) switch (_context.prev = _context.next) {
85
+ case 0:
86
+ if (isReady) {
87
+ _context.next = 2;
88
+ break;
89
+ }
90
+ return _context.abrupt("return");
91
+ case 2:
92
+ return _context.abrupt("return", postGlobalRemoteFileAttachmentUpload({
93
+ attachmentFile: attachmentFile
94
+ }).then(function (res) {
95
+ return res.url;
96
+ }).catch(function (err) {
97
+ console.error(err);
98
+ throw err;
99
+ }));
100
+ case 3:
101
+ case "end":
102
+ return _context.stop();
103
+ }
104
+ }, _callee);
105
+ }));
106
+ return function uploadContentFile(_x) {
107
+ return _ref2.apply(this, arguments);
108
+ };
109
+ }();
86
110
  /**
87
111
  *
88
112
  */
89
- const getContentUrl = contentUrl => {
113
+ var getContentUrl = function getContentUrl(contentUrl) {
90
114
  if (contentUrl.includes('![]')) {
91
- const optionContentUrl = contentUrl === null || contentUrl === void 0 ? void 0 : contentUrl.substring(contentUrl.indexOf('(') + 1, contentUrl.indexOf(')'));
115
+ var optionContentUrl = contentUrl === null || contentUrl === void 0 ? void 0 : contentUrl.substring(contentUrl.indexOf('(') + 1, contentUrl.indexOf(')'));
92
116
  return optionContentUrl;
93
117
  }
94
118
  return contentUrl;
@@ -96,174 +120,231 @@ const OptionGroupAnswerListItem = ({
96
120
  /**
97
121
  *
98
122
  */
99
- const renderOptionTitleInput = () => {
100
- return React.createElement(StyledSortableListItemOption, {
123
+ var renderOptionTitleInput = function renderOptionTitleInput() {
124
+ return jsx(StyledSortableListItemOption, {
101
125
  style: {
102
126
  width: '33.3%'
103
- }
104
- }, React.createElement(Controller, {
105
- control: control,
106
- name: `optionsDefault.${optionId}.title`,
107
- rules: {
108
- required: {
109
- value: !isOptionTitle && !isOptionContent,
110
- message: intl.formatMessage({
111
- id: 'answer.option.errorMessage'
112
- })
113
- },
114
- validate: e => {
115
- if (!trim(e).length) {
116
- return intl.formatMessage({
127
+ },
128
+ children: jsx(Controller, {
129
+ control: control,
130
+ name: "optionsDefault.".concat(optionId, ".title"),
131
+ rules: {
132
+ required: {
133
+ value: !isOptionTitle && !isOptionContent,
134
+ message: intl.formatMessage({
117
135
  id: 'answer.option.errorMessage'
118
- });
136
+ })
137
+ },
138
+ validate: function validate(e) {
139
+ if (!trim(e).length) {
140
+ return intl.formatMessage({
141
+ id: 'answer.option.errorMessage'
142
+ });
143
+ }
119
144
  }
145
+ },
146
+ render: function render(_ref3) {
147
+ var field = _ref3.field;
148
+ return jsx(StyledQuizOptionTextInput, Object.assign({}, field, {
149
+ width: "full",
150
+ disabled: disabled
151
+ }));
120
152
  }
121
- },
122
- render: ({
123
- field
124
- }) => React.createElement(StyledQuizOptionTextInput, Object.assign({}, field, {
125
- width: "full",
126
- disabled: disabled
127
- }))
128
- }));
153
+ })
154
+ });
129
155
  };
130
156
  /**
131
157
  *
132
158
  */
133
- const renderOptionContentInput = () => {
134
- return React.createElement(StyledSortableListItemOption, {
159
+ var renderOptionContentInput = function renderOptionContentInput() {
160
+ return jsx(StyledSortableListItemOption, {
135
161
  style: {
136
162
  width: '33.3%'
137
163
  },
138
- "aria-disabled": disabled
139
- }, React.createElement(Controller, {
140
- control: control,
141
- name: `optionsDefault.${optionId}.content`,
142
- render: ({
143
- field
144
- }) => React.createElement(React.Fragment, null, field.value ? React.createElement(StyledQuizOptionContent, null, React.createElement(Flex, {
145
- justify: "space-between",
146
- align: "center",
147
- width: "100%",
148
- height: "100%"
149
- }, React.createElement(Text, {
150
- ellipsis: true
151
- }, React.createElement("a", {
152
- href: getContentUrl(field.value),
153
- target: "_blank",
154
- rel: "noreferrer"
155
- }, getContentUrl(field.value))), React.createElement(Flex, {
156
- align: "center"
157
- }, React.createElement(Hspace, {
158
- width: 0.5
159
- }), React.createElement(IconButton, {
160
- disabled: disabled,
161
- icon: eilMathsignMultiplyBasic,
162
- role: "gray6",
163
- size: "micro",
164
- border: false,
165
- transparent: true,
166
- onClick: () => field.onChange('')
167
- })))) : React.createElement(React.Fragment, null, React.createElement(StyledQuizOptionContentLabel, {
168
- htmlFor: `${FILE_LABEL}_${optionId}`
169
- }, React.createElement(Text, {
170
- role: "primary",
171
- underline: true
172
- }, intl.formatMessage({
173
- id: 'answer.option.file.label'
174
- }))), React.createElement(StyledQuizOptionContentInput, Object.assign({}, field, {
175
- id: `${FILE_LABEL}_${optionId}`,
176
- type: "file",
177
- accept: FILE_ACCEPT,
178
- disabled: disabled,
179
- onChange: async e => {
180
- var _a, _b;
181
- const file = (_b = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
182
- if (!file) {
183
- return;
184
- }
185
- if (file.size > MAX_FILE_SIZE) {
186
- return Notification.error(intl.formatMessage({
187
- id: 'answer.option.file.errorMessage.maxSize'
188
- }, {
189
- size: 3
190
- }));
191
- }
192
- const contentFileUrl = await uploadContentFile(file);
193
- field.onChange(`![](${String(contentFileUrl)})`);
164
+ "aria-disabled": disabled,
165
+ children: jsx(Controller, {
166
+ control: control,
167
+ name: "optionsDefault.".concat(optionId, ".content"),
168
+ render: function render(_ref4) {
169
+ var field = _ref4.field;
170
+ return jsx(Fragment, {
171
+ children: field.value ? jsx(StyledQuizOptionContent, {
172
+ children: jsxs(Flex, {
173
+ justify: "space-between",
174
+ align: "center",
175
+ width: "100%",
176
+ height: "100%",
177
+ children: [jsx(Text, {
178
+ ellipsis: true,
179
+ children: jsx("a", {
180
+ href: getContentUrl(field.value),
181
+ target: "_blank",
182
+ rel: "noreferrer",
183
+ children: getContentUrl(field.value)
184
+ })
185
+ }), jsxs(Flex, {
186
+ align: "center",
187
+ children: [jsx(Hspace, {
188
+ width: 0.5
189
+ }), jsx(IconButton, {
190
+ disabled: disabled,
191
+ icon: eilMathsignMultiplyBasic,
192
+ role: "gray6",
193
+ size: "micro",
194
+ border: false,
195
+ transparent: true,
196
+ onClick: function onClick() {
197
+ return field.onChange('');
198
+ }
199
+ })]
200
+ })]
201
+ })
202
+ }) : jsxs(Fragment, {
203
+ children: [jsx(StyledQuizOptionContentLabel, {
204
+ htmlFor: "".concat(FILE_LABEL, "_").concat(optionId),
205
+ children: jsx(Text, {
206
+ role: "primary",
207
+ underline: true,
208
+ children: intl.formatMessage({
209
+ id: 'answer.option.file.label'
210
+ })
211
+ })
212
+ }), jsx(StyledQuizOptionContentInput, Object.assign({}, field, {
213
+ id: "".concat(FILE_LABEL, "_").concat(optionId),
214
+ type: "file",
215
+ accept: FILE_ACCEPT,
216
+ disabled: disabled,
217
+ onChange: function () {
218
+ var _onChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e) {
219
+ var _a, _b, file, contentFileUrl;
220
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
221
+ while (1) switch (_context2.prev = _context2.next) {
222
+ case 0:
223
+ file = (_b = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
224
+ if (file) {
225
+ _context2.next = 3;
226
+ break;
227
+ }
228
+ return _context2.abrupt("return");
229
+ case 3:
230
+ if (!(file.size > MAX_FILE_SIZE)) {
231
+ _context2.next = 5;
232
+ break;
233
+ }
234
+ return _context2.abrupt("return", Notification.error(intl.formatMessage({
235
+ id: 'answer.option.file.errorMessage.maxSize'
236
+ }, {
237
+ size: 3
238
+ })));
239
+ case 5:
240
+ _context2.next = 7;
241
+ return uploadContentFile(file);
242
+ case 7:
243
+ contentFileUrl = _context2.sent;
244
+ field.onChange("![](".concat(String(contentFileUrl), ")"));
245
+ case 9:
246
+ case "end":
247
+ return _context2.stop();
248
+ }
249
+ }, _callee2);
250
+ }));
251
+ function onChange(_x2) {
252
+ return _onChange.apply(this, arguments);
253
+ }
254
+ return onChange;
255
+ }()
256
+ }))]
257
+ })
258
+ });
194
259
  }
195
- }))))
196
- }));
260
+ })
261
+ });
197
262
  };
198
263
  /**
199
264
  *
200
265
  */
201
- const renderOptionGroupDropdown = () => {
202
- return React.createElement(StyledSortableListItemOption, {
266
+ var renderOptionGroupDropdown = function renderOptionGroupDropdown() {
267
+ return jsx(StyledSortableListItemOption, {
203
268
  style: {
204
269
  width: '33.3%'
205
270
  },
206
- "aria-disabled": disabled
207
- }, React.createElement(StyledDropdown, {
208
- disabled: disabled,
209
- value: groupIndex,
210
- onChange: e => {
211
- const cloneAnswerList = cloneDeep(watchedAnswerInfo);
212
- const answerList = cloneAnswerList.map(answers => answers.filter(answer => answer !== optionId));
213
- if (e === DEFAULT_OPTION_VALUE) {
214
- return setValue('answerInfoDefault', answerList);
215
- }
216
- if (answerList[e]) {
217
- answerList[e] = [...answerList[e], optionId];
218
- } else {
219
- answerList[e] = [optionId];
220
- }
221
- setValue('answerInfoDefault', answerList);
222
- }
223
- }, React.createElement("option", {
224
- value: DEFAULT_OPTION_VALUE
225
- }, intl.formatMessage({
226
- id: 'answer.option.default.group'
227
- })), watchedGroupList.map((group, index) => React.createElement("option", {
228
- key: index,
229
- value: index
230
- }, group.group))));
271
+ "aria-disabled": disabled,
272
+ children: jsxs(StyledDropdown, {
273
+ disabled: disabled,
274
+ value: groupIndex,
275
+ onChange: function onChange(e) {
276
+ var cloneAnswerList = cloneDeep(watchedAnswerInfo);
277
+ var answerList = cloneAnswerList.map(function (answers) {
278
+ return answers.filter(function (answer) {
279
+ return answer !== optionId;
280
+ });
281
+ });
282
+ if (e === DEFAULT_OPTION_VALUE) {
283
+ return setValue('answerInfoDefault', answerList);
284
+ }
285
+ if (answerList[e]) {
286
+ answerList[e] = [].concat(_toConsumableArray(answerList[e]), [optionId]);
287
+ } else {
288
+ answerList[e] = [optionId];
289
+ }
290
+ setValue('answerInfoDefault', answerList);
291
+ },
292
+ children: [jsx("option", {
293
+ value: DEFAULT_OPTION_VALUE,
294
+ children: intl.formatMessage({
295
+ id: 'answer.option.default.group'
296
+ })
297
+ }), watchedGroupList.map(function (group, index) {
298
+ return jsx("option", {
299
+ value: index,
300
+ children: group.group
301
+ }, index);
302
+ })]
303
+ })
304
+ });
231
305
  };
232
306
  /**
233
307
  *
234
308
  */
235
- const renderOptionRemoveButton = () => {
236
- const isMinimumOptions = (watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.length) <= MIN_OPTION_INFO_COUNT;
237
- return React.createElement(React.Fragment, null, React.createElement(Hspace, {
238
- width: 0.5
239
- }), React.createElement(Tooltip, {
240
- title: isMinimumOptions ? intl.formatMessage({
241
- id: 'answer.option.tooltip.minDisabled'
242
- }) : undefined,
243
- placement: "top"
244
- }, React.createElement("span", null, React.createElement(IconButton, {
245
- transparent: true,
246
- icon: eilMathsignMultiplyBasic,
247
- role: "gray6",
248
- size: "micro",
249
- border: false,
250
- disabled: disabled || isMinimumOptions,
251
- onClick: onRemoveItem
252
- }))));
309
+ var renderOptionRemoveButton = function renderOptionRemoveButton() {
310
+ var isMinimumOptions = (watchedOptions === null || watchedOptions === void 0 ? void 0 : watchedOptions.length) <= MIN_OPTION_INFO_COUNT;
311
+ return jsxs(Fragment, {
312
+ children: [jsx(Hspace, {
313
+ width: 0.5
314
+ }), jsx(Tooltip, {
315
+ title: isMinimumOptions ? intl.formatMessage({
316
+ id: 'answer.option.tooltip.minDisabled'
317
+ }) : undefined,
318
+ placement: "top",
319
+ children: jsx("span", {
320
+ children: jsx(IconButton, {
321
+ transparent: true,
322
+ icon: eilMathsignMultiplyBasic,
323
+ role: "gray6",
324
+ size: "micro",
325
+ border: false,
326
+ disabled: disabled || isMinimumOptions,
327
+ onClick: onRemoveItem
328
+ })
329
+ })
330
+ })]
331
+ });
253
332
  };
254
333
  /**
255
334
  *
256
335
  */
257
- const renderErrorMessage = () => {
336
+ var renderErrorMessage = function renderErrorMessage() {
258
337
  if (!errorMessage) {
259
338
  return null;
260
339
  }
261
- return React.createElement(Flex, {
262
- paddingleft: "0.25rem"
263
- }, React.createElement(Text, {
264
- size: "small",
265
- role: "danger"
266
- }, errorMessage));
340
+ return jsx(Flex, {
341
+ paddingleft: "0.25rem",
342
+ children: jsx(Text, {
343
+ size: "small",
344
+ role: "danger",
345
+ children: errorMessage
346
+ })
347
+ });
267
348
  };
268
349
  //
269
350
  //
@@ -271,16 +352,21 @@ const OptionGroupAnswerListItem = ({
271
352
  if (!checkTwoDimensionArray(watchedAnswerInfo)) {
272
353
  return null;
273
354
  }
274
- return React.createElement(StyledSortableListItem, {
355
+ return jsx(StyledSortableListItem, {
275
356
  index: optionId,
276
- disabled: disabled
277
- }, React.createElement(Flex, {
278
- justify: "center",
279
- width: "calc(100% - 1.5rem)",
280
- column: true
281
- }, React.createElement(Flex, {
282
- align: "center"
283
- }, React.createElement(StyledSortableListItemOptionWrapper, null, renderOptionTitleInput(), renderOptionContentInput(), renderOptionGroupDropdown()), renderOptionRemoveButton()), renderErrorMessage()));
357
+ disabled: disabled,
358
+ children: jsxs(Flex, {
359
+ justify: "center",
360
+ width: "calc(100% - 1.5rem)",
361
+ column: true,
362
+ children: [jsxs(Flex, {
363
+ align: "center",
364
+ children: [jsxs(StyledSortableListItemOptionWrapper, {
365
+ children: [renderOptionTitleInput(), renderOptionContentInput(), renderOptionGroupDropdown()]
366
+ }), renderOptionRemoveButton()]
367
+ }), renderErrorMessage()]
368
+ })
369
+ });
284
370
  };
285
371
 
286
372
  export { OptionGroupAnswerListItem as default };