@elice/material-survey 1.230328.0 → 1.230418.0

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 (54) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +409 -0
  2. package/cjs/components/material-survey/MaterialSurvey.i18n.js +2 -2
  3. package/cjs/components/material-survey/MaterialSurvey.js +56 -51
  4. package/cjs/components/material-survey/MaterialSurveyInfo.js +6 -5
  5. package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +117 -91
  6. package/cjs/components/material-survey/MaterialSurveySelectOne.js +110 -81
  7. package/cjs/components/material-survey/MaterialSurveyShimmer.js +13 -12
  8. package/cjs/components/material-survey/MaterialSurveyText.js +111 -80
  9. package/cjs/components/material-survey/SurveyResultBadge.js +9 -8
  10. package/cjs/components/material-survey/SurveySubmitStatusText.js +6 -8
  11. package/cjs/components/material-survey/context/MaterialSurveyContext.js +102 -79
  12. package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +45 -38
  13. package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +79 -83
  14. package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +71 -76
  15. package/cjs/components/material-survey-edit/context.js +4 -2
  16. package/cjs/components/material-survey-edit/locales.js +2 -2
  17. package/cjs/components/material-survey-edit/utils/editValue.js +17 -16
  18. package/cjs/components/shared/StyledMarkdown.js +4 -2
  19. package/cjs/components/shared/SurveyContentBox.js +48 -54
  20. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
  21. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +15 -18
  22. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +48 -103
  23. package/cjs/components/shared/question-radio/QuestionRadio.js +7 -9
  24. package/cjs/components/shared/question-radio/QuestionRadioContext.js +15 -18
  25. package/cjs/components/shared/question-radio/QuestionRadioOption.js +41 -87
  26. package/cjs/helpers/index.js +0 -3
  27. package/cjs/index.js +7 -7
  28. package/es/_virtual/_rollupPluginBabelHelpers.js +394 -0
  29. package/es/components/material-survey/MaterialSurvey.i18n.js +2 -2
  30. package/es/components/material-survey/MaterialSurvey.js +51 -46
  31. package/es/components/material-survey/MaterialSurveyInfo.js +3 -4
  32. package/es/components/material-survey/MaterialSurveySelectMultiple.js +109 -85
  33. package/es/components/material-survey/MaterialSurveySelectOne.js +102 -75
  34. package/es/components/material-survey/MaterialSurveyShimmer.js +10 -11
  35. package/es/components/material-survey/MaterialSurveyText.js +106 -77
  36. package/es/components/material-survey/SurveyResultBadge.js +6 -7
  37. package/es/components/material-survey/SurveySubmitStatusText.js +3 -7
  38. package/es/components/material-survey/context/MaterialSurveyContext.js +103 -80
  39. package/es/components/material-survey-edit/MaterialSurveyEdit.js +41 -36
  40. package/es/components/material-survey-edit/MaterialSurveyEditContent.js +75 -81
  41. package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +68 -75
  42. package/es/components/material-survey-edit/context.js +4 -2
  43. package/es/components/material-survey-edit/locales.js +2 -2
  44. package/es/components/material-survey-edit/utils/editValue.js +17 -16
  45. package/es/components/shared/StyledMarkdown.js +1 -1
  46. package/es/components/shared/SurveyContentBox.js +48 -54
  47. package/es/components/shared/question-checkbox/QuestionCheckbox.js +4 -8
  48. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +15 -18
  49. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +45 -102
  50. package/es/components/shared/question-radio/QuestionRadio.js +4 -8
  51. package/es/components/shared/question-radio/QuestionRadioContext.js +15 -18
  52. package/es/components/shared/question-radio/QuestionRadioOption.js +38 -86
  53. package/es/helpers/index.js +0 -3
  54. package/package.json +8 -8
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var React = require('react');
4
6
  var reactHookForm = require('react-hook-form');
5
7
  var reactIntl = require('react-intl');
@@ -13,29 +15,29 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
13
15
 
14
16
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
17
 
