@elice/material-survey 1.240718.0-trasncript.0 → 1.240718.0-trasncript.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/_virtual/_rollupPluginBabelHelpers.js +399 -0
- package/cjs/components/markdown-editor/index.d.ts +1 -2
- package/cjs/components/markdown-editor/index.js +19 -10
- package/cjs/components/material-survey/MaterialSurvey.js +82 -57
- package/cjs/components/material-survey/MaterialSurveyInfo.js +69 -59
- package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +131 -90
- package/cjs/components/material-survey/MaterialSurveySelectOne.js +125 -86
- package/cjs/components/material-survey/MaterialSurveyShimmer.js +47 -40
- package/cjs/components/material-survey/MaterialSurveyText.js +114 -75
- package/cjs/components/material-survey/SurveyResultBadge.js +17 -10
- package/cjs/components/material-survey/SurveySubmitStatusText.js +21 -16
- package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/cjs/components/material-survey/context/MaterialSurveyContext.js +115 -74
- package/cjs/components/material-survey/index.js +9 -0
- package/cjs/components/material-survey/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +49 -36
- package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +113 -91
- package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +100 -87
- package/cjs/components/material-survey-edit/context.js +8 -2
- package/cjs/components/material-survey-edit/index.js +7 -0
- package/cjs/components/material-survey-edit/locales/index.js +13 -0
- package/cjs/components/material-survey-edit/utils/editValue.js +17 -11
- package/cjs/components/shared/StyledMarkdown.js +5 -1
- package/cjs/components/shared/SurveyContentBox.js +85 -74
- package/cjs/components/shared/index.js +13 -0
- package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +13 -7
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +24 -17
- package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +66 -89
- package/cjs/components/shared/question-radio/QuestionRadio.js +13 -7
- package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/cjs/components/shared/question-radio/QuestionRadioContext.js +24 -17
- package/cjs/components/shared/question-radio/QuestionRadioOption.js +59 -80
- package/es/_virtual/_rollupPluginBabelHelpers.js +386 -0
- package/es/components/markdown-editor/index.d.ts +1 -2
- package/es/components/markdown-editor/index.js +15 -10
- package/es/components/material-survey/MaterialSurvey.js +77 -57
- package/es/components/material-survey/MaterialSurveyInfo.js +65 -59
- package/es/components/material-survey/MaterialSurveySelectMultiple.js +127 -90
- package/es/components/material-survey/MaterialSurveySelectOne.js +121 -86
- package/es/components/material-survey/MaterialSurveyShimmer.js +43 -40
- package/es/components/material-survey/MaterialSurveyText.js +109 -75
- package/es/components/material-survey/SurveyResultBadge.js +13 -10
- package/es/components/material-survey/SurveySubmitStatusText.js +17 -16
- package/es/components/material-survey/context/MaterialSurveyContext.d.ts +1 -1
- package/es/components/material-survey/context/MaterialSurveyContext.js +112 -75
- package/es/components/material-survey/index.js +2 -0
- package/es/components/material-survey/locales/index.js +4 -0
- package/es/components/material-survey-edit/MaterialSurveyEdit.js +45 -36
- package/es/components/material-survey-edit/MaterialSurveyEditContent.js +107 -90
- package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +96 -87
- package/es/components/material-survey-edit/context.js +4 -2
- package/es/components/material-survey-edit/index.js +1 -0
- package/es/components/material-survey-edit/locales/index.js +4 -0
- package/es/components/material-survey-edit/utils/editValue.js +17 -11
- package/es/components/shared/StyledMarkdown.js +1 -1
- package/es/components/shared/SurveyContentBox.js +81 -74
- package/es/components/shared/index.js +4 -0
- package/es/components/shared/question-checkbox/QuestionCheckbox.js +9 -7
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +1 -1
- package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +20 -17
- package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +61 -89
- package/es/components/shared/question-radio/QuestionRadio.js +9 -7
- package/es/components/shared/question-radio/QuestionRadioContext.d.ts +1 -1
- package/es/components/shared/question-radio/QuestionRadioContext.js +20 -17
- package/es/components/shared/question-radio/QuestionRadioOption.js +54 -80
- package/package.json +9 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useFormContext, useFieldArray, Controller } from 'react-hook-form';
|
|
3
3
|
import { Input, Tooltip, IconButton, Vspace, Button, Icon } from '@elice/blocks';
|
|
4
4
|
import { eilMathsignMultiplyBasic, eilMathsignAddCircle } from '@elice/icons';
|
|
@@ -7,35 +7,32 @@ import styled from 'styled-components';
|
|
|
7
7
|
import { createRandomId } from './utils/randomId.js';
|
|
8
8
|
import { useMaterialSurveyEditContext } from './context.js';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
var MIN_OPTION_INFO_COUNT = 2;
|
|
11
|
+
var MAX_OPTION_INFO_COUNT = 20;
|
|
12
|
+
var StyledWrap = styled.div.withConfig({
|
|
13
13
|
componentId: "sc-1eiyk6z-0"
|
|
14
14
|
})([""]);
|
|
15
|
-
|
|
15
|
+
var StyledInputGroup = styled.div.withConfig({
|
|
16
16
|
componentId: "sc-1eiyk6z-1"
|
|
17
17
|
})(["width:100%;.eb-input{margin-bottom:0.5rem;&:last-of-type{margin-bottom:0;}}"]);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
disabled
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
keyName: 'id',
|
|
33
|
-
shouldUnregister: true
|
|
34
|
-
});
|
|
18
|
+
var OptionSelectOne = function OptionSelectOne() {
|
|
19
|
+
var intl = useRawEliceIntl();
|
|
20
|
+
var _useMaterialSurveyEdi = useMaterialSurveyEditContext(),
|
|
21
|
+
disabled = _useMaterialSurveyEdi.disabled;
|
|
22
|
+
var _useFormContext = useFormContext(),
|
|
23
|
+
control = _useFormContext.control;
|
|
24
|
+
var _useFieldArray = useFieldArray({
|
|
25
|
+
name: 'questionInfoList.0.optionInfo',
|
|
26
|
+
keyName: 'id',
|
|
27
|
+
shouldUnregister: true
|
|
28
|
+
}),
|
|
29
|
+
optionInfoFields = _useFieldArray.fields,
|
|
30
|
+
appendOptionInfoFieldItem = _useFieldArray.append,
|
|
31
|
+
removeOptionInfoFieldItem = _useFieldArray.remove;
|
|
35
32
|
/**
|
|
36
33
|
* Append option info.
|
|
37
34
|
*/
|
|
38
|
-
|
|
35
|
+
var appendOptionInfo = function appendOptionInfo() {
|
|
39
36
|
appendOptionInfoFieldItem({
|
|
40
37
|
id: createRandomId(),
|
|
41
38
|
value: ''
|
|
@@ -44,76 +41,88 @@ const OptionSelectOne = () => {
|
|
|
44
41
|
/**
|
|
45
42
|
* Remove item from option info at index.
|
|
46
43
|
*/
|
|
47
|
-
|
|
44
|
+
var removeOptionInfo = function removeOptionInfo(index) {
|
|
48
45
|
removeOptionInfoFieldItem(index);
|
|
49
46
|
};
|
|
50
47
|
//
|
|
51
48
|
//
|
|
52
49
|
//
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
50
|
+
return jsxs(StyledWrap, {
|
|
51
|
+
children: [jsx(StyledInputGroup, {
|
|
52
|
+
children: optionInfoFields.map(function (_ref, index) {
|
|
53
|
+
var id = _ref.id;
|
|
54
|
+
return jsx(Controller, {
|
|
55
|
+
control: control,
|
|
56
|
+
name: "questionInfoList.0.optionInfo.".concat(index, ".value"),
|
|
57
|
+
rules: {
|
|
58
|
+
required: {
|
|
59
|
+
value: true,
|
|
60
|
+
message: intl.formatMessage({
|
|
61
|
+
id: 'option.common.select.errorMessage.required'
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
render: function render(_ref2) {
|
|
66
|
+
var field = _ref2.field,
|
|
67
|
+
fieldState = _ref2.fieldState;
|
|
68
|
+
var _a;
|
|
69
|
+
return jsx(Input, Object.assign({
|
|
70
|
+
size: "small",
|
|
71
|
+
width: "full",
|
|
72
|
+
placeholder: intl.formatMessage({
|
|
73
|
+
id: 'option.common.select.placeholder'
|
|
74
|
+
}),
|
|
75
|
+
suffix: jsx(Tooltip, {
|
|
76
|
+
title: optionInfoFields.length <= MIN_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
77
|
+
id: 'option.common.select.tooltip.minOptionInfoItem'
|
|
78
|
+
}) : undefined,
|
|
79
|
+
placement: "top-start",
|
|
80
|
+
children: jsx("span", {
|
|
81
|
+
children: jsx(IconButton, {
|
|
82
|
+
icon: eilMathsignMultiplyBasic,
|
|
83
|
+
role: "grey9",
|
|
84
|
+
size: "tiny",
|
|
85
|
+
border: false,
|
|
86
|
+
transparent: true,
|
|
87
|
+
disabled: optionInfoFields.length <= MIN_OPTION_INFO_COUNT || disabled,
|
|
88
|
+
onClick: function onClick() {
|
|
89
|
+
return removeOptionInfo(index);
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
}),
|
|
94
|
+
readOnly: disabled,
|
|
95
|
+
invalid: fieldState.invalid,
|
|
96
|
+
invalidText: (_a = fieldState.error) === null || _a === void 0 ? void 0 : _a.message
|
|
97
|
+
}, field));
|
|
98
|
+
}
|
|
99
|
+
}, id);
|
|
100
|
+
})
|
|
101
|
+
}), jsx(Vspace, {
|
|
102
|
+
height: 0.5
|
|
103
|
+
}), jsx(Tooltip, {
|
|
104
|
+
title: optionInfoFields.length >= MAX_OPTION_INFO_COUNT ? intl.formatMessage({
|
|
105
|
+
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
106
|
+
}) : undefined,
|
|
107
|
+
placement: "bottom",
|
|
108
|
+
children: jsx("span", {
|
|
109
|
+
children: jsx(Button, {
|
|
110
|
+
block: true,
|
|
111
|
+
size: "micro",
|
|
112
|
+
borderDashed: true,
|
|
88
113
|
transparent: true,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
id: 'option.common.select.tooltip.maxOptionInfoItem'
|
|
102
|
-
}) : undefined,
|
|
103
|
-
placement: "bottom"
|
|
104
|
-
}, React.createElement("span", null, React.createElement(Button, {
|
|
105
|
-
block: true,
|
|
106
|
-
size: "micro",
|
|
107
|
-
borderDashed: true,
|
|
108
|
-
transparent: true,
|
|
109
|
-
icon: React.createElement(Icon, {
|
|
110
|
-
icon: eilMathsignAddCircle
|
|
111
|
-
}),
|
|
112
|
-
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
113
|
-
onClick: appendOptionInfo
|
|
114
|
-
}, intl.formatMessage({
|
|
115
|
-
id: 'option.common.select.addButton'
|
|
116
|
-
})))));
|
|
114
|
+
icon: jsx(Icon, {
|
|
115
|
+
icon: eilMathsignAddCircle
|
|
116
|
+
}),
|
|
117
|
+
disabled: optionInfoFields.length >= MAX_OPTION_INFO_COUNT || disabled,
|
|
118
|
+
onClick: appendOptionInfo,
|
|
119
|
+
children: intl.formatMessage({
|
|
120
|
+
id: 'option.common.select.addButton'
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
})
|
|
124
|
+
})]
|
|
125
|
+
});
|
|
117
126
|
};
|
|
118
127
|
|
|
119
128
|
export { OptionSelectOne as default };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var MaterialSurveyEditContext = React.createContext(null);
|
|
4
|
+
var useMaterialSurveyEditContext = function useMaterialSurveyEditContext() {
|
|
5
|
+
return React.useContext(MaterialSurveyEditContext);
|
|
6
|
+
};
|
|
5
7
|
|
|
6
8
|
export { MaterialSurveyEditContext as default, useMaterialSurveyEditContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as MaterialSurveyEdit } from './MaterialSurveyEdit.js';
|
|
@@ -5,14 +5,18 @@ import { createRandomId } from './randomId.js';
|
|
|
5
5
|
*/
|
|
6
6
|
function manipulateValue(v) {
|
|
7
7
|
return Object.assign(Object.assign({}, v), {
|
|
8
|
-
questionInfoList: v.questionInfoList.map(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
questionInfoList: v.questionInfoList.map(function (questionInfo) {
|
|
9
|
+
return 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(function (option) {
|
|
13
|
+
return {
|
|
14
|
+
id: createRandomId(),
|
|
15
|
+
value: option
|
|
16
|
+
};
|
|
17
|
+
}) : []
|
|
18
|
+
});
|
|
19
|
+
})
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
@@ -20,10 +24,12 @@ function manipulateValue(v) {
|
|
|
20
24
|
*/
|
|
21
25
|
function restoreValue(v) {
|
|
22
26
|
return Object.assign(Object.assign({}, v), {
|
|
23
|
-
questionInfoList: v.questionInfoList.map(questionInfo
|
|
27
|
+
questionInfoList: v.questionInfoList.map(function (questionInfo) {
|
|
24
28
|
var _a;
|
|
25
|
-
|
|
26
|
-
optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(
|
|
29
|
+
var newQuestionInfo = Object.assign(Object.assign({}, questionInfo), {
|
|
30
|
+
optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(function (option) {
|
|
31
|
+
return option.value;
|
|
32
|
+
}) : null
|
|
27
33
|
});
|
|
28
34
|
if (!newQuestionInfo.optionInfo) {
|
|
29
35
|
delete newQuestionInfo.optionInfo;
|
|
@@ -1,96 +1,103 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Text, Button } from '@elice/blocks';
|
|
4
4
|
import { base } from '@elice/design-tokens';
|
|
5
5
|
import { useRawEliceIntl } from '@elice/intl';
|
|
6
6
|
import styled from 'styled-components';
|
|
7
7
|
import { useMaterialSurveyState } from '../material-survey/context/MaterialSurveyContext.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
var StyledQuestionBox = styled.div.withConfig({
|
|
10
10
|
componentId: "sc-h8ztvr-0"
|
|
11
|
-
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;max-height:", ";min-height:", ";"], ({
|
|
12
|
-
vertical
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
hasFooter
|
|
17
|
-
}
|
|
18
|
-
|
|
11
|
+
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;max-height:", ";min-height:", ";"], function (_ref) {
|
|
12
|
+
var vertical = _ref.vertical;
|
|
13
|
+
return vertical ? '0' : '8px';
|
|
14
|
+
}, function (_ref2) {
|
|
15
|
+
var hasFooter = _ref2.hasFooter;
|
|
16
|
+
return hasFooter ? '100%' : '';
|
|
17
|
+
}, function (_ref3) {
|
|
18
|
+
var hasFooter = _ref3.hasFooter;
|
|
19
|
+
return hasFooter ? '' : '100%';
|
|
20
|
+
});
|
|
21
|
+
var StyledQuestionBoxHeader = styled.div.withConfig({
|
|
19
22
|
componentId: "sc-h8ztvr-1"
|
|
20
23
|
})(["display:flex;justify-content:space-between;background-color:", ";padding:1rem 1.5rem;flex:none;height:3.5rem;"], base.color.navy6);
|
|
21
|
-
|
|
24
|
+
var StyledQuestionBoxBody = styled.div.withConfig({
|
|
22
25
|
componentId: "sc-h8ztvr-2"
|
|
23
|
-
})(["padding:1.5rem;background-color:", ";flex:auto;", "})"], base.color.navy7, ({
|
|
24
|
-
hasFooter
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
})(["padding:1.5rem;background-color:", ";flex:auto;", "})"], base.color.navy7, function (_ref4) {
|
|
27
|
+
var hasFooter = _ref4.hasFooter;
|
|
28
|
+
return hasFooter ? 'height: 100%; overflow-y: auto;' : '';
|
|
29
|
+
});
|
|
30
|
+
var StyledQuestionBoxFooter = styled.div.withConfig({
|
|
27
31
|
componentId: "sc-h8ztvr-3"
|
|
28
|
-
})(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], base.color.navy8, ({
|
|
29
|
-
vertical
|
|
30
|
-
|
|
31
|
-
return vertical ? `
|
|
32
|
-
flex-direction: column;
|
|
33
|
-
align-items: flex-start;
|
|
34
|
-
` : '';
|
|
32
|
+
})(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], base.color.navy8, function (_ref5) {
|
|
33
|
+
var vertical = _ref5.vertical;
|
|
34
|
+
return vertical ? "\n flex-direction: column;\n align-items: flex-start;\n " : '';
|
|
35
35
|
});
|
|
36
|
-
|
|
36
|
+
var StyledQuestionBoxFooterActions = styled.div.withConfig({
|
|
37
37
|
componentId: "sc-h8ztvr-4"
|
|
38
38
|
})(["display:flex;> *:not(:last-child){margin-right:0.75rem;}"]);
|
|
39
|
-
|
|
39
|
+
var StyledQuestionBoxFooterStatus = styled.div.withConfig({
|
|
40
40
|
componentId: "sc-h8ztvr-5"
|
|
41
|
-
})(["margin-left:0.75rem;", ""], ({
|
|
42
|
-
vertical
|
|
43
|
-
|
|
44
|
-
return vertical ? `
|
|
45
|
-
margin-left: 0;
|
|
46
|
-
margin-top: 0.75rem;
|
|
47
|
-
` : '';
|
|
41
|
+
})(["margin-left:0.75rem;", ""], function (_ref6) {
|
|
42
|
+
var vertical = _ref6.vertical;
|
|
43
|
+
return vertical ? "\n margin-left: 0;\n margin-top: 0.75rem;\n " : '';
|
|
48
44
|
});
|
|
49
|
-
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} = _a,
|
|
45
|
+
var SurveyContentBox = function SurveyContentBox(_a) {
|
|
46
|
+
var children = _a.children,
|
|
47
|
+
_a$footerActions = _a.footerActions,
|
|
48
|
+
footerActions = _a$footerActions === void 0 ? [] : _a$footerActions,
|
|
49
|
+
title = _a.title,
|
|
50
|
+
submitResult = _a.submitResult,
|
|
51
|
+
submitStatus = _a.submitStatus,
|
|
52
|
+
onNext = _a.onNext,
|
|
58
53
|
props = __rest(_a, ["children", "footerActions", "title", "submitResult", "submitStatus", "onNext"]);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
vertical
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
54
|
+
var intl = useRawEliceIntl();
|
|
55
|
+
var _useMaterialSurveySta = useMaterialSurveyState(),
|
|
56
|
+
vertical = _useMaterialSurveySta.vertical;
|
|
57
|
+
var hasFooter = footerActions.length > 0;
|
|
58
|
+
var header = jsxs(StyledQuestionBoxHeader, {
|
|
59
|
+
children: [jsx(Text, {
|
|
60
|
+
bold: true,
|
|
61
|
+
customStyles: {
|
|
62
|
+
color: base.color.navy0
|
|
63
|
+
},
|
|
64
|
+
children: title
|
|
65
|
+
}), submitResult ? submitResult : null]
|
|
66
|
+
});
|
|
67
|
+
var body = jsx(StyledQuestionBoxBody, {
|
|
68
|
+
hasFooter: hasFooter,
|
|
69
|
+
children: children
|
|
70
|
+
});
|
|
71
|
+
var footer = jsxs(StyledQuestionBoxFooter, {
|
|
72
|
+
vertical: vertical,
|
|
73
|
+
children: [jsxs(StyledQuestionBoxFooterActions, {
|
|
74
|
+
children: [footerActions.map(function (action, index) {
|
|
75
|
+
return jsx(Button, Object.assign({
|
|
76
|
+
size: "small"
|
|
77
|
+
}, action, {
|
|
78
|
+
children: action.children
|
|
79
|
+
}), index);
|
|
80
|
+
}), typeof onNext === 'function' ? jsx(Button, {
|
|
81
|
+
size: "small",
|
|
82
|
+
border: true,
|
|
83
|
+
tabIndex: 0,
|
|
84
|
+
transparent: false,
|
|
85
|
+
role: "lightpurple",
|
|
86
|
+
onClick: onNext,
|
|
87
|
+
children: intl.formatMessage({
|
|
88
|
+
id: 'materialSurvey.next'
|
|
89
|
+
})
|
|
90
|
+
}) : null]
|
|
91
|
+
}), jsx(StyledQuestionBoxFooterStatus, {
|
|
92
|
+
vertical: vertical,
|
|
93
|
+
children: submitStatus
|
|
94
|
+
})]
|
|
95
|
+
});
|
|
96
|
+
return jsxs(StyledQuestionBox, Object.assign({}, props, {
|
|
91
97
|
vertical: vertical,
|
|
92
|
-
hasFooter: hasFooter
|
|
93
|
-
|
|
98
|
+
hasFooter: hasFooter,
|
|
99
|
+
children: [header, body, footerActions.length > 0 ? footer : null]
|
|
100
|
+
}));
|
|
94
101
|
};
|
|
95
102
|
|
|
96
103
|
export { StyledQuestionBox, SurveyContentBox as default };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as QuestionRadio } from './question-radio/QuestionRadio.js';
|
|
2
|
+
export { default as QuestionRadioOption } from './question-radio/QuestionRadioOption.js';
|
|
3
|
+
export { default as QuestionCheckbox } from './question-checkbox/QuestionCheckbox.js';
|
|
4
|
+
export { default as QuestionCheckboxOption } from './question-checkbox/QuestionCheckboxOption.js';
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { QuestionCheckboxContextProvider } from './QuestionCheckboxContext.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
var StyledQuestionCheckbox = styled.div.withConfig({
|
|
7
7
|
componentId: "sc-1ovh9lp-0"
|
|
8
8
|
})(["display:flex;flex-direction:column;"]);
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
children
|
|
12
|
-
} = _a,
|
|
9
|
+
var QuestionCheckbox = function QuestionCheckbox(_a) {
|
|
10
|
+
var children = _a.children,
|
|
13
11
|
props = __rest(_a, ["children"]);
|
|
14
|
-
return
|
|
12
|
+
return jsx(QuestionCheckboxContextProvider, Object.assign({}, props, {
|
|
13
|
+
children: jsx(StyledQuestionCheckbox, {
|
|
14
|
+
children: children
|
|
15
|
+
})
|
|
16
|
+
}));
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
export { QuestionCheckbox as default };
|
|
@@ -4,6 +4,6 @@ type Value = Pick<QuestionCheckboxProps, 'selectedOptions' | 'disabled' | 'onSel
|
|
|
4
4
|
interface QuestionCheckboxProviderProps extends QuestionCheckboxProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
-
declare function QuestionCheckboxContextProvider({ selectedOptions, onSelect, disabled, children, }: QuestionCheckboxProviderProps):
|
|
7
|
+
declare function QuestionCheckboxContextProvider({ selectedOptions, onSelect, disabled, children, }: QuestionCheckboxProviderProps): JSX.Element;
|
|
8
8
|
declare function useQuestionCheckboxContext(): Value;
|
|
9
9
|
export { QuestionCheckboxContextProvider, useQuestionCheckboxContext };
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
var QuestionCheckboxContext = React.createContext(undefined);
|
|
4
5
|
QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
|
|
5
|
-
function QuestionCheckboxContextProvider({
|
|
6
|
-
selectedOptions,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}) {
|
|
6
|
+
function QuestionCheckboxContextProvider(_ref) {
|
|
7
|
+
var selectedOptions = _ref.selectedOptions,
|
|
8
|
+
onSelect = _ref.onSelect,
|
|
9
|
+
disabled = _ref.disabled,
|
|
10
|
+
children = _ref.children;
|
|
11
11
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
var onSelectValue = React.useCallback(onSelect, []);
|
|
13
|
+
var value = React.useMemo(function () {
|
|
14
|
+
return {
|
|
15
|
+
selectedOptions: selectedOptions,
|
|
16
|
+
disabled: disabled,
|
|
17
|
+
onSelect: onSelectValue
|
|
18
|
+
};
|
|
19
|
+
}, [selectedOptions, disabled, onSelectValue]);
|
|
20
|
+
return jsx(QuestionCheckboxContext.Provider, {
|
|
21
|
+
value: value,
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
21
24
|
}
|
|
22
25
|
function useQuestionCheckboxContext() {
|
|
23
|
-
|
|
26
|
+
var context = React.useContext(QuestionCheckboxContext);
|
|
24
27
|
if (context === undefined) {
|
|
25
28
|
throw new Error('useQuestionCheckboxContext must be used within a QuestionCheckboxContextProvider');
|
|
26
29
|
}
|