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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +423 -0
  2. package/cjs/components/eb-sortable/EbDraggable.js +42 -33
  3. package/cjs/components/eb-sortable/EbDroppable.js +27 -20
  4. package/cjs/components/markdown-editor/index.d.ts +1 -2
  5. package/cjs/components/markdown-editor/index.js +19 -10
  6. package/cjs/components/material-quiz/MaterialQuiz.js +114 -83
  7. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +36 -29
  8. package/cjs/components/material-quiz/MaterialQuizInfo.js +151 -149
  9. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +175 -127
  10. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +360 -286
  11. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +172 -126
  12. package/cjs/components/material-quiz/MaterialQuizShimmer.js +46 -39
  13. package/cjs/components/material-quiz/MaterialQuizText.js +163 -115
  14. package/cjs/components/material-quiz/QuizResultBadge.js +32 -22
  15. package/cjs/components/material-quiz/QuizSubmitStatusText.js +21 -16
  16. package/cjs/components/material-quiz/constants/color.js +5 -5
  17. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  18. package/cjs/components/material-quiz/context/MaterialQuizContext.js +156 -93
  19. package/cjs/components/material-quiz/index.js +9 -0
  20. package/cjs/components/material-quiz/locales/index.js +13 -0
  21. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +259 -161
  22. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +134 -100
  23. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +130 -101
  24. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +64 -52
  25. package/cjs/components/material-quiz/material-quiz-group/context/context.js +5 -1
  26. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +47 -36
  27. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +280 -232
  28. package/cjs/components/material-quiz-edit/context.js +8 -2
  29. package/cjs/components/material-quiz-edit/index.js +7 -0
  30. package/cjs/components/material-quiz-edit/locales/index.js +13 -0
  31. package/cjs/components/material-quiz-edit/options/OptionEditor.js +70 -46
  32. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +174 -148
  33. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +175 -149
  34. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +164 -144
  35. package/cjs/components/material-quiz-edit/options/OptionText.js +90 -82
  36. package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
  37. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +156 -112
  38. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +288 -196
  39. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +88 -75
  40. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +108 -92
  41. package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
  42. package/cjs/components/material-quiz-edit/utils/editValue.js +21 -12
  43. package/cjs/components/shared/QuestionBox.js +198 -165
  44. package/cjs/components/shared/QuizDraggbleDroppedOption.js +11 -12
  45. package/cjs/components/shared/QuizDraggbleDummyOption.js +23 -16
  46. package/cjs/components/shared/QuizDraggbleOption.js +65 -59
  47. package/cjs/components/shared/StyledMarkdown.js +5 -1
  48. package/cjs/components/shared/index.js +19 -0
  49. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
  50. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  51. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
  52. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +59 -68
  53. package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
  54. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  55. package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
  56. package/cjs/components/shared/question-radio/QuestionRadioOption.js +52 -59
  57. package/cjs/components/shared/utils/getQuestionStatusStyle.js +7 -9
  58. package/cjs/components/shared/utils/mergeRefs.js +15 -6
  59. package/cjs/constant/element.js +3 -3
  60. package/cjs/constant/index.js +9 -0
  61. package/cjs/helpers/index.js +8 -10
  62. package/cjs/hooks/index.js +7 -0
  63. package/cjs/hooks/useCaculatePassage.js +21 -20
  64. package/es/_virtual/_rollupPluginBabelHelpers.js +408 -0
  65. package/es/components/eb-sortable/EbDraggable.js +37 -33
  66. package/es/components/eb-sortable/EbDroppable.js +22 -20
  67. package/es/components/markdown-editor/index.d.ts +1 -2
  68. package/es/components/markdown-editor/index.js +15 -10
  69. package/es/components/material-quiz/MaterialQuiz.js +109 -83
  70. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +32 -29
  71. package/es/components/material-quiz/MaterialQuizInfo.js +148 -150
  72. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +171 -127
  73. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +356 -287
  74. package/es/components/material-quiz/MaterialQuizSelectOne.js +168 -126
  75. package/es/components/material-quiz/MaterialQuizShimmer.js +42 -39
  76. package/es/components/material-quiz/MaterialQuizText.js +158 -115
  77. package/es/components/material-quiz/QuizResultBadge.js +27 -22
  78. package/es/components/material-quiz/QuizSubmitStatusText.js +17 -16
  79. package/es/components/material-quiz/constants/color.js +5 -5
  80. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  81. package/es/components/material-quiz/context/MaterialQuizContext.js +153 -94
  82. package/es/components/material-quiz/index.js +2 -0
  83. package/es/components/material-quiz/locales/index.js +4 -0
  84. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +253 -161
  85. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +129 -100
  86. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +125 -101
  87. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +60 -52
  88. package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
  89. package/es/components/material-quiz-edit/MaterialQuizEdit.js +43 -36
  90. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +272 -229
  91. package/es/components/material-quiz-edit/context.js +4 -2
  92. package/es/components/material-quiz-edit/index.js +1 -0
  93. package/es/components/material-quiz-edit/locales/index.js +4 -0
  94. package/es/components/material-quiz-edit/options/OptionEditor.js +64 -46
  95. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +170 -148
  96. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +171 -149
  97. package/es/components/material-quiz-edit/options/OptionSelectOne.js +159 -144
  98. package/es/components/material-quiz-edit/options/OptionText.js +86 -82
  99. package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +9 -8
  100. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +151 -112
  101. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +283 -197
  102. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +83 -75
  103. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +103 -92
  104. package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +5 -1
  105. package/es/components/material-quiz-edit/utils/editValue.js +17 -12
  106. package/es/components/shared/QuestionBox.js +192 -165
  107. package/es/components/shared/QuizDraggbleDroppedOption.js +11 -12
  108. package/es/components/shared/QuizDraggbleDummyOption.js +19 -16
  109. package/es/components/shared/QuizDraggbleOption.js +61 -59
  110. package/es/components/shared/StyledMarkdown.js +1 -1
  111. package/es/components/shared/index.js +7 -0
  112. package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
  113. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  114. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
  115. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +54 -68
  116. package/es/components/shared/question-radio/QuestionRadio.js +9 -7
  117. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  118. package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
  119. package/es/components/shared/question-radio/QuestionRadioOption.js +47 -59
  120. package/es/components/shared/utils/getQuestionStatusStyle.js +7 -9
  121. package/es/components/shared/utils/mergeRefs.js +15 -6
  122. package/es/constant/element.js +3 -3
  123. package/es/constant/index.js +1 -0
  124. package/es/helpers/index.js +8 -10
  125. package/es/hooks/index.js +1 -0
  126. package/es/hooks/useCaculatePassage.js +21 -20
  127. package/package.json +12 -15
