@elice/material-survey 1.220803.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/README.md +3 -0
- package/cjs/components/material-survey/MaterialSurvey.d.ts +4 -0
- package/cjs/components/material-survey/MaterialSurvey.i18n.d.ts +16 -0
- package/cjs/components/material-survey/MaterialSurvey.i18n.js +37 -0
- package/cjs/components/material-survey/MaterialSurvey.js +109 -0
- package/cjs/components/material-survey/MaterialSurveyError.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyInfo.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyInfo.js +73 -0
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +184 -0
- package/cjs/components/material-survey/MaterialSurveySelectOne.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +164 -0
- package/cjs/components/material-survey/MaterialSurveyShimmer.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +61 -0
- package/cjs/components/material-survey/MaterialSurveyText.d.ts +3 -0
- package/cjs/components/material-survey/MaterialSurveyText.js +159 -0
- package/cjs/components/material-survey/SurveyResultBadge.d.ts +7 -0
- package/cjs/components/material-survey/SurveyResultBadge.js +32 -0
- package/cjs/components/material-survey/SurveySubmitStatusText.d.ts +7 -0
- package/cjs/components/material-survey/SurveySubmitStatusText.js +38 -0
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +31 -0
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +134 -0
- package/cjs/components/material-survey/index.d.ts +3 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.d.ts +25 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +91 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.d.ts +3 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +235 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.d.ts +3 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +132 -0
- package/cjs/components/material-survey-edit/context.d.ts +6 -0
- package/cjs/components/material-survey-edit/context.js +15 -0
- package/cjs/components/material-survey-edit/index.d.ts +2 -0
- package/cjs/components/material-survey-edit/locales.d.ts +20 -0
- package/cjs/components/material-survey-edit/locales.js +45 -0
- package/cjs/components/material-survey-edit/utils/editValue.d.ts +19 -0
- package/cjs/components/material-survey-edit/utils/editValue.js +46 -0
- package/cjs/components/material-survey-edit/utils/randomId.d.ts +4 -0
- package/cjs/components/material-survey-edit/utils/randomId.js +12 -0
- package/cjs/components/shared/StyledMarkdown.d.ts +3 -0
- package/cjs/components/shared/StyledMarkdown.js +14 -0
- package/cjs/components/shared/SurveyContentBox.d.ts +15 -0
- package/cjs/components/shared/SurveyContentBox.js +108 -0
- package/cjs/components/shared/index.d.ts +4 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +26 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +42 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +226 -0
- package/cjs/components/shared/question-radio/QuestionRadio.d.ts +8 -0
- package/cjs/components/shared/question-radio/QuestionRadio.js +26 -0
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +42 -0
- package/cjs/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +187 -0
- package/cjs/helpers/index.d.ts +22 -0
- package/cjs/helpers/index.js +26 -0
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +21 -0
- package/es/components/material-survey/MaterialSurvey.d.ts +4 -0
- package/es/components/material-survey/MaterialSurvey.i18n.d.ts +16 -0
- package/es/components/material-survey/MaterialSurvey.i18n.js +32 -0
- package/es/components/material-survey/MaterialSurvey.js +101 -0
- package/es/components/material-survey/MaterialSurveyError.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyInfo.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyInfo.js +67 -0
- package/es/components/material-survey/MaterialSurveySelectMultiple.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +178 -0
- package/es/components/material-survey/MaterialSurveySelectOne.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveySelectOne.js +158 -0
- package/es/components/material-survey/MaterialSurveyShimmer.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyShimmer.js +54 -0
- package/es/components/material-survey/MaterialSurveyText.d.ts +3 -0
- package/es/components/material-survey/MaterialSurveyText.js +152 -0
- package/es/components/material-survey/SurveyResultBadge.d.ts +7 -0
- package/es/components/material-survey/SurveyResultBadge.js +26 -0
- package/es/components/material-survey/SurveySubmitStatusText.d.ts +7 -0
- package/es/components/material-survey/SurveySubmitStatusText.js +32 -0
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +31 -0
- package/es/components/material-survey/context/MaterialSurveyContext.js +124 -0
- package/es/components/material-survey/index.d.ts +3 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.d.ts +25 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +86 -0
- package/es/components/material-survey-edit/MaterialSurveyEditContent.d.ts +3 -0
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +228 -0
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.d.ts +3 -0
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +125 -0
- package/es/components/material-survey-edit/context.d.ts +6 -0
- package/es/components/material-survey-edit/context.js +6 -0
- package/es/components/material-survey-edit/index.d.ts +2 -0
- package/es/components/material-survey-edit/locales.d.ts +20 -0
- package/es/components/material-survey-edit/locales.js +40 -0
- package/es/components/material-survey-edit/utils/editValue.d.ts +19 -0
- package/es/components/material-survey-edit/utils/editValue.js +41 -0
- package/es/components/material-survey-edit/utils/randomId.d.ts +4 -0
- package/es/components/material-survey-edit/utils/randomId.js +8 -0
- package/es/components/shared/StyledMarkdown.d.ts +3 -0
- package/es/components/shared/StyledMarkdown.js +8 -0
- package/es/components/shared/SurveyContentBox.d.ts +15 -0
- package/es/components/shared/SurveyContentBox.js +98 -0
- package/es/components/shared/index.d.ts +4 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +19 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +33 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +219 -0
- package/es/components/shared/question-radio/QuestionRadio.d.ts +8 -0
- package/es/components/shared/question-radio/QuestionRadio.js +19 -0
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
- package/es/components/shared/question-radio/QuestionRadioContext.js +33 -0
- package/es/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
- package/es/components/shared/question-radio/QuestionRadioOption.js +180 -0
- package/es/helpers/index.d.ts +22 -0
- package/es/helpers/index.js +21 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +7 -0
- package/package.json +71 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactHookForm = require('react-hook-form');
|
|
5
|
+
var reactIntl = require('react-intl');
|
|
6
|
+
var blocks = require('@elice/blocks');
|
|
7
|
+
var markdown = require('@elice/markdown');
|
|
8
|
+
var types = require('@elice/types');
|
|
9
|
+
var styled = require('styled-components');
|
|
10
|
+
var randomId = require('./utils/randomId.js');
|
|
11
|
+
var context = require('./context.js');
|
|
12
|
+
var MaterialSurveyEditOptionSelect = require('./MaterialSurveyEditOptionSelect.js');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
18
|
+
|
|
19
|
+
const MIN_TEXT_LENGTH = 1;
|
|
20
|
+
const MAX_TEXT_LENGTH = 128;
|
|
21
|
+
const StyledSurveyOptionTypeSelectWrap = styled__default["default"].div.withConfig({
|
|
22
|
+
componentId: "sc-r4ms68-0"
|
|
23
|
+
})(["display:flex;max-width:12rem;"]);
|
|
24
|
+
|
|
25
|
+
const MaterialSurveyEditContent = () => {
|
|
26
|
+
const intl = reactIntl.useIntl();
|
|
27
|
+
const {
|
|
28
|
+
disabled,
|
|
29
|
+
onFileUploadRequest
|
|
30
|
+
} = context.useMaterialSurveyEditContext();
|
|
31
|
+
const {
|
|
32
|
+
control,
|
|
33
|
+
watch,
|
|
34
|
+
setValue
|
|
35
|
+
} = reactHookForm.useFormContext();
|
|
36
|
+
const [watchedOptionType, watchedOptionInfo] = watch(['questionInfoList.0.optionType', 'questionInfoList.0.optionInfo']); //
|
|
37
|
+
// Change `optionInfo` according to `optionType`.
|
|
38
|
+
//
|
|
39
|
+
|
|
40
|
+
React__default["default"].useEffect(() => {
|
|
41
|
+
const get = () => {
|
|
42
|
+
switch (watchedOptionType) {
|
|
43
|
+
case types.enums.SurveyOptionType.SelectOne:
|
|
44
|
+
case types.enums.SurveyOptionType.SelectMultiple:
|
|
45
|
+
return watchedOptionInfo.length > 0 ? watchedOptionInfo : // add default option info
|
|
46
|
+
[{
|
|
47
|
+
id: randomId.createRandomId(),
|
|
48
|
+
value: intl.formatMessage({
|
|
49
|
+
id: 'common.option'
|
|
50
|
+
}, {
|
|
51
|
+
number: 1
|
|
52
|
+
})
|
|
53
|
+
}, {
|
|
54
|
+
id: randomId.createRandomId(),
|
|
55
|
+
value: intl.formatMessage({
|
|
56
|
+
id: 'common.option'
|
|
57
|
+
}, {
|
|
58
|
+
number: 2
|
|
59
|
+
})
|
|
60
|
+
}];
|
|
61
|
+
|
|
62
|
+
case types.enums.SurveyOptionType.Text:
|
|
63
|
+
return [];
|
|
64
|
+
|
|
65
|
+
default:
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
setValue('questionInfoList.0.optionInfo', get());
|
|
71
|
+
}, // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
[watchedOptionType, setValue, intl]);
|
|
73
|
+
/**
|
|
74
|
+
* Input of option info and answer info,
|
|
75
|
+
* according to option type.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
const Option = React__default["default"].useMemo(() => {
|
|
79
|
+
switch (watchedOptionType) {
|
|
80
|
+
case types.enums.SurveyOptionType.SelectOne:
|
|
81
|
+
case types.enums.SurveyOptionType.SelectMultiple:
|
|
82
|
+
return MaterialSurveyEditOptionSelect;
|
|
83
|
+
|
|
84
|
+
case types.enums.SurveyOptionType.Text:
|
|
85
|
+
default:
|
|
86
|
+
return React__default["default"].Fragment;
|
|
87
|
+
}
|
|
88
|
+
}, [watchedOptionType]);
|
|
89
|
+
/**
|
|
90
|
+
* Render input for survey title.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
const renderQuestionTitleInput = () => {
|
|
94
|
+
return React__default["default"].createElement(blocks.FormInputVerticalLayout, {
|
|
95
|
+
label: React__default["default"].createElement(blocks.Label, {
|
|
96
|
+
size: "small",
|
|
97
|
+
required: true
|
|
98
|
+
}, React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
99
|
+
id: "content.title"
|
|
100
|
+
})),
|
|
101
|
+
input: React__default["default"].createElement(reactHookForm.Controller, {
|
|
102
|
+
control: control,
|
|
103
|
+
name: "questionInfoList.0.questionTitle",
|
|
104
|
+
rules: {
|
|
105
|
+
required: {
|
|
106
|
+
value: true,
|
|
107
|
+
message: intl.formatMessage({
|
|
108
|
+
id: 'content.title.errorMessage.required'
|
|
109
|
+
})
|
|
110
|
+
},
|
|
111
|
+
minLength: {
|
|
112
|
+
value: MIN_TEXT_LENGTH,
|
|
113
|
+
message: intl.formatMessage({
|
|
114
|
+
id: 'common.errorMessage.range'
|
|
115
|
+
}, {
|
|
116
|
+
min: MIN_TEXT_LENGTH,
|
|
117
|
+
max: MAX_TEXT_LENGTH
|
|
118
|
+
})
|
|
119
|
+
},
|
|
120
|
+
maxLength: {
|
|
121
|
+
value: MAX_TEXT_LENGTH,
|
|
122
|
+
message: intl.formatMessage({
|
|
123
|
+
id: 'common.errorMessage.range'
|
|
124
|
+
}, {
|
|
125
|
+
min: MIN_TEXT_LENGTH,
|
|
126
|
+
max: MAX_TEXT_LENGTH
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
render: ({
|
|
131
|
+
field,
|
|
132
|
+
fieldState
|
|
133
|
+
}) => {
|
|
134
|
+
var _a;
|
|
135
|
+
|
|
136
|
+
return React__default["default"].createElement(blocks.Input, Object.assign({
|
|
137
|
+
size: "small",
|
|
138
|
+
width: "full",
|
|
139
|
+
minLength: MIN_TEXT_LENGTH,
|
|
140
|
+
maxLength: MAX_TEXT_LENGTH,
|
|
141
|
+
placeholder: intl.formatMessage({
|
|
142
|
+
id: 'content.title.placeholder'
|
|
143
|
+
}),
|
|
144
|
+
invalid: fieldState.invalid,
|
|
145
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
146
|
+
}, field));
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Render input for survey description.
|
|
153
|
+
*/
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
const renderQuestionDescriptionInput = () => {
|
|
157
|
+
return React__default["default"].createElement(blocks.FormInputVerticalLayout, {
|
|
158
|
+
label: React__default["default"].createElement(blocks.Label, {
|
|
159
|
+
size: "small"
|
|
160
|
+
}, React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
161
|
+
id: "content.description.title"
|
|
162
|
+
})),
|
|
163
|
+
input: React__default["default"].createElement(reactHookForm.Controller, {
|
|
164
|
+
control: control,
|
|
165
|
+
name: "questionInfoList.0.questionDescription",
|
|
166
|
+
render: ({
|
|
167
|
+
field
|
|
168
|
+
}) => React__default["default"].createElement(markdown.MarkdownEditor, Object.assign({
|
|
169
|
+
enableFooter: true,
|
|
170
|
+
placeholder: intl.formatMessage({
|
|
171
|
+
id: 'content.description.placeholder'
|
|
172
|
+
}),
|
|
173
|
+
onFileUploadRequest: onFileUploadRequest
|
|
174
|
+
}, field))
|
|
175
|
+
})
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Render input of option type, option info and answer info.
|
|
180
|
+
*/
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
const renderOptionInput = () => {
|
|
184
|
+
return React__default["default"].createElement(blocks.FormInputVerticalLayout, {
|
|
185
|
+
label: React__default["default"].createElement(blocks.Label, {
|
|
186
|
+
size: "small",
|
|
187
|
+
required: true
|
|
188
|
+
}, React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
189
|
+
id: "content.option.title"
|
|
190
|
+
})),
|
|
191
|
+
input: React__default["default"].createElement(React__default["default"].Fragment, null, React__default["default"].createElement(reactHookForm.Controller, {
|
|
192
|
+
control: control,
|
|
193
|
+
name: "questionInfoList.0.optionType",
|
|
194
|
+
render: ({
|
|
195
|
+
field
|
|
196
|
+
}) => React__default["default"].createElement(blocks.Tooltip, {
|
|
197
|
+
title: disabled ? intl.formatMessage({
|
|
198
|
+
id: 'content.option.tooltip.disabled'
|
|
199
|
+
}) : undefined,
|
|
200
|
+
placement: "top-end"
|
|
201
|
+
}, React__default["default"].createElement(StyledSurveyOptionTypeSelectWrap, null, React__default["default"].createElement(blocks.Select, Object.assign({
|
|
202
|
+
size: "small",
|
|
203
|
+
width: "small",
|
|
204
|
+
readOnly: disabled
|
|
205
|
+
}, field, {
|
|
206
|
+
onChange: v => field.onChange(Number(v))
|
|
207
|
+
}), React__default["default"].createElement("option", {
|
|
208
|
+
value: types.enums.SurveyOptionType.SelectOne,
|
|
209
|
+
children: intl.formatMessage({
|
|
210
|
+
id: 'content.option.select.items.selectOne'
|
|
211
|
+
})
|
|
212
|
+
}), React__default["default"].createElement("option", {
|
|
213
|
+
value: types.enums.SurveyOptionType.SelectMultiple,
|
|
214
|
+
children: intl.formatMessage({
|
|
215
|
+
id: 'content.option.select.items.selectMultiple'
|
|
216
|
+
})
|
|
217
|
+
}), React__default["default"].createElement("option", {
|
|
218
|
+
value: types.enums.SurveyOptionType.Text,
|
|
219
|
+
children: intl.formatMessage({
|
|
220
|
+
id: 'content.option.select.items.text'
|
|
221
|
+
})
|
|
222
|
+
}))))
|
|
223
|
+
}), React__default["default"].createElement(blocks.Vspace, {
|
|
224
|
+
height: 0.5
|
|
225
|
+
}), React__default["default"].createElement(Option, null))
|
|
226
|
+
});
|
|
227
|
+
}; //
|
|
228
|
+
//
|
|
229
|
+
//
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
return React__default["default"].createElement(React__default["default"].Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput());
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
module.exports = MaterialSurveyEditContent;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var reactHookForm = require('react-hook-form');
|
|
5
|
+
var reactIntl = require('react-intl');
|
|
6
|
+
var blocks = require('@elice/blocks');
|
|
7
|
+
var icons = require('@elice/icons');
|
|
8
|
+
var styled = require('styled-components');
|
|
9
|
+
var randomId = require('./utils/randomId.js');
|
|
10
|
+
var context = require('./context.js');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
16
|
+
|
|
17
|
+
const MIN_OPTION_INFO_COUNT = 2;
|
|
18
|
+
const MAX_OPTION_INFO_COUNT = 20;
|
|
19
|
+
const StyledWrap = styled__default["default"].div.withConfig({
|
|
20
|
+
componentId: "sc-1eiyk6z-0"
|
|
21
|
+
})([""]);
|
|
22
|
+
const StyledInputGroup = styled__default["default"].div.withConfig({
|
|
23
|
+
componentId: "sc-1eiyk6z-1"
|
|
24
|
+
})(["width:100%;.eb-input{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
|
|
25
|
+
|
|
26
|
+
const OptionSelectOne = () => {
|
|
27
|
+
const intl = reactIntl.useIntl();
|
|
28
|
+
const {
|
|
29
|
+
disabled
|
|
30
|
+
} = context.useMaterialSurveyEditContext();
|
|
31
|
+
const {
|
|
32
|
+
control
|
|
33
|
+
} = reactHookForm.useFormContext();
|
|
34
|
+
const {
|
|
35
|
+
fields: optionInfoFields,
|
|
36
|
+
append: appendOptionInfoFieldItem,
|
|
37
|
+
remove: removeOptionInfoFieldItem
|
|
38
|
+
} = reactHookForm.useFieldArray({
|
|
39
|
+
name: 'questionInfoList.0.optionInfo',
|
|
40
|
+
keyName: 'id',
|
|
41
|
+
shouldUnregister: true
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Append option info.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
const appendOptionInfo = () => {
|
|
48
|
+
appendOptionInfoFieldItem({
|
|
49
|
+
id: randomId.createRandomId(),
|
|
50
|
+
value: ''
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Remove item from option info at index.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const removeOptionInfo = index => {
|
|
59
|
+
removeOptionInfoFieldItem(index);
|
|
60
|
+
}; //
|
|
61
|
+
//
|
|
62
|
+
//
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
return React__default["default"].createElement(StyledWrap, null, React__default["default"].createElement(StyledInputGroup, null, optionInfoFields.map(({
|
|
66
|
+
id
|
|
67
|
+
}, index) => React__default["default"].createElement(reactHookForm.Controller, {
|
|
68
|
+
key: id,
|
|
69
|
+
control: control,
|
|
70
|
+
name: `questionInfoList.0.optionInfo.${index}.value`,
|
|
71
|
+
rules: {
|
|
72
|
+
required: {
|
|
73
|
+
value: true,
|
|
74
|
+
message: intl.formatMessage({
|
|
75
|
+
id: 'option.common.select.errorMessage.required'
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
render: ({
|
|
80
|
+
field,
|
|
81
|
+
fieldState
|
|
82
|
+
}) => {
|
|
83
|
+
var _a;
|
|
84
|
+
|
|
85
|
+
return React__default["default"].createElement(blocks.Input, Object.assign({
|
|
86
|
+
size: "small",
|
|
87
|
+
width: "full",
|
|
88
|
+
placeholder: intl.formatMessage({
|
|
89
|
+
id: 'option.common.select.placeholder'
|
|
90
|
+
}),
|
|
91
|
+
suffix: React__default["default"].createElement(blocks.Tooltip, {
|
|
92
|
+
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
93
|
+
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
94
|
+
}) : undefined,
|
|
95
|
+
placement: "top-start"
|
|
96
|
+
}, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.IconButton, {
|
|
97
|
+
icon: icons.eilMathsignMultiplyBasic,
|
|
98
|
+
role: "grey9",
|
|
99
|
+
size: "tiny",
|
|
100
|
+
border: false,
|
|
101
|
+
transparent: true,
|
|
102
|
+
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
103
|
+
onClick: () => removeOptionInfo(index)
|
|
104
|
+
}))),
|
|
105
|
+
readOnly: disabled,
|
|
106
|
+
invalid: fieldState.invalid,
|
|
107
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
108
|
+
}, field));
|
|
109
|
+
}
|
|
110
|
+
}))), React__default["default"].createElement(blocks.Vspace, {
|
|
111
|
+
height: 0.5
|
|
112
|
+
}), React__default["default"].createElement(blocks.Tooltip, {
|
|
113
|
+
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
114
|
+
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
115
|
+
}) : undefined,
|
|
116
|
+
placement: "bottom"
|
|
117
|
+
}, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.Button, {
|
|
118
|
+
block: true,
|
|
119
|
+
size: "micro",
|
|
120
|
+
borderDashed: true,
|
|
121
|
+
transparent: true,
|
|
122
|
+
icon: React__default["default"].createElement(blocks.Icon, {
|
|
123
|
+
icon: icons.eilMathsignAddCircle
|
|
124
|
+
}),
|
|
125
|
+
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
126
|
+
onClick: appendOptionInfo
|
|
127
|
+
}, React__default["default"].createElement(reactIntl.FormattedMessage, {
|
|
128
|
+
id: "option.common.select.addButton"
|
|
129
|
+
})))));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
module.exports = OptionSelectOne;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { MaterialSurveyEditProps } from './MaterialSurveyEdit';
|
|
3
|
+
declare type MaterialSurveyEditContextValue = Pick<MaterialSurveyEditProps, 'disabled' | 'onFileUploadRequest'>;
|
|
4
|
+
declare const MaterialSurveyEditContext: React.Context<MaterialSurveyEditContextValue>;
|
|
5
|
+
export declare const useMaterialSurveyEditContext: () => MaterialSurveyEditContextValue;
|
|
6
|
+
export default MaterialSurveyEditContext;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
+
|
|
11
|
+
const MaterialSurveyEditContext = React__default["default"].createContext(null);
|
|
12
|
+
const useMaterialSurveyEditContext = () => React__default["default"].useContext(MaterialSurveyEditContext);
|
|
13
|
+
|
|
14
|
+
exports["default"] = MaterialSurveyEditContext;
|
|
15
|
+
exports.useMaterialSurveyEditContext = useMaterialSurveyEditContext;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
'common.option': string;
|
|
3
|
+
'common.errorMessage.range': string;
|
|
4
|
+
'content.title': string;
|
|
5
|
+
'content.title.errorMessage.required': string;
|
|
6
|
+
'content.title.placeholder': string;
|
|
7
|
+
'content.description.title': string;
|
|
8
|
+
'content.description.placeholder': string;
|
|
9
|
+
'content.option.title': string;
|
|
10
|
+
'content.option.tooltip.disabled': string;
|
|
11
|
+
'content.option.select.items.selectOne': string;
|
|
12
|
+
'content.option.select.items.selectMultiple': string;
|
|
13
|
+
'content.option.select.items.text': string;
|
|
14
|
+
'option.common.select.errorMessage.required': string;
|
|
15
|
+
'option.common.select.placeholder': string;
|
|
16
|
+
'option.common.select.tooltip.minOptionInfoItem': string;
|
|
17
|
+
'option.common.select.tooltip.maxOptionInfoItem': string;
|
|
18
|
+
'option.common.select.addButton': string;
|
|
19
|
+
};
|
|
20
|
+
export declare const ko: typeof en;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const en = {
|
|
6
|
+
'common.option': '옵션 {number}',
|
|
7
|
+
'common.errorMessage.range': '{min} ~ {max}자 이내로 입력해주세요.',
|
|
8
|
+
'content.title': '질문',
|
|
9
|
+
'content.title.errorMessage.required': 'Please fill the question.',
|
|
10
|
+
'content.title.placeholder': '질문을 입력해주세요.',
|
|
11
|
+
'content.description.title': '세부 내용',
|
|
12
|
+
'content.description.placeholder': '자세한 질문 설명이나 이미지 등을 입력해주세요.',
|
|
13
|
+
'content.option.title': '답변',
|
|
14
|
+
'content.option.tooltip.disabled': '설문 조사가 공개된 상태이거나 제출한 학생이 존재하면\n수정이 불가능합니다.',
|
|
15
|
+
'content.option.select.items.selectOne': '객관식 (단일 답변)',
|
|
16
|
+
'content.option.select.items.selectMultiple': '객관식 (복수 답변)',
|
|
17
|
+
'content.option.select.items.text': '주관식 답변',
|
|
18
|
+
'option.common.select.errorMessage.required': '선택지를 입력해주세요.',
|
|
19
|
+
'option.common.select.placeholder': '선택지 입력',
|
|
20
|
+
'option.common.select.tooltip.minOptionInfoItem': '선택지는 2개 이상 입력해야 합니다.',
|
|
21
|
+
'option.common.select.tooltip.maxOptionInfoItem': '선택지는 20개 초과하여 입력할 수 없습니다.',
|
|
22
|
+
'option.common.select.addButton': '보기 추가'
|
|
23
|
+
};
|
|
24
|
+
const ko = {
|
|
25
|
+
'common.option': '옵션 {number}',
|
|
26
|
+
'common.errorMessage.range': '{min} ~ {max}자 이내로 입력해주세요.',
|
|
27
|
+
'content.title': '질문',
|
|
28
|
+
'content.title.errorMessage.required': '질문을 입력해주세요.',
|
|
29
|
+
'content.title.placeholder': '질문을 입력해주세요.',
|
|
30
|
+
'content.description.title': '세부 내용',
|
|
31
|
+
'content.description.placeholder': '자세한 질문 설명이나 이미지 등을 입력해주세요.',
|
|
32
|
+
'content.option.title': '답변',
|
|
33
|
+
'content.option.tooltip.disabled': '설문 조사가 공개된 상태이거나 제출한 학생이 존재하면\n수정이 불가능합니다.',
|
|
34
|
+
'content.option.select.items.selectOne': '객관식 (단일 답변)',
|
|
35
|
+
'content.option.select.items.selectMultiple': '객관식 (복수 답변)',
|
|
36
|
+
'content.option.select.items.text': '주관식 답변',
|
|
37
|
+
'option.common.select.errorMessage.required': '선택지를 입력해주세요.',
|
|
38
|
+
'option.common.select.placeholder': '선택지 입력',
|
|
39
|
+
'option.common.select.tooltip.minOptionInfoItem': '선택지는 2개 이상 입력해야 합니다.',
|
|
40
|
+
'option.common.select.tooltip.maxOptionInfoItem': '선택지는 20개 초과하여 입력할 수 없습니다.',
|
|
41
|
+
'option.common.select.addButton': '보기 추가'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.en = en;
|
|
45
|
+
exports.ko = ko;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MaterialSurveyEditValue } from '../MaterialSurveyEdit';
|
|
2
|
+
declare type _SurveyEditQuestionInfo = Omit<MaterialSurveyEditValue['questionInfoList'][number], 'optionInfo'> & {
|
|
3
|
+
optionInfo: {
|
|
4
|
+
id: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
};
|
|
8
|
+
export declare type _SurveyEditValue = Omit<MaterialSurveyEditValue, 'questionInfoList'> & {
|
|
9
|
+
questionInfoList: _SurveyEditQuestionInfo[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export declare function manipulateValue(v: MaterialSurveyEditValue): _SurveyEditValue;
|
|
15
|
+
/**
|
|
16
|
+
* Restore manipulation from `manipulateValue()`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function restoreValue(v: _SurveyEditValue): MaterialSurveyEditValue;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var randomId = require('./randomId.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
function manipulateValue(v) {
|
|
12
|
+
return Object.assign(Object.assign({}, v), {
|
|
13
|
+
questionInfoList: v.questionInfoList.map(questionInfo => Object.assign(Object.assign({}, questionInfo), {
|
|
14
|
+
// convert string array to object array
|
|
15
|
+
// - ref: https://github.com/react-hook-form/react-hook-form/issues/7622#issuecomment-1018893318
|
|
16
|
+
optionInfo: Array.isArray(questionInfo.optionInfo) ? questionInfo.optionInfo.map(option => ({
|
|
17
|
+
id: randomId.createRandomId(),
|
|
18
|
+
value: option
|
|
19
|
+
})) : []
|
|
20
|
+
}))
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Restore manipulation from `manipulateValue()`.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
function restoreValue(v) {
|
|
28
|
+
return Object.assign(Object.assign({}, v), {
|
|
29
|
+
questionInfoList: v.questionInfoList.map(questionInfo => {
|
|
30
|
+
var _a;
|
|
31
|
+
|
|
32
|
+
const newQuestionInfo = Object.assign(Object.assign({}, questionInfo), {
|
|
33
|
+
optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(option => option.value) : null
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (!newQuestionInfo.optionInfo) {
|
|
37
|
+
delete newQuestionInfo.optionInfo;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return newQuestionInfo;
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.manipulateValue = manipulateValue;
|
|
46
|
+
exports.restoreValue = restoreValue;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const StyledMarkdown: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@elice/markdown").MarkdownProps & import("react").RefAttributes<HTMLParagraphElement>>, any, {}, never>;
|
|
3
|
+
export default StyledMarkdown;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var markdown = require('@elice/markdown');
|
|
4
|
+
var styled = require('styled-components');
|
|
5
|
+
|
|
6
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
|
+
|
|
8
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
9
|
+
|
|
10
|
+
const StyledMarkdown = styled__default["default"](markdown.Markdown).withConfig({
|
|
11
|
+
componentId: "sc-h8kc9g-0"
|
|
12
|
+
})(["p{margin:0 !important;}"]);
|
|
13
|
+
|
|
14
|
+
module.exports = StyledMarkdown;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ButtonProps } from '@elice/blocks';
|
|
3
|
+
interface QuestionBoxProps {
|
|
4
|
+
footerActions?: ButtonProps[];
|
|
5
|
+
title?: string;
|
|
6
|
+
submitResult?: React.ReactNode;
|
|
7
|
+
submitStatus?: React.ReactNode;
|
|
8
|
+
onNext?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const StyledQuestionBox: import("styled-components").StyledComponent<"div", any, {
|
|
11
|
+
vertical: boolean;
|
|
12
|
+
hasFooter: boolean;
|
|
13
|
+
}, never>;
|
|
14
|
+
declare const SurveyContentBox: React.FC<QuestionBoxProps>;
|
|
15
|
+
export default SurveyContentBox;
|