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

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