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