react-native-my-survey-sdk 3.1.1 → 3.1.3

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 (50) hide show
  1. package/dist/components/XeboDropdownView.d.ts.map +1 -1
  2. package/dist/components/XeboDropdownView.js +10 -6
  3. package/dist/components/XeboIntroView.d.ts.map +1 -1
  4. package/dist/components/XeboIntroView.js +3 -2
  5. package/dist/components/XeboLanguageView.d.ts +11 -0
  6. package/dist/components/XeboLanguageView.d.ts.map +1 -0
  7. package/dist/components/XeboLanguageView.js +90 -0
  8. package/dist/components/XeboMultiNPSView.d.ts.map +1 -1
  9. package/dist/components/XeboMultiNPSView.js +9 -7
  10. package/dist/components/XeboMultiRatingView.d.ts.map +1 -1
  11. package/dist/components/XeboMultiRatingView.js +9 -7
  12. package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -1
  13. package/dist/components/XeboMultipleChoiceView.js +10 -8
  14. package/dist/components/XeboNPSView.d.ts.map +1 -1
  15. package/dist/components/XeboNPSView.js +15 -13
  16. package/dist/components/XeboRatingView.d.ts.map +1 -1
  17. package/dist/components/XeboRatingView.js +10 -8
  18. package/dist/components/XeboSingleChoiceView.d.ts.map +1 -1
  19. package/dist/components/XeboSingleChoiceView.js +10 -8
  20. package/dist/components/XeboSurveyModal.d.ts.map +1 -1
  21. package/dist/components/XeboSurveyModal.js +96 -18
  22. package/dist/components/XeboTextBoxView.d.ts.map +1 -1
  23. package/dist/components/XeboTextBoxView.js +10 -7
  24. package/dist/components/XeboThankYouView.d.ts.map +1 -1
  25. package/dist/components/XeboThankYouView.js +3 -2
  26. package/dist/core/XeboLanguageService.d.ts +28 -0
  27. package/dist/core/XeboLanguageService.d.ts.map +1 -0
  28. package/dist/core/XeboLanguageService.js +261 -0
  29. package/dist/core/XeboNetworkService.d.ts +12 -2
  30. package/dist/core/XeboNetworkService.d.ts.map +1 -1
  31. package/dist/core/XeboNetworkService.js +27 -11
  32. package/dist/core/XeboSurveyManager.d.ts +22 -1
  33. package/dist/core/XeboSurveyManager.d.ts.map +1 -1
  34. package/dist/core/XeboSurveyManager.js +140 -39
  35. package/dist/i18n/XeboRtl.d.ts +11 -0
  36. package/dist/i18n/XeboRtl.d.ts.map +1 -0
  37. package/dist/i18n/XeboRtl.js +21 -0
  38. package/dist/i18n/XeboStrings.d.ts +29 -0
  39. package/dist/i18n/XeboStrings.d.ts.map +1 -0
  40. package/dist/i18n/XeboStrings.js +59 -0
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/models/XeboAPIModels.d.ts +10 -1
  44. package/dist/models/XeboAPIModels.d.ts.map +1 -1
  45. package/dist/models/XeboLanguageModels.d.ts +62 -0
  46. package/dist/models/XeboLanguageModels.d.ts.map +1 -0
  47. package/dist/models/XeboLanguageModels.js +3 -0
  48. package/dist/models/XeboModels.d.ts +7 -0
  49. package/dist/models/XeboModels.d.ts.map +1 -1
  50. package/package.json +3 -2
@@ -37,6 +37,8 @@ exports.XeboSingleChoiceView = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
39
  const XeboTheme_1 = require("../theme/XeboTheme");
40
+ const XeboStrings_1 = require("../i18n/XeboStrings");
41
+ const XeboRtl_1 = require("../i18n/XeboRtl");
40
42
  const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
41
43
  var _a;
42
44
  const theme = (0, XeboTheme_1.getTheme)();
