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