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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/cjs/components/eb-sortable/EbDraggable.js +33 -42
  2. package/cjs/components/eb-sortable/EbDroppable.js +20 -27
  3. package/cjs/components/markdown-editor/index.d.ts +2 -1
  4. package/cjs/components/markdown-editor/index.js +10 -19
  5. package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
  6. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
  7. package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
  8. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
  9. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
  10. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
  11. package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
  12. package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
  13. package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
  14. package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
  15. package/cjs/components/material-quiz/constants/color.js +5 -5
  16. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  17. package/cjs/components/material-quiz/context/MaterialQuizContext.js +93 -156
  18. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
  19. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
  20. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
  21. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
  22. package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
  23. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
  24. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
  25. package/cjs/components/material-quiz-edit/context.js +2 -8
  26. package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
  27. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
  28. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
  29. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
  30. package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
  31. package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  32. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
  33. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
  34. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
  35. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
  36. package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  37. package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
  38. package/cjs/components/shared/QuestionBox.js +165 -198
  39. package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
  40. package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
  41. package/cjs/components/shared/QuizDraggbleOption.js +59 -65
  42. package/cjs/components/shared/StyledMarkdown.js +1 -5
  43. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
  44. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  45. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
  46. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
  47. package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
  48. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  49. package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
  50. package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
  51. package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
  52. package/cjs/components/shared/utils/mergeRefs.js +6 -15
  53. package/cjs/constant/element.js +3 -3
  54. package/cjs/helpers/index.js +10 -8
  55. package/cjs/hooks/useCaculatePassage.js +20 -21
  56. package/es/components/eb-sortable/EbDraggable.js +33 -37
  57. package/es/components/eb-sortable/EbDroppable.js +20 -22
  58. package/es/components/markdown-editor/index.d.ts +2 -1
  59. package/es/components/markdown-editor/index.js +10 -15
  60. package/es/components/material-quiz/MaterialQuiz.js +83 -109
  61. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
  62. package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
  63. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
  64. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
  65. package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
  66. package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
  67. package/es/components/material-quiz/MaterialQuizText.js +115 -158
  68. package/es/components/material-quiz/QuizResultBadge.js +22 -27
  69. package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
  70. package/es/components/material-quiz/constants/color.js +5 -5
  71. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  72. package/es/components/material-quiz/context/MaterialQuizContext.js +94 -153
  73. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
  74. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
  75. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
  76. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
  77. package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
  78. package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
  79. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
  80. package/es/components/material-quiz-edit/context.js +2 -4
  81. package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
  82. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
  83. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
  84. package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
  85. package/es/components/material-quiz-edit/options/OptionText.js +82 -86
  86. package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  87. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
  88. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
  89. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
  90. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
  91. package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  92. package/es/components/material-quiz-edit/utils/editValue.js +12 -17
  93. package/es/components/shared/QuestionBox.js +165 -192
  94. package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
  95. package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
  96. package/es/components/shared/QuizDraggbleOption.js +59 -61
  97. package/es/components/shared/StyledMarkdown.js +1 -1
  98. package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
  99. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  100. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
  101. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
  102. package/es/components/shared/question-radio/QuestionRadio.js +7 -9
  103. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  104. package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
  105. package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
  106. package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
  107. package/es/components/shared/utils/mergeRefs.js +6 -15
  108. package/es/constant/element.js +3 -3
  109. package/es/helpers/index.js +10 -8
  110. package/es/hooks/useCaculatePassage.js +20 -21
  111. package/package.json +15 -12
  112. package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
  113. package/cjs/components/material-quiz/index.js +0 -9
  114. package/cjs/components/material-quiz/locales/index.js +0 -13
  115. package/cjs/components/material-quiz-edit/index.js +0 -7
  116. package/cjs/components/material-quiz-edit/locales/index.js +0 -13
  117. package/cjs/components/shared/index.js +0 -19
  118. package/cjs/constant/index.js +0 -9
  119. package/cjs/hooks/index.js +0 -7
  120. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
  121. package/es/components/material-quiz/index.js +0 -2
  122. package/es/components/material-quiz/locales/index.js +0 -4
  123. package/es/components/material-quiz-edit/index.js +0 -1
  124. package/es/components/material-quiz-edit/locales/index.js +0 -4
  125. package/es/components/shared/index.js +0 -7
  126. package/es/constant/index.js +0 -1
  127. package/es/hooks/index.js +0 -1
