@elice/material-survey 1.220803.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/README.md +3 -0
  2. package/cjs/components/material-survey/MaterialSurvey.d.ts +4 -0
  3. package/cjs/components/material-survey/MaterialSurvey.i18n.d.ts +16 -0
  4. package/cjs/components/material-survey/MaterialSurvey.i18n.js +37 -0
  5. package/cjs/components/material-survey/MaterialSurvey.js +109 -0
  6. package/cjs/components/material-survey/MaterialSurveyError.d.ts +3 -0
  7. package/cjs/components/material-survey/MaterialSurveyInfo.d.ts +3 -0
  8. package/cjs/components/material-survey/MaterialSurveyInfo.js +73 -0
  9. package/cjs/components/material-survey/MaterialSurveySelectMultiple.d.ts +3 -0
  10. package/cjs/components/material-survey/MaterialSurveySelectMultiple.js +184 -0
  11. package/cjs/components/material-survey/MaterialSurveySelectOne.d.ts +3 -0
  12. package/cjs/components/material-survey/MaterialSurveySelectOne.js +164 -0
  13. package/cjs/components/material-survey/MaterialSurveyShimmer.d.ts +3 -0
  14. package/cjs/components/material-survey/MaterialSurveyShimmer.js +61 -0
  15. package/cjs/components/material-survey/MaterialSurveyText.d.ts +3 -0
  16. package/cjs/components/material-survey/MaterialSurveyText.js +159 -0
  17. package/cjs/components/material-survey/SurveyResultBadge.d.ts +7 -0
  18. package/cjs/components/material-survey/SurveyResultBadge.js +32 -0
  19. package/cjs/components/material-survey/SurveySubmitStatusText.d.ts +7 -0
  20. package/cjs/components/material-survey/SurveySubmitStatusText.js +38 -0
  21. package/cjs/components/material-survey/context/MaterialSurveyContext.d.ts +31 -0
  22. package/cjs/components/material-survey/context/MaterialSurveyContext.js +134 -0
  23. package/cjs/components/material-survey/index.d.ts +3 -0
  24. package/cjs/components/material-survey-edit/MaterialSurveyEdit.d.ts +25 -0
  25. package/cjs/components/material-survey-edit/MaterialSurveyEdit.js +91 -0
  26. package/cjs/components/material-survey-edit/MaterialSurveyEditContent.d.ts +3 -0
  27. package/cjs/components/material-survey-edit/MaterialSurveyEditContent.js +235 -0
  28. package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.d.ts +3 -0
  29. package/cjs/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +132 -0
  30. package/cjs/components/material-survey-edit/context.d.ts +6 -0
  31. package/cjs/components/material-survey-edit/context.js +15 -0
  32. package/cjs/components/material-survey-edit/index.d.ts +2 -0
  33. package/cjs/components/material-survey-edit/locales.d.ts +20 -0
  34. package/cjs/components/material-survey-edit/locales.js +45 -0
  35. package/cjs/components/material-survey-edit/utils/editValue.d.ts +19 -0
  36. package/cjs/components/material-survey-edit/utils/editValue.js +46 -0
  37. package/cjs/components/material-survey-edit/utils/randomId.d.ts +4 -0
  38. package/cjs/components/material-survey-edit/utils/randomId.js +12 -0
  39. package/cjs/components/shared/StyledMarkdown.d.ts +3 -0
  40. package/cjs/components/shared/StyledMarkdown.js +14 -0
  41. package/cjs/components/shared/SurveyContentBox.d.ts +15 -0
  42. package/cjs/components/shared/SurveyContentBox.js +108 -0
  43. package/cjs/components/shared/index.d.ts +4 -0
  44. package/cjs/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
  45. package/cjs/components/shared/question-checkbox/QuestionCheckbox.js +26 -0
  46. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
  47. package/cjs/components/shared/question-checkbox/QuestionCheckboxContext.js +42 -0
  48. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
  49. package/cjs/components/shared/question-checkbox/QuestionCheckboxOption.js +226 -0
  50. package/cjs/components/shared/question-radio/QuestionRadio.d.ts +8 -0
  51. package/cjs/components/shared/question-radio/QuestionRadio.js +26 -0
  52. package/cjs/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
  53. package/cjs/components/shared/question-radio/QuestionRadioContext.js +42 -0
  54. package/cjs/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
  55. package/cjs/components/shared/question-radio/QuestionRadioOption.js +187 -0
  56. package/cjs/helpers/index.d.ts +22 -0
  57. package/cjs/helpers/index.js +26 -0
  58. package/cjs/index.d.ts +3 -0
  59. package/cjs/index.js +21 -0
  60. package/es/components/material-survey/MaterialSurvey.d.ts +4 -0
  61. package/es/components/material-survey/MaterialSurvey.i18n.d.ts +16 -0
  62. package/es/components/material-survey/MaterialSurvey.i18n.js +32 -0
  63. package/es/components/material-survey/MaterialSurvey.js +101 -0
  64. package/es/components/material-survey/MaterialSurveyError.d.ts +3 -0
  65. package/es/components/material-survey/MaterialSurveyInfo.d.ts +3 -0
  66. package/es/components/material-survey/MaterialSurveyInfo.js +67 -0
  67. package/es/components/material-survey/MaterialSurveySelectMultiple.d.ts +3 -0
  68. package/es/components/material-survey/MaterialSurveySelectMultiple.js +178 -0
  69. package/es/components/material-survey/MaterialSurveySelectOne.d.ts +3 -0
  70. package/es/components/material-survey/MaterialSurveySelectOne.js +158 -0
  71. package/es/components/material-survey/MaterialSurveyShimmer.d.ts +3 -0
  72. package/es/components/material-survey/MaterialSurveyShimmer.js +54 -0
  73. package/es/components/material-survey/MaterialSurveyText.d.ts +3 -0
  74. package/es/components/material-survey/MaterialSurveyText.js +152 -0
  75. package/es/components/material-survey/SurveyResultBadge.d.ts +7 -0
  76. package/es/components/material-survey/SurveyResultBadge.js +26 -0
  77. package/es/components/material-survey/SurveySubmitStatusText.d.ts +7 -0
  78. package/es/components/material-survey/SurveySubmitStatusText.js +32 -0
  79. package/es/components/material-survey/context/MaterialSurveyContext.d.ts +31 -0
  80. package/es/components/material-survey/context/MaterialSurveyContext.js +124 -0
  81. package/es/components/material-survey/index.d.ts +3 -0
  82. package/es/components/material-survey-edit/MaterialSurveyEdit.d.ts +25 -0
  83. package/es/components/material-survey-edit/MaterialSurveyEdit.js +86 -0
  84. package/es/components/material-survey-edit/MaterialSurveyEditContent.d.ts +3 -0
  85. package/es/components/material-survey-edit/MaterialSurveyEditContent.js +228 -0
  86. package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.d.ts +3 -0
  87. package/es/components/material-survey-edit/MaterialSurveyEditOptionSelect.js +125 -0
  88. package/es/components/material-survey-edit/context.d.ts +6 -0
  89. package/es/components/material-survey-edit/context.js +6 -0
  90. package/es/components/material-survey-edit/index.d.ts +2 -0
  91. package/es/components/material-survey-edit/locales.d.ts +20 -0
  92. package/es/components/material-survey-edit/locales.js +40 -0
  93. package/es/components/material-survey-edit/utils/editValue.d.ts +19 -0
  94. package/es/components/material-survey-edit/utils/editValue.js +41 -0
  95. package/es/components/material-survey-edit/utils/randomId.d.ts +4 -0
  96. package/es/components/material-survey-edit/utils/randomId.js +8 -0
  97. package/es/components/shared/StyledMarkdown.d.ts +3 -0
  98. package/es/components/shared/StyledMarkdown.js +8 -0
  99. package/es/components/shared/SurveyContentBox.d.ts +15 -0
  100. package/es/components/shared/SurveyContentBox.js +98 -0
  101. package/es/components/shared/index.d.ts +4 -0
  102. package/es/components/shared/question-checkbox/QuestionCheckbox.d.ts +8 -0
  103. package/es/components/shared/question-checkbox/QuestionCheckbox.js +19 -0
  104. package/es/components/shared/question-checkbox/QuestionCheckboxContext.d.ts +9 -0
  105. package/es/components/shared/question-checkbox/QuestionCheckboxContext.js +33 -0
  106. package/es/components/shared/question-checkbox/QuestionCheckboxOption.d.ts +9 -0
  107. package/es/components/shared/question-checkbox/QuestionCheckboxOption.js +219 -0
  108. package/es/components/shared/question-radio/QuestionRadio.d.ts +8 -0
  109. package/es/components/shared/question-radio/QuestionRadio.js +19 -0
  110. package/es/components/shared/question-radio/QuestionRadioContext.d.ts +9 -0
  111. package/es/components/shared/question-radio/QuestionRadioContext.js +33 -0
  112. package/es/components/shared/question-radio/QuestionRadioOption.d.ts +9 -0
  113. package/es/components/shared/question-radio/QuestionRadioOption.js +180 -0
  114. package/es/helpers/index.d.ts +22 -0
  115. package/es/helpers/index.js +21 -0
  116. package/es/index.d.ts +3 -0
  117. package/es/index.js +7 -0
  118. package/package.json +71 -0
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+ var reactIntl = require('react-intl');
8
+ var blocks = require('@elice/blocks');
9
+ var designTokens = require('@elice/design-tokens');
10
+ var styled = require('styled-components');
11
+ var MaterialSurveyContext = require('../material-survey/context/MaterialSurveyContext.js');
12
+
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
16
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
17
+
18
+ const StyledQuestionBox = styled__default["default"].div.withConfig({
19
+ componentId: "sc-h8ztvr-0"
20
+ })(["display:flex;flex-direction:column;border-radius:", ";overflow:hidden;width:100%;max-height:", ";min-height:", ";"], ({
21
+ vertical
22
+ }) => vertical ? '0' : '8px', ({
23
+ hasFooter
24
+ }) => hasFooter ? '100%' : '', ({
25
+ hasFooter
26
+ }) => hasFooter ? '' : '100%');
27
+ const StyledQuestionBoxHeader = styled__default["default"].div.withConfig({
28
+ componentId: "sc-h8ztvr-1"
29
+ })(["display:flex;justify-content:space-between;background-color:", ";padding:1rem 1.5rem;flex:none;height:3.5rem;"], designTokens.base.color.navy6);
30
+ const StyledQuestionBoxBody = styled__default["default"].div.withConfig({
31
+ componentId: "sc-h8ztvr-2"
32
+ })(["padding:1.5rem;background-color:", ";flex:auto;", "})"], designTokens.base.color.navy7, ({
33
+ hasFooter
34
+ }) => hasFooter ? 'height: 100%; overflow-y: auto;' : '');
35
+ const StyledQuestionBoxFooter = styled__default["default"].div.withConfig({
36
+ componentId: "sc-h8ztvr-3"
37
+ })(["flex:none;display:flex;justify-content:space-between;align-items:center;padding:0.75rem 1.5rem;background-color:", ";", ""], designTokens.base.color.navy6, ({
38
+ vertical
39
+ }) => {
40
+ return vertical ? `
41
+ flex-direction: column;
42
+ align-items: flex-start;
43
+ ` : '';
44
+ });
45
+ const StyledQuestionBoxFooterActions = styled__default["default"].div.withConfig({
46
+ componentId: "sc-h8ztvr-4"
47
+ })(["display:flex;> *:not(:last-child){margin-right:0.75rem;}"]);
48
+ const StyledQuestionBoxFooterStatus = styled__default["default"].div.withConfig({
49
+ componentId: "sc-h8ztvr-5"
50
+ })(["margin-left:0.75rem;", ""], ({
51
+ vertical
52
+ }) => {
53
+ return vertical ? `
54
+ margin-left: 0;
55
+ margin-top: 0.75rem;
56
+ ` : '';
57
+ });
58
+
59
+ const SurveyContentBox = _a => {
60
+ var {
61
+ children,
62
+ footerActions = [],
63
+ title,
64
+ submitResult,
65
+ submitStatus,
66
+ onNext
67
+ } = _a,
68
+ props = tslib.__rest(_a, ["children", "footerActions", "title", "submitResult", "submitStatus", "onNext"]);
69
+
70
+ const intl = reactIntl.useIntl();
71
+ const {
72
+ vertical
73
+ } = MaterialSurveyContext.useMaterialSurveyState();
74
+ const hasFooter = footerActions.length > 0;
75
+ const header = React__default["default"].createElement(StyledQuestionBoxHeader, null, React__default["default"].createElement(blocks.Text, {
76
+ bold: true,
77
+ customStyles: {
78
+ color: designTokens.base.color.navy0
79
+ }
80
+ }, title), submitResult ? submitResult : null);
81
+ const body = React__default["default"].createElement(StyledQuestionBoxBody, {
82
+ hasFooter: hasFooter
83
+ }, children);
84
+ const footer = React__default["default"].createElement(StyledQuestionBoxFooter, {
85
+ vertical: vertical
86
+ }, React__default["default"].createElement(StyledQuestionBoxFooterActions, null, footerActions.map((action, index) => React__default["default"].createElement(blocks.Button, Object.assign({
87
+ key: index,
88
+ size: "small"
89
+ }, action), action.children)), typeof onNext === 'function' ? React__default["default"].createElement(blocks.Button, {
90
+ size: "small",
91
+ border: true,
92
+ tabIndex: 0,
93
+ transparent: false,
94
+ role: "lightpurple",
95
+ onClick: onNext
96
+ }, intl.formatMessage({
97
+ id: 'materialSurvey.next'
98
+ })) : null), React__default["default"].createElement(StyledQuestionBoxFooterStatus, {
99
+ vertical: vertical
100
+ }, submitStatus));
101
+ return React__default["default"].createElement(StyledQuestionBox, Object.assign({}, props, {
102
+ vertical: vertical,
103
+ hasFooter: hasFooter
104
+ }), header, body, footerActions.length > 0 ? footer : null);
105
+ };
106
+
107
+ exports.StyledQuestionBox = StyledQuestionBox;
108
+ exports["default"] = SurveyContentBox;
@@ -0,0 +1,4 @@
1
+ export { default as QuestionRadio } from './question-radio/QuestionRadio';
2
+ export { default as QuestionRadioOption } from './question-radio/QuestionRadioOption';
3
+ export { default as QuestionCheckbox } from './question-checkbox/QuestionCheckbox';
4
+ export { default as QuestionCheckboxOption } from './question-checkbox/QuestionCheckboxOption';
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface QuestionCheckboxProps {
3
+ selectedOptions: any[];
4
+ onSelect: (index: number) => void;
5
+ disabled: boolean;
6
+ }
7
+ declare const QuestionCheckbox: React.FC<QuestionCheckboxProps>;
8
+ export default QuestionCheckbox;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var React = require('react');
5
+ var styled = require('styled-components');
6
+ var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
+
13
+ const StyledQuestionCheckbox = styled__default["default"].div.withConfig({
14
+ componentId: "sc-1ovh9lp-0"
15
+ })(["display:flex;flex-direction:column;"]);
16
+
17
+ const QuestionCheckbox = _a => {
18
+ var {
19
+ children
20
+ } = _a,
21
+ props = tslib.__rest(_a, ["children"]);
22
+
23
+ return React__default["default"].createElement(QuestionCheckboxContext.QuestionCheckboxContextProvider, Object.assign({}, props), React__default["default"].createElement(StyledQuestionCheckbox, null, children));
24
+ };
25
+
26
+ module.exports = QuestionCheckbox;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { QuestionCheckboxProps } from './QuestionCheckbox';
3
+ declare type Value = Pick<QuestionCheckboxProps, 'selectedOptions' | 'disabled' | 'onSelect'>;
4
+ interface QuestionCheckboxProviderProps extends QuestionCheckboxProps {
5
+ children: React.ReactNode;
6
+ }
7
+ declare function QuestionCheckboxContextProvider({ selectedOptions, onSelect, disabled, children, }: QuestionCheckboxProviderProps): JSX.Element;
8
+ declare function useQuestionCheckboxContext(): Value;
9
+ export { QuestionCheckboxContextProvider, useQuestionCheckboxContext };
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ const QuestionCheckboxContext = React__default["default"].createContext(undefined);
12
+ QuestionCheckboxContext.displayName = 'QuestionCheckboxContext';
13
+
14
+ function QuestionCheckboxContextProvider({
15
+ selectedOptions,
16
+ onSelect,
17
+ disabled,
18
+ children
19
+ }) {
20
+ const onSelectValue = React__default["default"].useCallback(onSelect, []);
21
+ const value = React__default["default"].useMemo(() => ({
22
+ selectedOptions,
23
+ disabled,
24
+ onSelect: onSelectValue
25
+ }), [selectedOptions, disabled, onSelectValue]);
26
+ return React__default["default"].createElement(QuestionCheckboxContext.Provider, {
27
+ value: value
28
+ }, children);
29
+ }
30
+
31
+ function useQuestionCheckboxContext() {
32
+ const context = React__default["default"].useContext(QuestionCheckboxContext);
33
+
34
+ if (context === undefined) {
35
+ throw new Error('useQuestionCheckboxContext must be used within a QuestionCheckboxContextProvider');
36
+ }
37
+
38
+ return context;
39
+ }
40
+
41
+ exports.QuestionCheckboxContextProvider = QuestionCheckboxContextProvider;
42
+ exports.useQuestionCheckboxContext = useQuestionCheckboxContext;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ declare type Status = 'correct' | 'wrong' | 'answer';
3
+ interface QuestionCheckboxOptionProps {
4
+ value: any;
5
+ status?: Status;
6
+ isAnswer?: boolean;
7
+ }
8
+ declare const QuestionCheckboxOption: React.FC<QuestionCheckboxOptionProps>;
9
+ export default QuestionCheckboxOption;
@@ -0,0 +1,226 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var designTokens = require('@elice/design-tokens');
5
+ var styled = require('styled-components');
6
+ var QuestionCheckboxContext = require('./QuestionCheckboxContext.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
+
13
+ const StyledQuestionCheckboxOption = styled__default["default"].div.withConfig({
14
+ componentId: "sc-em5vxx-0"
15
+ })(["display:flex;align-items:center;padding:1.125rem;border-radius:8px;background-color:", ";&:not(:last-of-type){margin-bottom:1rem;}&:hover,& *:hover{cursor:", ";}", ""], ({
16
+ checked,
17
+ status
18
+ }) => {
19
+ if (checked) {
20
+ return designTokens.base.color.primary1;
21
+ }
22
+
23
+ switch (status) {
24
+ case 'correct':
25
+ return designTokens.base.color.green1;
26
+
27
+ case 'wrong':
28
+ return designTokens.base.color.red1;
29
+
30
+ default:
31
+ return designTokens.base.color.navy5;
32
+ }
33
+ }, ({
34
+ disabled
35
+ }) => disabled ? 'not-allowed' : 'pointer', ({
36
+ isAnswer
37
+ }) => isAnswer ? `border: 3px solid ${designTokens.base.color.green5}` : '');
38
+ const StyledCustomCheckboxButton = styled__default["default"].span.withConfig({
39
+ componentId: "sc-em5vxx-1"
40
+ })([""]);
41
+ const StyledQuestionCheckboxInput = styled__default["default"].input.withConfig({
42
+ componentId: "sc-em5vxx-2"
43
+ })(["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:", ";", ""], ({
44
+ checked,
45
+ status
46
+ }) => {
47
+ if (checked) {
48
+ return designTokens.base.color.primary6;
49
+ }
50
+
51
+ switch (status) {
52
+ case 'correct':
53
+ return designTokens.base.color.green9;
54
+
55
+ case 'wrong':
56
+ return designTokens.base.color.red9;
57
+
58
+ default:
59
+ return 'transparent';
60
+ }
61
+ }, ({
62
+ checked,
63
+ status
64
+ }) => {
65
+ if (checked) {
66
+ return designTokens.base.color.primary6;
67
+ }
68
+
69
+ switch (status) {
70
+ case 'correct':
71
+ return designTokens.base.color.green9;
72
+
73
+ case 'wrong':
74
+ return designTokens.base.color.red9;
75
+
76
+ default:
77
+ return `1px solid ${designTokens.base.color.gray3}`;
78
+ }
79
+ }, ({
80
+ status,
81
+ checked
82
+ }) => {
83
+ if (checked) {
84
+ return `
85
+ &:after {
86
+ content: '';
87
+ position: absolute;
88
+ top: 50%;
89
+ left: 50%;
90
+ width: 5px;
91
+ height: 10px;
92
+ border: solid ${designTokens.base.color.primary1};
93
+ transform: translate(-50%, -50%) rotate(45deg);
94
+ border-width: 0 3px 3px 0;
95
+ }
96
+ `;
97
+ }
98
+
99
+ if (status) {
100
+ let bgColor;
101
+
102
+ switch (status) {
103
+ case 'correct':
104
+ bgColor = designTokens.base.color.green9;
105
+ break;
106
+
107
+ case 'wrong':
108
+ bgColor = designTokens.base.color.red9;
109
+ break;
110
+
111
+ default:
112
+ bgColor = 'transparent';
113
+ break;
114
+ }
115
+
116
+ let borderColor;
117
+
118
+ switch (status) {
119
+ case 'correct':
120
+ borderColor = designTokens.base.color.green1;
121
+ break;
122
+
123
+ case 'wrong':
124
+ borderColor = designTokens.base.color.red1;
125
+ break;
126
+
127
+ default:
128
+ borderColor = designTokens.base.color.navy5;
129
+ break;
130
+ }
131
+
132
+ return `
133
+ &:after {
134
+ content: '';
135
+ position: absolute;
136
+ top: 50%;
137
+ left: 50%;
138
+ width: 5px;
139
+ height: 10px;
140
+ border: solid ${borderColor};
141
+ transform: translate(-50%, -50%) rotate(45deg);
142
+ border-width: 0 3px 3px 0;
143
+ background-color: ${bgColor};
144
+ }
145
+ `;
146
+ }
147
+ });
148
+ const StyledLabel = styled__default["default"].label.withConfig({
149
+ componentId: "sc-em5vxx-3"
150
+ })(["word-break:break-all;margin-right:0.875rem;font-size:", ";color:", ";& p{color:", ";}"], designTokens.base.size.body3, ({
151
+ checked,
152
+ status
153
+ }) => {
154
+ if (checked) {
155
+ return designTokens.base.color.primary6;
156
+ }
157
+
158
+ switch (status) {
159
+ case 'correct':
160
+ return designTokens.base.color.green9;
161
+
162
+ case 'wrong':
163
+ return designTokens.base.color.red9;
164
+
165
+ default:
166
+ return designTokens.base.color.navy0;
167
+ }
168
+ }, ({
169
+ checked,
170
+ status
171
+ }) => {
172
+ if (checked) {
173
+ return designTokens.base.color.primary6;
174
+ }
175
+
176
+ switch (status) {
177
+ case 'correct':
178
+ return designTokens.base.color.green9;
179
+
180
+ case 'wrong':
181
+ return designTokens.base.color.red9;
182
+
183
+ default:
184
+ return designTokens.base.color.navy0;
185
+ }
186
+ });
187
+ const QuestionCheckboxOption = React__default["default"].memo(({
188
+ value,
189
+ status,
190
+ isAnswer,
191
+ children
192
+ }) => {
193
+ const {
194
+ selectedOptions,
195
+ disabled,
196
+ onSelect
197
+ } = QuestionCheckboxContext.useQuestionCheckboxContext();
198
+ const checked = selectedOptions.includes(value);
199
+ return React__default["default"].createElement(StyledQuestionCheckboxOption, {
200
+ isAnswer: isAnswer,
201
+ disabled: disabled,
202
+ checked: checked,
203
+ onClick: e => {
204
+ e.preventDefault();
205
+
206
+ if (disabled) {
207
+ return;
208
+ }
209
+
210
+ onSelect(value);
211
+ },
212
+ status: status
213
+ }, React__default["default"].createElement(StyledCustomCheckboxButton, null), React__default["default"].createElement(StyledQuestionCheckboxInput, {
214
+ id: value,
215
+ readOnly: true,
216
+ type: "checkbox",
217
+ checked: checked,
218
+ status: status
219
+ }), React__default["default"].createElement(StyledLabel, {
220
+ htmlFor: value,
221
+ checked: checked,
222
+ status: status
223
+ }, children));
224
+ });
225
+
226
+ module.exports = QuestionCheckboxOption;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ export interface QuestionRadioProps {
3
+ selectedValue: any;
4
+ onSelect: (index: number) => void;
5
+ disabled: boolean;
6
+ }
7
+ declare const QuestionRadio: React.FC<QuestionRadioProps>;
8
+ export default QuestionRadio;
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var tslib = require('tslib');
4
+ var React = require('react');
5
+ var styled = require('styled-components');
6
+ var QuestionRadioContext = require('./QuestionRadioContext.js');
7
+
8
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
+
10
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
+ var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
12
+
13
+ const StyledQuestionRadio = styled__default["default"].div.withConfig({
14
+ componentId: "sc-4da40f-0"
15
+ })(["display:flex;flex-direction:column;"]);
16
+
17
+ const QuestionRadio = _a => {
18
+ var {
19
+ children
20
+ } = _a,
21
+ props = tslib.__rest(_a, ["children"]);
22
+
23
+ return React__default["default"].createElement(QuestionRadioContext.QuestionRadioContextProvider, Object.assign({}, props), React__default["default"].createElement(StyledQuestionRadio, null, children));
24
+ };
25
+
26
+ module.exports = QuestionRadio;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import type { QuestionRadioProps } from './QuestionRadio';
3
+ declare type Value = Pick<QuestionRadioProps, 'selectedValue' | 'disabled' | 'onSelect'>;
4
+ interface QuestionRadioProviderProps extends QuestionRadioProps {
5
+ children: React.ReactNode;
6
+ }
7
+ declare function QuestionRadioContextProvider({ selectedValue, onSelect, disabled, children, }: QuestionRadioProviderProps): JSX.Element;
8
+ declare function useQuestionRadioContext(): Value;
9
+ export { QuestionRadioContextProvider, useQuestionRadioContext };
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+
7
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
+
9
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
10
+
11
+ const QuestionRadioContext = React__default["default"].createContext(undefined);
12
+ QuestionRadioContext.displayName = 'QuestionRadioContext';
13
+
14
+ function QuestionRadioContextProvider({
15
+ selectedValue,
16
+ onSelect,
17
+ disabled,
18
+ children
19
+ }) {
20
+ const onSelectValue = React__default["default"].useCallback(onSelect, []);
21
+ const value = React__default["default"].useMemo(() => ({
22
+ selectedValue,
23
+ disabled,
24
+ onSelect: onSelectValue
25
+ }), [selectedValue, disabled, onSelectValue]);
26
+ return React__default["default"].createElement(QuestionRadioContext.Provider, {
27
+ value: value
28
+ }, children);
29
+ }
30
+
31
+ function useQuestionRadioContext() {
32
+ const context = React__default["default"].useContext(QuestionRadioContext);
33
+
34
+ if (context === undefined) {
35
+ throw new Error('useQuestionRadioContext must be used within a QuestionRadioContextProvider');
36
+ }
37
+
38
+ return context;
39
+ }
40
+
41
+ exports.QuestionRadioContextProvider = QuestionRadioContextProvider;
42
+ exports.useQuestionRadioContext = useQuestionRadioContext;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ declare type Status = 'correct' | 'wrong' | 'answer';
3
+ interface QuestionRadioOptionProps {
4
+ value: any;
5
+ status?: Status;
6
+ isAnswer?: boolean;
7
+ }
8
+ declare const QuestionRadioOption: React.FC<QuestionRadioOptionProps>;
9
+ export default QuestionRadioOption;