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