16
- const MaterialSurveyEdit = React.forwardRef(({
17
- value,
18
- disabled = false,
19
- locale = 'en',
20
- onChange,
21
- onFormStateChange,
22
- onFileUploadRequest
23
- }, ref) => {
24
- const formElRef = React__default["default"].useRef(null);
25
- const useFormMethods = reactHookForm.useForm({
18
+ var MaterialSurveyEdit = React.forwardRef(function (_ref, ref) {
19
+ var value = _ref.value,
20
+ _ref$disabled = _ref.disabled,
21
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
22
+ _ref$locale = _ref.locale,
23
+ locale = _ref$locale === void 0 ? 'en' : _ref$locale,
24
+ onChange = _ref.onChange,
25
+ onFormStateChange = _ref.onFormStateChange,
26
+ onFileUploadRequest = _ref.onFileUploadRequest;
27
+ var formElRef = React__default["default"].useRef(null);
28
+ var useFormMethods = reactHookForm.useForm({
26
29
  defaultValues: editValue.manipulateValue(value),
27
30
  mode: 'onBlur'
28
31
  });
29
- const watchedMaterialSurveyEditValue = useFormMethods.watch();
30
- const {
31
- isDirty,
32
- isValid
33
- } = useFormMethods.formState; //
32
+ var watchedMaterialSurveyEditValue = useFormMethods.watch();
33
+ var _useFormMethods$formS = useFormMethods.formState,
34
+ isDirty = _useFormMethods$formS.isDirty,
35
+ isValid = _useFormMethods$formS.isValid;
36
+ //
34
37
  // Reset from value, when `value` changes.
35
38
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
36
39
  //
37
-
38
- reactUse.useDeepCompareEffect(() => {
40
+ reactUse.useDeepCompareEffect(function () {
39
41
  useFormMethods.reset(editValue.manipulateValue(value), {
40
42
  keepDirty: true,
41
43
  keepErrors: true,
@@ -44,48 +46,53 @@ const MaterialSurveyEdit = React.forwardRef(({
44
46
  keepValues: true
45
47
  });
46
48
  void useFormMethods.trigger();
47
- }, [value]); //
49
+ }, [value]);
50
+ //
48
51
  // Emit `onChange` handler when form value changed.
49
52
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
50
53
  //
51
-
52
- reactUse.useDeepCompareEffect(() => onChange(editValue.restoreValue(watchedMaterialSurveyEditValue)), [watchedMaterialSurveyEditValue]); //
54
+ reactUse.useDeepCompareEffect(function () {
55
+ return onChange(editValue.restoreValue(watchedMaterialSurveyEditValue));
56
+ }, [watchedMaterialSurveyEditValue]);
57
+ //
53
58
  // Emit `onFormStateChange` handler when form state change.
54
59
  //
55
-
56
- React__default["default"].useEffect(() => {
60
+ React__default["default"].useEffect(function () {
57
61
  if (typeof onFormStateChange === 'function') {
58
62
  onFormStateChange({
59
- isDirty,
60
- isValid
63
+ isDirty: isDirty,
64
+ isValid: isValid
61
65
  });
62
66
  }
63
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
64
- [isDirty, isValid]); //
67
+ },
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
69
+ [isDirty, isValid]);
70
+ //
65
71
  // Set ref.
66
72
  //
67
-
68
- React__default["default"].useImperativeHandle(ref, () => Object.assign(Object.assign({}, formElRef.current), {
69
- reset: () => {
70
- useFormMethods.reset(editValue.manipulateValue(value));
71
- void useFormMethods.trigger();
72
- }
73
- }), [useFormMethods, value]); //
73
+ React__default["default"].useImperativeHandle(ref, function () {
74
+ return Object.assign(Object.assign({}, formElRef.current), {
75
+ reset: function reset() {
76
+ useFormMethods.reset(editValue.manipulateValue(value));
77
+ void useFormMethods.trigger();
78
+ }
79
+ });
80
+ }, [useFormMethods, value]);
81
+ //
74
82
  //
75
83
  //
76
-
77
84
  return React__default["default"].createElement("form", {
78
85
  ref: formElRef
79
86
  }, React__default["default"].createElement(context["default"].Provider, {
80
87
  value: {
81
- disabled,
82
- onFileUploadRequest
88
+ disabled: disabled,
89
+ onFileUploadRequest: onFileUploadRequest
83
90
  }
84
91
  }, React__default["default"].createElement(reactIntl.IntlProvider, {
85
92
  locale: locale,
86
93
  defaultLocale: "en",
87
94
  messages: locale in locales ? locales[locale] : locales.en
88
- }, React__default["default"].createElement(reactHookForm.FormProvider, Object.assign({}, useFormMethods), React__default["default"].createElement(MaterialSurveyEditContent, null)))));
95
+ }, React__default["default"].createElement(reactHookForm.FormProvider, Object.assign({}, useFormMethods), React__default["default"].createElement(MaterialSurveyEditContent["default"], null)))));
89
96
  });
90
97
 
91
- module.exports = MaterialSurveyEdit;
98
+ exports["default"] = MaterialSurveyEdit;
@@ -1,5 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
3
6
  var React = require('react');
4
7
  var reactHookForm = require('react-hook-form');
5
8
  var reactIntl = require('react-intl');
@@ -16,33 +19,34 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
16
19
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
20
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
18
21
 
19
- const MIN_TEXT_LENGTH = 1;
20
- const MAX_TEXT_LENGTH = 128;
21
- const StyledSurveyOptionTypeSelectWrap = styled__default["default"].div.withConfig({
22
+ var MIN_TEXT_LENGTH = 1;
23
+ var MAX_TEXT_LENGTH = 128;
24
+ var StyledSurveyOptionTypeSelectWrap = styled__default["default"].div.withConfig({
22
25
  componentId: "sc-r4ms68-0"
23
26
  })(["display:flex;max-width:12rem;"]);
24
-
25
- const MaterialSurveyEditContent = () => {
26
- const intl = reactIntl.useIntl();
27
- const {
28
- disabled,
29
- onFileUploadRequest
30
- } = context.useMaterialSurveyEditContext();
31
- const {
32
- control,
33
- watch,
34
- setValue
35
- } = reactHookForm.useFormContext();
36
- const [watchedOptionType, watchedOptionInfo] = watch(['questionInfoList.0.optionType', 'questionInfoList.0.optionInfo']); //
27
+ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
28
+ var intl = reactIntl.useIntl();
29
+ var _useMaterialSurveyEdi = context.useMaterialSurveyEditContext(),
30
+ disabled = _useMaterialSurveyEdi.disabled,
31
+ onFileUploadRequest = _useMaterialSurveyEdi.onFileUploadRequest;
32
+ var _useFormContext = reactHookForm.useFormContext(),
33
+ control = _useFormContext.control,
34
+ watch = _useFormContext.watch,
35
+ setValue = _useFormContext.setValue;
36
+ var _watch = watch(['questionInfoList.0.optionType', 'questionInfoList.0.optionInfo']),
37
+ _watch2 = _rollupPluginBabelHelpers.slicedToArray(_watch, 2),
38
+ watchedOptionType = _watch2[0],
39
+ watchedOptionInfo = _watch2[1];
40
+ //
37
41
  // Change `optionInfo` according to `optionType`.
38
42
  //
39
-
40
- React__default["default"].useEffect(() => {
41
- const get = () => {
43
+ React__default["default"].useEffect(function () {
44
+ var get = function get() {
42
45
  switch (watchedOptionType) {
43
46
  case types.enums.SurveyOptionType.SelectOne:
44
47
  case types.enums.SurveyOptionType.SelectMultiple:
45
- return watchedOptionInfo.length > 0 ? watchedOptionInfo : // add default option info
48
+ return watchedOptionInfo.length > 0 ? watchedOptionInfo :
49
+ // add default option info
46
50
  [{
47
51
  id: randomId.createRandomId(),
48
52
  value: intl.formatMessage({
@@ -58,29 +62,25 @@ const MaterialSurveyEditContent = () => {
58
62
  number: 2
59
63
  })
60
64
  }];
61
-
62
65
  case types.enums.SurveyOptionType.Text:
63
66
  return [];
64
-
65
67
  default:
66
68
  return [];
67
69
  }
68
70
  };
69
-
70
71
  setValue('questionInfoList.0.optionInfo', get());
71
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
72
+ },
73
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
74
  [watchedOptionType, setValue, intl]);
73
75
  /**
74
76
  * Input of option info and answer info,
75
77
  * according to option type.
76
78
  */
77
-
78
- const Option = React__default["default"].useMemo(() => {
79
+ var Option = React__default["default"].useMemo(function () {
79
80
  switch (watchedOptionType) {
80
81
  case types.enums.SurveyOptionType.SelectOne:
81
82
  case types.enums.SurveyOptionType.SelectMultiple:
82
- return MaterialSurveyEditOptionSelect;
83
-
83
+ return MaterialSurveyEditOptionSelect["default"];
84
84
  case types.enums.SurveyOptionType.Text:
85
85
  default:
86
86
  return React__default["default"].Fragment;
@@ -89,8 +89,7 @@ const MaterialSurveyEditContent = () => {
89
89
  /**
90
90
  * Render input for survey title.
91
91
  */
92
-
93
- const renderQuestionTitleInput = () => {
92
+ var renderQuestionTitleInput = function renderQuestionTitleInput() {
94
93
  return React__default["default"].createElement(blocks.FormInputVerticalLayout, {
95
94
  label: React__default["default"].createElement(blocks.Label, {
96
95
  size: "small",
@@ -127,12 +126,10 @@ const MaterialSurveyEditContent = () => {
127
126
  })
128
127
  }
129
128
  },
130
- render: ({
131
- field,
132
- fieldState
133
- }) => {
129
+ render: function render(_ref) {
130
+ var field = _ref.field,
131
+ fieldState = _ref.fieldState;
134
132
  var _a;
135
-
136
133
  return React__default["default"].createElement(blocks.Input, Object.assign({
137
134
  size: "small",
138
135
  width: "full",
@@ -151,9 +148,7 @@ const MaterialSurveyEditContent = () => {
151
148
  /**
152
149
  * Render input for survey description.
153
150
  */
154
-
155
-
156
- const renderQuestionDescriptionInput = () => {
151
+ var renderQuestionDescriptionInput = function renderQuestionDescriptionInput() {
157
152
  return React__default["default"].createElement(blocks.FormInputVerticalLayout, {
158
153
  label: React__default["default"].createElement(blocks.Label, {
159
154
  size: "small"
@@ -163,24 +158,23 @@ const MaterialSurveyEditContent = () => {
163
158
  input: React__default["default"].createElement(reactHookForm.Controller, {
164
159
  control: control,
165
160
  name: "questionInfoList.0.questionDescription",
166
- render: ({
167
- field
168
- }) => React__default["default"].createElement(markdown.MarkdownEditor, Object.assign({
169
- enableFooter: true,
170
- placeholder: intl.formatMessage({
171
- id: 'content.description.placeholder'
172
- }),
173
- onFileUploadRequest: onFileUploadRequest
174
- }, field))
161
+ render: function render(_ref2) {
162
+ var field = _ref2.field;
163
+ return React__default["default"].createElement(markdown.MarkdownEditor, Object.assign({
164
+ enableFooter: true,
165
+ placeholder: intl.formatMessage({
166
+ id: 'content.description.placeholder'
167
+ }),
168
+ onFileUploadRequest: onFileUploadRequest
169
+ }, field));
170
+ }
175
171
  })
176
172
  });
177
173
  };
178
174
  /**
179
175
  * Render input of option type, option info and answer info.
180
176
  */
181
-
182
-
183
- const renderOptionInput = () => {
177
+ var renderOptionInput = function renderOptionInput() {
184
178
  return React__default["default"].createElement(blocks.FormInputVerticalLayout, {
185
179
  label: React__default["default"].createElement(blocks.Label, {
186
180
  size: "small",
@@ -191,45 +185,47 @@ const MaterialSurveyEditContent = () => {
191
185
  input: React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(reactHookForm.Controller, {
192
186
  control: control,
193
187
  name: "questionInfoList.0.optionType",
194
- render: ({
195
- field
196
- }) => React__default["default"].createElement(blocks.Tooltip, {
197
- title: disabled ? intl.formatMessage({
198
- id: 'content.option.tooltip.disabled'
199
- }) : undefined,
200
- placement: "top-end"
201
- }, React__default["default"].createElement(StyledSurveyOptionTypeSelectWrap, null, React__default["default"].createElement(blocks.Select, Object.assign({
202
- size: "small",
203
- width: "small",
204
- readOnly: disabled
205
- }, field, {
206
- onChange: v => field.onChange(Number(v))
207
- }), React__default["default"].createElement("option", {
208
- value: types.enums.SurveyOptionType.SelectOne,
209
- children: intl.formatMessage({
210
- id: 'content.option.select.items.selectOne'
211
- })
212
- }), React__default["default"].createElement("option", {
213
- value: types.enums.SurveyOptionType.SelectMultiple,
214
- children: intl.formatMessage({
215
- id: 'content.option.select.items.selectMultiple'
216
- })
217
- }), React__default["default"].createElement("option", {
218
- value: types.enums.SurveyOptionType.Text,
219
- children: intl.formatMessage({
220
- id: 'content.option.select.items.text'
221
- })
222
- }))))
188
+ render: function render(_ref3) {
189
+ var field = _ref3.field;
190
+ return React__default["default"].createElement(blocks.Tooltip, {
191
+ title: disabled ? intl.formatMessage({
192
+ id: 'content.option.tooltip.disabled'
193
+ }) : undefined,
194
+ placement: "top-end"
195
+ }, React__default["default"].createElement(StyledSurveyOptionTypeSelectWrap, null, React__default["default"].createElement(blocks.Select, Object.assign({
196
+ size: "small",
197
+ width: "small",
198
+ readOnly: disabled
199
+ }, field, {
200
+ onChange: function onChange(v) {
201
+ return field.onChange(Number(v));
202
+ }
203
+ }), React__default["default"].createElement("option", {
204
+ value: types.enums.SurveyOptionType.SelectOne,
205
+ children: intl.formatMessage({
206
+ id: 'content.option.select.items.selectOne'
207
+ })
208
+ }), React__default["default"].createElement("option", {
209
+ value: types.enums.SurveyOptionType.SelectMultiple,
210
+ children: intl.formatMessage({
211
+ id: 'content.option.select.items.selectMultiple'
212
+ })
213
+ }), React__default["default"].createElement("option", {
214
+ value: types.enums.SurveyOptionType.Text,
215
+ children: intl.formatMessage({
216
+ id: 'content.option.select.items.text'
217
+ })
218
+ }))));
219
+ }
223
220
  }), React__default["default"].createElement(blocks.Vspace, {
224
221
  height: 0.5
225
222
  }), React__default["default"].createElement(Option, null))
226
223
  });
227
- }; //
224
+ };
225
+ //
228
226
  //
229
227
  //
230
-
231
-
232
228
  return React__default["default"].createElement(React__default["default"].Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput());
233
229
  };
234
230
 
235
- module.exports = MaterialSurveyEditContent;
231
+ exports["default"] = MaterialSurveyEditContent;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var React = require('react');
4
6
  var reactHookForm = require('react-hook-form');
5
7
  var reactIntl = require('react-intl');
@@ -14,37 +16,32 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
14
16
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
17
  var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
16
18
 
17
- const MIN_OPTION_INFO_COUNT = 2;
18
- const MAX_OPTION_INFO_COUNT = 20;
19
- const StyledWrap = styled__default["default"].div.withConfig({
19
+ var MIN_OPTION_INFO_COUNT = 2;
20
+ var MAX_OPTION_INFO_COUNT = 20;
21
+ var StyledWrap = styled__default["default"].div.withConfig({
20
22
  componentId: "sc-1eiyk6z-0"
21
23
  })([""]);
22
- const StyledInputGroup = styled__default["default"].div.withConfig({
24
+ var StyledInputGroup = styled__default["default"].div.withConfig({
23
25
  componentId: "sc-1eiyk6z-1"
24
26
  })(["width:100%;.eb-input{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
25
-
26
- const OptionSelectOne = () => {
27
- const intl = reactIntl.useIntl();
28
- const {
29
- disabled
30
- } = context.useMaterialSurveyEditContext();
31
- const {
32
- control
33
- } = reactHookForm.useFormContext();
34
- const {
35
- fields: optionInfoFields,
36
- append: appendOptionInfoFieldItem,
37
- remove: removeOptionInfoFieldItem
38
- } = reactHookForm.useFieldArray({
39
- name: 'questionInfoList.0.optionInfo',
40
- keyName: 'id',
41
- shouldUnregister: true
42
- });
27
+ var OptionSelectOne = function OptionSelectOne() {
28
+ var intl = reactIntl.useIntl();
29
+ var _useMaterialSurveyEdi = context.useMaterialSurveyEditContext(),
30
+ disabled = _useMaterialSurveyEdi.disabled;
31
+ var _useFormContext = reactHookForm.useFormContext(),
32
+ control = _useFormContext.control;
33
+ var _useFieldArray = reactHookForm.useFieldArray({
34
+ name: 'questionInfoList.0.optionInfo',
35
+ keyName: 'id',
36
+ shouldUnregister: true
37
+ }),
38
+ optionInfoFields = _useFieldArray.fields,
39
+ appendOptionInfoFieldItem = _useFieldArray.append,
40
+ removeOptionInfoFieldItem = _useFieldArray.remove;
43
41
  /**
44
42
  * Append option info.
45
43
  */
46
-
47
- const appendOptionInfo = () => {
44
+ var appendOptionInfo = function appendOptionInfo() {
48
45
  appendOptionInfoFieldItem({
49
46
  id: randomId.createRandomId(),
50
47
  value: ''
@@ -53,61 +50,59 @@ const OptionSelectOne = () => {
53
50
  /**
54
51
  * Remove item from option info at index.
55
52
  */
56
-
57
-
58
- const removeOptionInfo = index => {
53
+ var removeOptionInfo = function removeOptionInfo(index) {
59
54
  removeOptionInfoFieldItem(index);
60
- }; //
55
+ };
61
56
  //
62
57
  //
63
-
64
-
65
- return React__default["default"].createElement(StyledWrap, null, React__default["default"].createElement(StyledInputGroup, null, optionInfoFields.map(({
66
- id
67
- }, index) => React__default["default"].createElement(reactHookForm.Controller, {
68
- key: id,
69
- control: control,
70
- name: `questionInfoList.0.optionInfo.${index}.value`,
71
- rules: {
72
- required: {
73
- value: true,
74
- message: intl.formatMessage({
75
- id: 'option.common.select.errorMessage.required'
76
- })
58
+ //
59
+ return React__default["default"].createElement(StyledWrap, null, React__default["default"].createElement(StyledInputGroup, null, optionInfoFields.map(function (_ref, index) {
60
+ var id = _ref.id;
61
+ return React__default["default"].createElement(reactHookForm.Controller, {
62
+ key: id,
63
+ control: control,
64
+ name: "questionInfoList.0.optionInfo.".concat(index, ".value"),
65
+ rules: {
66
+ required: {
67
+ value: true,
68
+ message: intl.formatMessage({
69
+ id: 'option.common.select.errorMessage.required'
70
+ })
71
+ }
72
+ },
73
+ render: function render(_ref2) {
74
+ var field = _ref2.field,
75
+ fieldState = _ref2.fieldState;
76
+ var _a;
77
+ return React__default["default"].createElement(blocks.Input, Object.assign({
78
+ size: "small",
79
+ width: "full",
80
+ placeholder: intl.formatMessage({
81
+ id: 'option.common.select.placeholder'
82
+ }),
83
+ suffix: React__default["default"].createElement(blocks.Tooltip, {
84
+ title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.formatMessage({
85
+ id: 'option.common.select.tooltip.minOptionInfoItem'
86
+ }) : undefined,
87
+ placement: "top-start"
88
+ }, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.IconButton, {
89
+ icon: icons.eilMathsignMultiplyBasic,
90
+ role: "grey9",
91
+ size: "tiny",
92
+ border: false,
93
+ transparent: true,
94
+ disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
95
+ onClick: function onClick() {
96
+ return removeOptionInfo(index);
97
+ }
98
+ }))),
99
+ readOnly: disabled,
100
+ invalid: fieldState.invalid,
101
+ invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
102
+ }, field));
77
103
  }
78
- },
79
- render: ({
80
- field,
81
- fieldState
82
- }) => {
83
- var _a;
84
-
85
- return React__default["default"].createElement(blocks.Input, Object.assign({
86
- size: "small",
87
- width: "full",
88
- placeholder: intl.formatMessage({
89
- id: 'option.common.select.placeholder'
90
- }),
91
- suffix: React__default["default"].createElement(blocks.Tooltip, {
92
- title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.formatMessage({
93
- id: 'option.common.select.tooltip.minOptionInfoItem'
94
- }) : undefined,
95
- placement: "top-start"
96
- }, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.IconButton, {
97
- icon: icons.eilMathsignMultiplyBasic,
98
- role: "grey9",
99
- size: "tiny",
100
- border: false,
101
- transparent: true,
102
- disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
103
- onClick: () => removeOptionInfo(index)
104
- }))),
105
- readOnly: disabled,
106
- invalid: fieldState.invalid,
107
- invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
108
- }, field));
109
- }
110
- }))), React__default["default"].createElement(blocks.Vspace, {
104
+ });
105
+ })), React__default["default"].createElement(blocks.Vspace, {
111
106
  height: 0.5
112
107
  }), React__default["default"].createElement(blocks.Tooltip, {
113
108
  title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl.formatMessage({
@@ -129,4 +124,4 @@ const OptionSelectOne = () => {
129
124
  })))));
130
125
  };
131
126
 
132
- module.exports = OptionSelectOne;
127
+ exports["default"] = OptionSelectOne;
@@ -8,8 +8,10 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
8
8
 
9
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
10
 
11
- const MaterialSurveyEditContext = React__default["default"].createContext(null);
12
- const useMaterialSurveyEditContext = () => React__default["default"].useContext(MaterialSurveyEditContext);
11
+ var MaterialSurveyEditContext = React__default["default"].createContext(null);
12
+ var useMaterialSurveyEditContext = function useMaterialSurveyEditContext() {
13
+ return React__default["default"].useContext(MaterialSurveyEditContext);
14
+ };
13
15
 
14
16
  exports["default"] = MaterialSurveyEditContext;
15
17
  exports.useMaterialSurveyEditContext = useMaterialSurveyEditContext;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const en = {
5
+ var en = {
6
6
  'common.option': '옵션 {number}',
7
7
  'common.errorMessage.range': '{min} ~ {max}자 이내로 입력해주세요.',
8
8
  'content.title': '질문',
@@ -21,7 +21,7 @@ const en = {
21
21
  'option.common.select.tooltip.maxOptionInfoItem': '선택지는 20개 초과하여 입력할 수 없습니다.',
22
22
  'option.common.select.addButton': '보기 추가'
23
23
  };
24
- const ko = {
24
+ var ko = {
25
25
  'common.option': '옵션 {number}',
26
26
  'common.errorMessage.range': '{min} ~ {max}자 이내로 입력해주세요.',
27
27
  'content.title': '질문',
@@ -7,36 +7,37 @@ var randomId = require('./randomId.js');
7
7
  /**
8
8
  *
9
9
  */
10
-
11
10
  function manipulateValue(v) {
12
11
  return Object.assign(Object.assign({}, v), {
13
- questionInfoList: v.questionInfoList.map(questionInfo => Object.assign(Object.assign({}, questionInfo), {
14
- // convert string array to object array
15
- // - ref: https://github.com/react-hook-form/react-hook-form/issues/7622#issuecomment-1018893318
16
- optionInfo: Array.isArray(questionInfo.optionInfo) ? questionInfo.optionInfo.map(option => ({
17
- id: randomId.createRandomId(),
18
- value: option
19
- })) : []
20
- }))
12
+ questionInfoList: v.questionInfoList.map(function (questionInfo) {
13
+ return Object.assign(Object.assign({}, questionInfo), {
14
+ // convert string array to object array
15
+ // - ref: https://github.com/react-hook-form/react-hook-form/issues/7622#issuecomment-1018893318
16
+ optionInfo: Array.isArray(questionInfo.optionInfo) ? questionInfo.optionInfo.map(function (option) {
17
+ return {
18
+ id: randomId.createRandomId(),
19
+ value: option
20
+ };
21
+ }) : []
22
+ });
23
+ })
21
24
  });
22
25
  }
23
26
  /**
24
27
  * Restore manipulation from `manipulateValue()`.
25
28
  */
26
-
27
29
  function restoreValue(v) {
28
30
  return Object.assign(Object.assign({}, v), {
29
- questionInfoList: v.questionInfoList.map(questionInfo => {
31
+ questionInfoList: v.questionInfoList.map(function (questionInfo) {
30
32
  var _a;
31
-
32
- const newQuestionInfo = Object.assign(Object.assign({}, questionInfo), {
33
- optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(option => option.value) : null
33
+ var newQuestionInfo = Object.assign(Object.assign({}, questionInfo), {
34
+ optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(function (option) {
35
+ return option.value;
36
+ }) : null
34
37
  });
35
-
36
38
  if (!newQuestionInfo.optionInfo) {
37
39
  delete newQuestionInfo.optionInfo;
38
40
  }
39
-
40
41
  return newQuestionInfo;
41
42
  })
42
43
  });