@elice/material-survey 1.240718.0-trasncript.2 → 1.240718.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/components/markdown-editor/index.d.ts +2 -1
- package/cjs/components/markdown-editor/index.js +10 -19
- package/cjs/components/material-survey/MaterialSurvey.js +57 -82
- package/cjs/components/material-survey/MaterialSurveyInfo.js +59 -69
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +90 -131
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +86 -125
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +40 -47
- package/cjs/components/material-survey/MaterialSurveyText.js +75 -114
- package/cjs/components/material-survey/SurveyResultBadge.js +10 -17
- package/cjs/components/material-survey/SurveySubmitStatusText.js +16 -21
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +74 -115
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +36 -49
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +91 -113
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +87 -100
- package/cjs/components/material-survey-edit/context.js +2 -8
- package/cjs/components/material-survey-edit/utils/editValue.js +11 -17
- package/cjs/components/shared/StyledMarkdown.js +1 -5
- package/cjs/components/shared/SurveyContentBox.js +74 -85
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +7 -13
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -24
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +89 -66
- package/cjs/components/shared/question-radio/QuestionRadio.js +7 -13
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +17 -24
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +80 -59
- package/es/components/markdown-editor/index.d.ts +2 -1
- package/es/components/markdown-editor/index.js +10 -15
- package/es/components/material-survey/MaterialSurvey.js +57 -77
- package/es/components/material-survey/MaterialSurveyInfo.js +59 -65
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +90 -127
- package/es/components/material-survey/MaterialSurveySelectOne.js +86 -121
- package/es/components/material-survey/MaterialSurveyShimmer.js +40 -43
- package/es/components/material-survey/MaterialSurveyText.js +75 -109
- package/es/components/material-survey/SurveyResultBadge.js +10 -13
- package/es/components/material-survey/SurveySubmitStatusText.js +16 -17
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/es/components/material-survey/context/MaterialSurveyContext.js +75 -112
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +36 -45
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +90 -107
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +87 -96
- package/es/components/material-survey-edit/context.js +2 -4
- 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 +74 -81
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +7 -9
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +17 -20
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +89 -61
- package/es/components/shared/question-radio/QuestionRadio.js +7 -9
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +17 -20
- package/es/components/shared/question-radio/QuestionRadioOption.js +80 -54
- package/package.json +12 -9
- package/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -399
- package/cjs/components/material-survey/index.js +0 -9
- package/cjs/components/material-survey/locales/index.js +0 -13
- package/cjs/components/material-survey-edit/index.js +0 -7
- package/cjs/components/material-survey-edit/locales/index.js +0 -13
- package/cjs/components/shared/index.js +0 -13
- package/es/_virtual/_rollupPluginBabelHelpers.js +0 -386
- package/es/components/material-survey/index.js +0 -2
- package/es/components/material-survey/locales/index.js +0 -4
- package/es/components/material-survey-edit/index.js +0 -1
- package/es/components/material-survey-edit/locales/index.js +0 -4
- package/es/components/shared/index.js +0 -4
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
5
|
var React = require('react');
|
|
7
6
|
var reactHookForm = require('react-hook-form');
|
|
8
7
|
var intl = require('@elice/intl');
|
|
@@ -13,35 +12,32 @@ var en = require('./locales/en.json.js');
|
|
|
13
12
|
var ko = require('./locales/ko.json.js');
|
|
14
13
|
var MaterialSurveyEditContent = require('./MaterialSurveyEditContent.js');
|
|
15
14
|
|
|
16
|
-
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
17
|
-
|
|
18
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
19
|
-
|
|
20
15
|
//
|
|
21
16
|
//
|
|
22
17
|
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
const MaterialSurveyEdit = React.forwardRef(({
|
|
19
|
+
value,
|
|
20
|
+
disabled = false,
|
|
21
|
+
onChange,
|
|
22
|
+
onFormStateChange,
|
|
23
|
+
onFileUploadRequest,
|
|
24
|
+
__intl
|
|
25
|
+
}, ref) => {
|
|
26
|
+
const formElRef = React.useRef(null);
|
|
27
|
+
const useFormMethods = reactHookForm.useForm({
|
|
33
28
|
defaultValues: editValue.manipulateValue(value),
|
|
34
29
|
mode: 'onBlur'
|
|
35
30
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
isDirty
|
|
39
|
-
isValid
|
|
31
|
+
const watchedMaterialSurveyEditValue = useFormMethods.watch();
|
|
32
|
+
const {
|
|
33
|
+
isDirty,
|
|
34
|
+
isValid
|
|
35
|
+
} = useFormMethods.formState;
|
|
40
36
|
//
|
|
41
37
|
// Reset from value, when `value` changes.
|
|
42
38
|
// TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
|
|
43
39
|
//
|
|
44
|
-
materialSharedUtils.useDeepClonedCompareEffect(
|
|
40
|
+
materialSharedUtils.useDeepClonedCompareEffect(() => {
|
|
45
41
|
useFormMethods.reset(editValue.manipulateValue(value), {
|
|
46
42
|
keepDirty: true,
|
|
47
43
|
keepErrors: true,
|
|
@@ -55,17 +51,15 @@ var MaterialSurveyEdit = React.forwardRef(function (_ref, ref) {
|
|
|
55
51
|
// Emit `onChange` handler when form value changed.
|
|
56
52
|
// TODO: will be removed, since `CourseLecturesMaterialTemplate` removed at `elice-web`.
|
|
57
53
|
//
|
|
58
|
-
materialSharedUtils.useDeepClonedCompareEffect(
|
|
59
|
-
return onChange(editValue.restoreValue(watchedMaterialSurveyEditValue));
|
|
60
|
-
}, [watchedMaterialSurveyEditValue]);
|
|
54
|
+
materialSharedUtils.useDeepClonedCompareEffect(() => onChange(editValue.restoreValue(watchedMaterialSurveyEditValue)), [watchedMaterialSurveyEditValue]);
|
|
61
55
|
//
|
|
62
56
|
// Emit `onFormStateChange` handler when form state change.
|
|
63
57
|
//
|
|
64
|
-
|
|
58
|
+
React.useEffect(() => {
|
|
65
59
|
if (typeof onFormStateChange === 'function') {
|
|
66
60
|
onFormStateChange({
|
|
67
|
-
isDirty
|
|
68
|
-
isValid
|
|
61
|
+
isDirty,
|
|
62
|
+
isValid
|
|
69
63
|
});
|
|
70
64
|
}
|
|
71
65
|
},
|
|
@@ -74,32 +68,25 @@ var MaterialSurveyEdit = React.forwardRef(function (_ref, ref) {
|
|
|
74
68
|
//
|
|
75
69
|
// Set ref.
|
|
76
70
|
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
reset
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
}, [useFormMethods, value]);
|
|
71
|
+
React.useImperativeHandle(ref, () => Object.assign(Object.assign({}, formElRef.current), {
|
|
72
|
+
reset: () => {
|
|
73
|
+
useFormMethods.reset(editValue.manipulateValue(value));
|
|
74
|
+
void useFormMethods.trigger();
|
|
75
|
+
}
|
|
76
|
+
}), [useFormMethods, value]);
|
|
85
77
|
//
|
|
86
78
|
//
|
|
87
79
|
//
|
|
88
|
-
return
|
|
89
|
-
value: __intl
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
children: jsxRuntime.jsx(MaterialSurveyEditContent.default, {})
|
|
99
|
-
}))
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
});
|
|
80
|
+
return React.createElement(intl.RawEliceIntlProvider, {
|
|
81
|
+
value: __intl
|
|
82
|
+
}, React.createElement("form", {
|
|
83
|
+
ref: formElRef
|
|
84
|
+
}, React.createElement(context.default.Provider, {
|
|
85
|
+
value: {
|
|
86
|
+
disabled,
|
|
87
|
+
onFileUploadRequest
|
|
88
|
+
}
|
|
89
|
+
}, React.createElement(reactHookForm.FormProvider, Object.assign({}, useFormMethods), React.createElement(MaterialSurveyEditContent.default, null)))));
|
|
103
90
|
});
|
|
104
91
|
var MaterialSurveyEdit$1 = new intl.IntlComponentBuilder(MaterialSurveyEdit).add('en', en.default).add('ko', ko.default).addAsync('th', Promise.resolve().then(function () { return require('./locales/th.json.js'); })).addAsync('ja', Promise.resolve().then(function () { return require('./locales/ja.json.js'); })).build();
|
|
105
92
|
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
7
5
|
var React = require('react');
|
|
8
6
|
var reactHookForm = require('react-hook-form');
|
|
9
7
|
var blocks = require('@elice/blocks');
|
|
@@ -15,34 +13,28 @@ var randomId = require('./utils/randomId.js');
|
|
|
15
13
|
var context = require('./context.js');
|
|
16
14
|
var MaterialSurveyEditOptionSelect = require('./MaterialSurveyEditOptionSelect.js');
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
22
|
-
|
|
23
|
-
var MIN_TEXT_LENGTH = 1;
|
|
24
|
-
var MAX_TEXT_LENGTH = 128;
|
|
25
|
-
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({
|
|
26
19
|
componentId: "sc-r4ms68-0"
|
|
27
20
|
})(["display:flex;max-width:12rem;"]);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
disabled
|
|
32
|
-
onFileUploadRequest
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
watchedOptionInfo = _watch2[1];
|
|
21
|
+
const MaterialSurveyEditContent = () => {
|
|
22
|
+
const intl$1 = intl.useRawEliceIntl();
|
|
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']);
|
|
41
33
|
//
|
|
42
34
|
// Change `optionInfo` according to `optionType`.
|
|
43
35
|
//
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
const get = () => {
|
|
46
38
|
switch (watchedOptionType) {
|
|
47
39
|
case types.enums.SurveyOptionType.SelectOne:
|
|
48
40
|
case types.enums.SurveyOptionType.SelectMultiple:
|
|
@@ -77,29 +69,28 @@ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
|
|
|
77
69
|
* Input of option info and answer info,
|
|
78
70
|
* according to option type.
|
|
79
71
|
*/
|
|
80
|
-
|
|
72
|
+
const Option = React.useMemo(() => {
|
|
81
73
|
switch (watchedOptionType) {
|
|
82
74
|
case types.enums.SurveyOptionType.SelectOne:
|
|
83
75
|
case types.enums.SurveyOptionType.SelectMultiple:
|
|
84
76
|
return MaterialSurveyEditOptionSelect.default;
|
|
85
77
|
case types.enums.SurveyOptionType.Text:
|
|
86
78
|
default:
|
|
87
|
-
return
|
|
79
|
+
return React.Fragment;
|
|
88
80
|
}
|
|
89
81
|
}, [watchedOptionType]);
|
|
90
82
|
/**
|
|
91
83
|
* Render input for survey title.
|
|
92
84
|
*/
|
|
93
|
-
|
|
94
|
-
return
|
|
95
|
-
label:
|
|
85
|
+
const renderQuestionTitleInput = () => {
|
|
86
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
87
|
+
label: React.createElement(blocks.Label, {
|
|
96
88
|
size: "small",
|
|
97
|
-
required: true
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
input: jsxRuntime.jsx(reactHookForm.Controller, {
|
|
89
|
+
required: true
|
|
90
|
+
}, intl$1.formatMessage({
|
|
91
|
+
id: 'content.title'
|
|
92
|
+
})),
|
|
93
|
+
input: React.createElement(reactHookForm.Controller, {
|
|
103
94
|
control: control,
|
|
104
95
|
name: "questionInfoList.0.questionTitle",
|
|
105
96
|
rules: {
|
|
@@ -128,11 +119,12 @@ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
|
|
|
128
119
|
})
|
|
129
120
|
}
|
|
130
121
|
},
|
|
131
|
-
render:
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
render: ({
|
|
123
|
+
field,
|
|
124
|
+
fieldState
|
|
125
|
+
}) => {
|
|
134
126
|
var _a;
|
|
135
|
-
return
|
|
127
|
+
return React.createElement(blocks.Input, Object.assign({
|
|
136
128
|
size: "small",
|
|
137
129
|
width: "full",
|
|
138
130
|
minLength: MIN_TEXT_LENGTH,
|
|
@@ -150,93 +142,79 @@ var MaterialSurveyEditContent = function MaterialSurveyEditContent() {
|
|
|
150
142
|
/**
|
|
151
143
|
* Render input for survey description.
|
|
152
144
|
*/
|
|
153
|
-
|
|
154
|
-
return
|
|
155
|
-
label:
|
|
156
|
-
size: "small"
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
input: jsxRuntime.jsx(reactHookForm.Controller, {
|
|
145
|
+
const renderQuestionDescriptionInput = () => {
|
|
146
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
147
|
+
label: React.createElement(blocks.Label, {
|
|
148
|
+
size: "small"
|
|
149
|
+
}, intl$1.formatMessage({
|
|
150
|
+
id: 'content.description.title'
|
|
151
|
+
})),
|
|
152
|
+
input: React.createElement(reactHookForm.Controller, {
|
|
162
153
|
control: control,
|
|
163
154
|
name: "questionInfoList.0.questionDescription",
|
|
164
|
-
render:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
155
|
+
render: ({
|
|
156
|
+
field
|
|
157
|
+
}) => React.createElement(index.MarkdownEditor, Object.assign({
|
|
158
|
+
placeholder: intl$1.formatMessage({
|
|
159
|
+
id: 'content.description.placeholder'
|
|
160
|
+
}),
|
|
161
|
+
onFileUploadRequest: onFileUploadRequest
|
|
162
|
+
}, field))
|
|
173
163
|
})
|
|
174
164
|
});
|
|
175
165
|
};
|
|
176
166
|
/**
|
|
177
167
|
* Render input of option type, option info and answer info.
|
|
178
168
|
*/
|
|
179
|
-
|
|
180
|
-
return
|
|
181
|
-
label:
|
|
169
|
+
const renderOptionInput = () => {
|
|
170
|
+
return React.createElement(blocks.FormInputVerticalLayout, {
|
|
171
|
+
label: React.createElement(blocks.Label, {
|
|
182
172
|
size: "small",
|
|
183
|
-
required: true
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
})
|
|
223
|
-
})]
|
|
224
|
-
}))
|
|
225
|
-
})
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
229
|
-
height: 0.5
|
|
230
|
-
}), jsxRuntime.jsx(Option, {})]
|
|
231
|
-
})
|
|
173
|
+
required: true
|
|
174
|
+
}, intl$1.formatMessage({
|
|
175
|
+
id: 'content.option.title'
|
|
176
|
+
})),
|
|
177
|
+
input: React.createElement(React.Fragment, null, React.createElement(reactHookForm.Controller, {
|
|
178
|
+
control: control,
|
|
179
|
+
name: "questionInfoList.0.optionType",
|
|
180
|
+
render: ({
|
|
181
|
+
field
|
|
182
|
+
}) => React.createElement(blocks.Tooltip, {
|
|
183
|
+
title: disabled ? intl$1.formatMessage({
|
|
184
|
+
id: 'content.option.tooltip.disabled'
|
|
185
|
+
}) : undefined,
|
|
186
|
+
placement: "top-end"
|
|
187
|
+
}, React.createElement(StyledSurveyOptionTypeSelectWrap, null, React.createElement(blocks.Select, Object.assign({
|
|
188
|
+
size: "small",
|
|
189
|
+
width: "small",
|
|
190
|
+
readOnly: disabled
|
|
191
|
+
}, field, {
|
|
192
|
+
onChange: v => field.onChange(Number(v))
|
|
193
|
+
}), React.createElement("option", {
|
|
194
|
+
value: types.enums.SurveyOptionType.SelectOne,
|
|
195
|
+
children: intl$1.formatMessage({
|
|
196
|
+
id: 'content.option.select.items.selectOne'
|
|
197
|
+
})
|
|
198
|
+
}), React.createElement("option", {
|
|
199
|
+
value: types.enums.SurveyOptionType.SelectMultiple,
|
|
200
|
+
children: intl$1.formatMessage({
|
|
201
|
+
id: 'content.option.select.items.selectMultiple'
|
|
202
|
+
})
|
|
203
|
+
}), React.createElement("option", {
|
|
204
|
+
value: types.enums.SurveyOptionType.Text,
|
|
205
|
+
children: intl$1.formatMessage({
|
|
206
|
+
id: 'content.option.select.items.text'
|
|
207
|
+
})
|
|
208
|
+
}))))
|
|
209
|
+
}), React.createElement(blocks.Vspace, {
|
|
210
|
+
height: 0.5
|
|
211
|
+
}), React.createElement(Option, null))
|
|
232
212
|
});
|
|
233
213
|
};
|
|
234
214
|
//
|
|
235
215
|
//
|
|
236
216
|
//
|
|
237
|
-
return
|
|
238
|
-
children: [renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput()]
|
|
239
|
-
});
|
|
217
|
+
return React.createElement(React.Fragment, null, renderQuestionTitleInput(), renderQuestionDescriptionInput(), renderOptionInput());
|
|
240
218
|
};
|
|
241
219
|
|
|
242
220
|
exports.default = MaterialSurveyEditContent;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var React = require('react');
|
|
6
6
|
var reactHookForm = require('react-hook-form');
|
|
7
7
|
var blocks = require('@elice/blocks');
|
|
8
8
|
var icons = require('@elice/icons');
|
|
@@ -11,36 +11,35 @@ var styled = require('styled-components');
|
|
|
11
11
|
var randomId = require('./utils/randomId.js');
|
|
12
12
|
var context = require('./context.js');
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var MIN_OPTION_INFO_COUNT = 2;
|
|
19
|
-
var MAX_OPTION_INFO_COUNT = 20;
|
|
20
|
-
var StyledWrap = styled__default.default.div.withConfig({
|
|
14
|
+
const MIN_OPTION_INFO_COUNT = 2;
|
|
15
|
+
const MAX_OPTION_INFO_COUNT = 20;
|
|
16
|
+
const StyledWrap = styled.div.withConfig({
|
|
21
17
|
componentId: "sc-1eiyk6z-0"
|
|
22
18
|
})([""]);
|
|
23
|
-
|
|
19
|
+
const StyledInputGroup = styled.div.withConfig({
|
|
24
20
|
componentId: "sc-1eiyk6z-1"
|
|
25
21
|
})(["width:100%;.eb-input{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
disabled
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
const OptionSelectOne = () => {
|
|
23
|
+
const intl$1 = intl.useRawEliceIntl();
|
|
24
|
+
const {
|
|
25
|
+
disabled
|
|
26
|
+
} = context.useMaterialSurveyEditContext();
|
|
27
|
+
const {
|
|
28
|
+
control
|
|
29
|
+
} = reactHookForm.useFormContext();
|
|
30
|
+
const {
|
|
31
|
+
fields: optionInfoFields,
|
|
32
|
+
append: appendOptionInfoFieldItem,
|
|
33
|
+
remove: removeOptionInfoFieldItem
|
|
34
|
+
} = reactHookForm.useFieldArray({
|
|
35
|
+
name: 'questionInfoList.0.optionInfo',
|
|
36
|
+
keyName: 'id',
|
|
37
|
+
shouldUnregister: true
|
|
38
|
+
});
|
|
40
39
|
/**
|
|
41
40
|
* Append option info.
|
|
42
41
|
*/
|
|
43
|
-
|
|
42
|
+
const appendOptionInfo = () => {
|
|
44
43
|
appendOptionInfoFieldItem({
|
|
45
44
|
id: randomId.createRandomId(),
|
|
46
45
|
value: ''
|
|
@@ -49,88 +48,76 @@ var OptionSelectOne = function OptionSelectOne() {
|
|
|
49
48
|
/**
|
|
50
49
|
* Remove item from option info at index.
|
|
51
50
|
*/
|
|
52
|
-
|
|
51
|
+
const removeOptionInfo = index => {
|
|
53
52
|
removeOptionInfoFieldItem(index);
|
|
54
53
|
};
|
|
55
54
|
//
|
|
56
55
|
//
|
|
57
56
|
//
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
id: 'option.common.select.errorMessage.required'
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
render: function render(_ref2) {
|
|
74
|
-
var field = _ref2.field,
|
|
75
|
-
fieldState = _ref2.fieldState;
|
|
76
|
-
var _a;
|
|
77
|
-
return jsxRuntime.jsx(blocks.Input, Object.assign({
|
|
78
|
-
size: "small",
|
|
79
|
-
width: "full",
|
|
80
|
-
placeholder: intl$1.formatMessage({
|
|
81
|
-
id: 'option.common.select.placeholder'
|
|
82
|
-
}),
|
|
83
|
-
suffix: jsxRuntime.jsx(blocks.Tooltip, {
|
|
84
|
-
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
85
|
-
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
86
|
-
}) : undefined,
|
|
87
|
-
placement: "top-start",
|
|
88
|
-
children: jsxRuntime.jsx("span", {
|
|
89
|
-
children: jsxRuntime.jsx(blocks.IconButton, {
|
|
90
|
-
icon: icons.eilMathsignMultiplyBasic,
|
|
91
|
-
role: "grey9",
|
|
92
|
-
size: "tiny",
|
|
93
|
-
border: false,
|
|
94
|
-
transparent: true,
|
|
95
|
-
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
96
|
-
onClick: function onClick() {
|
|
97
|
-
return removeOptionInfo(index);
|
|
98
|
-
}
|
|
99
|
-
})
|
|
100
|
-
})
|
|
101
|
-
}),
|
|
102
|
-
readOnly: disabled,
|
|
103
|
-
invalid: fieldState.invalid,
|
|
104
|
-
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
105
|
-
}, field));
|
|
106
|
-
}
|
|
107
|
-
}, id);
|
|
108
|
-
})
|
|
109
|
-
}), jsxRuntime.jsx(blocks.Vspace, {
|
|
110
|
-
height: 0.5
|
|
111
|
-
}), jsxRuntime.jsx(blocks.Tooltip, {
|
|
112
|
-
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
113
|
-
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
114
|
-
}) : undefined,
|
|
115
|
-
placement: "bottom",
|
|
116
|
-
children: jsxRuntime.jsx("span", {
|
|
117
|
-
children: jsxRuntime.jsx(blocks.Button, {
|
|
118
|
-
block: true,
|
|
119
|
-
size: "micro",
|
|
120
|
-
borderDashed: true,
|
|
121
|
-
transparent: true,
|
|
122
|
-
icon: jsxRuntime.jsx(blocks.Icon, {
|
|
123
|
-
icon: icons.eilMathsignAddCircle
|
|
124
|
-
}),
|
|
125
|
-
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
126
|
-
onClick: appendOptionInfo,
|
|
127
|
-
children: intl$1.formatMessage({
|
|
128
|
-
id: 'option.common.select.addButton'
|
|
129
|
-
})
|
|
57
|
+
return React.createElement(StyledWrap, null, React.createElement(StyledInputGroup, null, optionInfoFields.map(({
|
|
58
|
+
id
|
|
59
|
+
}, index) => React.createElement(reactHookForm.Controller, {
|
|
60
|
+
key: id,
|
|
61
|
+
control: control,
|
|
62
|
+
name: `questionInfoList.0.optionInfo.${index}.value`,
|
|
63
|
+
rules: {
|
|
64
|
+
required: {
|
|
65
|
+
value: true,
|
|
66
|
+
message: intl$1.formatMessage({
|
|
67
|
+
id: 'option.common.select.errorMessage.required'
|
|
130
68
|
})
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
render: ({
|
|
72
|
+
field,
|
|
73
|
+
fieldState
|
|
74
|
+
}) => {
|
|
75
|
+
var _a;
|
|
76
|
+
return React.createElement(blocks.Input, Object.assign({
|
|
77
|
+
size: "small",
|
|
78
|
+
width: "full",
|
|
79
|
+
placeholder: intl$1.formatMessage({
|
|
80
|
+
id: 'option.common.select.placeholder'
|
|
81
|
+
}),
|
|
82
|
+
suffix: React.createElement(blocks.Tooltip, {
|
|
83
|
+
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
84
|
+
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
85
|
+
}) : undefined,
|
|
86
|
+
placement: "top-start"
|
|
87
|
+
}, React.createElement("span", null, React.createElement(blocks.IconButton, {
|
|
88
|
+
icon: icons.eilMathsignMultiplyBasic,
|
|
89
|
+
role: "grey9",
|
|
90
|
+
size: "tiny",
|
|
91
|
+
border: false,
|
|
92
|
+
transparent: true,
|
|
93
|
+
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
94
|
+
onClick: () => removeOptionInfo(index)
|
|
95
|
+
}))),
|
|
96
|
+
readOnly: disabled,
|
|
97
|
+
invalid: fieldState.invalid,
|
|
98
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
99
|
+
}, field));
|
|
100
|
+
}
|
|
101
|
+
}))), React.createElement(blocks.Vspace, {
|
|
102
|
+
height: 0.5
|
|
103
|
+
}), React.createElement(blocks.Tooltip, {
|
|
104
|
+
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl$1.formatMessage({
|
|
105
|
+
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
106
|
+
}) : undefined,
|
|
107
|
+
placement: "bottom"
|
|
108
|
+
}, React.createElement("span", null, React.createElement(blocks.Button, {
|
|
109
|
+
block: true,
|
|
110
|
+
size: "micro",
|
|
111
|
+
borderDashed: true,
|
|
112
|
+
transparent: true,
|
|
113
|
+
icon: React.createElement(blocks.Icon, {
|
|
114
|
+
icon: icons.eilMathsignAddCircle
|
|
115
|
+
}),
|
|
116
|
+
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
117
|
+
onClick: appendOptionInfo
|
|
118
|
+
}, intl$1.formatMessage({
|
|
119
|
+
id: 'option.common.select.addButton'
|
|
120
|
+
})))));
|
|
134
121
|
};
|
|
135
122
|
|
|
136
123
|
exports.default = OptionSelectOne;
|
|
@@ -4,14 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
10
|
-
|
|
11
|
-
var MaterialSurveyEditContext = React__default.default.createContext(null);
|
|
12
|
-
var useMaterialSurveyEditContext = function useMaterialSurveyEditContext() {
|
|
13
|
-
return React__default.default.useContext(MaterialSurveyEditContext);
|
|
14
|
-
};
|
|
7
|
+
const MaterialSurveyEditContext = React.createContext(null);
|
|
8
|
+
const useMaterialSurveyEditContext = () => React.useContext(MaterialSurveyEditContext);
|
|
15
9
|
|
|
16
10
|
exports.default = MaterialSurveyEditContext;
|
|
17
11
|
exports.useMaterialSurveyEditContext = useMaterialSurveyEditContext;
|