@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,3 +1,4 @@
1
+ import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import React from 'react';
2
3
  import { useIntl } from 'react-intl';
3
4
  import { getOrgMaterialSurveyResponseGet, getOrgMaterialSurveyResponseList, postOrgMaterialSurveyResponseAdd } from '@elice/api-client';
@@ -9,56 +10,61 @@ import { useMaterialSurveyState, useMaterialSurveyDispatch } from './context/Mat
9
10
  import SurveyResultBadge from './SurveyResultBadge.js';
10
11
  import SurveySubmitStatusText from './SurveySubmitStatusText.js';
11
12
 
12
- const StyledTextarea = styled.textarea.withConfig({
13
+ var StyledTextarea = styled.textarea.withConfig({
13
14
  componentId: "sc-16tkulg-0"
14
- })(["min-height:12rem;width:100%;padding:1rem 1.375rem;font-size:1rem;color:", ";border-radius:4px;resize:vertical;line-height:1.5rem;outline:none;background-color:", ";&::placeholder{color:", ";}&:hover{cursor:", ";}"], base.color.navy2, base.color.navy5, base.color.navy2, ({
15
- disabled
16
- }) => disabled ? 'not-allowed' : 'text');
17
-
18
- const MaterialSurveyText = () => {
15
+ })(["min-height:12rem;width:100%;padding:1rem 1.375rem;font-size:1rem;color:", ";border-radius:4px;resize:vertical;line-height:1.5rem;outline:none;background-color:", ";&::placeholder{color:", ";}&:hover{cursor:", ";}"], base.color.navy2, base.color.navy5, base.color.navy2, function (_ref) {
16
+ var disabled = _ref.disabled;
17
+ return disabled ? 'not-allowed' : 'text';
18
+ });
19
+ var MaterialSurveyText = function MaterialSurveyText() {
19
20
  // context
20
- const {
21
- lecture,
22
- materialSurvey,
23
- userId
24
- } = useMaterialSurveyState();
25
- const {
26
- onSubmit,
27
- onNext,
28
- refreshOrgMaterialSurvey
29
- } = useMaterialSurveyDispatch(); // state
30
-
31
- const intl = useIntl();
32
- const [materialSurveyResponse, setMaterialSurveyResponse] = React.useState();
33
- const [submitStatus, setSubmitStatus] = React.useState('idle');
34
- const [answer, setAnswer] = React.useState(''); // survey response fetcher
35
-
36
- React.useEffect(() => {
21
+ var _useMaterialSurveySta = useMaterialSurveyState(),
22
+ lecture = _useMaterialSurveySta.lecture,
23
+ materialSurvey = _useMaterialSurveySta.materialSurvey,
24
+ userId = _useMaterialSurveySta.userId;
25
+ var _useMaterialSurveyDis = useMaterialSurveyDispatch(),
26
+ onSubmit = _useMaterialSurveyDis.onSubmit,
27
+ onNext = _useMaterialSurveyDis.onNext,
28
+ refreshOrgMaterialSurvey = _useMaterialSurveyDis.refreshOrgMaterialSurvey;
29
+ // state
30
+ var intl = useIntl();
31
+ var _React$useState = React.useState(),
32
+ _React$useState2 = _slicedToArray(_React$useState, 2),
33
+ materialSurveyResponse = _React$useState2[0],
34
+ setMaterialSurveyResponse = _React$useState2[1];
35
+ var _React$useState3 = React.useState('idle'),
36
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
37
+ submitStatus = _React$useState4[0],
38
+ setSubmitStatus = _React$useState4[1];
39
+ var _React$useState5 = React.useState(''),
40
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
41
+ answer = _React$useState6[0],
42
+ setAnswer = _React$useState6[1];
43
+ // survey response fetcher
44
+ React.useEffect(function () {
37
45
  if (!userId && (materialSurvey === null || materialSurvey === void 0 ? void 0 : materialSurvey.lastSurveyResponseId)) {
38
- const controller = new AbortController();
39
- const {
40
- signal
41
- } = controller;
46
+ var controller = new AbortController();
47
+ var signal = controller.signal;
42
48
  getOrgMaterialSurveyResponseGet({
43
49
  surveyResponseId: materialSurvey.lastSurveyResponseId
44
50
  }, {
45
- signal
46
- }).then(response => {
51
+ signal: signal
52
+ }).then(function (response) {
47
53
  setMaterialSurveyResponse(response.surveyResponse);
48
54
  setAnswer(response.surveyResponse.answers[0]);
49
- }).catch(error => {
55
+ }).catch(function (error) {
50
56
  console.error(error);
51
57
  });
52
- return () => controller.abort();
58
+ return function () {
59
+ return controller.abort();
60
+ };
53
61
  }
54
- }, [materialSurvey, userId]); // survey response fetcher
55
-
56
- React.useEffect(() => {
62
+ }, [materialSurvey, userId]);
63
+ // survey response fetcher
64
+ React.useEffect(function () {
57
65
  if (userId && materialSurvey) {
58
- const controller = new AbortController();
59
- const {
60
- signal
61
- } = controller;
66
+ var controller = new AbortController();
67
+ var signal = controller.signal;
62
68
  getOrgMaterialSurveyResponseList({
63
69
  materialSurveyId: materialSurvey.id,
64
70
  filterUserIds: [userId],
@@ -67,49 +73,72 @@ const MaterialSurveyText = () => {
67
73
  offset: 0,
68
74
  count: 1
69
75
  }, {
70
- signal
71
- }).then(response => {
72
- const surveyResponse = response.surveyResponses[0];
76
+ signal: signal
77
+ }).then(function (response) {
78
+ var surveyResponse = response.surveyResponses[0];
73
79
  setMaterialSurveyResponse(surveyResponse);
74
80
  setAnswer(typeof (surveyResponse === null || surveyResponse === void 0 ? void 0 : surveyResponse.answers[0]) === 'string' ? surveyResponse.answers[0] : '');
75
- }).catch(error => {
81
+ }).catch(function (error) {
76
82
  console.error(error);
77
83
  });
78
- return () => controller.abort();
79
- }
80
- }, [materialSurvey, userId]); // submit handler
81
-
82
- const handleSubmit = async () => {
83
- if (!materialSurvey) {
84
- return;
85
- }
86
-
87
- setSubmitStatus('pending');
88
-
89
- try {
90
- const {
91
- surveyResponseId
92
- } = await postOrgMaterialSurveyResponseAdd({
93
- materialSurveyId: materialSurvey.id,
94
- answers: [answer]
95
- });
96
- const {
97
- surveyResponse
98
- } = await getOrgMaterialSurveyResponseGet({
99
- surveyResponseId
100
- });
101
- setMaterialSurveyResponse(surveyResponse);
102
- void refreshOrgMaterialSurvey();
103
- onSubmit(true);
104
- setSubmitStatus('resolved');
105
- } catch (error) {
106
- console.error(error);
107
- onSubmit(false);
108
- setSubmitStatus('rejected');
84
+ return function () {
85
+ return controller.abort();
86
+ };
109
87
  }
110
- };
111
-
112
- const commonProps = {
88
+ }, [materialSurvey, userId]);
89
+ // submit handler
90
+ var handleSubmit = /*#__PURE__*/function () {
91
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
92
+ var _yield$postOrgMateria, surveyResponseId, _yield$getOrgMaterial, surveyResponse;
93
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
94
+ while (1) switch (_context.prev = _context.next) {
95
+ case 0:
96
+ if (materialSurvey) {
97
+ _context.next = 2;
98
+ break;
99
+ }
100
+ return _context.abrupt("return");
101
+ case 2:
102
+ setSubmitStatus('pending');
103
+ _context.prev = 3;
104
+ _context.next = 6;
105
+ return postOrgMaterialSurveyResponseAdd({
106
+ materialSurveyId: materialSurvey.id,
107
+ answers: [answer]
108
+ });
109
+ case 6:
110
+ _yield$postOrgMateria = _context.sent;
111
+ surveyResponseId = _yield$postOrgMateria.surveyResponseId;
112
+ _context.next = 10;
113
+ return getOrgMaterialSurveyResponseGet({
114
+ surveyResponseId: surveyResponseId
115
+ });
116
+ case 10:
117
+ _yield$getOrgMaterial = _context.sent;
118
+ surveyResponse = _yield$getOrgMaterial.surveyResponse;
119
+ setMaterialSurveyResponse(surveyResponse);
120
+ void refreshOrgMaterialSurvey();
121
+ onSubmit(true);
122
+ setSubmitStatus('resolved');
123
+ _context.next = 23;
124
+ break;
125
+ case 18:
126
+ _context.prev = 18;
127
+ _context.t0 = _context["catch"](3);
128
+ console.error(_context.t0);
129
+ onSubmit(false);
130
+ setSubmitStatus('rejected');
131
+ case 23:
132
+ case "end":
133
+ return _context.stop();
134
+ }
135
+ }, _callee, null, [[3, 18]]);
136
+ }));
137
+ return function handleSubmit() {
138
+ return _ref2.apply(this, arguments);
139
+ };
140
+ }();
141
+ var commonProps = {
113
142
  type: 'text',
114
143
  autoFocus: answer.length === 0,
115
144
  disabled: submitStatus === 'pending' || checkUserLectureTestEnded(lecture) || !!userId,
@@ -117,7 +146,7 @@ const MaterialSurveyText = () => {
117
146
  id: 'materialSurvey.text.placeholder'
118
147
  }),
