react-native-my-survey-sdk 3.1.2 → 4.0.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 (65) hide show
  1. package/dist/components/XeboDropdownView.d.ts +6 -2
  2. package/dist/components/XeboDropdownView.d.ts.map +1 -1
  3. package/dist/components/XeboDropdownView.js +35 -22
  4. package/dist/components/XeboIntroView.d.ts.map +1 -1
  5. package/dist/components/XeboIntroView.js +3 -2
  6. package/dist/components/XeboLanguageView.d.ts +11 -0
  7. package/dist/components/XeboLanguageView.d.ts.map +1 -0
  8. package/dist/components/XeboLanguageView.js +90 -0
  9. package/dist/components/XeboMultiNPSView.d.ts +4 -2
  10. package/dist/components/XeboMultiNPSView.d.ts.map +1 -1
  11. package/dist/components/XeboMultiNPSView.js +32 -23
  12. package/dist/components/XeboMultiRatingView.d.ts +4 -2
  13. package/dist/components/XeboMultiRatingView.d.ts.map +1 -1
  14. package/dist/components/XeboMultiRatingView.js +31 -22
  15. package/dist/components/XeboMultipleChoiceView.d.ts +6 -2
  16. package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -1
  17. package/dist/components/XeboMultipleChoiceView.js +43 -44
  18. package/dist/components/XeboNPSView.d.ts +8 -2
  19. package/dist/components/XeboNPSView.d.ts.map +1 -1
  20. package/dist/components/XeboNPSView.js +315 -55
  21. package/dist/components/XeboPageView.d.ts +33 -0
  22. package/dist/components/XeboPageView.d.ts.map +1 -0
  23. package/dist/components/XeboPageView.js +190 -0
  24. package/dist/components/XeboRatingView.d.ts +20 -2
  25. package/dist/components/XeboRatingView.d.ts.map +1 -1
  26. package/dist/components/XeboRatingView.js +71 -43
  27. package/dist/components/XeboSingleChoiceView.d.ts +8 -2
  28. package/dist/components/XeboSingleChoiceView.d.ts.map +1 -1
  29. package/dist/components/XeboSingleChoiceView.js +50 -46
  30. package/dist/components/XeboSurveyModal.d.ts.map +1 -1
  31. package/dist/components/XeboSurveyModal.js +236 -42
  32. package/dist/components/XeboTextBoxView.d.ts +4 -2
  33. package/dist/components/XeboTextBoxView.d.ts.map +1 -1
  34. package/dist/components/XeboTextBoxView.js +35 -23
  35. package/dist/components/XeboThankYouView.d.ts.map +1 -1
  36. package/dist/components/XeboThankYouView.js +3 -2
  37. package/dist/core/XeboLanguageService.d.ts +28 -0
  38. package/dist/core/XeboLanguageService.d.ts.map +1 -0
  39. package/dist/core/XeboLanguageService.js +267 -0
  40. package/dist/core/XeboNetworkService.d.ts +24 -3
  41. package/dist/core/XeboNetworkService.d.ts.map +1 -1
  42. package/dist/core/XeboNetworkService.js +202 -69
  43. package/dist/core/XeboOfflineQueue.d.ts +2 -1
  44. package/dist/core/XeboOfflineQueue.d.ts.map +1 -1
  45. package/dist/core/XeboOfflineQueue.js +24 -10
  46. package/dist/core/XeboSurveyManager.d.ts +38 -2
  47. package/dist/core/XeboSurveyManager.d.ts.map +1 -1
  48. package/dist/core/XeboSurveyManager.js +246 -72
  49. package/dist/i18n/XeboRtl.d.ts +16 -0
  50. package/dist/i18n/XeboRtl.d.ts.map +1 -0
  51. package/dist/i18n/XeboRtl.js +32 -0
  52. package/dist/i18n/XeboStrings.d.ts +35 -0
  53. package/dist/i18n/XeboStrings.d.ts.map +1 -0
  54. package/dist/i18n/XeboStrings.js +73 -0
  55. package/dist/index.d.ts +3 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/models/XeboAPIModels.d.ts +103 -1
  58. package/dist/models/XeboAPIModels.d.ts.map +1 -1
  59. package/dist/models/XeboLanguageModels.d.ts +62 -0
  60. package/dist/models/XeboLanguageModels.d.ts.map +1 -0
  61. package/dist/models/XeboLanguageModels.js +3 -0
  62. package/dist/models/XeboModels.d.ts +93 -2
  63. package/dist/models/XeboModels.d.ts.map +1 -1
  64. package/dist/models/XeboModels.js +24 -0
  65. package/package.json +5 -5
@@ -38,10 +38,45 @@ const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
39
  const XeboModels_1 = require("../models/XeboModels");
40
40
  const XeboTheme_1 = require("../theme/XeboTheme");
