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
@@ -1,267 +0,0 @@
1
- import React, { useRef, useState } from 'react';
2
- import {
3
- View,
4
- Text,
5
- TouchableOpacity,
6
- StyleSheet,
7
- ScrollView,
8
- Animated,
9
- TextInput,
10
- Keyboard,
11
- } from 'react-native';
12
- import { XeboQuestion, XeboAnswer } from '../models/XeboModels';
13
- import { getTheme } from '../theme/XeboTheme';
14
-
15
- interface Props {
16
- question: XeboQuestion;
17
- isLastQuestion: boolean;
18
- onAnswer: (answer: XeboAnswer) => void;
19
- }
20
-
21
- // ─── Icon renderers per style ─────────────────────────────────────────────────
22
-
23
- const EMOJI_MAP = ['😡', '😕', '😐', '🙂', '😄'];
24
-
25
- function RatingIcon({
26
- style,
27
- index,
28
- selected,
29
- filled,
30
- color,
31
- }: {
32
- style: string;
33
- index: number;
34
- selected: boolean;
35
- filled: boolean;
36
- color: string;
37
- }) {
38
- const activeColor = color || '#F59E0B';
39
- const inactive = '#E5E7EB';
40
-
41
- switch (style) {
42
- case 'heart':
43
- return (
44
- <Text style={{ fontSize: 34, color: filled ? activeColor : inactive }}>
45
- {filled ? '♥' : '♡'}
46
- </Text>
47
- );
48
- case 'circle':
49
- return (
50
- <View
51
- style={{
52
- width: 38,
53
- height: 38,
54
- borderRadius: 19,
55
- backgroundColor: filled ? activeColor : inactive,
56
- borderWidth: filled ? 0 : 1,
57
- borderColor: '#D1D5DB',
58
- }}
59
- />
60
- );
61
- case 'tile':
62
- return (
63
- <View
64
- style={{
65
- width: 42,
66
- height: 42,
67
- borderRadius: 6,
68
- backgroundColor: filled ? activeColor : inactive,
69
- alignItems: 'center',
70
- justifyContent: 'center',
71
- }}
72
- >
73
- <Text style={{ fontSize: 14, fontWeight: '700', color: filled ? '#FFF' : '#6B7280' }}>
74
- {index + 1}
75
- </Text>
76
- </View>
77
- );
78
- case 'emoji':
79
- return (
80
- <Text style={{ fontSize: 34, opacity: selected ? 1 : 0.35 }}>
81
- {EMOJI_MAP[Math.min(index, EMOJI_MAP.length - 1)]}
82
- </Text>
83
- );
84
- case 'star':
85
- default:
86
- return (
87
- <Text style={{ fontSize: 34, color: filled ? activeColor : inactive }}>
88
- {filled ? '★' : '☆'}
89
- </Text>
90
- );
91
- }
92
- }
93
-
94
- export const XeboRatingView: React.FC<Props> = ({ question, isLastQuestion, onAnswer }) => {
95
- const theme = getTheme();
96
- const ratingStyle = question.ratingStyle ?? 'star';
97
- const ratingColor = question.ratingColor ?? theme.primaryColor;
98
- const totalSteps = question.columns?.length ?? 5;
99
-
100
- const [selected, setSelected] = useState<number | null>(null);
101
- const [followUpText, setFollowUpText] = useState('');
102
- const [error, setError] = useState('');
103
- const shakeAnim = useRef(new Animated.Value(0)).current;
104
-
105
- const shake = () => {
106
- Animated.sequence([
107
- Animated.timing(shakeAnim, { toValue: 8, duration: 60, useNativeDriver: true }),
108
- Animated.timing(shakeAnim, { toValue: -8, duration: 60, useNativeDriver: true }),
109
- Animated.timing(shakeAnim, { toValue: 6, duration: 60, useNativeDriver: true }),
110
- Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
111
- ]).start();
112
- };
113
-
114
- // Star and heart fill cumulatively; others highlight only the selected item
115
- const isCumulative = ratingStyle === 'star' || ratingStyle === 'heart';
116
-
117
- const handleSelect = (index: number) => {
118
- setSelected(index);
119
- setError('');
120
- setFollowUpText('');
121
- };
122
-
123
- const handleNext = () => {
124
- if (question.isRequired && selected === null) {
125
- setError('Please select a rating.');
126
- shake();
127
- return;
128
- }
129
- Keyboard.dismiss();
130
- const idx = selected ?? 0;
131
- const colId = question.columns?.[idx]?.id ?? idx.toString();
132
- const rowId = question.options?.[0]?.id ?? 'rating';
133
-
134
- onAnswer({
135
- questionId: question.id,
136
- value: [{ rowId, colId, text: followUpText || undefined }],
137
- });
138
- };
139
-
140
- return (
141
- // Outer view fills modal content area; button pinned at bottom outside ScrollView
142
- <View style={styles.outer}>
143
- <ScrollView
144
- style={styles.scroll}
145
- contentContainerStyle={styles.scrollContent}
146
- showsVerticalScrollIndicator={false}
147
- keyboardShouldPersistTaps="handled"
148
- >
149
- <Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
150
- {question.title}
151
- </Text>
152
- {!!question.subtitle && (
153
- <Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
154
- {question.subtitle}
155
- </Text>
156
- )}
157
-
158
- {/* Rating icons row */}
159
- <View style={styles.iconsRow}>
160
- {Array.from({ length: totalSteps }, (_, i) => {
161
- const isFilled = isCumulative ? selected !== null && i <= selected : i === selected;
162
- return (
163
- <TouchableOpacity
164
- key={i}
165
- onPress={() => handleSelect(i)}
166
- style={styles.iconButton}
167
- activeOpacity={0.7}
168
- >
169
- <RatingIcon
170
- style={ratingStyle}
171
- index={i}
172
- selected={i === selected}
173
- filled={isFilled}
174
- color={ratingColor}
175
- />
176
- </TouchableOpacity>
177
- );
178
- })}
179
- </View>
180
-
181
- {/* Column labels */}
182
- {question.showColLabels && question.columns && (
183
- <View style={styles.colLabels}>
184
- {question.columns.map((col) => (
185
- <Text
186
- key={col.id}
187
- style={[styles.colLabel, { color: theme.textColor, fontFamily: theme.fontFamily }]}
188
- numberOfLines={1}
189
- >
190
- {col.text}
191
- </Text>
192
- ))}
193
- </View>
194
- )}
195
-
196
- {/* Follow-up after rating */}
197
- {selected !== null && !!question.followUpQuestion && (
198
- <View style={[styles.followUpCard, { borderRadius: theme.cornerRadius }]}>
199
- <Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
200
- {question.followUpQuestion}
201
- </Text>
202
- <TextInput
203
- style={[styles.followUpInput, { borderColor: '#E5E7EB', color: theme.textColor, borderRadius: theme.cornerRadius }]}
204
- placeholder="Your comment..."
205
- placeholderTextColor="#9CA3AF"
206
- value={followUpText}
207
- onChangeText={setFollowUpText}
208
- multiline
209
- numberOfLines={3}
210
- textAlignVertical="top"
211
- />
212
- </View>
213
- )}
214
- </ScrollView>
215
-
216
- {/* Error + button always visible at bottom, outside scroll */}
217
- {!!error && <Text style={styles.errorText}>{error}</Text>}
218
- <Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
219
- <TouchableOpacity
220
- style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius, opacity: selected === null ? 0.4 : 1 }]}
221
- onPress={handleNext}
222
- disabled={selected === null}
223
- activeOpacity={0.8}
224
- >
225
- <Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
226
- {isLastQuestion ? 'Submit' : 'Next'}
227
- </Text>
228
- </TouchableOpacity>
229
- </Animated.View>
230
- </View>
231
- );
232
- };
233
-
234
- const styles = StyleSheet.create({
235
- outer: {
236
- paddingHorizontal: 20,
237
- paddingBottom: 24,
238
- },
239
- scroll: { maxHeight: 320 },
240
- scrollContent: { paddingTop: 16, paddingBottom: 8 },
241
- title: { fontSize: 18, fontWeight: '700', marginBottom: 16 },
242
- subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
243
- iconsRow: { flexDirection: 'row', marginTop: 4, marginBottom: 20, flexWrap: 'nowrap', justifyContent: 'space-between' },
244
- iconButton: { alignItems: 'center', justifyContent: 'center' },
245
- colLabels: {
246
- flexDirection: 'row',
247
- justifyContent: 'space-between',
248
- marginBottom: 16,
249
- },
250
- colLabel: { fontSize: 11, opacity: 0.6, textAlign: 'center', flex: 1 },
251
- followUpCard: {
252
- borderWidth: 1.5,
253
- borderColor: '#E5E7EB',
254
- padding: 14,
255
- marginBottom: 16,
256
- },
257
- followUpTitle: { fontSize: 15, fontWeight: '600', marginBottom: 10 },
258
- followUpInput: {
259
- borderWidth: 1.5,
260
- padding: 10,
261
- fontSize: 14,
262
- minHeight: 80,
263
- },
264
- errorText: { color: '#EF4444', fontSize: 13, marginBottom: 8 },
265
- button: { paddingVertical: 14, alignItems: 'center', marginTop: 8 },
266
- buttonText: { color: '#FFFFFF', fontSize: 16, fontWeight: '600' },
267
- });
@@ -1,168 +0,0 @@
1
- import React, { useRef, useState } from 'react';
2
- import {
3
- View,
4
- Text,
5
- TouchableOpacity,
6
- StyleSheet,
7
- ScrollView,
8
- Animated,
9
- } from 'react-native';
10
- import { XeboQuestion, XeboAnswer, XeboChoice } from '../models/XeboModels';
11
- import { getTheme } from '../theme/XeboTheme';
12
-
13
- interface Props {
14
- question: XeboQuestion;
15
- isLastQuestion: boolean;
16
- onAnswer: (answer: XeboAnswer) => void;
17
- }
18
-
19
- export const XeboSingleChoiceView: React.FC<Props> = ({ question, isLastQuestion, onAnswer }) => {
20
- const theme = getTheme();
21
- const [selectedId, setSelectedId] = useState<string | null>(null);
22
- const [error, setError] = useState('');
23
- const shakeAnim = useRef(new Animated.Value(0)).current;
24
-
25
- const shake = () => {
26
- Animated.sequence([
27
- Animated.timing(shakeAnim, { toValue: 8, duration: 60, useNativeDriver: true }),
28
- Animated.timing(shakeAnim, { toValue: -8, duration: 60, useNativeDriver: true }),
29
- Animated.timing(shakeAnim, { toValue: 6, duration: 60, useNativeDriver: true }),
30
- Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
31
- ]).start();
32
- };
33
-
34
- const handleSelect = (choice: XeboChoice) => {
35
- setSelectedId(choice.id);
36
- setError('');
37
- };
38
-
39
- const handleNext = () => {
40
- if (question.isRequired && !selectedId) {
41
- setError('Please select an option.');
42
- shake();
43
- return;
44
- }
45
- if (!selectedId) {
46
- onAnswer({ questionId: question.id, value: [] });
47
- return;
48
- }
49
- onAnswer({
50
- questionId: question.id,
51
- value: [{ rowId: selectedId, text: question.options?.find(o => o.id === selectedId)?.text }],
52
- });
53
- };
54
-
55
- return (
56
- <View style={styles.container}>
57
- <Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
58
- {question.title}
59
- </Text>
60
- {!!question.subtitle && (
61
- <Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
62
- {question.subtitle}
63
- </Text>
64
- )}
65
-
66
- <ScrollView style={styles.optionsList} showsVerticalScrollIndicator={false}>
67
- {(question.options ?? []).map(choice => {
68
- const selected = selectedId === choice.id;
69
- return (
70
- <TouchableOpacity
71
- key={choice.id}
72
- style={[
73
- styles.optionRow,
74
- { borderColor: selected ? theme.primaryColor : '#E5E7EB' },
75
- ]}
76
- onPress={() => handleSelect(choice)}
77
- activeOpacity={0.7}
78
- >
79
- <View style={[styles.radio, { borderColor: selected ? theme.primaryColor : '#9CA3AF' }]}>
80
- {selected && <View style={[styles.radioDot, { backgroundColor: theme.primaryColor }]} />}
81
- </View>
82
- <Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
83
- {choice.text}
84
- </Text>
85
- </TouchableOpacity>
86
- );
87
- })}
88
- </ScrollView>
89
-
90
- {!!error && <Text style={styles.errorText}>{error}</Text>}
91
-
92
- <Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
93
- <TouchableOpacity
94
- style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]}
95
- onPress={handleNext}
96
- activeOpacity={0.8}
97
- >
98
- <Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
99
- {isLastQuestion ? 'Submit' : 'Next'}
100
- </Text>
101
- </TouchableOpacity>
102
- </Animated.View>
103
- </View>
104
- );
105
- };
106
-
107
- const styles = StyleSheet.create({
108
- container: {
109
- paddingHorizontal: 20,
110
- paddingTop: 16,
111
- paddingBottom: 24,
112
- },
113
- title: {
114
- fontSize: 18,
115
- fontWeight: '700',
116
- marginBottom: 16,
117
- },
118
- subtitle: {
119
- fontSize: 14,
120
- opacity: 0.6,
121
- marginBottom: 16,
122
- },
123
- optionsList: {
124
- maxHeight: 280,
125
- marginBottom: 12,
126
- },
127
- optionRow: {
128
- flexDirection: 'row',
129
- alignItems: 'center',
130
- borderWidth: 1.5,
131
- borderRadius: 10,
132
- padding: 14,
133
- marginBottom: 10,
134
- },
135
- radio: {
136
- width: 20,
137
- height: 20,
138
- borderRadius: 10,
139
- borderWidth: 2,
140
- alignItems: 'center',
141
- justifyContent: 'center',
142
- marginRight: 12,
143
- },
144
- radioDot: {
145
- width: 10,
146
- height: 10,
147
- borderRadius: 5,
148
- },
149
- optionText: {
150
- fontSize: 15,
151
- flex: 1,
152
- },
153
- errorText: {
154
- color: '#EF4444',
155
- fontSize: 13,
156
- marginBottom: 8,
157
- },
158
- button: {
159
- paddingVertical: 14,
160
- alignItems: 'center',
161
- marginTop: 4,
162
- },
163
- buttonText: {
164
- color: '#FFFFFF',
165
- fontSize: 16,
166
- fontWeight: '600',
167
- },
168
- });