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