41
+ const XeboRatingView_1 = require("./XeboRatingView");
42
+ const XeboStrings_1 = require("../i18n/XeboStrings");
43
+ const XeboRtl_1 = require("../i18n/XeboRtl");
41
44
  // NPS zone colors — matches iOS SDK defaults
42
45
  const DETRACTOR_COLOR = '#F24236';
43
46
  const PASSIVE_COLOR = '#FFC208';
44
47
  const PROMOTER_COLOR = '#2ECC70';
48
+ // Fill colors of the platform's default 'animated_nps' style (detractor sampled from the web).
49
+ const ANIMATED_DETRACTOR_COLOR = '#CD1B3C';
50
+ // Emoji per score for the emoji NPS styles, matching the web's sequence from 0 to 10.
51
+ const NPS_EMOJIS = ['😣', '😞', '😦', '😫', '😟', '😳', '😌', '🙂', '😆', '😄', '😍'];
52
+ // Arc style colours sampled from the web: unpicked zones, and the fill from 0 to the picked score.
53
+ // Passive/promoter fills are darker shades chosen to match; only the detractor fill was sampled.
54
+ function arcZoneColor(score) {
55
+ if (score <= 6)
56
+ return '#EB8281';
57
+ if (score <= 8)
58
+ return '#FFDB94';
59
+ return '#99E5C5';
60
+ }
61
+ // 'nps_arc' segment colours from 0 to 10, sampled from the web.
62
+ const NPS_ARC_SEGMENT_COLORS = [
63
+ '#DF3F2C', '#E13F2C', '#E44139', '#E65454', '#E96D6E', '#EB8281',
64
+ '#EF9E9E', '#FAB847', '#F8A630', '#A1C320', '#809B16',
65
+ ];
66
+ function arcFillColor(score) {
67
+ if (score <= 6)
68
+ return '#E65454';
69
+ if (score <= 8)
70
+ return '#FFC24D';
71
+ return '#4CC99A';
72
+ }
73
+ // 'animated_nps' fill per cell from 0 to 10, sampled from the web. Its bar blends between zones;
74
+ // 9 carries the orange→green blend because a gradient needs an extra dependency.
75
+ const ANIMATED_NPS_COLORS = [
76
+ ANIMATED_DETRACTOR_COLOR, ANIMATED_DETRACTOR_COLOR, ANIMATED_DETRACTOR_COLOR, ANIMATED_DETRACTOR_COLOR,
77
+ ANIMATED_DETRACTOR_COLOR, ANIMATED_DETRACTOR_COLOR, ANIMATED_DETRACTOR_COLOR,
78
+ '#F59601', '#F59700', '#C19204', '#40860E',
79
+ ];
45
80
  function npsColor(score, npsLabels) {
46
81
  var _a, _b, _c;
47
82
  if (score <= 6)
@@ -60,10 +95,16 @@ function isColorDark(hex) {
60
95
  const b = parseInt(m[3], 16) / 255;
61
96
  return 0.299 * r + 0.587 * g + 0.114 * b < 0.5;
62
97
  }
63
- const XeboNPSView = ({ question, isLastQuestion, onAnswer }) => {
64
- var _a, _b, _c, _d, _e, _f, _g;
98
+ exports.XeboNPSView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, onFitHeight, embedded, onSelect }, ref) => {
99
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
65
100
  const theme = (0, XeboTheme_1.getTheme)();
66
- const [selectedScore, setSelectedScore] = (0, react_1.useState)(null);
101
+ const scrollHeights = (0, react_1.useRef)({ layout: 0, content: 0 });
102
+ const reportFit = () => {
103
+ const { layout, content } = scrollHeights.current;
104
+ if (layout > 0 && content > 0)
105
+ onFitHeight === null || onFitHeight === void 0 ? void 0 : onFitHeight(content - layout);
106
+ };
107
+ const [selectedScore, setSelectedScore] = (0, react_1.useState)(() => { var _a, _b; return (0, XeboModels_1.scaleIndex)(question, (_b = (_a = question.previousAnswer) === null || _a === void 0 ? void 0 : _a.value[0]) === null || _b === void 0 ? void 0 : _b.colId); });
67
108
  const [followUpText, setFollowUpText] = (0, react_1.useState)('');
68
109
  const [followUpChoice, setFollowUpChoice] = (0, react_1.useState)(null);
69
110
  const [error, setError] = (0, react_1.useState)('');
@@ -77,29 +118,187 @@ const XeboNPSView = ({ question, isLastQuestion, onAnswer }) => {
77
118
  react_native_1.Animated.timing(shakeAnim, { toValue: 0, duration: 60, useNativeDriver: true }),
78
119
  ]).start();
79
120
  };
