react-native-my-survey-sdk 3.0.0 → 3.0.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.
Files changed (75) hide show
  1. package/dist/components/XeboDropdownView.d.ts +10 -0
  2. package/dist/components/XeboDropdownView.d.ts.map +1 -0
  3. package/dist/components/XeboDropdownView.js +190 -0
  4. package/dist/components/XeboIntroView.d.ts +9 -0
  5. package/dist/components/XeboIntroView.d.ts.map +1 -0
  6. package/dist/components/XeboIntroView.js +54 -0
  7. package/dist/components/XeboMultiNPSView.d.ts +10 -0
  8. package/dist/components/XeboMultiNPSView.d.ts.map +1 -0
  9. package/dist/components/XeboMultiNPSView.js +170 -0
  10. package/dist/components/XeboMultiRatingView.d.ts +10 -0
  11. package/dist/components/XeboMultiRatingView.d.ts.map +1 -0
  12. package/dist/components/XeboMultiRatingView.js +154 -0
  13. package/dist/components/XeboMultipleChoiceView.d.ts +10 -0
  14. package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -0
  15. package/dist/components/XeboMultipleChoiceView.js +188 -0
  16. package/dist/components/XeboNPSView.d.ts +10 -0
  17. package/dist/components/XeboNPSView.d.ts.map +1 -0
  18. package/dist/components/XeboNPSView.js +269 -0
  19. package/dist/components/XeboRatingView.d.ts +10 -0
  20. package/dist/components/XeboRatingView.d.ts.map +1 -0
  21. package/dist/components/XeboRatingView.js +249 -0
  22. package/dist/components/XeboSingleChoiceView.d.ts +10 -0
  23. package/dist/components/XeboSingleChoiceView.d.ts.map +1 -0
  24. package/dist/components/XeboSingleChoiceView.js +172 -0
  25. package/dist/components/XeboSurveyModal.d.ts +3 -0
  26. package/dist/components/XeboSurveyModal.d.ts.map +1 -0
  27. package/dist/components/XeboSurveyModal.js +345 -0
  28. package/dist/components/XeboTextBoxView.d.ts +10 -0
  29. package/dist/components/XeboTextBoxView.d.ts.map +1 -0
  30. package/dist/components/XeboTextBoxView.js +176 -0
  31. package/dist/components/XeboThankYouView.d.ts +9 -0
  32. package/dist/components/XeboThankYouView.d.ts.map +1 -0
  33. package/dist/components/XeboThankYouView.js +115 -0
  34. package/dist/core/XeboNetworkService.d.ts +34 -0
  35. package/dist/core/XeboNetworkService.d.ts.map +1 -0
  36. package/dist/core/XeboNetworkService.js +367 -0
  37. package/dist/core/XeboOfflineQueue.d.ts +8 -0
  38. package/dist/core/XeboOfflineQueue.d.ts.map +1 -0
  39. package/dist/core/XeboOfflineQueue.js +35 -0
  40. package/dist/core/XeboSurveyManager.d.ts +59 -0
  41. package/dist/core/XeboSurveyManager.d.ts.map +1 -0
  42. package/dist/core/XeboSurveyManager.js +351 -0
  43. package/dist/index.d.ts +5 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +12 -0
  46. package/dist/models/XeboAPIModels.d.ts +82 -0
  47. package/dist/models/XeboAPIModels.d.ts.map +1 -0
  48. package/dist/models/XeboAPIModels.js +4 -0
  49. package/dist/models/XeboModels.d.ts +141 -0
  50. package/dist/models/XeboModels.d.ts.map +1 -0
  51. package/dist/models/XeboModels.js +17 -0
  52. package/dist/theme/XeboTheme.d.ts +11 -0
  53. package/dist/theme/XeboTheme.d.ts.map +1 -0
  54. package/dist/theme/XeboTheme.js +25 -0
  55. package/package.json +10 -3
  56. package/babel.config.js +0 -4
  57. package/src/components/XeboDropdownView.tsx +0 -197
  58. package/src/components/XeboIntroView.tsx +0 -68
  59. package/src/components/XeboMultiNPSView.tsx +0 -166
  60. package/src/components/XeboMultiRatingView.tsx +0 -165
  61. package/src/components/XeboMultipleChoiceView.tsx +0 -183
  62. package/src/components/XeboNPSView.tsx +0 -315
  63. package/src/components/XeboRatingView.tsx +0 -267
  64. package/src/components/XeboSingleChoiceView.tsx +0 -168
  65. package/src/components/XeboSurveyModal.tsx +0 -360
  66. package/src/components/XeboTextBoxView.tsx +0 -188
  67. package/src/components/XeboThankYouView.tsx +0 -100
  68. package/src/core/XeboNetworkService.ts +0 -476
  69. package/src/core/XeboOfflineQueue.ts +0 -33
  70. package/src/core/XeboSurveyManager.ts +0 -422
  71. package/src/index.ts +0 -23
  72. package/src/models/XeboAPIModels.ts +0 -80
  73. package/src/models/XeboModels.ts +0 -169
  74. package/src/theme/XeboTheme.ts +0 -33
  75. package/tsconfig.json +0 -17