@@ -1,8 +1,7 @@
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';
1
+ import React from 'react';
3
2
  import { useFormContext, useWatch, Controller } from 'react-hook-form';
4
3
  import { config, postGlobalRemoteFileAttachmentUpload } from '@elice/api-client';
5
- import { SortableListItem, Input, Dropdown, Flex, Text, Hspace, IconButton, Tooltip, Notification } from '@elice/blocks';
4
+ import { SortableListItem, Input, Dropdown, Flex, Text, Hspace, IconButton, Notification, Tooltip } from '@elice/blocks';
6
5
  import { base } from '@elice/design-tokens';
7
6
  import { eilMathsignMultiplyBasic } from '@elice/icons';
8
7
  import { useRawEliceIntl } from '@elice/intl';
@@ -12,107 +11,84 @@ import trim from 'lodash-es/trim';
12
11
  import styled, { css } from 'styled-components';
13
12
  import { checkTwoDimensionArray } from '../../utils/checkTwoDimensionArray.js';
14
13
 
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({
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({
22
21
  componentId: "sc-18q96lt-0"
23
22
  })(["display:flex;flex:1;z-index:", ";padding:0;background:transparent;box-shadow:none;&:not(:last-child){margin-bottom:0.5rem;}"], SHEET_Z_INDEX + 1);
24
- var StyledSortableListItemOptionWrapper = styled.div.withConfig({
23
+ const StyledSortableListItemOptionWrapper = styled.div.withConfig({
25
24
  componentId: "sc-18q96lt-1"
26
25
  })(["display:flex;align-items:center;overflow:hidden;width:100%;height:100%;border:1px solid ", ";border-radius:4px;background:", ";"], base.color.gray3, base.color.white);
27
- var StyledSortableListItemOption = styled.div.withConfig({
26
+ const StyledSortableListItemOption = styled.div.withConfig({
28
27
  componentId: "sc-18q96lt-2"
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({
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({
33
30
  componentId: "sc-18q96lt-3"
34
31
  })(["display:flex;align-items:center;width:100%;height:100%;padding:0 1rem;"]);
35
- var StyledQuizOptionContentLabel = styled.label.withConfig({
32
+ const StyledQuizOptionContentLabel = styled.label.withConfig({
36
33
  componentId: "sc-18q96lt-4"
37
34
  })(["display:flex;align-items:center;width:100%;height:100%;padding:0 1rem;cursor:pointer;"]);
38
- var StyledQuizOptionTextInput = styled(Input).withConfig({
35
+ const StyledQuizOptionTextInput = styled(Input).withConfig({
39
36
  componentId: "sc-18q96lt-5"
40
37
  })(["& > div{border:0;}"]);
41
- var StyledQuizOptionContentInput = styled.input.withConfig({
38
+ const StyledQuizOptionContentInput = styled.input.withConfig({
42
39
  componentId: "sc-18q96lt-6"
43
40
  })(["display:none;"]);
44
- var StyledDropdown = styled(Dropdown).withConfig({
41
+ const StyledDropdown = styled(Dropdown).withConfig({
45
42
  componentId: "sc-18q96lt-7"
46
43
  })(["border:0;&.eb-dropdown__inner{width:100%;height:3.5rem;}"]);
47
44
  //
48
45
  //
49
46
  //
50
- var OptionGroupAnswerListItem = function OptionGroupAnswerListItem(_ref) {
51
- var optionId = _ref.optionId,
52
- disabled = _ref.disabled,
53
- onRemoveItem = _ref.onRemoveItem;
47
+ const OptionGroupAnswerListItem = ({
48
+ optionId,
49
+ disabled,
50
+ onRemoveItem
51
+ }) => {
54
52
  var _a, _b, _c, _d, _e, _f, _g, _h;
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,
53
+ const intl = useRawEliceIntl();
54
+ const {
55
+ control,
56
+ formState,
57
+ setValue
58
+ } = useFormContext();
59
+ const watchedAnswerInfo = useWatch({
60
+ control,
62
61
  name: 'answerInfoDefault'
63
62
  });
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);
63
+ const [watchedOptions, watchedGroupList] = useWatch({
64
+ control,
65
+ name: ['optionsDefault', 'groups']
74
66
  });
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;
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;
78
72
  /**
79
73
  * File upload function.
80
74
  */
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
- }();
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
+ };
110
86
  /**
111
87
  *
112
88
  */
113
- var getContentUrl = function getContentUrl(contentUrl) {
89
+ const getContentUrl = contentUrl => {
114
90
  if (contentUrl.includes('![]')) {
115
- var optionContentUrl = contentUrl === null || contentUrl === void 0 ? void 0 : contentUrl.substring(contentUrl.indexOf('(') + 1, contentUrl.indexOf(')'));
91
+ const optionContentUrl = contentUrl === null || contentUrl === void 0 ? void 0 : contentUrl.substring(contentUrl.indexOf('(') + 1, contentUrl.indexOf(')'));
116
92
  return optionContentUrl;
117
93
  }
118
94
  return contentUrl;
@@ -120,231 +96,174 @@ var OptionGroupAnswerListItem = function OptionGroupAnswerListItem(_ref) {
120
96
  /**
121
97
  *
122
98
  */
123
- var renderOptionTitleInput = function renderOptionTitleInput() {
124
- return jsx(StyledSortableListItemOption, {
99
+ const renderOptionTitleInput = () => {
100
+ return React.createElement(StyledSortableListItemOption, {
125
101
  style: {
126
102
  width: '33.3%'
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({
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({
135
117
  id: 'answer.option.errorMessage'
136
- })
137
- },
138
- validate: function validate(e) {
139
- if (!trim(e).length) {
140
- return intl.formatMessage({
141
- id: 'answer.option.errorMessage'
142
- });
143
- }
118
+ });
144
119
  }
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
- }));
152
120
  }
153
- })
154
- });
121
+ },
122
+ render: ({
123
+ field
124
+ }) => React.createElement(StyledQuizOptionTextInput, Object.assign({}, field, {
125
+ width: "full",
126
+ disabled: disabled
127
+ }))
128
+ }));
155
129
  };
156
130
  /**
157
131
  *
158
132
  */
159
- var renderOptionContentInput = function renderOptionContentInput() {
160
- return jsx(StyledSortableListItemOption, {
133
+ const renderOptionContentInput = () => {
134
+ return React.createElement(StyledSortableListItemOption, {
161
135
  style: {
162
136
  width: '33.3%'
163
137
  },
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
- });
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)})`);
259
194
  }
260
- })
261
- });
195
+ }))))
196
+ }));
262
197
  };
263
198
  /**
264
199
  *
265
200
  */
266
- var renderOptionGroupDropdown = function renderOptionGroupDropdown() {
267
- return jsx(StyledSortableListItemOption, {
201
+ const renderOptionGroupDropdown = () => {
202
+ return React.createElement(StyledSortableListItemOption, {
268
203
  style: {
269
204
  width: '33.3%'
270
205
  },
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
- });
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))));
305
231
  };
306
232
  /**
307
233
  *
308
234
  */
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
- });
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
+ }))));
332
253
  };
333
254
  /**
334
255
  *
335
256
  */
336
- var renderErrorMessage = function renderErrorMessage() {
257
+ const renderErrorMessage = () => {
337
258
  if (!errorMessage) {
338
259
  return null;
339
260
  }
340
- return jsx(Flex, {
341
- paddingleft: "0.25rem",
342
- children: jsx(Text, {
343
- size: "small",
344
- role: "danger",
345
- children: errorMessage
346
- })
347
- });
261
+ return React.createElement(Flex, {
262
+ paddingleft: "0.25rem"
263
+ }, React.createElement(Text, {
264
+ size: "small",
265
+ role: "danger"
266
+ }, errorMessage));
348
267
  };
349
268
  //
350
269
  //
@@ -352,21 +271,16 @@ var OptionGroupAnswerListItem = function OptionGroupAnswerListItem(_ref) {
352
271
  if (!checkTwoDimensionArray(watchedAnswerInfo)) {
353
272
  return null;
354
273
  }
355
- return jsx(StyledSortableListItem, {
274
+ return React.createElement(StyledSortableListItem, {
356
275
  index: optionId,
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
- });
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()));
370
284
  };
371
285
 
372
286
  export { OptionGroupAnswerListItem as default };