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.
- package/dist/components/XeboDropdownView.d.ts +6 -2
- package/dist/components/XeboDropdownView.d.ts.map +1 -1
- package/dist/components/XeboDropdownView.js +35 -22
- package/dist/components/XeboIntroView.d.ts.map +1 -1
- package/dist/components/XeboIntroView.js +3 -2
- package/dist/components/XeboLanguageView.d.ts +11 -0
- package/dist/components/XeboLanguageView.d.ts.map +1 -0
- package/dist/components/XeboLanguageView.js +90 -0
- package/dist/components/XeboMultiNPSView.d.ts +4 -2
- package/dist/components/XeboMultiNPSView.d.ts.map +1 -1
- package/dist/components/XeboMultiNPSView.js +32 -23
- package/dist/components/XeboMultiRatingView.d.ts +4 -2
- package/dist/components/XeboMultiRatingView.d.ts.map +1 -1
- package/dist/components/XeboMultiRatingView.js +31 -22
- package/dist/components/XeboMultipleChoiceView.d.ts +6 -2
- package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -1
- package/dist/components/XeboMultipleChoiceView.js +43 -44
- package/dist/components/XeboNPSView.d.ts +8 -2
- package/dist/components/XeboNPSView.d.ts.map +1 -1
- package/dist/components/XeboNPSView.js +315 -55
- package/dist/components/XeboPageView.d.ts +33 -0
- package/dist/components/XeboPageView.d.ts.map +1 -0
- package/dist/components/XeboPageView.js +190 -0
- package/dist/components/XeboRatingView.d.ts +20 -2
- package/dist/components/XeboRatingView.d.ts.map +1 -1
- package/dist/components/XeboRatingView.js +71 -43
- package/dist/components/XeboSingleChoiceView.d.ts +8 -2
- package/dist/components/XeboSingleChoiceView.d.ts.map +1 -1
- package/dist/components/XeboSingleChoiceView.js +50 -46
- package/dist/components/XeboSurveyModal.d.ts.map +1 -1
- package/dist/components/XeboSurveyModal.js +236 -42
- package/dist/components/XeboTextBoxView.d.ts +4 -2
- package/dist/components/XeboTextBoxView.d.ts.map +1 -1
- package/dist/components/XeboTextBoxView.js +35 -23
- package/dist/components/XeboThankYouView.d.ts.map +1 -1
- package/dist/components/XeboThankYouView.js +3 -2
- package/dist/core/XeboLanguageService.d.ts +28 -0
- package/dist/core/XeboLanguageService.d.ts.map +1 -0
- package/dist/core/XeboLanguageService.js +267 -0
- package/dist/core/XeboNetworkService.d.ts +24 -3
- package/dist/core/XeboNetworkService.d.ts.map +1 -1
- package/dist/core/XeboNetworkService.js +202 -69
- package/dist/core/XeboOfflineQueue.d.ts +2 -1
- package/dist/core/XeboOfflineQueue.d.ts.map +1 -1
- package/dist/core/XeboOfflineQueue.js +24 -10
- package/dist/core/XeboSurveyManager.d.ts +38 -2
- package/dist/core/XeboSurveyManager.d.ts.map +1 -1
- package/dist/core/XeboSurveyManager.js +246 -72
- package/dist/i18n/XeboRtl.d.ts +16 -0
- package/dist/i18n/XeboRtl.d.ts.map +1 -0
- package/dist/i18n/XeboRtl.js +32 -0
- package/dist/i18n/XeboStrings.d.ts +35 -0
- package/dist/i18n/XeboStrings.d.ts.map +1 -0
- package/dist/i18n/XeboStrings.js +73 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/models/XeboAPIModels.d.ts +103 -1
- package/dist/models/XeboAPIModels.d.ts.map +1 -1
- package/dist/models/XeboLanguageModels.d.ts +62 -0
- package/dist/models/XeboLanguageModels.d.ts.map +1 -0
- package/dist/models/XeboLanguageModels.js +3 -0
- package/dist/models/XeboModels.d.ts +93 -2
- package/dist/models/XeboModels.d.ts.map +1 -1
- package/dist/models/XeboModels.js +24 -0
- package/package.json +5 -5
|
@@ -40,9 +40,13 @@ exports.XeboSurveyModal = void 0;
|
|
|
40
40
|
const react_1 = __importStar(require("react"));
|
|
41
41
|
const react_native_1 = require("react-native");
|
|
42
42
|
const react_native_modal_1 = __importDefault(require("react-native-modal"));
|
|
43
|
+
const react_native_safe_area_context_1 = require("react-native-safe-area-context");
|
|
43
44
|
const XeboSurveyManager_1 = require("../core/XeboSurveyManager");
|
|
44
45
|
const XeboModels_1 = require("../models/XeboModels");
|
|
45
46
|
const XeboTheme_1 = require("../theme/XeboTheme");
|
|
47
|
+
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
48
|
+
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
49
|
+
const XeboLanguageView_1 = require("./XeboLanguageView");
|
|
46
50
|
const XeboIntroView_1 = require("./XeboIntroView");
|
|
47
51
|
const XeboThankYouView_1 = require("./XeboThankYouView");
|
|
48
52
|
const XeboSingleChoiceView_1 = require("./XeboSingleChoiceView");
|
|
@@ -53,8 +57,14 @@ const XeboNPSView_1 = require("./XeboNPSView");
|
|
|
53
57
|
const XeboMultiNPSView_1 = require("./XeboMultiNPSView");
|
|
54
58
|
const XeboRatingView_1 = require("./XeboRatingView");
|
|
55
59
|
const XeboMultiRatingView_1 = require("./XeboMultiRatingView");
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
const XeboPageView_1 = require("./XeboPageView");
|
|
61
|
+
function computeSheetHeight(question, screen, sh, languagePage, bottomInset) {
|
|
62
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
63
|
+
if (screen === 'language') {
|
|
64
|
+
const rows = (_a = languagePage === null || languagePage === void 0 ? void 0 : languagePage.options.length) !== null && _a !== void 0 ? _a : 2;
|
|
65
|
+
const prompts = (_b = languagePage === null || languagePage === void 0 ? void 0 : languagePage.prompts.length) !== null && _b !== void 0 ? _b : 1;
|
|
66
|
+
return Math.min(sh * 0.70, sh * (0.10 + rows * 0.085 + prompts * 0.055));
|
|
67
|
+
}
|
|
58
68
|
if (screen === 'thankYou')
|
|
59
69
|
return sh * 0.30;
|
|
60
70
|
if (screen === 'intro')
|
|
@@ -64,11 +74,11 @@ function computeSheetHeight(question, screen, sh) {
|
|
|
64
74
|
switch (question.type) {
|
|
65
75
|
case XeboModels_1.XeboQuestionType.multiNps:
|
|
66
76
|
case XeboModels_1.XeboQuestionType.multiRating: {
|
|
67
|
-
const rowCount = (
|
|
77
|
+
const rowCount = (_d = (_c = question.options) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 3;
|
|
68
78
|
return Math.min(sh * 0.75, sh * (0.25 + rowCount * 0.13));
|
|
69
79
|
}
|
|
70
80
|
case XeboModels_1.XeboQuestionType.nps:
|
|
71
|
-
return ((
|
|
81
|
+
return ((_f = (_e = question.conditionalFollowUps) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0) > 0
|
|
72
82
|
? sh * 0.60
|
|
73
83
|
: sh * 0.38;
|
|
74
84
|
case XeboModels_1.XeboQuestionType.rating:
|
|
@@ -76,56 +86,128 @@ function computeSheetHeight(question, screen, sh) {
|
|
|
76
86
|
case XeboModels_1.XeboQuestionType.singleTextBox:
|
|
77
87
|
return sh * 0.38;
|
|
78
88
|
case XeboModels_1.XeboQuestionType.multipleTextBox: {
|
|
79
|
-
const fieldCount = (
|
|
89
|
+
const fieldCount = (_h = (_g = question.options) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 1;
|
|
80
90
|
return Math.min(sh * 0.70, sh * (0.28 + fieldCount * 0.10));
|
|
81
91
|
}
|
|
82
92
|
case XeboModels_1.XeboQuestionType.dropdown:
|
|
83
93
|
return sh * 0.62;
|
|
84
94
|
case XeboModels_1.XeboQuestionType.singleChoice:
|
|
85
95
|
case XeboModels_1.XeboQuestionType.multipleChoice: {
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
// Sized in dp from the view's layout (≈200 for header, title and button, ≈61 per option row);
|
|
97
|
+
// a share of screen height left a gap on tall phones.
|
|
98
|
+
const optCount = (_k = (_j = question.options) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0;
|
|
99
|
+
const subtitle = question.subtitle ? 36 : 0;
|
|
100
|
+
return Math.min(sh * 0.75, 200 + subtitle + optCount * 61 + bottomInset);
|
|
88
101
|
}
|
|
89
102
|
default:
|
|
90
103
|
return sh * 0.45;
|
|
91
104
|
}
|
|
92
105
|
}
|
|
93
|
-
|
|
106
|
+
// With the survey's auto-advance on, a single-tap answer moves on to the next question or page.
|
|
107
|
+
const AUTO_ADVANCE_TYPES = [
|
|
108
|
+
XeboModels_1.XeboQuestionType.singleChoice,
|
|
109
|
+
XeboModels_1.XeboQuestionType.dropdown,
|
|
110
|
+
XeboModels_1.XeboQuestionType.nps,
|
|
111
|
+
XeboModels_1.XeboQuestionType.rating,
|
|
112
|
+
];
|
|
113
|
+
// A follow-up opens under the answer, so those questions wait for their Ok / Next buttons.
|
|
114
|
+
function autoAdvances(survey, q) {
|
|
94
115
|
var _a;
|
|
116
|
+
return !!survey.autoAdvance
|
|
117
|
+
&& AUTO_ADVANCE_TYPES.includes(q.type)
|
|
118
|
+
&& !((_a = q.conditionalFollowUps) === null || _a === void 0 ? void 0 : _a.length)
|
|
119
|
+
&& !q.followUpQuestion;
|
|
120
|
+
}
|
|
121
|
+
// The web drops Ok / Next only for NPS; other auto-advancing types (e.g. rating) keep them.
|
|
122
|
+
function hidesButtons(survey, q) {
|
|
123
|
+
return autoAdvances(survey, q) && q.type === XeboModels_1.XeboQuestionType.nps;
|
|
124
|
+
}
|
|
125
|
+
const XeboSurveyModal = () => {
|
|
126
|
+
var _a, _b, _c, _d;
|
|
95
127
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
96
128
|
// Always get the live window dimensions — fixes stale height on Android first open
|
|
97
129
|
const { height: windowHeight } = (0, react_native_1.useWindowDimensions)();
|
|
98
130
|
const screenDims = react_native_1.Dimensions.get('screen');
|
|
131
|
+
// screen - window also covers the status bar, so subtract it to get the nav bar alone.
|
|
132
|
+
const statusBarHeight = react_native_1.Platform.OS === 'android' ? ((_a = react_native_1.StatusBar.currentHeight) !== null && _a !== void 0 ? _a : 0) : 0;
|
|
99
133
|
const androidNavBar = react_native_1.Platform.OS === 'android'
|
|
100
|
-
? Math.max(0, screenDims.height - windowHeight)
|
|
134
|
+
? Math.max(0, screenDims.height - windowHeight - statusBarHeight)
|
|
135
|
+
: 0;
|
|
136
|
+
// Real system inset: 3-button nav, gesture bar, home indicator, or none (Touch ID iPhones).
|
|
137
|
+
// Falls back to the estimate if the native metrics aren't available.
|
|
138
|
+
const systemBottomInset = (_b = react_native_safe_area_context_1.initialWindowMetrics === null || react_native_safe_area_context_1.initialWindowMetrics === void 0 ? void 0 : react_native_safe_area_context_1.initialWindowMetrics.insets.bottom) !== null && _b !== void 0 ? _b : (react_native_1.Platform.OS === 'ios' ? 34 : androidNavBar);
|
|
139
|
+
const bottomInset = Math.max(12, systemBottomInset);
|
|
140
|
+
// Android edge-to-edge: the modal window spans the whole screen, but RN (0.77) can lay
|
|
141
|
+
// its content out shorter (screen minus status bar), leaving a gap under the sheet.
|
|
142
|
+
// Measure the real content height and pull the sheet down by the difference.
|
|
143
|
+
// full = tallest measured (keyboard closed); current = after the keyboard resizes the modal.
|
|
144
|
+
const [modalRoot, setModalRoot] = (0, react_1.useState)({ full: 0, current: 0 });
|
|
145
|
+
const androidRootGap = react_native_1.Platform.OS === 'android' && modalRoot.full > 0
|
|
146
|
+
? Math.max(0, screenDims.height - modalRoot.full)
|
|
101
147
|
: 0;
|
|
102
|
-
|
|
103
|
-
// Slides the sheet above the keyboard when any TextInput is focused.
|
|
148
|
+
// Slides the sheet above the keyboard when any TextInput is focused (iOS).
|
|
104
149
|
const shiftAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
150
|
+
// Android lifts via layout instead, since the modal window may already resize for the keyboard.
|
|
151
|
+
const [androidKeyboardHeight, setAndroidKeyboardHeight] = (0, react_1.useState)(0);
|
|
105
152
|
const sheetHeightRef = (0, react_1.useRef)(0);
|
|
106
153
|
const [visible, setVisible] = (0, react_1.useState)(false);
|
|
107
154
|
const [survey, setSurvey] = (0, react_1.useState)(null);
|
|
108
155
|
const [screen, setScreen] = (0, react_1.useState)('intro');
|
|
109
156
|
const [questionIndex, setQuestionIndex] = (0, react_1.useState)(0);
|
|
110
|
-
const
|
|
157
|
+
const [languagePage, setLanguagePage] = (0, react_1.useState)(null);
|
|
158
|
+
const [selectedLangKey, setSelectedLangKey] = (0, react_1.useState)(null);
|
|
159
|
+
const [languageBusy, setLanguageBusy] = (0, react_1.useState)(false);
|
|
160
|
+
const [disqualified, setDisqualified] = (0, react_1.useState)(false);
|
|
161
|
+
// Counts questions actually shown, so logic that skips questions doesn't leave gaps.
|
|
162
|
+
const [questionNumber, setQuestionNumber] = (0, react_1.useState)(1);
|
|
163
|
+
// Height a choice view measured it needs; applies only to the question that reported it.
|
|
164
|
+
const [fitHeight, setFitHeight] = (0, react_1.useState)(null);
|
|
165
|
+
const strings = (0, XeboStrings_1.getStrings)();
|
|
166
|
+
const currentQuestion = (_c = survey === null || survey === void 0 ? void 0 : survey.questions[questionIndex]) !== null && _c !== void 0 ? _c : null;
|
|
167
|
+
// Questions shown together on this page; more than one when the survey has no page break between them.
|
|
168
|
+
const pageSize = screen === 'question' ? XeboSurveyManager_1.XeboSurveyManager.currentPage.length : 0;
|
|
169
|
+
const pageRefs = (0, react_1.useRef)({});
|
|
170
|
+
const pageViewRef = (0, react_1.useRef)(null);
|
|
171
|
+
const sheetHeight = (0, react_1.useMemo)(() => {
|
|
172
|
+
if (screen === 'question' && fitHeight && fitHeight.questionId === (currentQuestion === null || currentQuestion === void 0 ? void 0 : currentQuestion.id)) {
|
|
173
|
+
return Math.min(windowHeight * 0.75, fitHeight.height);
|
|
174
|
+
}
|
|
175
|
+
if (pageSize > 1)
|
|
176
|
+
return windowHeight * 0.75;
|
|
177
|
+
return computeSheetHeight(currentQuestion, screen, windowHeight, languagePage, bottomInset);
|
|
178
|
+
}, [currentQuestion, screen, windowHeight, languagePage, bottomInset, fitHeight, pageSize]);
|
|
111
179
|
sheetHeightRef.current = sheetHeight;
|
|
180
|
+
const androidKeyboardLift = Math.max(0, Math.min(androidKeyboardHeight, windowHeight - sheetHeight) - (modalRoot.full - modalRoot.current));
|
|
181
|
+
const handleFitHeight = (0, react_1.useCallback)((questionId, delta) => {
|
|
182
|
+
if (Math.abs(delta) < 1)
|
|
183
|
+
return;
|
|
184
|
+
setFitHeight({ questionId, height: sheetHeightRef.current + delta });
|
|
185
|
+
}, []);
|
|
112
186
|
// ─── Keyboard: slide sheet above keyboard when any TextInput focuses ──────
|
|
113
187
|
(0, react_1.useEffect)(() => {
|
|
114
188
|
const showEvent = react_native_1.Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
|
|
115
189
|
const hideEvent = react_native_1.Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
|
|
116
190
|
const onShow = (e) => {
|
|
117
191
|
const kh = e.endCoordinates.height;
|
|
192
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
193
|
+
setAndroidKeyboardHeight(kh);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
118
196
|
const maxShift = Math.max(0, windowHeight - sheetHeightRef.current);
|
|
119
197
|
react_native_1.Animated.timing(shiftAnim, {
|
|
120
198
|
toValue: -Math.min(kh, maxShift),
|
|
121
|
-
duration:
|
|
199
|
+
duration: 250,
|
|
122
200
|
useNativeDriver: true,
|
|
123
201
|
}).start();
|
|
124
202
|
};
|
|
125
203
|
const onHide = () => {
|
|
204
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
205
|
+
setAndroidKeyboardHeight(0);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
126
208
|
react_native_1.Animated.timing(shiftAnim, {
|
|
127
209
|
toValue: 0,
|
|
128
|
-
duration:
|
|
210
|
+
duration: 200,
|
|
129
211
|
useNativeDriver: true,
|
|
130
212
|
}).start();
|
|
131
213
|
};
|
|
@@ -142,9 +224,21 @@ const XeboSurveyModal = () => {
|
|
|
142
224
|
const onVisible = (v) => {
|
|
143
225
|
var _a;
|
|
144
226
|
if (v) {
|
|
227
|
+
// The manager clears languagePage once a language resolves, so it decides the screen.
|
|
228
|
+
const page = XeboSurveyManager_1.XeboSurveyManager.languagePage;
|
|
229
|
+
if (page) {
|
|
230
|
+
setLanguagePage(page);
|
|
231
|
+
setScreen('language');
|
|
232
|
+
setVisible(true);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
145
235
|
// Sync survey into React state before showing so first frame isn't blank
|
|
146
236
|
const s = XeboSurveyManager_1.XeboSurveyManager.survey;
|
|
147
237
|
setSurvey(s);
|
|
238
|
+
setLanguagePage(null);
|
|
239
|
+
setLanguageBusy(false);
|
|
240
|
+
setDisqualified(false);
|
|
241
|
+
setQuestionNumber(1);
|
|
148
242
|
if ((_a = s === null || s === void 0 ? void 0 : s.introPage) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
149
243
|
setScreen('intro');
|
|
150
244
|
}
|
|
@@ -155,22 +249,38 @@ const XeboSurveyModal = () => {
|
|
|
155
249
|
}
|
|
156
250
|
setVisible(v);
|
|
157
251
|
};
|
|
252
|
+
const onLanguagePage = (page) => {
|
|
253
|
+
setLanguagePage(page);
|
|
254
|
+
setSelectedLangKey(null);
|
|
255
|
+
setLanguageBusy(false);
|
|
256
|
+
setScreen('language');
|
|
257
|
+
};
|
|
158
258
|
const onQuestionChanged = (idx) => {
|
|
159
259
|
setQuestionIndex(idx);
|
|
160
260
|
};
|
|
161
261
|
XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_LOADED, onLoaded);
|
|
162
262
|
XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_VISIBLE, onVisible);
|
|
163
263
|
XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.QUESTION_CHANGED, onQuestionChanged);
|
|
264
|
+
XeboSurveyManager_1.XeboSurveyManager.on(XeboSurveyManager_1.XEBO_EVENTS.LANGUAGE_PAGE, onLanguagePage);
|
|
164
265
|
return () => {
|
|
165
266
|
XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_LOADED, onLoaded);
|
|
166
267
|
XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.SURVEY_VISIBLE, onVisible);
|
|
167
268
|
XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.QUESTION_CHANGED, onQuestionChanged);
|
|
269
|
+
XeboSurveyManager_1.XeboSurveyManager.off(XeboSurveyManager_1.XEBO_EVENTS.LANGUAGE_PAGE, onLanguagePage);
|
|
168
270
|
};
|
|
169
271
|
}, []);
|
|
170
272
|
// ─── User actions ─────────────────────────────────────────────────────────
|
|
171
273
|
const handleSkip = () => {
|
|
274
|
+
// Also aborts a translation still loading, so the survey never pops up after a skip.
|
|
275
|
+
setLanguageBusy(false);
|
|
276
|
+
setSelectedLangKey(null);
|
|
172
277
|
XeboSurveyManager_1.XeboSurveyManager.dismissSurvey();
|
|
173
278
|
};
|
|
279
|
+
const handleSelectLanguage = (langKey) => {
|
|
280
|
+
setSelectedLangKey(langKey);
|
|
281
|
+
setLanguageBusy(true);
|
|
282
|
+
XeboSurveyManager_1.XeboSurveyManager.selectLanguage(langKey);
|
|
283
|
+
};
|
|
174
284
|
const handleIntroStart = () => {
|
|
175
285
|
setScreen('question');
|
|
176
286
|
setQuestionIndex(0);
|
|
@@ -180,39 +290,75 @@ const XeboSurveyModal = () => {
|
|
|
180
290
|
// NPS Pro sends [npsAnswer, followUpAnswer] — record each separately
|
|
181
291
|
const answers = Array.isArray(answer) ? answer : [answer];
|
|
182
292
|
answers.forEach(a => XeboSurveyManager_1.XeboSurveyManager.recordAnswer(a));
|
|
293
|
+
const answeredCount = XeboSurveyManager_1.XeboSurveyManager.currentPage.length || 1;
|
|
183
294
|
XeboSurveyManager_1.XeboSurveyManager.nextQuestion();
|
|
295
|
+
if (XeboSurveyManager_1.XeboSurveyManager.disqualified) {
|
|
296
|
+
setDisqualified(true);
|
|
297
|
+
setScreen('thankYou');
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
184
300
|
const s = XeboSurveyManager_1.XeboSurveyManager.survey;
|
|
185
301
|
const newIdx = XeboSurveyManager_1.XeboSurveyManager.currentQuestionIndex;
|
|
186
302
|
if (s && ((_a = s.questions[newIdx]) === null || _a === void 0 ? void 0 : _a.id) === 'thank_you_auto') {
|
|
187
303
|
setScreen('thankYou');
|
|
188
304
|
}
|
|
305
|
+
else {
|
|
306
|
+
setQuestionNumber(n => n + answeredCount);
|
|
307
|
+
}
|
|
189
308
|
}, []);
|
|
309
|
+
// Validates every question on the page (so all errors show), then submits them together.
|
|
310
|
+
const handlePageNext = () => {
|
|
311
|
+
const collected = XeboSurveyManager_1.XeboSurveyManager.currentPage.map(i => {
|
|
312
|
+
var _a, _b, _c;
|
|
313
|
+
const id = (_a = survey === null || survey === void 0 ? void 0 : survey.questions[i]) === null || _a === void 0 ? void 0 : _a.id;
|
|
314
|
+
return id ? (_c = (_b = pageRefs.current[id]) === null || _b === void 0 ? void 0 : _b.collect()) !== null && _c !== void 0 ? _c : null : null;
|
|
315
|
+
});
|
|
316
|
+
if (collected.some(a => a === null))
|
|
317
|
+
return;
|
|
318
|
+
handleAnswer([].concat(...collected));
|
|
319
|
+
};
|
|
320
|
+
// Numbering steps back by the size of the page returned to.
|
|
321
|
+
const handlePreviousPage = () => {
|
|
322
|
+
if (XeboSurveyManager_1.XeboSurveyManager.previousPage()) {
|
|
323
|
+
setQuestionNumber(n => Math.max(1, n - XeboSurveyManager_1.XeboSurveyManager.currentPage.length));
|
|
324
|
+
}
|
|
325
|
+
};
|
|
190
326
|
// ─── Question renderer ────────────────────────────────────────────────────
|
|
191
|
-
const renderQuestion = (question) => {
|
|
327
|
+
const renderQuestion = (question, number, isLast, embedded = false) => {
|
|
192
328
|
var _a;
|
|
193
|
-
const questions = (_a = survey === null || survey === void 0 ? void 0 : survey.questions) !== null && _a !== void 0 ? _a : [];
|
|
194
|
-
const lastRealIndex = questions.findIndex(q => q.id === 'thank_you_auto') - 1;
|
|
195
|
-
const isLast = questionIndex === lastRealIndex;
|
|
196
329
|
// key must be passed directly (not via spread) — forces unmount/remount on question change,
|
|
197
330
|
// resetting all component state (selected score, text, etc.)
|
|
198
|
-
const
|
|
199
|
-
const
|
|
331
|
+
const options = XeboSurveyManager_1.XeboSurveyManager.optionsFor(question);
|
|
332
|
+
const previousAnswer = XeboSurveyManager_1.XeboSurveyManager.currentAnswers.find(a => a.questionId === question.id);
|
|
333
|
+
// Options display logic may now hide an option that was restored or auto-selected.
|
|
334
|
+
const isShown = (id) => !question.optionDisplayRules || !!(options === null || options === void 0 ? void 0 : options.some(o => o.id === id));
|
|
335
|
+
const numberedQuestion = Object.assign(Object.assign({}, question), { title: (survey === null || survey === void 0 ? void 0 : survey.showQuestionNumbers) ? `${number}. ${question.title}` : question.title, options, previousAnswer: previousAnswer && Object.assign(Object.assign({}, previousAnswer), { value: previousAnswer.value.filter(v => isShown(v.rowId)) }), autoSelectOptionIds: (_a = question.autoSelectOptionIds) === null || _a === void 0 ? void 0 : _a.filter(isShown) });
|
|
336
|
+
const ref = embedded
|
|
337
|
+
? (handle) => { pageRefs.current[question.id] = handle; }
|
|
338
|
+
: undefined;
|
|
339
|
+
const commonProps = { question: numberedQuestion, isLastQuestion: isLast, onAnswer: handleAnswer, embedded, ref };
|
|
340
|
+
// On a shared page the page itself reports the height it needs.
|
|
341
|
+
const onFitHeight = embedded ? undefined : (delta) => handleFitHeight(question.id, delta);
|
|
342
|
+
// Auto-advance: picking an answer moves on, only for the types the web does it for.
|
|
343
|
+
const onSelect = embedded && survey && autoAdvances(survey, question)
|
|
344
|
+
? () => { var _a; return (_a = pageViewRef.current) === null || _a === void 0 ? void 0 : _a.scrollToNext(question.id); }
|
|
345
|
+
: undefined;
|
|
200
346
|
switch (question.type) {
|
|
201
347
|
case XeboModels_1.XeboQuestionType.singleChoice:
|
|
202
|
-
return <XeboSingleChoiceView_1.XeboSingleChoiceView key={question.id} {...commonProps}/>;
|
|
348
|
+
return <XeboSingleChoiceView_1.XeboSingleChoiceView key={question.id} {...commonProps} onFitHeight={onFitHeight} onSelect={onSelect}/>;
|
|
203
349
|
case XeboModels_1.XeboQuestionType.multipleChoice:
|
|
204
|
-
return <XeboMultipleChoiceView_1.XeboMultipleChoiceView key={question.id} {...commonProps}/>;
|
|
350
|
+
return <XeboMultipleChoiceView_1.XeboMultipleChoiceView key={question.id} {...commonProps} onFitHeight={onFitHeight}/>;
|
|
205
351
|
case XeboModels_1.XeboQuestionType.dropdown:
|
|
206
|
-
return <XeboDropdownView_1.XeboDropdownView key={question.id} {...commonProps}/>;
|
|
352
|
+
return <XeboDropdownView_1.XeboDropdownView key={question.id} {...commonProps} onSelect={onSelect}/>;
|
|
207
353
|
case XeboModels_1.XeboQuestionType.singleTextBox:
|
|
208
354
|
case XeboModels_1.XeboQuestionType.multipleTextBox:
|
|
209
355
|
return <XeboTextBoxView_1.XeboTextBoxView key={question.id} {...commonProps}/>;
|
|
210
356
|
case XeboModels_1.XeboQuestionType.nps:
|
|
211
|
-
return <XeboNPSView_1.XeboNPSView key={question.id} {...commonProps}/>;
|
|
357
|
+
return <XeboNPSView_1.XeboNPSView key={question.id} {...commonProps} onFitHeight={onFitHeight} onSelect={onSelect}/>;
|
|
212
358
|
case XeboModels_1.XeboQuestionType.multiNps:
|
|
213
359
|
return <XeboMultiNPSView_1.XeboMultiNPSView key={question.id} {...commonProps}/>;
|
|
214
360
|
case XeboModels_1.XeboQuestionType.rating:
|
|
215
|
-
return <XeboRatingView_1.XeboRatingView key={question.id} {...commonProps}/>;
|
|
361
|
+
return <XeboRatingView_1.XeboRatingView key={question.id} {...commonProps} onFitHeight={onFitHeight} onSelect={onSelect}/>;
|
|
216
362
|
case XeboModels_1.XeboQuestionType.multiRating:
|
|
217
363
|
return <XeboMultiRatingView_1.XeboMultiRatingView key={question.id} {...commonProps}/>;
|
|
218
364
|
default:
|
|
@@ -220,13 +366,26 @@ const XeboSurveyModal = () => {
|
|
|
220
366
|
}
|
|
221
367
|
};
|
|
222
368
|
const renderContent = () => {
|
|
369
|
+
var _a, _b;
|
|
370
|
+
if (screen === 'language') {
|
|
371
|
+
if (!languagePage)
|
|
372
|
+
return null;
|
|
373
|
+
return (<XeboLanguageView_1.XeboLanguageView page={languagePage} selectedLangKey={selectedLangKey} busy={languageBusy} onSelect={handleSelectLanguage}/>);
|
|
374
|
+
}
|
|
223
375
|
if (!survey)
|
|
224
376
|
return null;
|
|
225
377
|
if (screen === 'intro' && survey.introPage) {
|
|
226
378
|
return <XeboIntroView_1.XeboIntroView introPage={survey.introPage} onStart={handleIntroStart}/>;
|
|
227
379
|
}
|
|
228
380
|
if (screen === 'thankYou') {
|
|
229
|
-
const tyQuestion =
|
|
381
|
+
const tyQuestion = disqualified
|
|
382
|
+
? {
|
|
383
|
+
id: 'disqualify_auto',
|
|
384
|
+
type: XeboModels_1.XeboQuestionType.thankYou,
|
|
385
|
+
title: (_a = survey.disqualifyMessage) !== null && _a !== void 0 ? _a : 'Your profile does not fit our criteria. Thank you for your time.',
|
|
386
|
+
isRequired: false,
|
|
387
|
+
}
|
|
388
|
+
: survey.questions.find(q => q.id === 'thank_you_auto');
|
|
230
389
|
if (tyQuestion) {
|
|
231
390
|
return <XeboThankYouView_1.XeboThankYouView question={tyQuestion} onDismiss={handleSkip}/>;
|
|
232
391
|
}
|
|
@@ -235,39 +394,72 @@ const XeboSurveyModal = () => {
|
|
|
235
394
|
const question = survey.questions[questionIndex];
|
|
236
395
|
if (!question)
|
|
237
396
|
return null;
|
|
238
|
-
|
|
397
|
+
const page = XeboSurveyManager_1.XeboSurveyManager.currentPage;
|
|
398
|
+
const lastRealIndex = survey.questions.findIndex(q => q.id === 'thank_you_auto') - 1;
|
|
399
|
+
const isLast = ((_b = page[page.length - 1]) !== null && _b !== void 0 ? _b : questionIndex) === lastRealIndex;
|
|
400
|
+
// Every page, even a single question, goes through the page view so its buttons match the web.
|
|
401
|
+
return (<XeboPageView_1.XeboPageView ref={pageViewRef} key={question.id} questions={page.map((idx, n) => ({
|
|
402
|
+
id: survey.questions[idx].id,
|
|
403
|
+
view: renderQuestion(survey.questions[idx], questionNumber + n, isLast, true),
|
|
404
|
+
hidesButtons: hidesButtons(survey, survey.questions[idx]),
|
|
405
|
+
}))} isLastPage={isLast} onOk={id => { var _a, _b; return ((_b = (_a = pageRefs.current[id]) === null || _a === void 0 ? void 0 : _a.collect()) !== null && _b !== void 0 ? _b : null) !== null; }} onNext={handlePageNext} previousLabel={survey.showPrevious === false ? undefined : strings.previous} previousIconOnly={survey.previousIconOnly} canGoBack={XeboSurveyManager_1.XeboSurveyManager.canGoBack} onPreviousPage={handlePreviousPage} buttonColors={survey.buttonColors} onFitHeight={delta => handleFitHeight(question.id, delta)}/>);
|
|
239
406
|
}
|
|
240
407
|
return null;
|
|
241
408
|
};
|
|
242
409
|
// ─── 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}
|
|
410
|
+
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}
|
|
411
|
+
// Android 15+ draws edge-to-edge; without these the modal is offset by the
|
|
412
|
+
// status bar and stops short of the nav bar, so the sheet sits at the wrong height.
|
|
413
|
+
// The sheet's own bottomInset spacer keeps content clear of the nav bar.
|
|
414
|
+
statusBarTranslucent={true}
|
|
415
|
+
// RN 0.75+ prop, missing from the RN 0.73 types we build against; older RN ignores it.
|
|
416
|
+
{...{ navigationBarTranslucent: true }} propagateSwipe={false} onModalHide={() => {
|
|
244
417
|
setSurvey(null);
|
|
418
|
+
setLanguagePage(null);
|
|
419
|
+
setSelectedLangKey(null);
|
|
420
|
+
setLanguageBusy(false);
|
|
421
|
+
setDisqualified(false);
|
|
422
|
+
setFitHeight(null);
|
|
245
423
|
shiftAnim.setValue(0); // reset in case keyboard was open when modal closed
|
|
424
|
+
setAndroidKeyboardHeight(0);
|
|
425
|
+
setModalRoot({ full: 0, current: 0 });
|
|
246
426
|
}}>
|
|
247
427
|
{/* Animated.View handles ONLY the keyboard shift (transform).
|
|
248
428
|
The inner View owns height/layout so flex children compute correctly. */}
|
|
249
|
-
<react_native_1.
|
|
429
|
+
<react_native_1.View pointerEvents="none" style={react_native_1.StyleSheet.absoluteFill} onLayout={e => {
|
|
430
|
+
const h = e.nativeEvent.layout.height;
|
|
431
|
+
setModalRoot(prev => ({ full: Math.max(prev.full, h), current: h }));
|
|
432
|
+
}}/>
|
|
433
|
+
<react_native_1.Animated.View style={{ marginBottom: androidKeyboardLift - androidRootGap, transform: [{ translateY: shiftAnim }] }}>
|
|
250
434
|
<react_native_1.View style={[
|
|
251
435
|
styles.sheet,
|
|
252
436
|
{
|
|
253
437
|
backgroundColor: theme.backgroundColor,
|
|
254
438
|
height: sheetHeight,
|
|
255
439
|
},
|
|
440
|
+
strings.direction === 'rtl' && styles.sheetRtl,
|
|
256
441
|
]}>
|
|
257
442
|
{/* Handle bar */}
|
|
258
443
|
<react_native_1.View style={styles.handleWrap}>
|
|
259
444
|
<react_native_1.View style={styles.handle}/>
|
|
260
445
|
</react_native_1.View>
|
|
261
446
|
|
|
262
|
-
{/* Header row: Survey name /
|
|
447
|
+
{/* Header row: Survey name / X close on the thank-you page */}
|
|
263
448
|
<react_native_1.View style={styles.headerRow}>
|
|
264
|
-
<react_native_1.Text style={[
|
|
265
|
-
|
|
449
|
+
<react_native_1.Text style={[
|
|
450
|
+
styles.surveyName,
|
|
451
|
+
{ color: theme.textColor, fontFamily: theme.fontFamily },
|
|
452
|
+
(0, XeboRtl_1.rtlText)(),
|
|
453
|
+
]} numberOfLines={1} ellipsizeMode="tail">
|
|
454
|
+
{(_d = survey === null || survey === void 0 ? void 0 : survey.name) !== null && _d !== void 0 ? _d : ''}
|
|
266
455
|
</react_native_1.Text>
|
|
267
|
-
{screen === 'thankYou'
|
|
268
|
-
<react_native_1.Text style={[
|
|
269
|
-
|
|
270
|
-
|
|
456
|
+
{screen === 'thankYou' && (<react_native_1.TouchableOpacity onPress={handleSkip} style={styles.closeButton} activeOpacity={0.7}>
|
|
457
|
+
<react_native_1.Text style={[
|
|
458
|
+
strings.localized ? styles.skipText : styles.closeText,
|
|
459
|
+
{ color: theme.textColor },
|
|
460
|
+
]}>
|
|
461
|
+
{strings.localized ? strings.close : '✕'}
|
|
462
|
+
</react_native_1.Text>
|
|
271
463
|
</react_native_1.TouchableOpacity>)}
|
|
272
464
|
</react_native_1.View>
|
|
273
465
|
|
|
@@ -287,6 +479,9 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
287
479
|
justifyContent: 'flex-end',
|
|
288
480
|
margin: 0,
|
|
289
481
|
},
|
|
482
|
+
sheetRtl: {
|
|
483
|
+
direction: 'rtl',
|
|
484
|
+
},
|
|
290
485
|
sheet: {
|
|
291
486
|
borderTopLeftRadius: 16,
|
|
292
487
|
borderTopRightRadius: 16,
|
|
@@ -316,15 +511,14 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
316
511
|
paddingBottom: 4,
|
|
317
512
|
},
|
|
318
513
|
surveyName: {
|
|
319
|
-
flex: 1
|
|
514
|
+
// Explicit basis: `flex: 1` alone does not reliably expand a Text inside an RTL row.
|
|
515
|
+
flexGrow: 1,
|
|
516
|
+
flexShrink: 1,
|
|
517
|
+
flexBasis: 0,
|
|
320
518
|
fontSize: 13,
|
|
321
519
|
fontWeight: '600',
|
|
322
520
|
opacity: 0.5,
|
|
323
|
-
|
|
324
|
-
},
|
|
325
|
-
skipButton: {
|
|
326
|
-
paddingHorizontal: 12,
|
|
327
|
-
paddingVertical: 6,
|
|
521
|
+
marginEnd: 8,
|
|
328
522
|
},
|
|
329
523
|
skipText: {
|
|
330
524
|
fontSize: 14,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { XeboQuestion, XeboAnswer } from '../models/XeboModels';
|
|
2
|
+
import { XeboQuestion, XeboAnswer, XeboQuestionHandle } from '../models/XeboModels';
|
|
3
3
|
interface Props {
|
|
4
4
|
question: XeboQuestion;
|
|
5
5
|
isLastQuestion: boolean;
|
|
6
6
|
onAnswer: (answer: XeboAnswer) => void;
|
|
7
|
+
/** Shown with other questions on one page: no own button, sized to content. */
|
|
8
|
+
embedded?: boolean;
|
|
7
9
|
}
|
|
8
|
-
export declare const XeboTextBoxView: React.
|
|
10
|
+
export declare const XeboTextBoxView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
|
|
9
11
|
export {};
|
|
10
12
|
//# sourceMappingURL=XeboTextBoxView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XeboTextBoxView.d.ts","sourceRoot":"","sources":["../../src/components/XeboTextBoxView.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"XeboTextBoxView.d.ts","sourceRoot":"","sources":["../../src/components/XeboTextBoxView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAWjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAKtG,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,kFAkI1B,CAAC"}
|
|
@@ -38,11 +38,16 @@ 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
|
|
41
|
+
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
42
|
+
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
43
|
+
exports.XeboTextBoxView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, embedded }, ref) => {
|
|
42
44
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
43
45
|
const isMulti = question.type === XeboModels_1.XeboQuestionType.multipleTextBox;
|
|
44
46
|
const fields = question.options && question.options.length > 0 ? question.options : [{ id: 'default', text: '', value: '' }];
|
|
45
|
-
const [values, setValues] = (0, react_1.useState)({
|
|
47
|
+
const [values, setValues] = (0, react_1.useState)(() => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
return ((_b = (_a = question.previousAnswer) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : []).reduce((acc, v) => { var _a; return (Object.assign(Object.assign({}, acc), { [v.rowId]: (_a = v.text) !== null && _a !== void 0 ? _a : '' })); }, {});
|
|
50
|
+
});
|
|
46
51
|
const [error, setError] = (0, react_1.useState)('');
|
|
47
52
|
const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
48
53
|
const scrollRef = (0, react_1.useRef)(null);
|
|
@@ -65,36 +70,42 @@ const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
65
70
|
setValues(prev => (Object.assign(Object.assign({}, prev), { [fieldId]: text })));
|
|
66
71
|
setError('');
|
|
67
72
|
};
|
|
68
|
-
const
|
|
73
|
+
const collect = () => {
|
|
69
74
|
if (question.isRequired) {
|
|
70
75
|
const empty = fields.some(f => { var _a; return !((_a = values[f.id]) !== null && _a !== void 0 ? _a : '').trim(); });
|
|
71
76
|
if (empty) {
|
|
72
|
-
setError('Please fill in all fields.');
|
|
77
|
+
setError((0, XeboStrings_1.requiredMessage)(question, 'Please fill in all fields.'));
|
|
73
78
|
shake();
|
|
74
|
-
return;
|
|
79
|
+
return null;
|
|
75
80
|
}
|
|
76
81
|
}
|
|
77
82
|
react_native_1.Keyboard.dismiss();
|
|
78
|
-
|
|
83
|
+
return {
|
|
79
84
|
questionId: question.id,
|
|
80
85
|
value: fields
|
|
81
86
|
.filter(f => { var _a; return ((_a = values[f.id]) !== null && _a !== void 0 ? _a : '').trim(); })
|
|
82
87
|
.map(f => { var _a; return ({ rowId: f.id, text: (_a = values[f.id]) !== null && _a !== void 0 ? _a : '' }); }),
|
|
83
|
-
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
(0, react_1.useImperativeHandle)(ref, () => ({ collect }));
|
|
91
|
+
const handleSubmit = () => {
|
|
92
|
+
const answer = collect();
|
|
93
|
+
if (answer)
|
|
94
|
+
onAnswer(answer);
|
|
84
95
|
};
|
|
85
96
|
return (<react_native_1.View style={styles.outer}>
|
|
86
|
-
<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 }]}>
|
|
97
|
+
<react_native_1.ScrollView ref={scrollRef} style={[styles.scroll, embedded && styles.embeddedScroll]} scrollEnabled={!embedded} contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
|
|
98
|
+
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
88
99
|
{question.title}
|
|
89
100
|
</react_native_1.Text>
|
|
90
|
-
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
101
|
+
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
91
102
|
{question.subtitle}
|
|
92
103
|
</react_native_1.Text>)}
|
|
93
104
|
|
|
94
105
|
{fields.map((field, idx) => {
|
|
95
106
|
var _a;
|
|
96
107
|
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 }]}>
|
|
108
|
+
{isMulti && !!field.text && (<react_native_1.Text style={[styles.fieldLabel, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
98
109
|
{field.text}
|
|
99
110
|
</react_native_1.Text>)}
|
|
100
111
|
<react_native_1.TextInput style={[
|
|
@@ -106,31 +117,32 @@ const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
106
117
|
borderRadius: theme.cornerRadius,
|
|
107
118
|
minHeight: 48,
|
|
108
119
|
},
|
|
109
|
-
|
|
120
|
+
(0, XeboRtl_1.rtlInput)(),
|
|
121
|
+
]} placeholder={isMulti ? question.placeholder : (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
122
|
</react_native_1.View>);
|
|
111
123
|
})}
|
|
112
124
|
</react_native_1.ScrollView>
|
|
113
125
|
|
|
114
126
|
{/* Error + button always visible at bottom, outside scroll */}
|
|
115
|
-
{!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
|
|
116
|
-
<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
{!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
|
|
128
|
+
{!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
129
|
+
<react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleSubmit} activeOpacity={0.8}>
|
|
130
|
+
<react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
|
|
131
|
+
{(0, XeboStrings_1.actionLabel)(isLastQuestion)}
|
|
132
|
+
</react_native_1.Text>
|
|
133
|
+
</react_native_1.TouchableOpacity>
|
|
134
|
+
</react_native_1.Animated.View>)}
|
|
123
135
|
</react_native_1.View>);
|
|
124
|
-
};
|
|
125
|
-
exports.XeboTextBoxView = XeboTextBoxView;
|
|
136
|
+
});
|
|
126
137
|
const styles = react_native_1.StyleSheet.create({
|
|
127
138
|
outer: {
|
|
128
139
|
paddingHorizontal: 20,
|
|
129
|
-
paddingBottom:
|
|
140
|
+
paddingBottom: 10,
|
|
130
141
|
},
|
|
131
142
|
scroll: {
|
|
132
143
|
maxHeight: 340,
|
|
133
144
|
},
|
|
145
|
+
embeddedScroll: { maxHeight: undefined },
|
|
134
146
|
scrollContent: {
|
|
135
147
|
paddingTop: 16,
|
|
136
148
|
paddingBottom: 8,
|
|
@@ -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;
|
|
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"}
|