@elice/material-survey 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 (67) hide show
  1. package/cjs/_virtual/_rollupPluginBabelHelpers.js +399 -0
  2. package/cjs/components/markdown-editor/index.d.ts +1 -2
  3. package/cjs/components/markdown-editor/index.js +19 -10
  4. package/cjs/components/material-survey/MaterialSurvey.js +82 -57
  5. package/cjs/components/material-survey/MaterialSurveyInfo.js +69 -59
  6. package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +131 -90
  7. package/cjs/components/material-survey/MaterialSurveySelectOne.js +125 -86
  8. package/cjs/components/material-survey/MaterialSurveyShimmer.js +47 -40
  9. package/cjs/components/material-survey/MaterialSurveyText.js +114 -75
  10. package/cjs/components/material-survey/SurveyResultBadge.js +17 -10
  11. package/cjs/components/material-survey/SurveySubmitStatusText.js +21 -16
  12. package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
  13. package/cjs/components/material-survey/context/MaterialSurveyContext.js +115 -74
  14. package/cjs/components/material-survey/index.js +9 -0
  15. package/cjs/components/material-survey/locales/index.js +13 -0
  16. package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +49 -36
  17. package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +113 -91
  18. package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +100 -87
  19. package/cjs/components/material-survey-edit/context.js +8 -2
  20. package/cjs/components/material-survey-edit/index.js +7 -0
  21. package/cjs/components/material-survey-edit/locales/index.js +13 -0
  22. package/cjs/components/material-survey-edit/utils/editValue.js +17 -11
  23. package/cjs/components/shared/StyledMarkdown.js +5 -1
  24. package/cjs/components/shared/SurveyContentBox.js +85 -74
  25. package/cjs/components/shared/index.js +13 -0
  26. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
  27. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  28. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
  29. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +66 -89
  30. package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
  31. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  32. package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
  33. package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -80
  34. package/es/_virtual/_rollupPluginBabelHelpers.js +386 -0
  35. package/es/components/markdown-editor/index.d.ts +1 -2
  36. package/es/components/markdown-editor/index.js +15 -10
  37. package/es/components/material-survey/MaterialSurvey.js +77 -57
  38. package/es/components/material-survey/MaterialSurveyInfo.js +65 -59
  39. package/es/components/material-survey/MaterialSurveySelectMultiple.js +127 -90
  40. package/es/components/material-survey/MaterialSurveySelectOne.js +121 -86
  41. package/es/components/material-survey/MaterialSurveyShimmer.js +43 -40
  42. package/es/components/material-survey/MaterialSurveyText.js +109 -75
  43. package/es/components/material-survey/SurveyResultBadge.js +13 -10
  44. package/es/components/material-survey/SurveySubmitStatusText.js +17 -16
  45. package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
  46. package/es/components/material-survey/context/MaterialSurveyContext.js +112 -75
  47. package/es/components/material-survey/index.js +2 -0
  48. package/es/components/material-survey/locales/index.js +4 -0
  49. package/es/components/material-survey-edit/MaterialSurveyEdit.js +45 -36
  50. package/es/components/material-survey-edit/MaterialSurveyEditContent.js +107 -90
  51. package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +96 -87
  52. package/es/components/material-survey-edit/context.js +4 -2
  53. package/es/components/material-survey-edit/index.js +1 -0
  54. package/es/components/material-survey-edit/locales/index.js +4 -0
  55. package/es/components/material-survey-edit/utils/editValue.js +17 -11
  56. package/es/components/shared/StyledMarkdown.js +1 -1
  57. package/es/components/shared/SurveyContentBox.js +81 -74
  58. package/es/components/shared/index.js +4 -0
  59. package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
  60. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
  61. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
  62. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +61 -89
  63. package/es/components/shared/question-radio/QuestionRadio.js +9 -7
  64. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
  65. package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
  66. package/es/components/shared/question-radio/QuestionRadioOption.js +54 -80
  67. package/package.json +9 -12