@@ -0,0 +1,249 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.XeboRatingView = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const react_native_1 = require("react-native");
39
+ const XeboTheme_1 = require("../theme/XeboTheme");
40
+ // ─── Icon renderers per style ─────────────────────────────────────────────────
41
+ const FLAT_EMOJI_CONFIGS = [
42
+ { bg: '#E63946', mouth: 'frown' },
43
+ { bg: '#F4845F', mouth: 'frown' },
44
+ { bg: '#F7C948', mouth: 'neutral' },
45
+ { bg: '#8AC926', mouth: 'smile' },
46
+ { bg: '#21B573', mouth: 'bigSmile' },
47
+ ];
48
+ function FlatEmoji({ index, selected }) {
49
+ const conf = FLAT_EMOJI_CONFIGS[Math.min(index, FLAT_EMOJI_CONFIGS.length - 1)];
50
+ const size = 44;
51
+ const eyeSize = 5;
52
+ const mouthW = 18;
53
+ const mouthH = 9;
54
+ return (<react_native_1.View style={{
55
+ width: size,
56
+ height: size,
57
+ borderRadius: size / 2,
58
+ backgroundColor: conf.bg,
59
+ opacity: selected ? 1 : 0.38,
60
+ alignItems: 'center',
61
+ justifyContent: 'center',
62
+ }}>
63
+ {/* Eyes */}
64
+ <react_native_1.View style={{ flexDirection: 'row', gap: 9, marginBottom: 6 }}>
65
+ <react_native_1.View style={{ width: eyeSize, height: eyeSize, borderRadius: eyeSize / 2, backgroundColor: '#fff' }}/>
66
+ <react_native_1.View style={{ width: eyeSize, height: eyeSize, borderRadius: eyeSize / 2, backgroundColor: '#fff' }}/>
67
+ </react_native_1.View>
68
+ {/* Mouth */}
69
+ {conf.mouth === 'neutral' ? (<react_native_1.View style={{ width: mouthW, height: 2.5, borderRadius: 2, backgroundColor: '#fff' }}/>) : conf.mouth === 'frown' ? (
70
+ // Top half of a ring = arch = frown
71
+ <react_native_1.View style={{ width: mouthW, height: mouthH, overflow: 'hidden' }}>
72
+ <react_native_1.View style={{ width: mouthW, height: mouthW, borderRadius: mouthW / 2, borderWidth: 2.5, borderColor: '#fff' }}/>
73
+ </react_native_1.View>) : conf.mouth === 'smile' ? (
74
+ // Bottom half of a ring = U = smile
75
+ <react_native_1.View style={{ width: mouthW, height: mouthH, overflow: 'hidden' }}>
76
+ <react_native_1.View style={{ width: mouthW, height: mouthW, borderRadius: mouthW / 2, borderWidth: 2.5, borderColor: '#fff', marginTop: -mouthH }}/>
77
+ </react_native_1.View>) : (
78
+ // bigSmile: wider U
79
+ <react_native_1.View style={{ width: 22, height: 11, overflow: 'hidden' }}>
80
+ <react_native_1.View style={{ width: 22, height: 22, borderRadius: 11, borderWidth: 3, borderColor: '#fff', marginTop: -11 }}/>
81
+ </react_native_1.View>)}
82
+ </react_native_1.View>);
83
+ }
84
+ function RatingIcon({ style, index, selected, filled, color, }) {
85
+ const activeColor = color || '#F59E0B';
86
+ const inactive = '#E5E7EB';
87
+ switch (style) {
88
+ case 'heart':
89
+ return (<react_native_1.Text style={{ fontSize: 34, color: filled ? activeColor : inactive }}>
90
+ {filled ? '♥' : '♡'}
91
+ </react_native_1.Text>);
92
+ case 'circle':
93
+ return (<react_native_1.View style={{
94
+ width: 38,
95
+ height: 38,
96
+ borderRadius: 19,
97
+ backgroundColor: filled ? activeColor : inactive,
98
+ borderWidth: filled ? 0 : 1,
99
+ borderColor: '#D1D5DB',
100
+ }}/>);
101
+ case 'tile':
102
+ return (<react_native_1.View style={{
103
+ width: 42,
104
+ height: 42,
105
+ borderRadius: 6,
106
+ backgroundColor: filled ? activeColor : inactive,
107
+ alignItems: 'center',
108
+ justifyContent: 'center',
109
+ }}>
110
+ <react_native_1.Text style={{ fontSize: 14, fontWeight: '700', color: filled ? '#FFF' : '#6B7280' }}>
111
+ {index + 1}
112
+ </react_native_1.Text>
113
+ </react_native_1.View>);
114
+ case 'emoji':
115
+ case 'flat_emoji':
116
+ case 'flatEmoji':
117
+ return <FlatEmoji index={index} selected={selected}/>;
118
+ case 'star':
119
+ default:
120
+ return (<react_native_1.Text style={{ fontSize: 34, color: filled ? activeColor : inactive }}>
121
+ {filled ? '★' : '☆'}
122
+ </react_native_1.Text>);
123
+ }
124
+ }
125
+ const XeboRatingView = ({ question, isLastQuestion, onAnswer }) => {
126
+ var _a, _b, _c, _d;
127
+ const theme = (0, XeboTheme_1.getTheme)();
128
+ const ratingStyle = (_a = question.ratingStyle) !== null && _a !== void 0 ? _a : 'star';
129
+ const ratingColor = (_b = question.ratingColor) !== null && _b !== void 0 ? _b : theme.primaryColor;
130
+ const totalSteps = (_d = (_c = question.columns) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 5;
131
+ console.log('[XeboRatingView] question:', JSON.stringify(question, null, 2));
132
+ const [selected, setSelected] = (0, react_1.useState)(null);
133
+ const [followUpText, setFollowUpText] = (0, react_1.useState)('');
134
+ const [error, setError] = (0, react_1.useState)('');
135
+ const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
136
+ const shake = () => {
137
+ react_native_1.Animated.sequence([
138
+ react_native_1.Animated.timing(shakeAnim, { toValue: 8, duration: 60, useNativeDriver: true }),
139
+ react_native_1.Animated.timing(shakeAnim, { toValue: -8, duration: 60, useNativeDriver: true }),
140
+ react_native_1.Animated.timing(shakeAnim, { toValue: 6, duration: 60, useNativeDriver: true }),
141
+ react_native_1.Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
142
+ ]).start();
143
+ };
144
+ // Star and heart fill cumulatively; others highlight only the selected item
145
+ const isCumulative = ratingStyle === 'star' || ratingStyle === 'heart';
146
+ const handleSelect = (index) => {
147
+ setSelected(index);
148
+ setError('');
149
+ setFollowUpText('');
150
+ };
151
+ const handleNext = () => {
152
+ var _a, _b, _c, _d, _e, _f;
153
+ if (question.isRequired && selected === null) {
154
+ setError('Please select a rating.');
155
+ shake();
156
+ return;
157
+ }
158
+ react_native_1.Keyboard.dismiss();
159
+ const idx = selected !== null && selected !== void 0 ? selected : 0;
160
+ const colId = (_c = (_b = (_a = question.columns) === null || _a === void 0 ? void 0 : _a[idx]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : idx.toString();
161
+ const rowId = (_f = (_e = (_d = question.options) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : 'rating';
162
+ onAnswer({
163
+ questionId: question.id,
164
+ value: [{ rowId, colId, text: followUpText || undefined }],
165
+ });
166
+ };
167
+ return (
168
+ // Outer view fills modal content area; button pinned at bottom outside ScrollView
169
+ <react_native_1.View style={styles.outer}>
170
+ <react_native_1.ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled">
171
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
172
+ {question.title}
173
+ </react_native_1.Text>
174
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
175
+ {question.subtitle}
176
+ </react_native_1.Text>)}
177
+
178
+ {/* Rating icons row */}
179
+ <react_native_1.View style={styles.iconsRow}>
180
+ {Array.from({ length: totalSteps }, (_, i) => {
181
+ const isFilled = isCumulative ? selected !== null && i <= selected : i === selected;
182
+ return (<react_native_1.TouchableOpacity key={i} onPress={() => handleSelect(i)} style={styles.iconButton} activeOpacity={0.7}>
183
+ <RatingIcon style={ratingStyle} index={i} selected={i === selected} filled={isFilled} color={ratingColor}/>
184
+ </react_native_1.TouchableOpacity>);
185
+ })}
186
+ </react_native_1.View>
187
+
188
+ {/* Column labels */}
189
+ {question.showColLabels && question.columns && (<react_native_1.View style={styles.colLabels}>
190
+ {question.columns.map((col) => (<react_native_1.Text key={col.id} style={[styles.colLabel, { color: theme.textColor, fontFamily: theme.fontFamily }]} numberOfLines={1}>
191
+ {col.text}
192
+ </react_native_1.Text>))}
193
+ </react_native_1.View>)}
194
+
195
+ {/* Follow-up after rating */}
196
+ {selected !== null && !!question.followUpQuestion && (<react_native_1.View style={[styles.followUpCard, { borderRadius: theme.cornerRadius }]}>
197
+ <react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
198
+ {question.followUpQuestion}
199
+ </react_native_1.Text>
200
+ <react_native_1.TextInput style={[styles.followUpInput, { borderColor: '#E5E7EB', color: theme.textColor, borderRadius: theme.cornerRadius }]} placeholder="Your comment..." placeholderTextColor="#9CA3AF" value={followUpText} onChangeText={setFollowUpText} multiline numberOfLines={3} textAlignVertical="top"/>
201
+ </react_native_1.View>)}
202
+ </react_native_1.ScrollView>
203
+
204
+ {/* Error + button always visible at bottom, outside scroll */}
205
+ {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
206
+ <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
207
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius, opacity: selected === null ? 0.4 : 1 }]} onPress={handleNext} disabled={selected === null} activeOpacity={0.8}>
208
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
209
+ {isLastQuestion ? 'Submit' : 'Next'}
210
+ </react_native_1.Text>
211
+ </react_native_1.TouchableOpacity>
212
+ </react_native_1.Animated.View>
213
+ </react_native_1.View>);
214
+ };
215
+ exports.XeboRatingView = XeboRatingView;
216
+ const styles = react_native_1.StyleSheet.create({
217
+ outer: {
218
+ paddingHorizontal: 20,
219
+ paddingBottom: 24,
220
+ },
221
+ scroll: { maxHeight: 320 },
222
+ scrollContent: { paddingTop: 16, paddingBottom: 8 },
223
+ title: { fontSize: 18, fontWeight: '700', marginBottom: 16 },
224
+ subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
225
+ iconsRow: { flexDirection: 'row', marginTop: 4, marginBottom: 20, flexWrap: 'nowrap', justifyContent: 'space-between' },
226
+ iconButton: { alignItems: 'center', justifyContent: 'center' },
227
+ colLabels: {
228
+ flexDirection: 'row',
229
+ justifyContent: 'space-between',
230
+ marginBottom: 16,
231
+ },
232
+ colLabel: { fontSize: 11, opacity: 0.6, textAlign: 'center', flex: 1 },
233
+ followUpCard: {
234
+ borderWidth: 1.5,
235
+ borderColor: '#E5E7EB',
236
+ padding: 14,
237
+ marginBottom: 16,
238
+ },
239
+ followUpTitle: { fontSize: 15, fontWeight: '600', marginBottom: 10 },
240
+ followUpInput: {
241
+ borderWidth: 1.5,
242
+ padding: 10,
243
+ fontSize: 14,
244
+ minHeight: 80,
245
+ },
246
+ errorText: { color: '#EF4444', fontSize: 13, marginBottom: 8 },
247
+ button: { paddingVertical: 14, alignItems: 'center', marginTop: 8 },
248
+ buttonText: { color: '#FFFFFF', fontSize: 16, fontWeight: '600' },
249
+ });
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { XeboQuestion, XeboAnswer } from '../models/XeboModels';
3
+ interface Props {
4
+ question: XeboQuestion;
5
+ isLastQuestion: boolean;
6
+ onAnswer: (answer: XeboAnswer) => void;
7
+ }
8
+ export declare const XeboSingleChoiceView: React.FC<Props>;
9
+ export {};
10
+ //# sourceMappingURL=XeboSingleChoiceView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboSingleChoiceView.d.ts","sourceRoot":"","sources":["../../src/components/XeboSingleChoiceView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAc,MAAM,sBAAsB,CAAC;AAG5E,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAsFhD,CAAC"}
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.XeboSingleChoiceView = void 0;
37
+ const react_1 = __importStar(require("react"));
38
+ const react_native_1 = require("react-native");
39
+ const XeboTheme_1 = require("../theme/XeboTheme");
40
+ const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
41
+ var _a;
42
+ const theme = (0, XeboTheme_1.getTheme)();
43
+ const [selectedId, setSelectedId] = (0, react_1.useState)(null);
44
+ const [error, setError] = (0, react_1.useState)('');
45
+ const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
46
+ const shake = () => {
47
+ react_native_1.Animated.sequence([
48
+ react_native_1.Animated.timing(shakeAnim, { toValue: 8, duration: 60, useNativeDriver: true }),
49
+ react_native_1.Animated.timing(shakeAnim, { toValue: -8, duration: 60, useNativeDriver: true }),
50
+ react_native_1.Animated.timing(shakeAnim, { toValue: 6, duration: 60, useNativeDriver: true }),
51
+ react_native_1.Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
52
+ ]).start();
53
+ };
54
+ const handleSelect = (choice) => {
55
+ setSelectedId(choice.id);
56
+ setError('');
57
+ };
58
+ const handleNext = () => {
59
+ var _a, _b;
60
+ if (question.isRequired && !selectedId) {
61
+ setError('Please select an option.');
62
+ shake();
63
+ return;
64
+ }
65
+ if (!selectedId) {
66
+ onAnswer({ questionId: question.id, value: [] });
67
+ return;
68
+ }
69
+ onAnswer({
70
+ questionId: question.id,
71
+ value: [{ rowId: selectedId, text: (_b = (_a = question.options) === null || _a === void 0 ? void 0 : _a.find(o => o.id === selectedId)) === null || _b === void 0 ? void 0 : _b.text }],
72
+ });
73
+ };
74
+ return (<react_native_1.View style={styles.container}>
75
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
76
+ {question.title}
77
+ </react_native_1.Text>
78
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
79
+ {question.subtitle}
80
+ </react_native_1.Text>)}
81
+
82
+ <react_native_1.ScrollView style={styles.optionsList} showsVerticalScrollIndicator={false}>
83
+ {((_a = question.options) !== null && _a !== void 0 ? _a : []).map(choice => {
84
+ const selected = selectedId === choice.id;
85
+ return (<react_native_1.TouchableOpacity key={choice.id} style={[
86
+ styles.optionRow,
87
+ { borderColor: selected ? theme.primaryColor : '#E5E7EB' },
88
+ ]} onPress={() => handleSelect(choice)} activeOpacity={0.7}>
89
+ <react_native_1.View style={[styles.radio, { borderColor: selected ? theme.primaryColor : '#9CA3AF' }]}>
90
+ {selected && <react_native_1.View style={[styles.radioDot, { backgroundColor: theme.primaryColor }]}/>}
91
+ </react_native_1.View>
92
+ <react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
93
+ {choice.text}
94
+ </react_native_1.Text>
95
+ </react_native_1.TouchableOpacity>);
96
+ })}
97
+ </react_native_1.ScrollView>
98
+
99
+ {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
100
+
101
+ <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
102
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
103
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
104
+ {isLastQuestion ? 'Submit' : 'Next'}
105
+ </react_native_1.Text>
106
+ </react_native_1.TouchableOpacity>
107
+ </react_native_1.Animated.View>
108
+ </react_native_1.View>);
109
+ };
110
+ exports.XeboSingleChoiceView = XeboSingleChoiceView;
111
+ const styles = react_native_1.StyleSheet.create({
112
+ container: {
113
+ paddingHorizontal: 20,
114
+ paddingTop: 16,
115
+ paddingBottom: 24,
116
+ },
117
+ title: {
118
+ fontSize: 18,
119
+ fontWeight: '700',
120
+ marginBottom: 16,
121
+ },
122
+ subtitle: {
123
+ fontSize: 14,
124
+ opacity: 0.6,
125
+ marginBottom: 16,
126
+ },
127
+ optionsList: {
128
+ maxHeight: 280,
129
+ marginBottom: 12,
130
+ },
131
+ optionRow: {
132
+ flexDirection: 'row',
133
+ alignItems: 'center',
134
+ borderWidth: 1.5,
135
+ borderRadius: 10,
136
+ padding: 14,
137
+ marginBottom: 10,
138
+ },
139
+ radio: {
140
+ width: 20,
141
+ height: 20,
142
+ borderRadius: 10,
143
+ borderWidth: 2,
144
+ alignItems: 'center',
145
+ justifyContent: 'center',
146
+ marginRight: 12,
147
+ },
148
+ radioDot: {
149
+ width: 10,
150
+ height: 10,
151
+ borderRadius: 5,
152
+ },
153
+ optionText: {
154
+ fontSize: 15,
155
+ flex: 1,
156
+ },
157
+ errorText: {
158
+ color: '#EF4444',
159
+ fontSize: 13,
160
+ marginBottom: 8,
161
+ },
162
+ button: {
163
+ paddingVertical: 14,
164
+ alignItems: 'center',
165
+ marginTop: 4,
166
+ },
167
+ buttonText: {
168
+ color: '#FFFFFF',
169
+ fontSize: 16,
170
+ fontWeight: '600',
171
+ },
172
+ });
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const XeboSurveyModal: React.FC;
3
+ //# sourceMappingURL=XeboSurveyModal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboSurveyModal.d.ts","sourceRoot":"","sources":["../../src/components/XeboSurveyModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAqEjF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAiPnC,CAAC"}