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