@@ -1,31 +1,32 @@
1
- import React from 'react';
1
+ import { jsx } from 'react/jsx-runtime';
2
2
  import { StatusText } from '@elice/blocks';
3
3
  import { useRawEliceIntl } from '@elice/intl';
4
4
  import { colors } from '@elice/mui-system';
5
5
  import styled from 'styled-components';
6
6
 
7
- const StyledSuccessStatusText = styled(StatusText).withConfig({
7
+ var StyledSuccessStatusText = styled(StatusText).withConfig({
8
8
  componentId: "sc-szxa5m-0"
9
9
  })(["color:", ";"], colors.green[400]);
10
- const SurveySubmitStatusText = ({
11
- status
12
- }) => {
13
- const intl = useRawEliceIntl();
10
+ var SurveySubmitStatusText = function SurveySubmitStatusText(_ref) {
11
+ var status = _ref.status;
12
+ var intl = useRawEliceIntl();
14
13
  switch (status) {
15
14
  case 'resolved':
16
- return React.createElement(StyledSuccessStatusText, {
15
+ return jsx(StyledSuccessStatusText, {
17
16
  role: "success",
18
- size: "small"
19
- }, intl.formatMessage({
20
- id: 'materialSurvey.submitStatus.success'
21
- }));
17
+ size: "small",
18
+ children: intl.formatMessage({
19
+ id: 'materialSurvey.submitStatus.success'
20
+ })
21
+ });
22
22
  case 'rejected':
23
- return React.createElement(StatusText, {
23
+ return jsx(StatusText, {
24
24
  role: "danger",
25
- size: "small"
26
- }, intl.formatMessage({
27
- id: 'materialSurvey.submitStatus.failure'
28
- }));
25
+ size: "small",
26
+ children: intl.formatMessage({
27
+ id: 'materialSurvey.submitStatus.failure'
28
+ })
29
+ });
29
30
  default:
30
31
  return null;
31
32
  }
@@ -25,7 +25,7 @@ interface DispatchContextType {
25
25
  setVertical: React.Dispatch<React.SetStateAction<boolean>>;
26
26
  onNext?: () => void;
27
27
  }
28
- declare function MaterialSurveyProvider({ materialSurveyId, userId, onSubmit, onNext, children, }: MaterialSurveyProviderProps): React.JSX.Element;
28
+ declare function MaterialSurveyProvider({ materialSurveyId, userId, onSubmit, onNext, children, }: MaterialSurveyProviderProps): JSX.Element;
29
29
  declare function useMaterialSurveyState(): State;
30
30
  declare function useMaterialSurveyDispatch(): DispatchContextType;
31
31
  export { MaterialSurveyProvider, useMaterialSurveyState, useMaterialSurveyDispatch, };
@@ -1,100 +1,137 @@
1
+ import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsx } from 'react/jsx-runtime';
1
3
  import React from 'react';
2
- import { config, getOrgMaterialSurveyGet, getOrgCourseGet, getOrgLectureGet } from '@elice/api-client';
4
+ import { config, getOrgMaterialSurveyGet, getOrgLectureGet, getOrgCourseGet } from '@elice/api-client';
3
5
  import { useMaterialConfigApiClientUpdate, useMaterialFetchRaw } from '@elice/material-shared-utils';
4
6
  import { enums } from '@elice/types';
5
7
 
6
- const StateContext = React.createContext(undefined);
7
- const DispatchContext = React.createContext(undefined);
8
+ var StateContext = React.createContext(undefined);
9
+ var DispatchContext = React.createContext(undefined);
8
10
  StateContext.displayName = 'MaterialSurveyStateContext';
9
11
  DispatchContext.displayName = 'MaterialSurveyDispatchContext';
10
- function MaterialSurveyProvider({
11
- materialSurveyId,
12
- userId,
13
- onSubmit = () => void 0,
14
- onNext,
15
- children
16
- }) {
17
- const [course, setCourse] = React.useState();
18
- const [lecture, setLecture] = React.useState();
19
- const [initStatus, setInitStatus] = React.useState('idle');
20
- const [vertical, setVertical] = React.useState(false);
21
- const canInit = useMaterialConfigApiClientUpdate(config.init);
22
- const {
23
- materialSurvey,
24
- materialLecturePage,
25
- refetch: refreshOrgMaterialSurvey
26
- } = useMaterialFetchRaw(enums.LectureMaterialType.Survey, React.useCallback(signal => getOrgMaterialSurveyGet({
27
- materialSurveyId
28
- }, {
29
- signal
30
- }), [materialSurveyId]), canInit);
31
- const doInitilize = React.useCallback(async () => {
32
- const controller = new AbortController();
33
- const {
34
- signal
35
- } = controller;
36
- try {
37
- setInitStatus('pending');
38
- if (!materialLecturePage) {
39
- throw new Error('materialSurvey is not ready');
40
- }
41
- // fetch course
42
- const {
43
- course
44
- } = await getOrgCourseGet({
45
- courseId: materialLecturePage.courseId
46
- }, {
47
- signal
48
- });
49
- // fetch lecture
50
- const {
51
- lecture
52
- } = await getOrgLectureGet({
53
- lectureId: materialLecturePage.lectureId
12
+ function MaterialSurveyProvider(_ref) {
13
+ var materialSurveyId = _ref.materialSurveyId,
14
+ userId = _ref.userId,
15
+ _ref$onSubmit = _ref.onSubmit,
16
+ onSubmit = _ref$onSubmit === void 0 ? function () {
17
+ return void 0;
18
+ } : _ref$onSubmit,
19
+ onNext = _ref.onNext,
20
+ children = _ref.children;
21
+ var _React$useState = React.useState(),
22
+ _React$useState2 = _slicedToArray(_React$useState, 2),
23
+ course = _React$useState2[0],
24
+ setCourse = _React$useState2[1];
25
+ var _React$useState3 = React.useState(),
26
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
27
+ lecture = _React$useState4[0],
28
+ setLecture = _React$useState4[1];
29
+ var _React$useState5 = React.useState('idle'),
30
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
31
+ initStatus = _React$useState6[0],
32
+ setInitStatus = _React$useState6[1];
33
+ var _React$useState7 = React.useState(false),
34
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
35
+ vertical = _React$useState8[0],
36
+ setVertical = _React$useState8[1];
37
+ var canInit = useMaterialConfigApiClientUpdate(config.init);
38
+ var _useMaterialFetchRaw = useMaterialFetchRaw(enums.LectureMaterialType.Survey, React.useCallback(function (signal) {
39
+ return getOrgMaterialSurveyGet({
40
+ materialSurveyId: materialSurveyId
54
41
  }, {
55
- signal
42
+ signal: signal
56
43
  });
57
- setCourse(course);
58
- setLecture(lecture);
59
- setInitStatus('resolved');
60
- } catch (error) {
61
- console.error(error);
62
- setInitStatus('rejected');
63
- }
64
- return () => controller.abort();
65
- }, [materialLecturePage]);
66
- React.useEffect(() => {
44
+ }, [materialSurveyId]), canInit),
45
+ materialSurvey = _useMaterialFetchRaw.materialSurvey,
46
+ materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
47
+ refreshOrgMaterialSurvey = _useMaterialFetchRaw.refetch;
48
+ var doInitilize = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
49
+ var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
50
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
51
+ while (1) switch (_context.prev = _context.next) {
52
+ case 0:
53
+ controller = new AbortController();
54
+ signal = controller.signal;
55
+ _context.prev = 2;
56
+ setInitStatus('pending');
57
+ if (materialLecturePage) {
58
+ _context.next = 6;
59
+ break;
60
+ }
61
+ throw new Error('materialSurvey is not ready');
62
+ case 6:
63
+ _context.next = 8;
64
+ return getOrgCourseGet({
65
+ courseId: materialLecturePage.courseId
66
+ }, {
67
+ signal: signal
68
+ });
69
+ case 8:
70
+ _yield$getOrgCourseGe = _context.sent;
71
+ _course = _yield$getOrgCourseGe.course;
72
+ _context.next = 12;
73
+ return getOrgLectureGet({
74
+ lectureId: materialLecturePage.lectureId
75
+ }, {
76
+ signal: signal
77
+ });
78
+ case 12:
79
+ _yield$getOrgLectureG = _context.sent;
80
+ _lecture = _yield$getOrgLectureG.lecture;
81
+ setCourse(_course);
82
+ setLecture(_lecture);
83
+ setInitStatus('resolved');
84
+ _context.next = 23;
85
+ break;
86
+ case 19:
87
+ _context.prev = 19;
88
+ _context.t0 = _context["catch"](2);
89
+ console.error(_context.t0);
90
+ setInitStatus('rejected');
91
+ case 23:
92
+ return _context.abrupt("return", function () {
93
+ return controller.abort();
94
+ });
95
+ case 24:
96
+ case "end":
97
+ return _context.stop();
98
+ }
99
+ }, _callee, null, [[2, 19]]);
100
+ })), [materialLecturePage]);
101
+ React.useEffect(function () {
67
102
  if (canInit && materialLecturePage) {
68
103
  void doInitilize();
69
104
  }
70
105
  }, [canInit, materialLecturePage, doInitilize]);
71
- return React.createElement(StateContext.Provider, {
106
+ return jsx(StateContext.Provider, {
72
107
  value: {
73
- course,
74
- lecture,
108
+ course: course,
109
+ lecture: lecture,
75
110
  materialSurvey: materialSurvey !== null && materialSurvey !== void 0 ? materialSurvey : undefined,
76
- userId,
77
- vertical,
78
- initStatus
79
- }
80
- }, React.createElement(DispatchContext.Provider, {
81
- value: {
82
- onSubmit,
83
- onNext,
84
- refreshOrgMaterialSurvey,
85
- setVertical
86
- }
87
- }, children));
111
+ userId: userId,
112
+ vertical: vertical,
113
+ initStatus: initStatus
114
+ },
115
+ children: jsx(DispatchContext.Provider, {
116
+ value: {
117
+ onSubmit: onSubmit,
118
+ onNext: onNext,
119
+ refreshOrgMaterialSurvey: refreshOrgMaterialSurvey,
120
+ setVertical: setVertical
121
+ },
122
+ children: children
123
+ })
124
+ });
88
125
  }
89
126
  function useMaterialSurveyState() {
90
- const context = React.useContext(StateContext);
127
+ var context = React.useContext(StateContext);
91
128
  if (context === undefined) {
92
129
  throw new Error('useMaterialSurveyState must be used within a MaterialSurveyProvider');
93
130
  }
94
131
  return context;
95
132
  }
96
133
  function useMaterialSurveyDispatch() {
97
- const context = React.useContext(DispatchContext);
134
+ var context = React.useContext(DispatchContext);
98
135
  if (context === undefined) {
99
136
  throw new Error('useMaterialSurveyDispatch must be used within a MaterialSurveyProvider');
100
137
  }
@@ -0,0 +1,2 @@
1
+ export { default as MaterialSurvey } from './MaterialSurvey.js';
2
+ export { default as MaterialSurveyInfo } from './MaterialSurveyInfo.js';
@@ -0,0 +1,4 @@
1
+ export { default as messageEn } from './en.json.js';
2
+ export { default as messageKo } from './ko.json.js';
3
+ export { default as messageTh } from './th.json.js';
4
+ export { default as messageJa } from './ja.json.js';
@@ -1,3 +1,4 @@
1
+ import { jsx } from 'react/jsx-runtime';
1
2
  import React, { forwardRef } from 'react';
2
3
  import { useForm, FormProvider } from 'react-hook-form';
3
4
  import { RawEliceIntlProvider, IntlComponentBuilder } from '@elice/intl';
@@ -11,29 +12,28 @@ import MaterialSurveyEditContent from './MaterialSurveyEditContent.js';
11
12
  //
12
13
  //
13
14
  //
14
- const MaterialSurveyEdit = forwardRef(({
15
- value,
16
- disabled = false,
17
- onChange,
18
- onFormStateChange,
19
- onFileUploadRequest,
20
- __intl
21
- }, ref) => {
22
- const formElRef = React.useRef(null);
23
- const useFormMethods = useForm({
15
+ var MaterialSurveyEdit = forwardRef(function (_ref, ref) {
16
+ var value = _ref.value,
17
+ _ref$disabled = _ref.disabled,
18
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
19
+ onChange = _ref.onChange,
20
+ onFormStateChange = _ref.onFormStateChange,
21
+ onFileUploadRequest = _ref.onFileUploadRequest,
22
+ __intl = _ref.__intl;
23
+ var formElRef = React.useRef(null);
24
+ var useFormMethods = useForm({
24
25
  defaultValues: manipulateValue(value),
25
26
  mode: 'onBlur'
26
27
  });
27
- const watchedMaterialSurveyEditValue = useFormMethods.watch();
28
- const {
29
- isDirty,
30
- isValid
31
- } = useFormMethods.formState;
28
+ var watchedMaterialSurveyEditValue = useFormMethods.watch();
29
+ var _useFormMethods$formS = useFormMethods.formState,
30
+ isDirty = _useFormMethods$formS.isDirty,
31
+ isValid = _useFormMethods$formS.isValid;
32
32
  //
33
33
  // Reset from value, when `value` changes.
34
34
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
35
35
  //
36
- useDeepClonedCompareEffect(() => {
36
+ useDeepClonedCompareEffect(function () {
37
37
  useFormMethods.reset(manipulateValue(value), {
38
38
  keepDirty: true,
39
39
  keepErrors: true,
@@ -47,15 +47,17 @@ const MaterialSurveyEdit = forwardRef(({
47
47
  // Emit `onChange` handler when form value changed.
48
48
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
49
49
  //
50
- useDeepClonedCompareEffect(() => onChange(restoreValue(watchedMaterialSurveyEditValue)), [watchedMaterialSurveyEditValue]);
50
+ useDeepClonedCompareEffect(function () {
51
+ return onChange(restoreValue(watchedMaterialSurveyEditValue));
52
+ }, [watchedMaterialSurveyEditValue]);
51
53
  //
52
54
  // Emit `onFormStateChange` handler when form state change.
53
55
  //
54
- React.useEffect(() => {
56
+ React.useEffect(function () {
55
57
  if (typeof onFormStateChange === 'function') {
56
58
  onFormStateChange({
57
- isDirty,
58
- isValid
59
+ isDirty: isDirty,
60
+ isValid: isValid
59
61
  });
60
62
  }
61
63
  },
@@ -64,25 +66,32 @@ const MaterialSurveyEdit = forwardRef(({
64
66
  //
65
67
  // Set ref.
66
68
  //
67
- React.useImperativeHandle(ref, () => Object.assign(Object.assign({}, formElRef.current), {
68
- reset: () => {
69
- useFormMethods.reset(manipulateValue(value));
70
- void useFormMethods.trigger();
71
- }
72
- }), [useFormMethods, value]);
69
+ React.useImperativeHandle(ref, function () {
70
+ return Object.assign(Object.assign({}, formElRef.current), {
71
+ reset: function reset() {
72
+ useFormMethods.reset(manipulateValue(value));
73
+ void useFormMethods.trigger();
74
+ }
75
+ });
76
+ }, [useFormMethods, value]);
73
77
  //
74
78
  //
75
79
  //
76
- return React.createElement(RawEliceIntlProvider, {
77
- value: __intl
78
- }, React.createElement("form", {
79
- ref: formElRef
80
- }, React.createElement(MaterialSurveyEditContext.Provider, {
81
- value: {
82
- disabled,
83
- onFileUploadRequest
84
- }
85
- }, React.createElement(FormProvider, Object.assign({}, useFormMethods), React.createElement(MaterialSurveyEditContent, null)))));
80
+ return jsx(RawEliceIntlProvider, {
81
+ value: __intl,
82
+ children: jsx("form", {
83
+ ref: formElRef,
84
+ children: jsx(MaterialSurveyEditContext.Provider, {
85
+ value: {
86
+ disabled: disabled,
87
+ onFileUploadRequest: onFileUploadRequest
88
+ },
89
+ children: jsx(FormProvider, Object.assign({}, useFormMethods, {
90
+ children: jsx(MaterialSurveyEditContent, {})
91
+ }))
92
+ })
93
+ })
94
+ });
86
95
  });
87
96
  var MaterialSurveyEdit$1 = new IntlComponentBuilder(MaterialSurveyEdit).add('en', messageEn).add('ko', messageKo).addAsync('th', import('./locales/th.json.js')).addAsync('ja', import('./locales/ja.json.js')).build();
88
97
 
@@ -1,3 +1,5 @@
1
+ import { slicedToArray as _slicedToArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
1
3
  import React from 'react';
2
4
  import { useFormContext, Controller } from 'react-hook-form';
3
5
  import { FormInputVerticalLayout, Label, Input, Tooltip, Select, Vspace } from '@elice/blocks';
@@ -9,28 +11,29 @@ import { createRandomId } from './utils/randomId.js';
9
11
  import { useMaterialSurveyEditContext } from './context.js';
10
12
  import OptionSelectOne from './MaterialSurveyEditOptionSelect.js';
11
13
 
12
- const MIN_TEXT_LENGTH = 1;
13
- const MAX_TEXT_LENGTH = 128;
14
- const StyledSurveyOptionTypeSelectWrap = styled.div.withConfig({
14
+ var MIN_TEXT_LENGTH = 1;
15
+ var MAX_TEXT_LENGTH = 128;
16
+ var StyledSurveyOptionTypeSelectWrap = styled.div.withConfig({
15
17
  componentId: "sc-r4ms68-0"
16
18
  })(["display:flex;max-width:12rem;"]);
17
- const MaterialSurveyEditContent = () => {
18
- const intl = useRawEliceIntl();
19
- const {
20
- disabled,
21
- onFileUploadRequest
22
- } = useMaterialSurveyEditContext();
23
- const {
24
- control,
25
- watch,
26
- setValue
27
- } = useFormContext();
28
- const [watchedOptionType, watchedOptionInfo] = watch(['questionInfoList.0.optionType', 'questionInfoList.0.optionInfo']);
19
+ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
20
+ var intl = useRawEliceIntl();
21
+ var _useMaterialSurveyEdi = useMaterialSurveyEditContext(),
22
+ disabled = _useMaterialSurveyEdi.disabled,
23
+ onFileUploadRequest = _useMaterialSurveyEdi.onFileUploadRequest;
24
+ var _useFormContext = useFormContext(),
25
+ control = _useFormContext.control,
26
+ watch = _useFormContext.watch,
27
+ setValue = _useFormContext.setValue;
28
+ var _watch = watch(['questionInfoList.0.optionType', 'questionInfoList.0.optionInfo']),
29
+ _watch2 = _slicedToArray(_watch, 2),
30
+ watchedOptionType = _watch2[0],
31
+ watchedOptionInfo = _watch2[1];
29
32
  //
30
33
  // Change `optionInfo` according to `optionType`.
31
34
  //
32
- React.useEffect(() => {
33
- const get = () => {
35
+ React.useEffect(function () {
36
+ var get = function get() {
34
37
  switch (watchedOptionType) {
35
38
  case enums.SurveyOptionType.SelectOne:
36
39
  case enums.SurveyOptionType.SelectMultiple:
@@ -65,7 +68,7 @@ const MaterialSurveyEditContent = () => {
65
68
  * Input of option info and answer info,
66
69
  * according to option type.
67
70
  */
68
- const Option = React.useMemo(() => {
71
+ var Option = React.useMemo(function () {
69
72
  switch (watchedOptionType) {
70
73
  case enums.SurveyOptionType.SelectOne:
71
74
  case enums.SurveyOptionType.SelectMultiple:
@@ -78,15 +81,16 @@ const MaterialSurveyEditContent = () => {
78
81
  /**
79
82
  * Render input for survey title.
80
83
  */
81
- const renderQuestionTitleInput = () => {
82
- return React.createElement(FormInputVerticalLayout, {
83
- label: React.createElement(Label, {
84
+ var renderQuestionTitleInput = function renderQuestionTitleInput() {
85
+ return jsx(FormInputVerticalLayout, {
86
+ label: jsx(Label, {
84
87
  size: "small",
85
- required: true
86
- }, intl.formatMessage({
87
- id: 'content.title'
88
- })),
89
- input: React.createElement(Controller, {
88
+ required: true,
89
+ children: intl.formatMessage({
90
+ id: 'content.title'
91
+ })
92
+ }),
93
+ input: jsx(Controller, {
90
94
  control: control,
91
95
  name: "questionInfoList.0.questionTitle",
92
96
  rules: {
@@ -115,12 +119,11 @@ const MaterialSurveyEditContent = () => {
115
119
  })
116
120
  }
117
121
  },
118
- render: ({
119
- field,
120
- fieldState
121
- }) => {
122
+ render: function render(_ref) {
123
+ var field = _ref.field,
124
+ fieldState = _ref.fieldState;
122
125
  var _a;
123
- return React.createElement(Input, Object.assign({
126
+ return jsx(Input, Object.assign({
124
127
  size: "small",
125
128
  width: "full",
126
129
  minLength: MIN_TEXT_LENGTH,
@@ -138,79 +141,93 @@ const MaterialSurveyEditContent = () => {
138
141
  /**
139
142
  * Render input for survey description.
140
143
  */
141
- const renderQuestionDescriptionInput = () => {
142
- return React.createElement(FormInputVerticalLayout, {
143
- label: React.createElement(Label, {
144
- size: "small"
145
- }, intl.formatMessage({
146
- id: 'content.description.title'
147
- })),
148
- input: React.createElement(Controller, {
144
+ var renderQuestionDescriptionInput = function renderQuestionDescriptionInput() {
145
+ return jsx(FormInputVerticalLayout, {
146
+ label: jsx(Label, {
147
+ size: "small",
148
+ children: intl.formatMessage({
149
+ id: 'content.description.title'
150
+ })
151
+ }),
152
+ input: jsx(Controller, {
149
153
  control: control,
150
154
  name: "questionInfoList.0.questionDescription",
151
- render: ({
152
- field
153
- }) => React.createElement(MarkdownEditor, Object.assign({
154
- placeholder: intl.formatMessage({
155
- id: 'content.description.placeholder'
156
- }),
157
- onFileUploadRequest: onFileUploadRequest
158
- }, field))
155
+ render: function render(_ref2) {
156
+ var field = _ref2.field;
157
+ return jsx(MarkdownEditor, Object.assign({
158
+ placeholder: intl.formatMessage({
159
+ id: 'content.description.placeholder'
160
+ }),
161
+ onFileUploadRequest: onFileUploadRequest
162
+ }, field));
163
+ }
159
164
  })
160
165
  });
161
166
  };
162
167
  /**
163
168
  * Render input of option type, option info and answer info.
164
169
  */
165
- const renderOptionInput = () => {
166
- return React.createElement(FormInputVerticalLayout, {
167
- label: React.createElement(Label, {
170
+ var renderOptionInput = function renderOptionInput() {
171
+ return jsx(FormInputVerticalLayout, {
172
+ label: jsx(Label, {
168
173
  size: "small",
169
- required: true
170
- }, intl.formatMessage({
171
- id: 'content.option.title'
172
- })),
173
- input: React.createElement(React.Fragment, null, React.createElement(Controller, {
174
- control: control,
175
- name: "questionInfoList.0.optionType",
176
- render: ({
177
- field
178
- }) => React.createElement(Tooltip, {
179
- title: disabled ? intl.formatMessage({
180
- id: 'content.option.tooltip.disabled'
181
- }) : undefined,
182
- placement: "top-end"
183
- }, React.createElement(StyledSurveyOptionTypeSelectWrap, null, React.createElement(Select, Object.assign({
184
- size: "small",
185
- width: "small",
186
- readOnly: disabled
187
- }, field, {
188
- onChange: v => field.onChange(Number(v))
189
- }), React.createElement("option", {
190
- value: enums.SurveyOptionType.SelectOne,
191
- children: intl.formatMessage({
192
- id: 'content.option.select.items.selectOne'
193
- })
194
- }), React.createElement("option", {
195
- value: enums.SurveyOptionType.SelectMultiple,
196
- children: intl.formatMessage({
197
- id: 'content.option.select.items.selectMultiple'
198
- })
199
- }), React.createElement("option", {
200
- value: enums.SurveyOptionType.Text,
201
- children: intl.formatMessage({
202
- id: 'content.option.select.items.text'
203
- })
204
- }))))
205
- }), React.createElement(Vspace, {
206
- height: 0.5
207
- }), React.createElement(Option, null))
174
+ required: true,
175
+ children: intl.formatMessage({
176
+ id: 'content.option.title'
177
+ })
178
+ }),
179
+ input: jsxs(Fragment, {
180
+ children: [jsx(Controller, {
181
+ control: control,
182
+ name: "questionInfoList.0.optionType",
183
+ render: function render(_ref3) {
184
+ var field = _ref3.field;
185
+ return jsx(Tooltip, {
186
+ title: disabled ? intl.formatMessage({
187
+ id: 'content.option.tooltip.disabled'
188
+ }) : undefined,
189
+ placement: "top-end",
190
+ children: jsx(StyledSurveyOptionTypeSelectWrap, {
191
+ children: jsxs(Select, Object.assign({
192
+ size: "small",
193
+ width: "small",
194
+ readOnly: disabled
195
+ }, field, {
196
+ onChange: function onChange(v) {
197
+ return field.onChange(Number(v));
198
+ },
199
+ children: [jsx("option", {
200
+ value: enums.SurveyOptionType.SelectOne,
201
+ children: intl.formatMessage({
202
+ id: 'content.option.select.items.selectOne'
203
+ })
204
+ }), jsx("option", {
205
+ value: enums.SurveyOptionType.SelectMultiple,
206
+ children: intl.formatMessage({
207
+ id: 'content.option.select.items.selectMultiple'
208
+ })
209
+ }), jsx("option", {
210
+ value: enums.SurveyOptionType.Text,
211
+ children: intl.formatMessage({
212
+ id: 'content.option.select.items.text'
213
+ })
214
+ })]
215
+ }))
216
+ })
217
+ });
218
+ }
219
+ }), jsx(Vspace, {
220
+ height: 0.5
221
+ }), jsx(Option, {})]
222
+ })
208
223
  });
209
224
  };
210
225
  //
211
226
  //
212
227
  //
213
- return React.createElement(React.Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput());
228
+ return jsxs(Fragment, {
229
+ children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput()]
230
+ });
214
231
  };
215
232
 
216
233
  export { MaterialSurveyEditContent as default };