121
+ // Animated style: white cells; picking a score fills 0..score and keeps the picked cell raised.
122
+ const isAnimated = question.npsStyle === 'animated_nps';
123
+ // 'default' is the platform's uncoloured style: white cells, grey highlight on the picked one.
124
+ const isPlain = question.npsStyle === 'default';
125
+ // 'graphical' (gauge), 'nps_arc', 'nps_arc_emoji': 0–10 round a ring coloured by NPS zone,
126
+ // 30° apart with 5 on top, filled from 0 to the picked score. All but 'nps_arc' show an emoji.
127
+ const isArc = ['graphical', 'nps_arc', 'nps_arc_emoji'].includes((_a = question.npsStyle) !== null && _a !== void 0 ? _a : '');
128
+ // Emoji styles (e.g. 'emojis_flat'): one emoji per score in a bordered cell, sized so all 11 fit.
129
+ const isEmoji = !!((_b = question.npsStyle) === null || _b === void 0 ? void 0 : _b.includes('emoji')) && !isArc;
130
+ const holdsRaised = isAnimated || isPlain || isEmoji;
131
+ const { width: windowWidth } = (0, react_native_1.useWindowDimensions)();
132
+ const emojiSize = Math.min(28, ((windowWidth - 40 - 30) / 11) * 0.8);
133
+ const gaugeSize = Math.min(260, windowWidth - 80);
134
+ // A 262° horseshoe of 11 segments split by thin lines.
135
+ // 'nps_arc': fixed-colour segments, white numbers, ✓ on the picked one.
136
+ // 'nps_arc_emoji': grey segments with a face over each number; the picked segment darkens.
137
+ const renderSegmentedArc = (withFaces) => {
138
+ const c = gaugeSize / 2;
139
+ const band = gaugeSize * 0.2;
140
+ const bandRadius = c - band / 2;
141
+ const span = 262;
142
+ const slice = span / 11;
143
+ const strips = 12;
144
+ const stripDeg = slice / strips;
145
+ const stripLen = (c * stripDeg * Math.PI) / 180 + 1;
146
+ const dot = 34;
147
+ const faceSize = gaugeSize * 0.075;
148
+ const at = (deg, w, h, r = bandRadius) => {
149
+ const a = (deg * Math.PI) / 180;
150
+ return { left: c + r * Math.sin(a) - w / 2, top: c - r * Math.cos(a) - h / 2 };
151
+ };
152
+ const startOf = (i) => -span / 2 + i * slice;
153
+ const segmentColor = (i) => {
154
+ if (!withFaces)
155
+ return NPS_ARC_SEGMENT_COLORS[i];
156
+ return selectedScore === i ? '#AEB3BF' : '#EDEEF3';
157
+ };
158
+ const parts = [];
159
+ for (let i = 0; i < 11; i += 1) {
160
+ for (let k = 0; k < strips; k += 1) {
161
+ const deg = startOf(i) + (k + 0.5) * stripDeg;
162
+ parts.push(<react_native_1.View key={`s${i}-${k}`} style={[
163
+ styles.arcDot,
164
+ at(deg, stripLen, band),
165
+ { width: stripLen, height: band, backgroundColor: segmentColor(i), transform: [{ rotate: `${deg}deg` }] },
166
+ ]}/>);
167
+ }
168
+ }
169
+ const divider = withFaces ? { width: 1, color: '#E5E3F9' } : { width: 2, color: theme.backgroundColor };
170
+ for (let i = 1; i < 11; i += 1) {
171
+ const deg = startOf(i);
172
+ parts.push(<react_native_1.View key={`d${i}`} style={[
173
+ styles.arcDot,
174
+ at(deg, divider.width, band + 2),
175
+ { width: divider.width, height: band + 2, backgroundColor: divider.color, transform: [{ rotate: `${deg}deg` }] },
176
+ ]}/>);
177
+ }
178
+ // The horseshoe's lowest point is its end corners at ±131°, so trim the empty space below.
179
+ const height = c + c * Math.cos(((180 - span / 2) * Math.PI) / 180) + 2;
180
+ return (<react_native_1.View style={[styles.gauge, { width: gaugeSize, height }]}>
181
+ {parts}
182
+ {Array.from({ length: 11 }, (_, i) => {
183
+ const deg = startOf(i) + slice / 2;
184
+ const selected = selectedScore === i;
185
+ if (withFaces) {
186
+ // Red frown for 0–6, yellow frown for 7–8, green smile for 9–10.
187
+ const face = i <= 6 ? { index: 0, color: '#ED464E' } : i <= 8 ? { index: 1, color: '#E5BB4F' } : { index: 3, color: '#6CA077' };
188
+ // Face sits in the outer part of the segment, the number in the inner part.
189
+ return (<react_1.default.Fragment key={i}>
190
+ <react_native_1.View style={[styles.arcDot, at(deg, faceSize, faceSize, c - band * 0.4)]}>
191
+ <XeboRatingView_1.FlatEmoji index={face.index} color={face.color} featureColor="#6E351D" size={faceSize} selected hasSelection={false}/>
192
+ </react_native_1.View>
193
+ <react_native_1.Text style={[styles.arcDot, styles.arcFaceNumber, at(deg, 24, 16, c - band * 0.84)]}>{i}</react_native_1.Text>
194
+ <react_native_1.TouchableOpacity onPress={() => handleScorePress(i)} activeOpacity={0.7} style={[styles.arcDot, at(deg, band, band), { width: band, height: band }]}/>
195
+ </react_1.default.Fragment>);
196
+ }
197
+ return (<react_native_1.TouchableOpacity key={i} onPress={() => handleScorePress(i)} activeOpacity={0.7} style={[styles.gaugeNumber, at(deg, dot, dot), { width: dot, height: dot }]}>
198
+ <react_native_1.Text style={[styles.gaugeNumberText, { color: '#FFFFFF', fontSize: 15 }]}>{i}</react_native_1.Text>
199
+ {selected && (<react_native_1.View style={styles.arcCheck}>
200
+ <react_native_1.Text style={[styles.arcCheckText, { color: NPS_ARC_SEGMENT_COLORS[i] }]}>✓</react_native_1.Text>
201
+ </react_native_1.View>)}
202
+ </react_native_1.TouchableOpacity>);
203
+ })}
204
+ </react_native_1.View>);
205
+ };
206
+ // No SVG dependency: the band is short rotated segments (straight cuts between zones);
207
+ // the picked fill adds round caps at its two ends, like the web.
208
+ const renderArc = () => {
209
+ if (question.npsStyle === 'nps_arc')
210
+ return renderSegmentedArc(false);
211
+ if (question.npsStyle === 'nps_arc_emoji')
212
+ return renderSegmentedArc(true);
213
+ const c = gaugeSize / 2;
214
+ const band = gaugeSize * 0.17;
215
+ const bandRadius = c - band / 2;
216
+ const dot = 34;
217
+ const step = 2.5;
218
+ // Sized to the outer edge so neighbouring segments leave no seams.
219
+ const segLen = (c * step * Math.PI) / 180 + 1;
220
+ const capDeg = (band / 2 / bandRadius) * (180 / Math.PI);
221
+ const toPoint = (deg, size) => {
222
+ const a = (deg * Math.PI) / 180;
223
+ return { left: c + bandRadius * Math.sin(a) - size / 2, top: c - bandRadius * Math.cos(a) - size / 2 };
224
+ };
225
+ const segment = (key, deg, color) => {
226
+ const a = (deg * Math.PI) / 180;
227
+ return (<react_native_1.View key={key} style={[
228
+ styles.arcDot,
229
+ {
230
+ left: c + bandRadius * Math.sin(a) - segLen / 2,
231
+ top: c - bandRadius * Math.cos(a) - band / 2,
232
+ width: segLen,
233
+ height: band,
234
+ backgroundColor: color,
235
+ transform: [{ rotate: `${deg}deg` }],
236
+ },
237
+ ]}/>);
238
+ };
239
+ const cap = (key, deg, color) => (<react_native_1.View key={key} style={[styles.arcDot, toPoint(deg, band), { width: band, height: band, borderRadius: band / 2, backgroundColor: color }]}/>);
240
+ // Each score owns a 30° slice centred on its number; together they span -165°..165°.
241
+ const sliceOf = (deg) => Math.min(10, Math.floor((deg + 165) / 30));
242
+ const dots = [];
243
+ for (let deg = -165 + step / 2; deg < 165; deg += step) {
244
+ dots.push(segment(`b${deg}`, deg, arcZoneColor(sliceOf(deg))));
245
+ }
246
+ if (selectedScore !== null) {
247
+ const fill = arcFillColor(selectedScore);
248
+ const start = -165 + capDeg;
249
+ const end = (selectedScore - 5) * 30 + 15 - capDeg;
250
+ for (let deg = start; deg <= end; deg += step)
251
+ dots.push(segment(`f${deg}`, deg, fill));
252
+ dots.push(cap('fs', start, fill), cap('fe', end, fill));
253
+ }
254
+ return (<react_native_1.View style={[styles.gauge, { width: gaugeSize, height: gaugeSize }]}>
255
+ {dots}
256
+ {question.npsStyle !== 'nps_arc' && (<react_native_1.View style={[styles.gaugeCenter, { left: 0, top: 0, width: gaugeSize, height: gaugeSize }]} pointerEvents="none">
257
+ <react_native_1.Text style={{ fontSize: gaugeSize * 0.15 }}>{NPS_EMOJIS[selectedScore !== null && selectedScore !== void 0 ? selectedScore : 9]}</react_native_1.Text>
258
+ </react_native_1.View>)}
259
+ {Array.from({ length: 11 }, (_, i) => {
260
+ // White numbers only on the strong detractor fill; every other band colour is light.
261
+ const onDark = selectedScore !== null && i <= selectedScore && selectedScore <= 6;
262
+ return (<react_native_1.TouchableOpacity key={i} onPress={() => handleScorePress(i)} activeOpacity={0.7} style={[styles.gaugeNumber, toPoint((i - 5) * 30, dot), { width: dot, height: dot }]}>
263
+ <react_native_1.Text style={[styles.gaugeNumberText, { color: onDark ? '#FFFFFF' : '#374151' }]}>{i}</react_native_1.Text>
264
+ </react_native_1.TouchableOpacity>);
265
+ })}
266
+ </react_native_1.View>);
267
+ };
80
268
  const handleScorePress = (score) => {
269
+ var _a;
270
+ if (holdsRaised && selectedScore !== null && selectedScore !== score) {
271
+ react_native_1.Animated.spring(scaleAnim[selectedScore], { toValue: 1, useNativeDriver: true }).start();
272
+ }
81
273
  setSelectedScore(score);
82
274
  setError('');
83
275
  setFollowUpText('');
84
276
  setFollowUpChoice(null);
85
277
  react_native_1.Animated.spring(scaleAnim[score], { toValue: 1.15, useNativeDriver: true }).start(() => {
86
- react_native_1.Animated.spring(scaleAnim[score], { toValue: 1, useNativeDriver: true }).start();
278
+ if (!holdsRaised)
279
+ react_native_1.Animated.spring(scaleAnim[score], { toValue: 1, useNativeDriver: true }).start();
87
280
  });
281
+ // A follow-up opens under the scale for some scores, so stay put when it does.
282
+ const opensFollowUp = ((_a = question.conditionalFollowUps) !== null && _a !== void 0 ? _a : []).some(f => score >= f.minRating && score <= f.maxRating);
283
+ if (!opensFollowUp && !question.followUpQuestion)
284
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
88
285
  };
