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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/cjs/components/eb-sortable/EbDraggable.js +33 -42
  2. package/cjs/components/eb-sortable/EbDroppable.js +20 -27
  3. package/cjs/components/markdown-editor/index.d.ts +2 -1
  4. package/cjs/components/markdown-editor/index.js +10 -19
  5. package/cjs/components/material-quiz/MaterialQuiz.js +83 -114
  6. package/cjs/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -36
  7. package/cjs/components/material-quiz/MaterialQuizInfo.js +149 -151
  8. package/cjs/components/material-quiz/MaterialQuizSelectMultiple.js +127 -175
  9. package/cjs/components/material-quiz/MaterialQuizSelectMultipleOrder.js +286 -360
  10. package/cjs/components/material-quiz/MaterialQuizSelectOne.js +126 -172
  11. package/cjs/components/material-quiz/MaterialQuizShimmer.js +39 -46
  12. package/cjs/components/material-quiz/MaterialQuizText.js +115 -163
  13. package/cjs/components/material-quiz/QuizResultBadge.js +22 -32
  14. package/cjs/components/material-quiz/QuizSubmitStatusText.js +16 -21
  15. package/cjs/components/material-quiz/constants/color.js +5 -5
  16. package/cjs/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  17. package/cjs/components/material-quiz/context/MaterialQuizContext.js +93 -156
  18. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -259
  19. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -134
  20. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -130
  21. package/cjs/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -64
  22. package/cjs/components/material-quiz/material-quiz-group/context/context.js +1 -5
  23. package/cjs/components/material-quiz-edit/MaterialQuizEdit.js +36 -47
  24. package/cjs/components/material-quiz-edit/MaterialQuizEditContent.js +232 -280
  25. package/cjs/components/material-quiz-edit/context.js +2 -8
  26. package/cjs/components/material-quiz-edit/options/OptionEditor.js +46 -70
  27. package/cjs/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -174
  28. package/cjs/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -175
  29. package/cjs/components/material-quiz-edit/options/OptionSelectOne.js +144 -164
  30. package/cjs/components/material-quiz-edit/options/OptionText.js +82 -90
  31. package/cjs/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  32. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -156
  33. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +196 -288
  34. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -88
  35. package/cjs/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -108
  36. package/cjs/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  37. package/cjs/components/material-quiz-edit/utils/editValue.js +12 -21
  38. package/cjs/components/shared/QuestionBox.js +165 -198
  39. package/cjs/components/shared/QuizDraggbleDroppedOption.js +12 -11
  40. package/cjs/components/shared/QuizDraggbleDummyOption.js +16 -23
  41. package/cjs/components/shared/QuizDraggbleOption.js +59 -65
  42. package/cjs/components/shared/StyledMarkdown.js +1 -5
  43. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
  44. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  45. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
  46. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -59
  47. package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
  48. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  49. package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
  50. package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -52
  51. package/cjs/components/shared/utils/getQuestionStatusStyle.js +9 -7
  52. package/cjs/components/shared/utils/mergeRefs.js +6 -15
  53. package/cjs/constant/element.js +3 -3
  54. package/cjs/helpers/index.js +10 -8
  55. package/cjs/hooks/useCaculatePassage.js +20 -21
  56. package/es/components/eb-sortable/EbDraggable.js +33 -37
  57. package/es/components/eb-sortable/EbDroppable.js +20 -22
  58. package/es/components/markdown-editor/index.d.ts +2 -1
  59. package/es/components/markdown-editor/index.js +10 -15
  60. package/es/components/material-quiz/MaterialQuiz.js +83 -109
  61. package/es/components/material-quiz/MaterialQuizAnswerExplanation.js +29 -32
  62. package/es/components/material-quiz/MaterialQuizInfo.js +150 -148
  63. package/es/components/material-quiz/MaterialQuizSelectMultiple.js +127 -171
  64. package/es/components/material-quiz/MaterialQuizSelectMultipleOrder.js +287 -356
  65. package/es/components/material-quiz/MaterialQuizSelectOne.js +126 -168
  66. package/es/components/material-quiz/MaterialQuizShimmer.js +39 -42
  67. package/es/components/material-quiz/MaterialQuizText.js +115 -158
  68. package/es/components/material-quiz/QuizResultBadge.js +22 -27
  69. package/es/components/material-quiz/QuizSubmitStatusText.js +16 -17
  70. package/es/components/material-quiz/constants/color.js +5 -5
  71. package/es/components/material-quiz/context/MaterialQuizContext.d.ts +1 -1
  72. package/es/components/material-quiz/context/MaterialQuizContext.js +94 -153
  73. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroup.js +161 -253
  74. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupDesktop.js +100 -129
  75. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupMobile.js +101 -125
  76. package/es/components/material-quiz/material-quiz-group/MaterialQuizGroupOptionItem.js +52 -60
  77. package/es/components/material-quiz/material-quiz-group/context/context.js +1 -1
  78. package/es/components/material-quiz-edit/MaterialQuizEdit.js +36 -43
  79. package/es/components/material-quiz-edit/MaterialQuizEditContent.js +229 -272
  80. package/es/components/material-quiz-edit/context.js +2 -4
  81. package/es/components/material-quiz-edit/options/OptionEditor.js +46 -64
  82. package/es/components/material-quiz-edit/options/OptionSelectMultiple.js +148 -170
  83. package/es/components/material-quiz-edit/options/OptionSelectMultipleOrder.js +149 -171
  84. package/es/components/material-quiz-edit/options/OptionSelectOne.js +144 -159
  85. package/es/components/material-quiz-edit/options/OptionText.js +82 -86
  86. package/es/components/material-quiz-edit/options/options-group/OptionGroup.js +8 -9
  87. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerInfo.js +112 -151
  88. package/es/components/material-quiz-edit/options/options-group/OptionGroupAnswerListItem.js +197 -283
  89. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupInfo.js +75 -83
  90. package/es/components/material-quiz-edit/options/options-group/OptionGroupGroupListItem.js +92 -103
  91. package/es/components/material-quiz-edit/utils/checkTwoDimensionArray.js +1 -5
  92. package/es/components/material-quiz-edit/utils/editValue.js +12 -17
  93. package/es/components/shared/QuestionBox.js +165 -192
  94. package/es/components/shared/QuizDraggbleDroppedOption.js +12 -11
  95. package/es/components/shared/QuizDraggbleDummyOption.js +16 -19
  96. package/es/components/shared/QuizDraggbleOption.js +59 -61
  97. package/es/components/shared/StyledMarkdown.js +1 -1
  98. package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
  99. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  100. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
  101. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +68 -54
  102. package/es/components/shared/question-radio/QuestionRadio.js +7 -9
  103. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  104. package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
  105. package/es/components/shared/question-radio/QuestionRadioOption.js +59 -47
  106. package/es/components/shared/utils/getQuestionStatusStyle.js +9 -7
  107. package/es/components/shared/utils/mergeRefs.js +6 -15
  108. package/es/constant/element.js +3 -3
  109. package/es/helpers/index.js +10 -8
  110. package/es/hooks/useCaculatePassage.js +20 -21
  111. package/package.json +15 -12
  112. package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -423
  113. package/cjs/components/material-quiz/index.js +0 -9
  114. package/cjs/components/material-quiz/locales/index.js +0 -13
  115. package/cjs/components/material-quiz-edit/index.js +0 -7
  116. package/cjs/components/material-quiz-edit/locales/index.js +0 -13
  117. package/cjs/components/shared/index.js +0 -19
  118. package/cjs/constant/index.js +0 -9
  119. package/cjs/hooks/index.js +0 -7
  120. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -408
  121. package/es/components/material-quiz/index.js +0 -2
  122. package/es/components/material-quiz/locales/index.js +0 -4
  123. package/es/components/material-quiz-edit/index.js +0 -1
  124. package/es/components/material-quiz-edit/locales/index.js +0 -4
  125. package/es/components/shared/index.js +0 -7
  126. package/es/constant/index.js +0 -1
  127. package/es/hooks/index.js +0 -1
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var jsxRuntime = require('react/jsx-runtime');
6
5
  var React = require('react');
