@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
|
@@ -11,37 +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
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
18
|
-
|
|
19
|
-
var MIN_OPTION_INFO_COUNT = 2;
|
|
20
|
-
var MAX_OPTION_INFO_COUNT = 20;
|
|
21
|
-
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({
|
|
22
17
|
componentId: "sc-1eiyk6z-0"
|
|
23
18
|
})([""]);
|
|
24
|
-
|
|
19
|
+
const StyledInputGroup = styled.div.withConfig({
|
|
25
20
|
componentId: "sc-1eiyk6z-1"
|
|
26
21
|
})(["width:100%;.eb-input{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
disabled
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
const OptionSelectOne = () => {
|
|
23
|
+
const intl = reactIntl.useIntl();
|
|
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
|
+
});
|
|
41
39
|
/**
|
|
42
40
|
* Append option info.
|
|
43
41
|
*/
|
|
44
|
-
|
|
42
|
+
const appendOptionInfo = () => {
|
|
45
43
|
appendOptionInfoFieldItem({
|
|
46
44
|
id: randomId.createRandomId(),
|
|
47
45
|
value: ''
|
|
@@ -50,78 +48,76 @@ var OptionSelectOne = function OptionSelectOne() {
|
|
|
50
48
|
/**
|
|
51
49
|
* Remove item from option info at index.
|
|
52
50
|
*/
|
|
53
|
-
|
|
51
|
+
const removeOptionInfo = index => {
|
|
54
52
|
removeOptionInfoFieldItem(index);
|
|
55
53
|
};
|
|
56
54
|
//
|
|
57
55
|
//
|
|
58
56
|
//
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
render: function render(_ref2) {
|
|
74
|
-
var field = _ref2.field,
|
|
75
|
-
fieldState = _ref2.fieldState;
|
|
76
|
-
var _a;
|
|
77
|
-
return React__default["default"].createElement(blocks.Input, Object.assign({
|
|
78
|
-
size: "small",
|
|
79
|
-
width: "full",
|
|
80
|
-
placeholder: intl.formatMessage({
|
|
81
|
-
id: 'option.common.select.placeholder'
|
|
82
|
-
}),
|
|
83
|
-
suffix: React__default["default"].createElement(blocks.Tooltip, {
|
|
84
|
-
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
85
|
-
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
86
|
-
}) : undefined,
|
|
87
|
-
placement: "top-start"
|
|
88
|
-
}, React__default["default"].createElement("span", null, React__default["default"].createElement(blocks.IconButton, {
|
|
89
|
-
icon: icons.eilMathsignMultiplyBasic,
|
|
90
|
-
role: "grey9",
|
|
91
|
-
size: "tiny",
|
|
92
|
-
border: false,
|
|
93
|
-
transparent: true,
|
|
94
|
-
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
95
|
-
onClick: function onClick() {
|
|
96
|
-
return removeOptionInfo(index);
|
|
97
|
-
}
|
|
98
|
-
}))),
|
|
99
|
-
readOnly: disabled,
|
|
100
|
-
invalid: fieldState.invalid,
|
|
101
|
-
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
102
|
-
}, field));
|
|
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.formatMessage({
|
|
67
|
+
id: 'option.common.select.errorMessage.required'
|
|
68
|
+
})
|
|
103
69
|
}
|
|
104
|
-
}
|
|
105
|
-
|
|
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.formatMessage({
|
|
80
|
+
id: 'option.common.select.placeholder'
|
|
81
|
+
}),
|
|
82
|
+
suffix: React.createElement(blocks.Tooltip, {
|
|
83
|
+
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.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, {
|
|
106
102
|
height: 0.5
|
|
107
|
-
}),
|
|
103
|
+
}), React.createElement(blocks.Tooltip, {
|
|
108
104
|
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
109
105
|
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
110
106
|
}) : undefined,
|
|
111
107
|
placement: "bottom"
|
|
112
|
-
},
|
|
108
|
+
}, React.createElement("span", null, React.createElement(blocks.Button, {
|
|
113
109
|
block: true,
|
|
114
110
|
size: "micro",
|
|
115
111
|
borderDashed: true,
|
|
116
112
|
transparent: true,
|
|
117
|
-
icon:
|
|
113
|
+
icon: React.createElement(blocks.Icon, {
|
|
118
114
|
icon: icons.eilMathsignAddCircle
|
|
119
115
|
}),
|
|
120
116
|
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
121
117
|
onClick: appendOptionInfo
|
|
122
|
-
},
|
|
118
|
+
}, React.createElement(reactIntl.FormattedMessage, {
|
|
123
119
|
id: "option.common.select.addButton"
|
|
124
120
|
})))));
|
|
125
121
|
};
|
|
126
122
|
|
|
127
|
-
exports
|
|
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
|
-
|
|
7
|
+
const MaterialSurveyEditContext = React.createContext(null);
|
|
8
|
+
const useMaterialSurveyEditContext = () => React.useContext(MaterialSurveyEditContext);
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var MaterialSurveyEditContext = React__default["default"].createContext(null);
|
|
12
|
-
var useMaterialSurveyEditContext = function useMaterialSurveyEditContext() {
|
|
13
|
-
return React__default["default"].useContext(MaterialSurveyEditContext);
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
exports["default"] = MaterialSurveyEditContext;
|
|
10
|
+
exports.default = MaterialSurveyEditContext;
|
|
17
11
|
exports.useMaterialSurveyEditContext = useMaterialSurveyEditContext;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var en = {
|
|
3
|
+
const en = {
|
|
6
4
|
'common.option': 'Option {number}',
|
|
7
5
|
'common.errorMessage.range': 'Please enter within {min} ~ {max} characters.',
|
|
8
6
|
'content.title': 'Question',
|
|
@@ -21,7 +19,7 @@ var en = {
|
|
|
21
19
|
'option.common.select.tooltip.maxOptionInfoItem': 'You cannot enter more than 20 options.',
|
|
22
20
|
'option.common.select.addButton': 'Add Option'
|
|
23
21
|
};
|
|
24
|
-
|
|
22
|
+
const ko = {
|
|
25
23
|
'common.option': '옵션 {number}',
|
|
26
24
|
'common.errorMessage.range': '{min} ~ {max}자 이내로 입력해주세요.',
|
|
27
25
|
'content.title': '질문',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var randomId = require('./randomId.js');
|
|
6
4
|
|
|
7
5
|
/**
|
|
@@ -9,18 +7,14 @@ var randomId = require('./randomId.js');
|
|
|
9
7
|
*/
|
|
10
8
|
function manipulateValue(v) {
|
|
11
9
|
return Object.assign(Object.assign({}, v), {
|
|
12
|
-
questionInfoList: v.questionInfoList.map(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
}) : []
|
|
22
|
-
});
|
|
23
|
-
})
|
|
10
|
+
questionInfoList: v.questionInfoList.map(questionInfo => Object.assign(Object.assign({}, questionInfo), {
|
|
11
|
+
// convert string array to object array
|
|
12
|
+
// - ref: https://github.com/react-hook-form/react-hook-form/issues/7622#issuecomment-1018893318
|
|
13
|
+
optionInfo: Array.isArray(questionInfo.optionInfo) ? questionInfo.optionInfo.map(option => ({
|
|
14
|
+
id: randomId.createRandomId(),
|
|
15
|
+
value: option
|
|
16
|
+
})) : []
|
|
17
|
+
}))
|
|
24
18
|
});
|
|
25
19
|
}
|
|
26
20
|
/**
|
|
@@ -28,12 +22,10 @@ function manipulateValue(v) {
|
|
|
28
22
|
*/
|
|
29
23
|
function restoreValue(v) {
|
|
30
24
|
return Object.assign(Object.assign({}, v), {
|
|
31
|
-
questionInfoList: v.questionInfoList.map(
|
|
25
|
+
questionInfoList: v.questionInfoList.map(questionInfo => {
|
|
32
26
|
var _a;
|
|
33
|
-
|
|
34
|
-
optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(
|
|
35
|
-
return option.value;
|
|
36
|
-
}) : null
|
|
27
|
+
const newQuestionInfo = Object.assign(Object.assign({}, questionInfo), {
|
|
28
|
+
optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(option => option.value) : null
|
|
37
29
|
});
|
|
38
30
|
if (!newQuestionInfo.optionInfo) {
|
|
39
31
|
delete newQuestionInfo.optionInfo;
|
|
@@ -5,12 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var markdown = require('@elice/markdown');
|
|
6
6
|
var styled = require('styled-components');
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
11
|
-
|
|
12
|
-
var StyledMarkdown = styled__default["default"](markdown.Markdown).withConfig({
|
|
8
|
+
const StyledMarkdown = styled(markdown.Markdown).withConfig({
|
|
13
9
|
componentId: "sc-h8kc9g-0"
|
|
14
10
|
})(["p{margin:0 !important;}"]);
|
|
15
11
|
|
|
16
|
-
exports
|
|
12
|
+
exports.default = StyledMarkdown;
|
|
@@ -10,77 +10,76 @@ var designTokens = require('@elice/design-tokens');
|
|
|
10
10
|
var styled = require('styled-components');
|
|
11
11
|
var MaterialSurveyContext = require('../material-survey/context/MaterialSurveyContext.js');
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
17
|
-
|
|
18
|
-
var StyledQuestionBox = styled__default["default"].div.withConfig({
|
|
13
|
+
const StyledQuestionBox = styled.div.withConfig({
|
|
19
14
|
componentId: "sc-h8ztvr-0"
|
|
20
|
-
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;max-height:", ";min-height:", ";"],
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return hasFooter ? '' : '100%';
|
|
29
|
-
});
|
|
30
|
-
var StyledQuestionBoxHeader = styled__default["default"].div.withConfig({
|
|
15
|
+
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;max-height:", ";min-height:", ";"], ({
|
|
16
|
+
vertical
|
|
17
|
+
}) => vertical ? '0' : '8px', ({
|
|
18
|
+
hasFooter
|
|
19
|
+
}) => hasFooter ? '100%' : '', ({
|
|
20
|
+
hasFooter
|
|
21
|
+
}) => hasFooter ? '' : '100%');
|
|
22
|
+
const StyledQuestionBoxHeader = styled.div.withConfig({
|
|
31
23
|
componentId: "sc-h8ztvr-1"
|
|
32
24
|
})(["display:flex;justify-content:space-between;background-color:", ";padding:1rem 1.5rem;flex:none;height:3.5rem;"], designTokens.base.color.navy6);
|
|
33
|
-
|
|
25
|
+
const StyledQuestionBoxBody = styled.div.withConfig({
|
|
34
26
|
componentId: "sc-h8ztvr-2"
|
|
35
|
-
})(["padding:1.5rem;background-color:", ";flex:auto;", "})"], designTokens.base.color.navy7,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var StyledQuestionBoxFooter = styled__default["default"].div.withConfig({
|
|
27
|
+
})(["padding:1.5rem;background-color:", ";flex:auto;", "})"], designTokens.base.color.navy7, ({
|
|
28
|
+
hasFooter
|
|
29
|
+
}) => hasFooter ? 'height: 100%; overflow-y: auto;' : '');
|
|
30
|
+
const StyledQuestionBoxFooter = styled.div.withConfig({
|
|
40
31
|
componentId: "sc-h8ztvr-3"
|
|
41
|
-
})(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], designTokens.base.color.navy6,
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
})(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], designTokens.base.color.navy6, ({
|
|
33
|
+
vertical
|
|
34
|
+
}) => {
|
|
35
|
+
return vertical ? `
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
align-items: flex-start;
|
|
38
|
+
` : '';
|
|
44
39
|
});
|
|
45
|
-
|
|
40
|
+
const StyledQuestionBoxFooterActions = styled.div.withConfig({
|
|
46
41
|
componentId: "sc-h8ztvr-4"
|
|
47
42
|
})(["display:flex;> *:not(:last-child){margin-right:0.75rem;}"]);
|
|
48
|
-
|
|
43
|
+
const StyledQuestionBoxFooterStatus = styled.div.withConfig({
|
|
49
44
|
componentId: "sc-h8ztvr-5"
|
|
50
|
-
})(["margin-left:0.75rem;", ""],
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
})(["margin-left:0.75rem;", ""], ({
|
|
46
|
+
vertical
|
|
47
|
+
}) => {
|
|
48
|
+
return vertical ? `
|
|
49
|
+
margin-left: 0;
|
|
50
|
+
margin-top: 0.75rem;
|
|
51
|
+
` : '';
|
|
53
52
|
});
|
|
54
|
-
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
const SurveyContentBox = _a => {
|
|
54
|
+
var {
|
|
55
|
+
children,
|
|
56
|
+
footerActions = [],
|
|
57
|
+
title,
|
|
58
|
+
submitResult,
|
|
59
|
+
submitStatus,
|
|
60
|
+
onNext
|
|
61
|
+
} = _a,
|
|
62
62
|
props = tslib.__rest(_a, ["children", "footerActions", "title", "submitResult", "submitStatus", "onNext"]);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
vertical
|
|
66
|
-
|
|
67
|
-
|
|
63
|
+
const intl = reactIntl.useIntl();
|
|
64
|
+
const {
|
|
65
|
+
vertical
|
|
66
|
+
} = MaterialSurveyContext.useMaterialSurveyState();
|
|
67
|
+
const hasFooter = footerActions.length > 0;
|
|
68
|
+
const header = React.createElement(StyledQuestionBoxHeader, null, React.createElement(blocks.Text, {
|
|
68
69
|
bold: true,
|
|
69
70
|
customStyles: {
|
|
70
71
|
color: designTokens.base.color.navy0
|
|
71
72
|
}
|
|
72
73
|
}, title), submitResult ? submitResult : null);
|
|
73
|
-
|
|
74
|
+
const body = React.createElement(StyledQuestionBoxBody, {
|
|
74
75
|
hasFooter: hasFooter
|
|
75
76
|
}, children);
|
|
76
|
-
|
|
77
|
+
const footer = React.createElement(StyledQuestionBoxFooter, {
|
|
77
78
|
vertical: vertical
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}, action), action.children);
|
|
83
|
-
}), typeof onNext === 'function' ? React__default["default"].createElement(blocks.Button, {
|
|
79
|
+
}, React.createElement(StyledQuestionBoxFooterActions, null, footerActions.map((action, index) => React.createElement(blocks.Button, Object.assign({
|
|
80
|
+
key: index,
|
|
81
|
+
size: "small"
|
|
82
|
+
}, action), action.children)), typeof onNext === 'function' ? React.createElement(blocks.Button, {
|
|
84
83
|
size: "small",
|
|
85
84
|
border: true,
|
|
86
85
|
tabIndex: 0,
|
|
@@ -89,14 +88,14 @@ var SurveyContentBox = function SurveyContentBox(_a) {
|
|
|
89
88
|
onClick: onNext
|
|
90
89
|
}, intl.formatMessage({
|
|
91
90
|
id: 'materialSurvey.next'
|
|
92
|
-
})) : null),
|
|
91
|
+
})) : null), React.createElement(StyledQuestionBoxFooterStatus, {
|
|
93
92
|
vertical: vertical
|
|
94
93
|
}, submitStatus));
|
|
95
|
-
return
|
|
94
|
+
return React.createElement(StyledQuestionBox, Object.assign({}, props, {
|
|
96
95
|
vertical: vertical,
|
|
97
96
|
hasFooter: hasFooter
|
|
98
97
|
}), header, body, footerActions.length > 0 ? footer : null);
|
|
99
98
|
};
|
|
100
99
|
|
|
101
100
|
exports.StyledQuestionBox = StyledQuestionBox;
|
|
102
|
-
exports
|
|
101
|
+
exports.default = SurveyContentBox;
|
|
@@ -7,18 +7,15 @@ var React = require('react');
|
|
|
7
7
|
var styled = require('styled-components');
|
|
8
8
|
var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
13
|
-
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
14
|
-
|
|
15
|
-
var StyledQuestionCheckbox = styled__default["default"].div.withConfig({
|
|
10
|
+
const StyledQuestionCheckbox = styled.div.withConfig({
|
|
16
11
|
componentId: "sc-1ovh9lp-0"
|
|
17
12
|
})(["display:flex;flex-direction:column;"]);
|
|
18
|
-
|
|
19
|
-
var
|
|
13
|
+
const QuestionCheckbox = _a => {
|
|
14
|
+
var {
|
|
15
|
+
children
|
|
16
|
+
} = _a,
|
|
20
17
|
props = tslib.__rest(_a, ["children"]);
|
|
21
|
-
return
|
|
18
|
+
return React.createElement(QuestionCheckboxContext.QuestionCheckboxContextProvider, Object.assign({}, props), React.createElement(StyledQuestionCheckbox, null, children));
|
|
22
19
|
};
|
|
23
20
|
|
|
24
|
-
exports
|
|
21
|
+
exports.default = QuestionCheckbox;
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var React = require('react');
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
10
|
-
|
|
11
|
-
var QuestionCheckboxContext = React__default["default"].createContext(undefined);
|
|
5
|
+
const QuestionCheckboxContext = React.createContext(undefined);
|
|
12
6
|
QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
|
|
13
|
-
function QuestionCheckboxContextProvider(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
function QuestionCheckboxContextProvider({
|
|
8
|
+
selectedOptions,
|
|
9
|
+
onSelect,
|
|
10
|
+
disabled,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
18
13
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, [selectedOptions, disabled, onSelectValue]);
|
|
27
|
-
return React__default["default"].createElement(QuestionCheckboxContext.Provider, {
|
|
14
|
+
const onSelectValue = React.useCallback(onSelect, []);
|
|
15
|
+
const value = React.useMemo(() => ({
|
|
16
|
+
selectedOptions,
|
|
17
|
+
disabled,
|
|
18
|
+
onSelect: onSelectValue
|
|
19
|
+
}), [selectedOptions, disabled, onSelectValue]);
|
|
20
|
+
return React.createElement(QuestionCheckboxContext.Provider, {
|
|
28
21
|
value: value
|
|
29
22
|
}, children);
|
|
30
23
|
}
|
|
31
24
|
function useQuestionCheckboxContext() {
|
|
32
|
-
|
|
25
|
+
const context = React.useContext(QuestionCheckboxContext);
|
|
33
26
|
if (context === undefined) {
|
|
34
27
|
throw new Error('useQuestionCheckboxContext must be used within a QuestionCheckboxContextProvider');
|
|
35
28
|
}
|