@elice/material-survey 1.240718.0-trasncript.2 → 1.240718.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/cjs/components/markdown-editor/index.d.ts +2 -1
  2. package/cjs/components/markdown-editor/index.js +10 -19
  3. package/cjs/components/material-survey/MaterialSurvey.js +57 -82
  4. package/cjs/components/material-survey/MaterialSurveyInfo.js +59 -69
  5. package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +90 -131
  6. package/cjs/components/material-survey/MaterialSurveySelectOne.js +86 -125
  7. package/cjs/components/material-survey/MaterialSurveyShimmer.js +40 -47
  8. package/cjs/components/material-survey/MaterialSurveyText.js +75 -114
  9. package/cjs/components/material-survey/SurveyResultBadge.js +10 -17
  10. package/cjs/components/material-survey/SurveySubmitStatusText.js +16 -21
  11. package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
  12. package/cjs/components/material-survey/context/MaterialSurveyContext.js +74 -115
  13. package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +36 -49
  14. package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +91 -113
  15. package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +87 -100
  16. package/cjs/components/material-survey-edit/context.js +2 -8
  17. package/cjs/components/material-survey-edit/utils/editValue.js +11 -17
  18. package/cjs/components/shared/StyledMarkdown.js +1 -5
  19. package/cjs/components/shared/SurveyContentBox.js +74 -85
  20. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
  21. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  22. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
  23. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +89 -66
  24. package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
  25. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  26. package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
  27. package/cjs/components/shared/question-radio/QuestionRadioOption.js +80 -59
  28. package/es/components/markdown-editor/index.d.ts +2 -1
  29. package/es/components/markdown-editor/index.js +10 -15
  30. package/es/components/material-survey/MaterialSurvey.js +57 -77
  31. package/es/components/material-survey/MaterialSurveyInfo.js +59 -65
  32. package/es/components/material-survey/MaterialSurveySelectMultiple.js +90 -127
  33. package/es/components/material-survey/MaterialSurveySelectOne.js +86 -121
  34. package/es/components/material-survey/MaterialSurveyShimmer.js +40 -43
  35. package/es/components/material-survey/MaterialSurveyText.js +75 -109
  36. package/es/components/material-survey/SurveyResultBadge.js +10 -13
  37. package/es/components/material-survey/SurveySubmitStatusText.js +16 -17
  38. package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
  39. package/es/components/material-survey/context/MaterialSurveyContext.js +75 -112
  40. package/es/components/material-survey-edit/MaterialSurveyEdit.js +36 -45
  41. package/es/components/material-survey-edit/MaterialSurveyEditContent.js +90 -107
  42. package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +87 -96
  43. package/es/components/material-survey-edit/context.js +2 -4
  44. package/es/components/material-survey-edit/utils/editValue.js +11 -17
  45. package/es/components/shared/StyledMarkdown.js +1 -1
  46. package/es/components/shared/SurveyContentBox.js +74 -81
  47. package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
  48. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  49. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
  50. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +89 -61
  51. package/es/components/shared/question-radio/QuestionRadio.js +7 -9
  52. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  53. package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
  54. package/es/components/shared/question-radio/QuestionRadioOption.js +80 -54
  55. package/package.json +12 -9
  56. package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -399
  57. package/cjs/components/material-survey/index.js +0 -9
  58. package/cjs/components/material-survey/locales/index.js +0 -13
  59. package/cjs/components/material-survey-edit/index.js +0 -7
  60. package/cjs/components/material-survey-edit/locales/index.js +0 -13
  61. package/cjs/components/shared/index.js +0 -13
  62. package/es/_virtual/_rollupPluginBabelHelpers.js +0 -386
  63. package/es/components/material-survey/index.js +0 -2
  64. package/es/components/material-survey/locales/index.js +0 -4
  65. package/es/components/material-survey-edit/index.js +0 -1
  66. package/es/components/material-survey-edit/locales/index.js +0 -4
  67. package/es/components/shared/index.js +0 -4
@@ -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 intl = require('@elice/intl');
@@ -13,35 +12,32 @@ var en = require('./locales/en.json.js');
13
12
  var ko = require('./locales/ko.json.js');
14
13
  var MaterialSurveyEditContent = require('./MaterialSurveyEditContent.js');
