@elice/material-quiz 1.240718.0-trasncript.2 → 1.240718.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/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,6 @@
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');
7
5
  var React = require('react');
8
6
  var reactHookForm = require('react-hook-form');
9
7
  var reactTransitionGroup = require('react-transition-group');
@@ -22,38 +20,26 @@ var checkTwoDimensionArray = require('./utils/checkTwoDimensionArray.js');
22
20
  var randomId = require('./utils/randomId.js');
23
21
  var context = require('./context.js');
24
22
 
25
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
26
-
27
- var React__default = /*#__PURE__*/_interopDefaultCompat(React);
28
- var flattenDeep__default = /*#__PURE__*/_interopDefaultCompat(flattenDeep);
29
-
30
- var MIN_TEXT_LENGTH = 1;
31
- var MAX_TEXT_LENGTH = 128;
32
- var MaterialQuizEditContent = function MaterialQuizEditContent() {
33
- var intl$1 = intl.useRawEliceIntl();
34
- var _useMaterialQuizEditC = context.useMaterialQuizEditContext(),
35
- disabled = _useMaterialQuizEditC.disabled,
36
- onFileUploadRequest = _useMaterialQuizEditC.onFileUploadRequest;
37
- var _useFormContext = reactHookForm.useFormContext(),
38
- control = _useFormContext.control,
39
- watch = _useFormContext.watch,
40
- setValue = _useFormContext.setValue;
41
- var _watch = watch(['optionType', 'optionsDefault', 'answerInfoDefault', 'answerHint', 'explanationInfo', 'isAutoGrade', 'groups', 'optionsSetEnabled']),
42
- _watch2 = _rollupPluginBabelHelpers.slicedToArray(_watch, 8),
43
- watchedOptionType = _watch2[0],
44
- watchedOptionInfo = _watch2[1],
45
- watchedAnswerInfo = _watch2[2],
46
- watchedAnswerHint = _watch2[3],
47
- watchedExplanationInfo = _watch2[4],
48
- watchedIsAutoGrade = _watch2[5],
49
- watchedGroups = _watch2[6],
50
- optionsSetEnabled = _watch2[7];
23
+ const MIN_TEXT_LENGTH = 1;
24
+ const MAX_TEXT_LENGTH = 128;
25
+ const MaterialQuizEditContent = () => {
26
+ const intl$1 = intl.useRawEliceIntl();
27
+ const {
28
+ disabled,
29
+ onFileUploadRequest
30
+ } = context.useMaterialQuizEditContext();
31
+ const {
32
+ control,
33
+ watch,
34
+ setValue
35
+ } = reactHookForm.useFormContext();
36
+ const [watchedOptionType, watchedOptionInfo, watchedAnswerInfo, watchedAnswerHint, watchedExplanationInfo, watchedIsAutoGrade, watchedGroups, optionsSetEnabled] = watch(['optionType', 'optionsDefault', 'answerInfoDefault', 'answerHint', 'explanationInfo', 'isAutoGrade', 'groups', 'optionsSetEnabled']);
51
37
  //
52
38
  // Change `options` according to `optionType`.
53
39
  //
54
- React__default.default.useEffect(function () {
55
- var get = function get() {
56
- var filteredNotMarkdownOptions = watchedOptionInfo === null || watchedOptionInfo === void 0 ? void 0 : watchedOptionInfo.filter(function (option) {
40
+ React.useEffect(() => {
41
+ const get = () => {
42
+ const filteredNotMarkdownOptions = watchedOptionInfo === null || watchedOptionInfo === void 0 ? void 0 : watchedOptionInfo.filter(option => {
57
43
  var _a;
58
44
  return !((_a = option.content) === null || _a === void 0 ? void 0 : _a.includes('![]'));
59
45
  });
@@ -82,7 +68,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
82
68
  }];
83
69
  }
84
70
  if (filteredNotMarkdownOptions.length) {
85
- return watchedOptionInfo.map(function (e) {
71
+ return watchedOptionInfo.map(e => {
86
72
  var _a;
87
73
  if ((_a = e.title) === null || _a === void 0 ? void 0 : _a.length) {
88
74
  return Object.assign(Object.assign({}, e), {
@@ -116,7 +102,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
116
102
  }];
117
103
  }
118
104
  if (filteredNotMarkdownOptions.length) {
119
- return watchedOptionInfo.map(function (e) {
105
+ return watchedOptionInfo.map(e => {
120
106
  var _a, _b;
121
107
  if (!((_a = e.content) === null || _a === void 0 ? void 0 : _a.includes('![]')) && !((_b = e.title) === null || _b === void 0 ? void 0 : _b.length)) {
122
108
  return Object.assign(Object.assign({}, e), {
@@ -141,16 +127,16 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
141
127
  //
142
128
  // Change `answerInfo` according to `optionType`.
143
129
  //
144
- React__default.default.useEffect(function () {
145
- var get = function get() {
130
+ React.useEffect(() => {
131
+ const get = () => {
146
132
  switch (watchedOptionType) {
147
133
  case types.enums.QuizOptionType.SelectOne:
148
134
  if (!Array.isArray(watchedAnswerInfo)) {
149
135
  return [0];
150
136
  }
151
137
  if (checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
152
- var convertedAnswerInfo = watchedAnswerInfo;
153
- return flattenDeep__default.default(convertedAnswerInfo).slice(0, 1);
138
+ const convertedAnswerInfo = watchedAnswerInfo;
139
+ return flattenDeep(convertedAnswerInfo).slice(0, 1);
154
140
  }
155
141
  return watchedAnswerInfo.slice(0, 1);
156
142
  case types.enums.QuizOptionType.SelectMultiple:
@@ -159,7 +145,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
159
145
  return [0];
160
146
  }
161
147
  if (checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
162
- return flattenDeep__default.default(watchedAnswerInfo);
148
+ return flattenDeep(watchedAnswerInfo);
163
149
  }
164
150
  return watchedAnswerInfo;
165
151
  case types.enums.QuizOptionType.Text:
@@ -177,8 +163,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
177
163
  //
178
164
  // Change `answerHint` according to `optionType`.
179
165
  //
180
- React__default.default.useEffect(function () {
181
- var get = function get() {
166
+ React.useEffect(() => {
167
+ const get = () => {
182
168
  switch (watchedOptionType) {
183
169
  case types.enums.QuizOptionType.SelectOne:
184
170
  case types.enums.QuizOptionType.SelectMultiple:
@@ -198,8 +184,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
198
184
  //
199
185
  // Change `isAutoGrade` according to `optionType`.
200
186
  //
201
- React__default.default.useEffect(function () {
202
- var get = function get() {
187
+ React.useEffect(() => {
188
+ const get = () => {
203
189
  switch (watchedOptionType) {
204
190
  case types.enums.QuizOptionType.SelectOne:
205
191
  case types.enums.QuizOptionType.SelectMultiple:
@@ -219,8 +205,8 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
219
205
  //
220
206
  // Change `groups` according to `optionType`.
221
207
  //
222
- React__default.default.useEffect(function () {
223
- var get = function get() {
208
+ React.useEffect(() => {
209
+ const get = () => {
224
210
  switch (watchedOptionType) {
225
211
  case types.enums.QuizOptionType.SelectOne:
226
212
  case types.enums.QuizOptionType.SelectMultiple:
@@ -255,7 +241,7 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
255
241
  * Input of option info and answer info,
256
242
  * according to option type.
257
243
  */
258
- var Option = React__default.default.useMemo(function () {
244
+ const Option = React.useMemo(() => {
259
245
  switch (watchedOptionType) {
260
246
  case types.enums.QuizOptionType.SelectOne:
261
247
  return OptionSelectOne.default;
@@ -268,22 +254,21 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
268
254
  case types.enums.QuizOptionType.Text:
269
255
  return OptionText.default;
270
256
  default:
271
- return React__default.default.Fragment;
257
+ return React.Fragment;
272
258
  }
273
259
  }, [watchedOptionType]);
274
260
  /**
275
261
  * Render input for quiz title.
276
262
  */
277
- var renderQuestionTitleInput = function renderQuestionTitleInput() {
278
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
279
- label: jsxRuntime.jsx(blocks.Label, {
263
+ const renderQuestionTitleInput = () => {
264
+ return React.createElement(blocks.FormInputVerticalLayout, {
265
+ label: React.createElement(blocks.Label, {
280
266
  size: "small",
281
- required: true,
282
- children: intl$1.formatMessage({
283
- id: 'content.title'
284
- })
285
- }),
286
- input: jsxRuntime.jsx(reactHookForm.Controller, {
267
+ required: true
268
+ }, intl$1.formatMessage({
269
+ id: 'content.title'
270
+ })),
271
+ input: React.createElement(reactHookForm.Controller, {
287
272
  control: control,
288
273
  name: "questionTitle",
289
274
  rules: {
@@ -312,11 +297,12 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
312
297
  })
313
298
  }
314
299
  },
315
- render: function render(_ref) {
316
- var field = _ref.field,
317
- fieldState = _ref.fieldState;
300
+ render: ({
301
+ field,
302
+ fieldState
303
+ }) => {
318
304
  var _a;
319
- return jsxRuntime.jsx(blocks.Input, Object.assign({
305
+ return React.createElement(blocks.Input, Object.assign({
320
306
  size: "small",
321
307
  width: "full",
322
308
  minLength: MIN_TEXT_LENGTH,
@@ -334,169 +320,149 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
334
320
  /**
335
321
  * Render input for quiz description.
336
322
  */
337
- var renderQuestionDescriptionInput = function renderQuestionDescriptionInput() {
338
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
339
- label: jsxRuntime.jsx(blocks.Label, {
340
- size: "small",
341
- children: intl$1.formatMessage({
342
- id: 'content.description.title'
343
- })
344
- }),
345
- input: jsxRuntime.jsx(reactHookForm.Controller, {
323
+ const renderQuestionDescriptionInput = () => {
324
+ return React.createElement(blocks.FormInputVerticalLayout, {
325
+ label: React.createElement(blocks.Label, {
326
+ size: "small"
327
+ }, intl$1.formatMessage({
328
+ id: 'content.description.title'
329
+ })),
330
+ input: React.createElement(reactHookForm.Controller, {
346
331
  control: control,
347
332
  name: "questionDescription",
348
- render: function render(_ref2) {
349
- var field = _ref2.field;
350
- return jsxRuntime.jsx(index.MarkdownEditor, Object.assign({
351
- placeholder: intl$1.formatMessage({
352
- id: 'content.description.placeholder'
353
- }),
354
- onFileUploadRequest: onFileUploadRequest
355
- }, field));
356
- }
333
+ render: ({
334
+ field
335
+ }) => React.createElement(index.MarkdownEditor, Object.assign({
336
+ placeholder: intl$1.formatMessage({
337
+ id: 'content.description.placeholder'
338
+ }),
339
+ onFileUploadRequest: onFileUploadRequest
340
+ }, field))
357
341
  })
358
342
  });
359
343
  };
360
344
  /**
361
345
  * Render input of option type, option info and answer info.
362
346
  */
363
- var renderOptionInput = function renderOptionInput() {
364
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
365
- label: jsxRuntime.jsx(blocks.Label, {
347
+ const renderOptionInput = () => {
348
+ return React.createElement(blocks.FormInputVerticalLayout, {
349
+ label: React.createElement(blocks.Label, {
366
350
  size: "small",
367
- required: true,
368
- children: intl$1.formatMessage({
369
- id: 'content.option.title'
370
- })
371
- }),
372
- input: jsxRuntime.jsxs(jsxRuntime.Fragment, {
373
- children: [jsxRuntime.jsx(reactHookForm.Controller, {
374
- control: control,
375
- name: "optionType",
376
- render: function render(_ref3) {
377
- var field = _ref3.field;
378
- return jsxRuntime.jsx(material.Tooltip, {
379
- title: disabled && intl$1.formatMessage({
380
- id: 'content.option.tooltip.disabled'
381
- }),
382
- placement: "top-end",
383
- children: jsxRuntime.jsxs(material.Stack, {
384
- direction: "row",
385
- justifyContent: "space-between",
386
- marginBottom: "0.5rem",
387
- children: [jsxRuntime.jsxs(material.TextField, Object.assign({
388
- select: true,
389
- disabled: disabled
390
- }, field, {
391
- onChange: function onChange(event) {
392
- var isTextQuizOption = Number(event.target.value) === types.enums.QuizOptionType.Text;
393
- if (isTextQuizOption) {
394
- setValue('optionsSetEnabled', false);
395
- }
396
- field.onChange(event);
397
- },
398
- children: [jsxRuntime.jsx(material.MenuItem, {
399
- value: types.enums.QuizOptionType.SelectOne,
400
- children: intl$1.formatMessage({
401
- id: 'content.option.select.items.selectOne'
402
- })
403
- }), jsxRuntime.jsx(material.MenuItem, {
404
- value: types.enums.QuizOptionType.SelectMultiple,
405
- children: intl$1.formatMessage({
406
- id: 'content.option.select.items.selectMultiple'
407
- })
408
- }), jsxRuntime.jsx(material.MenuItem, {
409
- value: types.enums.QuizOptionType.SelectMultipleOrder,
410
- children: intl$1.formatMessage({
411
- id: 'content.option.select.items.selectMultipleOrder'
412
- })
413
- }), jsxRuntime.jsx(material.MenuItem, {
414
- value: types.enums.QuizOptionType.Group,
415
- children: intl$1.formatMessage({
416
- id: 'content.option.select.items.group'
417
- })
418
- }), jsxRuntime.jsx(material.MenuItem, {
419
- value: types.enums.QuizOptionType.Text,
420
- children: intl$1.formatMessage({
421
- id: 'content.option.select.items.text'
422
- })
423
- })]
424
- })), watchedOptionType !== types.enums.QuizOptionType.Text ? jsxRuntime.jsx(reactHookForm.Controller, {
425
- name: "optionsSetEnabled",
426
- control: control,
427
- render: function render(_ref4) {
428
- var field = _ref4.field;
429
- return jsxRuntime.jsx(material.Tooltip, {
430
- title: disabled ? '' : intl$1.formatMessage({
431
- id: 'content.option.optionsSetEnabled.tooltip'
432
- }),
433
- placement: "top",
434
- children: jsxRuntime.jsx(material.FormControlLabel, {
435
- disabled: disabled,
436
- label: intl$1.formatMessage({
437
- id: 'content.option.optionsSetEnabled.label'
438
- }),
439
- control: jsxRuntime.jsx(material.Switch, Object.assign({}, field, {
440
- checked: field.value
441
- }))
442
- })
443
- });
444
- }
445
- }) : null]
446
- })
447
- });
351
+ required: true
352
+ }, intl$1.formatMessage({
353
+ id: 'content.option.title'
354
+ })),
355
+ input: React.createElement(React.Fragment, null, React.createElement(reactHookForm.Controller, {
356
+ control: control,
357
+ name: "optionType",
358
+ render: ({
359
+ field
360
+ }) => React.createElement(material.Tooltip, {
361
+ title: disabled && intl$1.formatMessage({
362
+ id: 'content.option.tooltip.disabled'
363
+ }),
364
+ placement: "top-end"
365
+ }, React.createElement(material.Stack, {
366
+ direction: "row",
367
+ justifyContent: "space-between",
368
+ marginBottom: "0.5rem"
369
+ }, React.createElement(material.TextField, Object.assign({
370
+ select: true,
371
+ disabled: disabled
372
+ }, field, {
373
+ onChange: event => {
374
+ const isTextQuizOption = Number(event.target.value) === types.enums.QuizOptionType.Text;
375
+ if (isTextQuizOption) {
376
+ setValue('optionsSetEnabled', false);
377
+ }
378
+ field.onChange(event);
448
379
  }
449
- }), watchedOptionType !== types.enums.QuizOptionType.Text && optionsSetEnabled ? jsxRuntime.jsxs(material.Alert, {
450
- severity: "info",
451
- sx: {
452
- marginBottom: '1rem'
453
- },
454
- children: [jsxRuntime.jsx(material.AlertTitle, {
455
- children: intl$1.formatMessage({
456
- id: 'content.option.alert.randomized.title'
457
- })
458
- }), intl$1.formatMessage({
459
- id: 'content.option.alert.randomized.description'
460
- })]
461
- }) : null, jsxRuntime.jsx(reactTransitionGroup.Transition, {
462
- in: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder || watchedOptionType === types.enums.QuizOptionType.Group,
463
- timeout: 0,
464
- mountOnEnter: true,
465
- unmountOnExit: true,
466
- children: jsxRuntime.jsx(material.Box, {
467
- marginBottom: "0.5rem",
468
- children: jsxRuntime.jsx(blocks.StatusText, {
469
- role: "description",
470
- preWrap: true,
471
- children: intl$1.formatMessage({
472
- id: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder ? 'content.option.statusText.dragNDrop' : 'content.option.statusText.dragNDropGroup'
473
- })
474
- })
380
+ }), React.createElement(material.MenuItem, {
381
+ value: types.enums.QuizOptionType.SelectOne,
382
+ children: intl$1.formatMessage({
383
+ id: 'content.option.select.items.selectOne'
475
384
  })
476
- }), jsxRuntime.jsx(Option, {})]
477
- })
385
+ }), React.createElement(material.MenuItem, {
386
+ value: types.enums.QuizOptionType.SelectMultiple,
387
+ children: intl$1.formatMessage({
388
+ id: 'content.option.select.items.selectMultiple'
389
+ })
390
+ }), React.createElement(material.MenuItem, {
391
+ value: types.enums.QuizOptionType.SelectMultipleOrder,
392
+ children: intl$1.formatMessage({
393
+ id: 'content.option.select.items.selectMultipleOrder'
394
+ })
395
+ }), React.createElement(material.MenuItem, {
396
+ value: types.enums.QuizOptionType.Group,
397
+ children: intl$1.formatMessage({
398
+ id: 'content.option.select.items.group'
399
+ })
400
+ }), React.createElement(material.MenuItem, {
401
+ value: types.enums.QuizOptionType.Text,
402
+ children: intl$1.formatMessage({
403
+ id: 'content.option.select.items.text'
404
+ })
405
+ })), watchedOptionType !== types.enums.QuizOptionType.Text ? React.createElement(reactHookForm.Controller, {
406
+ name: "optionsSetEnabled",
407
+ control: control,
408
+ render: ({
409
+ field
410
+ }) => React.createElement(material.Tooltip, {
411
+ title: disabled ? '' : intl$1.formatMessage({
412
+ id: 'content.option.optionsSetEnabled.tooltip'
413
+ }),
414
+ placement: "top"
415
+ }, React.createElement(material.FormControlLabel, {
416
+ disabled: disabled,
417
+ label: intl$1.formatMessage({
418
+ id: 'content.option.optionsSetEnabled.label'
419
+ }),
420
+ control: React.createElement(material.Switch, Object.assign({}, field, {
421
+ checked: field.value
422
+ }))
423
+ }))
424
+ }) : null))
425
+ }), watchedOptionType !== types.enums.QuizOptionType.Text && optionsSetEnabled ? React.createElement(material.Alert, {
426
+ severity: "info",
427
+ sx: {
428
+ marginBottom: '1rem'
429
+ }
430
+ }, React.createElement(material.AlertTitle, null, intl$1.formatMessage({
431
+ id: 'content.option.alert.randomized.title'
432
+ })), intl$1.formatMessage({
433
+ id: 'content.option.alert.randomized.description'
434
+ })) : null, React.createElement(reactTransitionGroup.Transition, {
435
+ in: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder || watchedOptionType === types.enums.QuizOptionType.Group,
436
+ timeout: 0,
437
+ mountOnEnter: true,
438
+ unmountOnExit: true
439
+ }, React.createElement(material.Box, {
440
+ marginBottom: "0.5rem"
441
+ }, React.createElement(blocks.StatusText, {
442
+ role: "description",
443
+ preWrap: true
444
+ }, intl$1.formatMessage({
445
+ id: watchedOptionType === types.enums.QuizOptionType.SelectMultipleOrder ? 'content.option.statusText.dragNDrop' : 'content.option.statusText.dragNDropGroup'
446
+ })))), React.createElement(Option, null))
478
447
  });
479
448
  };
480
449
  /**
481
450
  * Input of answer hint.
482
451
  */
483
- var renderAnswerHintInput = function renderAnswerHintInput() {
452
+ const renderAnswerHintInput = () => {
484
453
  if (watchedOptionType !== types.enums.QuizOptionType.Text) {
485
454
  return null;
486
455
  }
487
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
488
- label: jsxRuntime.jsx(blocks.Label, {
489
- size: "small",
490
- children: intl$1.formatMessage({
491
- id: 'content.answerHint.title'
492
- })
493
- }),
494
- description: jsxRuntime.jsx(blocks.Text, {
495
- children: intl$1.formatMessage({
496
- id: 'content.answerHint.description'
497
- })
498
- }),
499
- input: jsxRuntime.jsx(reactHookForm.Controller, {
456
+ return React.createElement(blocks.FormInputVerticalLayout, {
457
+ label: React.createElement(blocks.Label, {
458
+ size: "small"
459
+ }, intl$1.formatMessage({
460
+ id: 'content.answerHint.title'
461
+ })),
462
+ description: React.createElement(blocks.Text, null, intl$1.formatMessage({
463
+ id: 'content.answerHint.description'
464
+ })),
465
+ input: React.createElement(reactHookForm.Controller, {
500
466
  control: control,
501
467
  name: "answerHint",
502
468
  rules: {
@@ -519,11 +485,12 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
519
485
  })
520
486
  }
521
487
  },
522
- render: function render(_ref5) {
523
- var field = _ref5.field,
524
- fieldState = _ref5.fieldState;
488
+ render: ({
489
+ field,
490
+ fieldState
491
+ }) => {
525
492
  var _a, _b;
526
- return jsxRuntime.jsx(blocks.Input, Object.assign({
493
+ return React.createElement(blocks.Input, Object.assign({
527
494
  size: "small",
528
495
  width: "full",
529
496
  minLength: MIN_TEXT_LENGTH,
@@ -543,85 +510,70 @@ var MaterialQuizEditContent = function MaterialQuizEditContent() {
543
510
  /**
544
511
  * Input of explanation info.
545
512
  */
546
- var renderExplanationInfoInput = function renderExplanationInfoInput() {
547
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
548
- label: jsxRuntime.jsx(blocks.Label, {
549
- size: "small",
550
- children: intl$1.formatMessage({
551
- id: 'content.explanationInfo.title'
552
- })
553
- }),
554
- description: jsxRuntime.jsx(blocks.Text, {
555
- children: intl$1.formatMessage({
556
- id: 'content.explanationInfo.description'
557
- })
558
- }),
559
- input: jsxRuntime.jsxs(jsxRuntime.Fragment, {
560
- children: [jsxRuntime.jsx(reactHookForm.Controller, {
561
- control: control,
562
- name: "explanationInfo.isEnabled",
563
- render: function render(_ref6) {
564
- var field = _ref6.field;
565
- return jsxRuntime.jsx(blocks.Checkbox, Object.assign({
566
- size: "small"
567
- }, field, {
568
- children: intl$1.formatMessage({
569
- id: 'content.explanationInfo.checkbox.label'
570
- })
571
- }));
513
+ const renderExplanationInfoInput = () => {
514
+ return React.createElement(blocks.FormInputVerticalLayout, {
515
+ label: React.createElement(blocks.Label, {
516
+ size: "small"
517
+ }, intl$1.formatMessage({
518
+ id: 'content.explanationInfo.title'
519
+ })),
520
+ description: React.createElement(blocks.Text, null, intl$1.formatMessage({
521
+ id: 'content.explanationInfo.description'
522
+ })),
523
+ input: React.createElement(React.Fragment, null, React.createElement(reactHookForm.Controller, {
524
+ control: control,
525
+ name: "explanationInfo.isEnabled",
526
+ render: ({
527
+ field
528
+ }) => React.createElement(blocks.Checkbox, Object.assign({
529
+ size: "small"
530
+ }, field), intl$1.formatMessage({
531
+ id: 'content.explanationInfo.checkbox.label'
532
+ }))
533
+ }), React.createElement(reactTransitionGroup.Transition, {
534
+ in: watchedExplanationInfo.isEnabled,
535
+ timeout: 0,
536
+ mountOnEnter: true,
537
+ unmountOnExit: true
538
+ }, React.createElement(React.Fragment, null, React.createElement(blocks.Vspace, {
539
+ height: 1
540
+ }), React.createElement(reactHookForm.Controller, {
541
+ control: control,
542
+ name: "explanationInfo.value",
543
+ rules: {
544
+ required: {
545
+ value: true,
546
+ message: intl$1.formatMessage({
547
+ id: 'content.explanationInfo.textarea.placeholder'
548
+ })
572
549
  }
573
- }), jsxRuntime.jsx(reactTransitionGroup.Transition, {
574
- in: watchedExplanationInfo.isEnabled,
575
- timeout: 0,
576
- mountOnEnter: true,
577
- unmountOnExit: true,
578
- children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
579
- children: [jsxRuntime.jsx(blocks.Vspace, {
580
- height: 1
581
- }), jsxRuntime.jsx(reactHookForm.Controller, {
582
- control: control,
583
- name: "explanationInfo.value",
584
- rules: {
585
- required: {
586
- value: true,
587
- message: intl$1.formatMessage({
588
- id: 'content.explanationInfo.textarea.placeholder'
589
- })
590
- }
591
- },
592
- render: function render(_ref7) {
593
- var field = _ref7.field,
594
- fieldState = _ref7.fieldState;
595
- var _a;
596
- return jsxRuntime.jsxs(blocks.Flex, {
597
- column: true,
598
- children: [fieldState.invalid ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
599
- children: [jsxRuntime.jsx(blocks.StatusText, {
600
- children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
601
- role: "danger"
602
- }), jsxRuntime.jsx(blocks.Vspace, {
603
- height: 0.5
604
- })]
605
- }) : null, jsxRuntime.jsx(index.MarkdownEditor, Object.assign({
606
- placeholder: intl$1.formatMessage({
607
- id: 'content.explanationInfo.textarea.errorMessage.required'
608
- }),
609
- onFileUploadRequest: onFileUploadRequest
610
- }, field))]
611
- });
612
- }
613
- })]
614
- })
615
- })]
616
- })
550
+ },
551
+ render: ({
552
+ field,
553
+ fieldState
554
+ }) => {
555
+ var _a;
556
+ return React.createElement(blocks.Flex, {
557
+ column: true
558
+ }, fieldState.invalid ? React.createElement(React.Fragment, null, React.createElement(blocks.StatusText, {
559
+ children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
560
+ role: "danger"
561
+ }), React.createElement(blocks.Vspace, {
562
+ height: 0.5
563
+ })) : null, React.createElement(index.MarkdownEditor, Object.assign({
564
+ placeholder: intl$1.formatMessage({
565
+ id: 'content.explanationInfo.textarea.errorMessage.required'
566
+ }),
567
+ onFileUploadRequest: onFileUploadRequest
568
+ }, field)));
569
+ }
570
+ }))))
617
571
  });
618
572
  };
619
573
  //
620
574
  //
621
575
  //
622
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
623
- children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput()]
624
- });
576
+ return React.createElement(React.Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput());
625
577
  };
626
578
 
627
579
  exports.default = MaterialQuizEditContent;