89
286
  // Find applicable conditional follow-up
90
287
  const activeFollowUp = selectedScore !== null
91
- ? ((_a = question.conditionalFollowUps) !== null && _a !== void 0 ? _a : []).find(f => selectedScore >= f.minRating && selectedScore <= f.maxRating)
288
+ ? ((_c = question.conditionalFollowUps) !== null && _c !== void 0 ? _c : []).find(f => selectedScore >= f.minRating && selectedScore <= f.maxRating)
92
289
  : undefined;
93
290
  const hasTextFollowUp = !!question.followUpQuestion && !activeFollowUp;
94
- const handleNext = () => {
291
+ const collect = () => {
95
292
  var _a, _b, _c, _d, _e, _f, _g;
96
293
  if (question.isRequired && selectedScore === null) {
97
- setError('Please select a score.');
294
+ setError((0, XeboStrings_1.requiredMessage)(question, 'Please select a score.'));
98
295
  shake();
99
- return;
296
+ return null;
100
297
  }
101
298
  react_native_1.Keyboard.dismiss();
102
- const score = selectedScore !== null && selectedScore !== void 0 ? selectedScore : 0;
299
+ if (selectedScore === null)
300
+ return { questionId: question.id, value: [] };
301
+ const score = selectedScore;
103
302
  const colId = (_c = (_b = (_a = question.columns) === null || _a === void 0 ? void 0 : _a[score]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : score.toString();
104
303
  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 : score.toString();
105
304
  // NPS Pro: conditional follow-up has its own questionId — submit as a separate answer entry
@@ -120,113 +319,155 @@ const XeboNPSView = ({ question, isLastQuestion, onAnswer }) => {
120
319
  value: [{ rowId: activeFollowUp.questionId, text: followUpText }],
121
320
  });
122
321
  }
123
- onAnswer(answers);
124
- return;
322
+ return answers;
125
323
  }
126
324
  // Simple text follow-up
127
- onAnswer({
325
+ return {
128
326
  questionId: question.id,
129
327
  value: [{ rowId, colId, text: hasTextFollowUp ? followUpText : undefined }],
130
- });
328
+ };
329
+ };
330
+ (0, react_1.useImperativeHandle)(ref, () => ({ collect }));
331
+ const handleNext = () => {
332
+ const answer = collect();
333
+ if (answer)
334
+ onAnswer(answer);
131
335
  };
