@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.
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +399 -0
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-survey/MaterialSurvey.js +82 -57
- package/cjs/components/material-survey/MaterialSurveyInfo.js +69 -59
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +131 -90
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +125 -86
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +47 -40
- package/cjs/components/material-survey/MaterialSurveyText.js +114 -75
- package/cjs/components/material-survey/SurveyResultBadge.js +17 -10
- package/cjs/components/material-survey/SurveySubmitStatusText.js +21 -16
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +115 -74
- package/cjs/components/material-survey/index.js +9 -0
- package/cjs/components/material-survey/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +49 -36
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +113 -91
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +100 -87
- package/cjs/components/material-survey-edit/context.js +8 -2
- package/cjs/components/material-survey-edit/index.js +7 -0
- package/cjs/components/material-survey-edit/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/utils/editValue.js +17 -11
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/SurveyContentBox.js +85 -74
- package/cjs/components/shared/index.js +13 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +66 -89
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -80
- package/es/_virtual/_rollupPluginBabelHelpers.js +386 -0
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-survey/MaterialSurvey.js +77 -57
- package/es/components/material-survey/MaterialSurveyInfo.js +65 -59
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +127 -90
- package/es/components/material-survey/MaterialSurveySelectOne.js +121 -86
- package/es/components/material-survey/MaterialSurveyShimmer.js +43 -40
- package/es/components/material-survey/MaterialSurveyText.js +109 -75
- package/es/components/material-survey/SurveyResultBadge.js +13 -10
- package/es/components/material-survey/SurveySubmitStatusText.js +17 -16
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/es/components/material-survey/context/MaterialSurveyContext.js +112 -75
- package/es/components/material-survey/index.js +2 -0
- package/es/components/material-survey/locales/index.js +4 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +45 -36
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +107 -90
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +96 -87
- package/es/components/material-survey-edit/context.js +4 -2
- package/es/components/material-survey-edit/index.js +1 -0
- package/es/components/material-survey-edit/locales/index.js +4 -0
- package/es/components/material-survey-edit/utils/editValue.js +17 -11
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/SurveyContentBox.js +81 -74
- package/es/components/shared/index.js +4 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +61 -89
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +54 -80
- package/package.json +9 -12
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
7
|
+
var StyledSuccessStatusText = styled(StatusText).withConfig({
|
|
8
8
|
componentId: "sc-szxa5m-0"
|
|
9
9
|
})(["color:", ";"], colors.green[400]);
|
|
10
|
-
|
|
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
|
|
15
|
+
return jsx(StyledSuccessStatusText, {
|
|
17
16
|
role: "success",
|
|
18
|
-
size: "small"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
size: "small",
|
|
18
|
+
children: intl.formatMessage({
|
|
19
|
+
id: 'materialSurvey.submitStatus.success'
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
22
|
case 'rejected':
|
|
23
|
-
return
|
|
23
|
+
return jsx(StatusText, {
|
|
24
24
|
role: "danger",
|
|
25
|
-
size: "small"
|
|
26
|
-
|
|
27
|
-
|
|
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):
|
|
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,
|
|
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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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
|
-
|
|
15
|
-
value,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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(
|
|
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,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
77
|
-
value: __intl
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
disabled,
|
|
21
|
-
onFileUploadRequest
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
return
|
|
83
|
-
label:
|
|
84
|
+
var renderQuestionTitleInput = function renderQuestionTitleInput() {
|
|
85
|
+
return jsx(FormInputVerticalLayout, {
|
|
86
|
+
label: jsx(Label, {
|
|
84
87
|
size: "small",
|
|
85
|
-
required: true
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
121
|
-
}) => {
|
|
122
|
+
render: function render(_ref) {
|
|
123
|
+
var field = _ref.field,
|
|
124
|
+
fieldState = _ref.fieldState;
|
|
122
125
|
var _a;
|
|
123
|
-
return
|
|
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
|
-
|
|
142
|
-
return
|
|
143
|
-
label:
|
|
144
|
-
size: "small"
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
|
|
166
|
-
return
|
|
167
|
-
label:
|
|
170
|
+
var renderOptionInput = function renderOptionInput() {
|
|
171
|
+
return jsx(FormInputVerticalLayout, {
|
|
172
|
+
label: jsx(Label, {
|
|
168
173
|
size: "small",
|
|
169
|
-
required: true
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
|
228
|
+
return jsxs(Fragment, {
|
|
229
|
+
children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput()]
|
|
230
|
+
});
|
|
214
231
|
};
|
|
215
232
|
|
|
216
233
|
export { MaterialSurveyEditContent as default };
|