119
148
  value: answer,
120
- onChange: e => {
149
+ onChange: function onChange(e) {
121
150
  setAnswer(e.target.value);
122
151
  }
123
152
  };
@@ -3,12 +3,12 @@ import { useIntl } from 'react-intl';
3
3
  import { BadgeNext } from '@elice/blocks';
4
4
  import { getSurveyResultStatus, SurveyResultStatus } from '../../helpers/index.js';
5
5
 
6
- const SurveyResultBadge = ({
7
- materialSurveyResponse
8
- }) => {
9
- const intl = useIntl();
10
- const status = React.useMemo(() => getSurveyResultStatus(materialSurveyResponse), [materialSurveyResponse]);
11
-
6
+ var SurveyResultBadge = function SurveyResultBadge(_ref) {
7
+ var materialSurveyResponse = _ref.materialSurveyResponse;
8
+ var intl = useIntl();
9
+ var status = React.useMemo(function () {
10
+ return getSurveyResultStatus(materialSurveyResponse);
11
+ }, [materialSurveyResponse]);
12
12
  switch (status) {
13
13
  case SurveyResultStatus.Submitted:
14
14
  return React.createElement(BadgeNext, {
@@ -17,7 +17,6 @@ const SurveyResultBadge = ({
17
17
  }, intl.formatMessage({
18
18
  id: 'materialSurvey.resultStatus.submitted'
19
19
  }));
20
-
21
20
  default:
22
21
  return null;
23
22
  }
@@ -2,11 +2,9 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
3
  import { StatusText } from '@elice/blocks';
4
4
 
5
- const SurveySubmitStatusText = ({
6
- status
7
- }) => {
8
- const intl = useIntl();
9
-
5
+ var SurveySubmitStatusText = function SurveySubmitStatusText(_ref) {
6
+ var status = _ref.status;
7
+ var intl = useIntl();
10
8
  switch (status) {
11
9
  case 'resolved':
12
10
  return React.createElement(StatusText, {
@@ -15,7 +13,6 @@ const SurveySubmitStatusText = ({
15
13
  }, intl.formatMessage({
16
14
  id: 'materialSurvey.submitStatus.success'
17
15
  }));
18
-
19
16
  case 'rejected':
20
17
  return React.createElement(StatusText, {
21
18
  role: "danger",
@@ -23,7 +20,6 @@ const SurveySubmitStatusText = ({
23
20
  }, intl.formatMessage({
24
21
  id: 'materialSurvey.submitStatus.failure'
25
22
  }));
26
-
27
23
  default:
28
24
  return null;
29
25
  }
@@ -1,114 +1,137 @@
1
+ import { slicedToArray as _slicedToArray, asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
1
2
  import React from 'react';
2
- import { config, getOrgMaterialSurveyGet, getOrgCourseGet, getOrgLectureGet } from '@elice/api-client';
3
+ import { config, getOrgMaterialSurveyGet, getOrgLectureGet, getOrgCourseGet } from '@elice/api-client';
3
4
  import { useMaterialConfigApiClientUpdate, useMaterialFetchRaw } from '@elice/material-shared-utils';
4
5
  import { enums } from '@elice/types';
5
6
 
6
- const StateContext = React.createContext(undefined);
7
- const DispatchContext = React.createContext(undefined);
7
+ var StateContext = React.createContext(undefined);
8
+ var DispatchContext = React.createContext(undefined);
8
9
  StateContext.displayName = 'MaterialSurveyStateContext';
9
10
  DispatchContext.displayName = 'MaterialSurveyDispatchContext';
10
-
11
- function MaterialSurveyProvider({
12
- materialSurveyId,
13
- userId,
14
- onSubmit = () => void 0,
15
- onNext,
16
- children
17
- }) {
18
- const [course, setCourse] = React.useState();
19
- const [lecture, setLecture] = React.useState();
20
- const [initStatus, setInitStatus] = React.useState('idle');
21
- const [vertical, setVertical] = React.useState(false);
22
- const canInit = useMaterialConfigApiClientUpdate(config.init);
23
- const {
24
- materialSurvey,
25
- materialLecturePage,
26
- refetch: refreshOrgMaterialSurvey
27
- } = useMaterialFetchRaw(enums.LectureMaterialType.Survey, React.useCallback(signal => getOrgMaterialSurveyGet({
28
- materialSurveyId
29
- }, {
30
- signal
31
- }), [materialSurveyId]), canInit);
32
- const doInitilize = React.useCallback(async () => {
33
- const controller = new AbortController();
34
- const {
35
- signal
36
- } = controller;
37
-
38
- try {
39
- setInitStatus('pending');
40
-
41
- if (!materialLecturePage) {
42
- throw new Error('materialSurvey is not ready');
43
- } // fetch course
44
-
45
-
46
- const {
47
- course
48
- } = await getOrgCourseGet({
49
- courseId: materialLecturePage.courseId
50
- }, {
51
- signal
52
- }); // fetch lecture
53
-
54
- const {
55
- lecture
56
- } = await getOrgLectureGet({
57
- lectureId: materialLecturePage.lectureId
11
+ function MaterialSurveyProvider(_ref) {
12
+ var materialSurveyId = _ref.materialSurveyId,
13
+ userId = _ref.userId,
14
+ _ref$onSubmit = _ref.onSubmit,
15
+ onSubmit = _ref$onSubmit === void 0 ? function () {
16
+ return void 0;
17
+ } : _ref$onSubmit,
18
+ onNext = _ref.onNext,
19
+ children = _ref.children;
20
+ var _React$useState = React.useState(),
21
+ _React$useState2 = _slicedToArray(_React$useState, 2),
22
+ course = _React$useState2[0],
23
+ setCourse = _React$useState2[1];
24
+ var _React$useState3 = React.useState(),
25
+ _React$useState4 = _slicedToArray(_React$useState3, 2),
26
+ lecture = _React$useState4[0],
27
+ setLecture = _React$useState4[1];
28
+ var _React$useState5 = React.useState('idle'),
29
+ _React$useState6 = _slicedToArray(_React$useState5, 2),
30
+ initStatus = _React$useState6[0],
31
+ setInitStatus = _React$useState6[1];
32
+ var _React$useState7 = React.useState(false),
33
+ _React$useState8 = _slicedToArray(_React$useState7, 2),
34
+ vertical = _React$useState8[0],
35
+ setVertical = _React$useState8[1];
36
+ var canInit = useMaterialConfigApiClientUpdate(config.init);
37
+ var _useMaterialFetchRaw = useMaterialFetchRaw(enums.LectureMaterialType.Survey, React.useCallback(function (signal) {
38
+ return getOrgMaterialSurveyGet({
39
+ materialSurveyId: materialSurveyId
58
40
  }, {
59
- signal
41
+ signal: signal
60
42
  });
61
- setCourse(course);
62
- setLecture(lecture);
63
- setInitStatus('resolved');
64
- } catch (error) {
65
- console.error(error);
66
- setInitStatus('rejected');
67
- }
68
-
69
- return () => controller.abort();
70
- }, [materialLecturePage]);
71
- React.useEffect(() => {
43
+ }, [materialSurveyId]), canInit),
44
+ materialSurvey = _useMaterialFetchRaw.materialSurvey,
45
+ materialLecturePage = _useMaterialFetchRaw.materialLecturePage,
46
+ refreshOrgMaterialSurvey = _useMaterialFetchRaw.refetch;
47
+ var doInitilize = React.useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
48
+ var controller, signal, _yield$getOrgCourseGe, _course, _yield$getOrgLectureG, _lecture;
49
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
50
+ while (1) switch (_context.prev = _context.next) {
51
+ case 0:
52
+ controller = new AbortController();
53
+ signal = controller.signal;
54
+ _context.prev = 2;
55
+ setInitStatus('pending');
56
+ if (materialLecturePage) {
57
+ _context.next = 6;
58
+ break;
59
+ }
60
+ throw new Error('materialSurvey is not ready');
61
+ case 6:
62
+ _context.next = 8;
63
+ return getOrgCourseGet({
64
+ courseId: materialLecturePage.courseId
65
+ }, {
66
+ signal: signal
67
+ });
68
+ case 8:
69
+ _yield$getOrgCourseGe = _context.sent;
70
+ _course = _yield$getOrgCourseGe.course;
71
+ _context.next = 12;
72
+ return getOrgLectureGet({
73
+ lectureId: materialLecturePage.lectureId
74
+ }, {
75
+ signal: signal
76
+ });
77
+ case 12:
78
+ _yield$getOrgLectureG = _context.sent;
79
+ _lecture = _yield$getOrgLectureG.lecture;
80
+ setCourse(_course);
81
+ setLecture(_lecture);
82
+ setInitStatus('resolved');
83
+ _context.next = 23;
84
+ break;
85
+ case 19:
86
+ _context.prev = 19;
87
+ _context.t0 = _context["catch"](2);
88
+ console.error(_context.t0);
89
+ setInitStatus('rejected');
90
+ case 23:
91
+ return _context.abrupt("return", function () {
92
+ return controller.abort();
93
+ });
94
+ case 24:
95
+ case "end":
96
+ return _context.stop();
97
+ }
98
+ }, _callee, null, [[2, 19]]);
99
+ })), [materialLecturePage]);
100
+ React.useEffect(function () {
72
101
  if (canInit && materialLecturePage) {
73
102
  void doInitilize();
74
103
  }
75
104
  }, [canInit, materialLecturePage, doInitilize]);
76
105
  return React.createElement(StateContext.Provider, {
77
106
  value: {
78
- course,
79
- lecture,
107
+ course: course,
108
+ lecture: lecture,
80
109
  materialSurvey: materialSurvey !== null && materialSurvey !== void 0 ? materialSurvey : undefined,
81
- userId,
82
- vertical,
83
- initStatus
110
+ userId: userId,
111
+ vertical: vertical,
112
+ initStatus: initStatus
84
113
  }
85
114
  }, React.createElement(DispatchContext.Provider, {
86
115
  value: {
87
- onSubmit,
88
- onNext,
89
- refreshOrgMaterialSurvey,
90
- setVertical
116
+ onSubmit: onSubmit,
117
+ onNext: onNext,
118
+ refreshOrgMaterialSurvey: refreshOrgMaterialSurvey,
119
+ setVertical: setVertical
91
120
  }
92
121
  }, children));
93
122
  }
94
-
95
123
  function useMaterialSurveyState() {
96
- const context = React.useContext(StateContext);
97
-
124
+ var context = React.useContext(StateContext);
98
125
  if (context === undefined) {
99
126
  throw new Error('useMaterialSurveyState must be used within a MaterialSurveyProvider');
100
127
  }
101
-
102
128
  return context;
103
129
  }
104
-
105
130
  function useMaterialSurveyDispatch() {
106
- const context = React.useContext(DispatchContext);
107
-
131
+ var context = React.useContext(DispatchContext);
108
132
  if (context === undefined) {
109
133
  throw new Error('useMaterialSurveyDispatch must be used within a MaterialSurveyProvider');
110
134
  }
111
-
112
135
  return context;
113
136
  }
114
137
 
@@ -8,29 +8,29 @@ import * as locales from './locales.js';
8
8
  import { en } from './locales.js';
9
9
  import MaterialSurveyEditContent from './MaterialSurveyEditContent.js';
10
10
 
11
- const MaterialSurveyEdit = forwardRef(({
12
- value,
13
- disabled = false,
14
- locale = 'en',
15
- onChange,
16
- onFormStateChange,
17
- onFileUploadRequest
18
- }, ref) => {
19
- const formElRef = React.useRef(null);
20
- const useFormMethods = useForm({
11
+ var MaterialSurveyEdit = forwardRef(function (_ref, ref) {
12
+ var value = _ref.value,
13
+ _ref$disabled = _ref.disabled,
14
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
15
+ _ref$locale = _ref.locale,
16
+ locale = _ref$locale === void 0 ? 'en' : _ref$locale,
17
+ onChange = _ref.onChange,
18
+ onFormStateChange = _ref.onFormStateChange,
19
+ onFileUploadRequest = _ref.onFileUploadRequest;
20
+ var formElRef = React.useRef(null);
21
+ var useFormMethods = useForm({
21
22
  defaultValues: manipulateValue(value),
22
23
  mode: 'onBlur'
23
24
  });
24
- const watchedMaterialSurveyEditValue = useFormMethods.watch();
25
- const {
26
- isDirty,
27
- isValid
28
- } = useFormMethods.formState; //
25
+ var watchedMaterialSurveyEditValue = useFormMethods.watch();
26
+ var _useFormMethods$formS = useFormMethods.formState,
27
+ isDirty = _useFormMethods$formS.isDirty,
28
+ isValid = _useFormMethods$formS.isValid;
29
+ //
29
30
  // Reset from value, when `value` changes.
30
31
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
31
32
  //
32
-
33
- useDeepCompareEffect(() => {
33
+ useDeepCompareEffect(function () {
34
34
  useFormMethods.reset(manipulateValue(value), {
35
35
  keepDirty: true,
36
36
  keepErrors: true,
@@ -39,42 +39,47 @@ const MaterialSurveyEdit = forwardRef(({
39
39
  keepValues: true
40
40
  });
41
41
  void useFormMethods.trigger();
42
- }, [value]); //
42
+ }, [value]);
43
+ //
43
44
  // Emit `onChange` handler when form value changed.
44
45
  // TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
45
46
  //
46
-
47
- useDeepCompareEffect(() => onChange(restoreValue(watchedMaterialSurveyEditValue)), [watchedMaterialSurveyEditValue]); //
47
+ useDeepCompareEffect(function () {
48
+ return onChange(restoreValue(watchedMaterialSurveyEditValue));
49
+ }, [watchedMaterialSurveyEditValue]);
50
+ //
48
51
  // Emit `onFormStateChange` handler when form state change.
49
52
  //
50
-
51
- React.useEffect(() => {
53
+ React.useEffect(function () {
52
54
  if (typeof onFormStateChange === 'function') {
53
55
  onFormStateChange({
54
- isDirty,
55
- isValid
56
+ isDirty: isDirty,
57
+ isValid: isValid
56
58
  });
57
59
  }
58
- }, // eslint-disable-next-line react-hooks/exhaustive-deps
59
- [isDirty, isValid]); //
60
+ },
61
+ // eslint-disable-next-line react-hooks/exhaustive-deps
62
+ [isDirty, isValid]);
63
+ //
60
64
  // Set ref.
61
65
  //
62
-
63
- React.useImperativeHandle(ref, () => Object.assign(Object.assign({}, formElRef.current), {
64
- reset: () => {
65
- useFormMethods.reset(manipulateValue(value));
66
- void useFormMethods.trigger();
67
- }
68
- }), [useFormMethods, value]); //
66
+ React.useImperativeHandle(ref, function () {
67
+ return Object.assign(Object.assign({}, formElRef.current), {
68
+ reset: function reset() {
69
+ useFormMethods.reset(manipulateValue(value));
70
+ void useFormMethods.trigger();
71
+ }
72
+ });
73
+ }, [useFormMethods, value]);
74
+ //
69
75
  //
70
76
  //
71
-
72
77
  return React.createElement("form", {
73
78
  ref: formElRef
74
79
  }, React.createElement(MaterialSurveyEditContext.Provider, {
75
80
  value: {
76
- disabled,
77
- onFileUploadRequest
81
+ disabled: disabled,
82
+ onFileUploadRequest: onFileUploadRequest
78
83
  }
79
84
  }, React.createElement(IntlProvider, {
80
85
  locale: locale,