15
14
 
16
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
17
-
18
- var React__default = /*#__PURE__*/_interopDefaultCompat(React);
19
-
20
15
  //
21
16
  //
22
17
  //
23
- var MaterialSurveyEdit = React.forwardRef(function (_ref, ref) {
24
- var value = _ref.value,
25
- _ref$disabled = _ref.disabled,
26
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
27
- onChange = _ref.onChange,
28
- onFormStateChange = _ref.onFormStateChange,
29
- onFileUploadRequest = _ref.onFileUploadRequest,
30
- __intl = _ref.__intl;
31
- var formElRef = React__default.default.useRef(null);
32
- var useFormMethods = reactHookForm.useForm({
18
+ const MaterialSurveyEdit = React.forwardRef(({
19
+ value,
20
+ disabled = false,
21
+ onChange,
22
+ onFormStateChange,
23
+ onFileUploadRequest,
24
+ __intl
25
+ }, ref) => {
26
+ const formElRef = React.useRef(null);
27
+ const useFormMethods = reactHookForm.useForm({
33
28
  defaultValues: editValue.manipulateValue(value),
34
29
  mode: 'onBlur'
35
30
  });
36
- var watchedMaterialSurveyEditValue = useFormMethods.watch();
37
- var _useFormMethods$formS = useFormMethods.formState,
38
- isDirty = _useFormMethods$formS.isDirty,
39
- isValid = _useFormMethods$formS.isValid;
31
+ const watchedMaterialSurveyEditValue = useFormMethods.watch();
32
+ const {
33
+ isDirty,
34
+ isValid
35
+ } = useFormMethods.formState;
40
36
  //
41
37
  // Reset from value, when `value` changes.
42
38
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
43
39
  //
44
- materialSharedUtils.useDeepClonedCompareEffect(function () {
40
+ materialSharedUtils.useDeepClonedCompareEffect(() => {
45
41
  useFormMethods.reset(editValue.manipulateValue(value), {
46
42
  keepDirty: true,
47
43
  keepErrors: true,
@@ -55,17 +51,15 @@ var MaterialSurveyEdit = React.forwardRef(function (_ref, ref) {
55
51
  // Emit `onChange` handler when form value changed.
56
52
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
57
53
  //
58
- materialSharedUtils.useDeepClonedCompareEffect(function () {
59
- return onChange(editValue.restoreValue(watchedMaterialSurveyEditValue));
60
- }, [watchedMaterialSurveyEditValue]);
54
+ materialSharedUtils.useDeepClonedCompareEffect(() => onChange(editValue.restoreValue(watchedMaterialSurveyEditValue)), [watchedMaterialSurveyEditValue]);
61
55
  //
62
56
  // Emit `onFormStateChange` handler when form state change.
63
57
  //
64
- React__default.default.useEffect(function () {
58
+ React.useEffect(() => {
65
59
  if (typeof onFormStateChange === 'function') {
66
60
  onFormStateChange({
67
- isDirty: isDirty,
68
- isValid: isValid
61
+ isDirty,
62
+ isValid
69
63
  });
70
64
  }
71
65
  },
@@ -74,32 +68,25 @@ var MaterialSurveyEdit = React.forwardRef(function (_ref, ref) {
74
68
  //
75
69
  // Set ref.
76
70
  //
77
- React__default.default.useImperativeHandle(ref, function () {
78
- return Object.assign(Object.assign({}, formElRef.current), {
79
- reset: function reset() {
80
- useFormMethods.reset(editValue.manipulateValue(value));
81
- void useFormMethods.trigger();
82
- }
83
- });
84
- }, [useFormMethods, value]);
71
+ React.useImperativeHandle(ref, () => Object.assign(Object.assign({}, formElRef.current), {
72
+ reset: () => {
73
+ useFormMethods.reset(editValue.manipulateValue(value));
74
+ void useFormMethods.trigger();
75
+ }
76
+ }), [useFormMethods, value]);
85
77
  //
86
78
  //
87
79
  //
88
- return jsxRuntime.jsx(intl.RawEliceIntlProvider, {
89
- value: __intl,
90
- children: jsxRuntime.jsx("form", {
91
- ref: formElRef,
92
- children: jsxRuntime.jsx(context.default.Provider, {
93
- value: {
94
- disabled: disabled,
95
- onFileUploadRequest: onFileUploadRequest
96
- },
97
- children: jsxRuntime.jsx(reactHookForm.FormProvider, Object.assign({}, useFormMethods, {
98
- children: jsxRuntime.jsx(MaterialSurveyEditContent.default, {})
99
- }))
100
- })
101
- })
102
- });
80
+ return React.createElement(intl.RawEliceIntlProvider, {
81
+ value: __intl
82
+ }, React.createElement("form", {
83
+ ref: formElRef
84
+ }, React.createElement(context.default.Provider, {
85
+ value: {
86
+ disabled,
87
+ onFileUploadRequest
88
+ }
89
+ }, React.createElement(reactHookForm.FormProvider, Object.assign({}, useFormMethods), React.createElement(MaterialSurveyEditContent.default, null)))));
103
90
  });
104
91
  var MaterialSurveyEdit$1 = new intl.IntlComponentBuilder(MaterialSurveyEdit).add('en', en.default).add('ko', ko.default).addAsync('th', Promise.resolve().then(function () { return require('./locales/th.json.js'); })).addAsync('ja', Promise.resolve().then(function () { return require('./locales/ja.json.js'); })).build();
105
92
 
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
- var jsxRuntime = require('react/jsx-runtime');
7
5
  var React = require('react');
8
6
  var reactHookForm = require('react-hook-form');
9
7
  var blocks = require('@elice/blocks');
@@ -15,34 +13,28 @@ var randomId = require('./utils/randomId.js');
15
13
  var context = require('./context.js');
16
14
  var MaterialSurveyEditOptionSelect = require('./MaterialSurveyEditOptionSelect.js');
17
15
 
18
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
19
-
20
- var React__default = /*#__PURE__*/_interopDefaultCompat(React);
21
- var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
22
-
23
- var MIN_TEXT_LENGTH = 1;
24
- var MAX_TEXT_LENGTH = 128;
25
- var StyledSurveyOptionTypeSelectWrap = styled__default.default.div.withConfig({
16
+ const MIN_TEXT_LENGTH = 1;
17
+ const MAX_TEXT_LENGTH = 128;
18
+ const StyledSurveyOptionTypeSelectWrap = styled.div.withConfig({
26
19
  componentId: "sc-r4ms68-0"
27
20
  })(["display:flex;max-width:12rem;"]);
28
- var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
29
- var intl$1 = intl.useRawEliceIntl();
30
- var _useMaterialSurveyEdi = context.useMaterialSurveyEditContext(),
31
- disabled = _useMaterialSurveyEdi.disabled,
32
- onFileUploadRequest = _useMaterialSurveyEdi.onFileUploadRequest;
33
- var _useFormContext = reactHookForm.useFormContext(),
34
- control = _useFormContext.control,
35
- watch = _useFormContext.watch,
36
- setValue = _useFormContext.setValue;
37
- var _watch = watch(['questionInfoList.0.optionType', 'questionInfoList.0.optionInfo']),
38
- _watch2 = _rollupPluginBabelHelpers.slicedToArray(_watch, 2),
39
- watchedOptionType = _watch2[0],
40
- watchedOptionInfo = _watch2[1];
21
+ const MaterialSurveyEditContent = () => {
22
+ const intl$1 = intl.useRawEliceIntl();
23
+ const {
24
+ disabled,
25
+ onFileUploadRequest
26
+ } = context.useMaterialSurveyEditContext();
27
+ const {
28
+ control,
29
+ watch,
30
+ setValue
31
+ } = reactHookForm.useFormContext();
32
+ const [watchedOptionType, watchedOptionInfo] = watch(['questionInfoList.0.optionType', 'questionInfoList.0.optionInfo']);
41
33
  //
42
34
  // Change `optionInfo` according to `optionType`.
43
35
  //
44
- React__default.default.useEffect(function () {
45
- var get = function get() {
36
+ React.useEffect(() => {
37
+ const get = () => {
46
38
  switch (watchedOptionType) {
47
39
  case types.enums.SurveyOptionType.SelectOne:
48
40
  case types.enums.SurveyOptionType.SelectMultiple:
@@ -77,29 +69,28 @@ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
77
69
  * Input of option info and answer info,
78
70
  * according to option type.
79
71
  */
80
- var Option = React__default.default.useMemo(function () {
72
+ const Option = React.useMemo(() => {
81
73
  switch (watchedOptionType) {
82
74
  case types.enums.SurveyOptionType.SelectOne:
83
75
  case types.enums.SurveyOptionType.SelectMultiple:
84
76
  return MaterialSurveyEditOptionSelect.default;
85
77
  case types.enums.SurveyOptionType.Text:
86
78
  default:
87
- return React__default.default.Fragment;
79
+ return React.Fragment;
88
80
  }
89
81
  }, [watchedOptionType]);
90
82
  /**
91
83
  * Render input for survey title.
92
84
  */
93
- var renderQuestionTitleInput = function renderQuestionTitleInput() {
94
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
95
- label: jsxRuntime.jsx(blocks.Label, {
85
+ const renderQuestionTitleInput = () => {
86
+ return React.createElement(blocks.FormInputVerticalLayout, {
87
+ label: React.createElement(blocks.Label, {
96
88
  size: "small",
97
- required: true,
98
- children: intl$1.formatMessage({
99
- id: 'content.title'
100
- })
101
- }),
102
- input: jsxRuntime.jsx(reactHookForm.Controller, {
89
+ required: true
90
+ }, intl$1.formatMessage({
91
+ id: 'content.title'
92
+ })),
93
+ input: React.createElement(reactHookForm.Controller, {
103
94
  control: control,
104
95
  name: "questionInfoList.0.questionTitle",
105
96
  rules: {
@@ -128,11 +119,12 @@ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
128
119
  })
129
120
  }
130
121
  },
131
- render: function render(_ref) {
132
- var field = _ref.field,
133
- fieldState = _ref.fieldState;
122
+ render: ({
123
+ field,
124
+ fieldState
125
+ }) => {
134
126
  var _a;
135
- return jsxRuntime.jsx(blocks.Input, Object.assign({
127
+ return React.createElement(blocks.Input, Object.assign({
136
128
  size: "small",
137
129
  width: "full",
138
130
  minLength: MIN_TEXT_LENGTH,
@@ -150,93 +142,79 @@ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
150
142
  /**
151
143
  * Render input for survey description.
152
144
  */
153
- var renderQuestionDescriptionInput = function renderQuestionDescriptionInput() {
154
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
155
- label: jsxRuntime.jsx(blocks.Label, {
156
- size: "small",
157
- children: intl$1.formatMessage({
158
- id: 'content.description.title'
159
- })
160
- }),
161
- input: jsxRuntime.jsx(reactHookForm.Controller, {
145
+ const renderQuestionDescriptionInput = () => {
146
+ return React.createElement(blocks.FormInputVerticalLayout, {
147
+ label: React.createElement(blocks.Label, {
148
+ size: "small"
149
+ }, intl$1.formatMessage({
150
+ id: 'content.description.title'
151
+ })),
152
+ input: React.createElement(reactHookForm.Controller, {
162
153
  control: control,
163
154
  name: "questionInfoList.0.questionDescription",
164
- render: function render(_ref2) {
165
- var field = _ref2.field;
166
- return jsxRuntime.jsx(index.MarkdownEditor, Object.assign({
167
- placeholder: intl$1.formatMessage({
168
- id: 'content.description.placeholder'
169
- }),
170
- onFileUploadRequest: onFileUploadRequest
171
- }, field));
172
- }
155
+ render: ({
156
+ field
157
+ }) => React.createElement(index.MarkdownEditor, Object.assign({
158
+ placeholder: intl$1.formatMessage({
159
+ id: 'content.description.placeholder'
160
+ }),
161
+ onFileUploadRequest: onFileUploadRequest
162
+ }, field))
173
163
  })
174
164
  });
175
165
  };
176
166
  /**
177
167
  * Render input of option type, option info and answer info.
178
168
  */
179
- var renderOptionInput = function renderOptionInput() {
180
- return jsxRuntime.jsx(blocks.FormInputVerticalLayout, {
181
- label: jsxRuntime.jsx(blocks.Label, {
169
+ const renderOptionInput = () => {
170
+ return React.createElement(blocks.FormInputVerticalLayout, {
171
+ label: React.createElement(blocks.Label, {
182
172
  size: "small",
183
- required: true,
184
- children: intl$1.formatMessage({
185
- id: 'content.option.title'
186
- })
187
- }),
188
- input: jsxRuntime.jsxs(jsxRuntime.Fragment, {
189
- children: [jsxRuntime.jsx(reactHookForm.Controller, {
190
- control: control,
191
- name: "questionInfoList.0.optionType",
192
- render: function render(_ref3) {
193
- var field = _ref3.field;
194
- return jsxRuntime.jsx(blocks.Tooltip, {
195
- title: disabled ? intl$1.formatMessage({
196
- id: 'content.option.tooltip.disabled'
197
- }) : undefined,
198
- placement: "top-end",
199
- children: jsxRuntime.jsx(StyledSurveyOptionTypeSelectWrap, {
200
- children: jsxRuntime.jsxs(blocks.Select, Object.assign({
201
- size: "small",
202
- width: "small",
203
- readOnly: disabled
204
- }, field, {
205
- onChange: function onChange(v) {
206
- return field.onChange(Number(v));
207
- },
208
- children: [jsxRuntime.jsx("option", {
209
- value: types.enums.SurveyOptionType.SelectOne,
210
- children: intl$1.formatMessage({
211
- id: 'content.option.select.items.selectOne'
212
- })
213
- }), jsxRuntime.jsx("option", {
214
- value: types.enums.SurveyOptionType.SelectMultiple,
215
- children: intl$1.formatMessage({
216
- id: 'content.option.select.items.selectMultiple'
217
- })
218
- }), jsxRuntime.jsx("option", {
219
- value: types.enums.SurveyOptionType.Text,
220
- children: intl$1.formatMessage({
221
- id: 'content.option.select.items.text'
222
- })
223
- })]
224
- }))
225
- })
226
- });
227
- }
228
- }), jsxRuntime.jsx(blocks.Vspace, {
229
- height: 0.5
230
- }), jsxRuntime.jsx(Option, {})]
231
- })
173
+ required: true
174
+ }, intl$1.formatMessage({
175
+ id: 'content.option.title'
176
+ })),
177
+ input: React.createElement(React.Fragment, null, React.createElement(reactHookForm.Controller, {
178
+ control: control,
179
+ name: "questionInfoList.0.optionType",
180
+ render: ({
181
+ field
182
+ }) => React.createElement(blocks.Tooltip, {
183
+ title: disabled ? intl$1.formatMessage({
184
+ id: 'content.option.tooltip.disabled'
185
+ }) : undefined,
186
+ placement: "top-end"
187
+ }, React.createElement(StyledSurveyOptionTypeSelectWrap, null, React.createElement(blocks.Select, Object.assign({
188
+ size: "small",
189
+ width: "small",
190
+ readOnly: disabled
191
+ }, field, {
192
+ onChange: v => field.onChange(Number(v))
193
+ }), React.createElement("option", {
194
+ value: types.enums.SurveyOptionType.SelectOne,
195
+ children: intl$1.formatMessage({
196
+ id: 'content.option.select.items.selectOne'
197
+ })
198
+ }), React.createElement("option", {
199
+ value: types.enums.SurveyOptionType.SelectMultiple,
200
+ children: intl$1.formatMessage({
201
+ id: 'content.option.select.items.selectMultiple'
202
+ })
203
+ }), React.createElement("option", {
204
+ value: types.enums.SurveyOptionType.Text,
205
+ children: intl$1.formatMessage({
206
+ id: 'content.option.select.items.text'
207
+ })
208
+ }))))
209
+ }), React.createElement(blocks.Vspace, {
210
+ height: 0.5
211
+ }), React.createElement(Option, null))
232
212
  });
233
213
  };
234
214
  //
235
215
  //
236
216
  //
237
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
238
- children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput()]
239
- });
217
+ return React.createElement(React.Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput());
240
218
  };
241
219
 
242
220
  exports.default = MaterialSurveyEditContent;
@@ -2,7 +2,7 @@
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 reactHookForm = require('react-hook-form');
7
7
  var blocks = require('@elice/blocks');
8
8
  var icons = require('@elice/icons');
@@ -11,36 +11,35 @@ var styled = require('styled-components');
11
11
  var randomId = require('./utils/randomId.js');
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
- var MIN_OPTION_INFO_COUNT = 2;
19
- var MAX_OPTION_INFO_COUNT = 20;
20
- var StyledWrap = styled__default.default.div.withConfig({
14
+ const MIN_OPTION_INFO_COUNT = 2;
15
+ const MAX_OPTION_INFO_COUNT = 20;
16
+ const StyledWrap = styled.div.withConfig({
21
17
  componentId: "sc-1eiyk6z-0"
22
18
  })([""]);
23
- var StyledInputGroup = styled__default.default.div.withConfig({
19
+ const StyledInputGroup = styled.div.withConfig({
24
20
  componentId: "sc-1eiyk6z-1"
25
21
  })(["width:100%;.eb-input{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
26
- var OptionSelectOne = function OptionSelectOne() {
27
- var intl$1 = intl.useRawEliceIntl();
28
- var _useMaterialSurveyEdi = context.useMaterialSurveyEditContext(),
29
- disabled = _useMaterialSurveyEdi.disabled;
30
- var _useFormContext = reactHookForm.useFormContext(),
31
- control = _useFormContext.control;
32
- var _useFieldArray = reactHookForm.useFieldArray({
33
- name: 'questionInfoList.0.optionInfo',
34
- keyName: 'id',
35
- shouldUnregister: true
36
- }),
37
- optionInfoFields = _useFieldArray.fields,
38
- appendOptionInfoFieldItem = _useFieldArray.append,
39
- removeOptionInfoFieldItem = _useFieldArray.remove;
22
+ const OptionSelectOne = () => {
23
+ const intl$1 = intl.useRawEliceIntl();
24
+ const {
25
+ disabled
26
+ } = context.useMaterialSurveyEditContext();
27
+ const {
28
+ control
29
+ } = reactHookForm.useFormContext();
30
+ const {
31
+ fields: optionInfoFields,
32
+ append: appendOptionInfoFieldItem,
33
+ remove: removeOptionInfoFieldItem
34
+ } = reactHookForm.useFieldArray({
35
+ name: 'questionInfoList.0.optionInfo',
36
+ keyName: 'id',
37
+ shouldUnregister: true
38
+ });
40
39
  /**
41
40
  * Append option info.
42
41
  */
43
- var appendOptionInfo = function appendOptionInfo() {
42
+ const appendOptionInfo = () => {
44
43
  appendOptionInfoFieldItem({
45
44
  id: randomId.createRandomId(),
46
45
  value: ''
@@ -49,88 +48,76 @@ var OptionSelectOne = function OptionSelectOne() {
49
48
  /**
50
49
  * Remove item from option info at index.
51
50
  */
52
- var removeOptionInfo = function removeOptionInfo(index) {
51
+ const removeOptionInfo = index => {
53
52
  removeOptionInfoFieldItem(index);
54
53
  };
55
54
  //
56
55
  //
57
56
  //
58
- return jsxRuntime.jsxs(StyledWrap, {
59
- children: [jsxRuntime.jsx(StyledInputGroup, {
60
- children: optionInfoFields.map(function (_ref, index) {
61
- var id = _ref.id;
62
- return jsxRuntime.jsx(reactHookForm.Controller, {
63
- control: control,
64
- name: "questionInfoList.0.optionInfo.".concat(index, ".value"),
65
- rules: {
66
- required: {
67
- value: true,
68
- message: intl$1.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 jsxRuntime.jsx(blocks.Input, Object.assign({
78
- size: "small",
79
- width: "full",
80
- placeholder: intl$1.formatMessage({
81
- id: 'option.common.select.placeholder'
82
- }),
83
- suffix: jsxRuntime.jsx(blocks.Tooltip, {
84
- title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
85
- id: 'option.common.select.tooltip.minOptionInfoItem'
86
- }) : undefined,
87
- placement: "top-start",
88
- children: jsxRuntime.jsx("span", {
89
- children: jsxRuntime.jsx(blocks.IconButton, {
90
- icon: icons.eilMathsignMultiplyBasic,
91
- role: "grey9",
92
- size: "tiny",
93
- border: false,
94
- transparent: true,
95
- disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
96
- onClick: function onClick() {
97
- return removeOptionInfo(index);
98
- }
99
- })
100
- })
101
- }),
102
- readOnly: disabled,
103
- invalid: fieldState.invalid,
104
- invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
105
- }, field));
106
- }
107
- }, id);
108
- })
109
- }), jsxRuntime.jsx(blocks.Vspace, {
110
- height: 0.5
111
- }), jsxRuntime.jsx(blocks.Tooltip, {
112
- title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
113
- id: 'option.common.select.tooltip.maxOptionInfoItem'
114
- }) : undefined,
115
- placement: "bottom",
116
- children: jsxRuntime.jsx("span", {
117
- children: jsxRuntime.jsx(blocks.Button, {
118
- block: true,
119
- size: "micro",
120
- borderDashed: true,
121
- transparent: true,
122
- icon: jsxRuntime.jsx(blocks.Icon, {
123
- icon: icons.eilMathsignAddCircle
124
- }),
125
- disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
126
- onClick: appendOptionInfo,
127
- children: intl$1.formatMessage({
128
- id: 'option.common.select.addButton'
129
- })
57
+ return React.createElement(StyledWrap, null, React.createElement(StyledInputGroup, null, optionInfoFields.map(({
58
+ id
59
+ }, index) => React.createElement(reactHookForm.Controller, {
60
+ key: id,
61
+ control: control,
62
+ name: `questionInfoList.0.optionInfo.${index}.value`,
63
+ rules: {
64
+ required: {
65
+ value: true,
66
+ message: intl$1.formatMessage({
67
+ id: 'option.common.select.errorMessage.required'
130
68
  })
131
- })
132
- })]
133
- });
69
+ }
70
+ },
71
+ render: ({
72
+ field,
73
+ fieldState
74
+ }) => {
75
+ var _a;
76
+ return React.createElement(blocks.Input, Object.assign({
77
+ size: "small",
78
+ width: "full",
79
+ placeholder: intl$1.formatMessage({
80
+ id: 'option.common.select.placeholder'
81
+ }),
82
+ suffix: React.createElement(blocks.Tooltip, {
83
+ title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
84
+ id: 'option.common.select.tooltip.minOptionInfoItem'
85
+ }) : undefined,
86
+ placement: "top-start"
87
+ }, React.createElement("span", null, React.createElement(blocks.IconButton, {
88
+ icon: icons.eilMathsignMultiplyBasic,
89
+ role: "grey9",
90
+ size: "tiny",
91
+ border: false,
92
+ transparent: true,
93
+ disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
94
+ onClick: () => removeOptionInfo(index)
95
+ }))),
96
+ readOnly: disabled,
97
+ invalid: fieldState.invalid,
98
+ invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
99
+ }, field));
100
+ }
101
+ }))), React.createElement(blocks.Vspace, {
102
+ height: 0.5
103
+ }), React.createElement(blocks.Tooltip, {
104
+ title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
105
+ id: 'option.common.select.tooltip.maxOptionInfoItem'
106
+ }) : undefined,
107
+ placement: "bottom"
108
+ }, React.createElement("span", null, React.createElement(blocks.Button, {
109
+ block: true,
110
+ size: "micro",
111
+ borderDashed: true,
112
+ transparent: true,
113
+ icon: React.createElement(blocks.Icon, {
114
+ icon: icons.eilMathsignAddCircle
115
+ }),
116
+ disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
117
+ onClick: appendOptionInfo
118
+ }, intl$1.formatMessage({
119
+ id: 'option.common.select.addButton'
120
+ })))));
134
121
  };
135
122
 
136
123
  exports.default = OptionSelectOne;
@@ -4,14 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
6
 
7
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
8
-
9
- var React__default = /*#__PURE__*/_interopDefaultCompat(React);
10
-
11
- var MaterialSurveyEditContext = React__default.default.createContext(null);
12
- var useMaterialSurveyEditContext = function useMaterialSurveyEditContext() {
13
- return React__default.default.useContext(MaterialSurveyEditContext);
14
- };
7
+ const MaterialSurveyEditContext = React.createContext(null);
8
+ const useMaterialSurveyEditContext = () => React.useContext(MaterialSurveyEditContext);
15
9
 
16
10
  exports.default = MaterialSurveyEditContext;
17
11
  exports.useMaterialSurveyEditContext = useMaterialSurveyEditContext;