@@ -58,7 +60,7 @@ const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
58
60
  const handleNext = () => {
59
61
  var _a, _b;
60
62
  if (question.isRequired && !selectedId) {
61
- setError('Please select an option.');
63
+ setError((0, XeboStrings_1.requiredMessage)(question, 'Please select an option.'));
62
64
  shake();
63
65
  return;
64
66
  }
@@ -72,10 +74,10 @@ const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
72
74
  });
73
75
  };
74
76
  return (<react_native_1.View style={styles.container}>
75
- <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
77
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
76
78
  {question.title}
77
79
  </react_native_1.Text>
78
- {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
80
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
79
81
  {question.subtitle}
80
82
  </react_native_1.Text>)}
81
83
 
@@ -89,19 +91,19 @@ const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
89
91
  <react_native_1.View style={[styles.radio, { borderColor: selected ? theme.primaryColor : '#9CA3AF' }]}>
90
92
  {selected && <react_native_1.View style={[styles.radioDot, { backgroundColor: theme.primaryColor }]}/>}
91
93
  </react_native_1.View>
92
- <react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
94
+ <react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
93
95
  {choice.text}
94
96
  </react_native_1.Text>
95
97
  </react_native_1.TouchableOpacity>);
96
98
  })}
97
99
  </react_native_1.ScrollView>
98
100
 