132
336
  return (
133
337
  // Outer view fills modal content area; button pinned at bottom outside ScrollView
134
- <react_native_1.View style={styles.outer}>
135
- <react_native_1.ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled">
136
- <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
338
+ <react_native_1.View style={[styles.outer, embedded && styles.embedded]}>
339
+ <react_native_1.ScrollView style={[styles.scroll, embedded && styles.embedded]} scrollEnabled={!embedded} onLayout={e => { scrollHeights.current.layout = e.nativeEvent.layout.height; reportFit(); }} onContentSizeChange={(_, h) => { scrollHeights.current.content = h; reportFit(); }} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled">
340
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
137
341
  {question.title}
138
342
  </react_native_1.Text>
139
- {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
343
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
140
344
  {question.subtitle}
141
345
  </react_native_1.Text>)}
142
346
 
143
347
  {/* NPS Scale — single row, always-visible category colors */}
144
- <react_native_1.View style={styles.scaleRow}>
348
+ {isArc ? renderArc() : (<react_native_1.View style={[styles.scaleRow, isAnimated && styles.animatedRow]}>
145
349
  {Array.from({ length: 11 }, (_, i) => {
146
- const selected = selectedScore === i;
147
- const color = npsColor(i, question.npsLabels);
148
- return (<react_native_1.Animated.View key={i} style={[styles.scoreCell, { transform: [{ scale: scaleAnim[i] }] }]}>
350
+ const selected = selectedScore === i;
351
+ const color = npsColor(i, question.npsLabels);
352
+ const filled = selectedScore !== null && i <= selectedScore;
353
+ // Animated: each filled cell keeps its own zone colour, joined into one bar with rounded ends.
354
+ const fill = ANIMATED_NPS_COLORS[i];
355
+ if (isEmoji) {
356
+ return (<react_native_1.Animated.View key={i} style={[styles.scoreCell, { transform: [{ scale: scaleAnim[i] }] }]}>
357
+ <react_native_1.TouchableOpacity style={[
358
+ styles.scoreButton,
359
+ styles.emojiCell,
360
+ selected && { backgroundColor: '#F2F2F2', borderColor: '#8188A2', borderWidth: 1.5 },
361
+ ]} onPress={() => handleScorePress(i)} activeOpacity={0.8}>
362
+ <react_native_1.Text style={{ fontSize: emojiSize }}>{NPS_EMOJIS[i]}</react_native_1.Text>
363
+ </react_native_1.TouchableOpacity>
364
+ </react_native_1.Animated.View>);
365
+ }
366
+ return (<react_native_1.Animated.View key={i} style={[styles.scoreCell, { transform: [{ scale: scaleAnim[i] }], zIndex: selected ? 1 : 0 }]}>
149
367
  <react_native_1.TouchableOpacity style={[
150
- styles.scoreButton,
151
- {
152
- backgroundColor: color,
153
- borderColor: selected ? '#000000' : color,
154
- borderWidth: selected ? 2.5 : 1.5,
155
- },
156
- ]} onPress={() => handleScorePress(i)} activeOpacity={0.8}>
368
+ styles.scoreButton,
369
+ isPlain
370
+ ? {
371
+ backgroundColor: selected ? '#F2F2F2' : '#FFFFFF',
372
+ borderColor: selected ? '#8188A2' : '#EEF0F4',
373
+ borderWidth: selected ? 1.5 : 1,
374
+ }
375
+ : isAnimated
376
+ ? {
377
+ backgroundColor: filled ? fill : '#FFFFFF',
378
+ borderColor: filled ? fill : '#E5E7EB',
379
+ borderWidth: 1,
380
+ borderRadius: selected ? 8 : 0,
381
+ borderTopLeftRadius: selected || i === 0 ? 8 : 0,
382
+ borderBottomLeftRadius: selected || i === 0 ? 8 : 0,
383
+ borderTopRightRadius: selected || i === 10 ? 8 : 0,
384
+ borderBottomRightRadius: selected || i === 10 ? 8 : 0,
385
+ }
386
+ : {
387
+ backgroundColor: color,
388
+ borderColor: selected ? '#000000' : color,
389
+ borderWidth: selected ? 2.5 : 1.5,
390
+ },
391
+ ]} onPress={() => handleScorePress(i)} activeOpacity={0.8}>
157
392
  <react_native_1.Text style={[
158
- styles.scoreText,
159
- { color: isColorDark(color) ? '#FFFFFF' : selected ? '#111111' : '#444444' },
160
- ]}>
393
+ styles.scoreText,
394
+ isPlain
395
+ ? { color: '#374151' }
396
+ : isAnimated
397
+ ? { color: filled ? '#FFFFFF' : '#374151', fontWeight: '500' }
398
+ : { color: isColorDark(color) ? '#FFFFFF' : selected ? '#111111' : '#444444' },
399
+ ]}>
161
400
  {i}
162
401
  </react_native_1.Text>
163
402
  </react_native_1.TouchableOpacity>
164
403
  </react_native_1.Animated.View>);
165
- })}
166
- </react_native_1.View>
404
+ })}
405
+ </react_native_1.View>)}
167
406
 
