@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
|
@@ -7,18 +7,14 @@ var randomId = require('./randomId.js');
|
|
|
7
7
|
*/
|
|
8
8
|
function manipulateValue(v) {
|
|
9
9
|
return Object.assign(Object.assign({}, v), {
|
|
10
|
-
questionInfoList: v.questionInfoList.map(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
}) : []
|
|
20
|
-
});
|
|
21
|
-
})
|
|
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
|
+
}))
|
|
22
18
|
});
|
|
23
19
|
}
|
|
24
20
|
/**
|
|
@@ -26,12 +22,10 @@ function manipulateValue(v) {
|
|
|
26
22
|
*/
|
|
27
23
|
function restoreValue(v) {
|
|
28
24
|
return Object.assign(Object.assign({}, v), {
|
|
29
|
-
questionInfoList: v.questionInfoList.map(
|
|
25
|
+
questionInfoList: v.questionInfoList.map(questionInfo => {
|
|
30
26
|
var _a;
|
|
31
|
-
|
|
32
|
-
optionInfo: ((_a = questionInfo.optionInfo) === null || _a === void 0 ? void 0 : _a.length) ? questionInfo.optionInfo.map(
|
|
33
|
-
return option.value;
|
|
34
|
-
}) : 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
|
|
35
29
|
});
|
|
36
30
|
if (!newQuestionInfo.optionInfo) {
|
|
37
31
|
delete newQuestionInfo.optionInfo;
|
|
@@ -5,11 +5,7 @@ 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__*/_interopDefaultCompat(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
|
|
|
@@ -3,109 +3,98 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
7
|
var blocks = require('@elice/blocks');
|
|
8
8
|
var designTokens = require('@elice/design-tokens');
|
|
9
9
|
var intl = require('@elice/intl');
|
|
10
10
|
var styled = require('styled-components');
|
|
11
11
|
var MaterialSurveyContext = require('../material-survey/context/MaterialSurveyContext.js');
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
16
|
-
|
|
17
|
-
var StyledQuestionBox = styled__default.default.div.withConfig({
|
|
13
|
+
const StyledQuestionBox = styled.div.withConfig({
|
|
18
14
|
componentId: "sc-h8ztvr-0"
|
|
19
|
-
})(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;max-height:", ";min-height:", ";"],
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return hasFooter ? '' : '100%';
|
|
28
|
-
});
|
|
29
|
-
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({
|
|
30
23
|
componentId: "sc-h8ztvr-1"
|
|
31
24
|
})(["display:flex;justify-content:space-between;background-color:", ";padding:1rem 1.5rem;flex:none;height:3.5rem;"], designTokens.base.color.navy6);
|
|
32
|
-
|
|
25
|
+
const StyledQuestionBoxBody = styled.div.withConfig({
|
|
33
26
|
componentId: "sc-h8ztvr-2"
|
|
34
|
-
})(["padding:1.5rem;background-color:", ";flex:auto;", "})"], designTokens.base.color.navy7,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
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({
|
|
39
31
|
componentId: "sc-h8ztvr-3"
|
|
40
|
-
})(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], designTokens.base.color.navy8,
|
|
41
|
-
|
|
42
|
-
|
|
32
|
+
})(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], designTokens.base.color.navy8, ({
|
|
33
|
+
vertical
|
|
34
|
+
}) => {
|
|
35
|
+
return vertical ? `
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
align-items: flex-start;
|
|
38
|
+
` : '';
|
|
43
39
|
});
|
|
44
|
-
|
|
40
|
+
const StyledQuestionBoxFooterActions = styled.div.withConfig({
|
|
45
41
|
componentId: "sc-h8ztvr-4"
|
|
46
42
|
})(["display:flex;> *:not(:last-child){margin-right:0.75rem;}"]);
|
|
47
|
-
|
|
43
|
+
const StyledQuestionBoxFooterStatus = styled.div.withConfig({
|
|
48
44
|
componentId: "sc-h8ztvr-5"
|
|
49
|
-
})(["margin-left:0.75rem;", ""],
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
})(["margin-left:0.75rem;", ""], ({
|
|
46
|
+
vertical
|
|
47
|
+
}) => {
|
|
48
|
+
return vertical ? `
|
|
49
|
+
margin-left: 0;
|
|
50
|
+
margin-top: 0.75rem;
|
|
51
|
+
` : '';
|
|
52
52
|
});
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
const SurveyContentBox = _a => {
|
|
54
|
+
var {
|
|
55
|
+
children,
|
|
56
|
+
footerActions = [],
|
|
57
|
+
title,
|
|
58
|
+
submitResult,
|
|
59
|
+
submitStatus,
|
|
60
|
+
onNext
|
|
61
|
+
} = _a,
|
|
61
62
|
props = tslib.__rest(_a, ["children", "footerActions", "title", "submitResult", "submitStatus", "onNext"]);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
vertical
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
onClick: onNext,
|
|
95
|
-
children: intl$1.formatMessage({
|
|
96
|
-
id: 'materialSurvey.next'
|
|
97
|
-
})
|
|
98
|
-
}) : null]
|
|
99
|
-
}), jsxRuntime.jsx(StyledQuestionBoxFooterStatus, {
|
|
100
|
-
vertical: vertical,
|
|
101
|
-
children: submitStatus
|
|
102
|
-
})]
|
|
103
|
-
});
|
|
104
|
-
return jsxRuntime.jsxs(StyledQuestionBox, Object.assign({}, props, {
|
|
63
|
+
const intl$1 = intl.useRawEliceIntl();
|
|
64
|
+
const {
|
|
65
|
+
vertical
|
|
66
|
+
} = MaterialSurveyContext.useMaterialSurveyState();
|
|
67
|
+
const hasFooter = footerActions.length > 0;
|
|
68
|
+
const header = React.createElement(StyledQuestionBoxHeader, null, React.createElement(blocks.Text, {
|
|
69
|
+
bold: true,
|
|
70
|
+
customStyles: {
|
|
71
|
+
color: designTokens.base.color.navy0
|
|
72
|
+
}
|
|
73
|
+
}, title), submitResult ? submitResult : null);
|
|
74
|
+
const body = React.createElement(StyledQuestionBoxBody, {
|
|
75
|
+
hasFooter: hasFooter
|
|
76
|
+
}, children);
|
|
77
|
+
const footer = React.createElement(StyledQuestionBoxFooter, {
|
|
78
|
+
vertical: vertical
|
|
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, {
|
|
83
|
+
size: "small",
|
|
84
|
+
border: true,
|
|
85
|
+
tabIndex: 0,
|
|
86
|
+
transparent: false,
|
|
87
|
+
role: "lightpurple",
|
|
88
|
+
onClick: onNext
|
|
89
|
+
}, intl$1.formatMessage({
|
|
90
|
+
id: 'materialSurvey.next'
|
|
91
|
+
})) : null), React.createElement(StyledQuestionBoxFooterStatus, {
|
|
92
|
+
vertical: vertical
|
|
93
|
+
}, submitStatus));
|
|
94
|
+
return React.createElement(StyledQuestionBox, Object.assign({}, props, {
|
|
105
95
|
vertical: vertical,
|
|
106
|
-
hasFooter: hasFooter
|
|
107
|
-
|
|
108
|
-
}));
|
|
96
|
+
hasFooter: hasFooter
|
|
97
|
+
}), header, body, footerActions.length > 0 ? footer : null);
|
|
109
98
|
};
|
|
110
99
|
|
|
111
100
|
exports.StyledQuestionBox = StyledQuestionBox;
|
|
@@ -3,25 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
7
|
var styled = require('styled-components');
|
|
8
8
|
var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
13
|
-
|
|
14
|
-
var StyledQuestionCheckbox = styled__default.default.div.withConfig({
|
|
10
|
+
const StyledQuestionCheckbox = styled.div.withConfig({
|
|
15
11
|
componentId: "sc-1ovh9lp-0"
|
|
16
12
|
})(["display:flex;flex-direction:column;"]);
|
|
17
|
-
|
|
18
|
-
var
|
|
13
|
+
const QuestionCheckbox = _a => {
|
|
14
|
+
var {
|
|
15
|
+
children
|
|
16
|
+
} = _a,
|
|
19
17
|
props = tslib.__rest(_a, ["children"]);
|
|
20
|
-
return
|
|
21
|
-
children: jsxRuntime.jsx(StyledQuestionCheckbox, {
|
|
22
|
-
children: children
|
|
23
|
-
})
|
|
24
|
-
}));
|
|
18
|
+
return React.createElement(QuestionCheckboxContext.QuestionCheckboxContextProvider, Object.assign({}, props), React.createElement(StyledQuestionCheckbox, null, children));
|
|
25
19
|
};
|
|
26
20
|
|
|
27
21
|
exports.default = QuestionCheckbox;
|
|
@@ -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): JSX.Element;
|
|
7
|
+
declare function QuestionCheckboxContextProvider({ selectedOptions, onSelect, disabled, children, }: QuestionCheckboxProviderProps): React.JSX.Element;
|
|
8
8
|
declare function useQuestionCheckboxContext(): Value;
|
|
9
9
|
export { QuestionCheckboxContextProvider, useQuestionCheckboxContext };
|
|
@@ -1,35 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
3
|
var React = require('react');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
9
|
-
|
|
10
|
-
var QuestionCheckboxContext = React__default.default.createContext(undefined);
|
|
5
|
+
const QuestionCheckboxContext = React.createContext(undefined);
|
|
11
6
|
QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
|
|
12
|
-
function QuestionCheckboxContextProvider(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
function QuestionCheckboxContextProvider({
|
|
8
|
+
selectedOptions,
|
|
9
|
+
onSelect,
|
|
10
|
+
disabled,
|
|
11
|
+
children
|
|
12
|
+
}) {
|
|
17
13
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
value: value,
|
|
28
|
-
children: children
|
|
29
|
-
});
|
|
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, {
|
|
21
|
+
value: value
|
|
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
|
}
|
|
@@ -2,22 +2,17 @@
|
|
|
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 designTokens = require('@elice/design-tokens');
|
|
8
7
|
var styled = require('styled-components');
|
|
9
8
|
var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
14
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
15
|
-
|
|
16
|
-
var StyledQuestionCheckboxOption = styled__default.default.div.withConfig({
|
|
10
|
+
const StyledQuestionCheckboxOption = styled.div.withConfig({
|
|
17
11
|
componentId: "sc-em5vxx-0"
|
|
18
|
-
})(["display:flex;align-items:center;padding:1.125rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""],
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
})(["display:flex;align-items:center;padding:1.125rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
|
|
13
|
+
checked,
|
|
14
|
+
status
|
|
15
|
+
}) => {
|
|
21
16
|
if (checked) {
|
|
22
17
|
return designTokens.base.color.primary1;
|
|
23
18
|
}
|
|
@@ -29,21 +24,20 @@ var StyledQuestionCheckboxOption = styled__default.default.div.withConfig({
|
|
|
29
24
|
default:
|
|
30
25
|
return designTokens.base.color.navy5;
|
|
31
26
|
}
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
});
|
|
39
|
-
var StyledCustomCheckboxButton = styled__default.default.span.withConfig({
|
|
27
|
+
}, ({
|
|
28
|
+
disabled
|
|
29
|
+
}) => disabled ? 'not-allowed' : 'pointer', ({
|
|
30
|
+
isAnswer
|
|
31
|
+
}) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
|
|
32
|
+
const StyledCustomCheckboxButton = styled.span.withConfig({
|
|
40
33
|
componentId: "sc-em5vxx-1"
|
|
41
34
|
})([""]);
|
|
42
|
-
|
|
35
|
+
const StyledQuestionCheckboxInput = styled.input.withConfig({
|
|
43
36
|
componentId: "sc-em5vxx-2"
|
|
44
|
-
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;width:1.25rem;height:1.25rem;margin-right:0.875rem;background-color:", ";border:", ";", ""],
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
})(["flex:none;margin:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;position:relative;width:1.25rem;height:1.25rem;margin-right:0.875rem;background-color:", ";border:", ";", ""], ({
|
|
38
|
+
checked,
|
|
39
|
+
status
|
|
40
|
+
}) => {
|
|
47
41
|
if (checked) {
|
|
48
42
|
return designTokens.base.color.primary6;
|
|
49
43
|
}
|
|
@@ -55,9 +49,10 @@ var StyledQuestionCheckboxInput = styled__default.default.input.withConfig({
|
|
|
55
49
|
default:
|
|
56
50
|
return 'transparent';
|
|
57
51
|
}
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
}, ({
|
|
53
|
+
checked,
|
|
54
|
+
status
|
|
55
|
+
}) => {
|
|
61
56
|
if (checked) {
|
|
62
57
|
return designTokens.base.color.primary6;
|
|
63
58
|
}
|
|
@@ -67,16 +62,29 @@ var StyledQuestionCheckboxInput = styled__default.default.input.withConfig({
|
|
|
67
62
|
case 'wrong':
|
|
68
63
|
return designTokens.base.color.red9;
|
|
69
64
|
default:
|
|
70
|
-
return
|
|
65
|
+
return `1px solid ${designTokens.base.color.gray3}`;
|
|
71
66
|
}
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
}, ({
|
|
68
|
+
status,
|
|
69
|
+
checked
|
|
70
|
+
}) => {
|
|
75
71
|
if (checked) {
|
|
76
|
-
return
|
|
72
|
+
return `
|
|
73
|
+
&:after {
|
|
74
|
+
content: '';
|
|
75
|
+
position: absolute;
|
|
76
|
+
top: 50%;
|
|
77
|
+
left: 50%;
|
|
78
|
+
width: 5px;
|
|
79
|
+
height: 10px;
|
|
80
|
+
border: solid ${designTokens.base.color.primary1};
|
|
81
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
82
|
+
border-width: 0 3px 3px 0;
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
77
85
|
}
|
|
78
86
|
if (status) {
|
|
79
|
-
|
|
87
|
+
let bgColor;
|
|
80
88
|
switch (status) {
|
|
81
89
|
case 'correct':
|
|
82
90
|
bgColor = designTokens.base.color.green9;
|
|
@@ -88,7 +96,7 @@ var StyledQuestionCheckboxInput = styled__default.default.input.withConfig({
|
|
|
88
96
|
bgColor = 'transparent';
|
|
89
97
|
break;
|
|
90
98
|
}
|
|
91
|
-
|
|
99
|
+
let borderColor;
|
|
92
100
|
switch (status) {
|
|
93
101
|
case 'correct':
|
|
94
102
|
borderColor = designTokens.base.color.green1;
|
|
@@ -100,14 +108,28 @@ var StyledQuestionCheckboxInput = styled__default.default.input.withConfig({
|
|
|
100
108
|
borderColor = designTokens.base.color.navy5;
|
|
101
109
|
break;
|
|
102
110
|
}
|
|
103
|
-
return
|
|
111
|
+
return `
|
|
112
|
+
&:after {
|
|
113
|
+
content: '';
|
|
114
|
+
position: absolute;
|
|
115
|
+
top: 50%;
|
|
116
|
+
left: 50%;
|
|
117
|
+
width: 5px;
|
|
118
|
+
height: 10px;
|
|
119
|
+
border: solid ${borderColor};
|
|
120
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
121
|
+
border-width: 0 3px 3px 0;
|
|
122
|
+
background-color: ${bgColor};
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
104
125
|
}
|
|
105
126
|
});
|
|
106
|
-
|
|
127
|
+
const StyledLabel = styled.label.withConfig({
|
|
107
128
|
componentId: "sc-em5vxx-3"
|
|
108
|
-
})(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], designTokens.base.size.body3,
|
|
109
|
-
|
|
110
|
-
|
|
129
|
+
})(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], designTokens.base.size.body3, ({
|
|
130
|
+
checked,
|
|
131
|
+
status
|
|
132
|
+
}) => {
|
|
111
133
|
if (checked) {
|
|
112
134
|
return designTokens.base.color.primary6;
|
|
113
135
|
}
|
|
@@ -119,9 +141,10 @@ var StyledLabel = styled__default.default.label.withConfig({
|
|
|
119
141
|
default:
|
|
120
142
|
return designTokens.base.color.navy0;
|
|
121
143
|
}
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
|
|
144
|
+
}, ({
|
|
145
|
+
checked,
|
|
146
|
+
status
|
|
147
|
+
}) => {
|
|
125
148
|
if (checked) {
|
|
126
149
|
return designTokens.base.color.primary6;
|
|
127
150
|
}
|
|
@@ -134,41 +157,41 @@ var StyledLabel = styled__default.default.label.withConfig({
|
|
|
134
157
|
return designTokens.base.color.navy0;
|
|
135
158
|
}
|
|
136
159
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
160
|
+
const QuestionCheckboxOption = React.memo(({
|
|
161
|
+
value,
|
|
162
|
+
status,
|
|
163
|
+
isAnswer,
|
|
164
|
+
children
|
|
165
|
+
}) => {
|
|
166
|
+
const {
|
|
167
|
+
selectedOptions,
|
|
168
|
+
disabled,
|
|
169
|
+
onSelect
|
|
170
|
+
} = QuestionCheckboxContext.useQuestionCheckboxContext();
|
|
171
|
+
const checked = selectedOptions.includes(value);
|
|
172
|
+
return React.createElement(StyledQuestionCheckboxOption, {
|
|
148
173
|
isAnswer: isAnswer,
|
|
149
174
|
disabled: disabled,
|
|
150
175
|
checked: checked,
|
|
151
|
-
onClick:
|
|
176
|
+
onClick: e => {
|
|
152
177
|
e.preventDefault();
|
|
153
178
|
if (disabled) {
|
|
154
179
|
return;
|
|
155
180
|
}
|
|
156
181
|
onSelect(value);
|
|
157
182
|
},
|
|
158
|
-
status: status
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
})]
|
|
171
|
-
});
|
|
183
|
+
status: status
|
|
184
|
+
}, React.createElement(StyledCustomCheckboxButton, null), React.createElement(StyledQuestionCheckboxInput, {
|
|
185
|
+
id: value,
|
|
186
|
+
readOnly: true,
|
|
187
|
+
type: "checkbox",
|
|
188
|
+
checked: checked,
|
|
189
|
+
status: status
|
|
190
|
+
}), React.createElement(StyledLabel, {
|
|
191
|
+
htmlFor: value,
|
|
192
|
+
checked: checked,
|
|
193
|
+
status: status
|
|
194
|
+
}, children));
|
|
172
195
|
});
|
|
173
196
|
|
|
174
197
|
exports.default = QuestionCheckboxOption;
|
|
@@ -3,25 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var
|
|
6
|
+
var React = require('react');
|
|
7
7
|
var styled = require('styled-components');
|
|
8
8
|
var QuestionRadioContext = require('./QuestionRadioContext.js');
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var styled__default = /*#__PURE__*/_interopDefaultCompat(styled);
|
|
13
|
-
|
|
14
|
-
var StyledQuestionRadio = styled__default.default.div.withConfig({
|
|
10
|
+
const StyledQuestionRadio = styled.div.withConfig({
|
|
15
11
|
componentId: "sc-4da40f-0"
|
|
16
12
|
})(["display:flex;flex-direction:column;"]);
|
|
17
|
-
|
|
18
|
-
var
|
|
13
|
+
const QuestionRadio = _a => {
|
|
14
|
+
var {
|
|
15
|
+
children
|
|
16
|
+
} = _a,
|
|
19
17
|
props = tslib.__rest(_a, ["children"]);
|
|
20
|
-
return
|
|
21
|
-
children: jsxRuntime.jsx(StyledQuestionRadio, {
|
|
22
|
-
children: children
|
|
23
|
-
})
|
|
24
|
-
}));
|
|
18
|
+
return React.createElement(QuestionRadioContext.QuestionRadioContextProvider, Object.assign({}, props), React.createElement(StyledQuestionRadio, null, children));
|
|
25
19
|
};
|
|
26
20
|
|
|
27
21
|
exports.default = QuestionRadio;
|
|
@@ -4,6 +4,6 @@ type Value = Pick<QuestionRadioProps, 'selectedValue' | 'disabled' | 'onSelect'>
|
|
|
4
4
|
interface QuestionRadioProviderProps extends QuestionRadioProps {
|
|
5
5
|
children: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
-
declare function QuestionRadioContextProvider({ selectedValue, onSelect, disabled, children, }: QuestionRadioProviderProps): JSX.Element;
|
|
7
|
+
declare function QuestionRadioContextProvider({ selectedValue, onSelect, disabled, children, }: QuestionRadioProviderProps): React.JSX.Element;
|
|
8
8
|
declare function useQuestionRadioContext(): Value;
|
|
9
9
|
export { QuestionRadioContextProvider, useQuestionRadioContext };
|