7
6
  var reactHookForm = require('react-hook-form');
8
7
  var reactSortableHoc = require('react-sortable-hoc');
@@ -16,52 +15,50 @@ var context = require('../context.js');
16
15
  var randomId = require('../utils/randomId.js');
17
16
  var OptionEditor = require('./OptionEditor.js');
18
17
 
19
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
20
-
21
- var React__default = /*#__PURE__*/_interopDefaultCompat(React);
22
- var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
23
-
24
- var MIN_OPTION_INFO_COUNT = 2;
25
- var MAX_OPTION_INFO_COUNT = 20;
26
- var StyledWrap = styled__default.default.div.withConfig({
18
+ const MIN_OPTION_INFO_COUNT = 2;
19
+ const MAX_OPTION_INFO_COUNT = 20;
20
+ const StyledWrap = styled.div.withConfig({
27
21
  componentId: "sc-vizer2-0"
28
22
  })(["& > ul{display:flex;flex-direction:column;gap:0.75rem;}"]);
29
- var StyledInputGroup = styled__default.default(blocks.SortableListGroup).withConfig({
23
+ const StyledInputGroup = styled(blocks.SortableListGroup).withConfig({
30
24
  componentId: "sc-vizer2-1"
31
25
  })(["width:100%;.em-option-editor{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
32
- var StyledInputPrefixRadioOption = styled__default.default(blocks.RadioOption).withConfig({
26
+ const StyledInputPrefixRadioOption = styled(blocks.RadioOption).withConfig({
33
27
  componentId: "sc-vizer2-2"
34
28
  })([".eb-radio-option__label{display:none;}"]);
35
- var OptionSelectOne = function OptionSelectOne() {
36
- var intl$1 = intl.useRawEliceIntl();
37
- var _useMaterialQuizEditC = context.useMaterialQuizEditContext(),
38
- disabled = _useMaterialQuizEditC.disabled;
39
- var _useFormContext = reactHookForm.useFormContext(),
40
- control = _useFormContext.control,
41
- getValues = _useFormContext.getValues,
42
- setValue = _useFormContext.setValue;
43
- var _useFieldArray = reactHookForm.useFieldArray({
44
- name: 'optionsDefault',
45
- keyName: 'id',
46
- shouldUnregister: true
47
- }),
48
- optionInfoFields = _useFieldArray.fields,
49
- appendOptionInfoFieldItem = _useFieldArray.append,
50
- removeOptionInfoFieldItem = _useFieldArray.remove,
51
- moveOptionInfoFieldItem = _useFieldArray.move;
52
- var watchedAnswerInfo = reactHookForm.useWatch({
53
- control: control,
29
+ const OptionSelectOne = () => {
30
+ const intl$1 = intl.useRawEliceIntl();
31
+ const {
32
+ disabled
33
+ } = context.useMaterialQuizEditContext();
34
+ const {
35
+ control,
36
+ getValues,
37
+ setValue
38
+ } = reactHookForm.useFormContext();
39
+ const {
40
+ fields: optionInfoFields,
41
+ append: appendOptionInfoFieldItem,
42
+ remove: removeOptionInfoFieldItem,
43
+ move: moveOptionInfoFieldItem
44
+ } = reactHookForm.useFieldArray({
45
+ name: 'optionsDefault',
46
+ keyName: 'id',
47
+ shouldUnregister: true
48
+ });
49
+ const watchedAnswerInfo = reactHookForm.useWatch({
50
+ control,
54
51
  name: 'answerInfoDefault'
55
52
  });
56
- var watchedOptions = reactHookForm.useWatch({
57
- control: control,
53
+ const watchedOptions = reactHookForm.useWatch({
54
+ control,
58
55
  name: 'optionsDefault'
59
56
  });
60
57
  /**
61
58
  * Update answer info.
62
59
  */
63
- var updateAnswerInfo = function updateAnswerInfo(index) {
64
- var prevAnswerInfo = getValues('answerInfoDefault');
60
+ const updateAnswerInfo = index => {
61
+ const prevAnswerInfo = getValues('answerInfoDefault');
65
62
  if (!Array.isArray(prevAnswerInfo)) {
66
63
  return;
67
64
  }
@@ -73,7 +70,7 @@ var OptionSelectOne = function OptionSelectOne() {
73
70
  /**
74
71
  * Append option info.
75
72
  */
76
- var appendOptionInfo = function appendOptionInfo() {
73
+ const appendOptionInfo = () => {
77
74
  appendOptionInfoFieldItem({
78
75
  id: randomId.createRandomId(),
79
76
  title: '',
@@ -83,10 +80,10 @@ var OptionSelectOne = function OptionSelectOne() {
83
80
  /**
84
81
  * Remove item from option info at index.
85
82
  */
86
- var removeOptionInfo = function removeOptionInfo(index) {
83
+ const removeOptionInfo = index => {
87
84
  // set answer info to 0 index,
88
85
  // if this option is selected as answer.
89
- var curAnswerInfo = getValues('answerInfoDefault');
86
+ const curAnswerInfo = getValues('answerInfoDefault');
90
87
  if (Array.isArray(curAnswerInfo) && curAnswerInfo.includes(index)) {
91
88
  updateAnswerInfo(0);
92
89
  }
@@ -95,19 +92,16 @@ var OptionSelectOne = function OptionSelectOne() {
95
92
  /**
96
93
  * Sort options based on the old and new index.
97
94
  */
98
- var handleSortEnd = function handleSortEnd(_ref) {
99
- var oldIndex = _ref.oldIndex,
100
- newIndex = _ref.newIndex;
101
- var prevAnswerInfo = lodashEs.cloneDeep(watchedAnswerInfo);
102
- var prevOptions = lodashEs.cloneDeep(watchedOptions).map(function (option, index) {
103
- return Object.assign(Object.assign({}, option), {
104
- isAnswer: prevAnswerInfo.includes(index)
105
- });
106
- });
107
- var updatedOptions = reactSortableHoc.arrayMove(prevOptions, oldIndex, newIndex);
108
- var updatedAnswer = updatedOptions.findIndex(function (option) {
109
- return option.isAnswer;
110
- });
95
+ const handleSortEnd = ({
96
+ oldIndex,
97
+ newIndex
98
+ }) => {
99
+ const prevAnswerInfo = lodashEs.cloneDeep(watchedAnswerInfo);
100
+ const prevOptions = lodashEs.cloneDeep(watchedOptions).map((option, index) => Object.assign(Object.assign({}, option), {
101
+ isAnswer: prevAnswerInfo.includes(index)
102
+ }));
103
+ const updatedOptions = reactSortableHoc.arrayMove(prevOptions, oldIndex, newIndex);
104
+ const updatedAnswer = updatedOptions.findIndex(option => option.isAnswer);
111
105
  setValue('answerInfoDefault', [updatedAnswer]);
112
106
  moveOptionInfoFieldItem(oldIndex, newIndex);
113
107
  };
@@ -117,123 +111,109 @@ var OptionSelectOne = function OptionSelectOne() {
117
111
  if (!Array.isArray(watchedAnswerInfo)) {
118
112
  return null;
119
113
  }
120
- return jsxRuntime.jsxs(StyledWrap, {
121
- children: [jsxRuntime.jsx(reactHookForm.Controller, {
122
- name: "answerInfoDefault",
123
- control: control,
124
- rules: {
125
- validate: function validate(v) {
126
- if (Array.isArray(v) && v.length < 1) {
127
- return intl$1.formatMessage({
128
- id: 'content.option.errorMessage.required'
129
- });
130
- }
131
- return true;
114
+ return React.createElement(StyledWrap, null, React.createElement(reactHookForm.Controller, {
115
+ name: "answerInfoDefault",
116
+ control: control,
117
+ rules: {
118
+ validate: v => {
119
+ if (Array.isArray(v) && v.length < 1) {
120
+ return intl$1.formatMessage({
121
+ id: 'content.option.errorMessage.required'
122
+ });
132
123
  }
133
- },
134
- render: function render(_ref2) {
135
- var fieldState = _ref2.fieldState;
136
- var _a;
137
- return jsxRuntime.jsx(reactTransitionGroup.Transition, {
138
- in: fieldState.invalid,
139
- timeout: 0,
140
- mountOnEnter: true,
141
- unmountOnExit: true,
142
- children: jsxRuntime.jsxs(jsxRuntime.Fragment, {
143
- children: [jsxRuntime.jsx(blocks.StatusText, {
144
- children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
145
- role: "danger"
146
- }), jsxRuntime.jsx(blocks.Vspace, {
147
- height: 0.5
148
- })]
149
- })
150
- });
124
+ return true;
151
125
  }
152
- }), jsxRuntime.jsx(StyledInputGroup, {
153
- useDragHandle: true,
154
- pressDelay: 100,
155
- onSortEnd: handleSortEnd,
156
- children: optionInfoFields.map(function (_ref3, index) {
157
- var id = _ref3.id;
158
- return jsxRuntime.jsx(reactHookForm.Controller, {
159
- control: control,
160
- name: "optionsDefault.".concat(index, ".content"),
161
- rules: {
162
- required: {
163
- value: true,
164
- message: intl$1.formatMessage({
165
- id: 'option.common.select.errorMessage.required'
166
- })
167
- }
168
- },
169
- render: function render(_ref4) {
170
- var field = _ref4.field,
171
- fieldState = _ref4.fieldState;
172
- var _a;
173
- return jsxRuntime.jsx(OptionEditor.default, Object.assign({
174
- index: index,
175
- invalid: fieldState.invalid,
176
- invalidText: (_a = fieldState === null || fieldState === void 0 ? void 0 : fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
177
- placeholder: intl$1.formatMessage({
178
- id: 'option.common.select.placeholder'
179
- }),
180
- readOnly: disabled,
181
- prefix: jsxRuntime.jsxs(blocks.Radio, {
182
- value: watchedAnswerInfo[0],
183
- disabled: disabled,
184
- onChange: updateAnswerInfo,
185
- children: [jsxRuntime.jsx(StyledInputPrefixRadioOption, {
186
- value: index
187
- }), jsxRuntime.jsx(React__default.default.Fragment, {})]
188
- }),
189
- suffix: jsxRuntime.jsx(blocks.Tooltip, {
190
- title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
191
- id: 'option.common.select.tooltip.minOptionInfoItem'
192
- }) : undefined,
193
- placement: "top-start",
194
- children: jsxRuntime.jsx("span", {
195
- children: jsxRuntime.jsx(blocks.IconButton, {
196
- icon: icons.eilMathsignMultiplyBasic,
197
- size: "tiny",
198
- role: "grey9",
199
- border: false,
200
- transparent: true,
201
- disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
202
- onClick: function onClick() {
203
- return removeOptionInfo(index);
204
- }
205
- })
206
- })
207
- })
208
- }, field));
209
- }
210
- }, id);
211
- })
212
- }), jsxRuntime.jsx(blocks.Vspace, {
213
- height: 0.5
214
- }), jsxRuntime.jsx(blocks.Tooltip, {
215
- title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
216
- id: 'option.common.select.tooltip.maxOptionInfoItem'
217
- }) : undefined,
218
- placement: "bottom",
219
- children: jsxRuntime.jsx("span", {
220
- children: jsxRuntime.jsx(blocks.Button, {
221
- block: true,
222
- size: "micro",
223
- borderDashed: true,
224
- transparent: true,
225
- icon: jsxRuntime.jsx(blocks.Icon, {
226
- icon: icons.eilMathsignAddCircle
227
- }),
228
- disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
229
- onClick: appendOptionInfo,
230
- children: intl$1.formatMessage({
231
- id: 'option.common.select.addButton'
232
- })
126
+ },
127
+ render: ({
128
+ fieldState
129
+ }) => {
130
+ var _a;
131
+ return React.createElement(reactTransitionGroup.Transition, {
132
+ in: fieldState.invalid,
133
+ timeout: 0,
134
+ mountOnEnter: true,
135
+ unmountOnExit: true
136
+ }, React.createElement(React.Fragment, null, React.createElement(blocks.StatusText, {
137
+ children: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
138
+ role: "danger"
139
+ }), React.createElement(blocks.Vspace, {
140
+ height: 0.5
141
+ })));
142
+ }
143
+ }), React.createElement(StyledInputGroup, {
144
+ useDragHandle: true,
145
+ pressDelay: 100,
146
+ onSortEnd: handleSortEnd
147
+ }, optionInfoFields.map(({
148
+ id
149
+ }, index) => React.createElement(reactHookForm.Controller, {
150
+ key: id,
151
+ control: control,
152
+ name: `optionsDefault.${index}.content`,
153
+ rules: {
154
+ required: {
155
+ value: true,
156
+ message: intl$1.formatMessage({
157
+ id: 'option.common.select.errorMessage.required'
233
158
  })
234
- })
235
- })]
236
- });
159
+ }
160
+ },
161
+ render: ({
162
+ field,
163
+ fieldState
164
+ }) => {
165
+ var _a;
166
+ return React.createElement(OptionEditor.default, Object.assign({
167
+ index: index,
168
+ invalid: fieldState.invalid,
169
+ invalidText: (_a = fieldState === null || fieldState === void 0 ? void 0 : fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
170
+ placeholder: intl$1.formatMessage({
171
+ id: 'option.common.select.placeholder'
172
+ }),
173
+ readOnly: disabled,
174
+ prefix: React.createElement(blocks.Radio, {
175
+ value: watchedAnswerInfo[0],
176
+ disabled: disabled,
177
+ onChange: updateAnswerInfo
178
+ }, React.createElement(StyledInputPrefixRadioOption, {
179
+ value: index
180
+ }), React.createElement(React.Fragment, null)),
181
+ suffix: React.createElement(blocks.Tooltip, {
182
+ title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
183
+ id: 'option.common.select.tooltip.minOptionInfoItem'
184
+ }) : undefined,
185
+ placement: "top-start"
186
+ }, React.createElement("span", null, React.createElement(blocks.IconButton, {
187
+ icon: icons.eilMathsignMultiplyBasic,
188
+ size: "tiny",
189
+ role: "grey9",
190
+ border: false,
191
+ transparent: true,
192
+ disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
193
+ onClick: () => removeOptionInfo(index)
194
+ })))
195
+ }, field));
196
+ }
197
+ }))), React.createElement(blocks.Vspace, {
198
+ height: 0.5
199
+ }), React.createElement(blocks.Tooltip, {
200
+ title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
201
+ id: 'option.common.select.tooltip.maxOptionInfoItem'
202
+ }) : undefined,
203
+ placement: "bottom"
204
+ }, React.createElement("span", null, React.createElement(blocks.Button, {
205
+ block: true,
206
+ size: "micro",
207
+ borderDashed: true,
208
+ transparent: true,
209
+ icon: React.createElement(blocks.Icon, {
210
+ icon: icons.eilMathsignAddCircle
211
+ }),
212
+ disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
213
+ onClick: appendOptionInfo
214
+ }, intl$1.formatMessage({
215
+ id: 'option.common.select.addButton'
216
+ })))));
237
217
  };
238
218
 
239
219
  exports.default = OptionSelectOne;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _styled = require('@emotion/styled/base');
6
- var jsxRuntime = require('react/jsx-runtime');
6
+ var React = require('react');
7
7
  var reactHookForm = require('react-hook-form');
8
8
  var blocks = require('@elice/blocks');
9
9
  var designTokens = require('@elice/design-tokens');
@@ -11,112 +11,104 @@ var intl = require('@elice/intl');
11
11
  var react = require('@emotion/react');
12
12
  var context = require('../context.js');
13
13
 
14
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
15
-
16
- var _styled__default = /*#__PURE__*/_interopDefaultCompat(_styled);
17
-
18
14
  //
19
15
  //
20
16
  //
21
- var MIN_TEXT_LENGTH = 1;
22
- var MAX_TEXT_LENGTH = 128;
17
+ const MIN_TEXT_LENGTH = 1;
18
+ const MAX_TEXT_LENGTH = 128;
23
19
  //
24
20
  //
25
21
  //
26
- var StyledInput = /*#__PURE__*/_styled__default.default(blocks.Input, {
22
+ const StyledInput = /*#__PURE__*/_styled(blocks.Input, {
27
23
  target: "edimfaf0"
28
- })("&>:first-child{", function (_ref) {
29
- var disabled = _ref.disabled;
30
- return disabled && /*#__PURE__*/react.css("background-color:", designTokens.base.color.gray2, ";");
31
- }, ";}");
24
+ })("&>:first-child{", ({
25
+ disabled
26
+ }) => disabled && /*#__PURE__*/react.css("background-color:", designTokens.base.color.gray2, ";"), ";}");
32
27
  //
33
28
  //
34
29
  //
35
- var OptionText = function OptionText() {
36
- var intl$1 = intl.useRawEliceIntl();
37
- var _useMaterialQuizEditC = context.useMaterialQuizEditContext(),
38
- disabled = _useMaterialQuizEditC.disabled;
39
- var _useFormContext = reactHookForm.useFormContext(),
40
- control = _useFormContext.control;
41
- var watchedIsAutoGrade = reactHookForm.useWatch({
42
- control: control,
30
+ const OptionText = () => {
31
+ const intl$1 = intl.useRawEliceIntl();
32
+ const {
33
+ disabled
34
+ } = context.useMaterialQuizEditContext();
35
+ const {
36
+ control
37
+ } = reactHookForm.useFormContext();
38
+ const watchedIsAutoGrade = reactHookForm.useWatch({
39
+ control,
43
40
  name: 'isAutoGrade'
44
41
  });
45
42
  //
46
43
  //
47
44
  //
48
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
49
- children: [jsxRuntime.jsx(reactHookForm.Controller, {
50
- control: control,
51
- name: "answerInfoDefault",
52
- rules: {
53
- required: {
54
- value: watchedIsAutoGrade,
55
- message: intl$1.formatMessage({
56
- id: 'option.text.answerInfo.errorMessage.required'
57
- })
58
- },
59
- minLength: {
60
- value: MIN_TEXT_LENGTH,
61
- message: intl$1.formatMessage({
62
- id: 'common.errorMessage.range'
63
- }, {
64
- min: MIN_TEXT_LENGTH,
65
- max: MAX_TEXT_LENGTH
66
- })
67
- },
68
- maxLength: {
69
- value: MAX_TEXT_LENGTH,
70
- message: intl$1.formatMessage({
71
- id: 'common.errorMessage.range'
72
- }, {
73
- min: MIN_TEXT_LENGTH,
74
- max: MAX_TEXT_LENGTH
75
- })
76
- }
45
+ return React.createElement(React.Fragment, null, React.createElement(reactHookForm.Controller, {
46
+ control: control,
47
+ name: "answerInfoDefault",
48
+ rules: {
49
+ required: {
50
+ value: watchedIsAutoGrade,
51
+ message: intl$1.formatMessage({
52
+ id: 'option.text.answerInfo.errorMessage.required'
53
+ })
77
54
  },
78
- render: function render(_ref2) {
79
- var field = _ref2.field,
80
- fieldState = _ref2.fieldState;
81
- var _a;
82
- return jsxRuntime.jsx(StyledInput, Object.assign({
83
- size: "small",
84
- width: "full",
85
- minLength: MIN_TEXT_LENGTH,
86
- maxLength: MAX_TEXT_LENGTH,
87
- readOnly: disabled,
88
- disabled: !watchedIsAutoGrade,
89
- invalid: fieldState.invalid,
90
- invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
91
- helpText: intl$1.formatMessage({
92
- id: 'option.text.answerInfo.hintText'
93
- })
94
- }, field, {
95
- value: field.value
96
- }));
97
- }
98
- }), jsxRuntime.jsx(blocks.Vspace, {
99
- height: 0.5
100
- }), jsxRuntime.jsx(reactHookForm.Controller, {
101
- control: control,
102
- name: "isAutoGrade",
103
- render: function render(_ref3) {
104
- var field = _ref3.field;
105
- return jsxRuntime.jsx(blocks.Checkbox, Object.assign({
106
- size: "small"
107
- }, field, {
108
- value: !field.value,
109
- checked: !field.value,
110
- onChange: function onChange(v) {
111
- return field.onChange(!v);
112
- },
113
- children: intl$1.formatMessage({
114
- id: 'option.text.isAutoGrade.checkbox.label'
115
- })
116
- }));
55
+ minLength: {
56
+ value: MIN_TEXT_LENGTH,
57
+ message: intl$1.formatMessage({
58
+ id: 'common.errorMessage.range'
59
+ }, {
60
+ min: MIN_TEXT_LENGTH,
61
+ max: MAX_TEXT_LENGTH
62
+ })
63
+ },
64
+ maxLength: {
65
+ value: MAX_TEXT_LENGTH,
66
+ message: intl$1.formatMessage({
67
+ id: 'common.errorMessage.range'
68
+ }, {
69
+ min: MIN_TEXT_LENGTH,
70
+ max: MAX_TEXT_LENGTH
71
+ })
117
72
  }
118
- })]
119
- });
73
+ },
74
+ render: ({
75
+ field,
76
+ fieldState
77
+ }) => {
78
+ var _a;
79
+ return React.createElement(StyledInput, Object.assign({
80
+ size: "small",
81
+ width: "full",
82
+ minLength: MIN_TEXT_LENGTH,
83
+ maxLength: MAX_TEXT_LENGTH,
84
+ readOnly: disabled,
85
+ disabled: !watchedIsAutoGrade,
86
+ invalid: fieldState.invalid,
87
+ invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message,
88
+ helpText: intl$1.formatMessage({
89
+ id: 'option.text.answerInfo.hintText'
90
+ })
91
+ }, field, {
92
+ value: field.value
93
+ }));
94
+ }
95
+ }), React.createElement(blocks.Vspace, {
96
+ height: 0.5
97
+ }), React.createElement(reactHookForm.Controller, {
98
+ control: control,
99
+ name: "isAutoGrade",
100
+ render: ({
101
+ field
102
+ }) => React.createElement(blocks.Checkbox, Object.assign({
103
+ size: "small"
104
+ }, field, {
105
+ value: !field.value,
106
+ checked: !field.value,
107
+ onChange: v => field.onChange(!v)
108
+ }), intl$1.formatMessage({
109
+ id: 'option.text.isAutoGrade.checkbox.label'
110
+ }))
111
+ }));
120
112
  };
121
113
 
122
114
  exports.default = OptionText;
@@ -2,23 +2,22 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var jsxRuntime = require('react/jsx-runtime');
5
+ var React = require('react');
6
6
  var blocks = require('@elice/blocks');
7
7
  var OptionGroupAnswerInfo = require('./OptionGroupAnswerInfo.js');
8
8
  var OptionGroupGroupInfo = require('./OptionGroupGroupInfo.js');
9
9
 
10
- var OptionGroup = function OptionGroup() {
10
+ const OptionGroup = () => {
11
11
  //
12
12
  //
13
13
  //
14
- return jsxRuntime.jsxs(blocks.Flex, {
14
+ return React.createElement(blocks.Flex, {
15
15
  column: true,
16
- margintop: "1.5rem",
17
- children: [jsxRuntime.jsx(OptionGroupGroupInfo.default, {}), jsxRuntime.jsx(blocks.Hr, {
18
- marginStart: "1.5rem",
19
- marginEnd: "1.5rem"
20
- }), jsxRuntime.jsx(OptionGroupAnswerInfo.default, {})]
21
- });
16
+ margintop: "1.5rem"
17
+ }, React.createElement(OptionGroupGroupInfo.default, null), React.createElement(blocks.Hr, {
18
+ marginStart: "1.5rem",
19
+ marginEnd: "1.5rem"
20
+ }), React.createElement(OptionGroupAnswerInfo.default, null));
22
21
  };
23
22
 
24
23
  exports.default = OptionGroup;