168
407
  {/* Lower / Upper labels */}
169
- {(((_b = question.npsLabels) === null || _b === void 0 ? void 0 : _b.lower) || ((_c = question.npsLabels) === null || _c === void 0 ? void 0 : _c.upper)) && (<react_native_1.View style={styles.labelsRow}>
170
- <react_native_1.Text style={[styles.label, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
171
- {(_e = (_d = question.npsLabels) === null || _d === void 0 ? void 0 : _d.lower) !== null && _e !== void 0 ? _e : ''}
408
+ {(((_d = question.npsLabels) === null || _d === void 0 ? void 0 : _d.lower) || ((_e = question.npsLabels) === null || _e === void 0 ? void 0 : _e.upper)) && (<react_native_1.View style={styles.labelsRow}>
409
+ <react_native_1.Text style={[styles.label, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
410
+ {(_g = (_f = question.npsLabels) === null || _f === void 0 ? void 0 : _f.lower) !== null && _g !== void 0 ? _g : ''}
172
411
  </react_native_1.Text>
173
- <react_native_1.Text style={[styles.label, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
174
- {(_g = (_f = question.npsLabels) === null || _f === void 0 ? void 0 : _f.upper) !== null && _g !== void 0 ? _g : ''}
412
+ <react_native_1.Text style={[styles.label, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
413
+ {(_j = (_h = question.npsLabels) === null || _h === void 0 ? void 0 : _h.upper) !== null && _j !== void 0 ? _j : ''}
175
414
  </react_native_1.Text>
176
415
  </react_native_1.View>)}
177
416
 
178
417
  {/* Conditional follow-up (NPS Pro) */}
179
418
  {selectedScore !== null && activeFollowUp && (<react_native_1.View style={[styles.followUpCard, { borderColor: '#E5E7EB', borderRadius: theme.cornerRadius }]}>
180
- <react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
419
+ <react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
181
420
  {activeFollowUp.followUpQuestion}
182
421
  </react_native_1.Text>
183
422
  {activeFollowUp.followUpType === XeboModels_1.XeboQuestionType.singleChoice && activeFollowUp.followUpOptions.length > 0 ? (activeFollowUp.followUpOptions.map(opt => (<react_native_1.TouchableOpacity key={opt.id} style={[
184
423
  styles.followUpOption,
185
424
  followUpChoice === opt.id && { borderColor: theme.primaryColor },
186
425
  ]} onPress={() => setFollowUpChoice(opt.id)} activeOpacity={0.7}>
187
- <react_native_1.Text style={[styles.followUpOptionText, { color: theme.textColor }]}>{opt.text}</react_native_1.Text>
188
- </react_native_1.TouchableOpacity>))) : (<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"/>)}
426
+ <react_native_1.Text style={[styles.followUpOptionText, { color: theme.textColor }, (0, XeboRtl_1.rtlText)()]}>{opt.text}</react_native_1.Text>
427
+ </react_native_1.TouchableOpacity>))) : (<react_native_1.TextInput style={[styles.followUpInput, { borderColor: '#E5E7EB', color: theme.textColor, borderRadius: theme.cornerRadius }, (0, XeboRtl_1.rtlInput)()]} placeholder="Your comment..." placeholderTextColor="#9CA3AF" value={followUpText} onChangeText={setFollowUpText} multiline numberOfLines={3} textAlignVertical="top"/>)}
189
428
  </react_native_1.View>)}
190
429
 
191
430
  {/* Simple text follow-up */}
192
431
  {selectedScore !== null && hasTextFollowUp && (<react_native_1.View style={[styles.followUpCard, { borderColor: '#E5E7EB', borderRadius: theme.cornerRadius }]}>
193
- <react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
432
+ <react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
194
433
  {question.followUpQuestion}
195
434
  </react_native_1.Text>
196
- <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"/>
435
+ <react_native_1.TextInput style={[styles.followUpInput, { borderColor: '#E5E7EB', color: theme.textColor, borderRadius: theme.cornerRadius }, (0, XeboRtl_1.rtlInput)()]} placeholder="Your comment..." placeholderTextColor="#9CA3AF" value={followUpText} onChangeText={setFollowUpText} multiline numberOfLines={3} textAlignVertical="top"/>
197
436
  </react_native_1.View>)}
198
437
  </react_native_1.ScrollView>
199
438
 
200
439
  {/* Error + button always visible at bottom, outside scroll */}
201
- {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
202
- <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
203
- <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius, opacity: selectedScore === null ? 0.4 : 1 }]} onPress={handleNext} disabled={selectedScore === null} activeOpacity={0.8}>
204
- <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
205
- {isLastQuestion ? 'Submit' : 'Next'}
206
- </react_native_1.Text>
207
- </react_native_1.TouchableOpacity>
208
- </react_native_1.Animated.View>
440
+ {!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
441
+ {!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
442
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius, opacity: selectedScore === null ? 0.4 : 1 }]} onPress={handleNext} disabled={selectedScore === null} activeOpacity={0.8}>
443
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
444
+ {(0, XeboStrings_1.actionLabel)(isLastQuestion)}
445
+ </react_native_1.Text>
446
+ </react_native_1.TouchableOpacity>
447
+ </react_native_1.Animated.View>)}
209
448
  </react_native_1.View>);
210
- };
211
- exports.XeboNPSView = XeboNPSView;
449
+ });
212
450
  const styles = react_native_1.StyleSheet.create({
213
451
  outer: {
214
452
  flex: 1,
215
453
  paddingHorizontal: 20,
216
- paddingBottom: 16,
454
+ paddingBottom: 10,
217
455
  },
218
456
  scroll: { flex: 1, minHeight: 0 },
457
+ embedded: { flex: 0 },
219
458
  scrollContent: {
220
459
  paddingTop: 16,
221
460
  paddingBottom: 8,
222
461
  },
223
- title: { fontSize: 18, fontWeight: '700', marginBottom: 6 },
462
+ title: { fontSize: 18, fontWeight: '700', marginBottom: 16 },
224
463
  subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
225
464
  scaleRow: {
226
465
  flexDirection: 'row',
227
466
  gap: 3,
228
467
  marginBottom: 8,
229
468
  },
469
+ // Animated cells touch so the filled part reads as one bar.
470
+ animatedRow: { gap: 0 },
230
471
  scoreCell: {
231
472
  flex: 1,
232
473
  },
@@ -237,6 +478,25 @@ const styles = react_native_1.StyleSheet.create({
237
478
  justifyContent: 'center',
238
479
  },
239
480
  scoreText: { fontSize: 13, fontWeight: '700' },
481
+ gauge: { alignSelf: 'center', marginVertical: 8 },
482
+ gaugeCenter: { position: 'absolute', alignItems: 'center', justifyContent: 'center' },
483
+ gaugeNumber: { position: 'absolute', alignItems: 'center', justifyContent: 'center' },
484
+ gaugeNumberText: { fontSize: 14, fontWeight: '500' },
485
+ arcDot: { position: 'absolute' },
486
+ arcCheck: {
487
+ position: 'absolute',
488
+ right: 0,
489
+ top: 2,
490
+ width: 14,
491
+ height: 14,
492
+ borderRadius: 7,
493
+ backgroundColor: '#FFFFFF',
494
+ alignItems: 'center',
495
+ justifyContent: 'center',
496
+ },
497
+ arcCheckText: { fontSize: 9, fontWeight: '800' },
498
+ arcFaceNumber: { width: 24, height: 16, textAlign: 'center', fontSize: 12, fontWeight: '500', color: '#4B5563' },
499
+ emojiCell: { backgroundColor: '#FFFFFF', borderColor: '#CBD1DC', borderWidth: 1, borderRadius: 2 },
240
500
  labelsRow: {
241
501
  flexDirection: 'row',
242
502
  justifyContent: 'space-between',
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { XeboSurvey } from '../models/XeboModels';
3
+ interface Props {
4
+ /** The page's questions in order, each already rendered. */
5
+ questions: Array<{
6
+ id: string;
7
+ view: React.ReactNode;
8
+ /** Auto-advance moves on when this is answered and, like the web, it shows no Ok / Next. */
9
+ hidesButtons?: boolean;
10
+ }>;
11
+ isLastPage: boolean;
12
+ /** Validates one question; true when the respondent can move on to the next. */
13
+ onOk: (questionId: string) => boolean;
14
+ onNext: () => void;
15
+ /** Reports how much taller (or shorter) the sheet must be to fit every question without scrolling. */
16
+ onFitHeight?: (delta: number) => void;
17
+ /** Label of the "Previous" button; omitted when the survey turns it off. */
18
+ previousLabel?: string;
19
+ /** Show Previous as a small "‹" button, as the web does when its text is blank. */
20
+ previousIconOnly?: boolean;
21
+ /** True when an earlier page exists, so Previous on this page's first question can go there. */
22
+ canGoBack: boolean;
23
+ onPreviousPage: () => void;
24
+ buttonColors?: XeboSurvey['buttonColors'];
25
+ }
26
+ export interface XeboPageViewHandle {
27
+ /** Auto-advance: brings the next question into view, or from the page's last question moves to the next page. */
28
+ scrollToNext: (questionId: string) => void;
29
+ }
30
+ /** One page of the survey: its questions, then Ok / Previous / Next-or-Submit like the web. */
31
+ export declare const XeboPageView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboPageViewHandle>>;
32
+ export {};
33
+ //# sourceMappingURL=XeboPageView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboPageView.d.ts","sourceRoot":"","sources":["../../src/components/XeboPageView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,UAAU,KAAK;IACb,4DAA4D;IAC5D,SAAS,EAAE,KAAK,CAAC;QACf,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;QACtB,4FAA4F;QAC5F,YAAY,CAAC,EAAE,OAAO,CAAC;KACxB,CAAC,CAAC;IACH,UAAU,EAAE,OAAO,CAAC;IACpB,gFAAgF;IAChF,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IACtC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,sGAAsG;IACtG,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,mFAAmF;IACnF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gGAAgG;IAChG,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,UAAU,CAAC,cAAc,CAAC,CAAC;CAC3C;AAED,MAAM,WAAW,kBAAkB;IACjC,iHAAiH;IACjH,YAAY,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C;AAED,+FAA+F;AAC/F,eAAO,MAAM,YAAY,kFAmIvB,CAAC"}