@@ -2,6 +2,8 @@
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
7
  var React = require('react');
6
8
  var reactHookForm = require('react-hook-form');
7
9
  var reactTransitionGroup = require('react-transition-group');
@@ -20,26 +22,38 @@ var checkTwoDimensionArray = require('./utils/checkTwoDimensionArray.js');
20
22
  var randomId = require('./utils/randomId.js');
21
23
  var context = require('./context.js');
22
24
 
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']);
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];
37
51
  //
38
52
  // Change `options` according to `optionType`.
39
53
  //
40
- React.useEffect(() => {
41
- const get = () => {
42
- const filteredNotMarkdownOptions = watchedOptionInfo === null || watchedOptionInfo === void 0 ? void 0 : watchedOptionInfo.filter(option => {
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) {
43
57
  var _a;
44
58
  return !((_a = option.content) === null || _a === void 0 ? void 0 : _a.includes('![]'));
45
59
  });
@@ -68,7 +82,7 @@ const MaterialQuizEditContent = () => {
68
82
  }];
69
83
  }
70
84
  if (filteredNotMarkdownOptions.length) {
71
- return watchedOptionInfo.map(e => {
85
+ return watchedOptionInfo.map(function (e) {
72
86
  var _a;
73
87
  if ((_a = e.title) === null || _a === void 0 ? void 0 : _a.length) {
74
88
  return Object.assign(Object.assign({}, e), {
@@ -102,7 +116,7 @@ const MaterialQuizEditContent = () => {
102
116
  }];
103
117
  }
104
118
  if (filteredNotMarkdownOptions.length) {
105
- return watchedOptionInfo.map(e => {
119
+ return watchedOptionInfo.map(function (e) {
106
120
  var _a, _b;
107
121
  if (!((_a = e.content) === null || _a === void 0 ? void 0 : _a.includes('![]')) && !((_b = e.title) === null || _b === void 0 ? void 0 : _b.length)) {
108
122
  return Object.assign(Object.assign({}, e), {
@@ -127,16 +141,16 @@ const MaterialQuizEditContent = () => {
127
141
  //
128
142
  // Change `answerInfo` according to `optionType`.
129
143
  //
130
- React.useEffect(() => {
131
- const get = () => {
144
+ React__default.default.useEffect(function () {
145
+ var get = function get() {
132
146
  switch (watchedOptionType) {
133
147
  case types.enums.QuizOptionType.SelectOne:
134
148
  if (!Array.isArray(watchedAnswerInfo)) {
135
149
  return [0];
136
150
  }
137
151
  if (checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
138
- const convertedAnswerInfo = watchedAnswerInfo;
139
- return flattenDeep(convertedAnswerInfo).slice(0, 1);
152
+ var convertedAnswerInfo = watchedAnswerInfo;
153
+ return flattenDeep__default.default(convertedAnswerInfo).slice(0, 1);
140
154
  }
141
155
  return watchedAnswerInfo.slice(0, 1);
142
156
  case types.enums.QuizOptionType.SelectMultiple:
@@ -145,7 +159,7 @@ const MaterialQuizEditContent = () => {
145
159
  return [0];
146
160
  }
147
161
  if (checkTwoDimensionArray.checkTwoDimensionArray(watchedAnswerInfo)) {
148
- return flattenDeep(watchedAnswerInfo);
162
+ return flattenDeep__default.default(watchedAnswerInfo);
149
163
  }
150
164
  return watchedAnswerInfo;
151
165
  case types.enums.QuizOptionType.Text:
@@ -163,8 +177,8 @@ const MaterialQuizEditContent = () => {
163
177
  //
164
178
  // Change `answerHint` according to `optionType`.
165
179
  //
166
- React.useEffect(() => {
167
- const get = () => {
180
+ React__default.default.useEffect(function () {
181
+ var get = function get() {
168
182
  switch (watchedOptionType) {
169
183
  case types.enums.QuizOptionType.SelectOne:
170
184
  case types.enums.QuizOptionType.SelectMultiple:
@@ -184,8 +198,8 @@ const MaterialQuizEditContent = () => {
184
198
  //
185
199
  // Change `isAutoGrade` according to `optionType`.
186
200
  //
187
- React.useEffect(() => {
188
- const get = () => {
201
+ React__default.default.useEffect(function () {
202
+ var get = function get() {
189
203
  switch (watchedOptionType) {
190
204
  case types.enums.QuizOptionType.SelectOne:
191
205
  case types.enums.QuizOptionType.SelectMultiple:
@@ -205,8 +219,8 @@ const MaterialQuizEditContent = () => {
205
219
  //
206
220
  // Change `groups` according to `optionType`.
207
221
  //
208
- React.useEffect(() => {
209
- const get = () => {
222
+ React__default.default.useEffect(function () {
223
+ var get = function get() {
210
224
  switch (watchedOptionType) {
211
225
  case types.enums.QuizOptionType.SelectOne:
212
226
  case types.enums.QuizOptionType.SelectMultiple:
@@ -241,7 +255,7 @@ const MaterialQuizEditContent = () => {
241
255
  * Input of option info and answer info,
242
256
  * according to option type.
243
257
  */
244
- const Option = React.useMemo(() => {
258
+ var Option = React__default.default.useMemo(function () {
245
259
  switch (watchedOptionType) {
246
260
  case types.enums.QuizOptionType.SelectOne:
247
261
  return OptionSelectOne.default;
@@ -254,21 +268,22 @@ const MaterialQuizEditContent = () => {
254
268
  case types.enums.QuizOptionType.Text:
255
269
  return OptionText.default;
256
270
  default:
257
- return React.Fragment;
271
+ return React__default.default.Fragment;
258
272
  }
259
273
  }, [watchedOptionType]);
260
274
  /**
261
275
  * Render input for quiz title.
262
276
  */
263
- const renderQuestionTitleInput = () => {
264
- return React.createElement(blocks.FormInputVerticalLayout, {
265
- label: React.createElement(blocks.Label, {
277
+ var renderQuestionTitleInput = function renderQuestionTitleInput() {
278
+ return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
279
+ label: jsxRuntime.jsx(blocks.Label, {
266
280
  size: "small",
267
- required: true
268
- }, intl$1.formatMessage({
269
- id: 'content.title'
270
- })),
271
- input: React.createElement(reactHookForm.Controller, {
281
+ required: true,
282
+ children: intl$1.formatMessage({
283
+ id: 'content.title'
284
+ })
285
+ }),
286
+ input: jsxRuntime.jsx(reactHookForm.Controller, {
272
287
  control: control,
273
288
  name: "questionTitle",
274
289
  rules: {
@@ -297,12 +312,11 @@ const MaterialQuizEditContent = () => {
297
312
  })
298
313
  }
299
314
  },
300
- render: ({
301
- field,
302
- fieldState
303
- }) => {
315
+ render: function render(_ref) {
316
+ var field = _ref.field,
317
+ fieldState = _ref.fieldState;
304
318
  var _a;
305
- return React.createElement(blocks.Input, Object.assign({
319
+ return jsxRuntime.jsx(blocks.Input, Object.assign({
306
320
  size: "small",
307
321
  width: "full",
308
322
  minLength: MIN_TEXT_LENGTH,
@@ -320,149 +334,169 @@ const MaterialQuizEditContent = () => {
320
334
  /**
321
335
  * Render input for quiz description.
322
336
  */
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, {
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, {
331
346
  control: control,
332
347
  name: "questionDescription",
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))
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
+ }
341
357
  })
342
358
  });
343
359
  };
344
360
  /**
345
361
  * Render input of option type, option info and answer info.
346
362
  */
347
- const renderOptionInput = () => {
348
- return React.createElement(blocks.FormInputVerticalLayout, {
349
- label: React.createElement(blocks.Label, {
363
+ var renderOptionInput = function renderOptionInput() {
364
+ return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
365
+ label: jsxRuntime.jsx(blocks.Label, {
350
366
  size: "small",
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);
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
+ });
379
448
  }
380
- }), React.createElement(material.MenuItem, {
381
- value: types.enums.QuizOptionType.SelectOne,
382
- children: intl$1.formatMessage({
383
- id: 'content.option.select.items.selectOne'
384
- })
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'
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
+ })
404
475
  })
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))
476
+ }), jsxRuntime.jsx(Option, {})]
477
+ })
447
478
  });
448
479
  };
449
480
  /**
450
481
  * Input of answer hint.
451
482
  */
452
- const renderAnswerHintInput = () => {
483
+ var renderAnswerHintInput = function renderAnswerHintInput() {
453
484
  if (watchedOptionType !== types.enums.QuizOptionType.Text) {
454
485
  return null;
455
486
  }
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, {
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, {
466
500
  control: control,
467
501
  name: "answerHint",
468
502
  rules: {
@@ -485,12 +519,11 @@ const MaterialQuizEditContent = () => {
485
519
  })
486
520
  }
487
521
  },
488
- render: ({
489
- field,
490
- fieldState
491
- }) => {
522
+ render: function render(_ref5) {
523
+ var field = _ref5.field,
524
+ fieldState = _ref5.fieldState;
492
525
  var _a, _b;
493
- return React.createElement(blocks.Input, Object.assign({
526
+ return jsxRuntime.jsx(blocks.Input, Object.assign({
494
527
  size: "small",
495
528
  width: "full",
496
529
  minLength: MIN_TEXT_LENGTH,
@@ -510,70 +543,85 @@ const MaterialQuizEditContent = () => {
510
543
  /**
511
544
  * Input of explanation info.
512
545
  */
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
- })
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
+ }));
549
572
  }
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
- }))))
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
+ })
571
617
  });
572
618
  };
573
619
  //
574
620
  //
575
621
  //
576
- return React.createElement(React.Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput());
622
+ return jsxRuntime.jsxs(jsxRuntime.Fragment, {
623
+ children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput(), renderAnswerHintInput(), renderExplanationInfoInput()]
624
+ });
577
625
  };
578
626
 
579
627
  exports.default = MaterialQuizEditContent;