99
- {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
101
+ {!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
100
102
 
101
103
  <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
102
104
  <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
103
105
  <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
104
- {isLastQuestion ? 'Submit' : 'Next'}
106
+ {(0, XeboStrings_1.actionLabel)(isLastQuestion)}
105
107
  </react_native_1.Text>
106
108
  </react_native_1.TouchableOpacity>
107
109
  </react_native_1.Animated.View>
@@ -113,7 +115,7 @@ const styles = react_native_1.StyleSheet.create({
113
115
  flex: 1,
114
116
  paddingHorizontal: 20,
115
117
  paddingTop: 16,
116
- paddingBottom: 24,
118
+ paddingBottom: 10,
117
119
  },
118
120
  title: {
119
121
  fontSize: 18,
@@ -144,7 +146,7 @@ const styles = react_native_1.StyleSheet.create({
144
146
  borderWidth: 2,
145
147
  alignItems: 'center',
146
148
  justifyContent: 'center',
147
- marginRight: 12,
149
+ marginEnd: 12,
148
150
  },
149
151
  radioDot: {
150
152
  width: 10,
@@ -1 +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,EAkPnC,CAAC"}
1
+ {"version":3,"file":"XeboSurveyModal.d.ts","sourceRoot":"","sources":["../../src/components/XeboSurveyModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAoFjF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAmUnC,CAAC"}
@@ -43,6 +43,9 @@ const react_native_modal_1 = __importDefault(require("react-native-modal"));
43
43
  const XeboSurveyManager_1 = require("../core/XeboSurveyManager");
44
44
  const XeboModels_1 = require("../models/XeboModels");
45
45
  const XeboTheme_1 = require("../theme/XeboTheme");
46
+ const XeboStrings_1 = require("../i18n/XeboStrings");
47
+ const XeboRtl_1 = require("../i18n/XeboRtl");
48
+ const XeboLanguageView_1 = require("./XeboLanguageView");
46
49
  const XeboIntroView_1 = require("./XeboIntroView");
47
50
  const XeboThankYouView_1 = require("./XeboThankYouView");
48
51
  const XeboSingleChoiceView_1 = require("./XeboSingleChoiceView");
@@ -53,8 +56,13 @@ const XeboNPSView_1 = require("./XeboNPSView");
53
56
  const XeboMultiNPSView_1 = require("./XeboMultiNPSView");
54
57
  const XeboRatingView_1 = require("./XeboRatingView");
55
58
  const XeboMultiRatingView_1 = require("./XeboMultiRatingView");
56
- function computeSheetHeight(question, screen, sh) {
57
- var _a, _b, _c, _d, _e, _f, _g, _h;
59
+ function computeSheetHeight(question, screen, sh, languagePage) {
60
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
61
+ if (screen === 'language') {
62
+ const rows = (_a = languagePage === null || languagePage === void 0 ? void 0 : languagePage.options.length) !== null && _a !== void 0 ? _a : 2;
63
+ const prompts = (_b = languagePage === null || languagePage === void 0 ? void 0 : languagePage.prompts.length) !== null && _b !== void 0 ? _b : 1;
64
+ return Math.min(sh * 0.70, sh * (0.10 + rows * 0.085 + prompts * 0.055));
65
+ }
58
66
  if (screen === 'thankYou')
59
67
  return sh * 0.30;
60
68
  if (screen === 'intro')
@@ -64,11 +72,11 @@ function computeSheetHeight(question, screen, sh) {
64
72
  switch (question.type) {
65
73
  case XeboModels_1.XeboQuestionType.multiNps:
66
74
  case XeboModels_1.XeboQuestionType.multiRating: {
67
- const rowCount = (_b = (_a = question.options) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 3;
75
+ const rowCount = (_d = (_c = question.options) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 3;
68
76
  return Math.min(sh * 0.75, sh * (0.25 + rowCount * 0.13));
69
77
  }
70
78
  case XeboModels_1.XeboQuestionType.nps:
71
- return ((_d = (_c = question.conditionalFollowUps) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) > 0
79
+ return ((_f = (_e = question.conditionalFollowUps) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0
72
80
  ? sh * 0.60
73
81
  : sh * 0.38;
74
82
  case XeboModels_1.XeboQuestionType.rating:
@@ -76,14 +84,14 @@ function computeSheetHeight(question, screen, sh) {
76
84
  case XeboModels_1.XeboQuestionType.singleTextBox:
77
85
  return sh * 0.38;
78
86
  case XeboModels_1.XeboQuestionType.multipleTextBox: {
79
- const fieldCount = (_f = (_e = question.options) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 1;
87
+ const fieldCount = (_h = (_g = question.options) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 1;
80
88
  return Math.min(sh * 0.70, sh * (0.28 + fieldCount * 0.10));
81
89
  }
82
90
  case XeboModels_1.XeboQuestionType.dropdown:
83
91
  return sh * 0.62;
84
92
  case XeboModels_1.XeboQuestionType.singleChoice:
85
93
  case XeboModels_1.XeboQuestionType.multipleChoice: {
86
- const optCount = (_h = (_g = question.options) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0;
94
+ const optCount = (_k = (_j = question.options) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0;
87
95
  return Math.min(sh * 0.75, sh * (0.26 + optCount * 0.08));
88
96
  }
89
97
  default:
@@ -91,15 +99,24 @@ function computeSheetHeight(question, screen, sh) {
91
99
  }
92
100
  }
93
101
  const XeboSurveyModal = () => {
94
- var _a;
102
+ var _a, _b;
95
103
  const theme = (0, XeboTheme_1.getTheme)();
96
104
  // Always get the live window dimensions — fixes stale height on Android first open
97
105
  const { height: windowHeight } = (0, react_native_1.useWindowDimensions)();
98
106
  const screenDims = react_native_1.Dimensions.get('screen');
107
+ // screen - window also covers the status bar, so subtract it to get the nav bar alone.
108
+ const statusBarHeight = react_native_1.Platform.OS === 'android' ? ((_a = react_native_1.StatusBar.currentHeight) !== null && _a !== void 0 ? _a : 0) : 0;
99
109
  const androidNavBar = react_native_1.Platform.OS === 'android'
100
- ? Math.max(0, screenDims.height - windowHeight)
110
+ ? Math.max(0, screenDims.height - windowHeight - statusBarHeight)
111
+ : 0;
112
+ const bottomInset = react_native_1.Platform.OS === 'ios' ? 34 : Math.max(12, androidNavBar);
113
+ // Android edge-to-edge: the modal window spans the whole screen, but RN (0.77) can lay
114
+ // its content out shorter (screen minus status bar), leaving a gap under the sheet.
115
+ // Measure the real content height and pull the sheet down by the difference.
116
+ const [modalRootHeight, setModalRootHeight] = (0, react_1.useState)(0);
117
+ const androidRootGap = react_native_1.Platform.OS === 'android' && modalRootHeight > 0
118
+ ? Math.max(0, screenDims.height - modalRootHeight)
101
119
  : 0;
102
- const bottomInset = react_native_1.Platform.OS === 'ios' ? 34 : Math.max(34, androidNavBar);
103
120
  // Slides the sheet above the keyboard when any TextInput is focused.
104
121
  const shiftAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
105
122
  const sheetHeightRef = (0, react_1.useRef)(0);
@@ -107,7 +124,11 @@ const XeboSurveyModal = () => {
107
124
  const [survey, setSurvey] = (0, react_1.useState)(null);
108
125
  const [screen, setScreen] = (0, react_1.useState)('intro');
109
126
  const [questionIndex, setQuestionIndex] = (0, react_1.useState)(0);
110
- const sheetHeight = (0, react_1.useMemo)(() => { var _a; return computeSheetHeight((_a = survey === null || survey === void 0 ? void 0 : survey.questions[questionIndex]) !== null && _a !== void 0 ? _a : null, screen, windowHeight); }, [survey, questionIndex, screen, windowHeight]);
127
+ const [languagePage, setLanguagePage] = (0, react_1.useState)(null);
128
+ const [selectedLangKey, setSelectedLangKey] = (0, react_1.useState)(null);
129
+ const [languageBusy, setLanguageBusy] = (0, react_1.useState)(false);
130
+ const strings = (0, XeboStrings_1.getStrings)();
131
+ const sheetHeight = (0, react_1.useMemo)(() => { var _a; return computeSheetHeight((_a = survey === null || survey === void 0 ? void 0 : survey.questions[questionIndex]) !== null && _a !== void 0 ? _a : null, screen, windowHeight, languagePage); }, [survey, questionIndex, screen, windowHeight, languagePage]);
111
132
  sheetHeightRef.current = sheetHeight;
112
133
  // ─── Keyboard: slide sheet above keyboard when any TextInput focuses ──────
113
134
  (0, react_1.useEffect)(() => {
@@ -142,9 +163,19 @@ const XeboSurveyModal = () => {
142
163
  const onVisible = (v) => {
143
164
  var _a;
144
165
  if (v) {
166
+ // The manager clears languagePage once a language resolves, so it decides the screen.
167
+ const page = XeboSurveyManager_1.XeboSurveyManager.languagePage;
168
+ if (page) {
169
+ setLanguagePage(page);
170
+ setScreen('language');
171
+ setVisible(true);
172
+ return;
173
+ }
145
174
  // Sync survey into React state before showing so first frame isn't blank
146
175
  const s = XeboSurveyManager_1.XeboSurveyManager.survey;
147
176
  setSurvey(s);
177
+ setLanguagePage(null);
178
+ setLanguageBusy(false);
148
179
  if ((_a = s === null || s === void 0 ? void 0 : s.introPage) === null || _a === void 0 ? void 0 : _a.enabled) {
149
180
  setScreen('intro');
150
181
  }
@@ -155,22 +186,38 @@ const XeboSurveyModal = () => {
155
186
  }
156
187
  setVisible(v);
157
188
  };
189
+ const onLanguagePage = (page) => {
190
+ setLanguagePage(page);
191
+ setSelectedLangKey(null);
192
+ setLanguageBusy(false);
193
+ setScreen('language');
194
+ };
158
195
  const onQuestionChanged = (idx) => {
159
196
  setQuestionIndex(idx);
160
197
  };
161
198
  XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_LOADED, onLoaded);
162
199
  XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_VISIBLE, onVisible);
163
200
  XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.QUESTION_CHANGED, onQuestionChanged);
201
+ XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.LANGUAGE_PAGE, onLanguagePage);
164
202
  return () => {
165
203
  XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_LOADED, onLoaded);
166
204
  XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_VISIBLE, onVisible);
167
205
  XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.QUESTION_CHANGED, onQuestionChanged);
206
+ XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.LANGUAGE_PAGE, onLanguagePage);
168
207
  };
169
208
  }, []);
170
209
  // ─── User actions ─────────────────────────────────────────────────────────
171
210
  const handleSkip = () => {
211
+ // Also aborts a translation still loading, so the survey never pops up after a skip.
212
+ setLanguageBusy(false);
213
+ setSelectedLangKey(null);
172
214
  XeboSurveyManager_1.XeboSurveyManager.dismissSurvey();
173
215
  };
216
+ const handleSelectLanguage = (langKey) => {
217
+ setSelectedLangKey(langKey);
218
+ setLanguageBusy(true);
219
+ XeboSurveyManager_1.XeboSurveyManager.selectLanguage(langKey);
220
+ };
174
221
  const handleIntroStart = () => {
175
222
  setScreen('question');
176
223
  setQuestionIndex(0);
@@ -220,6 +267,11 @@ const XeboSurveyModal = () => {
220
267
  }
221
268
  };
222
269
  const renderContent = () => {
270
+ if (screen === 'language') {
271
+ if (!languagePage)
272
+ return null;
273
+ return (<XeboLanguageView_1.XeboLanguageView page={languagePage} selectedLangKey={selectedLangKey} busy={languageBusy} onSelect={handleSelectLanguage}/>);
274
+ }
223
275
  if (!survey)
224
276
  return null;
225
277
  if (screen === 'intro' && survey.introPage) {
@@ -240,19 +292,30 @@ const XeboSurveyModal = () => {
240
292
  return null;
241
293
  };
242
294
  // ─── Render ───────────────────────────────────────────────────────────────
243
- return (<react_native_modal_1.default isVisible={visible} onBackButtonPress={handleSkip} backdropOpacity={0.5} backdropColor="#000000" style={styles.modal} animationIn="slideInUp" animationInTiming={350} animationOut="slideOutDown" animationOutTiming={300} useNativeDriver={true} useNativeDriverForBackdrop={true} hideModalContentWhileAnimating={true} coverScreen={true} propagateSwipe={false} onModalHide={() => {
295
+ return (<react_native_modal_1.default isVisible={visible} onBackButtonPress={handleSkip} backdropOpacity={0.5} backdropColor="#000000" style={styles.modal} animationIn="slideInUp" animationInTiming={350} animationOut="slideOutDown" animationOutTiming={300} useNativeDriver={true} useNativeDriverForBackdrop={true} hideModalContentWhileAnimating={true} coverScreen={true}
296
+ // Android 15+ draws edge-to-edge; without these the modal is offset by the
297
+ // status bar and stops short of the nav bar, so the sheet sits at the wrong height.
298
+ // The sheet's own bottomInset spacer keeps content clear of the nav bar.
299
+ statusBarTranslucent={true}
300
+ // RN 0.75+ prop, missing from the RN 0.73 types we build against; older RN ignores it.
301
+ {...{ navigationBarTranslucent: true }} propagateSwipe={false} onModalHide={() => {
244
302
  setSurvey(null);
303
+ setLanguagePage(null);
304
+ setSelectedLangKey(null);
305
+ setLanguageBusy(false);
245
306
  shiftAnim.setValue(0); // reset in case keyboard was open when modal closed
246
307
  }}>
247
308
  {/* Animated.View handles ONLY the keyboard shift (transform).
248
309
  The inner View owns height/layout so flex children compute correctly. */}
249
- <react_native_1.Animated.View style={{ transform: [{ translateY: shiftAnim }] }}>
310
+ <react_native_1.View pointerEvents="none" style={react_native_1.StyleSheet.absoluteFill} onLayout={e => setModalRootHeight(e.nativeEvent.layout.height)}/>
311
+ <react_native_1.Animated.View style={{ marginBottom: -androidRootGap, transform: [{ translateY: shiftAnim }] }}>
250
312
  <react_native_1.View style={[
251
313
  styles.sheet,
252
314
  {
253
315
  backgroundColor: theme.backgroundColor,
254
316
  height: sheetHeight,
255
317
  },
318
+ strings.direction === 'rtl' && styles.sheetRtl,
256
319
  ]}>
257
320
  {/* Handle bar */}
258
321
  <react_native_1.View style={styles.handleWrap}>
@@ -261,13 +324,22 @@ const XeboSurveyModal = () => {
261
324
 
262
325
  {/* Header row: Survey name / Skip or X close */}
263
326
  <react_native_1.View style={styles.headerRow}>
264
- <react_native_1.Text style={[styles.surveyName, { color: theme.textColor, fontFamily: theme.fontFamily }]} numberOfLines={1} ellipsizeMode="tail">
265
- {(_a = survey === null || survey === void 0 ? void 0 : survey.name) !== null && _a !== void 0 ? _a : ''}
327
+ <react_native_1.Text style={[
328
+ styles.surveyName,
329
+ { color: theme.textColor, fontFamily: theme.fontFamily },
330
+ (0, XeboRtl_1.rtlText)(),
331
+ ]} numberOfLines={1} ellipsizeMode="tail">
332
+ {(_b = survey === null || survey === void 0 ? void 0 : survey.name) !== null && _b !== void 0 ? _b : ''}
266
333
  </react_native_1.Text>
267
334
  {screen === 'thankYou' ? (<react_native_1.TouchableOpacity onPress={handleSkip} style={styles.closeButton} activeOpacity={0.7}>
268
- <react_native_1.Text style={[styles.closeText, { color: theme.textColor }]}>✕</react_native_1.Text>
335
+ <react_native_1.Text style={[
336
+ strings.localized ? styles.skipText : styles.closeText,
337
+ { color: theme.textColor },
338
+ ]}>
339
+ {strings.localized ? strings.close : '✕'}
340
+ </react_native_1.Text>
269
341
  </react_native_1.TouchableOpacity>) : (<react_native_1.TouchableOpacity onPress={handleSkip} style={styles.skipButton} activeOpacity={0.7}>
270
- <react_native_1.Text style={[styles.skipText, { color: theme.textColor }]}>Skip</react_native_1.Text>
342
+ <react_native_1.Text style={[styles.skipText, { color: theme.textColor }]}>{strings.skip}</react_native_1.Text>
271
343
  </react_native_1.TouchableOpacity>)}
272
344
  </react_native_1.View>
273
345
 
@@ -287,6 +359,9 @@ const styles = react_native_1.StyleSheet.create({
287
359
  justifyContent: 'flex-end',
288
360
  margin: 0,
289
361
  },
362
+ sheetRtl: {
363
+ direction: 'rtl',
364
+ },
290
365
  sheet: {
291
366
  borderTopLeftRadius: 16,
292
367
  borderTopRightRadius: 16,
@@ -316,11 +391,14 @@ const styles = react_native_1.StyleSheet.create({
316
391
  paddingBottom: 4,
317
392
  },
318
393
  surveyName: {
319
- flex: 1,
394
+ // Explicit basis: `flex: 1` alone does not reliably expand a Text inside an RTL row.
395
+ flexGrow: 1,
396
+ flexShrink: 1,
397
+ flexBasis: 0,
320
398
  fontSize: 13,
321
399
  fontWeight: '600',
322
400
  opacity: 0.5,
323
- marginRight: 8,
401
+ marginEnd: 8,
324
402
  },
325
403
  skipButton: {
326
404
  paddingHorizontal: 12,
@@ -1 +1 @@
1
- {"version":3,"file":"XeboTextBoxView.d.ts","sourceRoot":"","sources":["../../src/components/XeboTextBoxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAWhD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AAGlF,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,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAmH3C,CAAC"}
1
+ {"version":3,"file":"XeboTextBoxView.d.ts","sourceRoot":"","sources":["../../src/components/XeboTextBoxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAWhD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AAKlF,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,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAoH3C,CAAC"}
@@ -38,6 +38,8 @@ 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 XeboStrings_1 = require("../i18n/XeboStrings");
42
+ const XeboRtl_1 = require("../i18n/XeboRtl");
41
43
  const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
42
44
  const theme = (0, XeboTheme_1.getTheme)();
43
45
  const isMulti = question.type === XeboModels_1.XeboQuestionType.multipleTextBox;
@@ -69,7 +71,7 @@ const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
69
71
  if (question.isRequired) {
70
72
  const empty = fields.some(f => { var _a; return !((_a = values[f.id]) !== null && _a !== void 0 ? _a : '').trim(); });
71
73
  if (empty) {
72
- setError('Please fill in all fields.');
74
+ setError((0, XeboStrings_1.requiredMessage)(question, 'Please fill in all fields.'));
73
75
  shake();
74
76
  return;
75
77
  }
@@ -84,17 +86,17 @@ const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
84
86
  };
85
87
  return (<react_native_1.View style={styles.outer}>
86
88
  <react_native_1.ScrollView ref={scrollRef} style={styles.scroll} contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
87
- <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
89
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
88
90
  {question.title}
89
91
  </react_native_1.Text>
90
- {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
92
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
91
93
  {question.subtitle}
92
94
  </react_native_1.Text>)}
93
95
 
94
96
  {fields.map((field, idx) => {
95
97
  var _a;
96
98
  return (<react_native_1.View key={field.id} style={styles.fieldWrap}>
97
- {isMulti && !!field.text && (<react_native_1.Text style={[styles.fieldLabel, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
99
+ {isMulti && !!field.text && (<react_native_1.Text style={[styles.fieldLabel, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
98
100
  {field.text}
99
101
  </react_native_1.Text>)}
100
102
  <react_native_1.TextInput style={[
@@ -106,17 +108,18 @@ const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
106
108
  borderRadius: theme.cornerRadius,
107
109
  minHeight: 48,
108
110
  },
111
+ (0, XeboRtl_1.rtlText)(),
109
112
  ]} placeholder={isMulti ? '' : (question.placeholder || 'Type your answer here...')} placeholderTextColor="#9CA3AF" value={(_a = values[field.id]) !== null && _a !== void 0 ? _a : ''} onChangeText={text => handleChange(field.id, text)} onFocus={() => handleFocus(idx)} multiline={!isMulti} numberOfLines={isMulti ? 1 : 4} textAlignVertical={isMulti ? 'center' : 'top'} returnKeyType={idx === fields.length - 1 ? 'done' : 'next'}/>
110
113
  </react_native_1.View>);
111
114
  })}
112
115
  </react_native_1.ScrollView>
113
116
 
114
117
  {/* Error + button always visible at bottom, outside scroll */}
115
- {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
118
+ {!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
116
119
  <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
117
120
  <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleSubmit} activeOpacity={0.8}>
118
121
  <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
119
- {isLastQuestion ? 'Submit' : 'Next'}
122
+ {(0, XeboStrings_1.actionLabel)(isLastQuestion)}
120
123
  </react_native_1.Text>
121
124
  </react_native_1.TouchableOpacity>
122
125
  </react_native_1.Animated.View>
@@ -126,7 +129,7 @@ exports.XeboTextBoxView = XeboTextBoxView;
126
129
  const styles = react_native_1.StyleSheet.create({
127
130
  outer: {
128
131
  paddingHorizontal: 20,
129
- paddingBottom: 24,
132
+ paddingBottom: 10,
130
133
  },
131
134
  scroll: {
132
135
  maxHeight: 340,
@@ -1 +1 @@
1
- {"version":3,"file":"XeboThankYouView.d.ts","sourceRoot":"","sources":["../../src/components/XeboThankYouView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAQjD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+C5C,CAAC"}
1
+ {"version":3,"file":"XeboThankYouView.d.ts","sourceRoot":"","sources":["../../src/components/XeboThankYouView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAQjD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+C5C,CAAC"}
@@ -37,6 +37,7 @@ exports.XeboThankYouView = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
39
  const XeboTheme_1 = require("../theme/XeboTheme");
40
+ const XeboRtl_1 = require("../i18n/XeboRtl");
40
41
  const XeboThankYouView = ({ question, onDismiss }) => {
41
42
  const theme = (0, XeboTheme_1.getTheme)();
42
43
  const fadeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
@@ -68,11 +69,11 @@ const XeboThankYouView = ({ question, onDismiss }) => {
68
69
  <react_native_1.Text style={styles.checkmark}>✓</react_native_1.Text>
69
70
  </react_native_1.View>
70
71
 
71
- <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
72
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
72
73
  {question.title}
73
74
  </react_native_1.Text>
74
75
 
75
- {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
76
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
76
77
  {question.subtitle}
77
78
  </react_native_1.Text>)}
78
79
  </react_native_1.Animated.View>);
@@ -0,0 +1,28 @@
1
+ import { APILangScript, APILanguageEntry, APILangSettings, APIPrimaryLang, XeboLanguageOption, XeboLanguagePageModel, XeboTextMapping } from '../models/XeboLanguageModels';
2
+ /** Slug the backend uses for the language-page prompt. */
3
+ export declare const SCREENER_PROMPT_KEY = "which-language-do-you-want-to-take-survey";
4
+ /** Survey JSON carrying the language blocks; kept loose so we can merge into it. */
5
+ export interface RawSurveyData {
6
+ uuid?: string;
7
+ primaryLang?: APIPrimaryLang | null;
8
+ languages?: APILanguageEntry[] | null;
9
+ langSettings?: APILangSettings | null;
10
+ [key: string]: unknown;
11
+ }
12
+ /** Backend sends null or "" for untranslated values; never let "null" through. */
13
+ export declare function translatedText(value: unknown): string | undefined;
14
+ export declare function buildLanguageOptions(data: RawSurveyData): XeboLanguageOption[];
15
+ export declare function findLanguageOption(data: RawSurveyData, langKey: string | undefined): XeboLanguageOption | undefined;
16
+ /** Show the page when changing is allowed, a real alternative exists, and no valid language was passed. */
17
+ export declare function shouldShowLanguagePage(data: RawSurveyData, language?: string): boolean;
18
+ /** One prompt per screenerTextLang key; the primary uses screenerText, others their langScript. */
19
+ export declare function buildLanguagePage(data: RawSurveyData): XeboLanguagePageModel;
20
+ export interface TranslationBundle {
21
+ textMapping: XeboTextMapping;
22
+ script: APILangScript | undefined;
23
+ }
24
+ /** PUT getLanguage; works unauthenticated but we send the token when we have one. */
25
+ export declare function fetchTranslation(baseURL: string, surveyId: string, option: XeboLanguageOption, bearerToken?: string): Promise<TranslationBundle>;
26
+ /** Merge a textMapping into a copy of the raw survey, matching nodes by uuid. */
27
+ export declare function applyTranslation<T extends RawSurveyData>(data: T, textMapping: XeboTextMapping): T;
28
+ //# sourceMappingURL=XeboLanguageService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboLanguageService.d.ts","sourceRoot":"","sources":["../../src/core/XeboLanguageService.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,qBAAqB,EAGrB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAEtC,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,8CAA8C,CAAC;AAE/E,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;IACpC,SAAS,CAAC,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IACtC,YAAY,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAID,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAKjE;AAaD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,aAAa,GAAG,kBAAkB,EAAE,CAmC9E;AAED,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,kBAAkB,GAAG,SAAS,CAIhC;AAED,2GAA2G;AAC3G,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAKtF;AAED,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,qBAAqB,CAuB5E;AAID,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;CACnC;AAED,qFAAqF;AACrF,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,kBAAkB,EAC1B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,iBAAiB,CAAC,CA+B5B;AA2FD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,eAAe,GAAG,CAAC,CA+BlG"}