react-native-my-survey-sdk 3.0.0 → 3.0.1

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 +248 -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,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 XeboDropdownView: React.FC<Props>;
9
+ export {};
10
+ //# sourceMappingURL=XeboDropdownView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboDropdownView.d.ts","sourceRoot":"","sources":["../../src/components/XeboDropdownView.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,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+G5C,CAAC"}
@@ -0,0 +1,190 @@
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.XeboDropdownView = 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 XeboDropdownView = ({ question, isLastQuestion, onAnswer }) => {
41
+ var _a;
42
+ const theme = (0, XeboTheme_1.getTheme)();
43
+ const [selectedChoice, setSelectedChoice] = (0, react_1.useState)(null);
44
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
45
+ const [error, setError] = (0, react_1.useState)('');
46
+ const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
47
+ const shake = () => {
48
+ react_native_1.Animated.sequence([
49
+ react_native_1.Animated.timing(shakeAnim, { toValue: 8, duration: 60, useNativeDriver: true }),
50
+ react_native_1.Animated.timing(shakeAnim, { toValue: -8, duration: 60, useNativeDriver: true }),
51
+ react_native_1.Animated.timing(shakeAnim, { toValue: 6, duration: 60, useNativeDriver: true }),
52
+ react_native_1.Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
53
+ ]).start();
54
+ };
55
+ const handleSelect = (choice) => {
56
+ setSelectedChoice(choice);
57
+ setIsOpen(false);
58
+ setError('');
59
+ };
60
+ const handleNext = () => {
61
+ if (question.isRequired && !selectedChoice) {
62
+ setError('Please select an option.');
63
+ shake();
64
+ return;
65
+ }
66
+ onAnswer({
67
+ questionId: question.id,
68
+ value: selectedChoice ? [{ rowId: selectedChoice.id, text: selectedChoice.text }] : [],
69
+ });
70
+ };
71
+ return (<react_native_1.View style={styles.container}>
72
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
73
+ {question.title}
74
+ </react_native_1.Text>
75
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
76
+ {question.subtitle}
77
+ </react_native_1.Text>)}
78
+
79
+ <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
80
+ <react_native_1.TouchableOpacity style={[styles.trigger, { borderColor: isOpen ? theme.primaryColor : '#E5E7EB', borderRadius: theme.cornerRadius }]} onPress={() => setIsOpen(prev => !prev)} activeOpacity={0.8}>
81
+ <react_native_1.Text style={[
82
+ styles.triggerText,
83
+ { color: selectedChoice ? theme.textColor : '#9CA3AF', fontFamily: theme.fontFamily },
84
+ ]}>
85
+ {selectedChoice ? selectedChoice.text : (question.placeholder || 'Select an option')}
86
+ </react_native_1.Text>
87
+ <react_native_1.Text style={[styles.chevron, { color: theme.textColor }]}>{isOpen ? '▲' : '▼'}</react_native_1.Text>
88
+ </react_native_1.TouchableOpacity>
89
+ </react_native_1.Animated.View>
90
+
91
+ {isOpen && (<react_native_1.View style={[styles.optionsList, { borderColor: theme.primaryColor, borderRadius: theme.cornerRadius }]}>
92
+ <react_native_1.ScrollView nestedScrollEnabled style={styles.optionsScroll} showsVerticalScrollIndicator={false}>
93
+ {((_a = question.options) !== null && _a !== void 0 ? _a : []).map((choice) => (<react_native_1.TouchableOpacity key={choice.id} style={[
94
+ styles.optionRow,
95
+ (selectedChoice === null || selectedChoice === void 0 ? void 0 : selectedChoice.id) === choice.id && { backgroundColor: `${theme.primaryColor}15` },
96
+ ]} onPress={() => handleSelect(choice)} activeOpacity={0.7}>
97
+ <react_native_1.Text style={[
98
+ styles.optionText,
99
+ {
100
+ color: (selectedChoice === null || selectedChoice === void 0 ? void 0 : selectedChoice.id) === choice.id ? theme.primaryColor : theme.textColor,
101
+ fontFamily: theme.fontFamily,
102
+ fontWeight: (selectedChoice === null || selectedChoice === void 0 ? void 0 : selectedChoice.id) === choice.id ? '600' : '400',
103
+ },
104
+ ]}>
105
+ {choice.text}
106
+ </react_native_1.Text>
107
+ </react_native_1.TouchableOpacity>))}
108
+ </react_native_1.ScrollView>
109
+ </react_native_1.View>)}
110
+
111
+ {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
112
+
113
+ <react_native_1.TouchableOpacity style={[
114
+ styles.button,
115
+ { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius },
116
+ (question.isRequired && !selectedChoice) && styles.buttonDisabled,
117
+ ]} onPress={handleNext} activeOpacity={0.8}>
118
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
119
+ {isLastQuestion ? 'Submit' : 'Next'}
120
+ </react_native_1.Text>
121
+ </react_native_1.TouchableOpacity>
122
+ </react_native_1.View>);
123
+ };
124
+ exports.XeboDropdownView = XeboDropdownView;
125
+ const styles = react_native_1.StyleSheet.create({
126
+ container: {
127
+ paddingHorizontal: 20,
128
+ paddingTop: 16,
129
+ paddingBottom: 24,
130
+ },
131
+ title: {
132
+ fontSize: 18,
133
+ fontWeight: '700',
134
+ marginBottom: 16,
135
+ },
136
+ subtitle: {
137
+ fontSize: 14,
138
+ opacity: 0.6,
139
+ marginBottom: 16,
140
+ },
141
+ trigger: {
142
+ flexDirection: 'row',
143
+ alignItems: 'center',
144
+ borderWidth: 1.5,
145
+ padding: 14,
146
+ },
147
+ triggerText: {
148
+ fontSize: 15,
149
+ flex: 1,
150
+ },
151
+ chevron: {
152
+ fontSize: 12,
153
+ },
154
+ optionsList: {
155
+ borderWidth: 1.5,
156
+ maxHeight: 200,
157
+ marginTop: 6,
158
+ marginBottom: 12,
159
+ },
160
+ optionsScroll: {
161
+ flexGrow: 0,
162
+ },
163
+ optionRow: {
164
+ padding: 14,
165
+ borderBottomWidth: 1,
166
+ borderBottomColor: '#F3F4F6',
167
+ },
168
+ optionText: {
169
+ fontSize: 15,
170
+ },
171
+ errorText: {
172
+ color: '#EF4444',
173
+ fontSize: 13,
174
+ marginTop: 6,
175
+ marginBottom: 4,
176
+ },
177
+ button: {
178
+ paddingVertical: 14,
179
+ alignItems: 'center',
180
+ marginTop: 16,
181
+ },
182
+ buttonDisabled: {
183
+ opacity: 0.4,
184
+ },
185
+ buttonText: {
186
+ color: '#FFFFFF',
187
+ fontSize: 16,
188
+ fontWeight: '600',
189
+ },
190
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { XeboSurveyPage } from '../models/XeboModels';
3
+ interface Props {
4
+ introPage: XeboSurveyPage;
5
+ onStart: () => void;
6
+ }
7
+ export declare const XeboIntroView: React.FC<Props>;
8
+ export {};
9
+ //# sourceMappingURL=XeboIntroView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboIntroView.d.ts","sourceRoot":"","sources":["../../src/components/XeboIntroView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,UAAU,KAAK;IACb,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA4BzC,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.XeboIntroView = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_native_1 = require("react-native");
9
+ const XeboTheme_1 = require("../theme/XeboTheme");
10
+ const XeboIntroView = ({ introPage, onStart }) => {
11
+ const theme = (0, XeboTheme_1.getTheme)();
12
+ return (<react_native_1.View style={styles.outer}>
13
+ {!!introPage.content && (<react_native_1.ScrollView style={styles.scroll} showsVerticalScrollIndicator={false} contentContainerStyle={styles.scrollContent}>
14
+ <react_native_1.Text style={[styles.content, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
15
+ {introPage.content}
16
+ </react_native_1.Text>
17
+ </react_native_1.ScrollView>)}
18
+
19
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={onStart} activeOpacity={0.8}>
20
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
21
+ {introPage.buttonText || "Let's get started"}
22
+ </react_native_1.Text>
23
+ </react_native_1.TouchableOpacity>
24
+ </react_native_1.View>);
25
+ };
26
+ exports.XeboIntroView = XeboIntroView;
27
+ const styles = react_native_1.StyleSheet.create({
28
+ outer: {
29
+ paddingHorizontal: 20,
30
+ paddingTop: 8,
31
+ paddingBottom: 24,
32
+ },
33
+ scroll: {
34
+ maxHeight: 220,
35
+ marginBottom: 4,
36
+ },
37
+ scrollContent: {
38
+ paddingBottom: 8,
39
+ },
40
+ content: {
41
+ fontSize: 16,
42
+ lineHeight: 26,
43
+ },
44
+ button: {
45
+ paddingVertical: 14,
46
+ alignItems: 'center',
47
+ marginTop: 16,
48
+ },
49
+ buttonText: {
50
+ color: '#FFFFFF',
51
+ fontSize: 16,
52
+ fontWeight: '600',
53
+ },
54
+ });
@@ -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 XeboMultiNPSView: React.FC<Props>;
9
+ export {};
10
+ //# sourceMappingURL=XeboMultiNPSView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboMultiNPSView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultiNPSView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGhE,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAqBD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAwG5C,CAAC"}
@@ -0,0 +1,170 @@
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.XeboMultiNPSView = 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 DETRACTOR_COLOR = '#F24236';
41
+ const PASSIVE_COLOR = '#FFC208';
42
+ const PROMOTER_COLOR = '#2ECC70';
43
+ function npsColor(score, npsLabels) {
44
+ var _a, _b, _c;
45
+ if (score <= 6)
46
+ return (_a = npsLabels === null || npsLabels === void 0 ? void 0 : npsLabels.detractorColor) !== null && _a !== void 0 ? _a : DETRACTOR_COLOR;
47
+ if (score <= 8)
48
+ return (_b = npsLabels === null || npsLabels === void 0 ? void 0 : npsLabels.passiveColor) !== null && _b !== void 0 ? _b : PASSIVE_COLOR;
49
+ return (_c = npsLabels === null || npsLabels === void 0 ? void 0 : npsLabels.promoterColor) !== null && _c !== void 0 ? _c : PROMOTER_COLOR;
50
+ }
51
+ function isColorDark(hex) {
52
+ const m = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
53
+ if (!m)
54
+ return false;
55
+ const r = parseInt(m[1], 16) / 255;
56
+ const g = parseInt(m[2], 16) / 255;
57
+ const b = parseInt(m[3], 16) / 255;
58
+ return 0.299 * r + 0.587 * g + 0.114 * b < 0.5;
59
+ }
60
+ const XeboMultiNPSView = ({ question, isLastQuestion, onAnswer }) => {
61
+ var _a;
62
+ const theme = (0, XeboTheme_1.getTheme)();
63
+ const rows = (_a = question.options) !== null && _a !== void 0 ? _a : [];
64
+ const [scores, setScores] = (0, react_1.useState)({});
65
+ const [error, setError] = (0, react_1.useState)('');
66
+ const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
67
+ const shake = () => {
68
+ react_native_1.Animated.sequence([
69
+ react_native_1.Animated.timing(shakeAnim, { toValue: 8, duration: 60, useNativeDriver: true }),
70
+ react_native_1.Animated.timing(shakeAnim, { toValue: -8, duration: 60, useNativeDriver: true }),
71
+ react_native_1.Animated.timing(shakeAnim, { toValue: 6, duration: 60, useNativeDriver: true }),
72
+ react_native_1.Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
73
+ ]).start();
74
+ };
75
+ const setScore = (rowId, score) => {
76
+ setScores(prev => (Object.assign(Object.assign({}, prev), { [rowId]: score })));
77
+ setError('');
78
+ };
79
+ const handleNext = () => {
80
+ if (question.isRequired && rows.some(r => scores[r.id] === undefined)) {
81
+ setError('Please rate all items.');
82
+ shake();
83
+ return;
84
+ }
85
+ onAnswer({
86
+ questionId: question.id,
87
+ value: rows
88
+ .filter(r => scores[r.id] !== undefined)
89
+ .map(r => {
90
+ var _a, _b, _c;
91
+ return ({
92
+ rowId: r.id,
93
+ colId: ((_c = (_b = (_a = question.columns) === null || _a === void 0 ? void 0 : _a[scores[r.id]]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : scores[r.id].toString()),
94
+ });
95
+ }),
96
+ });
97
+ };
98
+ return (<react_native_1.View style={styles.container}>
99
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
100
+ {question.title}
101
+ </react_native_1.Text>
102
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
103
+ {question.subtitle}
104
+ </react_native_1.Text>)}
105
+
106
+ <react_native_1.ScrollView style={styles.scroll} showsVerticalScrollIndicator={false}>
107
+ {rows.map(row => (<react_native_1.View key={row.id} style={styles.rowWrap}>
108
+ <react_native_1.Text style={[styles.rowLabel, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
109
+ {row.text}
110
+ </react_native_1.Text>
111
+ {/* Single-row NPS scale with always-visible category colors */}
112
+ <react_native_1.View style={styles.scaleRow}>
113
+ {Array.from({ length: 11 }, (_, i) => {
114
+ const selected = scores[row.id] === i;
115
+ const color = npsColor(i, question.npsLabels);
116
+ return (<react_native_1.TouchableOpacity key={i} style={[
117
+ styles.scoreButton,
118
+ {
119
+ backgroundColor: color,
120
+ borderColor: selected ? '#000000' : color,
121
+ borderWidth: selected ? 2.5 : 1.5,
122
+ },
123
+ ]} onPress={() => setScore(row.id, i)} activeOpacity={0.8}>
124
+ <react_native_1.Text style={[
125
+ styles.scoreText,
126
+ { color: isColorDark(color) ? '#FFFFFF' : selected ? '#111111' : '#444444' },
127
+ ]}>
128
+ {i}
129
+ </react_native_1.Text>
130
+ </react_native_1.TouchableOpacity>);
131
+ })}
132
+ </react_native_1.View>
133
+ </react_native_1.View>))}
134
+ </react_native_1.ScrollView>
135
+
136
+ {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
137
+
138
+ <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
139
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
140
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
141
+ {isLastQuestion ? 'Submit' : 'Next'}
142
+ </react_native_1.Text>
143
+ </react_native_1.TouchableOpacity>
144
+ </react_native_1.Animated.View>
145
+ </react_native_1.View>);
146
+ };
147
+ exports.XeboMultiNPSView = XeboMultiNPSView;
148
+ const styles = react_native_1.StyleSheet.create({
149
+ container: { flex: 1, paddingHorizontal: 20, paddingTop: 16, paddingBottom: 24 },
150
+ title: { fontSize: 18, fontWeight: '700', marginBottom: 6 },
151
+ subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
152
+ scroll: { flex: 1, minHeight: 0, marginBottom: 12 },
153
+ rowWrap: { marginBottom: 20 },
154
+ rowLabel: { fontSize: 15, fontWeight: '500', marginBottom: 8 },
155
+ scaleRow: {
156
+ flexDirection: 'row',
157
+ gap: 3,
158
+ },
159
+ scoreButton: {
160
+ flex: 1,
161
+ height: 40,
162
+ borderRadius: 5,
163
+ alignItems: 'center',
164
+ justifyContent: 'center',
165
+ },
166
+ scoreText: { fontSize: 12, fontWeight: '700' },
167
+ errorText: { color: '#EF4444', fontSize: 13, marginBottom: 8 },
168
+ button: { paddingVertical: 14, alignItems: 'center', marginTop: 4 },
169
+ buttonText: { color: '#FFFFFF', fontSize: 16, fontWeight: '600' },
170
+ });
@@ -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 XeboMultiRatingView: React.FC<Props>;
9
+ export {};
10
+ //# sourceMappingURL=XeboMultiRatingView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboMultiRatingView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultiRatingView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGhE,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,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2H/C,CAAC"}
@@ -0,0 +1,154 @@
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.XeboMultiRatingView = 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 XeboMultiRatingView = ({ question, isLastQuestion, onAnswer }) => {
41
+ var _a, _b, _c, _d, _e;
42
+ const theme = (0, XeboTheme_1.getTheme)();
43
+ const rows = (_a = question.options) !== null && _a !== void 0 ? _a : [];
44
+ const totalSteps = (_c = (_b = question.columns) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 5;
45
+ const ratingColor = (_d = question.ratingColor) !== null && _d !== void 0 ? _d : theme.primaryColor;
46
+ const ratingStyle = (_e = question.ratingStyle) !== null && _e !== void 0 ? _e : 'star';
47
+ const [ratings, setRatings] = (0, react_1.useState)({});
48
+ const [error, setError] = (0, react_1.useState)('');
49
+ const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
50
+ const shake = () => {
51
+ react_native_1.Animated.sequence([
52
+ react_native_1.Animated.timing(shakeAnim, { toValue: 8, duration: 60, useNativeDriver: true }),
53
+ react_native_1.Animated.timing(shakeAnim, { toValue: -8, duration: 60, useNativeDriver: true }),
54
+ react_native_1.Animated.timing(shakeAnim, { toValue: 6, duration: 60, useNativeDriver: true }),
55
+ react_native_1.Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
56
+ ]).start();
57
+ };
58
+ const setRating = (rowId, index) => {
59
+ setRatings(prev => (Object.assign(Object.assign({}, prev), { [rowId]: index })));
60
+ setError('');
61
+ };
62
+ const isCumulative = ratingStyle === 'star' || ratingStyle === 'heart';
63
+ const handleNext = () => {
64
+ if (question.isRequired && rows.some(r => ratings[r.id] === undefined)) {
65
+ setError('Please rate all items.');
66
+ shake();
67
+ return;
68
+ }
69
+ onAnswer({
70
+ questionId: question.id,
71
+ value: rows
72
+ .filter(r => ratings[r.id] !== undefined)
73
+ .map(r => {
74
+ var _a, _b, _c;
75
+ return ({
76
+ rowId: r.id,
77
+ colId: (_c = (_b = (_a = question.columns) === null || _a === void 0 ? void 0 : _a[ratings[r.id]]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : ratings[r.id].toString(),
78
+ });
79
+ }),
80
+ });
81
+ };
82
+ const starIcon = (filled) => ratingStyle === 'heart' ? (filled ? '♥' : '♡') : filled ? '★' : '☆';
83
+ return (<react_native_1.View style={styles.container}>
84
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
85
+ {question.title}
86
+ </react_native_1.Text>
87
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
88
+ {question.subtitle}
89
+ </react_native_1.Text>)}
90
+
91
+ <react_native_1.ScrollView style={styles.scroll} showsVerticalScrollIndicator={false}>
92
+ {rows.map(row => (<react_native_1.View key={row.id} style={styles.rowWrap}>
93
+ <react_native_1.Text style={[styles.rowLabel, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
94
+ {row.text}
95
+ </react_native_1.Text>
96
+ <react_native_1.View style={styles.iconsRow}>
97
+ {Array.from({ length: totalSteps }, (_, i) => {
98
+ const isFilled = isCumulative
99
+ ? ratings[row.id] !== undefined && i <= ratings[row.id]
100
+ : i === ratings[row.id];
101
+ return (<react_native_1.TouchableOpacity key={i} onPress={() => setRating(row.id, i)} activeOpacity={0.7} style={styles.iconButton}>
102
+ {ratingStyle === 'circle' ? (<react_native_1.View style={[
103
+ styles.circle,
104
+ { backgroundColor: isFilled ? ratingColor : '#E5E7EB' },
105
+ ]}/>) : ratingStyle === 'tile' ? (<react_native_1.View style={[
106
+ styles.tile,
107
+ { backgroundColor: isFilled ? ratingColor : '#E5E7EB' },
108
+ ]}>
109
+ <react_native_1.Text style={[styles.tileText, { color: isFilled ? '#FFF' : '#6B7280' }]}>
110
+ {i + 1}
111
+ </react_native_1.Text>
112
+ </react_native_1.View>) : (<react_native_1.Text style={{ fontSize: 30, color: isFilled ? ratingColor : '#E5E7EB' }}>
113
+ {starIcon(isFilled)}
114
+ </react_native_1.Text>)}
115
+ </react_native_1.TouchableOpacity>);
116
+ })}
117
+ </react_native_1.View>
118
+ </react_native_1.View>))}
119
+ </react_native_1.ScrollView>
120
+
121
+ {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
122
+
123
+ <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
124
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
125
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
126
+ {isLastQuestion ? 'Submit' : 'Next'}
127
+ </react_native_1.Text>
128
+ </react_native_1.TouchableOpacity>
129
+ </react_native_1.Animated.View>
130
+ </react_native_1.View>);
131
+ };
132
+ exports.XeboMultiRatingView = XeboMultiRatingView;
133
+ const styles = react_native_1.StyleSheet.create({
134
+ container: { paddingHorizontal: 20, paddingTop: 16, paddingBottom: 24 },
135
+ title: { fontSize: 18, fontWeight: '700', marginBottom: 16 },
136
+ subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
137
+ scroll: { maxHeight: 280, marginBottom: 12 },
138
+ rowWrap: { marginBottom: 24 },
139
+ rowLabel: { fontSize: 15, fontWeight: '500', marginBottom: 8 },
140
+ iconsRow: { flexDirection: 'row', flexWrap: 'nowrap', justifyContent: 'space-between' },
141
+ iconButton: { alignItems: 'center', justifyContent: 'center' },
142
+ circle: { width: 36, height: 36, borderRadius: 18 },
143
+ tile: {
144
+ width: 40,
145
+ height: 40,
146
+ borderRadius: 6,
147
+ alignItems: 'center',
148
+ justifyContent: 'center',
149
+ },
150
+ tileText: { fontSize: 13, fontWeight: '700' },
151
+ errorText: { color: '#EF4444', fontSize: 13, marginBottom: 8 },
152
+ button: { paddingVertical: 14, alignItems: 'center', marginTop: 4 },
153
+ buttonText: { color: '#FFFFFF', fontSize: 16, fontWeight: '600' },
154
+ });
@@ -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 XeboMultipleChoiceView: React.FC<Props>;
9
+ export {};
10
+ //# sourceMappingURL=XeboMultipleChoiceView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboMultipleChoiceView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultipleChoiceView.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,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAqGlD,CAAC"}